@powerlines/plugin-env 0.14.27 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -440,7 +440,124 @@ function EnvBuiltin(props) {
440
440
  get initializer() {
441
441
  return [__alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
442
442
  }
443
- })
443
+ }),
444
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
445
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
446
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
447
+ "export": true,
448
+ "const": true,
449
+ name: "isCI",
450
+ doc: "Detect if the application is running in a CI environment.",
451
+ initializer: __alloy_js_core.code`Boolean(
452
+ env.CI ||
453
+ env.RUN_ID ||
454
+ env.AGOLA_GIT_REF ||
455
+ env.AC_APPCIRCLE ||
456
+ env.APPVEYOR ||
457
+ env.CODEBUILD ||
458
+ env.TF_BUILD ||
459
+ env.bamboo_planKey ||
460
+ env.BITBUCKET_COMMIT ||
461
+ env.BITRISE_IO ||
462
+ env.BUDDY_WORKSPACE_ID ||
463
+ env.BUILDKITE ||
464
+ env.CIRCLECI ||
465
+ env.CIRRUS_CI ||
466
+ env.CF_BUILD_ID ||
467
+ env.CM_BUILD_ID ||
468
+ env.CI_NAME ||
469
+ env.DRONE ||
470
+ env.DSARI ||
471
+ env.EARTHLY_CI ||
472
+ env.EAS_BUILD ||
473
+ env.GERRIT_PROJECT ||
474
+ env.GITEA_ACTIONS ||
475
+ env.GITHUB_ACTIONS ||
476
+ env.GITLAB_CI ||
477
+ env.GOCD ||
478
+ env.BUILDER_OUTPUT ||
479
+ env.HARNESS_BUILD_ID ||
480
+ env.JENKINS_URL ||
481
+ env.LAYERCI ||
482
+ env.MAGNUM ||
483
+ env.NETLIFY ||
484
+ env.NEVERCODE ||
485
+ env.PROW_JOB_ID ||
486
+ env.RELEASE_BUILD_ID ||
487
+ env.RENDER ||
488
+ env.SAILCI ||
489
+ env.HUDSON ||
490
+ env.SCREWDRIVER ||
491
+ env.SEMAPHORE ||
492
+ env.SOURCEHUT ||
493
+ env.STRIDER ||
494
+ env.TASK_ID ||
495
+ env.RUN_ID ||
496
+ env.TEAMCITY_VERSION ||
497
+ env.TRAVIS ||
498
+ env.VELA ||
499
+ env.NOW_BUILDER ||
500
+ env.APPCENTER_BUILD_ID ||
501
+ env.CI_XCODE_PROJECT ||
502
+ env.XCS || false
503
+ );
504
+ `
505
+ }),
506
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
507
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
508
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDoc, {
509
+ heading: "Detect the \\`mode\\` of the current runtime environment.",
510
+ get children() {
511
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocRemarks, { children: __alloy_js_core.code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, Storm Software generally only allows a value in the following list:
512
+ - \`production\`
513
+ - \`test\`
514
+ - \`development\`` });
515
+ }
516
+ }),
517
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
518
+ "export": true,
519
+ "const": true,
520
+ name: "mode",
521
+ initializer: __alloy_js_core.code`String(env.MODE) || "production"; `
522
+ }),
523
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
524
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
525
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
526
+ "export": true,
527
+ "const": true,
528
+ name: "isProduction",
529
+ doc: "Detect if the application is running in \\\"production\\\\\" mode",
530
+ initializer: __alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
531
+ }),
532
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
533
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
534
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
535
+ "export": true,
536
+ "const": true,
537
+ name: "isTest",
538
+ doc: "Detect if the application is running in \"test\" mode",
539
+ initializer: __alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
540
+ }),
541
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
542
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
543
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
544
+ "export": true,
545
+ "const": true,
546
+ name: "isDevelopment",
547
+ doc: "Detect if the application is running in \"development\" mode",
548
+ initializer: __alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `
549
+ }),
550
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
551
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
552
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
553
+ "export": true,
554
+ "const": true,
555
+ name: "isDebug",
556
+ doc: "Detect if the application is running in \"debug\" mode",
557
+ initializer: __alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `
558
+ }),
559
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
560
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
444
561
  ];
445
562
  }
446
563
  }));
