@powerlines/plugin-nodejs 0.1.115 → 0.1.117

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.
Files changed (144) hide show
  1. package/dist/components/env.cjs +14 -14
  2. package/dist/components/env.mjs +6 -6
  3. package/dist/deepkit/schemas/reflection.cjs +3998 -0
  4. package/dist/deepkit/schemas/reflection.mjs +3996 -0
  5. package/dist/deepkit/schemas/reflection2.cjs +4112 -0
  6. package/dist/deepkit/schemas/reflection2.mjs +4110 -0
  7. package/dist/deepkit/src/capnp.cjs +913 -0
  8. package/dist/deepkit/src/capnp.mjs +911 -0
  9. package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
  10. package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
  11. package/dist/deepkit/src/reflect-type.cjs +22 -0
  12. package/dist/deepkit/src/reflect-type.mjs +20 -0
  13. package/dist/deepkit/src/resolve-reflections.cjs +16 -0
  14. package/dist/deepkit/src/resolve-reflections.mjs +15 -0
  15. package/dist/deepkit/src/transformer.cjs +52 -0
  16. package/dist/deepkit/src/transformer.mjs +49 -0
  17. package/dist/deepkit/src/transpile.cjs +29 -0
  18. package/dist/deepkit/src/transpile.mjs +27 -0
  19. package/dist/deepkit/src/utilities.cjs +67 -0
  20. package/dist/deepkit/src/utilities.mjs +66 -0
  21. package/dist/index.cjs +6 -8
  22. package/dist/index.mjs +5 -5
  23. package/dist/plugin-alloy/src/core/components/output.cjs +43 -0
  24. package/dist/plugin-alloy/src/core/components/output.mjs +42 -0
  25. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
  26. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
  27. package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
  28. package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
  29. package/dist/plugin-alloy/src/core/contexts/context.cjs +49 -0
  30. package/dist/plugin-alloy/src/core/contexts/context.mjs +44 -0
  31. package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
  32. package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
  33. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
  34. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
  35. package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
  36. package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
  37. package/dist/plugin-alloy/src/index.cjs +105 -0
  38. package/dist/plugin-alloy/src/index.mjs +103 -0
  39. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +115 -0
  40. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +114 -0
  41. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +39 -0
  42. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +38 -0
  43. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +18 -0
  44. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
  45. package/dist/plugin-alloy/src/types/components.d.mts +2 -1
  46. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +62 -0
  47. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +61 -0
  48. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +131 -0
  49. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +129 -0
  50. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +451 -0
  51. package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +1 -1
  52. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +442 -0
  53. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +216 -0
  54. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +1 -1
  55. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +213 -0
  56. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +72 -0
  57. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +2 -2
  58. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +71 -0
  59. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
  60. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
  61. package/dist/plugin-automd/src/index.cjs +101 -0
  62. package/dist/plugin-automd/src/index.mjs +98 -0
  63. package/dist/plugin-automd/src/types/plugin.d.mts +3 -1
  64. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
  65. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
  66. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
  67. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
  68. package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
  69. package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
  70. package/dist/plugin-babel/src/helpers/index.cjs +5 -0
  71. package/dist/plugin-babel/src/helpers/index.mjs +7 -0
  72. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
  73. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
  74. package/dist/plugin-babel/src/helpers/options.cjs +49 -0
  75. package/dist/plugin-babel/src/helpers/options.mjs +46 -0
  76. package/dist/plugin-babel/src/index.cjs +85 -0
  77. package/dist/plugin-babel/src/index.mjs +83 -0
  78. package/dist/plugin-babel/src/types/index.d.mts +1 -0
  79. package/dist/plugin-env/src/babel/index.cjs +1 -0
  80. package/dist/plugin-env/src/babel/index.mjs +3 -0
  81. package/dist/plugin-env/src/babel/plugin.cjs +70 -0
  82. package/dist/plugin-env/src/babel/plugin.mjs +69 -0
  83. package/dist/plugin-env/src/components/docs.cjs +70 -0
  84. package/dist/plugin-env/src/components/docs.mjs +69 -0
  85. package/dist/plugin-env/src/components/env.cjs +589 -0
  86. package/dist/plugin-env/src/components/env.mjs +586 -0
  87. package/dist/plugin-env/src/components/index.cjs +2 -0
  88. package/dist/plugin-env/src/components/index.mjs +4 -0
  89. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
  90. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
  91. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
  92. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
  93. package/dist/plugin-env/src/helpers/docs-helper.cjs +16 -0
  94. package/dist/plugin-env/src/helpers/docs-helper.mjs +15 -0
  95. package/dist/plugin-env/src/helpers/index.cjs +6 -0
  96. package/dist/plugin-env/src/helpers/index.mjs +8 -0
  97. package/dist/plugin-env/src/helpers/load.cjs +84 -0
  98. package/dist/plugin-env/src/helpers/load.mjs +81 -0
  99. package/dist/plugin-env/src/helpers/persistence.cjs +201 -0
  100. package/dist/plugin-env/src/helpers/persistence.mjs +190 -0
  101. package/dist/plugin-env/src/helpers/reflect.cjs +125 -0
  102. package/dist/plugin-env/src/helpers/reflect.mjs +117 -0
  103. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
  104. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
  105. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
  106. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
  107. package/dist/plugin-env/src/index.cjs +177 -0
  108. package/dist/plugin-env/src/index.mjs +175 -0
  109. package/dist/plugin-env/src/types/plugin.d.mts +2 -1
  110. package/dist/powerlines/src/internal/helpers/hooks.d.mts +2 -0
  111. package/dist/powerlines/src/lib/build/esbuild.cjs +93 -0
  112. package/dist/powerlines/src/lib/build/esbuild.mjs +91 -0
  113. package/dist/powerlines/src/lib/constants/environments.cjs +6 -0
  114. package/dist/powerlines/src/lib/constants/environments.mjs +5 -0
  115. package/dist/powerlines/src/lib/entry.cjs +11 -0
  116. package/dist/powerlines/src/lib/entry.mjs +13 -0
  117. package/dist/powerlines/src/lib/logger.cjs +41 -0
  118. package/dist/powerlines/src/lib/logger.mjs +39 -0
  119. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
  120. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
  121. package/dist/powerlines/src/lib/unplugin/helpers.cjs +3 -0
  122. package/dist/powerlines/src/lib/unplugin/helpers.mjs +5 -0
  123. package/dist/powerlines/src/lib/unplugin/module-resolution.cjs +66 -0
  124. package/dist/powerlines/src/lib/unplugin/module-resolution.mjs +65 -0
  125. package/dist/powerlines/src/lib/unplugin/plugin.cjs +46 -0
  126. package/dist/powerlines/src/lib/unplugin/plugin.mjs +45 -0
  127. package/dist/powerlines/src/lib/utilities/bundle.cjs +42 -0
  128. package/dist/powerlines/src/lib/utilities/bundle.mjs +40 -0
  129. package/dist/powerlines/src/lib/utilities/resolve.cjs +50 -0
  130. package/dist/powerlines/src/lib/utilities/resolve.mjs +49 -0
  131. package/dist/powerlines/src/lib/utilities/source-file.cjs +5 -0
  132. package/dist/powerlines/src/lib/utilities/source-file.mjs +5 -0
  133. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  134. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
  135. package/dist/powerlines/src/types/build.cjs +21 -0
  136. package/dist/powerlines/src/types/build.d.mts +6 -6
  137. package/dist/powerlines/src/types/build.mjs +21 -0
  138. package/dist/powerlines/src/types/commands.d.mts +1 -0
  139. package/dist/powerlines/src/types/config.d.mts +3 -2
  140. package/dist/powerlines/src/types/context.d.mts +2 -2
  141. package/dist/powerlines/src/types/plugin.d.mts +1 -1
  142. package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
  143. package/dist/powerlines/src/types/unplugin.d.mts +2 -1
  144. package/package.json +6 -6
