@powerlines/plugin-env 0.14.21 → 0.14.23
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 +37 -1
- package/dist/_virtual/rolldown_runtime.mjs +29 -1
- package/dist/babel/index.cjs +1 -1
- package/dist/babel/index.mjs +3 -1
- package/dist/babel/plugin.cjs +120 -4
- package/dist/babel/plugin.d.cts +2 -3
- package/dist/babel/plugin.d.mts +3 -2
- package/dist/babel/plugin.mjs +118 -4
- package/dist/components/docs.cjs +71 -1
- package/dist/components/docs.mjs +70 -1
- package/dist/components/env.cjs +432 -11
- package/dist/components/env.mjs +430 -9
- package/dist/components/index.cjs +6 -1
- package/dist/components/index.mjs +4 -1
- package/dist/deepkit/schemas/reflection.cjs +3940 -1
- package/dist/deepkit/schemas/reflection.mjs +3938 -1
- package/dist/deepkit/schemas/reflection2.cjs +4112 -1
- package/dist/deepkit/schemas/reflection2.mjs +4110 -1
- package/dist/deepkit/src/capnp.cjs +913 -1
- package/dist/deepkit/src/capnp.mjs +911 -1
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -4
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -4
- package/dist/deepkit/src/reflect-type.cjs +22 -1
- package/dist/deepkit/src/reflect-type.mjs +20 -1
- package/dist/deepkit/src/resolve-reflections.cjs +16 -1
- package/dist/deepkit/src/resolve-reflections.mjs +15 -1
- package/dist/deepkit/src/transformer.cjs +52 -1
- package/dist/deepkit/src/transformer.mjs +49 -1
- package/dist/deepkit/src/transpile.cjs +29 -1
- package/dist/deepkit/src/transpile.mjs +27 -1
- package/dist/deepkit/src/utilities.cjs +66 -1
- package/dist/deepkit/src/utilities.mjs +65 -1
- package/dist/deepkit/src/vendor/type-compiler/index.cjs +38 -1
- package/dist/deepkit/src/vendor/type-compiler/index.mjs +19 -1
- package/dist/deepkit/src/vendor/type.cjs +20 -1
- package/dist/deepkit/src/vendor/type.mjs +11 -1
- package/dist/helpers/automd-generator.cjs +22 -1
- package/dist/helpers/automd-generator.mjs +21 -1
- package/dist/helpers/create-reflection-resource.cjs +55 -1
- package/dist/helpers/create-reflection-resource.mjs +54 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +8 -1
- package/dist/helpers/load.cjs +83 -1
- package/dist/helpers/load.d.cts +2 -2
- package/dist/helpers/load.d.mts +3 -2
- package/dist/helpers/load.mjs +80 -1
- package/dist/helpers/persistence.cjs +214 -1
- package/dist/helpers/persistence.d.cts +1 -1
- package/dist/helpers/persistence.d.mts +1 -1
- package/dist/helpers/persistence.mjs +202 -1
- package/dist/helpers/reflect.cjs +111 -1
- package/dist/helpers/reflect.mjs +103 -1
- package/dist/helpers/source-file-env.cjs +28 -1
- package/dist/helpers/source-file-env.mjs +26 -1
- package/dist/helpers/template-helpers.cjs +42 -1
- package/dist/helpers/template-helpers.mjs +41 -1
- package/dist/index.cjs +203 -5
- package/dist/index.d.cts +1 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +170 -5
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -1
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -1
- package/dist/plugin-alloy/src/core/contexts/context.cjs +11 -1
- package/dist/plugin-alloy/src/core/contexts/context.mjs +10 -1
- package/dist/plugin-alloy/src/index.cjs +93 -1
- package/dist/plugin-alloy/src/index.mjs +91 -1
- package/dist/plugin-alloy/src/types/plugin.d.cts +2 -2
- package/dist/plugin-alloy/src/types/plugin.d.mts +2 -2
- package/dist/plugin-automd/src/index.cjs +101 -1
- package/dist/plugin-automd/src/index.mjs +98 -1
- package/dist/plugin-automd/src/types/plugin.d.mts +2 -2
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -1
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -1
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -1
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -1
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -1
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -1
- package/dist/plugin-babel/src/helpers/index.cjs +5 -1
- package/dist/plugin-babel/src/helpers/index.mjs +7 -1
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -1
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -1
- package/dist/plugin-babel/src/helpers/options.cjs +50 -1
- package/dist/plugin-babel/src/helpers/options.mjs +47 -1
- package/dist/plugin-babel/src/index.cjs +91 -1
- package/dist/plugin-babel/src/index.mjs +89 -1
- package/dist/plugin-babel/src/types/plugin.d.cts +2 -2
- package/dist/plugin-babel/src/types/plugin.d.mts +2 -2
- 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.d.mts +5 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -14
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -14
- package/dist/powerlines/src/lib/entry.cjs +12 -1
- package/dist/powerlines/src/lib/entry.mjs +14 -1
- package/dist/powerlines/src/lib/logger.cjs +41 -1
- package/dist/powerlines/src/lib/logger.mjs +39 -1
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -1
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -1
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -1
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -1
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -1
- package/dist/powerlines/src/types/api.d.mts +5 -0
- package/dist/powerlines/src/types/babel.d.cts +3 -2
- package/dist/powerlines/src/types/babel.d.mts +3 -2
- package/dist/powerlines/src/types/commands.d.cts +1 -1
- package/dist/powerlines/src/types/commands.d.mts +2 -2
- package/dist/powerlines/src/types/config.d.cts +5 -5
- package/dist/powerlines/src/types/config.d.mts +6 -6
- package/dist/powerlines/src/types/context.d.cts +28 -4
- package/dist/powerlines/src/types/context.d.mts +30 -6
- package/dist/powerlines/src/types/fs.d.cts +1 -1
- package/dist/powerlines/src/types/fs.d.mts +1 -1
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +3 -3
- package/dist/powerlines/src/types/plugin.d.mts +4 -4
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +2 -2
- package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
- package/dist/powerlines/src/types/unplugin.d.mts +7 -0
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/runtime.mjs +1 -1
- package/package.json +16 -16
- package/dist/babel/index.d.cts +0 -1
- package/dist/helpers/index.d.cts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,208 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_type = require('./deepkit/src/vendor/type.cjs');
|
|
4
|
+
const require_index = require('./plugin-alloy/src/index.cjs');
|
|
5
|
+
const require_index$1 = require('./plugin-automd/src/index.cjs');
|
|
6
|
+
const require_index$2 = require('./plugin-babel/src/index.cjs');
|
|
7
|
+
const require_reflect = require('./helpers/reflect.cjs');
|
|
8
|
+
const require_persistence = require('./helpers/persistence.cjs');
|
|
9
|
+
const require_plugin = require('./babel/plugin.cjs');
|
|
10
|
+
const require_source_file_env = require('./helpers/source-file-env.cjs');
|
|
11
|
+
const require_load = require('./helpers/load.cjs');
|
|
12
|
+
const require_create_reflection_resource = require('./helpers/create-reflection-resource.cjs');
|
|
13
|
+
const require_components_env = require('./components/env.cjs');
|
|
14
|
+
const require_automd_generator = require('./helpers/automd-generator.cjs');
|
|
15
|
+
require('./babel/index.cjs');
|
|
16
|
+
const require_components_docs = require('./components/docs.cjs');
|
|
17
|
+
require('./components/index.cjs');
|
|
18
|
+
const require_template_helpers = require('./helpers/template-helpers.cjs');
|
|
19
|
+
require('./helpers/index.cjs');
|
|
20
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
21
|
+
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
22
|
+
let defu = require("defu");
|
|
23
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
24
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
25
|
+
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
26
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
27
|
+
let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
|
|
28
|
+
let __stryke_env_types = require("@stryke/env/types");
|
|
29
|
+
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
30
|
+
let __stryke_fs_helpers = require("@stryke/fs/helpers");
|
|
31
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
32
|
+
let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
33
|
+
|
|
34
|
+
//#region src/index.tsx
|
|
35
|
+
/**
|
|
36
|
+
* A Powerlines plugin to inject environment variables into the source code.
|
|
37
|
+
*/
|
|
38
|
+
const plugin = (options = {}) => {
|
|
39
|
+
return [
|
|
40
|
+
require_index.default(options.alloy),
|
|
41
|
+
require_index$2.default(options.babel),
|
|
42
|
+
{
|
|
43
|
+
name: "env",
|
|
44
|
+
async config() {
|
|
45
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `env` build plugin.");
|
|
46
|
+
const config = {
|
|
47
|
+
env: (0, defu.default)(options, {
|
|
48
|
+
types: {},
|
|
49
|
+
prefix: []
|
|
50
|
+
}),
|
|
51
|
+
transform: { babel: { plugins: [require_plugin.envBabelPlugin] } }
|
|
52
|
+
};
|
|
53
|
+
if (config.env.types) config.env.types = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.types);
|
|
54
|
+
else {
|
|
55
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.WARN, "The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
56
|
+
const envDefaultTypeDefinition = await require_persistence.getEnvDefaultTypeDefinition(this);
|
|
57
|
+
config.env.types = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
|
|
58
|
+
}
|
|
59
|
+
if (config.env.secrets) config.env.secrets = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.secrets);
|
|
60
|
+
else {
|
|
61
|
+
const secretsDefaultTypeDefinition = await require_persistence.getSecretsDefaultTypeDefinition(this);
|
|
62
|
+
config.env.secrets = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
|
|
63
|
+
}
|
|
64
|
+
config.env.prefix = (0, __stryke_convert_to_array.toArray)(config.env.prefix ?? []).reduce((ret, prefix) => {
|
|
65
|
+
const formattedPrefix = (0, __stryke_string_format_constant_case.constantCase)(prefix);
|
|
66
|
+
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
67
|
+
return ret;
|
|
68
|
+
}, [...__stryke_env_types.ENV_PREFIXES, "POWERLINES_"]);
|
|
69
|
+
config.env.prefix = config.env.prefix.reduce((ret, prefix) => {
|
|
70
|
+
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
71
|
+
return ret;
|
|
72
|
+
}, []);
|
|
73
|
+
return config;
|
|
74
|
+
},
|
|
75
|
+
async configResolved() {
|
|
76
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Environment plugin configuration has been resolved for the Powerlines project.`);
|
|
77
|
+
this.config.env.inject ??= this.config.projectType === "application";
|
|
78
|
+
this.env = (0, defu.default)({ parsed: await require_load.loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
79
|
+
types: { env: {} },
|
|
80
|
+
used: {
|
|
81
|
+
env: {},
|
|
82
|
+
secrets: {}
|
|
83
|
+
},
|
|
84
|
+
parsed: {},
|
|
85
|
+
injected: {}
|
|
86
|
+
});
|
|
87
|
+
if (this.config.command !== "prepare" && this.persistedMeta?.checksum === this.meta.checksum && (0, __stryke_fs_exists.existsSync)(require_persistence.getEnvTypeReflectionsPath(this, "env"))) {
|
|
88
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping reflection initialization as the meta checksum has not changed.`);
|
|
89
|
+
this.env.types.env = await require_persistence.readEnvTypeReflection(this, "env");
|
|
90
|
+
if ((0, __stryke_fs_exists.existsSync)(require_persistence.getEnvReflectionsPath(this, "env"))) this.env.used.env = await require_persistence.readEnvReflection(this);
|
|
91
|
+
if ((0, __stryke_fs_exists.existsSync)(require_persistence.getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await require_persistence.readEnvTypeReflection(this, "secrets");
|
|
92
|
+
if ((0, __stryke_fs_exists.existsSync)(require_persistence.getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await require_persistence.readSecretsReflection(this);
|
|
93
|
+
} else {
|
|
94
|
+
this.env.types.env = await require_reflect.reflectEnv(this, this.config.env.types?.file ? (0, __stryke_path_is_parent_path.isParentPath)(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : (0, __stryke_path_join.joinPaths)(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
|
|
95
|
+
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
96
|
+
await require_persistence.writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
97
|
+
this.env.types.secrets = await require_reflect.reflectSecrets(this, this.config.env.secrets?.file ? (0, __stryke_path_is_parent_path.isParentPath)(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : (0, __stryke_path_join.joinPaths)(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
|
|
98
|
+
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
99
|
+
await require_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
100
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
101
|
+
const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
102
|
+
Object.entries(await require_load.loadEnv(this, this.config.env)).forEach(([key, value]) => {
|
|
103
|
+
const unprefixedKey = this.config.env.prefix.reduce((ret, prefix) => {
|
|
104
|
+
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
105
|
+
return ret;
|
|
106
|
+
}, key);
|
|
107
|
+
const aliasKey = envWithAlias.find((prop) => prop?.getAlias().reverse().includes(unprefixedKey));
|
|
108
|
+
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
109
|
+
});
|
|
110
|
+
this.env.used.env = new require_type.type_exports.ReflectionClass({
|
|
111
|
+
kind: require_type.type_exports.ReflectionKind.objectLiteral,
|
|
112
|
+
typeName: "Env",
|
|
113
|
+
description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
114
|
+
types: []
|
|
115
|
+
}, this.env.types.env);
|
|
116
|
+
await require_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
117
|
+
if (this.env.types.secrets) {
|
|
118
|
+
await require_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
119
|
+
this.env.used.secrets = new require_type.type_exports.ReflectionClass({
|
|
120
|
+
kind: require_type.type_exports.ReflectionKind.objectLiteral,
|
|
121
|
+
typeName: "Secrets",
|
|
122
|
+
description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
123
|
+
types: []
|
|
124
|
+
}, this.env.types.secrets);
|
|
125
|
+
await require_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
async prepare() {
|
|
130
|
+
const _self$ = this;
|
|
131
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
132
|
+
return this.render((0, __alloy_js_core_jsx_runtime.createComponent)(require_components_env.EnvBuiltin, { get defaultConfig() {
|
|
133
|
+
return _self$.config.env.defaultConfig;
|
|
134
|
+
} }));
|
|
135
|
+
},
|
|
136
|
+
async docs() {
|
|
137
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
|
|
138
|
+
const outputPath = (0, __stryke_path_join.joinPaths)(this.config.projectRoot, "docs", "generated");
|
|
139
|
+
if (!(0, __stryke_fs_exists.existsSync)(outputPath)) await (0, __stryke_fs_helpers.createDirectory)(outputPath);
|
|
140
|
+
const reflection = await require_persistence.readEnvTypeReflection(this, "env");
|
|
141
|
+
const envDocFile = (0, __stryke_path_join.joinPaths)(outputPath, "env.md");
|
|
142
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
|
|
143
|
+
await this.fs.write(envDocFile, `<!-- Generated by ${(0, __stryke_string_format_title_case.titleCase)(this.config.framework) || "Powerlines"} -->
|
|
2
144
|
|
|
3
145
|
Below is a list of environment variables used by the [${this.packageJson.name}](https://www.npmjs.com/package/${this.packageJson.name}) package. These values can be updated in the \`.env\` file in the root of the project. The variables in the list below 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.
|
|
4
146
|
|
|
5
147
|
| Name | Description | Type | Default Value | Required |
|
|
6
148
|
| ---- | ----------- | ---- | ------------- | :------: |
|
|
7
|
-
${
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`)
|
|
149
|
+
${reflection.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
150
|
+
return `| ${reflectionProperty.getNameAsString().trim()} | ${(reflectionProperty.getDescription()?.replaceAll("\r", "")?.replaceAll("\n", "") ?? "").trim()} | ${(0, require_type.type_exports.stringifyType)(reflectionProperty.getType()).trim().replaceAll(" | ", ", or ")} | ${reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : ""} | ${reflectionProperty.isValueRequired() ? "" : "✔"} |`;
|
|
151
|
+
}).join("\n")}
|
|
152
|
+
`);
|
|
153
|
+
},
|
|
154
|
+
async buildEnd() {
|
|
155
|
+
const reflectionPath = require_persistence.getEnvReflectionsPath(this, "env");
|
|
156
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing env reflection types to ${reflectionPath}.`);
|
|
157
|
+
await require_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "env:automd-generator",
|
|
162
|
+
config() {
|
|
163
|
+
return { automd: (0, defu.default)(options.automd ?? {}, { generators: { "env": require_automd_generator.env(this) } }) };
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "env:vite",
|
|
168
|
+
vite: { configResolved() {
|
|
169
|
+
return { envPrefix: this.config?.env?.prefix };
|
|
170
|
+
} }
|
|
171
|
+
},
|
|
172
|
+
require_index$1.default(options.automd)
|
|
173
|
+
];
|
|
174
|
+
};
|
|
175
|
+
var src_default = plugin;
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
exports.BaseEnv = require_reflect.BaseEnv;
|
|
179
|
+
exports.BaseSecrets = require_reflect.BaseSecrets;
|
|
180
|
+
exports.EnvBuiltin = require_components_env.EnvBuiltin;
|
|
181
|
+
exports.EnvDocs = require_components_docs.EnvDocs;
|
|
182
|
+
exports.EnvTypeDefinition = require_components_env.EnvTypeDefinition;
|
|
183
|
+
exports.createEnvReflection = require_reflect.createEnvReflection;
|
|
184
|
+
exports.createReflectionResource = require_create_reflection_resource.createReflectionResource;
|
|
185
|
+
exports.createSecretsReflection = require_reflect.createSecretsReflection;
|
|
186
|
+
exports.createTemplateReflection = require_template_helpers.createTemplateReflection;
|
|
187
|
+
exports.default = src_default;
|
|
188
|
+
exports.envBabelPlugin = require_plugin.envBabelPlugin;
|
|
189
|
+
exports.formatEnvField = require_source_file_env.formatEnvField;
|
|
190
|
+
exports.getEnvDefaultTypeDefinition = require_persistence.getEnvDefaultTypeDefinition;
|
|
191
|
+
exports.getEnvReflectionsPath = require_persistence.getEnvReflectionsPath;
|
|
192
|
+
exports.getEnvTypeReflectionsPath = require_persistence.getEnvTypeReflectionsPath;
|
|
193
|
+
exports.getSecretsDefaultTypeDefinition = require_persistence.getSecretsDefaultTypeDefinition;
|
|
194
|
+
exports.loadEnv = require_load.loadEnv;
|
|
195
|
+
exports.loadEnvFromContext = require_load.loadEnvFromContext;
|
|
196
|
+
exports.mergeEnvReflections = require_reflect.mergeEnvReflections;
|
|
197
|
+
exports.mergeSecretsReflections = require_reflect.mergeSecretsReflections;
|
|
198
|
+
exports.plugin = plugin;
|
|
199
|
+
exports.readEnvReflection = require_persistence.readEnvReflection;
|
|
200
|
+
exports.readEnvTypeReflection = require_persistence.readEnvTypeReflection;
|
|
201
|
+
exports.readSecretsReflection = require_persistence.readSecretsReflection;
|
|
202
|
+
exports.reflectEnv = require_reflect.reflectEnv;
|
|
203
|
+
exports.reflectSecrets = require_reflect.reflectSecrets;
|
|
204
|
+
exports.removeEnvPrefix = require_source_file_env.removeEnvPrefix;
|
|
205
|
+
exports.resolveRuntimeTypeFile = require_persistence.resolveRuntimeTypeFile;
|
|
206
|
+
exports.writeEnvReflection = require_persistence.writeEnvReflection;
|
|
207
|
+
exports.writeEnvReflectionSync = require_persistence.writeEnvReflectionSync;
|
|
208
|
+
exports.writeEnvTypeReflection = require_persistence.writeEnvTypeReflection;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { EnvDocs } from "./components/docs.cjs";
|
|
2
2
|
import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.cjs";
|
|
3
|
+
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
3
4
|
import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.cjs";
|
|
4
5
|
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.cjs";
|
|
5
6
|
import { envBabelPlugin } from "./babel/plugin.cjs";
|
|
6
|
-
import "./babel/index.cjs";
|
|
7
7
|
import { createReflectionResource } from "./helpers/create-reflection-resource.cjs";
|
|
8
8
|
import { loadEnv, loadEnvFromContext } from "./helpers/load.cjs";
|
|
9
9
|
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.cjs";
|
|
10
10
|
import { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.cjs";
|
|
11
11
|
import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.cjs";
|
|
12
12
|
import { createTemplateReflection } from "./helpers/template-helpers.cjs";
|
|
13
|
-
import "./helpers/index.cjs";
|
|
14
|
-
import { Plugin } from "powerlines";
|
|
15
13
|
|
|
16
14
|
//#region src/index.d.ts
|
|
17
15
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EnvDocs } from "./components/docs.mjs";
|
|
2
2
|
import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.mjs";
|
|
3
3
|
import "./components/index.mjs";
|
|
4
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
5
|
+
import "./powerlines/src/index.mjs";
|
|
4
6
|
import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
|
|
5
7
|
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
|
|
6
8
|
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
@@ -13,7 +15,6 @@ import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.mjs";
|
|
|
13
15
|
import { createTemplateReflection } from "./helpers/template-helpers.mjs";
|
|
14
16
|
import "./helpers/index.mjs";
|
|
15
17
|
import "./types/index.mjs";
|
|
16
|
-
import { Plugin } from "powerlines";
|
|
17
18
|
|
|
18
19
|
//#region src/index.d.ts
|
|
19
20
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,175 @@
|
|
|
1
|
-
import{type_exports
|
|
1
|
+
import { type_exports } from "./deepkit/src/vendor/type.mjs";
|
|
2
|
+
import src_default$1 from "./plugin-alloy/src/index.mjs";
|
|
3
|
+
import src_default$2 from "./plugin-automd/src/index.mjs";
|
|
4
|
+
import src_default$3 from "./plugin-babel/src/index.mjs";
|
|
5
|
+
import { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
|
|
6
|
+
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.mjs";
|
|
7
|
+
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
8
|
+
import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.mjs";
|
|
9
|
+
import { loadEnv, loadEnvFromContext } from "./helpers/load.mjs";
|
|
10
|
+
import { createReflectionResource } from "./helpers/create-reflection-resource.mjs";
|
|
11
|
+
import { EnvBuiltin, EnvTypeDefinition } from "./components/env.mjs";
|
|
12
|
+
import { env } from "./helpers/automd-generator.mjs";
|
|
13
|
+
import "./babel/index.mjs";
|
|
14
|
+
import { EnvDocs } from "./components/docs.mjs";
|
|
15
|
+
import "./components/index.mjs";
|
|
16
|
+
import { createTemplateReflection } from "./helpers/template-helpers.mjs";
|
|
17
|
+
import "./helpers/index.mjs";
|
|
18
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
19
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
20
|
+
import defu from "defu";
|
|
21
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
22
|
+
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
23
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
24
|
+
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
|
|
25
|
+
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
26
|
+
import { existsSync } from "@stryke/fs/exists";
|
|
27
|
+
import { createDirectory } from "@stryke/fs/helpers";
|
|
28
|
+
import { joinPaths } from "@stryke/path/join";
|
|
29
|
+
import { constantCase } from "@stryke/string-format/constant-case";
|
|
30
|
+
|
|
31
|
+
//#region src/index.tsx
|
|
32
|
+
/**
|
|
33
|
+
* A Powerlines plugin to inject environment variables into the source code.
|
|
34
|
+
*/
|
|
35
|
+
const plugin = (options = {}) => {
|
|
36
|
+
return [
|
|
37
|
+
src_default$1(options.alloy),
|
|
38
|
+
src_default$3(options.babel),
|
|
39
|
+
{
|
|
40
|
+
name: "env",
|
|
41
|
+
async config() {
|
|
42
|
+
this.log(LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `env` build plugin.");
|
|
43
|
+
const config = {
|
|
44
|
+
env: defu(options, {
|
|
45
|
+
types: {},
|
|
46
|
+
prefix: []
|
|
47
|
+
}),
|
|
48
|
+
transform: { babel: { plugins: [envBabelPlugin] } }
|
|
49
|
+
};
|
|
50
|
+
if (config.env.types) config.env.types = parseTypeDefinition(config.env.types);
|
|
51
|
+
else {
|
|
52
|
+
this.log(LogLevelLabel.WARN, "The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
53
|
+
const envDefaultTypeDefinition = await getEnvDefaultTypeDefinition(this);
|
|
54
|
+
config.env.types = parseTypeDefinition(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
|
|
55
|
+
}
|
|
56
|
+
if (config.env.secrets) config.env.secrets = parseTypeDefinition(config.env.secrets);
|
|
57
|
+
else {
|
|
58
|
+
const secretsDefaultTypeDefinition = await getSecretsDefaultTypeDefinition(this);
|
|
59
|
+
config.env.secrets = parseTypeDefinition(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
|
|
60
|
+
}
|
|
61
|
+
config.env.prefix = toArray(config.env.prefix ?? []).reduce((ret, prefix) => {
|
|
62
|
+
const formattedPrefix = constantCase(prefix);
|
|
63
|
+
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
64
|
+
return ret;
|
|
65
|
+
}, [...ENV_PREFIXES, "POWERLINES_"]);
|
|
66
|
+
config.env.prefix = config.env.prefix.reduce((ret, prefix) => {
|
|
67
|
+
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
68
|
+
return ret;
|
|
69
|
+
}, []);
|
|
70
|
+
return config;
|
|
71
|
+
},
|
|
72
|
+
async configResolved() {
|
|
73
|
+
this.log(LogLevelLabel.TRACE, `Environment plugin configuration has been resolved for the Powerlines project.`);
|
|
74
|
+
this.config.env.inject ??= this.config.projectType === "application";
|
|
75
|
+
this.env = defu({ parsed: await loadEnv(this, this.config.env) }, this.env ?? {}, {
|
|
76
|
+
types: { env: {} },
|
|
77
|
+
used: {
|
|
78
|
+
env: {},
|
|
79
|
+
secrets: {}
|
|
80
|
+
},
|
|
81
|
+
parsed: {},
|
|
82
|
+
injected: {}
|
|
83
|
+
});
|
|
84
|
+
if (this.config.command !== "prepare" && this.persistedMeta?.checksum === this.meta.checksum && existsSync(getEnvTypeReflectionsPath(this, "env"))) {
|
|
85
|
+
this.log(LogLevelLabel.TRACE, `Skipping reflection initialization as the meta checksum has not changed.`);
|
|
86
|
+
this.env.types.env = await readEnvTypeReflection(this, "env");
|
|
87
|
+
if (existsSync(getEnvReflectionsPath(this, "env"))) this.env.used.env = await readEnvReflection(this);
|
|
88
|
+
if (existsSync(getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await readEnvTypeReflection(this, "secrets");
|
|
89
|
+
if (existsSync(getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await readSecretsReflection(this);
|
|
90
|
+
} else {
|
|
91
|
+
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);
|
|
92
|
+
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
93
|
+
await writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
94
|
+
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);
|
|
95
|
+
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
96
|
+
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
97
|
+
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`);
|
|
98
|
+
const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0);
|
|
99
|
+
Object.entries(await loadEnv(this, this.config.env)).forEach(([key, value]) => {
|
|
100
|
+
const unprefixedKey = this.config.env.prefix.reduce((ret, prefix) => {
|
|
101
|
+
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
102
|
+
return ret;
|
|
103
|
+
}, key);
|
|
104
|
+
const aliasKey = envWithAlias.find((prop) => prop?.getAlias().reverse().includes(unprefixedKey));
|
|
105
|
+
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
106
|
+
});
|
|
107
|
+
this.env.used.env = new type_exports.ReflectionClass({
|
|
108
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
109
|
+
typeName: "Env",
|
|
110
|
+
description: `An object containing the environment configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
111
|
+
types: []
|
|
112
|
+
}, this.env.types.env);
|
|
113
|
+
await writeEnvReflection(this, this.env.used.env, "env");
|
|
114
|
+
if (this.env.types.secrets) {
|
|
115
|
+
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
116
|
+
this.env.used.secrets = new type_exports.ReflectionClass({
|
|
117
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
118
|
+
typeName: "Secrets",
|
|
119
|
+
description: `An object containing the secret configuration parameters used by the ${this.config.name ? `${this.config.name} application` : "application"}.`,
|
|
120
|
+
types: []
|
|
121
|
+
}, this.env.types.secrets);
|
|
122
|
+
await writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
async prepare() {
|
|
127
|
+
const _self$ = this;
|
|
128
|
+
this.log(LogLevelLabel.TRACE, `Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
129
|
+
return this.render(createComponent(EnvBuiltin, { get defaultConfig() {
|
|
130
|
+
return _self$.config.env.defaultConfig;
|
|
131
|
+
} }));
|
|
132
|
+
},
|
|
133
|
+
async docs() {
|
|
134
|
+
this.log(LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
|
|
135
|
+
const outputPath = joinPaths(this.config.projectRoot, "docs", "generated");
|
|
136
|
+
if (!existsSync(outputPath)) await createDirectory(outputPath);
|
|
137
|
+
const reflection = await readEnvTypeReflection(this, "env");
|
|
138
|
+
const envDocFile = joinPaths(outputPath, "env.md");
|
|
139
|
+
this.log(LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
|
|
140
|
+
await this.fs.write(envDocFile, `<!-- Generated by ${titleCase(this.config.framework) || "Powerlines"} -->
|
|
2
141
|
|
|
3
142
|
Below is a list of environment variables used by the [${this.packageJson.name}](https://www.npmjs.com/package/${this.packageJson.name}) package. These values can be updated in the \`.env\` file in the root of the project. The variables in the list below 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.
|
|
4
143
|
|
|
5
144
|
| Name | Description | Type | Default Value | Required |
|
|
6
145
|
| ---- | ----------- | ---- | ------------- | :------: |
|
|
7
|
-
${
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`)
|
|
146
|
+
${reflection.getProperties().filter((property) => property.getNameAsString() !== "__POWERLINES_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
147
|
+
return `| ${reflectionProperty.getNameAsString().trim()} | ${(reflectionProperty.getDescription()?.replaceAll("\r", "")?.replaceAll("\n", "") ?? "").trim()} | ${(0, type_exports.stringifyType)(reflectionProperty.getType()).trim().replaceAll(" | ", ", or ")} | ${reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : ""} | ${reflectionProperty.isValueRequired() ? "" : "✔"} |`;
|
|
148
|
+
}).join("\n")}
|
|
149
|
+
`);
|
|
150
|
+
},
|
|
151
|
+
async buildEnd() {
|
|
152
|
+
const reflectionPath = getEnvReflectionsPath(this, "env");
|
|
153
|
+
this.log(LogLevelLabel.TRACE, `Writing env reflection types to ${reflectionPath}.`);
|
|
154
|
+
await writeEnvReflection(this, this.env.used.env, "env");
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "env:automd-generator",
|
|
159
|
+
config() {
|
|
160
|
+
return { automd: defu(options.automd ?? {}, { generators: { "env": env(this) } }) };
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "env:vite",
|
|
165
|
+
vite: { configResolved() {
|
|
166
|
+
return { envPrefix: this.config?.env?.prefix };
|
|
167
|
+
} }
|
|
168
|
+
},
|
|
169
|
+
src_default$2(options.automd)
|
|
170
|
+
];
|
|
171
|
+
};
|
|
172
|
+
var src_default = plugin;
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
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 };
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_context = require('../contexts/context.cjs');
|
|
3
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
6
|
+
|
|
7
|
+
//#region ../plugin-alloy/src/core/components/output.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
10
|
+
*/
|
|
11
|
+
function Output(props) {
|
|
12
|
+
const [{ children, context, meta, basePath }, rest] = (0, __alloy_js_core.splitProps)(props, [
|
|
13
|
+
"children",
|
|
14
|
+
"context",
|
|
15
|
+
"meta",
|
|
16
|
+
"basePath"
|
|
17
|
+
]);
|
|
18
|
+
const contextRef = (0, __alloy_js_core.ref)(context);
|
|
19
|
+
const metaRef = (0, __alloy_js_core.ref)(meta ?? {});
|
|
20
|
+
const basePathRef = (0, __alloy_js_core.computed)(() => basePath ? (0, __stryke_path_replace.replacePath)(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
|
|
21
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Output, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
22
|
+
get basePath() {
|
|
23
|
+
return basePathRef.value;
|
|
24
|
+
},
|
|
25
|
+
get children() {
|
|
26
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_context.PowerlinesContext.Provider, {
|
|
27
|
+
value: {
|
|
28
|
+
ref: contextRef,
|
|
29
|
+
meta: metaRef
|
|
30
|
+
},
|
|
31
|
+
get children() {
|
|
32
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
33
|
+
get when() {
|
|
34
|
+
return Boolean(contextRef.value);
|
|
35
|
+
},
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.Output = Output;
|
|
@@ -1 +1,44 @@
|
|
|
1
|
-
import{PowerlinesContext
|
|
1
|
+
import { PowerlinesContext } from "../contexts/context.mjs";
|
|
2
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { Output, Show, computed, ref, splitProps } from "@alloy-js/core";
|
|
4
|
+
import { replacePath } from "@stryke/path/replace";
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-alloy/src/core/components/output.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
9
|
+
*/
|
|
10
|
+
function Output$1(props) {
|
|
11
|
+
const [{ children, context, meta, basePath }, rest] = splitProps(props, [
|
|
12
|
+
"children",
|
|
13
|
+
"context",
|
|
14
|
+
"meta",
|
|
15
|
+
"basePath"
|
|
16
|
+
]);
|
|
17
|
+
const contextRef = ref(context);
|
|
18
|
+
const metaRef = ref(meta ?? {});
|
|
19
|
+
const basePathRef = computed(() => basePath ? replacePath(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
|
|
20
|
+
return createComponent(Output, mergeProps(rest, {
|
|
21
|
+
get basePath() {
|
|
22
|
+
return basePathRef.value;
|
|
23
|
+
},
|
|
24
|
+
get children() {
|
|
25
|
+
return createComponent(PowerlinesContext.Provider, {
|
|
26
|
+
value: {
|
|
27
|
+
ref: contextRef,
|
|
28
|
+
meta: metaRef
|
|
29
|
+
},
|
|
30
|
+
get children() {
|
|
31
|
+
return createComponent(Show, {
|
|
32
|
+
get when() {
|
|
33
|
+
return Boolean(contextRef.value);
|
|
34
|
+
},
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Output$1 as Output };
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
3
|
+
|
|
4
|
+
//#region ../plugin-alloy/src/core/contexts/context.ts
|
|
5
|
+
/**
|
|
6
|
+
* The Powerlines context used in template rendering.
|
|
7
|
+
*/
|
|
8
|
+
const PowerlinesContext = (0, __alloy_js_core.createNamedContext)("powerlines");
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.PowerlinesContext = PowerlinesContext;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import{createNamedContext
|
|
1
|
+
import { createNamedContext } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region ../plugin-alloy/src/core/contexts/context.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Powerlines context used in template rendering.
|
|
6
|
+
*/
|
|
7
|
+
const PowerlinesContext = createNamedContext("powerlines");
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { PowerlinesContext };
|