@powerlines/plugin-env 0.16.240 → 0.16.250
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.
- package/dist/babel/plugin.cjs +8 -10
- package/dist/babel/plugin.d.cts.map +1 -1
- package/dist/babel/plugin.d.mts.map +1 -1
- package/dist/babel/plugin.mjs +9 -10
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +14 -11
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +15 -11
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +19 -22
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.mjs +19 -21
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/automd-generator.cjs +0 -1
- package/dist/helpers/index.cjs +2 -4
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/load.cjs +1 -1
- package/dist/helpers/load.d.cts +3 -3
- package/dist/helpers/load.d.mts +3 -3
- package/dist/helpers/load.mjs +1 -1
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/schema.cjs +24 -75
- package/dist/helpers/schema.d.cts +2 -16
- package/dist/helpers/schema.d.cts.map +1 -1
- package/dist/helpers/schema.d.mts +2 -16
- package/dist/helpers/schema.d.mts.map +1 -1
- package/dist/helpers/schema.mjs +25 -74
- package/dist/helpers/schema.mjs.map +1 -1
- package/dist/helpers/source-file-env.cjs +0 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/dist/types/plugin.cjs +12 -14
- package/dist/types/plugin.d.cts +14 -8
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +14 -8
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +12 -14
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +11 -11
|
@@ -72,7 +72,7 @@ function EnvTypeDefinition() {
|
|
|
72
72
|
get children() {
|
|
73
73
|
return __assignType((prefix) => createComponent(For, {
|
|
74
74
|
get each() {
|
|
75
|
-
return getPropertiesList(context.env.vars.schema).filter(__assignType((property) => !property
|
|
75
|
+
return getPropertiesList(context.env.vars.schema).filter(__assignType((property) => !property?.isIgnored, [
|
|
76
76
|
"property",
|
|
77
77
|
"",
|
|
78
78
|
"P\"2!\"/\""
|
|
@@ -82,13 +82,13 @@ function EnvTypeDefinition() {
|
|
|
82
82
|
get children() {
|
|
83
83
|
return __assignType((property) => [createComponent(TSDocSchemaProperty, { schema: property }), createComponent(InterfaceMember, {
|
|
84
84
|
get name() {
|
|
85
|
-
return `${prefix}_${property
|
|
85
|
+
return `${prefix}_${property?.name}`;
|
|
86
86
|
},
|
|
87
87
|
get type() {
|
|
88
|
-
return `UnprefixedEnv["${property
|
|
88
|
+
return `UnprefixedEnv["${property?.name}"]`;
|
|
89
89
|
},
|
|
90
|
-
get
|
|
91
|
-
return property
|
|
90
|
+
get readOnly() {
|
|
91
|
+
return property?.readOnly;
|
|
92
92
|
}
|
|
93
93
|
})], [
|
|
94
94
|
"property",
|
|
@@ -162,12 +162,12 @@ function ConfigPropertyGet(props) {
|
|
|
162
162
|
context
|
|
163
163
|
}), createComponent(Show, {
|
|
164
164
|
get when() {
|
|
165
|
-
return property
|
|
165
|
+
return property?.alias && property?.alias.length > 0;
|
|
166
166
|
},
|
|
167
167
|
get children() {
|
|
168
168
|
return [code` || `, createComponent(For, {
|
|
169
169
|
get each() {
|
|
170
|
-
return property
|
|
170
|
+
return property?.alias ?? [];
|
|
171
171
|
},
|
|
172
172
|
joiner: code` || `,
|
|
173
173
|
get children() {
|
|
@@ -192,12 +192,12 @@ function ConfigPropertyGet(props) {
|
|
|
192
192
|
context
|
|
193
193
|
}), createComponent(Show, {
|
|
194
194
|
get when() {
|
|
195
|
-
return property
|
|
195
|
+
return property?.alias && property?.alias.length > 0;
|
|
196
196
|
},
|
|
197
197
|
get children() {
|
|
198
198
|
return [code` || `, createComponent(For, {
|
|
199
199
|
get each() {
|
|
200
|
-
return property
|
|
200
|
+
return property?.alias ?? [];
|
|
201
201
|
},
|
|
202
202
|
joiner: code` || `,
|
|
203
203
|
get children() {
|
|
@@ -237,12 +237,12 @@ function ConfigPropertySet(props) {
|
|
|
237
237
|
context
|
|
238
238
|
}), createComponent(Show, {
|
|
239
239
|
get when() {
|
|
240
|
-
return property
|
|
240
|
+
return property?.alias && property?.alias.length > 0;
|
|
241
241
|
},
|
|
242
242
|
get children() {
|
|
243
243
|
return [code` || `, createComponent(For, {
|
|
244
244
|
get each() {
|
|
245
|
-
return property
|
|
245
|
+
return property?.alias ?? [];
|
|
246
246
|
},
|
|
247
247
|
joiner: code` || `,
|
|
248
248
|
get children() {
|
|
@@ -270,12 +270,12 @@ function ConfigPropertySet(props) {
|
|
|
270
270
|
context
|
|
271
271
|
}), createComponent(Show, {
|
|
272
272
|
get when() {
|
|
273
|
-
return property
|
|
273
|
+
return property?.alias && property?.alias.length > 0;
|
|
274
274
|
},
|
|
275
275
|
get children() {
|
|
276
276
|
return [code` || `, createComponent(For, {
|
|
277
277
|
get each() {
|
|
278
|
-
return property
|
|
278
|
+
return property?.alias ?? [];
|
|
279
279
|
},
|
|
280
280
|
joiner: code` || `,
|
|
281
281
|
get children() {
|
|
@@ -321,21 +321,21 @@ function EnvBuiltin(props) {
|
|
|
321
321
|
const [{ defaultConfig, children }, rest] = splitProps(props, ["defaultConfig", "children"]);
|
|
322
322
|
const context = (usePowerlines.Ω = [["EnvPluginContext", "\"w!"]], usePowerlines());
|
|
323
323
|
const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
|
|
324
|
-
const reflectionGetProperties = computed(() => getPropertiesList(context.env.vars.schema).filter(__assignType((property) => !property
|
|
324
|
+
const reflectionGetProperties = computed(() => getPropertiesList(context.env.vars.schema).filter(__assignType((property) => !property?.isIgnored, [
|
|
325
325
|
"property",
|
|
326
326
|
"",
|
|
327
327
|
"P\"2!\"/\""
|
|
328
|
-
])).sort(__assignType((a, b) => !a
|
|
328
|
+
])).sort(__assignType((a, b) => !a?.name && !b?.name ? 0 : !a?.name ? 1 : !b?.name ? -1 : a?.name.localeCompare(b?.name), [
|
|
329
329
|
"a",
|
|
330
330
|
"b",
|
|
331
331
|
"",
|
|
332
332
|
"P\"2!\"2\"\"/#"
|
|
333
333
|
])) ?? []);
|
|
334
|
-
const reflectionSetProperties = computed(() => getPropertiesList(context.env.vars.schema).filter(__assignType((property) => !property
|
|
334
|
+
const reflectionSetProperties = computed(() => getPropertiesList(context.env.vars.schema).filter(__assignType((property) => !property?.isIgnored && !property?.readOnly, [
|
|
335
335
|
"property",
|
|
336
336
|
"",
|
|
337
337
|
"P\"2!\"/\""
|
|
338
|
-
])).sort(__assignType((a, b) => !a
|
|
338
|
+
])).sort(__assignType((a, b) => !a?.name && !b?.name ? 0 : !a?.name ? 1 : !b?.name ? -1 : a?.name.localeCompare(b?.name), [
|
|
339
339
|
"a",
|
|
340
340
|
"b",
|
|
341
341
|
"",
|
|
@@ -419,11 +419,10 @@ function EnvBuiltin(props) {
|
|
|
419
419
|
},
|
|
420
420
|
property
|
|
421
421
|
}), [
|
|
422
|
-
"name",
|
|
423
422
|
"property",
|
|
424
423
|
"index",
|
|
425
424
|
"",
|
|
426
|
-
"
|
|
425
|
+
"P!2!'2\"\"/#"
|
|
427
426
|
]);
|
|
428
427
|
}
|
|
429
428
|
}),
|
|
@@ -447,11 +446,10 @@ function EnvBuiltin(props) {
|
|
|
447
446
|
},
|
|
448
447
|
property
|
|
449
448
|
}), [
|
|
450
|
-
"name",
|
|
451
449
|
"property",
|
|
452
450
|
"index",
|
|
453
451
|
"",
|
|
454
|
-
"
|
|
452
|
+
"P!2!'2\"\"/#"
|
|
455
453
|
]);
|
|
456
454
|
}
|
|
457
455
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.mjs","names":[],"sources":["../../src/components/env-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n code,\n computed,\n For,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n InterfaceDeclaration as BaseInterfaceDeclaration,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport type { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps,\n InterfaceDeclaration,\n InterfaceMember,\n ObjectDeclaration,\n TSDocSchemaProperty\n} from \"@powerlines/plugin-alloy/typescript/components\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { JTDSchemaType } from \"@powerlines/schema\";\nimport { getPropertiesList } from \"@powerlines/schema/helpers\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport type { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition() {\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\"UnprefixedEnv\"\n schema={context.env.vars.schema}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`UnprefixedEnv\\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}\n </TSDocRemarks>\n </TSDoc>\n <BaseInterfaceDeclaration name=\"Env\" export extends=\"UnprefixedEnv\">\n <For\n each={getUnique(context.config.env.prefix).map(prefix =>\n prefix.replace(/_$/, \"\")\n )}\n doubleHardline>\n {prefix => (\n <For\n each={\n getPropertiesList(context.env.vars.schema).filter(\n property => !property.metadata?.isIgnored\n ) ?? []\n }\n doubleHardline>\n {property => (\n <>\n <TSDocSchemaProperty schema={property} />\n <InterfaceMember\n name={`${prefix}_${property.metadata?.name}`}\n type={`UnprefixedEnv[\"${property.metadata?.name}\"]`}\n isReadonly={property.metadata?.isReadonly}\n />\n </>\n )}\n </For>\n )}\n </For>\n </BaseInterfaceDeclaration>\n <Spacing />\n </>\n );\n}\n\ninterface ConfigPropertyConditionalProps extends ComponentProps {\n context: EnvPluginContext;\n name: string;\n}\n\nfunction ConfigPropertyConditional(props: ConfigPropertyConditionalProps) {\n const [{ context, name }] = splitProps(props, [\"context\", \"name\"]);\n\n return code`propertyName === \"${name}\" || propertyName.replace(/^(${getUnique(\n context.config.env.prefix\n .sort((a, b) =>\n a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)\n )\n .map(prefix => `${prefix.replace(/_$/, \"\")}_`)\n ).join(\"|\")})/g, \"\").toLowerCase().replace(/[\\\\s\\\\-_]+/g, \"\") === \"${name\n .toLowerCase()\n .replace(/[\\s\\-_]+/g, \"\")}\"`;\n}\n\ninterface ConfigPropertyProps extends ComponentProps {\n index: number;\n context: EnvPluginContext;\n name: string;\n property: JTDSchemaType;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show\n when={\n property.metadata?.alias &&\n property.metadata?.alias.length > 0\n }>\n {code` || `}\n <For each={property.metadata?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show\n when={\n property.metadata?.alias &&\n property.metadata?.alias.length > 0\n }>\n {code` || `}\n <For each={property.metadata?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show\n when={\n property.metadata?.alias &&\n property.metadata?.alias.length > 0\n }>\n {code` || `}\n <For each={property.metadata?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show\n when={\n property.metadata?.alias &&\n property.metadata?.alias.length > 0\n }>\n {code` || `}\n <For each={property.metadata?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const reflectionGetProperties = computed(\n () =>\n getPropertiesList(context.env.vars.schema)\n .filter(property => !property.metadata?.isIgnored)\n .sort((a, b) =>\n !a.metadata?.name && !b.metadata?.name\n ? 0\n : !a.metadata?.name\n ? 1\n : !b.metadata?.name\n ? -1\n : a.metadata?.name.localeCompare(b.metadata?.name)\n ) ?? []\n );\n const reflectionSetProperties = computed(\n () =>\n getPropertiesList(context.env.vars.schema)\n .filter(\n property =>\n !property.metadata?.isIgnored && !property.metadata?.isReadonly\n )\n .sort((a, b) =>\n !a.metadata?.name && !b.metadata?.name\n ? 0\n : !a.metadata?.name\n ? 1\n : !b.metadata?.name\n ? -1\n : a.metadata?.name.localeCompare(b.metadata?.name)\n ) ?? []\n );\n\n return (\n <BuiltinFile\n id=\"env\"\n description=\"The environment configuration module provides an interface to define environment configuration parameters.\"\n {...rest}>\n <Show when={Boolean(context.env.vars.schema)}>\n <EnvTypeDefinition defaultValue={defaultValue} />\n <Spacing />\n </Show>\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<Env>\"\n schema={context.env.vars.schema}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\n <TSDoc heading=\"Initializes the Powerlines environment configuration module.\">\n <TSDocRemarks>\n {`This function initializes the Powerlines environment configuration object.`}\n </TSDocRemarks>\n <TSDocParam name=\"environmentConfig\">\n {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}\n </TSDocParam>\n <TSDocReturns>\n {`The initialized Powerlines configuration object.`}\n </TSDocReturns>\n </TSDoc>\n <Show when={Boolean(context?.entryPath)}>\n <FunctionDeclaration\n refkey={createEnvRefkey}\n async={false}\n export\n name=\"createEnv\"\n parameters={[\n {\n name: \"environmentConfig\",\n type: `Partial<Env>`,\n optional: false,\n default: \"{}\"\n }\n ]}\n returnType=\"Env\">\n {code`\n return new Proxy<Env>(\n deserializeEnv({\n ...initialEnv,\n ...environmentConfig\n } as Env),\n {\n get: (target: UnprefixedEnv, propertyName: string) => { `}\n <hbr />\n <For each={reflectionGetProperties.value}>\n {(property: JTDSchemaType & { name: string }, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n name={property.name}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `}\n <hbr />\n <For each={reflectionSetProperties.value} ender={code` else `}>\n {(property: JTDSchemaType & { name: string }, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n name={property.name}\n property={property}\n />\n )}\n </For>\n\n <hbr />\n {code`return false;\n }\n }\n );\n`}\n </FunctionDeclaration>\n </Show>\n <Spacing />\n <TSDoc heading=\"The environment configuration object.\">\n <TSDocRemarks>\n {`This object provides access to the environment configuration parameters in the application runtime.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n refkey={envRefkey}\n name=\"env\"\n type=\"Env\"\n export\n const\n initializer={\n <>{code`createEnv(${defaultConfig || \"{}\"} as Partial<Env>);`}</>\n }\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isCI\"\n doc=\"Detect if the application is running in a continuous integration (CI) environment.\"\n initializer={code`Boolean(\n env.CI ||\n env.RUN_ID ||\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS || false\n ); `}\n />\n <Spacing />\n\n <TSDoc heading=\"Detect the \\`mode\\` of the current runtime environment.\">\n <TSDocRemarks>\n {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, it is generally recommended to only allow a value in the following list:\n - \\`production\\`\n - \\`test\\`\n - \\`development\\`\n `}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n export\n const\n name=\"mode\"\n initializer={code`String(env.MODE) || \"production\"; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isProduction\"\n doc='Detect if the application is running in `\"production\"` mode'\n initializer={code`[\"prd\", \"prod\", \"production\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isTest\"\n doc='Detect if the application is running in `\"test\"` mode'\n initializer={code`[\"tst\", \"test\", \"testing\", \"stg\", \"stage\", \"staging\"].includes(mode.toLowerCase()) || env.TEST; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDevelopment\"\n doc='Detect if the application is running in `\"development\"` mode'\n initializer={code`[\"dev\", \"development\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDebug\"\n doc=\"Detect if the application is currently being debugged\"\n initializer={code`Boolean(isDevelopment && env.DEBUG); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;AAAG;;;;;;;AAEtC,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;;;;AA+BA,SAAa,oBAAA;CACX,MAAA,WAAgB,cAAA,IAAA,CAAA,CAAA,oBAAA,MAAA,CAAA,GAAA,cAAA;CAChB,OAAA;EAAA,gBAAoB,wBAAA;GACpB,MAAA;GACA,IAAA,SAAA;IACA,OAAA,QAAA,IAAA,KAAA;GACA;GACF,UAAO;EACL,CAAA;EAAA,gBAAK,SAAA,CAAA,CAAA;EAAA,gBAAA,OAAA;GACL,SAAU;GACV,IAAA,WAAY;IACZ,OAAA,gBAAA,cAAA,EACM,UAAC,sPACH,CAAC;GACP;EACA,CAAA;EAAM,gBAAe,sBAA0B;GAC/C,MAAS;GACT,UAAc;;GAEZ,IAAA,WAAA;IACC,OAAU,gBAAgB,KAAA;KAC3B,IAAA,OAAA;MACK,OAAS,UAAA,QA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,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAkB,SAAE,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACtB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAM,IAAA;GACR,CAAC;GAAG,gBAAI,SAAkB,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACxB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAiB,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACnB,UAAM;IACN,SAAM;IACN,MAAM;IACN,KAAK;IACL,aAAM,IAAW;GACnB,CAAC;GAAG,gBAAe,SAAA,CAAA,CAAA;GAAA,gBAAA,MAAA;IACjB,IAAE,OAAI;KACJ,OAAI,QAAS,QAAA;IACf;IACM;GACR,CAAC;EAAC;CACJ,EACF,CAAC,CAAC;AACJ;AACA,WAAU,SAAI;OAAA;CAAoB;CAAA;CAAA;CAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"env-builtin.mjs","names":[],"sources":["../../src/components/env-builtin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n code,\n computed,\n For,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n InterfaceDeclaration as BaseInterfaceDeclaration,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport type { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps,\n InterfaceDeclaration,\n InterfaceMember,\n ObjectDeclaration,\n TSDocSchemaProperty\n} from \"@powerlines/plugin-alloy/typescript/components\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { JsonSchemaProperty } from \"@powerlines/schema\";\nimport { getPropertiesList } from \"@powerlines/schema/helpers\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport type { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition() {\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\"UnprefixedEnv\"\n schema={context.env.vars.schema}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`UnprefixedEnv\\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}\n </TSDocRemarks>\n </TSDoc>\n <BaseInterfaceDeclaration name=\"Env\" export extends=\"UnprefixedEnv\">\n <For\n each={getUnique(context.config.env.prefix).map(prefix =>\n prefix.replace(/_$/, \"\")\n )}\n doubleHardline>\n {prefix => (\n <For\n each={\n getPropertiesList(context.env.vars.schema).filter(\n property => !property?.isIgnored\n ) ?? []\n }\n doubleHardline>\n {property => (\n <>\n <TSDocSchemaProperty schema={property} />\n <InterfaceMember\n name={`${prefix}_${property?.name}`}\n type={`UnprefixedEnv[\"${property?.name}\"]`}\n readOnly={property?.readOnly}\n />\n </>\n )}\n </For>\n )}\n </For>\n </BaseInterfaceDeclaration>\n <Spacing />\n </>\n );\n}\n\ninterface ConfigPropertyConditionalProps extends ComponentProps {\n context: EnvPluginContext;\n name: string;\n}\n\nfunction ConfigPropertyConditional(props: ConfigPropertyConditionalProps) {\n const [{ context, name }] = splitProps(props, [\"context\", \"name\"]);\n\n return code`propertyName === \"${name}\" || propertyName.replace(/^(${getUnique(\n context.config.env.prefix\n .sort((a, b) =>\n a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)\n )\n .map(prefix => `${prefix.replace(/_$/, \"\")}_`)\n ).join(\"|\")})/g, \"\").toLowerCase().replace(/[\\\\s\\\\-_]+/g, \"\") === \"${name\n .toLowerCase()\n .replace(/[\\s\\-_]+/g, \"\")}\"`;\n}\n\ninterface ConfigPropertyProps extends ComponentProps {\n index: number;\n context: EnvPluginContext;\n name: string;\n property: JsonSchemaProperty;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${name}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, name, property, index }] = splitProps(props, [\n \"context\",\n \"name\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional name={name} context={context} />\n <Show when={property?.alias && property?.alias.length > 0}>\n {code` || `}\n <For each={property?.alias ?? []} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${name}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const reflectionGetProperties = computed(\n () =>\n getPropertiesList(context.env.vars.schema)\n .filter(property => !property?.isIgnored)\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a?.name.localeCompare(b?.name)\n ) ?? []\n );\n const reflectionSetProperties = computed(\n () =>\n getPropertiesList(context.env.vars.schema)\n .filter(property => !property?.isIgnored && !property?.readOnly)\n .sort((a, b) =>\n !a?.name && !b?.name\n ? 0\n : !a?.name\n ? 1\n : !b?.name\n ? -1\n : a?.name.localeCompare(b?.name)\n ) ?? []\n );\n\n return (\n <BuiltinFile\n id=\"env\"\n description=\"The environment configuration module provides an interface to define environment configuration parameters.\"\n {...rest}>\n <Show when={Boolean(context.env.vars.schema)}>\n <EnvTypeDefinition defaultValue={defaultValue} />\n <Spacing />\n </Show>\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<Env>\"\n schema={context.env.vars.schema}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\n <TSDoc heading=\"Initializes the Powerlines environment configuration module.\">\n <TSDocRemarks>\n {`This function initializes the Powerlines environment configuration object.`}\n </TSDocRemarks>\n <TSDocParam name=\"environmentConfig\">\n {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}\n </TSDocParam>\n <TSDocReturns>\n {`The initialized Powerlines configuration object.`}\n </TSDocReturns>\n </TSDoc>\n <Show when={Boolean(context?.entryPath)}>\n <FunctionDeclaration\n refkey={createEnvRefkey}\n async={false}\n export\n name=\"createEnv\"\n parameters={[\n {\n name: \"environmentConfig\",\n type: `Partial<Env>`,\n optional: false,\n default: \"{}\"\n }\n ]}\n returnType=\"Env\">\n {code`\n return new Proxy<Env>(\n deserializeEnv({\n ...initialEnv,\n ...environmentConfig\n } as Env),\n {\n get: (target: UnprefixedEnv, propertyName: string) => { `}\n <hbr />\n <For each={reflectionGetProperties.value}>\n {(property: JsonSchemaProperty, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n name={property.name}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `}\n <hbr />\n <For each={reflectionSetProperties.value} ender={code` else `}>\n {(property: JsonSchemaProperty, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n name={property.name}\n property={property}\n />\n )}\n </For>\n\n <hbr />\n {code`return false;\n }\n }\n );\n`}\n </FunctionDeclaration>\n </Show>\n <Spacing />\n <TSDoc heading=\"The environment configuration object.\">\n <TSDocRemarks>\n {`This object provides access to the environment configuration parameters in the application runtime.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n refkey={envRefkey}\n name=\"env\"\n type=\"Env\"\n export\n const\n initializer={\n <>{code`createEnv(${defaultConfig || \"{}\"} as Partial<Env>);`}</>\n }\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isCI\"\n doc=\"Detect if the application is running in a continuous integration (CI) environment.\"\n initializer={code`Boolean(\n env.CI ||\n env.RUN_ID ||\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS || false\n ); `}\n />\n <Spacing />\n\n <TSDoc heading=\"Detect the \\`mode\\` of the current runtime environment.\">\n <TSDocRemarks>\n {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, it is generally recommended to only allow a value in the following list:\n - \\`production\\`\n - \\`test\\`\n - \\`development\\`\n `}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n export\n const\n name=\"mode\"\n initializer={code`String(env.MODE) || \"production\"; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isProduction\"\n doc='Detect if the application is running in `\"production\"` mode'\n initializer={code`[\"prd\", \"prod\", \"production\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isTest\"\n doc='Detect if the application is running in `\"test\"` mode'\n initializer={code`[\"tst\", \"test\", \"testing\", \"stg\", \"stage\", \"staging\"].includes(mode.toLowerCase()) || env.TEST; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDevelopment\"\n doc='Detect if the application is running in `\"development\"` mode'\n initializer={code`[\"dev\", \"development\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDebug\"\n doc=\"Detect if the application is currently being debugged\"\n initializer={code`Boolean(isDevelopment && env.DEBUG); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;AAAG;;;;;;;AAEtC,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;;;;AA+BA,SAAa,oBAAA;CACX,MAAA,WAAgB,cAAA,IAAA,CAAA,CAAA,oBAAA,MAAA,CAAA,GAAA,cAAA;CAChB,OAAA;EAAA,gBAAoB,wBAAA;GACpB,MAAA;GACA,IAAA,SAAA;IACA,OAAA,QAAA,IAAA,KAAA;GACA;GACF,UAAO;EACL,CAAA;EAAA,gBAAK,SAAA,CAAA,C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;IACL,aAAI,IAAA;GACN,CAAC;GAAA,gBAAA,SAAA,CAAA,CAAA;GAAA,gBAAA,gBAAA;IACA,UAAS;;IAET,MAAM;IACL,KAAC;IACD,aAAa,IAAC;GAChB,CAAC;GAAG,gBAAe,SAAA,CAAA,CAAA;GAAA,gBAAA,MAAA;IACjB,IAAI,OAAO;KACT,OAAI,QAAW,QAAC;IAClB;IACE;GACJ,CAAC;EAAC;CACJ,EACF,CAAC,CAAC;AACJ;AACA,WAAQ,SAAU;OAAA;CAAA;CAAA;CAAA;CAAA;AAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
4
3
|
let automd = require("automd");
|
|
5
4
|
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -5,13 +5,11 @@ const require_helpers_schema = require('./schema.cjs');
|
|
|
5
5
|
const require_helpers_automd_generator = require('./automd-generator.cjs');
|
|
6
6
|
|
|
7
7
|
exports.env = require_helpers_automd_generator.env;
|
|
8
|
-
exports.
|
|
8
|
+
exports.extractEnv = require_helpers_schema.extractEnv;
|
|
9
9
|
exports.formatEnvField = require_helpers_source_file_env.formatEnvField;
|
|
10
10
|
exports.getDefaultSecretsTypeDefinition = require_helpers_schema.getDefaultSecretsTypeDefinition;
|
|
11
11
|
exports.getDefaultVarsTypeDefinition = require_helpers_schema.getDefaultVarsTypeDefinition;
|
|
12
12
|
exports.loadEnv = require_helpers_load.loadEnv;
|
|
13
13
|
exports.loadEnvFromContext = require_helpers_load.loadEnvFromContext;
|
|
14
|
-
exports.readActiveEnv = require_helpers_schema.readActiveEnv;
|
|
15
14
|
exports.removeEnvPrefix = require_helpers_source_file_env.removeEnvPrefix;
|
|
16
|
-
exports.resolveRuntimeTypeFile = require_helpers_schema.resolveRuntimeTypeFile;
|
|
17
|
-
exports.writeActiveEnv = require_helpers_schema.writeActiveEnv;
|
|
15
|
+
exports.resolveRuntimeTypeFile = require_helpers_schema.resolveRuntimeTypeFile;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { env } from "./automd-generator.cjs";
|
|
2
2
|
import { loadEnv, loadEnvFromContext } from "./load.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile } from "./schema.cjs";
|
|
4
4
|
import { formatEnvField, removeEnvPrefix } from "./source-file-env.cjs";
|
|
5
|
-
export { env,
|
|
5
|
+
export { env, extractEnv, formatEnvField, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { env } from "./automd-generator.mjs";
|
|
2
2
|
import { loadEnv, loadEnvFromContext } from "./load.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile } from "./schema.mjs";
|
|
4
4
|
import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
|
|
5
|
-
export { env,
|
|
5
|
+
export { env, extractEnv, formatEnvField, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
|
|
2
2
|
import { loadEnv, loadEnvFromContext } from "./load.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile } from "./schema.mjs";
|
|
4
4
|
import { env } from "./automd-generator.mjs";
|
|
5
5
|
|
|
6
|
-
export { env,
|
|
6
|
+
export { env, extractEnv, formatEnvField, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile };
|
package/dist/helpers/load.cjs
CHANGED
|
@@ -101,7 +101,7 @@ function loadEnvFromContext(context, parsed, workspaceConfig) {
|
|
|
101
101
|
RUNTIME: context.config.environment.runtime,
|
|
102
102
|
ENVIRONMENT: !context.config.environment.name || context.config.environment.name === powerlines_constants.DEFAULT_ENVIRONMENT ? context.config.mode : context.config.environment.name
|
|
103
103
|
}, (0, _stryke_type_checks_is_set_object.isSetObject)(context.env.vars) ? Object.entries((0, _powerlines_schema_helpers.getProperties)(context.env.vars)).reduce(__assignType((ret, [name, prop]) => {
|
|
104
|
-
ret[name] = parsed[name] ?? prop
|
|
104
|
+
ret[name] = parsed[name] ?? prop?.default;
|
|
105
105
|
return ret;
|
|
106
106
|
}, [
|
|
107
107
|
"ret",
|
package/dist/helpers/load.d.cts
CHANGED
|
@@ -20,15 +20,15 @@ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvPar
|
|
|
20
20
|
RELEASE_TAG: string;
|
|
21
21
|
DEFAULT_LOCALE: string | undefined;
|
|
22
22
|
DEFAULT_TIMEZONE: string | undefined;
|
|
23
|
-
LOG_LEVEL: "
|
|
23
|
+
LOG_LEVEL: "silent" | "error" | "warn" | "info" | "debug";
|
|
24
24
|
ERROR_URL: string | undefined;
|
|
25
25
|
ORGANIZATION: string | undefined;
|
|
26
26
|
PLATFORM: "node" | "browser" | "neutral";
|
|
27
|
-
MODE: "
|
|
27
|
+
MODE: "development" | "test" | "production";
|
|
28
28
|
TEST: boolean;
|
|
29
29
|
DEBUG: boolean;
|
|
30
30
|
STACKTRACE: boolean;
|
|
31
|
-
RUNTIME: "
|
|
31
|
+
RUNTIME: "browser" | "nodejs" | "workerd" | "edge" | undefined;
|
|
32
32
|
ENVIRONMENT: string;
|
|
33
33
|
};
|
|
34
34
|
declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
|
package/dist/helpers/load.d.mts
CHANGED
|
@@ -20,15 +20,15 @@ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvPar
|
|
|
20
20
|
RELEASE_TAG: string;
|
|
21
21
|
DEFAULT_LOCALE: string | undefined;
|
|
22
22
|
DEFAULT_TIMEZONE: string | undefined;
|
|
23
|
-
LOG_LEVEL: "
|
|
23
|
+
LOG_LEVEL: "silent" | "error" | "warn" | "info" | "debug";
|
|
24
24
|
ERROR_URL: string | undefined;
|
|
25
25
|
ORGANIZATION: string | undefined;
|
|
26
26
|
PLATFORM: "node" | "browser" | "neutral";
|
|
27
|
-
MODE: "
|
|
27
|
+
MODE: "development" | "test" | "production";
|
|
28
28
|
TEST: boolean;
|
|
29
29
|
DEBUG: boolean;
|
|
30
30
|
STACKTRACE: boolean;
|
|
31
|
-
RUNTIME: "
|
|
31
|
+
RUNTIME: "browser" | "nodejs" | "workerd" | "edge" | undefined;
|
|
32
32
|
ENVIRONMENT: string;
|
|
33
33
|
};
|
|
34
34
|
declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
|
package/dist/helpers/load.mjs
CHANGED
|
@@ -98,7 +98,7 @@ function loadEnvFromContext(context, parsed, workspaceConfig) {
|
|
|
98
98
|
RUNTIME: context.config.environment.runtime,
|
|
99
99
|
ENVIRONMENT: !context.config.environment.name || context.config.environment.name === DEFAULT_ENVIRONMENT ? context.config.mode : context.config.environment.name
|
|
100
100
|
}, isSetObject(context.env.vars) ? Object.entries(getProperties(context.env.vars)).reduce(__assignType((ret, [name, prop]) => {
|
|
101
|
-
ret[name] = parsed[name] ?? prop
|
|
101
|
+
ret[name] = parsed[name] ?? prop?.default;
|
|
102
102
|
return ret;
|
|
103
103
|
}, [
|
|
104
104
|
"ret",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getProperties } from \"@powerlines/schema/helpers\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopmentMode,\n isTestMode,\n toMode\n} from \"@stryke/env/environment-checks\";\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig?: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: context.config.framework?.name || \"powerlines\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || workspaceConfig?.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput,\n workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: toMode(context.config.mode),\n TEST: isTestMode(context.config.mode),\n DEBUG: isDevelopmentMode(context.config.mode),\n STACKTRACE: context.config.mode !== \"production\",\n RUNTIME: context.config.environment.runtime,\n ENVIRONMENT:\n !context.config.environment.name ||\n context.config.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.config.environment.name\n },\n isSetObject(context.env.vars)\n ? Object.entries(getProperties(context.env.vars)).reduce(\n (ret, [name, prop]) => {\n ret[name] = parsed[name] ?? prop
|
|
1
|
+
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getProperties } from \"@powerlines/schema/helpers\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopmentMode,\n isTestMode,\n toMode\n} from \"@stryke/env/environment-checks\";\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig?: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: context.config.framework?.name || \"powerlines\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || workspaceConfig?.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput,\n workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: toMode(context.config.mode),\n TEST: isTestMode(context.config.mode),\n DEBUG: isDevelopmentMode(context.config.mode),\n STACKTRACE: context.config.mode !== \"production\",\n RUNTIME: context.config.environment.runtime,\n ENVIRONMENT:\n !context.config.environment.name ||\n context.config.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.config.environment.name\n },\n isSetObject(context.env.vars)\n ? Object.entries(getProperties(context.env.vars)).reduce(\n (ret, [name, prop]) => {\n ret[name] = parsed[name] ?? prop?.default;\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const workspaceConfig = await tryGetWorkspaceConfig();\n\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.cwd,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env, workspaceConfig),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;AA6BA,eAAS,aAAkB,SAAM,MAAU,KAAC;CAC5C,IAAM,MAAG,MAAA,UAAqB,KAAK,IAAE;CACrC,IAAM,QAAG,mBAAkB,QAAA,iBAA4B,SAAY,GAAC;EACpE,MAAS,qBAAsB,MAAI,QAAO,IAAK,QAAI,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,GAAA,GAAA;GAAA;GAAA;GAAA;EAAA,CAAA,CAAA,CAAA;sDAE7C,MAAA,KAAS,mBAAkB,GAAA;CAE/B;CACA,OAAK,gBAAA,GAAA;AACP;AACA,aAAY,SAAM;OAAW;CAAW;CAAA;CAAA;CAAA;CAAA;AAAA;AACxC,eAAc,iBAAkB,SAAS,SAAA,WAAiB,MAAS,UAAG,aAAA,iBAAA;CACpE,MAAE,CAAK,WAAC,aAAqB,MAAM,QAAQ,IAAG,EAAA,aAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,aAAA,SAAA,MAAA,SAAA,IAAA,WAAA;EAC5C,KAAE;EACF,MAAI,QAAA,OAAgB,WAAA,QAAmB;EACvC,SAAE;EACF,UAAC;;GAED,MAAK;GACH,KAAK,QAAM,OAAA,gBAAuB,iBAAA;EACpC;EACF,UAAA;;EAEA,QAAO;EACT,aAAA;;GAEM,aAAS;EACb;CACD,CAAA,CAAA,CAAA;CACC,OAAO,KAAE,WAAA,UAAgB,QAAA,eAAA;AAC3B;AACA,iBAAa,SAAM;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA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,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,KAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;CAAA,CAAA;CAChD,OAAE,KAAU,mBAAmB,SAAI,QAAO,KAAA,eAAa,GAAA,SAAA,WAAA,MAAA;AACzD;AACA,QAAO,SAAS;OAAA;CAAkB;OAAA;CAAA;CAAA;CAAA;AAAA"}
|
package/dist/helpers/schema.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_types_plugin = require('../types/plugin.cjs');
|
|
3
4
|
const require_helpers_load = require('./load.cjs');
|
|
4
5
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
5
|
-
let _powerlines_schema = require("@powerlines/schema");
|
|
6
6
|
let _powerlines_schema_extract = require("@powerlines/schema/extract");
|
|
7
7
|
let _powerlines_schema_helpers = require("@powerlines/schema/helpers");
|
|
8
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
9
8
|
let _stryke_type_checks_is_set_array = require("@stryke/type-checks/is-set-array");
|
|
10
9
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
11
10
|
let defu = require("defu");
|
|
@@ -76,13 +75,13 @@ getDefaultSecretsTypeDefinition.__type = [
|
|
|
76
75
|
* @param context - The plugin context
|
|
77
76
|
* @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
|
|
78
77
|
*/
|
|
79
|
-
async function
|
|
78
|
+
async function extractEnv(context) {
|
|
80
79
|
const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
|
|
81
80
|
const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
|
|
82
|
-
const vars = await (0, _powerlines_schema_extract.extract)(context, context.config.env.vars);
|
|
83
|
-
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.vars) && context.config.env.vars !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.vars) && (context.config.env.vars.file !== defaultVarsTypeDefinition.file || context.config.env.vars.name !== defaultVarsTypeDefinition.name)) vars.schema = (0, _powerlines_schema_helpers.mergeSchemas)(vars, await (0, _powerlines_schema_extract.extract)(context, defaultVarsTypeDefinition));
|
|
84
|
-
const secrets = await (0, _powerlines_schema_extract.extract)(context, context.config.env.secrets);
|
|
85
|
-
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = (0, _powerlines_schema_helpers.mergeSchemas)(secrets, await (0, _powerlines_schema_extract.extract)(context, defaultSecretsTypeDefinition));
|
|
81
|
+
const vars = await (_powerlines_schema_extract.extract.Ω = [[() => require_types_plugin.__ΩEnv, "n!"]], (0, _powerlines_schema_extract.extract)(context, context.config.env.vars));
|
|
82
|
+
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.vars) && context.config.env.vars !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.vars) && (context.config.env.vars.file !== defaultVarsTypeDefinition.file || context.config.env.vars.name !== defaultVarsTypeDefinition.name)) vars.schema = (_powerlines_schema_helpers.mergeSchemas.Ω = [[() => require_types_plugin.__ΩEnv, "n!"]], (0, _powerlines_schema_helpers.mergeSchemas)(vars, await (_powerlines_schema_extract.extract.Ω = [[() => require_types_plugin.__ΩEnv, "n!"]], (0, _powerlines_schema_extract.extract)(context, defaultVarsTypeDefinition))));
|
|
83
|
+
const secrets = await (_powerlines_schema_extract.extract.Ω = [[() => require_types_plugin.__ΩEnv, "n!"]], (0, _powerlines_schema_extract.extract)(context, context.config.env.secrets));
|
|
84
|
+
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = (_powerlines_schema_helpers.mergeSchemas.Ω = [[() => require_types_plugin.__ΩEnv, "n!"]], (0, _powerlines_schema_helpers.mergeSchemas)(secrets, await (_powerlines_schema_extract.extract.Ω = [[() => require_types_plugin.__ΩEnv, "n!"]], (0, _powerlines_schema_extract.extract)(context, defaultSecretsTypeDefinition))));
|
|
86
85
|
context.env = (0, defu.default)({
|
|
87
86
|
vars,
|
|
88
87
|
secrets,
|
|
@@ -91,18 +90,19 @@ async function extractEnvSchema(context) {
|
|
|
91
90
|
parsed: {},
|
|
92
91
|
injected: []
|
|
93
92
|
});
|
|
94
|
-
await readActiveEnv(context);
|
|
95
93
|
const properties = (0, _powerlines_schema_helpers.getProperties)(context.env.vars);
|
|
96
94
|
context.info({
|
|
97
95
|
meta: { category: "env" },
|
|
98
96
|
message: `Environment Variables configuration: ${context.config.env.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${context.config.env.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? (0, _powerlines_schema_helpers.getPropertiesList)(context.env.secrets).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
|
|
99
97
|
});
|
|
100
|
-
const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => (0, _stryke_type_checks_is_set_array.isSetArray)(prop.
|
|
98
|
+
const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => (0, _stryke_type_checks_is_set_array.isSetArray)(prop.alias) ? prop.alias?.map(__assignType((alias) => [alias, {
|
|
101
99
|
...prop,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
name: alias,
|
|
101
|
+
alias: [...prop.alias?.filter(__assignType((a) => a !== alias, [
|
|
102
|
+
"a",
|
|
103
|
+
"",
|
|
104
|
+
"P\"2!\"/\""
|
|
105
|
+
])) ?? [], key]
|
|
106
106
|
}], [
|
|
107
107
|
"alias",
|
|
108
108
|
"",
|
|
@@ -123,79 +123,28 @@ async function extractEnvSchema(context) {
|
|
|
123
123
|
"P\"2!\"2\"\"/#"
|
|
124
124
|
]), key);
|
|
125
125
|
if (properties[unprefixedKey]) {
|
|
126
|
-
if (!properties[unprefixedKey]
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
context.env.vars.schema.optionalProperties[unprefixedKey].metadata.default = value;
|
|
130
|
-
} else if (context.env.vars.schema.properties?.[unprefixedKey]) {
|
|
131
|
-
context.env.vars.schema.properties[unprefixedKey].metadata ??= {};
|
|
132
|
-
context.env.vars.schema.properties[unprefixedKey].metadata.default = value;
|
|
133
|
-
}
|
|
126
|
+
if (!properties[unprefixedKey]?.runtime) {
|
|
127
|
+
const propertySchema = context.env.vars.schema.properties?.[unprefixedKey];
|
|
128
|
+
if (propertySchema) propertySchema.default = value;
|
|
134
129
|
}
|
|
135
130
|
} else if (aliases[unprefixedKey]) {
|
|
136
|
-
if (!aliases[unprefixedKey]
|
|
137
|
-
const alias = aliases[unprefixedKey]
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
context.env.vars.schema.optionalProperties[alias].metadata.default = value;
|
|
141
|
-
} else if (context.env.vars.schema.properties?.[alias]) {
|
|
142
|
-
context.env.vars.schema.properties[alias].metadata ??= {};
|
|
143
|
-
context.env.vars.schema.properties[alias].metadata.default = value;
|
|
144
|
-
}
|
|
131
|
+
if (!aliases[unprefixedKey]?.runtime) {
|
|
132
|
+
const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
|
|
133
|
+
const aliasSchema = context.env.vars.schema.properties?.[alias];
|
|
134
|
+
if (aliasSchema) aliasSchema.default = value;
|
|
145
135
|
}
|
|
146
136
|
}
|
|
147
137
|
}
|
|
148
138
|
}
|
|
149
|
-
|
|
139
|
+
extractEnv.__type = [
|
|
150
140
|
"context",
|
|
151
|
-
"
|
|
141
|
+
"extractEnv",
|
|
152
142
|
"Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.",
|
|
153
143
|
"P\"2!$`/\"?#"
|
|
154
144
|
];
|
|
155
|
-
/**
|
|
156
|
-
* Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
|
|
157
|
-
*
|
|
158
|
-
* @param context - The plugin context
|
|
159
|
-
* @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
|
|
160
|
-
*/
|
|
161
|
-
async function readActiveEnv(context) {
|
|
162
|
-
context.env.vars.active ??= [];
|
|
163
|
-
if (context.fs.existsSync((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "vars.json"))) {
|
|
164
|
-
const content = await context.fs.read((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "vars.json"));
|
|
165
|
-
if (content) context.env.vars.active = JSON.parse(content)?.elements ?? [];
|
|
166
|
-
}
|
|
167
|
-
context.env.secrets.active ??= [];
|
|
168
|
-
if (context.fs.existsSync((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "secrets.json"))) {
|
|
169
|
-
const content = await context.fs.read((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "secrets.json"));
|
|
170
|
-
if (content) context.env.secrets.active = JSON.parse(content)?.elements ?? [];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
readActiveEnv.__type = [
|
|
174
|
-
"context",
|
|
175
|
-
"readActiveEnv",
|
|
176
|
-
"Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.",
|
|
177
|
-
"P\"2!\"/\"?#"
|
|
178
|
-
];
|
|
179
|
-
/**
|
|
180
|
-
* Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
|
|
181
|
-
*
|
|
182
|
-
* @param context - The plugin context
|
|
183
|
-
* @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
|
|
184
|
-
*/
|
|
185
|
-
async function writeActiveEnv(context) {
|
|
186
|
-
return Promise.all([(0, _stryke_type_checks_is_set_array.isSetArray)(context.env.vars.active) ? context.fs.write((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "vars.json"), JSON.stringify({ elements: context.env.vars.active })) : void 0, (0, _stryke_type_checks_is_set_array.isSetArray)(context.env.secrets.active) ? context.fs.write((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "secrets.json"), JSON.stringify({ elements: context.env.secrets.active })) : void 0].filter(Boolean));
|
|
187
|
-
}
|
|
188
|
-
writeActiveEnv.__type = [
|
|
189
|
-
"context",
|
|
190
|
-
"writeActiveEnv",
|
|
191
|
-
"Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.",
|
|
192
|
-
"P\"2!\"/\"?#"
|
|
193
|
-
];
|
|
194
145
|
|
|
195
146
|
//#endregion
|
|
196
|
-
exports.
|
|
147
|
+
exports.extractEnv = extractEnv;
|
|
197
148
|
exports.getDefaultSecretsTypeDefinition = getDefaultSecretsTypeDefinition;
|
|
198
149
|
exports.getDefaultVarsTypeDefinition = getDefaultVarsTypeDefinition;
|
|
199
|
-
exports.
|
|
200
|
-
exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
|
|
201
|
-
exports.writeActiveEnv = writeActiveEnv;
|
|
150
|
+
exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
|
|
@@ -32,21 +32,7 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
|
|
|
32
32
|
* @param context - The plugin context
|
|
33
33
|
* @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
|
|
34
34
|
*/
|
|
35
|
-
declare function
|
|
36
|
-
/**
|
|
37
|
-
* Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
|
|
38
|
-
*
|
|
39
|
-
* @param context - The plugin context
|
|
40
|
-
* @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
|
|
41
|
-
*/
|
|
42
|
-
declare function readActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
|
|
45
|
-
*
|
|
46
|
-
* @param context - The plugin context
|
|
47
|
-
* @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
|
|
48
|
-
*/
|
|
49
|
-
declare function writeActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void[]>;
|
|
35
|
+
declare function extractEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
|
|
50
36
|
//#endregion
|
|
51
|
-
export {
|
|
37
|
+
export { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
|
|
52
38
|
//# sourceMappingURL=schema.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AAuCA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;;;;iBAgBR,UAAA,kBAA4B,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAA,GACR,OAAA"}
|