@@ -0,0 +1,83 @@
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 { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
8
+ import { isParentPath } from "@stryke/path/is-parent-path";
9
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
10
+ import defu from "defu";
11
+
12
+ //#region ../plugin-babel/src/index.ts
13
+ /**
14
+ * Babel plugin for Powerlines.
15
+ *
16
+ * @param options - The Babel plugin user configuration options.
17
+ * @returns A Powerlines plugin that integrates Babel transformations.
18
+ */
19
+ const plugin = (options = {}) => {
20
+ return {
21
+ name: "babel",
22
+ config() {
23
+ if (!isSetObject(options)) return;
24
+ return { transform: { babel: options } };
25
+ },
26
+ configResolved: {
27
+ order: "pre",
28
+ handler() {
29
+ this.config.transform.babel = defu(this.config.transform.babel ?? {}, {
30
+ plugins: [],
31
+ presets: []
32
+ });
33
+ }
34
+ },
35
+ async transform(code, id) {
36
+ if (isParentPath(id, this.powerlinesPath) || code.includes("/* @powerlines-ignore */") || code.includes("/* @powerlines-disable */")) {
37
+ this.trace(`Skipping Babel transformation for: ${id}`);
38
+ return {
39
+ code,
40
+ id
41
+ };
42
+ }
43
+ 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));
44
+ const presets = this.config.transform.babel.presets.map((preset) => resolveBabelPlugin(this, code, id, preset)).filter((preset, _, arr) => preset && !isDuplicatePlugin(arr, preset));
45
+ if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
46
+ code,
47
+ id
48
+ };
49
+ if (/^(?:m|c)?tsx?$/.test(findFileExtensionSafe(id, { fullExtension: true })) && !isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: findFileExtension(id) === "tsx" }]);
50
+ this.trace(`Running babel transformations with ${plugins.length} plugins and ${presets.length} presets for file: ${id}`);
51
+ const result = await transformAsync(code, {
52
+ highlightCode: true,
53
+ code: true,
54
+ ast: false,
55
+ cloneInputAst: false,
56
+ comments: true,
57
+ sourceType: "module",
58
+ configFile: false,
59
+ babelrc: false,
60
+ envName: this.config.mode,
61
+ caller: { name: this.config.framework },
62
+ ...this.config.transform.babel ?? {},
63
+ filename: id,
64
+ plugins: plugins.map((plugin$1) => {
65
+ 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;
66
+ }).filter(Boolean),
67
+ presets: presets.map((preset) => {
68
+ return Array.isArray(preset) && preset.length >= 2 ? [preset[0], defu(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
69
+ }).filter(Boolean)
70
+ });
71
+ if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
72
+ this.trace(`Completed babel transformations for file: ${id}`);
73
+ return {
74
+ code: result.code,
75
+ id
76
+ };
77
+ }
78
+ };
79
+ };
80
+ var src_default = plugin;
81
+
82
+ //#endregion
83
+ export { src_default as default };
@@ -0,0 +1 @@
1
+ import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "./plugin.mjs";
@@ -0,0 +1 @@
1
+ const require_plugin = require('./plugin.cjs');
@@ -0,0 +1,3 @@
1
+ import { envBabelPlugin } from "./plugin.mjs";
2
+
3
+ export { };
@@ -0,0 +1,70 @@
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_utilities = require('../../../deepkit/src/utilities.cjs');
5
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
6
+
7
+ //#region ../plugin-env/src/babel/plugin.ts
8
+ const envBabelPlugin = require_create_plugin.createBabelPlugin("env", ({ log, context }) => {
9
+ function extractEnv(node, pass, isInjectable = false) {
10
+ const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
11
+ if (node.name) {
12
+ 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}_`, "")))));
13
+ let name = node.name;
14
+ if (prefix) name = node.name.replace(`${prefix}_`, "");
15
+ log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
16
+ if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
17
+ const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
18
+ if (!envProperty || envProperty.isIgnored()) return;
19
+ if (!context.env.used.env.hasProperty(name)) {
20
+ log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`);
21
+ context.env.used.env.addProperty(envProperty.property);
22
+ }
23
+ if (context.config.env.inject && isInjectable) {
24
+ let value = context.env.parsed?.[name];
25
+ if (value === void 0) {
26
+ const prefix$1 = context.config.env.prefix.find((pre) => {
27
+ return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
28
+ });
29
+ if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
30
+ }
31
+ value ??= envProperty.getDefaultValue();
32
+ if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
33
+ return require_utilities.stringifyDefaultValue(envProperty, value);
34
+ }
35
+ } 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"}.
36
+
37
+ 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`);
38
+ }
39
+ }
40
+ return { visitor: { MemberExpression(path, pass) {
41
+ if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
42
+ const identifier = path.get("property")?.node;
43
+ if (!identifier.name) return;
44
+ extractEnv(identifier, pass, false);
45
+ path.replaceWithSourceString(`env.${identifier.name}`);
46
+ require_module_helpers.addImport(path, {
47
+ module: `${context.config.framework || "powerlines"}:env`,
48
+ name: "env",
49
+ imported: "env"
50
+ });
51
+ } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
52
+ const identifier = path.get("property")?.node;
53
+ if (!identifier.name) return;
54
+ extractEnv(identifier, pass, false);
55
+ path.replaceWithSourceString(`env.${identifier.name}`);
56
+ require_module_helpers.addImport(path, {
57
+ module: `${context.config.framework || "powerlines"}:env`,
58
+ name: "env",
59
+ imported: "env"
60
+ });
61
+ } else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
62
+ const identifier = path.get("property")?.node;
63
+ if (!identifier.name) return;
64
+ extractEnv(identifier, pass, false);
65
+ }
66
+ } } };
67
+ });
68
+
69
+ //#endregion
70
+ exports.envBabelPlugin = envBabelPlugin;
@@ -0,0 +1,69 @@
1
+ import { createBabelPlugin } from "../../../plugin-babel/src/helpers/create-plugin.mjs";
2
+ import { addImport } from "../../../plugin-babel/src/helpers/module-helpers.mjs";
3
+ import { stringifyDefaultValue } from "../../../deepkit/src/utilities.mjs";
4
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
5
+
6
+ //#region ../plugin-env/src/babel/plugin.ts
7
+ const envBabelPlugin = createBabelPlugin("env", ({ log, context }) => {
8
+ function extractEnv(node, pass, isInjectable = false) {
9
+ const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
10
+ if (node.name) {
11
+ 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}_`, "")))));
12
+ let name = node.name;
13
+ if (prefix) name = node.name.replace(`${prefix}_`, "");
14
+ log(LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
15
+ if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
16
+ const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
17
+ if (!envProperty || envProperty.isIgnored()) return;
18
+ if (!context.env.used.env.hasProperty(name)) {
19
+ log(LogLevelLabel.DEBUG, `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`);
20
+ context.env.used.env.addProperty(envProperty.property);
21
+ }
22
+ if (context.config.env.inject && isInjectable) {
23
+ let value = context.env.parsed?.[name];
24
+ if (value === void 0) {
25
+ const prefix$1 = context.config.env.prefix.find((pre) => {
26
+ return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
27
+ });
28
+ if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
29
+ }
30
+ value ??= envProperty.getDefaultValue();
31
+ if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
32
+ return stringifyDefaultValue(envProperty, value);
33
+ }
34
+ } 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"}.
35
+
36
+ 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`);
37
+ }
38
+ }
39
+ return { visitor: { MemberExpression(path, pass) {
40
+ if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
41
+ const identifier = path.get("property")?.node;
42
+ if (!identifier.name) return;
43
+ extractEnv(identifier, pass, false);
44
+ path.replaceWithSourceString(`env.${identifier.name}`);
45
+ addImport(path, {
46
+ module: `${context.config.framework || "powerlines"}:env`,
47
+ name: "env",
48
+ imported: "env"
49
+ });
50
+ } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
51
+ const identifier = path.get("property")?.node;
52
+ if (!identifier.name) return;
53
+ extractEnv(identifier, pass, false);
54
+ path.replaceWithSourceString(`env.${identifier.name}`);
55
+ addImport(path, {
56
+ module: `${context.config.framework || "powerlines"}:env`,
57
+ name: "env",
58
+ imported: "env"
59
+ });
60
+ } else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
61
+ const identifier = path.get("property")?.node;
62
+ if (!identifier.name) return;
63
+ extractEnv(identifier, pass, false);
64
+ }
65
+ } } };
66
+ });
67
+
68
+ //#endregion
69
+ export { envBabelPlugin };
@@ -0,0 +1,70 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_context = require('../../../plugin-alloy/src/core/contexts/context.cjs');
3
+ const require_markdown_file = require('../../../plugin-alloy/src/markdown/components/markdown-file.cjs');
4
+ const require_markdown_table = require('../../../plugin-alloy/src/markdown/components/markdown-table.cjs');
5
+ const require_create_reflection_resource = require('../helpers/create-reflection-resource.cjs');
6
+ const require_docs_helper = require('../helpers/docs-helper.cjs');
7
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
8
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
9
+ let __alloy_js_core = require("@alloy-js/core");
10
+ let __stryke_path_join = require("@stryke/path/join");
11
+ let __alloy_js_markdown = require("@alloy-js/markdown");
12
+
13
+ //#region ../plugin-env/src/components/docs.tsx
14
+ /**
15
+ * Generates the environment configuration markdown documentation for the Powerlines project.
16
+ */
17
+ function EnvDocsFile(props) {
18
+ const { levelOffset = 0, ...rest } = props;
19
+ const context = require_context.usePowerlinesSafe();
20
+ if (!context) return null;
21
+ const reflection = require_create_reflection_resource.createReflectionResource(context);
22
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_markdown_file.MarkdownFile, (0, __alloy_js_core_jsx_runtime.mergeProps)({ get path() {
23
+ return (0, __stryke_path_join.joinPaths)(require_docs_helper.getDocsOutputPath(context), "env.md");
24
+ } }, rest, { get children() {
25
+ return [
26
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_markdown.Heading, {
27
+ level: 1 + levelOffset,
28
+ children: "Environment Configuration"
29
+ }),
30
+ __alloy_js_core.code`Below is a list of environment variables used by the`,
31
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
32
+ get when() {
33
+ return !!context?.packageJson.name;
34
+ },
35
+ get children() {
36
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_markdown.Link, {
37
+ get href() {
38
+ return `https://www.npmjs.com/package/${context?.packageJson.name}`;
39
+ },
40
+ get title() {
41
+ return context.packageJson.name;
42
+ }
43
+ });
44
+ }
45
+ }),
46
+ __alloy_js_core.code`package. These values can be updated in the \`.env\` file in the root of the project.`,
47
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
48
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_markdown.Heading, {
49
+ level: 2 + levelOffset,
50
+ children: "Environment Variables"
51
+ }),
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.createIntrinsic)("hbr", {}),
54
+ (0, __alloy_js_core_jsx_runtime.createComponent)(require_markdown_table.MarkdownTable, { get data() {
55
+ return reflection.data?.getProperties().filter((property) => property.getNameAsString() !== "__STORM_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,69 @@
1
+ import { usePowerlinesSafe } from "../../../plugin-alloy/src/core/contexts/context.mjs";
2
+ import { MarkdownFile } from "../../../plugin-alloy/src/markdown/components/markdown-file.mjs";
3
+ import { MarkdownTable } from "../../../plugin-alloy/src/markdown/components/markdown-table.mjs";
4
+ import { createReflectionResource } from "../helpers/create-reflection-resource.mjs";
5
+ import { getDocsOutputPath } from "../helpers/docs-helper.mjs";
6
+ import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
7
+ import { stringifyType } from "@powerlines/deepkit/vendor/type";
8
+ import { Show, code } from "@alloy-js/core";
9
+ import { joinPaths } from "@stryke/path/join";
10
+ import { Heading, Link } from "@alloy-js/markdown";
11
+
12
+ //#region ../plugin-env/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, ...rest } = props;
18
+ const context = usePowerlinesSafe();
19
+ if (!context) return null;
20
+ const reflection = createReflectionResource(context);
21
+ return createComponent(MarkdownFile, mergeProps({ get path() {
22
+ return joinPaths(getDocsOutputPath(context), "env.md");
23
+ } }, rest, { get children() {
24
+ return [
25
+ createComponent(Heading, {
26
+ level: 1 + levelOffset,
27
+ children: "Environment Configuration"
28
+ }),
29
+ code`Below is a list of environment variables used by the`,
30
+ createComponent(Show, {
31
+ get when() {
32
+ return !!context?.packageJson.name;
33
+ },
34
+ get children() {
35
+ return createComponent(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
+ code`package. These values can be updated in the \`.env\` file in the root of the project.`,
46
+ createIntrinsic("hbr", {}),
47
+ createComponent(Heading, {
48
+ level: 2 + levelOffset,
49
+ children: "Environment Variables"
50
+ }),
51
+ 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.`,
52
+ createIntrinsic("hbr", {}),
53
+ createComponent(MarkdownTable, { get data() {
54
+ return reflection.data?.getProperties().filter((property) => property.getNameAsString() !== "__STORM_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
55
+ return {
56
+ name: reflectionProperty.getNameAsString().trim(),
57
+ description: (reflectionProperty.getDescription() ?? "").trim(),
58
+ type: stringifyType(reflectionProperty.getType()).trim().replaceAll(" | ", ", or "),
59
+ defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
60
+ required: reflectionProperty.isValueRequired() ? "" : "✔"
61
+ };
62
+ }) ?? [];
63
+ } })
64
+ ];
65
+ } }));
66
+ }
67
+
68
+ //#endregion
69
+ export { EnvDocsFile };