Skip to content

Commit 5aaf8ac

Browse files
authored
feat: create Infra.Ci.Is and Infra.Ci.IsNot extensions (#5019)
1 parent 0ad9c1c commit 5aaf8ac

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

packages/project-aws/src/infra.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { OpenSearch } from "./extensions/OpenSearch.js";
3535
import { AwsDefaultRegion } from "./extensions/AwsDefaultRegion.js";
3636
import { ApiLambdaFunction } from "./extensions/ApiLambdaFunction.js";
3737
import { EnvVar } from "@webiny/project/extensions/index.js";
38-
import { EnvIs, EnvIsNot } from "@webiny/project/extensions/infra/index.js";
38+
import { EnvIs, EnvIsNot, CiIs, CiIsNot } from "@webiny/project/extensions/infra/index.js";
3939

4040
export const Infra = {
4141
Vpc,
@@ -52,6 +52,10 @@ export const Infra = {
5252
Is: EnvIs,
5353
IsNot: EnvIsNot
5454
},
55+
Ci: {
56+
Is: CiIs,
57+
IsNot: CiIsNot
58+
},
5559
Admin: {
5660
BeforeBuild: AdminBeforeBuild,
5761
BeforeDeploy: AdminBeforeDeploy,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from "react";
2+
import { isCI } from "ci-info";
3+
4+
export interface CiIsProps {
5+
children: React.ReactNode;
6+
}
7+
8+
/**
9+
* Conditionally renders children when running in a CI environment.
10+
* Uses the `ci-info` library to detect CI environments.
11+
*/
12+
export const CiIs: React.FC<CiIsProps> = ({ children }) => {
13+
if (!isCI) {
14+
return null;
15+
}
16+
17+
return <>{children}</>;
18+
};
19+
20+
/**
21+
* Conditionally renders children when NOT running in a CI environment.
22+
* Uses the `ci-info` library to detect CI environments.
23+
*/
24+
export const CiIsNot: React.FC<CiIsProps> = ({ children }) => {
25+
if (isCI) {
26+
return null;
27+
}
28+
29+
return <>{children}</>;
30+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./Env.js";
2+
export * from "./Ci.js";

0 commit comments

Comments
 (0)