@powerlines/plugin-env 0.16.183 → 0.16.185
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 -1
- package/dist/babel/index.cjs +4 -1
- package/dist/babel/index.mjs +3 -1
- package/dist/babel/plugin.cjs +137 -4
- package/dist/babel/plugin.mjs +135 -4
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +111 -1
- package/dist/components/docs.mjs +108 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +730 -13
- package/dist/components/env-builtin.mjs +726 -11
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/components/index.cjs +9 -1
- package/dist/components/index.mjs +4 -1
- package/dist/helpers/automd-generator.cjs +32 -1
- package/dist/helpers/automd-generator.mjs +30 -1
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/create-reflection-resource.cjs +23 -1
- package/dist/helpers/create-reflection-resource.mjs +22 -1
- package/dist/helpers/create-reflection-resource.mjs.map +1 -1
- package/dist/helpers/index.cjs +34 -1
- package/dist/helpers/index.mjs +8 -1
- package/dist/helpers/load.cjs +141 -1
- package/dist/helpers/load.mjs +137 -1
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +308 -1
- package/dist/helpers/persistence.mjs +295 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.cjs +290 -1
- package/dist/helpers/reflect.mjs +280 -1
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/source-file-env.cjs +59 -1
- package/dist/helpers/source-file-env.mjs +56 -1
- package/dist/helpers/source-file-env.mjs.map +1 -1
- package/dist/helpers/template-helpers.cjs +70 -1
- package/dist/helpers/template-helpers.mjs +68 -1
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/index.cjs +306 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +292 -7
- package/dist/index.mjs.map +1 -1
- package/dist/types/env.cjs +541 -1
- package/dist/types/env.mjs +538 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +11 -1
- package/dist/types/index.mjs +4 -1
- package/dist/types/plugin.cjs +115 -1
- package/dist/types/plugin.mjs +109 -1
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
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;
|
package/dist/babel/index.cjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_babel_plugin = require('./plugin.cjs');
|
|
3
|
+
|
|
4
|
+
exports.envBabelPlugin = require_babel_plugin.envBabelPlugin;
|
package/dist/babel/index.mjs
CHANGED
package/dist/babel/plugin.cjs
CHANGED
|
@@ -1,5 +1,138 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
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_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
5
|
+
let _powerlines_plugin_babel_helpers_create_plugin = require("@powerlines/plugin-babel/helpers/create-plugin");
|
|
6
|
+
let _powerlines_plugin_babel_helpers_module_helpers = require("@powerlines/plugin-babel/helpers/module-helpers");
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
//#region src/babel/plugin.ts
|
|
9
|
+
function __assignType(fn, args) {
|
|
10
|
+
fn.__type = args;
|
|
11
|
+
return fn;
|
|
12
|
+
}
|
|
13
|
+
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 }) => {
|
|
14
|
+
function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
|
|
15
|
+
const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
16
|
+
"prop",
|
|
17
|
+
"",
|
|
18
|
+
"P\"2!\"/\""
|
|
19
|
+
]));
|
|
20
|
+
if (node.name) {
|
|
21
|
+
const name = node.name.replace(new RegExp(`^(${context.config.env.prefix.join("|")})_`), "");
|
|
22
|
+
logger.trace({
|
|
23
|
+
meta: { category: "env" },
|
|
24
|
+
message: `Environment variable ${name} found in ${pass.filename || "unknown file"}.`
|
|
25
|
+
});
|
|
26
|
+
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(name), [
|
|
27
|
+
"prop",
|
|
28
|
+
"",
|
|
29
|
+
"P\"2!\"/\""
|
|
30
|
+
]))) {
|
|
31
|
+
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find(__assignType((prop) => prop.getAlias().includes(name), [
|
|
32
|
+
"prop",
|
|
33
|
+
"",
|
|
34
|
+
"P\"2!\"/\""
|
|
35
|
+
]));
|
|
36
|
+
if (!envProperty || envProperty.isIgnored()) return;
|
|
37
|
+
if (!context.env.used.env.hasProperty(name)) {
|
|
38
|
+
logger.debug({
|
|
39
|
+
meta: { category: "env" },
|
|
40
|
+
message: `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`
|
|
41
|
+
});
|
|
42
|
+
context.env.used.env.addProperty(envProperty.property);
|
|
43
|
+
}
|
|
44
|
+
if (context.config.env.inject && isInjectable) {
|
|
45
|
+
let value = context.env.parsed?.[name];
|
|
46
|
+
if (value === void 0) {
|
|
47
|
+
const prefix = context.config.env.prefix.find(__assignType((pre) => {
|
|
48
|
+
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
49
|
+
}, [
|
|
50
|
+
"pre",
|
|
51
|
+
"",
|
|
52
|
+
"P\"2!\"/\""
|
|
53
|
+
]));
|
|
54
|
+
if (prefix) value = context.env.parsed[`${prefix.replace(/_$/g, "")}_${name}`];
|
|
55
|
+
}
|
|
56
|
+
value ??= envProperty.getDefaultValue();
|
|
57
|
+
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
58
|
+
return (0, _powerlines_deepkit_utilities.stringifyDefaultValue)(envProperty, value);
|
|
59
|
+
}
|
|
60
|
+
} 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"}.
|
|
61
|
+
|
|
62
|
+
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)), [
|
|
63
|
+
"a",
|
|
64
|
+
"b",
|
|
65
|
+
"",
|
|
66
|
+
"P\"2!\"2\"\"/#"
|
|
67
|
+
])).map(__assignType((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some(__assignType((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0, [
|
|
68
|
+
"prop",
|
|
69
|
+
"",
|
|
70
|
+
"P\"2!\"/\""
|
|
71
|
+
])) ? `(Alias: ${envTypesAliasProperties?.find(__assignType((prop) => prop.getNameAsString() === String(typeDef), [
|
|
72
|
+
"prop",
|
|
73
|
+
"",
|
|
74
|
+
"P\"2!\"/\""
|
|
75
|
+
]))?.getAlias().join(", ")})` : ""}`, [
|
|
76
|
+
"typeDef",
|
|
77
|
+
"",
|
|
78
|
+
"P\"2!\"/\""
|
|
79
|
+
])).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map(__assignType((prefix) => ` - ${prefix}`, [
|
|
80
|
+
"prefix",
|
|
81
|
+
"",
|
|
82
|
+
"P\"2!\"/\""
|
|
83
|
+
])).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`);
|
|
84
|
+
else if (pass.filename && isUsingBuiltin) logger.warn({
|
|
85
|
+
meta: { category: "env" },
|
|
86
|
+
message: `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.`
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
extractEnv.__type = [
|
|
91
|
+
"node",
|
|
92
|
+
"pass",
|
|
93
|
+
"isInjectable",
|
|
94
|
+
"isUsingBuiltin",
|
|
95
|
+
"extractEnv",
|
|
96
|
+
"P!2!!2\"\"2#\"2$\"/%"
|
|
97
|
+
];
|
|
98
|
+
return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
|
|
99
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
100
|
+
const identifier = path.get("property")?.node;
|
|
101
|
+
if (!identifier.name) return;
|
|
102
|
+
extractEnv(identifier, pass, false, false);
|
|
103
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
104
|
+
(0, _powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
105
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
106
|
+
name: "env",
|
|
107
|
+
imported: "env"
|
|
108
|
+
});
|
|
109
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
110
|
+
const identifier = path.get("property")?.node;
|
|
111
|
+
if (!identifier.name) return;
|
|
112
|
+
extractEnv(identifier, pass, false, false);
|
|
113
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
114
|
+
(0, _powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
115
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
116
|
+
name: "env",
|
|
117
|
+
imported: "env"
|
|
118
|
+
});
|
|
119
|
+
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
120
|
+
const identifier = path.get("property")?.node;
|
|
121
|
+
if (!identifier.name) return;
|
|
122
|
+
extractEnv(identifier, pass, false, true);
|
|
123
|
+
}
|
|
124
|
+
}, [
|
|
125
|
+
"NodePath",
|
|
126
|
+
"path",
|
|
127
|
+
"pass",
|
|
128
|
+
"MemberExpression",
|
|
129
|
+
"P\"w!2\"!2#\"/$"
|
|
130
|
+
]) } };
|
|
131
|
+
}, [
|
|
132
|
+
"param0",
|
|
133
|
+
"",
|
|
134
|
+
"P\"2!\"/\""
|
|
135
|
+
])));
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
exports.envBabelPlugin = envBabelPlugin;
|
package/dist/babel/plugin.mjs
CHANGED
|
@@ -1,6 +1,137 @@
|
|
|
1
|
-
import{__ΩEnvPluginContext
|
|
1
|
+
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
|
|
3
|
+
import { createBabelPlugin } from "@powerlines/plugin-babel/helpers/create-plugin";
|
|
4
|
+
import { addImport } from "@powerlines/plugin-babel/helpers/module-helpers";
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
//#region src/babel/plugin.ts
|
|
7
|
+
function __assignType(fn, args) {
|
|
8
|
+
fn.__type = args;
|
|
9
|
+
return fn;
|
|
10
|
+
}
|
|
11
|
+
const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!"]], createBabelPlugin("env", __assignType(({ logger, context }) => {
|
|
12
|
+
function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
|
|
13
|
+
const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
14
|
+
"prop",
|
|
15
|
+
"",
|
|
16
|
+
"P\"2!\"/\""
|
|
17
|
+
]));
|
|
18
|
+
if (node.name) {
|
|
19
|
+
const name = node.name.replace(new RegExp(`^(${context.config.env.prefix.join("|")})_`), "");
|
|
20
|
+
logger.trace({
|
|
21
|
+
meta: { category: "env" },
|
|
22
|
+
message: `Environment variable ${name} found in ${pass.filename || "unknown file"}.`
|
|
23
|
+
});
|
|
24
|
+
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(name), [
|
|
25
|
+
"prop",
|
|
26
|
+
"",
|
|
27
|
+
"P\"2!\"/\""
|
|
28
|
+
]))) {
|
|
29
|
+
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find(__assignType((prop) => prop.getAlias().includes(name), [
|
|
30
|
+
"prop",
|
|
31
|
+
"",
|
|
32
|
+
"P\"2!\"/\""
|
|
33
|
+
]));
|
|
34
|
+
if (!envProperty || envProperty.isIgnored()) return;
|
|
35
|
+
if (!context.env.used.env.hasProperty(name)) {
|
|
36
|
+
logger.debug({
|
|
37
|
+
meta: { category: "env" },
|
|
38
|
+
message: `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`
|
|
39
|
+
});
|
|
40
|
+
context.env.used.env.addProperty(envProperty.property);
|
|
41
|
+
}
|
|
42
|
+
if (context.config.env.inject && isInjectable) {
|
|
43
|
+
let value = context.env.parsed?.[name];
|
|
44
|
+
if (value === void 0) {
|
|
45
|
+
const prefix = context.config.env.prefix.find(__assignType((pre) => {
|
|
46
|
+
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
47
|
+
}, [
|
|
48
|
+
"pre",
|
|
49
|
+
"",
|
|
50
|
+
"P\"2!\"/\""
|
|
51
|
+
]));
|
|
52
|
+
if (prefix) value = context.env.parsed[`${prefix.replace(/_$/g, "")}_${name}`];
|
|
53
|
+
}
|
|
54
|
+
value ??= envProperty.getDefaultValue();
|
|
55
|
+
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
56
|
+
return stringifyDefaultValue(envProperty, value);
|
|
57
|
+
}
|
|
58
|
+
} 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"}.
|
|
59
|
+
|
|
60
|
+
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)), [
|
|
61
|
+
"a",
|
|
62
|
+
"b",
|
|
63
|
+
"",
|
|
64
|
+
"P\"2!\"2\"\"/#"
|
|
65
|
+
])).map(__assignType((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some(__assignType((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0, [
|
|
66
|
+
"prop",
|
|
67
|
+
"",
|
|
68
|
+
"P\"2!\"/\""
|
|
69
|
+
])) ? `(Alias: ${envTypesAliasProperties?.find(__assignType((prop) => prop.getNameAsString() === String(typeDef), [
|
|
70
|
+
"prop",
|
|
71
|
+
"",
|
|
72
|
+
"P\"2!\"/\""
|
|
73
|
+
]))?.getAlias().join(", ")})` : ""}`, [
|
|
74
|
+
"typeDef",
|
|
75
|
+
"",
|
|
76
|
+
"P\"2!\"/\""
|
|
77
|
+
])).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map(__assignType((prefix) => ` - ${prefix}`, [
|
|
78
|
+
"prefix",
|
|
79
|
+
"",
|
|
80
|
+
"P\"2!\"/\""
|
|
81
|
+
])).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`);
|
|
82
|
+
else if (pass.filename && isUsingBuiltin) logger.warn({
|
|
83
|
+
meta: { category: "env" },
|
|
84
|
+
message: `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.`
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
extractEnv.__type = [
|
|
89
|
+
"node",
|
|
90
|
+
"pass",
|
|
91
|
+
"isInjectable",
|
|
92
|
+
"isUsingBuiltin",
|
|
93
|
+
"extractEnv",
|
|
94
|
+
"P!2!!2\"\"2#\"2$\"/%"
|
|
95
|
+
];
|
|
96
|
+
return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
|
|
97
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
98
|
+
const identifier = path.get("property")?.node;
|
|
99
|
+
if (!identifier.name) return;
|
|
100
|
+
extractEnv(identifier, pass, false, false);
|
|
101
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
102
|
+
addImport(path, {
|
|
103
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
104
|
+
name: "env",
|
|
105
|
+
imported: "env"
|
|
106
|
+
});
|
|
107
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
108
|
+
const identifier = path.get("property")?.node;
|
|
109
|
+
if (!identifier.name) return;
|
|
110
|
+
extractEnv(identifier, pass, false, false);
|
|
111
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
112
|
+
addImport(path, {
|
|
113
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
114
|
+
name: "env",
|
|
115
|
+
imported: "env"
|
|
116
|
+
});
|
|
117
|
+
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
118
|
+
const identifier = path.get("property")?.node;
|
|
119
|
+
if (!identifier.name) return;
|
|
120
|
+
extractEnv(identifier, pass, false, true);
|
|
121
|
+
}
|
|
122
|
+
}, [
|
|
123
|
+
"NodePath",
|
|
124
|
+
"path",
|
|
125
|
+
"pass",
|
|
126
|
+
"MemberExpression",
|
|
127
|
+
"P\"w!2\"!2#\"/$"
|
|
128
|
+
]) } };
|
|
129
|
+
}, [
|
|
130
|
+
"param0",
|
|
131
|
+
"",
|
|
132
|
+
"P\"2!\"/\""
|
|
133
|
+
])));
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
export { envBabelPlugin };
|
|
6
137
|
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -1 +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 { 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 ({ logger, 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 name = node.name.replace(\n new RegExp(`^(${context.config.env.prefix.join(\"|\")})_`),\n \"\"\n );\n\n logger.trace({\n meta: {\n category: \"env\"\n },\n message: `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 logger.debug({\n meta: {\n category: \"env\"\n },\n message: `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 logger.warn({\n meta: {\n category: \"env\"\n },\n message: `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 (!ident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,CAAA,CAAA"}
|
|
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 { 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 ({ logger, 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 name = node.name.replace(\n new RegExp(`^(${context.config.env.prefix.join(\"|\")})_`),\n \"\"\n );\n\n logger.trace({\n meta: {\n category: \"env\"\n },\n message: `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 logger.debug({\n meta: {\n category: \"env\"\n },\n message: `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 logger.warn({\n meta: {\n category: \"env\"\n },\n message: `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":";;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;AAE1B,QAAK;;4HAYJ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MAAA;AACP,MAAI,KAAE,IAAO,SAAS,EAAE,IAAE,WAAO,EAAA,aAAqB,EACpD,MAAM,OACP,CAAC,IAAI,KAAK,IAAC,SAAK,EAAA,IAAY,SAAA,EAAA,aAAyB,EACpD,MAAI;GAGJ,MAAA,aAAA,KAAA,IAAA,WAAA,EAAA;wBAEE;AAEF,cAAW,YAAK,MAAW,OAAA,MAAA;AAC3B,QAAI,wBAAuB,OAAO,WAAW,OAAS;AACtD,aAAM,MAAO;IACX,QAAI,GAAA,QAAA,OAAA,aAAA,aAAA;IACJ,MAAM;IACN,UAAU;IACX,CAAC;aACE,KAAA,IAAA,SAAA,EAAA,IAAA,WAAA,EAAA,aAAA,EACJ,MAAE;;AAIF,OAAI,CAAC,WAAC,KACJ;AAEF,cAAK,YAAA,MAAA,OAAA,MAAA;AACL,QAAE,wBAAA,OAAA,WAAA,OAAA;;IAEA,QAAO,GAAA,QAAA,OAAA,aAAsB,aAAmB;IAClD,MAAA;IACA,UAAS;IACT,CAAA;aACS,KAAK,IAAG,SAAA,EAAY,aAAY,EACzC,MAAI,OACL,CAAC,IAAG,KAAA,IAAA,WAAA,EAAA,cAAA,EAAA;GAEH,MAAI,aAAU,KAAA,IAAY,WAAa,EAAC;AACxC,OAAI,CAAA,WAAA,KACF;AAEF,cAAW,YAAE,MAAA,OAAA,KAAA;;IAEd;EAAC;EAAQ;EAAA;EAAA;EAA4B;EAAA,CAAA,EACzC,EACF;GACA;CAAC;CAAU;CAAI;CAAS,CAAA,CAAA"}
|
package/dist/components/docs.cjs
CHANGED
|
@@ -1 +1,111 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
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_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
5
|
+
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
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_heading = require("@powerlines/plugin-alloy/markdown/components/heading");
|
|
12
|
+
let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
|
|
13
|
+
let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
|
|
14
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
15
|
+
|
|
16
|
+
//#region src/components/docs.tsx
|
|
17
|
+
const __ΩPartial = [
|
|
18
|
+
"T",
|
|
19
|
+
"Partial",
|
|
20
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
21
|
+
];
|
|
22
|
+
function __assignType(fn, args) {
|
|
23
|
+
fn.__type = args;
|
|
24
|
+
return fn;
|
|
25
|
+
}
|
|
26
|
+
const __ΩEnvDocsFileProps = [
|
|
27
|
+
() => __ΩPartial,
|
|
28
|
+
"levelOffset",
|
|
29
|
+
0,
|
|
30
|
+
"The heading level offset to apply to the generated documentation.",
|
|
31
|
+
"reflection",
|
|
32
|
+
"EnvDocsFileProps",
|
|
33
|
+
"P!o!\"'4\"8>#?$!4%Mw&y"
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
37
|
+
*/
|
|
38
|
+
function EnvDocsFile(props) {
|
|
39
|
+
const { levelOffset = 0, reflection, ...rest } = props;
|
|
40
|
+
const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
|
|
41
|
+
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() {
|
|
42
|
+
return (0, _stryke_path_join.joinPaths)((0, powerlines_plugin_utils.getDocsOutputPath)(context.config.root), "env.md");
|
|
43
|
+
} }, rest, { get children() {
|
|
44
|
+
return [
|
|
45
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_heading.Heading, {
|
|
46
|
+
level: 1 + levelOffset,
|
|
47
|
+
children: "Environment Configuration"
|
|
48
|
+
}),
|
|
49
|
+
_alloy_js_core.code`Below is a list of environment variables used by the`,
|
|
50
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
51
|
+
get when() {
|
|
52
|
+
return !!context.packageJson.name;
|
|
53
|
+
},
|
|
54
|
+
get children() {
|
|
55
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Link, {
|
|
56
|
+
get href() {
|
|
57
|
+
return `https://www.npmjs.com/package/${context.packageJson.name}`;
|
|
58
|
+
},
|
|
59
|
+
get title() {
|
|
60
|
+
return context.packageJson.name;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
_alloy_js_core.code`package. These values can be updated in the \`.env\` file in the root of the project.`,
|
|
66
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
67
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_heading.Heading, {
|
|
68
|
+
level: 2 + levelOffset,
|
|
69
|
+
children: "Environment Variables"
|
|
70
|
+
}),
|
|
71
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
72
|
+
_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.`,
|
|
73
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
74
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
|
|
75
|
+
return reflection?.getProperties().filter(__assignType((property) => !property.isHidden() && !property.isIgnored() && !property.isReadonly() && !property.isInternal(), [
|
|
76
|
+
"property",
|
|
77
|
+
"",
|
|
78
|
+
"P\"2!\"/\""
|
|
79
|
+
])).sort(__assignType((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()), [
|
|
80
|
+
"a",
|
|
81
|
+
"b",
|
|
82
|
+
"",
|
|
83
|
+
"P\"2!\"2\"\"/#"
|
|
84
|
+
])).map(__assignType((reflectionProperty) => {
|
|
85
|
+
return {
|
|
86
|
+
name: reflectionProperty.getNameAsString().trim(),
|
|
87
|
+
description: (reflectionProperty.getDescription() ?? "").trim(),
|
|
88
|
+
type: (0, _powerlines_deepkit_vendor_type.stringifyType)(reflectionProperty.getType()).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
|
|
89
|
+
defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
|
|
90
|
+
required: reflectionProperty.isValueRequired() ? "" : "✔"
|
|
91
|
+
};
|
|
92
|
+
}, [
|
|
93
|
+
"reflectionProperty",
|
|
94
|
+
"",
|
|
95
|
+
"P\"2!\"/\""
|
|
96
|
+
])) ?? [];
|
|
97
|
+
} })
|
|
98
|
+
];
|
|
99
|
+
} }));
|
|
100
|
+
}
|
|
101
|
+
EnvDocsFile.__type = [
|
|
102
|
+
() => __ΩEnvDocsFileProps,
|
|
103
|
+
"props",
|
|
104
|
+
"EnvDocsFile",
|
|
105
|
+
"Generates the environment configuration markdown documentation for the Powerlines project.",
|
|
106
|
+
"Pn!2\"\"/#?$"
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
exports.EnvDocsFile = EnvDocsFile;
|
|
111
|
+
exports.__ΩEnvDocsFileProps = __ΩEnvDocsFileProps;
|
package/dist/components/docs.mjs
CHANGED
|
@@ -1,2 +1,109 @@
|
|
|
1
|
-
import{__ΩEnvPluginContext
|
|
1
|
+
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import { stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
3
|
+
import { getDocsOutputPath } from "powerlines/plugin-utils";
|
|
4
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { Show, code } from "@alloy-js/core";
|
|
6
|
+
import { 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 { 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
|
+
import { joinPaths } from "@stryke/path/join";
|
|
13
|
+
|
|
14
|
+
//#region src/components/docs.tsx
|
|
15
|
+
const __ΩPartial = [
|
|
16
|
+
"T",
|
|
17
|
+
"Partial",
|
|
18
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
19
|
+
];
|
|
20
|
+
function __assignType(fn, args) {
|
|
21
|
+
fn.__type = args;
|
|
22
|
+
return fn;
|
|
23
|
+
}
|
|
24
|
+
const __ΩEnvDocsFileProps = [
|
|
25
|
+
() => __ΩPartial,
|
|
26
|
+
"levelOffset",
|
|
27
|
+
0,
|
|
28
|
+
"The heading level offset to apply to the generated documentation.",
|
|
29
|
+
"reflection",
|
|
30
|
+
"EnvDocsFileProps",
|
|
31
|
+
"P!o!\"'4\"8>#?$!4%Mw&y"
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
35
|
+
*/
|
|
36
|
+
function EnvDocsFile(props) {
|
|
37
|
+
const { levelOffset = 0, reflection, ...rest } = props;
|
|
38
|
+
const context = (usePowerlines.Ω = [[() => __ΩEnvPluginContext, "n!"]], usePowerlines());
|
|
39
|
+
return createComponent(MarkdownFile, mergeProps({ get path() {
|
|
40
|
+
return joinPaths(getDocsOutputPath(context.config.root), "env.md");
|
|
41
|
+
} }, rest, { get children() {
|
|
42
|
+
return [
|
|
43
|
+
createComponent(Heading, {
|
|
44
|
+
level: 1 + levelOffset,
|
|
45
|
+
children: "Environment Configuration"
|
|
46
|
+
}),
|
|
47
|
+
code`Below is a list of environment variables used by the`,
|
|
48
|
+
createComponent(Show, {
|
|
49
|
+
get when() {
|
|
50
|
+
return !!context.packageJson.name;
|
|
51
|
+
},
|
|
52
|
+
get children() {
|
|
53
|
+
return createComponent(Link, {
|
|
54
|
+
get href() {
|
|
55
|
+
return `https://www.npmjs.com/package/${context.packageJson.name}`;
|
|
56
|
+
},
|
|
57
|
+
get title() {
|
|
58
|
+
return context.packageJson.name;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
code`package. These values can be updated in the \`.env\` file in the root of the project.`,
|
|
64
|
+
createComponent(Spacing, {}),
|
|
65
|
+
createComponent(Heading, {
|
|
66
|
+
level: 2 + levelOffset,
|
|
67
|
+
children: "Environment Variables"
|
|
68
|
+
}),
|
|
69
|
+
createComponent(Spacing, {}),
|
|
70
|
+
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.`,
|
|
71
|
+
createComponent(Spacing, {}),
|
|
72
|
+
createComponent(MarkdownTable, { get data() {
|
|
73
|
+
return reflection?.getProperties().filter(__assignType((property) => !property.isHidden() && !property.isIgnored() && !property.isReadonly() && !property.isInternal(), [
|
|
74
|
+
"property",
|
|
75
|
+
"",
|
|
76
|
+
"P\"2!\"/\""
|
|
77
|
+
])).sort(__assignType((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()), [
|
|
78
|
+
"a",
|
|
79
|
+
"b",
|
|
80
|
+
"",
|
|
81
|
+
"P\"2!\"2\"\"/#"
|
|
82
|
+
])).map(__assignType((reflectionProperty) => {
|
|
83
|
+
return {
|
|
84
|
+
name: reflectionProperty.getNameAsString().trim(),
|
|
85
|
+
description: (reflectionProperty.getDescription() ?? "").trim(),
|
|
86
|
+
type: stringifyType(reflectionProperty.getType()).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
|
|
87
|
+
defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
|
|
88
|
+
required: reflectionProperty.isValueRequired() ? "" : "✔"
|
|
89
|
+
};
|
|
90
|
+
}, [
|
|
91
|
+
"reflectionProperty",
|
|
92
|
+
"",
|
|
93
|
+
"P\"2!\"/\""
|
|
94
|
+
])) ?? [];
|
|
95
|
+
} })
|
|
96
|
+
];
|
|
97
|
+
} }));
|
|
98
|
+
}
|
|
99
|
+
EnvDocsFile.__type = [
|
|
100
|
+
() => __ΩEnvDocsFileProps,
|
|
101
|
+
"props",
|
|
102
|
+
"EnvDocsFile",
|
|
103
|
+
"Generates the environment configuration markdown documentation for the Powerlines project.",
|
|
104
|
+
"Pn!2\"\"/#?$"
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
export { EnvDocsFile, __ΩEnvDocsFileProps };
|
|
2
109
|
//# sourceMappingURL=docs.mjs.map
|