@powerlines/plugin-nodejs 0.1.0 → 0.1.2
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/components/env.cjs +188 -2
- package/dist/components/env.d.cts +9 -2
- package/dist/components/env.d.mts +9 -2
- package/dist/components/env.mjs +185 -1
- package/dist/components/index.cjs +2 -3
- package/dist/components/index.d.cts +1 -3
- package/dist/components/index.d.mts +1 -3
- package/dist/components/index.mjs +1 -2
- package/dist/deepkit/schemas/reflection.cjs +3940 -0
- package/dist/{plugin-D7kBf19k.d.cts → deepkit/schemas/reflection.d.cts} +1 -1078
- package/dist/{plugin-JL1BtFku.d.mts → deepkit/schemas/reflection.d.mts} +59 -1136
- package/dist/deepkit/schemas/reflection.mjs +3938 -0
- package/dist/deepkit/schemas/reflection2.cjs +4112 -0
- package/dist/deepkit/schemas/reflection2.mjs +4110 -0
- package/dist/deepkit/src/capnp.cjs +913 -0
- package/dist/deepkit/src/capnp.mjs +911 -0
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
- package/dist/deepkit/src/reflect-type.cjs +22 -0
- package/dist/deepkit/src/reflect-type.mjs +20 -0
- package/dist/deepkit/src/resolve-reflections.cjs +16 -0
- package/dist/deepkit/src/resolve-reflections.mjs +15 -0
- package/dist/deepkit/src/transformer.cjs +52 -0
- package/dist/deepkit/src/transformer.mjs +49 -0
- package/dist/deepkit/src/transpile.cjs +29 -0
- package/dist/deepkit/src/transpile.mjs +27 -0
- package/dist/deepkit/src/types.d.cts +10 -0
- package/dist/deepkit/src/types.d.mts +10 -0
- package/dist/deepkit/src/utilities.cjs +66 -0
- package/dist/deepkit/src/utilities.mjs +65 -0
- package/dist/index.cjs +14 -813
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +11 -803
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -0
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
- package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
- package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
- package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
- package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
- package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
- package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
- package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
- package/dist/plugin-alloy/src/index.cjs +99 -0
- package/dist/plugin-alloy/src/index.mjs +97 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
- package/dist/plugin-alloy/src/types/components.d.cts +23 -0
- package/dist/plugin-alloy/src/types/components.d.mts +24 -0
- package/dist/plugin-alloy/src/types/index.d.cts +2 -0
- package/dist/plugin-alloy/src/types/index.d.mts +2 -0
- package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
- package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +194 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +191 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +4 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +4 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
- package/dist/plugin-automd/src/index.cjs +101 -0
- package/dist/plugin-automd/src/index.mjs +98 -0
- package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
- package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
- package/dist/plugin-automd/src/types/toc.d.cts +33 -0
- package/dist/plugin-automd/src/types/toc.d.mts +33 -0
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
- package/dist/plugin-babel/src/helpers/index.cjs +5 -0
- package/dist/plugin-babel/src/helpers/index.mjs +7 -0
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
- package/dist/plugin-babel/src/helpers/options.cjs +50 -0
- package/dist/plugin-babel/src/helpers/options.mjs +47 -0
- package/dist/plugin-babel/src/index.cjs +91 -0
- package/dist/plugin-babel/src/index.mjs +89 -0
- package/dist/plugin-babel/src/types/index.d.mts +1 -0
- package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
- package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
- package/dist/plugin-env/src/babel/index.cjs +1 -0
- package/dist/plugin-env/src/babel/index.mjs +3 -0
- package/dist/plugin-env/src/babel/plugin.cjs +121 -0
- package/dist/plugin-env/src/babel/plugin.mjs +119 -0
- package/dist/plugin-env/src/components/docs.cjs +9 -0
- package/dist/plugin-env/src/components/docs.mjs +11 -0
- package/dist/plugin-env/src/components/env.cjs +575 -0
- package/dist/plugin-env/src/components/env.d.cts +11 -0
- package/dist/plugin-env/src/components/env.d.mts +11 -0
- package/dist/plugin-env/src/components/env.mjs +572 -0
- package/dist/plugin-env/src/components/index.cjs +2 -0
- package/dist/plugin-env/src/components/index.mjs +4 -0
- package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
- package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
- package/dist/plugin-env/src/helpers/index.cjs +6 -0
- package/dist/plugin-env/src/helpers/index.mjs +8 -0
- package/dist/plugin-env/src/helpers/load.cjs +83 -0
- package/dist/plugin-env/src/helpers/load.mjs +80 -0
- package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
- package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
- package/dist/plugin-env/src/helpers/reflect.cjs +111 -0
- package/dist/plugin-env/src/helpers/reflect.mjs +103 -0
- package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
- package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
- package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
- package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
- package/dist/plugin-env/src/index.cjs +175 -0
- package/dist/plugin-env/src/index.mjs +173 -0
- package/dist/plugin-env/src/types/plugin.d.cts +152 -0
- package/dist/plugin-env/src/types/plugin.d.mts +153 -0
- package/dist/plugin-env/src/types/runtime.d.cts +792 -0
- package/dist/plugin-env/src/types/runtime.d.mts +792 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
- package/dist/powerlines/src/lib/entry.cjs +12 -0
- package/dist/powerlines/src/lib/entry.mjs +14 -0
- package/dist/powerlines/src/lib/logger.cjs +41 -0
- package/dist/powerlines/src/lib/logger.mjs +39 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
- package/dist/powerlines/src/types/babel.d.cts +22 -0
- package/dist/powerlines/src/types/babel.d.mts +22 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +145 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +387 -0
- package/dist/powerlines/src/types/config.d.mts +388 -0
- package/dist/powerlines/src/types/context.d.cts +414 -0
- package/dist/powerlines/src/types/context.d.mts +416 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/plugin.d.cts +231 -0
- package/dist/powerlines/src/types/plugin.d.mts +231 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -3
- package/dist/types/index.d.mts +1 -3
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +22 -2
- package/dist/types/plugin.d.mts +22 -2
- package/dist/types/plugin.mjs +0 -2
- package/package.json +6 -6
- package/dist/components-BWLXb7a2.cjs +0 -0
- package/dist/components-CXZYcH4q.d.mts +0 -1816
- package/dist/components-kh0CpIG2.mjs +0 -1
- package/dist/env-CAhIy_H3.cjs +0 -11713
- package/dist/env-CUyFiniR.d.cts +0 -107
- package/dist/env-IF4XhMjG.mjs +0 -11570
- package/dist/env-sRb-Y8mJ.d.mts +0 -89
- package/dist/index-CUbWeWHc.d.mts +0 -1
- package/dist/index-D6CnpA_r.d.cts +0 -1
- package/dist/index-DL0uimUT.d.mts +0 -1
- package/dist/index-DWPDThxu.d.cts +0 -1
- package/dist/plugin-ifZVa20V.mjs +0 -1
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/resolved-zsx09G03.d.cts +0 -1795
- package/dist/types-U3zd8PTP.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getPluginName } from "./filters.mjs";
|
|
2
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-babel/src/helpers/options.ts
|
|
7
|
+
function resolvePluginFunction(context, plugin) {
|
|
8
|
+
try {
|
|
9
|
+
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? isFunction(plugin[0]) ? plugin[0](context) : plugin[0] : isFunction(plugin) ? plugin(context) : plugin;
|
|
10
|
+
} catch {
|
|
11
|
+
return plugin[0];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
16
|
+
*
|
|
17
|
+
* @param context - The context for the transformation.
|
|
18
|
+
* @param code - The code to be transformed.
|
|
19
|
+
* @param id - The ID of the source file.
|
|
20
|
+
* @param plugin - The Babel plugin to resolve.
|
|
21
|
+
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
22
|
+
*/
|
|
23
|
+
function resolveBabelPlugin(context, code, id, plugin) {
|
|
24
|
+
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
25
|
+
if (plugin.length > 2 && plugin[2] && isFunction(plugin[2]) && !plugin[2](code, id)) {
|
|
26
|
+
context.log(LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.bold.cyanBright(getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return plugin.length > 2 ? [
|
|
30
|
+
resolvePluginFunction(context, plugin),
|
|
31
|
+
plugin[1],
|
|
32
|
+
plugin[2]
|
|
33
|
+
] : [
|
|
34
|
+
resolvePluginFunction(context, plugin),
|
|
35
|
+
plugin[1],
|
|
36
|
+
null
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
resolvePluginFunction(context, plugin),
|
|
41
|
+
{},
|
|
42
|
+
null
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_filters = require('./helpers/filters.cjs');
|
|
3
|
+
const require_options = require('./helpers/options.cjs');
|
|
4
|
+
const require_create_plugin = require('./helpers/create-plugin.cjs');
|
|
5
|
+
const require_module_helpers = require('./helpers/module-helpers.cjs');
|
|
6
|
+
require('./helpers/index.cjs');
|
|
7
|
+
let __babel_core = require("@babel/core");
|
|
8
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
9
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
10
|
+
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
11
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
12
|
+
let defu = require("defu");
|
|
13
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
14
|
+
|
|
15
|
+
//#region ../plugin-babel/src/index.ts
|
|
16
|
+
/**
|
|
17
|
+
* Babel plugin for Powerlines.
|
|
18
|
+
*
|
|
19
|
+
* @param options - The Babel plugin user configuration options.
|
|
20
|
+
* @returns A Powerlines plugin that integrates Babel transformations.
|
|
21
|
+
*/
|
|
22
|
+
const plugin = (options = {}) => {
|
|
23
|
+
return {
|
|
24
|
+
name: "babel",
|
|
25
|
+
config() {
|
|
26
|
+
if (!(0, __stryke_type_checks_is_set_object.isSetObject)(options)) return;
|
|
27
|
+
return { transform: { babel: options } };
|
|
28
|
+
},
|
|
29
|
+
configResolved: {
|
|
30
|
+
order: "pre",
|
|
31
|
+
handler() {
|
|
32
|
+
this.devDependencies["@babel/core"] = "^7.28.4";
|
|
33
|
+
this.config.transform.babel = (0, defu.default)(this.config.transform.babel ?? {}, {
|
|
34
|
+
plugins: [],
|
|
35
|
+
presets: []
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async transform(code, id) {
|
|
40
|
+
if ((0, __stryke_path_is_parent_path.isParentPath)(id, this.powerlinesPath) || code.includes("/* @storm-ignore */") || code.includes("/* @storm-disable */")) {
|
|
41
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
|
|
42
|
+
return {
|
|
43
|
+
code,
|
|
44
|
+
id
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
|
|
48
|
+
const plugins = this.config.transform.babel.plugins.map((plugin$1) => require_options.resolveBabelPlugin(this, code, id, plugin$1)).filter((plugin$1, _, arr) => plugin$1 && !require_filters.isDuplicatePlugin(arr, plugin$1));
|
|
49
|
+
const presets = this.config.transform.babel.presets.map((preset) => require_options.resolveBabelPlugin(this, code, id, preset)).filter((preset, _, arr) => preset && !require_filters.isDuplicatePlugin(arr, preset));
|
|
50
|
+
if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
|
|
51
|
+
code,
|
|
52
|
+
id
|
|
53
|
+
};
|
|
54
|
+
if ([
|
|
55
|
+
"ts",
|
|
56
|
+
"cts",
|
|
57
|
+
"mts",
|
|
58
|
+
"tsx"
|
|
59
|
+
].includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(id)) && !require_filters.isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !require_filters.isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: (0, __stryke_path_file_path_fns.findFileExtension)(id) === ".tsx" }]);
|
|
60
|
+
const result = await (0, __babel_core.transformAsync)(code, {
|
|
61
|
+
highlightCode: true,
|
|
62
|
+
code: true,
|
|
63
|
+
ast: false,
|
|
64
|
+
cloneInputAst: false,
|
|
65
|
+
comments: true,
|
|
66
|
+
sourceType: "module",
|
|
67
|
+
configFile: false,
|
|
68
|
+
babelrc: false,
|
|
69
|
+
envName: this.config.mode,
|
|
70
|
+
caller: { name: this.config.framework },
|
|
71
|
+
...this.config.transform.babel ?? {},
|
|
72
|
+
filename: id,
|
|
73
|
+
plugins: plugins.map((plugin$1) => {
|
|
74
|
+
return Array.isArray(plugin$1) && plugin$1.length >= 2 ? [plugin$1[0], (0, defu.default)(plugin$1.length > 1 && plugin$1[1] ? plugin$1[1] : {}, { options })] : plugin$1;
|
|
75
|
+
}).filter(Boolean),
|
|
76
|
+
presets: presets.map((preset) => {
|
|
77
|
+
return Array.isArray(preset) && preset.length >= 2 ? [preset[0], (0, defu.default)(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
|
|
78
|
+
}).filter(Boolean)
|
|
79
|
+
});
|
|
80
|
+
if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
|
|
81
|
+
return {
|
|
82
|
+
code: result.code,
|
|
83
|
+
id
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
var src_default = plugin;
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
exports.default = src_default;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { getPluginName, isDuplicatePlugin } from "./helpers/filters.mjs";
|
|
2
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.mjs";
|
|
3
|
+
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
4
|
+
import { addImport, addImportsToProgram } from "./helpers/module-helpers.mjs";
|
|
5
|
+
import "./helpers/index.mjs";
|
|
6
|
+
import { transformAsync } from "@babel/core";
|
|
7
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
8
|
+
import { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
|
|
9
|
+
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
10
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
11
|
+
import defu from "defu";
|
|
12
|
+
|
|
13
|
+
//#region ../plugin-babel/src/index.ts
|
|
14
|
+
/**
|
|
15
|
+
* Babel plugin for Powerlines.
|
|
16
|
+
*
|
|
17
|
+
* @param options - The Babel plugin user configuration options.
|
|
18
|
+
* @returns A Powerlines plugin that integrates Babel transformations.
|
|
19
|
+
*/
|
|
20
|
+
const plugin = (options = {}) => {
|
|
21
|
+
return {
|
|
22
|
+
name: "babel",
|
|
23
|
+
config() {
|
|
24
|
+
if (!isSetObject(options)) return;
|
|
25
|
+
return { transform: { babel: options } };
|
|
26
|
+
},
|
|
27
|
+
configResolved: {
|
|
28
|
+
order: "pre",
|
|
29
|
+
handler() {
|
|
30
|
+
this.devDependencies["@babel/core"] = "^7.28.4";
|
|
31
|
+
this.config.transform.babel = defu(this.config.transform.babel ?? {}, {
|
|
32
|
+
plugins: [],
|
|
33
|
+
presets: []
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
async transform(code, id) {
|
|
38
|
+
if (isParentPath(id, this.powerlinesPath) || code.includes("/* @storm-ignore */") || code.includes("/* @storm-disable */")) {
|
|
39
|
+
this.log(LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
|
|
40
|
+
return {
|
|
41
|
+
code,
|
|
42
|
+
id
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
this.log(LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
|
|
46
|
+
const plugins = this.config.transform.babel.plugins.map((plugin$1) => resolveBabelPlugin(this, code, id, plugin$1)).filter((plugin$1, _, arr) => plugin$1 && !isDuplicatePlugin(arr, plugin$1));
|
|
47
|
+
const presets = this.config.transform.babel.presets.map((preset) => resolveBabelPlugin(this, code, id, preset)).filter((preset, _, arr) => preset && !isDuplicatePlugin(arr, preset));
|
|
48
|
+
if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
|
|
49
|
+
code,
|
|
50
|
+
id
|
|
51
|
+
};
|
|
52
|
+
if ([
|
|
53
|
+
"ts",
|
|
54
|
+
"cts",
|
|
55
|
+
"mts",
|
|
56
|
+
"tsx"
|
|
57
|
+
].includes(findFileExtensionSafe(id)) && !isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: findFileExtension(id) === ".tsx" }]);
|
|
58
|
+
const result = await transformAsync(code, {
|
|
59
|
+
highlightCode: true,
|
|
60
|
+
code: true,
|
|
61
|
+
ast: false,
|
|
62
|
+
cloneInputAst: false,
|
|
63
|
+
comments: true,
|
|
64
|
+
sourceType: "module",
|
|
65
|
+
configFile: false,
|
|
66
|
+
babelrc: false,
|
|
67
|
+
envName: this.config.mode,
|
|
68
|
+
caller: { name: this.config.framework },
|
|
69
|
+
...this.config.transform.babel ?? {},
|
|
70
|
+
filename: id,
|
|
71
|
+
plugins: plugins.map((plugin$1) => {
|
|
72
|
+
return Array.isArray(plugin$1) && plugin$1.length >= 2 ? [plugin$1[0], defu(plugin$1.length > 1 && plugin$1[1] ? plugin$1[1] : {}, { options })] : plugin$1;
|
|
73
|
+
}).filter(Boolean),
|
|
74
|
+
presets: presets.map((preset) => {
|
|
75
|
+
return Array.isArray(preset) && preset.length >= 2 ? [preset[0], defu(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
|
|
76
|
+
}).filter(Boolean)
|
|
77
|
+
});
|
|
78
|
+
if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
|
|
79
|
+
return {
|
|
80
|
+
code: result.code,
|
|
81
|
+
id
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
var src_default = plugin;
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { src_default as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "./plugin.mjs";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PluginContext } from "../../../powerlines/src/types/context.cjs";
|
|
2
|
+
import { BabelUserConfig, UserConfig } from "../../../powerlines/src/types/config.cjs";
|
|
3
|
+
import { BabelResolvedConfig, ResolvedConfig } from "../../../powerlines/src/types/resolved.cjs";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-babel/src/types/plugin.d.ts
|
|
6
|
+
type BabelPluginOptions = Partial<BabelUserConfig>;
|
|
7
|
+
type BabelPluginUserConfig = UserConfig;
|
|
8
|
+
interface BabelPluginResolvedConfig extends ResolvedConfig {
|
|
9
|
+
transform: {
|
|
10
|
+
babel: BabelResolvedConfig;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type BabelPluginContext<TResolvedConfig extends BabelPluginResolvedConfig = BabelPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PluginContext } from "../../../powerlines/src/types/context.mjs";
|
|
2
|
+
import { BabelUserConfig, UserConfig } from "../../../powerlines/src/types/config.mjs";
|
|
3
|
+
import { BabelResolvedConfig, ResolvedConfig } from "../../../powerlines/src/types/resolved.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-babel/src/types/plugin.d.ts
|
|
6
|
+
type BabelPluginOptions = Partial<BabelUserConfig>;
|
|
7
|
+
type BabelPluginUserConfig = UserConfig;
|
|
8
|
+
interface BabelPluginResolvedConfig extends ResolvedConfig {
|
|
9
|
+
transform: {
|
|
10
|
+
babel: BabelResolvedConfig;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type BabelPluginContext<TResolvedConfig extends BabelPluginResolvedConfig = BabelPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const require_plugin = require('./plugin.cjs');
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_create_plugin = require('../../../plugin-babel/src/helpers/create-plugin.cjs');
|
|
3
|
+
const require_module_helpers = require('../../../plugin-babel/src/helpers/module-helpers.cjs');
|
|
4
|
+
const require_capnp = require('../../../deepkit/src/capnp.cjs');
|
|
5
|
+
const require_reflection = require('../../../deepkit/schemas/reflection2.cjs');
|
|
6
|
+
const require_utilities = require('../../../deepkit/src/utilities.cjs');
|
|
7
|
+
const require_persistence = require('../helpers/persistence.cjs');
|
|
8
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
9
|
+
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
10
|
+
let __stryke_capnp = require("@stryke/capnp");
|
|
11
|
+
__stryke_capnp = require_rolldown_runtime.__toESM(__stryke_capnp);
|
|
12
|
+
let __stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
13
|
+
let node_fs = require("node:fs");
|
|
14
|
+
|
|
15
|
+
//#region ../plugin-env/src/babel/plugin.ts
|
|
16
|
+
const envBabelPlugin = require_create_plugin.createBabelPlugin("env", ({ log, context }) => {
|
|
17
|
+
function extractEnv(node, pass, isInjectable = false) {
|
|
18
|
+
const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
19
|
+
if (node.name) {
|
|
20
|
+
const prefix = context.config.env.prefix.find((pre) => node.name && node.name.startsWith(pre) && (context.env.types.env?.hasProperty(node.name.replace(`${pre}_`, "")) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(node.name.replace(`${pre}_`, "")))));
|
|
21
|
+
let name = node.name;
|
|
22
|
+
if (prefix) name = node.name.replace(`${prefix}_`, "");
|
|
23
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
|
|
24
|
+
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
|
|
25
|
+
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
|
|
26
|
+
if (!envProperty || envProperty.isIgnored()) return;
|
|
27
|
+
if (!context.env.used.env.hasProperty(name)) context.env.used.env.addProperty(envProperty.property);
|
|
28
|
+
if (context.config.env.inject && isInjectable) {
|
|
29
|
+
let value = context.env.parsed?.[name];
|
|
30
|
+
if (value === void 0) {
|
|
31
|
+
const prefix$1 = context.config.env.prefix.find((pre) => {
|
|
32
|
+
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
33
|
+
});
|
|
34
|
+
if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
|
|
35
|
+
}
|
|
36
|
+
value ??= envProperty.getDefaultValue();
|
|
37
|
+
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
38
|
+
return require_utilities.stringifyDefaultValue(envProperty, value);
|
|
39
|
+
}
|
|
40
|
+
} else 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"}.
|
|
41
|
+
|
|
42
|
+
The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort((a, b) => String(a).localeCompare(String(b))).map((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0) ? `(Alias: ${envTypesAliasProperties?.find((prop) => prop.getNameAsString() === String(typeDef))?.getAlias().join(", ")})` : ""}`).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map((prefix$1) => ` - ${prefix$1}`).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`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
visitor: { MemberExpression(path, pass) {
|
|
47
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "$storm" }) && path.get("property")?.isIdentifier()) {
|
|
48
|
+
const identifier = path.get("property")?.node;
|
|
49
|
+
extractEnv(identifier, pass, false);
|
|
50
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
51
|
+
require_module_helpers.addImport(path, {
|
|
52
|
+
module: "storm:env",
|
|
53
|
+
name: "env",
|
|
54
|
+
imported: "env"
|
|
55
|
+
});
|
|
56
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isCallExpression({ callee: {
|
|
57
|
+
name: "useStorm",
|
|
58
|
+
type: "Identifier"
|
|
59
|
+
} }) && path.get("property")?.isIdentifier()) {
|
|
60
|
+
const identifier = path.get("property")?.node;
|
|
61
|
+
extractEnv(identifier, pass, false);
|
|
62
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
63
|
+
require_module_helpers.addImport(path, {
|
|
64
|
+
module: "storm:env",
|
|
65
|
+
name: "env",
|
|
66
|
+
imported: "env"
|
|
67
|
+
});
|
|
68
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
69
|
+
const identifier = path.get("property")?.node;
|
|
70
|
+
if (!identifier.name) return;
|
|
71
|
+
extractEnv(identifier, pass, false);
|
|
72
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
73
|
+
require_module_helpers.addImport(path, {
|
|
74
|
+
module: "storm:env",
|
|
75
|
+
name: "env",
|
|
76
|
+
imported: "env"
|
|
77
|
+
});
|
|
78
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
79
|
+
const identifier = path.get("property")?.node;
|
|
80
|
+
if (!identifier.name) return;
|
|
81
|
+
extractEnv(identifier, pass, false);
|
|
82
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
83
|
+
require_module_helpers.addImport(path, {
|
|
84
|
+
module: "storm:env",
|
|
85
|
+
name: "env",
|
|
86
|
+
imported: "env"
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} },
|
|
90
|
+
post() {
|
|
91
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
|
|
92
|
+
let persistedEnv = __powerlines_deepkit_vendor_type.ReflectionClass.from({
|
|
93
|
+
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
94
|
+
description: `An object containing the environment variables used by the application.`,
|
|
95
|
+
types: []
|
|
96
|
+
});
|
|
97
|
+
const reflectionPath = require_persistence.getEnvReflectionsPath(context, "env");
|
|
98
|
+
if (reflectionPath && (0, node_fs.existsSync)(reflectionPath)) {
|
|
99
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment reflection file found at ${reflectionPath}, reading existing reflection.`);
|
|
100
|
+
persistedEnv = (0, __powerlines_deepkit_vendor_type.resolveClassType)((0, __powerlines_deepkit_vendor_type.deserializeType)(require_capnp.convertFromCapnp(new __stryke_capnp.Message((0, __stryke_fs_buffer.readFileBufferSync)(reflectionPath), false).getRoot(require_reflection.SerializedTypes).types)));
|
|
101
|
+
}
|
|
102
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding new variables to env reflection at ${reflectionPath}.`);
|
|
103
|
+
persistedEnv.getProperties().filter((property) => property.getNameAsString() && !context.env.used.env.hasProperty(property.getNameAsString())).forEach((property) => {
|
|
104
|
+
context.env.used.env.addProperty({
|
|
105
|
+
...property,
|
|
106
|
+
name: property.getNameAsString(),
|
|
107
|
+
description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
|
|
108
|
+
default: property.getDefaultValue(),
|
|
109
|
+
optional: property.isOptional() ? true : void 0,
|
|
110
|
+
readonly: property.isReadonly() ? true : void 0,
|
|
111
|
+
visibility: property.getVisibility(),
|
|
112
|
+
type: property.getType(),
|
|
113
|
+
tags: property.getTags()
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
exports.envBabelPlugin = envBabelPlugin;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createBabelPlugin } from "../../../plugin-babel/src/helpers/create-plugin.mjs";
|
|
2
|
+
import { addImport } from "../../../plugin-babel/src/helpers/module-helpers.mjs";
|
|
3
|
+
import { convertFromCapnp } from "../../../deepkit/src/capnp.mjs";
|
|
4
|
+
import { SerializedTypes } from "../../../deepkit/schemas/reflection2.mjs";
|
|
5
|
+
import { stringifyDefaultValue } from "../../../deepkit/src/utilities.mjs";
|
|
6
|
+
import { getEnvReflectionsPath } from "../helpers/persistence.mjs";
|
|
7
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
8
|
+
import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
9
|
+
import * as capnp from "@stryke/capnp";
|
|
10
|
+
import { readFileBufferSync } from "@stryke/fs/buffer";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
|
|
13
|
+
//#region ../plugin-env/src/babel/plugin.ts
|
|
14
|
+
const envBabelPlugin = createBabelPlugin("env", ({ log, context }) => {
|
|
15
|
+
function extractEnv(node, pass, isInjectable = false) {
|
|
16
|
+
const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
17
|
+
if (node.name) {
|
|
18
|
+
const prefix = context.config.env.prefix.find((pre) => node.name && node.name.startsWith(pre) && (context.env.types.env?.hasProperty(node.name.replace(`${pre}_`, "")) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(node.name.replace(`${pre}_`, "")))));
|
|
19
|
+
let name = node.name;
|
|
20
|
+
if (prefix) name = node.name.replace(`${prefix}_`, "");
|
|
21
|
+
log(LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
|
|
22
|
+
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
|
|
23
|
+
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
|
|
24
|
+
if (!envProperty || envProperty.isIgnored()) return;
|
|
25
|
+
if (!context.env.used.env.hasProperty(name)) context.env.used.env.addProperty(envProperty.property);
|
|
26
|
+
if (context.config.env.inject && isInjectable) {
|
|
27
|
+
let value = context.env.parsed?.[name];
|
|
28
|
+
if (value === void 0) {
|
|
29
|
+
const prefix$1 = context.config.env.prefix.find((pre) => {
|
|
30
|
+
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
31
|
+
});
|
|
32
|
+
if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
|
|
33
|
+
}
|
|
34
|
+
value ??= envProperty.getDefaultValue();
|
|
35
|
+
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
36
|
+
return stringifyDefaultValue(envProperty, value);
|
|
37
|
+
}
|
|
38
|
+
} else 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"}.
|
|
39
|
+
|
|
40
|
+
The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort((a, b) => String(a).localeCompare(String(b))).map((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0) ? `(Alias: ${envTypesAliasProperties?.find((prop) => prop.getNameAsString() === String(typeDef))?.getAlias().join(", ")})` : ""}`).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map((prefix$1) => ` - ${prefix$1}`).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`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
visitor: { MemberExpression(path, pass) {
|
|
45
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "$storm" }) && path.get("property")?.isIdentifier()) {
|
|
46
|
+
const identifier = path.get("property")?.node;
|
|
47
|
+
extractEnv(identifier, pass, false);
|
|
48
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
49
|
+
addImport(path, {
|
|
50
|
+
module: "storm:env",
|
|
51
|
+
name: "env",
|
|
52
|
+
imported: "env"
|
|
53
|
+
});
|
|
54
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isCallExpression({ callee: {
|
|
55
|
+
name: "useStorm",
|
|
56
|
+
type: "Identifier"
|
|
57
|
+
} }) && path.get("property")?.isIdentifier()) {
|
|
58
|
+
const identifier = path.get("property")?.node;
|
|
59
|
+
extractEnv(identifier, pass, false);
|
|
60
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
61
|
+
addImport(path, {
|
|
62
|
+
module: "storm:env",
|
|
63
|
+
name: "env",
|
|
64
|
+
imported: "env"
|
|
65
|
+
});
|
|
66
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
67
|
+
const identifier = path.get("property")?.node;
|
|
68
|
+
if (!identifier.name) return;
|
|
69
|
+
extractEnv(identifier, pass, false);
|
|
70
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
71
|
+
addImport(path, {
|
|
72
|
+
module: "storm:env",
|
|
73
|
+
name: "env",
|
|
74
|
+
imported: "env"
|
|
75
|
+
});
|
|
76
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
77
|
+
const identifier = path.get("property")?.node;
|
|
78
|
+
if (!identifier.name) return;
|
|
79
|
+
extractEnv(identifier, pass, false);
|
|
80
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
81
|
+
addImport(path, {
|
|
82
|
+
module: "storm:env",
|
|
83
|
+
name: "env",
|
|
84
|
+
imported: "env"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
} },
|
|
88
|
+
post() {
|
|
89
|
+
log(LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
|
|
90
|
+
let persistedEnv = ReflectionClass.from({
|
|
91
|
+
kind: ReflectionKind.objectLiteral,
|
|
92
|
+
description: `An object containing the environment variables used by the application.`,
|
|
93
|
+
types: []
|
|
94
|
+
});
|
|
95
|
+
const reflectionPath = getEnvReflectionsPath(context, "env");
|
|
96
|
+
if (reflectionPath && existsSync(reflectionPath)) {
|
|
97
|
+
log(LogLevelLabel.TRACE, `Environment reflection file found at ${reflectionPath}, reading existing reflection.`);
|
|
98
|
+
persistedEnv = resolveClassType(deserializeType(convertFromCapnp(new capnp.Message(readFileBufferSync(reflectionPath), false).getRoot(SerializedTypes).types)));
|
|
99
|
+
}
|
|
100
|
+
log(LogLevelLabel.TRACE, `Adding new variables to env reflection at ${reflectionPath}.`);
|
|
101
|
+
persistedEnv.getProperties().filter((property) => property.getNameAsString() && !context.env.used.env.hasProperty(property.getNameAsString())).forEach((property) => {
|
|
102
|
+
context.env.used.env.addProperty({
|
|
103
|
+
...property,
|
|
104
|
+
name: property.getNameAsString(),
|
|
105
|
+
description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
|
|
106
|
+
default: property.getDefaultValue(),
|
|
107
|
+
optional: property.isOptional() ? true : void 0,
|
|
108
|
+
readonly: property.isReadonly() ? true : void 0,
|
|
109
|
+
visibility: property.getVisibility(),
|
|
110
|
+
type: property.getType(),
|
|
111
|
+
tags: property.getTags()
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { envBabelPlugin };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require('../../../plugin-alloy/src/core/contexts/context.cjs');
|
|
2
|
+
require('../helpers/create-reflection-resource.cjs');
|
|
3
|
+
require('../../../plugin-alloy/src/markdown/components/markdown-file.cjs');
|
|
4
|
+
require('../../../plugin-alloy/src/markdown/components/markdown-table.cjs');
|
|
5
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
8
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
9
|
+
require("@alloy-js/markdown");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../../../plugin-alloy/src/core/contexts/context.mjs";
|
|
2
|
+
import "../helpers/create-reflection-resource.mjs";
|
|
3
|
+
import "../../../plugin-alloy/src/markdown/components/markdown-file.mjs";
|
|
4
|
+
import "../../../plugin-alloy/src/markdown/components/markdown-table.mjs";
|
|
5
|
+
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
6
|
+
import { stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
7
|
+
import { Show, code } from "@alloy-js/core";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join";
|
|
9
|
+
import "@alloy-js/markdown";
|
|
10
|
+
|
|
11
|
+
export { };
|