@powerlines/plugin-env 0.16.348 → 0.16.350
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 +16 -15
- package/dist/components/docs.d.cts +1 -1
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +1 -1
- package/dist/components/docs.mjs +6 -5
- package/dist/components/env-builtin.cjs +37 -35
- package/dist/components/env-builtin.d.cts +2 -2
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts +2 -2
- package/dist/components/env-builtin.mjs +6 -4
- 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 +26 -25
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,15 +1,16 @@
|
|
|
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");
|
|
7
7
|
let _alloy_js_core = require("@alloy-js/core");
|
|
8
|
-
let
|
|
8
|
+
let _power_plant_alloy_js_core_components_spacing = require("@power-plant/alloy-js/core/components/spacing");
|
|
9
|
+
let _power_plant_alloy_js_markdown_components_heading = require("@power-plant/alloy-js/markdown/components/heading");
|
|
10
|
+
let _power_plant_alloy_js_markdown_components_markdown_file = require("@power-plant/alloy-js/markdown/components/markdown-file");
|
|
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");
|
|
9
13
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
10
|
-
let _powerlines_plugin_alloy_markdown_components_heading = require("@powerlines/plugin-alloy/markdown/components/heading");
|
|
11
|
-
let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
|
|
12
|
-
let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
|
|
13
14
|
|
|
14
15
|
//#region src/components/docs.tsx
|
|
15
16
|
const __ΩPartial = [
|
|
@@ -35,25 +36,25 @@ const __ΩEnvDocsFileProps = [
|
|
|
35
36
|
function EnvDocsFile(props) {
|
|
36
37
|
const { levelOffset = 0, ...rest } = props;
|
|
37
38
|
const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
|
|
38
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
39
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_markdown_components_markdown_file.MarkdownFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
|
|
39
40
|
return (0, _stryke_path_join.joinPaths)((0, powerlines_plugin_utils.getDocsOutputPath)(context.config.root), "env.md");
|
|
40
41
|
} }, rest, { get children() {
|
|
41
42
|
return [
|
|
42
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
43
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_markdown_components_heading.Heading, {
|
|
43
44
|
level: 1 + levelOffset,
|
|
44
45
|
children: "Environment"
|
|
45
46
|
}),
|
|
46
47
|
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The ${context.config.name} package uses various configuration parameters to control the behavior of the application. These parameters can be provided as environment variables when the application is run, or they can be defined in a \`config.json\` file in the application configuration directory.`),
|
|
47
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
48
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
48
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
49
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_markdown_components_heading.Heading, {
|
|
49
50
|
level: 2 + levelOffset,
|
|
50
51
|
children: "Configuration"
|
|
51
52
|
}),
|
|
52
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
53
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
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
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
55
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
56
|
-
return (0,
|
|
55
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
56
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_markdown_components_markdown_table.MarkdownTable, { get data() {
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { MarkdownFileProps } from "@
|
|
1
|
+
import { MarkdownFileProps } from "@power-plant/alloy-js/markdown/components/markdown-file";
|
|
2
2
|
//#region src/components/docs.d.ts
|
|
3
3
|
interface EnvDocsFileProps extends Partial<MarkdownFileProps> {
|
|
4
4
|
/**
|
|
@@ -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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarkdownFileProps } from "@
|
|
1
|
+
import { MarkdownFileProps } from "@power-plant/alloy-js/markdown/components/markdown-file";
|
|
2
2
|
//#region src/components/docs.d.ts
|
|
3
3
|
interface EnvDocsFileProps extends Partial<MarkdownFileProps> {
|
|
4
4
|
/**
|
package/dist/components/docs.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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";
|
|
6
6
|
import { code } from "@alloy-js/core";
|
|
7
|
-
import { Spacing } from "@
|
|
7
|
+
import { Spacing } from "@power-plant/alloy-js/core/components/spacing";
|
|
8
|
+
import { Heading } from "@power-plant/alloy-js/markdown/components/heading";
|
|
9
|
+
import { MarkdownFile } from "@power-plant/alloy-js/markdown/components/markdown-file";
|
|
10
|
+
import { MarkdownTable } from "@power-plant/alloy-js/markdown/components/markdown-table";
|
|
11
|
+
import { stringifyType } from "@power-plant/schema/codegen";
|
|
8
12
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
9
|
-
import { Heading } from "@powerlines/plugin-alloy/markdown/components/heading";
|
|
10
|
-
import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
|
|
11
|
-
import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
|
|
12
13
|
|
|
13
14
|
//#region src/components/docs.tsx
|
|
14
15
|
const __ΩPartial = [
|
|
@@ -1,15 +1,17 @@
|
|
|
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
|
-
let
|
|
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");
|
|
11
|
+
let _power_plant_alloy_js_typescript_components = require("@power-plant/alloy-js/typescript/components");
|
|
12
|
+
let _power_plant_alloy_js_typescript_components_tsdoc = require("@power-plant/alloy-js/typescript/components/tsdoc");
|
|
10
13
|
let _powerlines_plugin_alloy_helpers_refkey = require("@powerlines/plugin-alloy/helpers/refkey");
|
|
11
14
|
let _powerlines_plugin_alloy_typescript_components = require("@powerlines/plugin-alloy/typescript/components");
|
|
12
|
-
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
13
15
|
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
14
16
|
let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
|
|
15
17
|
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
@@ -51,16 +53,16 @@ function EnvTypeDefinition(props) {
|
|
|
51
53
|
const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["EnvPluginContext", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
|
|
52
54
|
const { schema } = props;
|
|
53
55
|
return [
|
|
54
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
56
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components.InterfaceDeclaration, {
|
|
55
57
|
name: "UnprefixedEnv",
|
|
56
58
|
schema,
|
|
57
59
|
"export": true
|
|
58
60
|
}),
|
|
59
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
60
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
61
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
62
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDoc, {
|
|
61
63
|
heading: "The environment configuration object with prefixed keys.",
|
|
62
64
|
get children() {
|
|
63
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
65
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocRemarks, { children: `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.` });
|
|
64
66
|
}
|
|
65
67
|
}),
|
|
66
68
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
@@ -80,7 +82,7 @@ function EnvTypeDefinition(props) {
|
|
|
80
82
|
get children() {
|
|
81
83
|
return __assignType((prefix) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
82
84
|
get each() {
|
|
83
|
-
return (0,
|
|
85
|
+
return (0, _power_plant_schema.getPropertiesList)(schema).filter(__assignType((property) => !property.ignore, [
|
|
84
86
|
"property",
|
|
85
87
|
"",
|
|
86
88
|
"P\"2!\"/\""
|
|
@@ -88,7 +90,7 @@ function EnvTypeDefinition(props) {
|
|
|
88
90
|
},
|
|
89
91
|
doubleHardline: true,
|
|
90
92
|
get children() {
|
|
91
|
-
return __assignType((property) => [(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
93
|
+
return __assignType((property) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components.TSDocSchemaProperty, {
|
|
92
94
|
get schema() {
|
|
93
95
|
return {
|
|
94
96
|
...property,
|
|
@@ -102,7 +104,7 @@ function EnvTypeDefinition(props) {
|
|
|
102
104
|
get defaultValue() {
|
|
103
105
|
return property?.default;
|
|
104
106
|
}
|
|
105
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
107
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components.InterfaceMember, {
|
|
106
108
|
get name() {
|
|
107
109
|
return `${prefix}_${property.name}`;
|
|
108
110
|
},
|
|
@@ -131,7 +133,7 @@ function EnvTypeDefinition(props) {
|
|
|
131
133
|
});
|
|
132
134
|
}
|
|
133
135
|
}),
|
|
134
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
136
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {})
|
|
135
137
|
];
|
|
136
138
|
}
|
|
137
139
|
EnvTypeDefinition.__type = [
|
|
@@ -365,7 +367,7 @@ function EnvBuiltin(props) {
|
|
|
365
367
|
]));
|
|
366
368
|
return result;
|
|
367
369
|
});
|
|
368
|
-
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, [
|
|
369
371
|
"property",
|
|
370
372
|
"",
|
|
371
373
|
"P\"2!\"/\""
|
|
@@ -375,7 +377,7 @@ function EnvBuiltin(props) {
|
|
|
375
377
|
"",
|
|
376
378
|
"P\"2!\"2\"\"/#"
|
|
377
379
|
])) ?? []);
|
|
378
|
-
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, [
|
|
379
381
|
"property",
|
|
380
382
|
"",
|
|
381
383
|
"P\"2!\"/\""
|
|
@@ -385,7 +387,7 @@ function EnvBuiltin(props) {
|
|
|
385
387
|
"",
|
|
386
388
|
"P\"2!\"2\"\"/#"
|
|
387
389
|
])) ?? []);
|
|
388
|
-
const parserCode = (0,
|
|
390
|
+
const parserCode = (0, _power_plant_schema_codegen.generateParserCode)(schema.value);
|
|
389
391
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
390
392
|
id: "env",
|
|
391
393
|
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
@@ -398,10 +400,10 @@ function EnvBuiltin(props) {
|
|
|
398
400
|
get children() {
|
|
399
401
|
return [(0, _alloy_js_core_jsx_runtime.createComponent)(EnvTypeDefinition, { get schema() {
|
|
400
402
|
return schema.value;
|
|
401
|
-
} }), (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
403
|
+
} }), (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {})];
|
|
402
404
|
}
|
|
403
405
|
}),
|
|
404
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
406
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components.ObjectDeclaration, {
|
|
405
407
|
name: "initialEnv",
|
|
406
408
|
type: "Partial<Env>",
|
|
407
409
|
get schema() {
|
|
@@ -411,28 +413,28 @@ function EnvBuiltin(props) {
|
|
|
411
413
|
"const": true,
|
|
412
414
|
doc: "The initial environment configuration object values for the runtime."
|
|
413
415
|
}),
|
|
414
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
416
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
415
417
|
parserCode,
|
|
416
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
418
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
417
419
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
418
420
|
get when() {
|
|
419
421
|
return Boolean(context?.entryPath);
|
|
420
422
|
},
|
|
421
423
|
get children() {
|
|
422
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
424
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDoc, {
|
|
423
425
|
get heading() {
|
|
424
426
|
return `Initializes the ${context?.config?.framework?.name || "Powerlines"} environment configuration module.`;
|
|
425
427
|
},
|
|
426
428
|
get children() {
|
|
427
429
|
return [
|
|
428
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
430
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocRemarks, { get children() {
|
|
429
431
|
return `This function initializes the ${context?.config?.framework?.name || "Powerlines"} environment configuration object.`;
|
|
430
432
|
} }),
|
|
431
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
433
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocParam, {
|
|
432
434
|
name: "environmentConfig",
|
|
433
435
|
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
434
436
|
}),
|
|
435
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
437
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocReturns, { get children() {
|
|
436
438
|
return `The initialized ${context?.config?.framework?.name || "Powerlines"} configuration object.`;
|
|
437
439
|
} })
|
|
438
440
|
];
|
|
@@ -483,7 +485,7 @@ function EnvBuiltin(props) {
|
|
|
483
485
|
_alloy_js_core.code`
|
|
484
486
|
return undefined;
|
|
485
487
|
}, `,
|
|
486
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
488
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
487
489
|
_alloy_js_core.code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `,
|
|
488
490
|
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
489
491
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
@@ -518,13 +520,13 @@ function EnvBuiltin(props) {
|
|
|
518
520
|
})];
|
|
519
521
|
}
|
|
520
522
|
}),
|
|
521
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
522
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
523
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
524
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDoc, {
|
|
523
525
|
get heading() {
|
|
524
526
|
return `The ${context?.config?.framework?.name || "Powerlines"} environment configuration object.`;
|
|
525
527
|
},
|
|
526
528
|
get children() {
|
|
527
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
529
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocRemarks, { get children() {
|
|
528
530
|
return `This object provides access to the ${context?.config?.framework?.name || "Powerlines"} environment configuration parameters in the application runtime.`;
|
|
529
531
|
} });
|
|
530
532
|
}
|
|
@@ -539,7 +541,7 @@ function EnvBuiltin(props) {
|
|
|
539
541
|
return [_alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
540
542
|
}
|
|
541
543
|
}),
|
|
542
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
544
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
543
545
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
544
546
|
"export": true,
|
|
545
547
|
"const": true,
|
|
@@ -599,11 +601,11 @@ function EnvBuiltin(props) {
|
|
|
599
601
|
env.XCS || false
|
|
600
602
|
); `
|
|
601
603
|
}),
|
|
602
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
603
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
604
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
605
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDoc, {
|
|
604
606
|
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
605
607
|
get children() {
|
|
606
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
608
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_typescript_components_tsdoc.TSDocRemarks, { children: _alloy_js_core.code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:
|
|
607
609
|
- \`production\`
|
|
608
610
|
- \`test\`
|
|
609
611
|
- \`development\`
|
|
@@ -616,7 +618,7 @@ function EnvBuiltin(props) {
|
|
|
616
618
|
name: "mode",
|
|
617
619
|
initializer: _alloy_js_core.code`String(env.MODE) || "production"; `
|
|
618
620
|
}),
|
|
619
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
621
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
620
622
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
621
623
|
"export": true,
|
|
622
624
|
"const": true,
|
|
@@ -624,7 +626,7 @@ function EnvBuiltin(props) {
|
|
|
624
626
|
doc: "Detect if the application is running in `\"production\"` mode",
|
|
625
627
|
initializer: _alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
626
628
|
}),
|
|
627
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
629
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
628
630
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
629
631
|
"export": true,
|
|
630
632
|
"const": true,
|
|
@@ -632,7 +634,7 @@ function EnvBuiltin(props) {
|
|
|
632
634
|
doc: "Detect if the application is running in `\"test\"` mode",
|
|
633
635
|
initializer: _alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
634
636
|
}),
|
|
635
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
637
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
636
638
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
637
639
|
"export": true,
|
|
638
640
|
"const": true,
|
|
@@ -640,7 +642,7 @@ function EnvBuiltin(props) {
|
|
|
640
642
|
doc: "Detect if the application is running in `\"development\"` mode",
|
|
641
643
|
initializer: _alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
642
644
|
}),
|
|
643
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
645
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
644
646
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
645
647
|
"export": true,
|
|
646
648
|
"const": true,
|
|
@@ -648,7 +650,7 @@ function EnvBuiltin(props) {
|
|
|
648
650
|
doc: "Detect if the application is currently being debugged",
|
|
649
651
|
initializer: _alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `
|
|
650
652
|
}),
|
|
651
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
653
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_power_plant_alloy_js_core_components_spacing.Spacing, {}),
|
|
652
654
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
653
655
|
get when() {
|
|
654
656
|
return Boolean(children);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { JsonSchemaObject } from "@
|
|
3
|
-
import { ComponentProps } from "@
|
|
2
|
+
import { JsonSchemaObject } from "@power-plant/schema";
|
|
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
|
|
6
6
|
interface EnvTypeDefinitionProps extends ComponentProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.d.cts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"env-builtin.d.cts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;;UAmEiB,+BAA+B;EAC9C,QAAQ;;;;;iBAMM,kBAAkB,OAAO,yBAAsB;UA6L9C,wBAAwB,KAAK;EAC5C,gBAAgB;;;;;iBASF,WAAW,OAAO,kBAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
import { ComponentProps } from "@
|
|
4
|
+
import { ComponentProps } from "@power-plant/alloy-js/core/types/components";
|
|
5
5
|
//#region src/components/env-builtin.d.ts
|
|
6
6
|
interface EnvTypeDefinitionProps extends ComponentProps {
|
|
7
7
|
schema: JsonSchemaObject;
|
|
@@ -1,14 +1,16 @@
|
|
|
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
|
-
import { Spacing } from "@
|
|
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";
|
|
10
|
+
import { InterfaceDeclaration as InterfaceDeclaration$1, InterfaceMember, ObjectDeclaration, TSDocSchemaProperty } from "@power-plant/alloy-js/typescript/components";
|
|
11
|
+
import { TSDoc, TSDocParam, TSDocRemarks, TSDocReturns } from "@power-plant/alloy-js/typescript/components/tsdoc";
|
|
9
12
|
import { refkey } from "@powerlines/plugin-alloy/helpers/refkey";
|
|
10
|
-
import { BuiltinFile
|
|
11
|
-
import { TSDoc, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
13
|
+
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components";
|
|
12
14
|
import { toArray } from "@stryke/convert/to-array";
|
|
13
15
|
import { deepClone } from "@stryke/helpers/deep-clone";
|
|
14
16
|
import { getUnique } from "@stryke/helpers/get-unique";
|
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.350",
|
|
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,35 +244,36 @@
|
|
|
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
|
-
"@
|
|
254
|
-
"@powerlines/
|
|
255
|
-
"@powerlines/plugin-
|
|
256
|
-
"@powerlines/plugin-
|
|
257
|
-
"@powerlines/plugin-
|
|
258
|
-
"@powerlines/
|
|
259
|
-
"@
|
|
260
|
-
"@
|
|
261
|
-
"@stryke/
|
|
262
|
-
"@stryke/
|
|
263
|
-
"@stryke/
|
|
264
|
-
"@stryke/
|
|
265
|
-
"@stryke/
|
|
266
|
-
"@stryke/
|
|
267
|
-
"@stryke/
|
|
268
|
-
"@stryke/
|
|
269
|
-
"@stryke/
|
|
253
|
+
"@power-plant/alloy-js": "^0.0.20",
|
|
254
|
+
"@powerlines/core": "^0.48.67",
|
|
255
|
+
"@powerlines/plugin-alloy": "^0.26.239",
|
|
256
|
+
"@powerlines/plugin-automd": "^0.1.607",
|
|
257
|
+
"@powerlines/plugin-babel": "^0.13.142",
|
|
258
|
+
"@powerlines/plugin-plugin": "^0.12.558",
|
|
259
|
+
"@power-plant/schema": "^0.0.22",
|
|
260
|
+
"@storm-software/config-tools": "^1.190.109",
|
|
261
|
+
"@stryke/capnp": "^0.12.123",
|
|
262
|
+
"@stryke/convert": "^0.7.27",
|
|
263
|
+
"@stryke/env": "^0.20.114",
|
|
264
|
+
"@stryke/fs": "^0.33.97",
|
|
265
|
+
"@stryke/helpers": "^0.10.36",
|
|
266
|
+
"@stryke/json": "^0.15.20",
|
|
267
|
+
"@stryke/path": "^0.29.23",
|
|
268
|
+
"@stryke/string-format": "^0.17.38",
|
|
269
|
+
"@stryke/type-checks": "^0.6.29",
|
|
270
|
+
"@stryke/types": "^0.12.24",
|
|
270
271
|
"automd": "^0.4.3",
|
|
271
272
|
"c12": "^3.3.4",
|
|
272
273
|
"defu": "^6.1.7",
|
|
273
|
-
"powerlines": "0.47.
|
|
274
|
+
"powerlines": "^0.47.146"
|
|
274
275
|
},
|
|
275
|
-
"devDependencies": { "@types/node": "^25.9.5", "vite": "^8.1.
|
|
276
|
+
"devDependencies": { "@types/node": "^25.9.5", "vite": "^8.1.5" },
|
|
276
277
|
"publishConfig": { "access": "public" },
|
|
277
|
-
"gitHead": "
|
|
278
|
+
"gitHead": "e86d6fab3bd4d2e2f9f6d05df8df7a07d399857e"
|
|
278
279
|
}
|