@@ -438,7 +438,124 @@ function EnvBuiltin(props) {
438
438
  get initializer() {
439
439
  return [code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
440
440
  }
441
- })
441
+ }),
442
+ createIntrinsic("hbr", {}),
443
+ createIntrinsic("hbr", {}),
444
+ createComponent(VarDeclaration, {
445
+ "export": true,
446
+ "const": true,
447
+ name: "isCI",
448
+ doc: "Detect if the application is running in a CI environment.",
449
+ initializer: code`Boolean(
450
+ env.CI ||
451
+ env.RUN_ID ||
452
+ env.AGOLA_GIT_REF ||
453
+ env.AC_APPCIRCLE ||
454
+ env.APPVEYOR ||
455
+ env.CODEBUILD ||
456
+ env.TF_BUILD ||
457
+ env.bamboo_planKey ||
458
+ env.BITBUCKET_COMMIT ||
459
+ env.BITRISE_IO ||
460
+ env.BUDDY_WORKSPACE_ID ||
461
+ env.BUILDKITE ||
462
+ env.CIRCLECI ||
463
+ env.CIRRUS_CI ||
464
+ env.CF_BUILD_ID ||
465
+ env.CM_BUILD_ID ||
466
+ env.CI_NAME ||
467
+ env.DRONE ||
468
+ env.DSARI ||
469
+ env.EARTHLY_CI ||
470
+ env.EAS_BUILD ||
471
+ env.GERRIT_PROJECT ||
472
+ env.GITEA_ACTIONS ||
473
+ env.GITHUB_ACTIONS ||
474
+ env.GITLAB_CI ||
475
+ env.GOCD ||
476
+ env.BUILDER_OUTPUT ||
477
+ env.HARNESS_BUILD_ID ||
478
+ env.JENKINS_URL ||
479
+ env.LAYERCI ||
480
+ env.MAGNUM ||
481
+ env.NETLIFY ||
482
+ env.NEVERCODE ||
483
+ env.PROW_JOB_ID ||
484
+ env.RELEASE_BUILD_ID ||
485
+ env.RENDER ||
486
+ env.SAILCI ||
487
+ env.HUDSON ||
488
+ env.SCREWDRIVER ||
489
+ env.SEMAPHORE ||
490
+ env.SOURCEHUT ||
491
+ env.STRIDER ||
492
+ env.TASK_ID ||
493
+ env.RUN_ID ||
494
+ env.TEAMCITY_VERSION ||
495
+ env.TRAVIS ||
496
+ env.VELA ||
497
+ env.NOW_BUILDER ||
498
+ env.APPCENTER_BUILD_ID ||
499
+ env.CI_XCODE_PROJECT ||
500
+ env.XCS || false
501
+ );
502
+ `
503
+ }),
504
+ createIntrinsic("hbr", {}),
505
+ createIntrinsic("hbr", {}),
506
+ createComponent(TSDoc, {
507
+ heading: "Detect the \\`mode\\` of the current runtime environment.",
508
+ get children() {
509
+ return createComponent(TSDocRemarks, { children: code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, Storm Software generally only allows a value in the following list:
510
+ - \`production\`
511
+ - \`test\`
512
+ - \`development\`` });
513
+ }
514
+ }),
515
+ createComponent(VarDeclaration, {
516
+ "export": true,
517
+ "const": true,
518
+ name: "mode",
519
+ initializer: code`String(env.MODE) || "production"; `
520
+ }),
521
+ createIntrinsic("hbr", {}),
522
+ createIntrinsic("hbr", {}),
523
+ createComponent(VarDeclaration, {
524
+ "export": true,
525
+ "const": true,
526
+ name: "isProduction",
527
+ doc: "Detect if the application is running in \\\"production\\\\\" mode",
528
+ initializer: code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
529
+ }),
530
+ createIntrinsic("hbr", {}),
531
+ createIntrinsic("hbr", {}),
532
+ createComponent(VarDeclaration, {
533
+ "export": true,
534
+ "const": true,
535
+ name: "isTest",
536
+ doc: "Detect if the application is running in \"test\" mode",
537
+ initializer: code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
538
+ }),
539
+ createIntrinsic("hbr", {}),
540
+ createIntrinsic("hbr", {}),
541
+ createComponent(VarDeclaration, {
542
+ "export": true,
543
+ "const": true,
544
+ name: "isDevelopment",
545
+ doc: "Detect if the application is running in \"development\" mode",
546
+ initializer: code`["dev", "development"].includes(mode.toLowerCase()); `
547
+ }),
548
+ createIntrinsic("hbr", {}),
549
+ createIntrinsic("hbr", {}),
550
+ createComponent(VarDeclaration, {
551
+ "export": true,
552
+ "const": true,
553
+ name: "isDebug",
554
+ doc: "Detect if the application is running in \"debug\" mode",
555
+ initializer: code`Boolean(isDevelopment && env.DEBUG); `
556
+ }),
557
+ createIntrinsic("hbr", {}),
558
+ createIntrinsic("hbr", {})
442
559
  ];
443
560
  }
444
561
  }));
@@ -14,6 +14,9 @@ interface TypescriptFileImportItem {
14
14
  alias?: string;
15
15
  type?: boolean;
16
16
  }
