@powerlines/plugin-env 0.15.4 → 0.15.6
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/babel/index.cjs +1 -0
- package/dist/babel/index.d.cts +1 -0
- package/dist/babel/index.d.mts +1 -0
- package/dist/babel/index.mjs +3 -0
- package/dist/babel/plugin.cjs +200 -0
- package/dist/babel/plugin.d.cts +8 -0
- package/dist/babel/plugin.d.mts +9 -0
- package/dist/babel/plugin.mjs +198 -0
- package/dist/components/docs.cjs +70 -3
- package/dist/components/docs.d.cts +8 -1
- package/dist/components/docs.d.mts +8 -1
- package/dist/components/docs.mjs +68 -2
- package/dist/components/env.cjs +574 -4
- package/dist/components/env.d.cts +19 -2
- package/dist/components/env.d.mts +19 -3
- package/dist/components/env.mjs +570 -2
- package/dist/components/index.cjs +5 -7
- package/dist/components/index.d.cts +2 -4
- package/dist/components/index.d.mts +2 -5
- package/dist/components/index.mjs +2 -4
- package/dist/deepkit/schemas/reflection.cjs +5368 -0
- package/dist/{plugin-BwuEBScL.d.cts → deepkit/schemas/reflection.d.cts} +1 -268
- package/dist/{plugin-BaInAuAh.d.mts → deepkit/schemas/reflection.d.mts} +59 -326
- package/dist/deepkit/schemas/reflection.mjs +5365 -0
- package/dist/deepkit/schemas/reflection2.cjs +4112 -0
- package/dist/deepkit/schemas/reflection2.mjs +4110 -0
- package/dist/deepkit/src/capnp.cjs +1692 -0
- package/dist/deepkit/src/capnp.mjs +1690 -0
- package/dist/deepkit/src/esbuild-plugin.cjs +99 -0
- package/dist/deepkit/src/esbuild-plugin.mjs +98 -0
- package/dist/deepkit/src/reflect-type.cjs +40 -0
- package/dist/deepkit/src/reflect-type.mjs +38 -0
- package/dist/deepkit/src/resolve-reflections.cjs +23 -0
- package/dist/deepkit/src/resolve-reflections.mjs +22 -0
- package/dist/deepkit/src/transformer.cjs +92 -0
- package/dist/deepkit/src/transformer.mjs +89 -0
- package/dist/deepkit/src/transpile.cjs +39 -0
- package/dist/deepkit/src/transpile.mjs +37 -0
- package/dist/deepkit/src/types.cjs +22 -0
- package/dist/deepkit/src/types.d.cts +10 -0
- package/dist/deepkit/src/types.d.mts +10 -0
- package/dist/deepkit/src/types.mjs +21 -0
- package/dist/deepkit/src/utilities.cjs +182 -0
- package/dist/deepkit/src/utilities.mjs +181 -0
- package/dist/helpers/automd-generator.cjs +32 -0
- package/dist/helpers/automd-generator.mjs +31 -0
- package/dist/helpers/create-reflection-resource.cjs +98 -0
- package/dist/helpers/create-reflection-resource.d.cts +15 -0
- package/dist/helpers/create-reflection-resource.d.mts +15 -0
- package/dist/helpers/create-reflection-resource.mjs +97 -0
- package/dist/helpers/index.cjs +6 -0
- package/dist/helpers/index.d.cts +6 -0
- package/dist/helpers/index.d.mts +6 -0
- package/dist/helpers/index.mjs +8 -0
- package/dist/helpers/load.cjs +134 -0
- package/dist/helpers/load.d.cts +35 -0
- package/dist/helpers/load.d.mts +36 -0
- package/dist/helpers/load.mjs +131 -0
- package/dist/helpers/persistence.cjs +320 -0
- package/dist/helpers/persistence.d.cts +84 -0
- package/dist/helpers/persistence.d.mts +84 -0
- package/dist/helpers/persistence.mjs +308 -0
- package/dist/helpers/reflect.cjs +263 -0
- package/dist/helpers/reflect.d.cts +46 -0
- package/dist/helpers/reflect.d.mts +46 -0
- package/dist/helpers/reflect.mjs +254 -0
- package/dist/helpers/source-file-env.cjs +58 -0
- package/dist/helpers/source-file-env.d.cts +8 -0
- package/dist/helpers/source-file-env.d.mts +8 -0
- package/dist/helpers/source-file-env.mjs +56 -0
- package/dist/helpers/template-helpers.cjs +70 -0
- package/dist/helpers/template-helpers.d.cts +15 -0
- package/dist/helpers/template-helpers.d.mts +15 -0
- package/dist/helpers/template-helpers.mjs +69 -0
- package/dist/index.cjs +82 -696
- package/dist/index.d.cts +16 -185
- package/dist/index.d.mts +17 -190
- package/dist/index.mjs +31 -648
- 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 +136 -0
- package/dist/plugin-alloy/src/core/contexts/context.mjs +128 -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 +110 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +101 -0
- package/dist/plugin-alloy/src/helpers/refkey.cjs +23 -0
- package/dist/plugin-alloy/src/helpers/refkey.mjs +22 -0
- package/dist/plugin-alloy/src/index.cjs +93 -0
- package/dist/plugin-alloy/src/index.mjs +91 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +115 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +114 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +39 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +38 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +72 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +71 -0
- package/dist/plugin-alloy/src/types/components.cjs +22 -0
- package/dist/plugin-alloy/src/types/components.d.cts +22 -0
- package/dist/{components-8W0Zgj0y.d.mts → plugin-alloy/src/types/components.d.mts} +2 -1
- package/dist/plugin-alloy/src/types/components.mjs +21 -0
- package/dist/plugin-alloy/src/types/index.d.mts +2 -0
- package/dist/plugin-alloy/src/types/plugin.cjs +55 -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/types/plugin.mjs +52 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +25 -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 +27 -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 +14 -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 +11 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +12 -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 +127 -0
- package/dist/plugin-automd/src/index.mjs +124 -0
- package/dist/plugin-automd/src/types/plugin.cjs +47 -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/plugin.mjs +47 -0
- package/dist/plugin-automd/src/types/toc.cjs +26 -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-automd/src/types/toc.mjs +25 -0
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +74 -0
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +70 -0
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +71 -0
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +69 -0
- package/dist/plugin-babel/src/helpers/filters.cjs +158 -0
- package/dist/plugin-babel/src/helpers/filters.mjs +154 -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 +200 -0
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +192 -0
- package/dist/plugin-babel/src/helpers/options.cjs +74 -0
- package/dist/plugin-babel/src/helpers/options.mjs +71 -0
- package/dist/plugin-babel/src/index.cjs +134 -0
- package/dist/plugin-babel/src/index.mjs +132 -0
- package/dist/plugin-babel/src/types/index.d.mts +1 -0
- package/dist/plugin-babel/src/types/plugin.cjs +42 -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-babel/src/types/plugin.mjs +39 -0
- package/dist/powerlines/schemas/fs.d.mts +1 -0
- package/dist/powerlines/src/api.d.mts +7 -0
- package/dist/powerlines/src/index.d.mts +12 -0
- package/dist/powerlines/src/internal/helpers/hooks.cjs +119 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +5 -0
- package/dist/powerlines/src/internal/helpers/hooks.mjs +118 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +161 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +159 -0
- package/dist/powerlines/src/lib/entry.cjs +203 -0
- package/dist/powerlines/src/lib/entry.mjs +201 -0
- package/dist/powerlines/src/lib/logger.cjs +108 -0
- package/dist/powerlines/src/lib/logger.mjs +106 -0
- package/dist/powerlines/src/lib/utilities/bundle.cjs +67 -0
- package/dist/powerlines/src/lib/utilities/bundle.mjs +66 -0
- package/dist/powerlines/src/lib/utilities/resolve.cjs +49 -0
- package/dist/powerlines/src/lib/utilities/resolve.mjs +48 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +46 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +45 -0
- package/dist/powerlines/src/types/api.cjs +1 -0
- package/dist/powerlines/src/types/api.d.mts +5 -0
- package/dist/powerlines/src/types/api.mjs +3 -0
- package/dist/powerlines/src/types/babel.cjs +156 -0
- package/dist/powerlines/src/types/babel.d.cts +23 -0
- package/dist/powerlines/src/types/babel.d.mts +23 -0
- package/dist/powerlines/src/types/babel.mjs +147 -0
- package/dist/powerlines/src/types/build.cjs +105 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +147 -0
- package/dist/powerlines/src/types/build.mjs +101 -0
- package/dist/powerlines/src/types/commands.cjs +16 -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/commands.mjs +15 -0
- package/dist/powerlines/src/types/config.cjs +306 -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/config.mjs +293 -0
- package/dist/powerlines/src/types/context.cjs +324 -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/context.mjs +311 -0
- package/dist/powerlines/src/types/fs.cjs +78 -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/fs.mjs +75 -0
- package/dist/powerlines/src/types/hooks.cjs +52 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/hooks.mjs +48 -0
- package/dist/powerlines/src/types/index.cjs +11 -0
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/index.mjs +13 -0
- package/dist/powerlines/src/types/plugin.cjs +249 -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/plugin.mjs +240 -0
- package/dist/powerlines/src/types/resolved.cjs +153 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +83 -0
- package/dist/powerlines/src/types/resolved.mjs +148 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/powerlines/src/types/unplugin.cjs +1 -0
- package/dist/powerlines/src/types/unplugin.d.mts +7 -0
- package/dist/powerlines/src/types/unplugin.mjs +3 -0
- package/dist/types/index.cjs +10 -3
- package/dist/types/index.d.cts +2 -4
- package/dist/types/index.d.mts +2 -5
- package/dist/types/index.mjs +3 -4
- package/dist/types/plugin.cjs +133 -1
- package/dist/types/plugin.d.cts +156 -3
- package/dist/types/plugin.d.mts +158 -4
- package/dist/types/plugin.mjs +128 -2
- package/dist/types/runtime.cjs +242 -1
- package/dist/types/runtime.d.cts +793 -2
- package/dist/types/runtime.d.mts +793 -2
- package/dist/types/runtime.mjs +240 -2
- package/package.json +13 -9
- package/dist/components-C9bYrQVK.cjs +0 -0
- package/dist/components-CNIQFfeK.mjs +0 -1
- package/dist/create-reflection-resource-BNYxBgW2.mjs +0 -9846
- package/dist/create-reflection-resource-BWYhmX7O.cjs +0 -10085
- package/dist/docs-5r844zC1.d.mts +0 -9
- package/dist/docs-B66b9li3.mjs +0 -219
- package/dist/docs-_MmTNBQX.d.cts +0 -9
- package/dist/docs-hBlKCRWK.cjs +0 -224
- package/dist/env-BPodCdD1.d.cts +0 -116
- package/dist/env-IQvgnabX.mjs +0 -1578
- package/dist/env-cO4BUDn1.cjs +0 -1596
- package/dist/env-zhzvpUI5.d.mts +0 -98
- package/dist/index-BXxhKmeA.d.mts +0 -1
- package/dist/index-Cc7fCJU9.d.mts +0 -1
- package/dist/index-CqdNToYT.d.cts +0 -1
- package/dist/index-DWPDThxu.d.cts +0 -1
- package/dist/plugin-D3B5E_Hg.mjs +0 -1
- package/dist/plugin-D5qyQPqC.cjs +0 -0
- package/dist/resolved-BZG2cwRG.d.cts +0 -1789
- package/dist/resolved-V5COsfDu.d.mts +0 -1791
- package/dist/runtime-Bisl_1Ja.cjs +0 -0
- package/dist/runtime-Q8Ni8SeN.d.cts +0 -794
- package/dist/runtime-azNoeKr-.mjs +0 -1
- package/dist/runtime-qZ0Z2kEd.d.mts +0 -794
- package/dist/types-DwElXV6q.mjs +0 -1
- package/dist/types-MYBaygjr.cjs +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,653 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
import "./plugin
|
|
6
|
-
import "./
|
|
7
|
-
import "./
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import src_default$1 from "./plugin-alloy/src/index.mjs";
|
|
2
|
+
import src_default$2 from "./plugin-automd/src/index.mjs";
|
|
3
|
+
import src_default$3 from "./plugin-babel/src/index.mjs";
|
|
4
|
+
import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
|
|
5
|
+
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
|
|
6
|
+
import { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
|
|
7
|
+
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.mjs";
|
|
8
|
+
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
9
|
+
import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.mjs";
|
|
10
|
+
import { loadEnv, loadEnvFromContext } from "./helpers/load.mjs";
|
|
11
|
+
import { createReflectionResource } from "./helpers/create-reflection-resource.mjs";
|
|
12
|
+
import { EnvBuiltin, EnvTypeDefinition } from "./components/env.mjs";
|
|
13
|
+
import { env } from "./helpers/automd-generator.mjs";
|
|
14
|
+
import "./babel/index.mjs";
|
|
15
|
+
import { EnvDocs } from "./components/docs.mjs";
|
|
16
|
+
import "./components/index.mjs";
|
|
17
|
+
import { createTemplateReflection } from "./helpers/template-helpers.mjs";
|
|
18
|
+
import "./helpers/index.mjs";
|
|
19
|
+
import "./types/index.mjs";
|
|
20
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
21
|
+
import { ReflectionClass, ReflectionKind, stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
14
22
|
import { toArray } from "@stryke/convert/to-array";
|
|
15
|
-
import
|
|
16
|
-
import { listFiles } from "@stryke/fs/list-files";
|
|
17
|
-
import { appendPath } from "@stryke/path/append";
|
|
18
|
-
import { isAbsolutePath } from "@stryke/path/is-type";
|
|
19
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
20
|
-
import { defineGenerator, loadConfig, resolveConfig, transform } from "automd";
|
|
21
|
-
import { loadConfig as loadConfig$1 } from "c12";
|
|
22
|
-
import defu from "defu";
|
|
23
|
-
import toc from "markdown-toc";
|
|
24
|
-
import { transformAsync } from "@babel/core";
|
|
23
|
+
import defu$1 from "defu";
|
|
25
24
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
26
|
-
import { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
|
|
27
25
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
28
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
29
|
-
import { isFunction } from "@stryke/type-checks/is-function";
|
|
30
|
-
import "@stryke/type-checks/is-object";
|
|
31
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
32
|
-
import chalk from "chalk";
|
|
33
|
-
import _generate from "@babel/generator";
|
|
34
|
-
import "@babel/parser";
|
|
35
|
-
import { declare } from "@babel/helper-plugin-utils";
|
|
36
|
-
import "@storm-software/config-tools/logger";
|
|
37
|
-
import "@storm-software/config-tools/utilities/colors";
|
|
38
|
-
import "@stryke/helpers/noop";
|
|
39
|
-
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
40
26
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
41
|
-
import * as t from "@babel/types";
|
|
42
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
43
27
|
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
|
|
44
28
|
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
45
29
|
import { existsSync } from "@stryke/fs/exists";
|
|
46
30
|
import { createDirectory } from "@stryke/fs/helpers";
|
|
47
|
-
import { joinPaths
|
|
31
|
+
import { joinPaths } from "@stryke/path/join";
|
|
48
32
|
import { constantCase } from "@stryke/string-format/constant-case";
|
|
49
|
-
import * as capnp from "@stryke/capnp";
|
|
50
|
-
import { readFileBufferSync } from "@stryke/fs/buffer";
|
|
51
|
-
import { existsSync as existsSync$1 } from "node:fs";
|
|
52
33
|
|
|
53
|
-
//#region ../plugin-alloy/src/core/components/output.tsx
|
|
54
|
-
/**
|
|
55
|
-
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
56
|
-
*/
|
|
57
|
-
function Output$1(props) {
|
|
58
|
-
const [{ children, context, meta, basePath }, rest] = splitProps(props, [
|
|
59
|
-
"children",
|
|
60
|
-
"context",
|
|
61
|
-
"meta",
|
|
62
|
-
"basePath"
|
|
63
|
-
]);
|
|
64
|
-
const contextRef = ref(context);
|
|
65
|
-
const metaRef = ref(meta ?? {});
|
|
66
|
-
const basePathRef = computed(() => basePath ? replacePath(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
|
|
67
|
-
return createComponent(Output, mergeProps(rest, {
|
|
68
|
-
get basePath() {
|
|
69
|
-
return basePathRef.value;
|
|
70
|
-
},
|
|
71
|
-
get children() {
|
|
72
|
-
return createComponent(PowerlinesContext.Provider, {
|
|
73
|
-
value: {
|
|
74
|
-
ref: contextRef,
|
|
75
|
-
meta: metaRef
|
|
76
|
-
},
|
|
77
|
-
get children() {
|
|
78
|
-
return createComponent(Show, {
|
|
79
|
-
get when() {
|
|
80
|
-
return Boolean(contextRef.value);
|
|
81
|
-
},
|
|
82
|
-
children
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region ../plugin-alloy/src/index.tsx
|
|
92
|
-
/**
|
|
93
|
-
* Alloy-js plugin for Powerlines.
|
|
94
|
-
*
|
|
95
|
-
* @param options - The Alloy-js plugin user configuration options.
|
|
96
|
-
* @returns A Powerlines plugin that integrates Alloy-js transformations.
|
|
97
|
-
*/
|
|
98
|
-
const plugin$3 = (options = {}) => {
|
|
99
|
-
return [{
|
|
100
|
-
name: "alloy:config",
|
|
101
|
-
config() {
|
|
102
|
-
return {
|
|
103
|
-
alloy: {
|
|
104
|
-
typescript: true,
|
|
105
|
-
...options
|
|
106
|
-
},
|
|
107
|
-
build: {
|
|
108
|
-
inputOptions: { transform: { jsx: {
|
|
109
|
-
runtime: "classic",
|
|
110
|
-
pragma: "Alloy.createElement",
|
|
111
|
-
importSource: "@alloy-js/core"
|
|
112
|
-
} } },
|
|
113
|
-
plugins: [alloy()]
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
async configResolved() {
|
|
118
|
-
if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
|
|
119
|
-
this.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
120
|
-
if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
|
|
121
|
-
if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
|
|
122
|
-
await this.fs.write(this.tsconfig.tsconfigFilePath, StormJSON.stringify(this.tsconfig.tsconfigJson));
|
|
123
|
-
}
|
|
124
|
-
this.dependencies["@alloy-js/core"] = "^0.22.0";
|
|
125
|
-
if (this.config.alloy?.typescript !== false) this.dependencies["@alloy-js/typescript"] = "^0.22.0";
|
|
126
|
-
if (this.config.alloy?.json === true) this.dependencies["@alloy-js/json"] = "^0.22.0";
|
|
127
|
-
if (this.config.alloy?.markdown === true) this.dependencies["@alloy-js/markdown"] = "^0.22.0";
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
name: "alloy:update-context",
|
|
131
|
-
configResolved: {
|
|
132
|
-
order: "pre",
|
|
133
|
-
async handler() {
|
|
134
|
-
this.render = async (children) => {
|
|
135
|
-
const _self$ = this;
|
|
136
|
-
const meta = {};
|
|
137
|
-
await traverseOutput(await renderAsync(createComponent(Output$1, {
|
|
138
|
-
context: _self$,
|
|
139
|
-
meta,
|
|
140
|
-
get basePath() {
|
|
141
|
-
return _self$.workspaceConfig.workspaceRoot;
|
|
142
|
-
},
|
|
143
|
-
children
|
|
144
|
-
})), {
|
|
145
|
-
visitDirectory: (directory) => {
|
|
146
|
-
if (this.fs.existsSync(directory.path)) return;
|
|
147
|
-
this.fs.mkdirSync(directory.path);
|
|
148
|
-
},
|
|
149
|
-
visitFile: (file) => {
|
|
150
|
-
if ("contents" in file) {
|
|
151
|
-
const metadata = meta[file.path] ?? {};
|
|
152
|
-
if (metadata.kind === "builtin") {
|
|
153
|
-
if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
|
|
154
|
-
this.emitBuiltinSync(file.contents, metadata.id, file.path, {
|
|
155
|
-
skipFormat: metadata.skipFormat,
|
|
156
|
-
storage: metadata.storage
|
|
157
|
-
});
|
|
158
|
-
} else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
|
|
159
|
-
skipFormat: metadata.skipFormat,
|
|
160
|
-
storage: metadata.storage,
|
|
161
|
-
...metadata.typeDefinition ?? {}
|
|
162
|
-
});
|
|
163
|
-
else this.emitSync(file.contents, file.path, metadata);
|
|
164
|
-
} else this.fs.copySync(file.sourcePath, file.path);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}];
|
|
171
|
-
};
|
|
172
|
-
var src_default$1 = plugin$3;
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region ../plugin-automd/src/index.ts
|
|
176
|
-
/**
|
|
177
|
-
* AutoMD Plugin
|
|
178
|
-
*
|
|
179
|
-
* @remarks
|
|
180
|
-
* A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
|
|
181
|
-
*
|
|
182
|
-
* @see https://automd.unjs.io/
|
|
183
|
-
*
|
|
184
|
-
* @param options - The plugin options.
|
|
185
|
-
* @returns A Powerlines plugin instance.
|
|
186
|
-
*/
|
|
187
|
-
const plugin$2 = (options = {}) => {
|
|
188
|
-
return {
|
|
189
|
-
name: "automd",
|
|
190
|
-
async config() {
|
|
191
|
-
const config = await loadConfig(joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
|
|
192
|
-
if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = toArray(config.prefix ?? []);
|
|
193
|
-
if (!config.prefix.includes("automd")) config.prefix.push("automd");
|
|
194
|
-
if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
|
|
195
|
-
return { automd: defu(config ?? {}, {
|
|
196
|
-
configFile: options.configFile,
|
|
197
|
-
allowIssues: true,
|
|
198
|
-
dir: this.config.projectRoot,
|
|
199
|
-
watch: false,
|
|
200
|
-
input: "README.md",
|
|
201
|
-
toc: {
|
|
202
|
-
maxDepth: 6,
|
|
203
|
-
bullets: "-"
|
|
204
|
-
}
|
|
205
|
-
}) };
|
|
206
|
-
},
|
|
207
|
-
async configResolved() {
|
|
208
|
-
if (this.config.framework && !toArray(this.config.automd.prefix).includes(this.config.framework)) this.config.automd.prefix = toArray(this.config.automd.prefix).concat(this.config.framework);
|
|
209
|
-
if (this.config.automd.configFile) {
|
|
210
|
-
const { config } = await loadConfig$1({
|
|
211
|
-
cwd: this.config.automd.dir,
|
|
212
|
-
configFile: this.config.automd.configFile,
|
|
213
|
-
defaults: {
|
|
214
|
-
ignore: [
|
|
215
|
-
"**/node_modules",
|
|
216
|
-
"**/dist",
|
|
217
|
-
"**/.*"
|
|
218
|
-
],
|
|
219
|
-
dir: this.config.automd.dir
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
this.config.automd = resolveConfig(defu(this.config.automd, {
|
|
223
|
-
...config,
|
|
224
|
-
prefix: toArray(config.prefix ?? [])
|
|
225
|
-
}));
|
|
226
|
-
}
|
|
227
|
-
this.config.automd.input = (await Promise.all(toArray(this.config.automd.input).map(async (input) => {
|
|
228
|
-
if (input.includes("*")) return listFiles(isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot), { ignore: this.config.automd.ignore });
|
|
229
|
-
return isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot);
|
|
230
|
-
}))).flat();
|
|
231
|
-
if (this.config.automd.output && !isAbsolutePath(this.config.automd.output)) this.config.automd.output = appendPath(this.config.automd.output, this.config.projectRoot);
|
|
232
|
-
this.config.automd.generators ??= {};
|
|
233
|
-
if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
|
|
234
|
-
name: "toc",
|
|
235
|
-
generate: (ctx) => {
|
|
236
|
-
const opts = this.config.automd.toc ?? {};
|
|
237
|
-
return { contents: toc(ctx.block.md, {
|
|
238
|
-
...opts,
|
|
239
|
-
maxdepth: opts.maxDepth,
|
|
240
|
-
first1: opts.firstH1
|
|
241
|
-
}).content };
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
},
|
|
245
|
-
async docs() {
|
|
246
|
-
await Promise.all(toArray(this.config.automd.input).map(async (input) => {
|
|
247
|
-
const contents = await this.fs.read(input);
|
|
248
|
-
if (contents) {
|
|
249
|
-
const result = await transform(contents, this.config.automd);
|
|
250
|
-
if (result.hasIssues && this.config.automd.allowIssues === false) throw new Error(`AutoMD found issues in file "${input}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);
|
|
251
|
-
if (result.hasChanged) await this.fs.write(appendPath(this.config.automd.output ? isDirectory(this.config.automd.output) ? replacePath(input, this.config.automd.output) : this.config.automd.output : input, this.config.projectRoot), result.contents);
|
|
252
|
-
}
|
|
253
|
-
}));
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
var src_default$2 = plugin$2;
|
|
258
|
-
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region ../plugin-babel/src/helpers/filters.ts
|
|
261
|
-
function getPluginName(plugin$4) {
|
|
262
|
-
return isSetString(plugin$4) ? plugin$4 : Array.isArray(plugin$4) && plugin$4.length > 0 ? getPluginName(plugin$4[0]) : plugin$4.$$name || plugin$4.name ? plugin$4.$$name || plugin$4.name : void 0;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
266
|
-
*
|
|
267
|
-
* @param plugins - The list of existing Babel plugins.
|
|
268
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
269
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
270
|
-
*/
|
|
271
|
-
function isDuplicatePlugin(plugins, plugin$4) {
|
|
272
|
-
return !!(getPluginName(plugin$4) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin$4)));
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region ../plugin-babel/src/helpers/options.ts
|
|
277
|
-
function resolvePluginFunction(context, plugin$4) {
|
|
278
|
-
try {
|
|
279
|
-
return Array.isArray(plugin$4) && plugin$4.length > 0 && plugin$4[0] ? isFunction(plugin$4[0]) ? plugin$4[0](context) : plugin$4[0] : isFunction(plugin$4) ? plugin$4(context) : plugin$4;
|
|
280
|
-
} catch {
|
|
281
|
-
return plugin$4[0];
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
286
|
-
*
|
|
287
|
-
* @param context - The context for the transformation.
|
|
288
|
-
* @param code - The code to be transformed.
|
|
289
|
-
* @param id - The ID of the source file.
|
|
290
|
-
* @param plugin - The Babel plugin to resolve.
|
|
291
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
292
|
-
*/
|
|
293
|
-
function resolveBabelPlugin(context, code$1, id, plugin$4) {
|
|
294
|
-
if (Array.isArray(plugin$4) && plugin$4.length > 0 && plugin$4[0]) {
|
|
295
|
-
if (plugin$4.length > 2 && plugin$4[2] && isFunction(plugin$4[2]) && !plugin$4[2](code$1, id)) {
|
|
296
|
-
context.log(LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.bold.cyanBright(getPluginName(plugin$4) || "unnamed")} for ${id}`);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
return plugin$4.length > 2 ? [
|
|
300
|
-
resolvePluginFunction(context, plugin$4),
|
|
301
|
-
plugin$4[1],
|
|
302
|
-
plugin$4[2]
|
|
303
|
-
] : [
|
|
304
|
-
resolvePluginFunction(context, plugin$4),
|
|
305
|
-
plugin$4[1],
|
|
306
|
-
null
|
|
307
|
-
];
|
|
308
|
-
}
|
|
309
|
-
return [
|
|
310
|
-
resolvePluginFunction(context, plugin$4),
|
|
311
|
-
{},
|
|
312
|
-
null
|
|
313
|
-
];
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region ../plugin-babel/src/helpers/ast-utils.ts
|
|
318
|
-
let generate = _generate;
|
|
319
|
-
if ("default" in generate) generate = generate.default;
|
|
320
|
-
|
|
321
|
-
//#endregion
|
|
322
|
-
//#region ../powerlines/src/lib/logger.ts
|
|
323
|
-
const BADGE_COLORS = [
|
|
324
|
-
"#00A0DD",
|
|
325
|
-
"#6FCE4E",
|
|
326
|
-
"#FBBF24",
|
|
327
|
-
"#F43F5E",
|
|
328
|
-
"#3B82F6",
|
|
329
|
-
"#A855F7",
|
|
330
|
-
"#469592",
|
|
331
|
-
"#288EDF",
|
|
332
|
-
"#D8B4FE",
|
|
333
|
-
"#10B981",
|
|
334
|
-
"#EF4444",
|
|
335
|
-
"#F0EC56",
|
|
336
|
-
"#F472B6",
|
|
337
|
-
"#22D3EE",
|
|
338
|
-
"#EAB308",
|
|
339
|
-
"#84CC16",
|
|
340
|
-
"#F87171",
|
|
341
|
-
"#0EA5E9",
|
|
342
|
-
"#D946EF",
|
|
343
|
-
"#FACC15",
|
|
344
|
-
"#34D399",
|
|
345
|
-
"#8B5CF6"
|
|
346
|
-
];
|
|
347
|
-
const extendLog = (logFn, name) => {
|
|
348
|
-
return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region ../plugin-babel/src/helpers/create-plugin.ts
|
|
353
|
-
/**
|
|
354
|
-
* Create a Babel plugin using the provided builder function.
|
|
355
|
-
*
|
|
356
|
-
* @param name - The name of the plugin.
|
|
357
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
358
|
-
* @returns A Babel plugin declaration.
|
|
359
|
-
*/
|
|
360
|
-
function createBabelPlugin(name, builder) {
|
|
361
|
-
const plugin$4 = (context) => {
|
|
362
|
-
return declare((api, options, dirname) => {
|
|
363
|
-
api.cache.using(() => context.meta.checksum);
|
|
364
|
-
api.assertVersion("^7.0.0-0");
|
|
365
|
-
const log = extendLog(context.log, name);
|
|
366
|
-
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
367
|
-
const result = builder({
|
|
368
|
-
log,
|
|
369
|
-
name,
|
|
370
|
-
api,
|
|
371
|
-
options,
|
|
372
|
-
context,
|
|
373
|
-
dirname
|
|
374
|
-
});
|
|
375
|
-
result.name = name;
|
|
376
|
-
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
377
|
-
return result;
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
plugin$4.$$name = name;
|
|
381
|
-
return plugin$4;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region ../plugin-babel/src/helpers/module-helpers.ts
|
|
386
|
-
/**
|
|
387
|
-
* Adds an import to the program if it doesn't already exist.
|
|
388
|
-
*
|
|
389
|
-
* @param path - The current NodePath in the AST.
|
|
390
|
-
* @param specifier - The import specifier.
|
|
391
|
-
*/
|
|
392
|
-
function addImport(path, specifier) {
|
|
393
|
-
addImportsToProgram(path.scope.getProgramParent().path, specifier);
|
|
394
|
-
}
|
|
395
|
-
function isNonNamespacedImport(importDeclPath) {
|
|
396
|
-
return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
|
397
|
-
}
|
|
398
|
-
function getExistingImports(program) {
|
|
399
|
-
const existingImports = /* @__PURE__ */ new Map();
|
|
400
|
-
program.traverse({ ImportDeclaration(path) {
|
|
401
|
-
if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
|
|
402
|
-
} });
|
|
403
|
-
return existingImports;
|
|
404
|
-
}
|
|
405
|
-
function addImportsToProgram(path, specifier) {
|
|
406
|
-
/**
|
|
407
|
-
* If an existing import of this module exists (ie \`import \{ ... \} from
|
|
408
|
-
* '<moduleName>'\`), inject new imported specifiers into the list of
|
|
409
|
-
* destructured variables.
|
|
410
|
-
*/
|
|
411
|
-
if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(t.identifier(specifier.name || specifier.imported), t.identifier(specifier.imported))], t.stringLiteral(specifier.module)));
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region ../plugin-babel/src/index.ts
|
|
416
|
-
/**
|
|
417
|
-
* Babel plugin for Powerlines.
|
|
418
|
-
*
|
|
419
|
-
* @param options - The Babel plugin user configuration options.
|
|
420
|
-
* @returns A Powerlines plugin that integrates Babel transformations.
|
|
421
|
-
*/
|
|
422
|
-
const plugin$1 = (options = {}) => {
|
|
423
|
-
return {
|
|
424
|
-
name: "babel",
|
|
425
|
-
config() {
|
|
426
|
-
if (!isSetObject(options)) return;
|
|
427
|
-
return { transform: { babel: options } };
|
|
428
|
-
},
|
|
429
|
-
configResolved: {
|
|
430
|
-
order: "pre",
|
|
431
|
-
handler() {
|
|
432
|
-
this.devDependencies["@babel/core"] = "^7.28.4";
|
|
433
|
-
this.config.transform.babel = defu(this.config.transform.babel ?? {}, {
|
|
434
|
-
plugins: [],
|
|
435
|
-
presets: []
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
|
-
async transform(code$1, id) {
|
|
440
|
-
if (isParentPath(id, this.powerlinesPath) || code$1.includes("/* @storm-ignore */") || code$1.includes("/* @storm-disable */")) {
|
|
441
|
-
this.log(LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
|
|
442
|
-
return {
|
|
443
|
-
code: code$1,
|
|
444
|
-
id
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
this.log(LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
|
|
448
|
-
const plugins = this.config.transform.babel.plugins.map((plugin$4) => resolveBabelPlugin(this, code$1, id, plugin$4)).filter((plugin$4, _, arr) => plugin$4 && !isDuplicatePlugin(arr, plugin$4));
|
|
449
|
-
const presets = this.config.transform.babel.presets.map((preset) => resolveBabelPlugin(this, code$1, id, preset)).filter((preset, _, arr) => preset && !isDuplicatePlugin(arr, preset));
|
|
450
|
-
if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
|
|
451
|
-
code: code$1,
|
|
452
|
-
id
|
|
453
|
-
};
|
|
454
|
-
if ([
|
|
455
|
-
"ts",
|
|
456
|
-
"cts",
|
|
457
|
-
"mts",
|
|
458
|
-
"tsx"
|
|
459
|
-
].includes(findFileExtensionSafe(id)) && !isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: findFileExtension(id) === ".tsx" }]);
|
|
460
|
-
const result = await transformAsync(code$1, {
|
|
461
|
-
highlightCode: true,
|
|
462
|
-
code: true,
|
|
463
|
-
ast: false,
|
|
464
|
-
cloneInputAst: false,
|
|
465
|
-
comments: true,
|
|
466
|
-
sourceType: "module",
|
|
467
|
-
configFile: false,
|
|
468
|
-
babelrc: false,
|
|
469
|
-
envName: this.config.mode,
|
|
470
|
-
caller: { name: this.config.framework },
|
|
471
|
-
...this.config.transform.babel ?? {},
|
|
472
|
-
filename: id,
|
|
473
|
-
plugins: plugins.map((plugin$4) => {
|
|
474
|
-
return Array.isArray(plugin$4) && plugin$4.length >= 2 ? [plugin$4[0], defu(plugin$4.length > 1 && plugin$4[1] ? plugin$4[1] : {}, { options })] : plugin$4;
|
|
475
|
-
}).filter(Boolean),
|
|
476
|
-
presets: presets.map((preset) => {
|
|
477
|
-
return Array.isArray(preset) && preset.length >= 2 ? [preset[0], defu(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
|
|
478
|
-
}).filter(Boolean)
|
|
479
|
-
});
|
|
480
|
-
if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
|
|
481
|
-
return {
|
|
482
|
-
code: result.code,
|
|
483
|
-
id
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
};
|
|
488
|
-
var src_default$3 = plugin$1;
|
|
489
|
-
|
|
490
|
-
//#endregion
|
|
491
|
-
//#region src/babel/plugin.ts
|
|
492
|
-
const envBabelPlugin = createBabelPlugin("env", ({ log, context }) => {
|
|
493
|
-
function extractEnv(node, pass, isInjectable = false) {
|
|
494
|
-
const envTypesAliasProperties = context.env.types.env?.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
495
|
-
if (node.name) {
|
|
496
|
-
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}_`, "")))));
|
|
497
|
-
let name = node.name;
|
|
498
|
-
if (prefix) name = node.name.replace(`${prefix}_`, "");
|
|
499
|
-
log(LogLevelLabel.TRACE, `Environment variable ${name} found in ${pass.filename || "unknown file"}.`);
|
|
500
|
-
if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some((prop) => prop.getAlias().includes(name))) {
|
|
501
|
-
const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find((prop) => prop.getAlias().includes(name));
|
|
502
|
-
if (!envProperty || envProperty.isIgnored()) return;
|
|
503
|
-
if (!context.env.used.env.hasProperty(name)) context.env.used.env.addProperty(envProperty.property);
|
|
504
|
-
if (context.config.env.inject && isInjectable) {
|
|
505
|
-
let value = context.env.parsed?.[name];
|
|
506
|
-
if (value === void 0) {
|
|
507
|
-
const prefix$1 = context.config.env.prefix.find((pre) => {
|
|
508
|
-
return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
|
|
509
|
-
});
|
|
510
|
-
if (prefix$1) value = context.env.parsed[`${prefix$1.replace(/_$/g, "")}_${name}`];
|
|
511
|
-
}
|
|
512
|
-
value ??= envProperty.getDefaultValue();
|
|
513
|
-
if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
|
|
514
|
-
return stringifyDefaultValue(envProperty, value);
|
|
515
|
-
}
|
|
516
|
-
} 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"}.
|
|
517
|
-
|
|
518
|
-
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`);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return {
|
|
522
|
-
visitor: { MemberExpression(path, pass) {
|
|
523
|
-
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "$storm" }) && path.get("property")?.isIdentifier()) {
|
|
524
|
-
const identifier = path.get("property")?.node;
|
|
525
|
-
extractEnv(identifier, pass, false);
|
|
526
|
-
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
527
|
-
addImport(path, {
|
|
528
|
-
module: "storm:env",
|
|
529
|
-
name: "env",
|
|
530
|
-
imported: "env"
|
|
531
|
-
});
|
|
532
|
-
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isCallExpression({ callee: {
|
|
533
|
-
name: "useStorm",
|
|
534
|
-
type: "Identifier"
|
|
535
|
-
} }) && path.get("property")?.isIdentifier()) {
|
|
536
|
-
const identifier = path.get("property")?.node;
|
|
537
|
-
extractEnv(identifier, pass, false);
|
|
538
|
-
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
539
|
-
addImport(path, {
|
|
540
|
-
module: "storm:env",
|
|
541
|
-
name: "env",
|
|
542
|
-
imported: "env"
|
|
543
|
-
});
|
|
544
|
-
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
545
|
-
const identifier = path.get("property")?.node;
|
|
546
|
-
if (!identifier.name) return;
|
|
547
|
-
extractEnv(identifier, pass, false);
|
|
548
|
-
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
549
|
-
addImport(path, {
|
|
550
|
-
module: "storm:env",
|
|
551
|
-
name: "env",
|
|
552
|
-
imported: "env"
|
|
553
|
-
});
|
|
554
|
-
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
555
|
-
const identifier = path.get("property")?.node;
|
|
556
|
-
if (!identifier.name) return;
|
|
557
|
-
extractEnv(identifier, pass, false);
|
|
558
|
-
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
559
|
-
addImport(path, {
|
|
560
|
-
module: "storm:env",
|
|
561
|
-
name: "env",
|
|
562
|
-
imported: "env"
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
} },
|
|
566
|
-
post() {
|
|
567
|
-
log(LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
|
|
568
|
-
let persistedEnv = ReflectionClass.from({
|
|
569
|
-
kind: ReflectionKind.objectLiteral,
|
|
570
|
-
description: `An object containing the environment variables used by the application.`,
|
|
571
|
-
types: []
|
|
572
|
-
});
|
|
573
|
-
const reflectionPath = getEnvReflectionsPath(context, "env");
|
|
574
|
-
if (reflectionPath && existsSync$1(reflectionPath)) {
|
|
575
|
-
log(LogLevelLabel.TRACE, `Environment reflection file found at ${reflectionPath}, reading existing reflection.`);
|
|
576
|
-
persistedEnv = resolveClassType(deserializeType(convertFromCapnp(new capnp.Message(readFileBufferSync(reflectionPath), false).getRoot(SerializedTypes).types)));
|
|
577
|
-
}
|
|
578
|
-
log(LogLevelLabel.TRACE, `Adding new variables to env reflection at ${reflectionPath}.`);
|
|
579
|
-
persistedEnv.getProperties().filter((property) => property.getNameAsString() && !context.env.used.env.hasProperty(property.getNameAsString())).forEach((property) => {
|
|
580
|
-
context.env.used.env.addProperty({
|
|
581
|
-
...property,
|
|
582
|
-
name: property.getNameAsString(),
|
|
583
|
-
description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
|
|
584
|
-
default: property.getDefaultValue(),
|
|
585
|
-
optional: property.isOptional() ? true : void 0,
|
|
586
|
-
readonly: property.isReadonly() ? true : void 0,
|
|
587
|
-
visibility: property.getVisibility(),
|
|
588
|
-
type: property.getType(),
|
|
589
|
-
tags: property.getTags()
|
|
590
|
-
});
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
//#endregion
|
|
597
|
-
//#region src/helpers/automd-generator.ts
|
|
598
|
-
/**
|
|
599
|
-
* AutoMD generator to generate environment variable documentation
|
|
600
|
-
*
|
|
601
|
-
* @param context - The generator context.
|
|
602
|
-
* @returns The generated documentation content.
|
|
603
|
-
*/
|
|
604
|
-
const env = (context) => defineGenerator({
|
|
605
|
-
name: "env",
|
|
606
|
-
async generate() {
|
|
607
|
-
const envDocFile = joinPaths(context.config.projectRoot, "docs", "generated", "env.md");
|
|
608
|
-
if (!context.fs.existsSync(envDocFile)) return { contents: "" };
|
|
609
|
-
return { contents: await context.fs.read(envDocFile) || "" };
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
//#endregion
|
|
614
|
-
//#region src/helpers/template-helpers.ts
|
|
615
|
-
/**
|
|
616
|
-
* Creates the reflection data used when generating runtime template files.
|
|
617
|
-
*
|
|
618
|
-
* @param context - The context for the configuration plugin.
|
|
619
|
-
* @param name - The name of the configuration template.
|
|
620
|
-
* @returns The reflection for the specified configuration template.
|
|
621
|
-
*/
|
|
622
|
-
async function createTemplateReflection(context, name) {
|
|
623
|
-
const reflection = await readEnvTypeReflection(context, name);
|
|
624
|
-
reflection.getProperties().forEach((prop) => {
|
|
625
|
-
prop.getAlias().filter(Boolean).forEach((alias) => {
|
|
626
|
-
reflection.addProperty({
|
|
627
|
-
name: alias,
|
|
628
|
-
optional: prop.isOptional() ? true : void 0,
|
|
629
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
630
|
-
description: prop.getDescription(),
|
|
631
|
-
visibility: prop.getVisibility(),
|
|
632
|
-
type: prop.getType(),
|
|
633
|
-
default: prop.getDefaultValue(),
|
|
634
|
-
tags: {
|
|
635
|
-
hidden: prop.isHidden(),
|
|
636
|
-
ignore: prop.isIgnored(),
|
|
637
|
-
internal: prop.isInternal(),
|
|
638
|
-
alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
|
|
639
|
-
title: prop.getTitle() || titleCase(prop.name),
|
|
640
|
-
readonly: prop.isReadonly(),
|
|
641
|
-
permission: prop.getPermission(),
|
|
642
|
-
domain: prop.getDomain()
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
});
|
|
646
|
-
});
|
|
647
|
-
return reflection;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
//#endregion
|
|
651
34
|
//#region src/index.tsx
|
|
652
35
|
/**
|
|
653
36
|
* A Powerlines plugin to inject environment variables into the source code.
|
|
@@ -661,7 +44,7 @@ const plugin = (options = {}) => {
|
|
|
661
44
|
async config() {
|
|
662
45
|
this.log(LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `env` build plugin.");
|
|
663
46
|
const config = {
|
|
664
|
-
env: defu(options, {
|
|
47
|
+
env: defu$1(options, {
|
|
665
48
|
types: {},
|
|
666
49
|
prefix: []
|
|
667
50
|
}),
|
|
@@ -692,7 +75,7 @@ const plugin = (options = {}) => {
|
|
|
692
75
|
async configResolved() {
|
|
693
76
|
this.log(LogLevelLabel.TRACE, `Environment plugin configuration has been resolved for the Powerlines project.`);
|
|
694
77
|
this.config.env.inject ??= this.config.projectType === "application";
|
|
695
|
-
this.env = defu({ parsed: await loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
78
|
+
this.env = defu$1({ parsed: await loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
696
79
|
types: { env: {} },
|
|
697
80
|
used: {
|
|
698
81
|
env: {},
|
|
@@ -708,10 +91,10 @@ const plugin = (options = {}) => {
|
|
|
708
91
|
if (existsSync(getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await readEnvTypeReflection(this, "secrets");
|
|
709
92
|
if (existsSync(getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await readSecretsReflection(this);
|
|
710
93
|
} else {
|
|
711
|
-
this.env.types.env = await reflectEnv(this, this.config.env.types?.file ? isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : joinPaths
|
|
94
|
+
this.env.types.env = await reflectEnv(this, this.config.env.types?.file ? isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : joinPaths(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
|
|
712
95
|
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
713
96
|
await writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
714
|
-
this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ? isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : joinPaths
|
|
97
|
+
this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ? isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : joinPaths(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
|
|
715
98
|
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
716
99
|
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
717
100
|
this.log(LogLevelLabel.TRACE, `Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
@@ -752,10 +135,10 @@ const plugin = (options = {}) => {
|
|
|
752
135
|
},
|
|
753
136
|
async docs() {
|
|
754
137
|
this.log(LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
|
|
755
|
-
const outputPath = joinPaths
|
|
138
|
+
const outputPath = joinPaths(this.config.projectRoot, "docs", "generated");
|
|
756
139
|
if (!existsSync(outputPath)) await createDirectory(outputPath);
|
|
757
140
|
const reflection = await readEnvTypeReflection(this, "env");
|
|
758
|
-
const envDocFile = joinPaths
|
|
141
|
+
const envDocFile = joinPaths(outputPath, "env.md");
|
|
759
142
|
this.log(LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
|
|
760
143
|
await this.fs.write(envDocFile, `<!-- Generated by ${titleCase(this.config.framework) || "Powerlines"} -->
|
|
761
144
|
|
|
@@ -777,7 +160,7 @@ ${reflection.getProperties().filter((property) => property.getNameAsString() !==
|
|
|
777
160
|
{
|
|
778
161
|
name: "env:automd-generator",
|
|
779
162
|
config() {
|
|
780
|
-
return { automd: defu(options.automd ?? {}, { generators: { "env": env(this) } }) };
|
|
163
|
+
return { automd: defu$1(options.automd ?? {}, { generators: { "env": env(this) } }) };
|
|
781
164
|
}
|
|
782
165
|
},
|
|
783
166
|
{
|
|
@@ -792,4 +175,4 @@ ${reflection.getProperties().filter((property) => property.getNameAsString() !==
|
|
|
792
175
|
var src_default = plugin;
|
|
793
176
|
|
|
794
177
|
//#endregion
|
|
795
|
-
export { BaseEnv, BaseSecrets, EnvBuiltin, EnvDocs, EnvTypeDefinition, createEnvReflection, createReflectionResource, createSecretsReflection, createTemplateReflection, src_default as default, envBabelPlugin, formatEnvField, getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, loadEnv, loadEnvFromContext, mergeEnvReflections, mergeSecretsReflections, plugin, readEnvReflection, readEnvTypeReflection, readSecretsReflection, reflectEnv, reflectSecrets, removeEnvPrefix, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
|
|
178
|
+
export { BaseEnv, BaseSecrets, EnvBuiltin, EnvDocs, EnvTypeDefinition, __ΩCreateEnvReflectionOptions, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface, createEnvReflection, createReflectionResource, createSecretsReflection, createTemplateReflection, src_default as default, envBabelPlugin, formatEnvField, getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, loadEnv, loadEnvFromContext, mergeEnvReflections, mergeSecretsReflections, plugin, readEnvReflection, readEnvTypeReflection, readSecretsReflection, reflectEnv, reflectSecrets, removeEnvPrefix, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
|