@powerlines/plugin-env 0.16.349 → 0.16.351
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 +2 -2
- package/dist/babel/plugin.mjs +1 -1
- package/dist/components/docs.cjs +5 -4
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.mjs +2 -1
- package/dist/components/env-builtin.cjs +6 -5
- package/dist/components/env-builtin.d.cts +1 -1
- package/dist/components/env-builtin.d.mts +1 -1
- package/dist/components/env-builtin.mjs +2 -1
- package/dist/helpers/load.cjs +2 -2
- package/dist/helpers/load.mjs +1 -1
- package/dist/helpers/schema.cjs +31 -20
- package/dist/helpers/schema.d.cts.map +1 -1
- package/dist/helpers/schema.mjs +24 -13
- package/dist/types/plugin.d.cts +4 -4
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +4 -4
- package/package.json +13 -13
package/dist/babel/plugin.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
4
4
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
5
5
|
let _powerlines_plugin_babel_helpers_create_plugin = require("@powerlines/plugin-babel/helpers/create-plugin");
|
|
6
6
|
let _powerlines_plugin_babel_helpers_module_helpers = require("@powerlines/plugin-babel/helpers/module-helpers");
|
|
@@ -13,7 +13,7 @@ function __assignType(fn, args) {
|
|
|
13
13
|
return fn;
|
|
14
14
|
}
|
|
15
15
|
const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin)("env", __assignType(({ logger, context }) => {
|
|
16
|
-
const config = (0,
|
|
16
|
+
const config = (0, _power_plant_schema.getProperties)(context.env.config);
|
|
17
17
|
function extractEnv(node, pass, isInjectable = false) {
|
|
18
18
|
if (node.name) {
|
|
19
19
|
const name = node.name.replace(new RegExp(`^(${context.config.env.prefix.join("|")})_`), "");
|
package/dist/babel/plugin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
|
-
import { getProperties } from "@
|
|
2
|
+
import { getProperties } from "@power-plant/schema";
|
|
3
3
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
4
4
|
import { createBabelPlugin } from "@powerlines/plugin-babel/helpers/create-plugin";
|
|
5
5
|
import { addImport } from "@powerlines/plugin-babel/helpers/module-helpers";
|
package/dist/components/docs.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
4
4
|
let _stryke_path_join = require("@stryke/path/join");
|
|
5
5
|
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
6
6
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
@@ -9,6 +9,7 @@ let _power_plant_alloy_js_core_components_spacing = require("@power-plant/alloy-
|
|
|
9
9
|
let _power_plant_alloy_js_markdown_components_heading = require("@power-plant/alloy-js/markdown/components/heading");
|
|
10
10
|
let _power_plant_alloy_js_markdown_components_markdown_file = require("@power-plant/alloy-js/markdown/components/markdown-file");
|
|
11
11
|
let _power_plant_alloy_js_markdown_components_markdown_table = require("@power-plant/alloy-js/markdown/components/markdown-table");
|
|
12
|
+
let _power_plant_schema_codegen = require("@power-plant/schema/codegen");
|
|
12
13
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
13
14
|
|
|
14
15
|
//#region src/components/docs.tsx
|
|
@@ -53,7 +54,7 @@ function EnvDocsFile(props) {
|
|
|
53
54
|
_alloy_js_core.code`The below list of configuration parameters are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text locally.`,
|
|
54
55
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
55
56
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_markdown_components_markdown_table.MarkdownTable, { get data() {
|
|
56
|
-
return (0,
|
|
57
|
+
return (0, _power_plant_schema.getPropertiesList)(context.env.config).filter(__assignType((property) => (0, _power_plant_schema.getPropertiesList)(context.env.config).some(__assignType((p) => p.name === property.name && context.env.config.active.includes(property.name), [
|
|
57
58
|
"p",
|
|
58
59
|
"",
|
|
59
60
|
"P\"2!\"/\""
|
|
@@ -70,8 +71,8 @@ function EnvDocsFile(props) {
|
|
|
70
71
|
return {
|
|
71
72
|
name: property.name?.trim(),
|
|
72
73
|
description: (property.description ?? "").trim(),
|
|
73
|
-
type: (0,
|
|
74
|
-
defaultValue: property.default ? (0,
|
|
74
|
+
type: (0, _power_plant_schema_codegen.stringifyType)(property).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
|
|
75
|
+
defaultValue: property.default ? (0, _power_plant_schema_codegen.stringifyType)(property.default) : "",
|
|
75
76
|
required: property.required ? "" : "✔"
|
|
76
77
|
};
|
|
77
78
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;UAiCiB,yBAAyB,QAAQ;;;;;;;;;EAShD;;;;;iBAMc,YAAY,OAAO,4CAAgB"}
|
package/dist/components/docs.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
|
-
import { getPropertiesList
|
|
2
|
+
import { getPropertiesList } from "@power-plant/schema";
|
|
3
3
|
import { joinPaths } from "@stryke/path/join";
|
|
4
4
|
import { getDocsOutputPath } from "powerlines/plugin-utils";
|
|
5
5
|
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
@@ -8,6 +8,7 @@ import { Spacing } from "@power-plant/alloy-js/core/components/spacing";
|
|
|
8
8
|
import { Heading } from "@power-plant/alloy-js/markdown/components/heading";
|
|
9
9
|
import { MarkdownFile } from "@power-plant/alloy-js/markdown/components/markdown-file";
|
|
10
10
|
import { MarkdownTable } from "@power-plant/alloy-js/markdown/components/markdown-table";
|
|
11
|
+
import { stringifyType } from "@power-plant/schema/codegen";
|
|
11
12
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
12
13
|
|
|
13
14
|
//#region src/components/docs.tsx
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_helpers_load = require('../helpers/load.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
4
4
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
5
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
6
|
let _alloy_js_core = require("@alloy-js/core");
|
|
7
7
|
let _power_plant_alloy_js_core_components_spacing = require("@power-plant/alloy-js/core/components/spacing");
|
|
8
|
+
let _power_plant_schema_codegen = require("@power-plant/schema/codegen");
|
|
8
9
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
9
10
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
10
11
|
let _power_plant_alloy_js_typescript_components = require("@power-plant/alloy-js/typescript/components");
|
|
@@ -81,7 +82,7 @@ function EnvTypeDefinition(props) {
|
|
|
81
82
|
get children() {
|
|
82
83
|
return __assignType((prefix) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
83
84
|
get each() {
|
|
84
|
-
return (0,
|
|
85
|
+
return (0, _power_plant_schema.getPropertiesList)(schema).filter(__assignType((property) => !property.ignore, [
|
|
85
86
|
"property",
|
|
86
87
|
"",
|
|
87
88
|
"P\"2!\"/\""
|
|
@@ -366,7 +367,7 @@ function EnvBuiltin(props) {
|
|
|
366
367
|
]));
|
|
367
368
|
return result;
|
|
368
369
|
});
|
|
369
|
-
const schemaGetProperties = (0, _alloy_js_core.computed)(() => (0,
|
|
370
|
+
const schemaGetProperties = (0, _alloy_js_core.computed)(() => (0, _power_plant_schema.getPropertiesList)(schema.value).filter(__assignType((property) => !property?.ignore && !property?.writeOnly, [
|
|
370
371
|
"property",
|
|
371
372
|
"",
|
|
372
373
|
"P\"2!\"/\""
|
|
@@ -376,7 +377,7 @@ function EnvBuiltin(props) {
|
|
|
376
377
|
"",
|
|
377
378
|
"P\"2!\"2\"\"/#"
|
|
378
379
|
])) ?? []);
|
|
379
|
-
const schemaSetProperties = (0, _alloy_js_core.computed)(() => (0,
|
|
380
|
+
const schemaSetProperties = (0, _alloy_js_core.computed)(() => (0, _power_plant_schema.getPropertiesList)(schema.value).filter(__assignType((property) => !property?.ignore && !property?.readOnly, [
|
|
380
381
|
"property",
|
|
381
382
|
"",
|
|
382
383
|
"P\"2!\"/\""
|
|
@@ -386,7 +387,7 @@ function EnvBuiltin(props) {
|
|
|
386
387
|
"",
|
|
387
388
|
"P\"2!\"2\"\"/#"
|
|
388
389
|
])) ?? []);
|
|
389
|
-
const parserCode = (0,
|
|
390
|
+
const parserCode = (0, _power_plant_schema_codegen.generateParserCode)(schema.value);
|
|
390
391
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
391
392
|
id: "env",
|
|
392
393
|
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { JsonSchemaObject } from "@
|
|
2
|
+
import { JsonSchemaObject } from "@power-plant/schema";
|
|
3
3
|
import { ComponentProps } from "@power-plant/alloy-js/core/types/components";
|
|
4
4
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components";
|
|
5
5
|
//#region src/components/env-builtin.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonSchemaObject } from "@
|
|
1
|
+
import { JsonSchemaObject } from "@power-plant/schema";
|
|
2
2
|
import { Children } from "@alloy-js/core";
|
|
3
3
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components";
|
|
4
4
|
import { ComponentProps } from "@power-plant/alloy-js/core/types/components";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { getPropertiesList } from "@power-plant/schema";
|
|
3
3
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
4
4
|
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
5
|
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
6
6
|
import { Spacing } from "@power-plant/alloy-js/core/components/spacing";
|
|
7
|
+
import { generateParserCode } from "@power-plant/schema/codegen";
|
|
7
8
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
9
|
import { ElseIfClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
9
10
|
import { InterfaceDeclaration as InterfaceDeclaration$1, InterfaceMember, ObjectDeclaration, TSDocSchemaProperty } from "@power-plant/alloy-js/typescript/components";
|
package/dist/helpers/load.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
4
|
const require_helpers_source_file_env = require('./source-file-env.cjs');
|
|
5
|
-
let
|
|
5
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
6
6
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
7
7
|
let _storm_software_config_tools_get_config = require("@storm-software/config-tools/get-config");
|
|
8
8
|
let _stryke_env_environment_checks = require("@stryke/env/environment-checks");
|
|
@@ -94,7 +94,7 @@ function loadEnvFromContext(context, parsed, workspaceConfig) {
|
|
|
94
94
|
STACKTRACE: context.config.mode !== "production",
|
|
95
95
|
RUNTIME: context.config.environment.runtime,
|
|
96
96
|
ENVIRONMENT: !context.config.environment.name || context.config.environment.name === powerlines_constants.DEFAULT_ENVIRONMENT ? context.config.mode : context.config.environment.name
|
|
97
|
-
}, (0, _stryke_type_checks_is_set_object.isSetObject)(context.env.config) ? Object.entries((0,
|
|
97
|
+
}, (0, _stryke_type_checks_is_set_object.isSetObject)(context.env.config) ? Object.entries((0, _power_plant_schema.getProperties)(context.env.config)).reduce(__assignType((ret, [name, prop]) => {
|
|
98
98
|
ret[name] = parsed[name] ?? prop?.default;
|
|
99
99
|
return ret;
|
|
100
100
|
}, [
|
package/dist/helpers/load.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "../types/plugin.mjs";
|
|
2
2
|
import { removeEnvPrefix } from "./source-file-env.mjs";
|
|
3
|
-
import { getProperties } from "@
|
|
3
|
+
import { getProperties } from "@power-plant/schema";
|
|
4
4
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
5
5
|
import { tryGetWorkspaceConfig } from "@storm-software/config-tools/get-config";
|
|
6
6
|
import { isDevelopmentMode, isTestMode, toMode } from "@stryke/env/environment-checks";
|
package/dist/helpers/schema.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
3
3
|
const require_helpers_load = require('./load.cjs');
|
|
4
|
-
let
|
|
5
|
-
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
4
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
6
5
|
let _stryke_path_join = require("@stryke/path/join");
|
|
7
6
|
let _stryke_type_checks_is_set_array = require("@stryke/type-checks/is-set-array");
|
|
8
7
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
@@ -91,7 +90,7 @@ getCacheFilePath.__type = [
|
|
|
91
90
|
"P\"2!P.\".#J2$&/%"
|
|
92
91
|
];
|
|
93
92
|
async function writeActive(context, variant, schema) {
|
|
94
|
-
if (!(0,
|
|
93
|
+
if (!(0, _power_plant_schema.isSchema)(schema)) throw new Error(`The provided input is not a valid env schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
95
94
|
await context.fs.write(getCacheFilePath(context, variant), JSON.stringify(schema.schema));
|
|
96
95
|
}
|
|
97
96
|
writeActive.__type = [
|
|
@@ -137,16 +136,33 @@ async function extractEnv(context) {
|
|
|
137
136
|
context.env ??= {};
|
|
138
137
|
context.env.parsed ??= {};
|
|
139
138
|
context.env.injected ??= [];
|
|
140
|
-
context.env.config = await (0,
|
|
139
|
+
context.env.config = await (0, _power_plant_schema.extract)(context.config.env.config);
|
|
141
140
|
context.env.config.active = await readActive(context, "config");
|
|
142
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(context.config.env.config) && new RegExp(`${defaultConfig.file}[:#;@]?${defaultConfig.export}`).test(context.config.env.config) === false || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.config) && (context.config.env.config.file !== defaultConfig.file || context.config.env.config.export !== defaultConfig.export)) context.env.config.schema = (0,
|
|
143
|
-
context.env.secrets = await (0,
|
|
141
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(context.config.env.config) && new RegExp(`${defaultConfig.file}[:#;@]?${defaultConfig.export}`).test(context.config.env.config) === false || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.config) && (context.config.env.config.file !== defaultConfig.file || context.config.env.config.export !== defaultConfig.export)) context.env.config.schema = (0, _power_plant_schema.merge)(await (0, _power_plant_schema.extract)(defaultConfig), context.env.config);
|
|
142
|
+
context.env.secrets = await (0, _power_plant_schema.extract)(context.config.env.secrets);
|
|
144
143
|
context.env.secrets.active = await readActive(context, "secrets");
|
|
145
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(context.config.env.secrets) && new RegExp(`${defaultSecrets.file}[:#;@]?${defaultSecrets.export}`).test(context.config.env.secrets) === false || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecrets.file || context.config.env.secrets.export !== defaultSecrets.export)) context.env.secrets.schema = (0,
|
|
146
|
-
const properties = (0,
|
|
144
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(context.config.env.secrets) && new RegExp(`${defaultSecrets.file}[:#;@]?${defaultSecrets.export}`).test(context.config.env.secrets) === false || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecrets.file || context.config.env.secrets.export !== defaultSecrets.export)) context.env.secrets.schema = (0, _power_plant_schema.merge)(await (0, _power_plant_schema.extract)(defaultSecrets), context.env.secrets);
|
|
145
|
+
const properties = (0, _power_plant_schema.getProperties)(context.env.config);
|
|
146
|
+
const describeVariant = __assignType((variant) => {
|
|
147
|
+
switch (variant) {
|
|
148
|
+
case "json-schema": return "JSON Schema";
|
|
149
|
+
case "standard-schema": return "Standard Schema";
|
|
150
|
+
case "zod3": return "Zod v3 schema";
|
|
151
|
+
case "valibot": return "Valibot schema";
|
|
152
|
+
case "untyped": return "Untyped configuration";
|
|
153
|
+
case "file-reference": return "Typescript exported type";
|
|
154
|
+
default: return variant;
|
|
155
|
+
}
|
|
156
|
+
}, [
|
|
157
|
+
() => require_types_plugin.__ΩEnvSchema,
|
|
158
|
+
"variant",
|
|
159
|
+
"variant",
|
|
160
|
+
"",
|
|
161
|
+
"Pn!.\"f2#\"/$"
|
|
162
|
+
]);
|
|
147
163
|
context.info({
|
|
148
164
|
meta: { category: "env" },
|
|
149
|
-
message: `Environment Variables configuration: ${context.config.env.config ? "" : "Defaulted "}${context.env.config.variant
|
|
165
|
+
message: `Environment Variables configuration: ${context.config.env.config ? "" : "Defaulted "}${describeVariant(context.env.config.variant)}${context.config.env.config ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${context.config.env.secrets ? "" : "Defaulted "}${describeVariant(context.env.secrets.variant)}${context.config.env.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? (0, _power_plant_schema.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"}`
|
|
150
166
|
});
|
|
151
167
|
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, {
|
|
152
168
|
...prop,
|
|
@@ -178,19 +194,19 @@ async function extractEnv(context) {
|
|
|
178
194
|
]), key);
|
|
179
195
|
if (properties[unprefixedKey]) {
|
|
180
196
|
if (!properties[unprefixedKey]?.runtime) {
|
|
181
|
-
const propertySchema = (0,
|
|
197
|
+
const propertySchema = (0, _power_plant_schema.getProperties)(context.env.config.schema)?.[unprefixedKey];
|
|
182
198
|
if (propertySchema) propertySchema.default = value;
|
|
183
199
|
}
|
|
184
200
|
} else if (aliases[unprefixedKey]) {
|
|
185
201
|
if (!aliases[unprefixedKey]?.runtime) {
|
|
186
202
|
const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
|
|
187
|
-
const aliasSchema = (0,
|
|
203
|
+
const aliasSchema = (0, _power_plant_schema.getProperties)(context.env.config.schema)?.[alias];
|
|
188
204
|
if (aliasSchema) aliasSchema.default = value;
|
|
189
205
|
}
|
|
190
206
|
}
|
|
191
207
|
}
|
|
192
|
-
if (!(0,
|
|
193
|
-
(0,
|
|
208
|
+
if (!(0, _power_plant_schema.isSchemaObject)(context.env.config)) throw new Error("Invalid environment variable schema extracted. Please ensure the `env.types` option points to a valid TypeScript type definition file that exports an interface representing the environment variable schema.");
|
|
209
|
+
(0, _power_plant_schema.getPropertiesList)(context.env.config).forEach(__assignType((property) => {
|
|
194
210
|
property.alias ??= [];
|
|
195
211
|
const aliases = [...property.alias];
|
|
196
212
|
context.config.env.prefix.forEach(__assignType((prefix) => {
|
|
@@ -216,7 +232,7 @@ async function extractEnv(context) {
|
|
|
216
232
|
"",
|
|
217
233
|
"P\"2!\"/\""
|
|
218
234
|
]));
|
|
219
|
-
(0,
|
|
235
|
+
(0, _power_plant_schema.getPropertiesList)(context.env.secrets).forEach(__assignType((property) => {
|
|
220
236
|
property.alias ??= [];
|
|
221
237
|
const aliases = [...property.alias];
|
|
222
238
|
context.config.env.prefix.forEach(__assignType((prefix) => {
|
|
@@ -256,12 +272,7 @@ extractEnv.__type = [
|
|
|
256
272
|
* @returns A promise that resolves when the schema has been successfully written to the cache directory.
|
|
257
273
|
*/
|
|
258
274
|
async function writeEnv(context) {
|
|
259
|
-
return Promise.all([
|
|
260
|
-
(0, _powerlines_schema.writeSchema)(context, (0, _stryke_helpers_omit.omit)(context.env.config, ["active"])),
|
|
261
|
-
(0, _powerlines_schema.writeSchema)(context, (0, _stryke_helpers_omit.omit)(context.env.secrets, ["active"])),
|
|
262
|
-
writeActive(context, "config", context.env.config),
|
|
263
|
-
writeActive(context, "secrets", context.env.secrets)
|
|
264
|
-
]);
|
|
275
|
+
return Promise.all([writeActive(context, "config", context.env.config), writeActive(context, "secrets", context.env.secrets)]);
|
|
265
276
|
}
|
|
266
277
|
writeEnv.__type = [
|
|
267
278
|
"context",
|
|
@@ -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":";;;;;;;;;;iBA0CsB,uBACpB,iBAAiB,mBACjB,SAAS,WAAW;;;;;;;iBAiBA,iBAAiB,iBAAiB,mBACtD,SAAS,WACR,QAAQ;;;;;;iBAYW,kBAAkB,iBAAiB,mBACvD,SAAS,WACR,QAAQ;;;;;;;iBAaK,kBAAkB,iBAAiB,kBACjD,SAAS;iBAKK,iBAAiB,iBAAiB,kBAChD,SAAS,UACT;;;;;;;;;;iBA+CoB,WAAW,iBAAiB,kBAChD,SAAS,WACR;;;;;;;iBA+MmB,SAAS,iBAAiB,kBAC9C,SAAS,WACR"}
|
package/dist/helpers/schema.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __ΩEnvSchema } from "../types/plugin.mjs";
|
|
2
2
|
import { loadEnv } from "./load.mjs";
|
|
3
|
-
import { extract, getProperties, getPropertiesList, isSchema, isSchemaObject, merge
|
|
4
|
-
import { omit } from "@stryke/helpers/omit";
|
|
3
|
+
import { extract, getProperties, getPropertiesList, isSchema, isSchemaObject, merge } from "@power-plant/schema";
|
|
5
4
|
import { joinPaths } from "@stryke/path/join";
|
|
6
5
|
import { isSetArray } from "@stryke/type-checks/is-set-array";
|
|
7
6
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
@@ -136,16 +135,33 @@ async function extractEnv(context) {
|
|
|
136
135
|
context.env ??= {};
|
|
137
136
|
context.env.parsed ??= {};
|
|
138
137
|
context.env.injected ??= [];
|
|
139
|
-
context.env.config = await extract(context
|
|
138
|
+
context.env.config = await extract(context.config.env.config);
|
|
140
139
|
context.env.config.active = await readActive(context, "config");
|
|
141
|
-
if (isSetString(context.config.env.config) && new RegExp(`${defaultConfig.file}[:#;@]?${defaultConfig.export}`).test(context.config.env.config) === false || isSetObject(context.config.env.config) && (context.config.env.config.file !== defaultConfig.file || context.config.env.config.export !== defaultConfig.export)) context.env.config.schema = merge(await extract(
|
|
142
|
-
context.env.secrets = await extract(context
|
|
140
|
+
if (isSetString(context.config.env.config) && new RegExp(`${defaultConfig.file}[:#;@]?${defaultConfig.export}`).test(context.config.env.config) === false || isSetObject(context.config.env.config) && (context.config.env.config.file !== defaultConfig.file || context.config.env.config.export !== defaultConfig.export)) context.env.config.schema = merge(await extract(defaultConfig), context.env.config);
|
|
141
|
+
context.env.secrets = await extract(context.config.env.secrets);
|
|
143
142
|
context.env.secrets.active = await readActive(context, "secrets");
|
|
144
|
-
if (isSetString(context.config.env.secrets) && new RegExp(`${defaultSecrets.file}[:#;@]?${defaultSecrets.export}`).test(context.config.env.secrets) === false || isSetObject(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecrets.file || context.config.env.secrets.export !== defaultSecrets.export)) context.env.secrets.schema = merge(await extract(
|
|
143
|
+
if (isSetString(context.config.env.secrets) && new RegExp(`${defaultSecrets.file}[:#;@]?${defaultSecrets.export}`).test(context.config.env.secrets) === false || isSetObject(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecrets.file || context.config.env.secrets.export !== defaultSecrets.export)) context.env.secrets.schema = merge(await extract(defaultSecrets), context.env.secrets);
|
|
145
144
|
const properties = getProperties(context.env.config);
|
|
145
|
+
const describeVariant = __assignType((variant) => {
|
|
146
|
+
switch (variant) {
|
|
147
|
+
case "json-schema": return "JSON Schema";
|
|
148
|
+
case "standard-schema": return "Standard Schema";
|
|
149
|
+
case "zod3": return "Zod v3 schema";
|
|
150
|
+
case "valibot": return "Valibot schema";
|
|
151
|
+
case "untyped": return "Untyped configuration";
|
|
152
|
+
case "file-reference": return "Typescript exported type";
|
|
153
|
+
default: return variant;
|
|
154
|
+
}
|
|
155
|
+
}, [
|
|
156
|
+
() => __ΩEnvSchema,
|
|
157
|
+
"variant",
|
|
158
|
+
"variant",
|
|
159
|
+
"",
|
|
160
|
+
"Pn!.\"f2#\"/$"
|
|
161
|
+
]);
|
|
146
162
|
context.info({
|
|
147
163
|
meta: { category: "env" },
|
|
148
|
-
message: `Environment Variables configuration: ${context.config.env.config ? "" : "Defaulted "}${context.env.config.variant
|
|
164
|
+
message: `Environment Variables configuration: ${context.config.env.config ? "" : "Defaulted "}${describeVariant(context.env.config.variant)}${context.config.env.config ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${context.config.env.secrets ? "" : "Defaulted "}${describeVariant(context.env.secrets.variant)}${context.config.env.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? 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"}`
|
|
149
165
|
});
|
|
150
166
|
const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => isSetArray(prop.alias) ? prop.alias?.map(__assignType((alias) => [alias, {
|
|
151
167
|
...prop,
|
|
@@ -255,12 +271,7 @@ extractEnv.__type = [
|
|
|
255
271
|
* @returns A promise that resolves when the schema has been successfully written to the cache directory.
|
|
256
272
|
*/
|
|
257
273
|
async function writeEnv(context) {
|
|
258
|
-
return Promise.all([
|
|
259
|
-
writeSchema(context, omit(context.env.config, ["active"])),
|
|
260
|
-
writeSchema(context, omit(context.env.secrets, ["active"])),
|
|
261
|
-
writeActive(context, "config", context.env.config),
|
|
262
|
-
writeActive(context, "secrets", context.env.secrets)
|
|
263
|
-
]);
|
|
274
|
+
return Promise.all([writeActive(context, "config", context.env.config), writeActive(context, "secrets", context.env.secrets)]);
|
|
264
275
|
}
|
|
265
276
|
writeEnv.__type = [
|
|
266
277
|
"context",
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
|
+
import { JsonSchemaObject, SchemaConfig, SchemaEnvelope } from "@power-plant/schema";
|
|
2
3
|
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
3
4
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
4
|
-
import { JsonSchemaObject, Schema, SchemaInput } from "@powerlines/schema";
|
|
5
5
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
6
6
|
import { RequiredKeys } from "@stryke/types";
|
|
7
7
|
import { DotenvConfiguration } from "@stryke/types/configuration";
|
|
@@ -11,11 +11,11 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
11
11
|
/**
|
|
12
12
|
* A path to the type definition for the expected env configuration parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `":"` or `"#"` character. For example: `"./src/types/env.ts#ConfigConfiguration"`.
|
|
13
13
|
*/
|
|
14
|
-
config?:
|
|
14
|
+
config?: SchemaConfig;
|
|
15
15
|
/**
|
|
16
16
|
* A path to the type definition for the expected env secret parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `":"` or `"#"` character. For example: `"./src/types/env.ts#ConfigSecrets"`.
|
|
17
17
|
*/
|
|
18
|
-
secrets?:
|
|
18
|
+
secrets?: SchemaConfig;
|
|
19
19
|
/**
|
|
20
20
|
* An additional prefix (or list of additional prefixes) to apply to the environment variables
|
|
21
21
|
*
|
|
@@ -91,7 +91,7 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
|
91
91
|
* @remarks
|
|
92
92
|
* This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.config} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.
|
|
93
93
|
*/
|
|
94
|
-
type EnvSchema =
|
|
94
|
+
type EnvSchema = SchemaEnvelope<JsonSchemaObject> & {
|
|
95
95
|
/**
|
|
96
96
|
* The list of active environment variables or secrets that should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled. This list is determined by filtering the properties defined in the schema based on the provided prefix and any additional filtering criteria defined in the type definition, such as an `active` property.
|
|
97
97
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;KAmCY;KAEA,mBAAmB,KAAK;;;;EAIlC,SAAS;;;;EAKT,UAAU;;;;;;;EAQV;;;;;;EAOA;;;;;;EAOA;;;;;;;EAQA,gBAAgB;;;;;;;EAQhB,QAAQ;;;;;;;EAQR,SAAS;;KAGC,sBAAsB;EAChC,KAAK;;KAGK,0BAA0B;EACpC,KAAK,SAAS,KAAK,2CACjB,aAAa;;;;;;;IAOX;;;;;;;IAQA;;;;;;;IAQA;;;;;;;;;KAUM,YAAY,eAAe;;;;;;;EAOrC;;UAGe,iBACf,wBAAwB,0BAA0B,iCAC1C,mBAAmB;EAC3B;;;;;;;IAOE,QAAQ;;;;;;;IAQR,SAAS;;;;;;;IAQT,QAAQ;;;;;;;IAQR"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
2
|
-
import { JsonSchemaObject,
|
|
2
|
+
import { JsonSchemaObject, SchemaConfig, SchemaEnvelope } from "@power-plant/schema";
|
|
3
3
|
import { Children } from "@alloy-js/core";
|
|
4
4
|
import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
|
|
5
5
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
|
|
@@ -11,11 +11,11 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
11
11
|
/**
|
|
12
12
|
* A path to the type definition for the expected env configuration parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `":"` or `"#"` character. For example: `"./src/types/env.ts#ConfigConfiguration"`.
|
|
13
13
|
*/
|
|
14
|
-
config?:
|
|
14
|
+
config?: SchemaConfig;
|
|
15
15
|
/**
|
|
16
16
|
* A path to the type definition for the expected env secret parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `":"` or `"#"` character. For example: `"./src/types/env.ts#ConfigSecrets"`.
|
|
17
17
|
*/
|
|
18
|
-
secrets?:
|
|
18
|
+
secrets?: SchemaConfig;
|
|
19
19
|
/**
|
|
20
20
|
* An additional prefix (or list of additional prefixes) to apply to the environment variables
|
|
21
21
|
*
|
|
@@ -91,7 +91,7 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
|
91
91
|
* @remarks
|
|
92
92
|
* This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.config} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.
|
|
93
93
|
*/
|
|
94
|
-
type EnvSchema =
|
|
94
|
+
type EnvSchema = SchemaEnvelope<JsonSchemaObject> & {
|
|
95
95
|
/**
|
|
96
96
|
* The list of active environment variables or secrets that should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled. This list is determined by filtering the properties defined in the schema based on the provided prefix and any additional filtering criteria defined in the type definition, such as an `active` property.
|
|
97
97
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-env",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.351",
|
|
4
4
|
"private": false,
|
|
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
|
"keywords": ["dotenv", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -244,19 +244,19 @@
|
|
|
244
244
|
"typings": "dist/index.d.mts",
|
|
245
245
|
"files": ["dist"],
|
|
246
246
|
"dependencies": {
|
|
247
|
-
"@alloy-js/core": "^0.
|
|
248
|
-
"@alloy-js/json": "^0.
|
|
249
|
-
"@alloy-js/markdown": "^0.
|
|
250
|
-
"@alloy-js/typescript": "^0.
|
|
247
|
+
"@alloy-js/core": "^0.24.1",
|
|
248
|
+
"@alloy-js/json": "^0.24.0",
|
|
249
|
+
"@alloy-js/markdown": "^0.24.0",
|
|
250
|
+
"@alloy-js/typescript": "^0.24.0",
|
|
251
251
|
"@babel/core": "^8.0.1",
|
|
252
252
|
"@babel/types": "^8.0.4",
|
|
253
253
|
"@power-plant/alloy-js": "^0.0.20",
|
|
254
|
-
"@powerlines/core": "^0.48.
|
|
255
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
256
|
-
"@powerlines/plugin-automd": "^0.1.
|
|
257
|
-
"@powerlines/plugin-babel": "^0.13.
|
|
258
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
259
|
-
"@
|
|
254
|
+
"@powerlines/core": "^0.48.68",
|
|
255
|
+
"@powerlines/plugin-alloy": "^0.26.240",
|
|
256
|
+
"@powerlines/plugin-automd": "^0.1.608",
|
|
257
|
+
"@powerlines/plugin-babel": "^0.13.143",
|
|
258
|
+
"@powerlines/plugin-plugin": "^0.12.559",
|
|
259
|
+
"@power-plant/schema": "^0.0.22",
|
|
260
260
|
"@storm-software/config-tools": "^1.190.109",
|
|
261
261
|
"@stryke/capnp": "^0.12.123",
|
|
262
262
|
"@stryke/convert": "^0.7.27",
|
|
@@ -271,9 +271,9 @@
|
|
|
271
271
|
"automd": "^0.4.3",
|
|
272
272
|
"c12": "^3.3.4",
|
|
273
273
|
"defu": "^6.1.7",
|
|
274
|
-
"powerlines": "^0.47.
|
|
274
|
+
"powerlines": "^0.47.147"
|
|
275
275
|
},
|
|
276
276
|
"devDependencies": { "@types/node": "^25.9.5", "vite": "^8.1.5" },
|
|
277
277
|
"publishConfig": { "access": "public" },
|
|
278
|
-
"gitHead": "
|
|
278
|
+
"gitHead": "af891c3e728ec71f441887e7f1bb92272c6823fe"
|
|
279
279
|
}
|