17
- type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
17
+ type TypescriptFileImportList = Record<string, null | Array<TypescriptFileImportItem | string>>;
18
+ type TypescriptFileImports = TypescriptFileImportList & {
19
+ $builtins?: TypescriptFileImportList;
20
+ };
18
21
  //#endregion
19
22
  export { ComponentProps, TypescriptFileImports };
@@ -17,6 +17,9 @@ interface TypescriptFileImportItem {
17
17
  alias?: string;
18
18
  type?: boolean;
19
19
  }
20
- type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
20
+ type TypescriptFileImportList = Record<string, null | Array<TypescriptFileImportItem | string>>;
21
+ type TypescriptFileImports = TypescriptFileImportList & {
22
+ $builtins?: TypescriptFileImportList;
23
+ };
21
24
  //#endregion
22
- export { ComponentProps, TypescriptFileImportItem, TypescriptFileImports };
25
+ export { ComponentProps, TypescriptFileImportItem, TypescriptFileImportList, TypescriptFileImports };
@@ -1,2 +1,2 @@
1
- import { ComponentProps, TypescriptFileImportItem, TypescriptFileImports } from "./components.mjs";
1
+ import { ComponentProps, TypescriptFileImportItem, TypescriptFileImportList, TypescriptFileImports } from "./components.mjs";
2
2
  import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "./plugin.mjs";
@@ -153,6 +153,7 @@ function TypescriptFileHeader(props) {
153
153
  */
154
154
  function TypescriptFileHeaderImports(props) {
155
155
  const { imports } = props;
156
+ const context = require_context.usePowerlines();
156
157
  const sourceFile = (0, __alloy_js_typescript.useSourceFile)();
157
158
  const scope = props.scope ?? sourceFile.scope;
158
159
  return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
@@ -166,7 +167,7 @@ function TypescriptFileHeaderImports(props) {
166
167
  return !!imports && Object.keys(imports).length > 0;
167
168
  },
168
169
  get children() {
169
- return Object.entries(imports ?? {}).map(([module$1, imported]) => {
170
+ return Object.entries(imports ?? {}).filter(([key]) => key !== "$builtins").concat(imports && imports.$builtins ? Object.entries(imports.$builtins).map(([key, entry]) => [key.includes(":") ? key : `${context.config.output.builtinPrefix}:${key}`, entry]) : []).map(([module$1, imported]) => {
170
171
  return __alloy_js_core.code`import ${imported === null ? "" : imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${imported.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module$1}";`;
171
172
  });
172
173
  }
@@ -152,6 +152,7 @@ function TypescriptFileHeader(props) {
152
152
  */
153
153
  function TypescriptFileHeaderImports(props) {
154
154
  const { imports } = props;
155
+ const context = usePowerlines();
155
156
  const sourceFile = useSourceFile();
156
157
  const scope = props.scope ?? sourceFile.scope;
157
158
  return createComponent(Show, {
@@ -165,7 +166,7 @@ function TypescriptFileHeaderImports(props) {
165
166
  return !!imports && Object.keys(imports).length > 0;
166
167
  },
167
168
  get children() {
168
- return Object.entries(imports ?? {}).map(([module, imported]) => {
169
+ return Object.entries(imports ?? {}).filter(([key]) => key !== "$builtins").concat(imports && imports.$builtins ? Object.entries(imports.$builtins).map(([key, entry]) => [key.includes(":") ? key : `${context.config.output.builtinPrefix}:${key}`, entry]) : []).map(([module, imported]) => {
169
170
  return code`import ${imported === null ? "" : imported.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !isString(i) && i.default).length > 0 && imported.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${imported.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module}";`;
170
171
  });
171
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-env",
3
- "version": "0.14.27",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
6
6
  "repository": {
@@ -194,7 +194,7 @@
194
194
  "@babel/core": "^7.28.5",
195
195
  "@babel/types": "^7.28.5",
196
196
  "@powerlines/deepkit": "^0.5.36",
197
- "@powerlines/plugin-alloy": "^0.17.6",
197
+ "@powerlines/plugin-alloy": "^0.18.0",
198
198
  "@powerlines/plugin-automd": "^0.1.121",
199
199
  "@powerlines/plugin-babel": "^0.12.130",
200
200
  "@powerlines/plugin-plugin": "^0.12.73",
@@ -211,5 +211,5 @@
211
211
  },
212
212
  "devDependencies": { "@types/node": "^24.10.4", "vite": "8.0.0-beta.2" },
213
213
  "publishConfig": { "access": "public" },
214
- "gitHead": "f27028746c0657470a2c93af2e3224565ae7fd61"
214
+ "gitHead": "b9a0574767447bffa6549e0492812dfe64e879e3"
215
215
  }