@powerlines/plugin-env 0.16.84 → 0.16.86
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/babel/index.cjs +4 -0
- package/dist/babel/index.d.cts +2 -0
- package/dist/babel/index.d.mts +2 -0
- package/dist/babel/index.mjs +3 -0
- package/dist/babel/plugin.cjs +144 -0
- package/dist/babel/plugin.d.cts +8 -0
- package/dist/babel/plugin.d.cts.map +1 -0
- package/dist/babel/plugin.d.mts +8 -0
- package/dist/babel/plugin.d.mts.map +1 -0
- package/dist/babel/plugin.mjs +143 -0
- package/dist/babel/plugin.mjs.map +1 -0
- package/dist/components/docs.cjs +70 -0
- package/dist/components/docs.d.cts +25 -0
- package/dist/components/docs.d.cts.map +1 -0
- package/dist/components/docs.d.mts +25 -0
- package/dist/components/docs.d.mts.map +1 -0
- package/dist/components/docs.mjs +69 -0
- package/dist/components/docs.mjs.map +1 -0
- package/dist/components/env-builtin.cjs +568 -0
- package/dist/components/env-builtin.d.cts +22 -0
- package/dist/components/env-builtin.d.cts.map +1 -0
- package/dist/components/env-builtin.d.mts +22 -0
- package/dist/components/env-builtin.d.mts.map +1 -0
- package/dist/components/env-builtin.mjs +565 -0
- package/dist/components/env-builtin.mjs.map +1 -0
- package/dist/components/index.cjs +7 -0
- package/dist/components/index.d.cts +3 -0
- package/dist/components/index.d.mts +3 -0
- package/dist/components/index.mjs +4 -0
- package/dist/helpers/automd-generator.cjs +33 -0
- package/dist/helpers/automd-generator.d.cts +14 -0
- package/dist/helpers/automd-generator.d.cts.map +1 -0
- package/dist/helpers/automd-generator.d.mts +14 -0
- package/dist/helpers/automd-generator.d.mts.map +1 -0
- package/dist/helpers/automd-generator.mjs +32 -0
- package/dist/helpers/automd-generator.mjs.map +1 -0
- package/dist/helpers/create-reflection-resource.cjs +23 -0
- package/dist/helpers/create-reflection-resource.d.cts +13 -0
- package/dist/helpers/create-reflection-resource.d.cts.map +1 -0
- package/dist/helpers/create-reflection-resource.d.mts +13 -0
- package/dist/helpers/create-reflection-resource.d.mts.map +1 -0
- package/dist/helpers/create-reflection-resource.mjs +23 -0
- package/dist/helpers/create-reflection-resource.mjs.map +1 -0
- package/dist/helpers/docs-helper.cjs +25 -0
- package/dist/helpers/docs-helper.d.cts +13 -0
- package/dist/helpers/docs-helper.d.cts.map +1 -0
- package/dist/helpers/docs-helper.d.mts +13 -0
- package/dist/helpers/docs-helper.d.mts.map +1 -0
- package/dist/helpers/docs-helper.mjs +24 -0
- package/dist/helpers/docs-helper.mjs.map +1 -0
- package/dist/helpers/index.cjs +34 -0
- package/dist/helpers/index.d.cts +7 -0
- package/dist/helpers/index.d.mts +7 -0
- package/dist/helpers/index.mjs +8 -0
- package/dist/helpers/load.cjs +136 -0
- package/dist/helpers/load.d.cts +35 -0
- package/dist/helpers/load.d.cts.map +1 -0
- package/dist/helpers/load.d.mts +35 -0
- package/dist/helpers/load.d.mts.map +1 -0
- package/dist/helpers/load.mjs +133 -0
- package/dist/helpers/load.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +323 -0
- package/dist/helpers/persistence.d.cts +84 -0
- package/dist/helpers/persistence.d.cts.map +1 -0
- package/dist/helpers/persistence.d.mts +84 -0
- package/dist/helpers/persistence.d.mts.map +1 -0
- package/dist/helpers/persistence.mjs +311 -0
- package/dist/helpers/persistence.mjs.map +1 -0
- package/dist/helpers/reflect.cjs +299 -0
- package/dist/helpers/reflect.d.cts +69 -0
- package/dist/helpers/reflect.d.cts.map +1 -0
- package/dist/helpers/reflect.d.mts +69 -0
- package/dist/helpers/reflect.d.mts.map +1 -0
- package/dist/helpers/reflect.mjs +290 -0
- package/dist/helpers/reflect.mjs.map +1 -0
- package/dist/helpers/source-file-env.cjs +59 -0
- package/dist/helpers/source-file-env.d.cts +9 -0
- package/dist/helpers/source-file-env.d.cts.map +1 -0
- package/dist/helpers/source-file-env.d.mts +9 -0
- package/dist/helpers/source-file-env.d.mts.map +1 -0
- package/dist/helpers/source-file-env.mjs +57 -0
- package/dist/helpers/source-file-env.mjs.map +1 -0
- package/dist/helpers/template-helpers.cjs +71 -0
- package/dist/helpers/template-helpers.d.cts +15 -0
- package/dist/helpers/template-helpers.d.cts.map +1 -0
- package/dist/helpers/template-helpers.d.mts +15 -0
- package/dist/helpers/template-helpers.d.mts.map +1 -0
- package/dist/helpers/template-helpers.mjs +70 -0
- package/dist/helpers/template-helpers.mjs.map +1 -0
- package/dist/index.cjs +195 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +189 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.cjs +11 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +137 -0
- package/dist/types/plugin.d.cts +168 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +168 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +132 -0
- package/dist/types/plugin.mjs.map +1 -0
- package/dist/types/runtime.cjs +244 -0
- package/dist/types/runtime.d.cts +792 -0
- package/dist/types/runtime.d.cts.map +1 -0
- package/dist/types/runtime.d.mts +792 -0
- package/dist/types/runtime.d.mts.map +1 -0
- package/dist/types/runtime.mjs +242 -0
- package/dist/types/runtime.mjs.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
|
+
let _powerlines_plugin_babel_types_config = require("@powerlines/plugin-babel/types/config");
|
|
5
|
+
let _babel_core = require("@babel/core");
|
|
6
|
+
let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
7
|
+
let _powerlines_plugin_babel_helpers_create_plugin = require("@powerlines/plugin-babel/helpers/create-plugin");
|
|
8
|
+
let _powerlines_plugin_babel_helpers_module_helpers = require("@powerlines/plugin-babel/helpers/module-helpers");
|
|
9
|
+
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
10
|
+
|
|
11
|
+
//#region src/babel/plugin.ts
|
|
12
|
+
function __assignType(fn, args) {
|
|
13
|
+
fn.__type = args;
|
|
14
|
+
return fn;
|
|
15
|
+
}
|
|
16
|
+
const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin)("env", __assignType(({ log, context }) => {
|
|
17
|
+
function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
|
|
18
|
+
const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
19
|
+
"prop",
|
|
20
|
+
"",
|
|
21
|
+
"P\"2!\"/\""
|
|
22
|
+
]));
|
|
23
|
+
if (node.name) {
|
|
24
|
+
const prefix = context.config.env.prefix.find(__assignType((pre) => node.name && node.name.startsWith(pre) && (context.env.types.env?.hasProperty(node.name.replace(`${pre}_`, "")) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(node.name.replace(`${pre}_`, "")), [
|
|
25
|
+
"prop",
|
|
26
|
+
"",
|
|
27
|
+
"P\"2!\"/\""
|
|
28
|
+
]))), [
|
|
29
|
+
"pre",
|
|
30
|
+
"",
|
|
31
|
+
"P\"2!\"/\""
|
|
32
|
+
]));
|
|
33
|
+
let name = node.name;
|
|
34
|
+
if (prefix) name = node.name.replace(`${prefix}_`, "");
|
|
35
|
+
log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
|
|
36
|
+
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(name), [
|
|
37
|
+
"prop",
|
|
38
|
+
"",
|
|
39
|
+
"P\"2!\"/\""
|
|
40
|
+
]))) {
|
|
41
|
+
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find(__assignType((prop) => prop.getAlias().includes(name), [
|
|
42
|
+
"prop",
|
|
43
|
+
"",
|
|
44
|
+
"P\"2!\"/\""
|
|
45
|
+
]));
|
|
46
|
+
if (!envProperty || envProperty.isIgnored()) return;
|
|
47
|
+
if (!context.env.used.env.hasProperty(name)) {
|
|
48
|
+
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`);
|
|
49
|
+
context.env.used.env.addProperty(envProperty.property);
|
|
50
|
+
}
|
|
51
|
+
if (context.config.env.inject && isInjectable) {
|
|
52
|
+
let value = context.env.parsed?.[name];
|
|
53
|
+
if (value === void 0) {
|
|
54
|
+
const prefix = context.config.env.prefix.find(__assignType((pre) => {
|
|
55
|
+
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
56
|
+
}, [
|
|
57
|
+
"pre",
|
|
58
|
+
"",
|
|
59
|
+
"P\"2!\"/\""
|
|
60
|
+
]));
|
|
61
|
+
if (prefix) value = context.env.parsed[`${prefix.replace(/_$/g, "")}_${name}`];
|
|
62
|
+
}
|
|
63
|
+
value ??= envProperty.getDefaultValue();
|
|
64
|
+
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
65
|
+
return (0, _powerlines_deepkit_utilities.stringifyDefaultValue)(envProperty, value);
|
|
66
|
+
}
|
|
67
|
+
} else if (context.config.env.validate) throw new Error(`The "${name}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${pass.filename ? pass.filename : "unknown"}.
|
|
68
|
+
|
|
69
|
+
The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort(__assignType((a, b) => String(a).localeCompare(String(b)), [
|
|
70
|
+
"a",
|
|
71
|
+
"b",
|
|
72
|
+
"",
|
|
73
|
+
"P\"2!\"2\"\"/#"
|
|
74
|
+
])).map(__assignType((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some(__assignType((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0, [
|
|
75
|
+
"prop",
|
|
76
|
+
"",
|
|
77
|
+
"P\"2!\"/\""
|
|
78
|
+
])) ? `(Alias: ${envTypesAliasProperties?.find(__assignType((prop) => prop.getNameAsString() === String(typeDef), [
|
|
79
|
+
"prop",
|
|
80
|
+
"",
|
|
81
|
+
"P\"2!\"/\""
|
|
82
|
+
]))?.getAlias().join(", ")})` : ""}`, [
|
|
83
|
+
"typeDef",
|
|
84
|
+
"",
|
|
85
|
+
"P\"2!\"/\""
|
|
86
|
+
])).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map(__assignType((prefix) => ` - ${prefix}`, [
|
|
87
|
+
"prefix",
|
|
88
|
+
"",
|
|
89
|
+
"P\"2!\"/\""
|
|
90
|
+
])).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
|
|
91
|
+
else if (pass.filename && isUsingBuiltin) context.warn(`The "${name}" environment variable is used in the source code file ${pass.filename}, but is not defined in the \`env\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
extractEnv.__type = [
|
|
95
|
+
"node",
|
|
96
|
+
() => _powerlines_plugin_babel_types_config.__ΩBabelPluginPass,
|
|
97
|
+
"pass",
|
|
98
|
+
"isInjectable",
|
|
99
|
+
"isUsingBuiltin",
|
|
100
|
+
"extractEnv",
|
|
101
|
+
"P!2!n\"2#\"2$\"2%\"/&"
|
|
102
|
+
];
|
|
103
|
+
return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
|
|
104
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
105
|
+
const identifier = path.get("property")?.node;
|
|
106
|
+
if (!identifier.name) return;
|
|
107
|
+
extractEnv(identifier, pass, false, false);
|
|
108
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
109
|
+
(0, _powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
110
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
111
|
+
name: "env",
|
|
112
|
+
imported: "env"
|
|
113
|
+
});
|
|
114
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
115
|
+
const identifier = path.get("property")?.node;
|
|
116
|
+
if (!identifier.name) return;
|
|
117
|
+
extractEnv(identifier, pass, false, false);
|
|
118
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
119
|
+
(0, _powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
120
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
121
|
+
name: "env",
|
|
122
|
+
imported: "env"
|
|
123
|
+
});
|
|
124
|
+
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
125
|
+
const identifier = path.get("property")?.node;
|
|
126
|
+
if (!identifier.name) return;
|
|
127
|
+
extractEnv(identifier, pass, false, true);
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
() => _babel_core.NodePath,
|
|
131
|
+
"path",
|
|
132
|
+
() => _powerlines_plugin_babel_types_config.__ΩBabelPluginPass,
|
|
133
|
+
"pass",
|
|
134
|
+
"MemberExpression",
|
|
135
|
+
"PP!7!2\"n#2$\"/%"
|
|
136
|
+
]) } };
|
|
137
|
+
}, [
|
|
138
|
+
"param0",
|
|
139
|
+
"",
|
|
140
|
+
"P\"2!\"/\""
|
|
141
|
+
])));
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
exports.envBabelPlugin = envBabelPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnvPluginContext, EnvPluginResolvedConfig } from "../types/plugin.cjs";
|
|
2
|
+
import * as _powerlines_plugin_babel0 from "@powerlines/plugin-babel";
|
|
3
|
+
|
|
4
|
+
//#region src/babel/plugin.d.ts
|
|
5
|
+
declare const envBabelPlugin: _powerlines_plugin_babel0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { envBabelPlugin };
|
|
8
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"mappings":";;;;cAiCa,cAAA,EAAc,yBAAA,CAAA,iCAAA,CAAA,gBAAA,CA4M1B,uBAAA,GA5M0B,MAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnvPluginContext, EnvPluginResolvedConfig } from "../types/plugin.mjs";
|
|
2
|
+
import * as _powerlines_plugin_babel0 from "@powerlines/plugin-babel";
|
|
3
|
+
|
|
4
|
+
//#region src/babel/plugin.d.ts
|
|
5
|
+
declare const envBabelPlugin: _powerlines_plugin_babel0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { envBabelPlugin };
|
|
8
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"mappings":";;;;cAiCa,cAAA,EAAc,yBAAA,CAAA,iCAAA,CAAA,gBAAA,CA4M1B,uBAAA,GA5M0B,MAAA"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import { __ΩBabelPluginPass } from "@powerlines/plugin-babel/types/config";
|
|
3
|
+
import { NodePath } from "@babel/core";
|
|
4
|
+
import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
|
|
5
|
+
import { createBabelPlugin } from "@powerlines/plugin-babel/helpers/create-plugin";
|
|
6
|
+
import { addImport } from "@powerlines/plugin-babel/helpers/module-helpers";
|
|
7
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
8
|
+
|
|
9
|
+
//#region src/babel/plugin.ts
|
|
10
|
+
function __assignType(fn, args) {
|
|
11
|
+
fn.__type = args;
|
|
12
|
+
return fn;
|
|
13
|
+
}
|
|
14
|
+
const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!"]], createBabelPlugin("env", __assignType(({ log, context }) => {
|
|
15
|
+
function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
|
|
16
|
+
const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
17
|
+
"prop",
|
|
18
|
+
"",
|
|
19
|
+
"P\"2!\"/\""
|
|
20
|
+
]));
|
|
21
|
+
if (node.name) {
|
|
22
|
+
const prefix = context.config.env.prefix.find(__assignType((pre) => node.name && node.name.startsWith(pre) && (context.env.types.env?.hasProperty(node.name.replace(`${pre}_`, "")) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(node.name.replace(`${pre}_`, "")), [
|
|
23
|
+
"prop",
|
|
24
|
+
"",
|
|
25
|
+
"P\"2!\"/\""
|
|
26
|
+
]))), [
|
|
27
|
+
"pre",
|
|
28
|
+
"",
|
|
29
|
+
"P\"2!\"/\""
|
|
30
|
+
]));
|
|
31
|
+
let name = node.name;
|
|
32
|
+
if (prefix) name = node.name.replace(`${prefix}_`, "");
|
|
33
|
+
log(LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
|
|
34
|
+
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(name), [
|
|
35
|
+
"prop",
|
|
36
|
+
"",
|
|
37
|
+
"P\"2!\"/\""
|
|
38
|
+
]))) {
|
|
39
|
+
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find(__assignType((prop) => prop.getAlias().includes(name), [
|
|
40
|
+
"prop",
|
|
41
|
+
"",
|
|
42
|
+
"P\"2!\"/\""
|
|
43
|
+
]));
|
|
44
|
+
if (!envProperty || envProperty.isIgnored()) return;
|
|
45
|
+
if (!context.env.used.env.hasProperty(name)) {
|
|
46
|
+
log(LogLevelLabel.DEBUG, `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`);
|
|
47
|
+
context.env.used.env.addProperty(envProperty.property);
|
|
48
|
+
}
|
|
49
|
+
if (context.config.env.inject && isInjectable) {
|
|
50
|
+
let value = context.env.parsed?.[name];
|
|
51
|
+
if (value === void 0) {
|
|
52
|
+
const prefix = context.config.env.prefix.find(__assignType((pre) => {
|
|
53
|
+
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
54
|
+
}, [
|
|
55
|
+
"pre",
|
|
56
|
+
"",
|
|
57
|
+
"P\"2!\"/\""
|
|
58
|
+
]));
|
|
59
|
+
if (prefix) value = context.env.parsed[`${prefix.replace(/_$/g, "")}_${name}`];
|
|
60
|
+
}
|
|
61
|
+
value ??= envProperty.getDefaultValue();
|
|
62
|
+
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
63
|
+
return stringifyDefaultValue(envProperty, value);
|
|
64
|
+
}
|
|
65
|
+
} else if (context.config.env.validate) throw new Error(`The "${name}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${pass.filename ? pass.filename : "unknown"}.
|
|
66
|
+
|
|
67
|
+
The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort(__assignType((a, b) => String(a).localeCompare(String(b)), [
|
|
68
|
+
"a",
|
|
69
|
+
"b",
|
|
70
|
+
"",
|
|
71
|
+
"P\"2!\"2\"\"/#"
|
|
72
|
+
])).map(__assignType((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some(__assignType((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0, [
|
|
73
|
+
"prop",
|
|
74
|
+
"",
|
|
75
|
+
"P\"2!\"/\""
|
|
76
|
+
])) ? `(Alias: ${envTypesAliasProperties?.find(__assignType((prop) => prop.getNameAsString() === String(typeDef), [
|
|
77
|
+
"prop",
|
|
78
|
+
"",
|
|
79
|
+
"P\"2!\"/\""
|
|
80
|
+
]))?.getAlias().join(", ")})` : ""}`, [
|
|
81
|
+
"typeDef",
|
|
82
|
+
"",
|
|
83
|
+
"P\"2!\"/\""
|
|
84
|
+
])).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map(__assignType((prefix) => ` - ${prefix}`, [
|
|
85
|
+
"prefix",
|
|
86
|
+
"",
|
|
87
|
+
"P\"2!\"/\""
|
|
88
|
+
])).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
|
|
89
|
+
else if (pass.filename && isUsingBuiltin) context.warn(`The "${name}" environment variable is used in the source code file ${pass.filename}, but is not defined in the \`env\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
extractEnv.__type = [
|
|
93
|
+
"node",
|
|
94
|
+
() => __ΩBabelPluginPass,
|
|
95
|
+
"pass",
|
|
96
|
+
"isInjectable",
|
|
97
|
+
"isUsingBuiltin",
|
|
98
|
+
"extractEnv",
|
|
99
|
+
"P!2!n\"2#\"2$\"2%\"/&"
|
|
100
|
+
];
|
|
101
|
+
return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
|
|
102
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
103
|
+
const identifier = path.get("property")?.node;
|
|
104
|
+
if (!identifier.name) return;
|
|
105
|
+
extractEnv(identifier, pass, false, false);
|
|
106
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
107
|
+
addImport(path, {
|
|
108
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
109
|
+
name: "env",
|
|
110
|
+
imported: "env"
|
|
111
|
+
});
|
|
112
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
113
|
+
const identifier = path.get("property")?.node;
|
|
114
|
+
if (!identifier.name) return;
|
|
115
|
+
extractEnv(identifier, pass, false, false);
|
|
116
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
117
|
+
addImport(path, {
|
|
118
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
119
|
+
name: "env",
|
|
120
|
+
imported: "env"
|
|
121
|
+
});
|
|
122
|
+
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
123
|
+
const identifier = path.get("property")?.node;
|
|
124
|
+
if (!identifier.name) return;
|
|
125
|
+
extractEnv(identifier, pass, false, true);
|
|
126
|
+
}
|
|
127
|
+
}, [
|
|
128
|
+
() => NodePath,
|
|
129
|
+
"path",
|
|
130
|
+
() => __ΩBabelPluginPass,
|
|
131
|
+
"pass",
|
|
132
|
+
"MemberExpression",
|
|
133
|
+
"PP!7!2\"n#2$\"/%"
|
|
134
|
+
]) } };
|
|
135
|
+
}, [
|
|
136
|
+
"param0",
|
|
137
|
+
"",
|
|
138
|
+
"P\"2!\"/\""
|
|
139
|
+
])));
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
export { envBabelPlugin };
|
|
143
|
+
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { BabelPluginPass } from \"@powerlines/plugin-babel/types/config\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ log, context }) => {\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false,\n isUsingBuiltin = false\n ) {\n const envTypesAliasProperties = context.env.types.env\n ?.getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n if (node.name) {\n const prefix = context.config.env.prefix.find(\n pre =>\n node.name &&\n node.name.startsWith(pre) &&\n (context.env.types.env?.hasProperty(\n node.name.replace(`${pre}_`, \"\")\n ) ||\n envTypesAliasProperties.some(prop =>\n prop.getAlias().includes(node.name.replace(`${pre}_`, \"\"))\n ))\n );\n\n let name = node.name;\n if (prefix) {\n name = node.name.replace(`${prefix}_`, \"\");\n }\n\n log(\n LogLevelLabel.TRACE,\n `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n );\n\n if (\n context.env.types.env?.hasProperty(name) ||\n envTypesAliasProperties.some(prop => prop.getAlias().includes(name))\n ) {\n const envProperty = context.env.types.env.hasProperty(name)\n ? context.env.types.env.getProperty(name)\n : envTypesAliasProperties.find(prop =>\n prop.getAlias().includes(name)\n );\n if (!envProperty || envProperty.isIgnored()) {\n return;\n }\n\n if (!context.env.used.env.hasProperty(name)) {\n log(\n LogLevelLabel.DEBUG,\n `Adding \"${name}\" environment variables found in \"${\n pass.filename || \"unknown file\"\n }\" to used environment configuration reflection object.`\n );\n\n context.env.used.env.addProperty(envProperty.property);\n }\n\n if (context.config.env.inject && isInjectable) {\n let value = context.env.parsed?.[name];\n if (value === undefined) {\n const prefix = context.config.env.prefix.find(pre => {\n return context.env.parsed[`${pre.replace(/_$/g, \"\")}_${name}`];\n });\n if (prefix) {\n value =\n context.env.parsed[`${prefix.replace(/_$/g, \"\")}_${name}`];\n }\n }\n\n value ??= envProperty.getDefaultValue();\n\n if (envProperty.isValueRequired() && value === undefined) {\n throw new Error(\n `Environment variable \\`${name}\\` is not defined in the .env configuration files`\n );\n }\n\n return stringifyDefaultValue(envProperty, value);\n }\n } else if (context.config.env.validate) {\n throw new Error(\n `The \"${name}\" environment variable is not defined in the \\`env\\` type definition, but is used in the source code file ${\n pass.filename ? pass.filename : \"unknown\"\n }.\n\n The following environment configuration names are defined in the \\`env\\` type definition: \\n${context.env.types.env\n ?.getPropertyNames()\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map(\n typeDef =>\n ` - ${String(typeDef)} ${\n envTypesAliasProperties.some(\n prop =>\n prop.getNameAsString() === String(typeDef) &&\n prop.getAlias().length > 0\n )\n ? `(Alias: ${envTypesAliasProperties\n ?.find(\n prop => prop.getNameAsString() === String(typeDef)\n )\n ?.getAlias()\n .join(\", \")})`\n : \"\"\n }`\n )\n .join(\n \"\\n\"\n )} \\n\\nUsing the following env prefix: \\n${context.config.env.prefix\n .map(prefix => ` - ${prefix}`)\n .join(\n \"\\n\"\n )} \\n\\nPlease check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \\n\\n`\n );\n } else if (pass.filename && isUsingBuiltin) {\n context.warn(\n `The \"${\n name\n }\" environment variable is used in the source code file ${\n pass.filename\n }, but is not defined in the \\`env\\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`\n );\n }\n }\n\n return undefined;\n }\n\n return {\n visitor: {\n MemberExpression(\n path: NodePath<t.MemberExpression>,\n pass: BabelPluginPass\n ) {\n if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path\n .get(\"object\")\n ?.get(\"object\")\n ?.isIdentifier({ name: \"process\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // process.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path.get(\"object\")?.get(\"object\")?.isMetaProperty() &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // import.meta.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path.get(\"object\")?.isIdentifier({ name: \"env\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, true);\n }\n }\n }\n };\n }\n);\n"],"mappings":";;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EK,cAAA,YAAA,MAAA,OAAA,KAAA;;IAER;QAAA;EAAA;QAAA;EAAA;EAAA;EAAA;EAAA,CAAA,EACH,EACH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_helpers_docs_helper = require('../helpers/docs-helper.cjs');
|
|
4
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
5
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
6
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
|
+
let _alloy_js_markdown = require("@alloy-js/markdown");
|
|
9
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
10
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
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
|
+
//#region src/components/docs.tsx
|
|
15
|
+
/**
|
|
16
|
+
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
17
|
+
*/
|
|
18
|
+
function EnvDocsFile(props) {
|
|
19
|
+
const { levelOffset = 0, reflection, ...rest } = props;
|
|
20
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
21
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_file.MarkdownFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
|
|
22
|
+
return (0, _stryke_path_join.joinPaths)(require_helpers_docs_helper.getDocsOutputPath(context), "env.md");
|
|
23
|
+
} }, rest, { get children() {
|
|
24
|
+
return [
|
|
25
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
|
|
26
|
+
level: 1 + levelOffset,
|
|
27
|
+
children: "Environment Configuration"
|
|
28
|
+
}),
|
|
29
|
+
_alloy_js_core.code`Below is a list of environment variables used by the`,
|
|
30
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
31
|
+
get when() {
|
|
32
|
+
return !!context.packageJson.name;
|
|
33
|
+
},
|
|
34
|
+
get children() {
|
|
35
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Link, {
|
|
36
|
+
get href() {
|
|
37
|
+
return `https://www.npmjs.com/package/${context.packageJson.name}`;
|
|
38
|
+
},
|
|
39
|
+
get title() {
|
|
40
|
+
return context.packageJson.name;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
_alloy_js_core.code`package. These values can be updated in the \`.env\` file in the root of the project.`,
|
|
46
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
47
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
|
|
48
|
+
level: 2 + levelOffset,
|
|
49
|
+
children: "Environment Variables"
|
|
50
|
+
}),
|
|
51
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
52
|
+
_alloy_js_core.code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`,
|
|
53
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
54
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
|
|
55
|
+
return reflection?.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
56
|
+
return {
|
|
57
|
+
name: reflectionProperty.getNameAsString().trim(),
|
|
58
|
+
description: (reflectionProperty.getDescription() ?? "").trim(),
|
|
59
|
+
type: (0, _powerlines_deepkit_vendor_type.stringifyType)(reflectionProperty.getType()).trim().replaceAll(" | ", ", or "),
|
|
60
|
+
defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
|
|
61
|
+
required: reflectionProperty.isValueRequired() ? "" : "✔"
|
|
62
|
+
};
|
|
63
|
+
}) ?? [];
|
|
64
|
+
} })
|
|
65
|
+
];
|
|
66
|
+
} }));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.EnvDocsFile = EnvDocsFile;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
|
|
3
|
+
import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
|
|
4
|
+
|
|
5
|
+
//#region src/components/docs.d.ts
|
|
6
|
+
interface EnvDocsFileProps extends Partial<MarkdownFileProps> {
|
|
7
|
+
/**
|
|
8
|
+
* The heading level offset to apply to the generated documentation.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This is useful when nesting the documentation within other markdown files.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue 0
|
|
14
|
+
*/
|
|
15
|
+
levelOffset?: number;
|
|
16
|
+
reflection: ReflectionClass<any>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
20
|
+
*/
|
|
21
|
+
declare function EnvDocsFile(props: EnvDocsFileProps): _alloy_js_core0.Children;
|
|
22
|
+
declare type __ΩEnvDocsFileProps = any[];
|
|
23
|
+
//#endregion
|
|
24
|
+
export { EnvDocsFile, EnvDocsFileProps, __ΩEnvDocsFileProps };
|
|
25
|
+
//# sourceMappingURL=docs.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;;UAmCiB,gBAAA,SAAyB,OAAA,CAAQ,iBAAA;;;AAAlD;;;;;;EASE,WAAA;EAEA,UAAA,EAAY,eAAA;AAAA;;;;iBAME,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAgB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
|
|
2
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
3
|
+
import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
|
|
4
|
+
|
|
5
|
+
//#region src/components/docs.d.ts
|
|
6
|
+
interface EnvDocsFileProps extends Partial<MarkdownFileProps> {
|
|
7
|
+
/**
|
|
8
|
+
* The heading level offset to apply to the generated documentation.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This is useful when nesting the documentation within other markdown files.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue 0
|
|
14
|
+
*/
|
|
15
|
+
levelOffset?: number;
|
|
16
|
+
reflection: ReflectionClass<any>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
20
|
+
*/
|
|
21
|
+
declare function EnvDocsFile(props: EnvDocsFileProps): _alloy_js_core0.Children;
|
|
22
|
+
declare type __ΩEnvDocsFileProps = any[];
|
|
23
|
+
//#endregion
|
|
24
|
+
export { EnvDocsFile, EnvDocsFileProps, __ΩEnvDocsFileProps };
|
|
25
|
+
//# sourceMappingURL=docs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.mts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;;UAmCiB,gBAAA,SAAyB,OAAA,CAAQ,iBAAA;;;AAAlD;;;;;;EASE,WAAA;EAEA,UAAA,EAAY,eAAA;AAAA;;;;iBAME,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAgB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getDocsOutputPath } from "../helpers/docs-helper.mjs";
|
|
2
|
+
import { stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
3
|
+
import { joinPaths } from "@stryke/path/join";
|
|
4
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { Show, code } from "@alloy-js/core";
|
|
6
|
+
import { Heading, Link } from "@alloy-js/markdown";
|
|
7
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
8
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
9
|
+
import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
|
|
10
|
+
import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
|
|
11
|
+
|
|
12
|
+
//#region src/components/docs.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
15
|
+
*/
|
|
16
|
+
function EnvDocsFile(props) {
|
|
17
|
+
const { levelOffset = 0, reflection, ...rest } = props;
|
|
18
|
+
const context = usePowerlines();
|
|
19
|
+
return createComponent(MarkdownFile, mergeProps({ get path() {
|
|
20
|
+
return joinPaths(getDocsOutputPath(context), "env.md");
|
|
21
|
+
} }, rest, { get children() {
|
|
22
|
+
return [
|
|
23
|
+
createComponent(Heading, {
|
|
24
|
+
level: 1 + levelOffset,
|
|
25
|
+
children: "Environment Configuration"
|
|
26
|
+
}),
|
|
27
|
+
code`Below is a list of environment variables used by the`,
|
|
28
|
+
createComponent(Show, {
|
|
29
|
+
get when() {
|
|
30
|
+
return !!context.packageJson.name;
|
|
31
|
+
},
|
|
32
|
+
get children() {
|
|
33
|
+
return createComponent(Link, {
|
|
34
|
+
get href() {
|
|
35
|
+
return `https://www.npmjs.com/package/${context.packageJson.name}`;
|
|
36
|
+
},
|
|
37
|
+
get title() {
|
|
38
|
+
return context.packageJson.name;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
code`package. These values can be updated in the \`.env\` file in the root of the project.`,
|
|
44
|
+
createComponent(Spacing, {}),
|
|
45
|
+
createComponent(Heading, {
|
|
46
|
+
level: 2 + levelOffset,
|
|
47
|
+
children: "Environment Variables"
|
|
48
|
+
}),
|
|
49
|
+
createComponent(Spacing, {}),
|
|
50
|
+
code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`,
|
|
51
|
+
createComponent(Spacing, {}),
|
|
52
|
+
createComponent(MarkdownTable, { get data() {
|
|
53
|
+
return reflection?.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
54
|
+
return {
|
|
55
|
+
name: reflectionProperty.getNameAsString().trim(),
|
|
56
|
+
description: (reflectionProperty.getDescription() ?? "").trim(),
|
|
57
|
+
type: stringifyType(reflectionProperty.getType()).trim().replaceAll(" | ", ", or "),
|
|
58
|
+
defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
|
|
59
|
+
required: reflectionProperty.isValueRequired() ? "" : "✔"
|
|
60
|
+
};
|
|
61
|
+
}) ?? [];
|
|
62
|
+
} })
|
|
63
|
+
];
|
|
64
|
+
} }));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { EnvDocsFile };
|
|
69
|
+
//# sourceMappingURL=docs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show } from \"@alloy-js/core\";\nimport { Heading, Link } from \"@alloy-js/markdown\";\nimport {\n ReflectionClass,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n MarkdownFile,\n MarkdownFileProps\n} from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"../helpers/docs-helper\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\nexport interface EnvDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n reflection: ReflectionClass<any>;\n}\n\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, reflection, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment Configuration</Heading>\n {code`Below is a list of environment variables used by the`}\n <Show when={!!context.packageJson.name}>\n <Link\n href={`https://www.npmjs.com/package/${context.packageJson.name}`}\n title={context.packageJson.name!}\n />\n </Show>\n {code`package. These values can be updated in the \\`.env\\` file in the root of the project.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Environment Variables</Heading>\n <Spacing />\n {code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`}\n <Spacing />\n <MarkdownTable\n data={\n reflection\n ?.getProperties()\n .filter(\n property =>\n property.getNameAsString() !== \"__POWERLINES_INJECTED__\"\n )\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n )\n .map(reflectionProperty => {\n return {\n name: reflectionProperty.getNameAsString().trim(),\n description: (reflectionProperty.getDescription() ?? \"\").trim(),\n type: stringifyType(reflectionProperty.getType())\n .trim()\n .replaceAll(\" | \", \", or \"),\n defaultValue: reflectionProperty.hasDefault()\n ? String(reflectionProperty.getDefaultValue())?.includes('\"')\n ? reflectionProperty.getDefaultValue()\n : `\\`${reflectionProperty.getDefaultValue()}\\``\n : \"\",\n required: reflectionProperty.isValueRequired() ? \"\" : \"✔\"\n };\n }) ?? []\n }\n />\n </MarkdownFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;CA8CE,MAAA,EACF,cAAA,eAEE,GAAA,SACC;CACD,MAAA,UAAA,eAAA;AACF,QAAO,gBAAoB,cAAQ,WAAkB,EACnD,IAAM,OAAE;;cAIR,IAAM,WAAC;AACJ,SAAA;GAAA,gBAAA,SAAA;IACC,OAAM,IAAA;IACJ,UAAO;IACR,CAAA;GAAA,IAAO;GAAoD,gBAAO,M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