@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
|
@@ -1 +1,202 @@
|
|
|
1
|
-
import{type_exports
|
|
1
|
+
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
import { convertFromCapnp, convertToCapnp } from "../deepkit/src/capnp.mjs";
|
|
3
|
+
import { SerializedTypes } from "../deepkit/schemas/reflection2.mjs";
|
|
4
|
+
import { getReflectionsPath } from "../deepkit/src/resolve-reflections.mjs";
|
|
5
|
+
import { createEnvReflection } from "./reflect.mjs";
|
|
6
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
7
|
+
import * as capnp from "@stryke/capnp";
|
|
8
|
+
import { readFileBuffer, writeFileBuffer, writeFileBufferSync } from "@stryke/fs/buffer";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { resolvePackage } from "@stryke/fs/resolve";
|
|
11
|
+
import { isEmptyObject } from "@stryke/type-checks/is-empty-object";
|
|
12
|
+
|
|
13
|
+
//#region src/helpers/persistence.ts
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the runtime type definition file for the environment variables.
|
|
16
|
+
*
|
|
17
|
+
* @param context - The plugin context.
|
|
18
|
+
* @returns The runtime type definition file for the environment variables.
|
|
19
|
+
*/
|
|
20
|
+
async function resolveRuntimeTypeFile(context) {
|
|
21
|
+
return resolvePackage("@powerlines/plugin-env/types/runtime", { paths: [context.workspaceConfig.workspaceRoot, joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)] });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the default type definition for the environment variables.
|
|
25
|
+
*
|
|
26
|
+
* @param context - The plugin context.
|
|
27
|
+
* @returns The default type definition for the environment variables.
|
|
28
|
+
*/
|
|
29
|
+
async function getEnvDefaultTypeDefinition(context) {
|
|
30
|
+
return {
|
|
31
|
+
file: await resolveRuntimeTypeFile(context),
|
|
32
|
+
name: "EnvInterface"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Gets the default type definition for the environment secrets.
|
|
36
|
+
*
|
|
37
|
+
* @param context - The plugin context.
|
|
38
|
+
* @returns The default type definition for the environment secrets.
|
|
39
|
+
*/
|
|
40
|
+
async function getSecretsDefaultTypeDefinition(context) {
|
|
41
|
+
return {
|
|
42
|
+
file: await resolveRuntimeTypeFile(context),
|
|
43
|
+
name: "SecretsInterface"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets the path to the environment type reflections.
|
|
48
|
+
*
|
|
49
|
+
* @param context - The plugin context.
|
|
50
|
+
* @param name - The name of the type reflections.
|
|
51
|
+
* @returns The path to the environment type reflections.
|
|
52
|
+
*/
|
|
53
|
+
function getEnvTypeReflectionsPath(context, name = "env") {
|
|
54
|
+
return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reads the environment type reflection from the file system.
|
|
58
|
+
*
|
|
59
|
+
* @param context - The plugin context.
|
|
60
|
+
* @param name - The name of the type reflections.
|
|
61
|
+
* @returns The environment type reflection.
|
|
62
|
+
*/
|
|
63
|
+
async function readEnvTypeReflection(context, name = "env") {
|
|
64
|
+
const filePath = getEnvTypeReflectionsPath(context, name);
|
|
65
|
+
if (!existsSync(filePath)) {
|
|
66
|
+
if (!context.env.types.env || isEmptyObject(context.env.types.env)) {
|
|
67
|
+
const reflection$1 = createEnvReflection(context);
|
|
68
|
+
const message = new capnp.Message();
|
|
69
|
+
reflection$1.messageRoot = message.initRoot(SerializedTypes);
|
|
70
|
+
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
71
|
+
context.env.types.env = reflection$1;
|
|
72
|
+
await writeEnvTypeReflection(context, context.env.types.env, name);
|
|
73
|
+
}
|
|
74
|
+
return context.env.types.env;
|
|
75
|
+
}
|
|
76
|
+
const buffer = await readFileBuffer(filePath);
|
|
77
|
+
const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
|
|
78
|
+
const reflection = (0, type_exports.resolveClassType)((0, type_exports.deserializeType)(convertFromCapnp(messageRoot.types)));
|
|
79
|
+
context.env.types[name] = reflection;
|
|
80
|
+
context.env.types[name].messageRoot = messageRoot;
|
|
81
|
+
context.env.types[name].dataBuffer = buffer;
|
|
82
|
+
return reflection;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Writes the environment type reflection to the file system.
|
|
86
|
+
*
|
|
87
|
+
* @param context - The plugin context.
|
|
88
|
+
* @param reflection - The environment type reflection to write.
|
|
89
|
+
* @param name - The name of the type reflections.
|
|
90
|
+
*/
|
|
91
|
+
async function writeEnvTypeReflection(context, reflection, name = "env") {
|
|
92
|
+
const serialized = reflection.serializeType();
|
|
93
|
+
const message = new capnp.Message();
|
|
94
|
+
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
95
|
+
await writeFileBuffer(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
|
|
96
|
+
}
|
|
97
|
+
function getEnvReflectionsPath(context, name) {
|
|
98
|
+
return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Reads the environment reflection data from the file system.
|
|
102
|
+
*
|
|
103
|
+
* @param context - The plugin context.
|
|
104
|
+
* @returns The environment reflection data.
|
|
105
|
+
*/
|
|
106
|
+
async function readEnvReflection(context) {
|
|
107
|
+
const filePath = getEnvReflectionsPath(context, "env");
|
|
108
|
+
if (!existsSync(filePath)) {
|
|
109
|
+
if (!context.env.types.env) context.env.types.env = await readEnvTypeReflection(context, "env");
|
|
110
|
+
if (!context.env.used.env || isEmptyObject(context.env.used.env)) {
|
|
111
|
+
const reflection$1 = createEnvReflection(context, {
|
|
112
|
+
type: {
|
|
113
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
114
|
+
typeName: "Env",
|
|
115
|
+
description: `An object containing the environment configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
|
|
116
|
+
types: []
|
|
117
|
+
},
|
|
118
|
+
superReflection: context.env.types.env
|
|
119
|
+
});
|
|
120
|
+
reflection$1.name = "Env";
|
|
121
|
+
const message = new capnp.Message();
|
|
122
|
+
reflection$1.messageRoot = message.initRoot(SerializedTypes);
|
|
123
|
+
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
124
|
+
context.env.used.env = reflection$1;
|
|
125
|
+
await writeEnvReflection(context, context.env.used.env, "env");
|
|
126
|
+
}
|
|
127
|
+
return context.env.used.env;
|
|
128
|
+
}
|
|
129
|
+
const buffer = await readFileBuffer(filePath);
|
|
130
|
+
const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
|
|
131
|
+
const reflection = (0, type_exports.resolveClassType)((0, type_exports.deserializeType)(convertFromCapnp(messageRoot.types)));
|
|
132
|
+
context.env.used.env = reflection;
|
|
133
|
+
context.env.used.env.messageRoot = messageRoot;
|
|
134
|
+
context.env.used.env.dataBuffer = buffer;
|
|
135
|
+
return reflection;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Reads the secret environment reflection data from the file system.
|
|
139
|
+
*
|
|
140
|
+
* @param context - The plugin context.
|
|
141
|
+
* @returns The environment reflection data.
|
|
142
|
+
*/
|
|
143
|
+
async function readSecretsReflection(context) {
|
|
144
|
+
const filePath = getEnvReflectionsPath(context, "secrets");
|
|
145
|
+
if (!existsSync(filePath)) {
|
|
146
|
+
if (!context.env.types.secrets) context.env.types.secrets = await readEnvTypeReflection(context, "secrets");
|
|
147
|
+
if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {
|
|
148
|
+
const reflection$1 = createEnvReflection(context, {
|
|
149
|
+
type: {
|
|
150
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
151
|
+
typeName: "Secrets",
|
|
152
|
+
description: `An object containing the secret configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
|
|
153
|
+
types: []
|
|
154
|
+
},
|
|
155
|
+
superReflection: context.env.types.secrets
|
|
156
|
+
});
|
|
157
|
+
reflection$1.name = "Secrets";
|
|
158
|
+
const message = new capnp.Message();
|
|
159
|
+
reflection$1.messageRoot = message.initRoot(SerializedTypes);
|
|
160
|
+
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
161
|
+
context.env.used.secrets = reflection$1;
|
|
162
|
+
await writeEnvReflection(context, context.env.used.secrets, "secrets");
|
|
163
|
+
}
|
|
164
|
+
return context.env.used.secrets;
|
|
165
|
+
}
|
|
166
|
+
const buffer = await readFileBuffer(filePath);
|
|
167
|
+
const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
|
|
168
|
+
const reflection = (0, type_exports.resolveClassType)((0, type_exports.deserializeType)(convertFromCapnp(messageRoot.types)));
|
|
169
|
+
context.env.used.secrets = reflection;
|
|
170
|
+
context.env.used.secrets.messageRoot = messageRoot;
|
|
171
|
+
context.env.used.secrets.dataBuffer = buffer;
|
|
172
|
+
return reflection;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Writes the environment reflection data to the file system.
|
|
176
|
+
*
|
|
177
|
+
* @param context - The plugin context.
|
|
178
|
+
* @param reflection - The reflection data to write.
|
|
179
|
+
* @param name - The name of the reflection (either "env" or "secrets").
|
|
180
|
+
*/
|
|
181
|
+
async function writeEnvReflection(context, reflection, name = "env") {
|
|
182
|
+
const serialized = reflection.serializeType();
|
|
183
|
+
const message = new capnp.Message();
|
|
184
|
+
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
185
|
+
await writeFileBuffer(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Writes the environment reflection data to the file system.
|
|
189
|
+
*
|
|
190
|
+
* @param context - The plugin context.
|
|
191
|
+
* @param reflection - The reflection data to write.
|
|
192
|
+
* @param name - The name of the reflection (either "env" or "secrets").
|
|
193
|
+
*/
|
|
194
|
+
function writeEnvReflectionSync(context, reflection, name = "env") {
|
|
195
|
+
const serialized = reflection.serializeType();
|
|
196
|
+
const message = new capnp.Message();
|
|
197
|
+
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
198
|
+
writeFileBufferSync(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
|
package/dist/helpers/reflect.cjs
CHANGED
|
@@ -1 +1,111 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_type = require('../deepkit/src/vendor/type.cjs');
|
|
3
|
+
const require_reflect_type = require('../deepkit/src/reflect-type.cjs');
|
|
4
|
+
const require_persistence = require('./persistence.cjs');
|
|
5
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
6
|
+
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
7
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
8
|
+
|
|
9
|
+
//#region src/helpers/reflect.ts
|
|
10
|
+
function mergeEnvReflections(context, reflections) {
|
|
11
|
+
return createEnvReflection(context, { type: (0, require_type.type_exports.merge)(reflections.map((reflection) => reflection.type)) });
|
|
12
|
+
}
|
|
13
|
+
function mergeSecretsReflections(context, reflections) {
|
|
14
|
+
return createSecretsReflection(context, { type: (0, require_type.type_exports.merge)(reflections.map((reflection) => reflection.type)) });
|
|
15
|
+
}
|
|
16
|
+
var BaseEnv = class {
|
|
17
|
+
PLATFORM = "neutral";
|
|
18
|
+
MODE = "production";
|
|
19
|
+
DEBUG = false;
|
|
20
|
+
TEST = false;
|
|
21
|
+
MINIMAL = false;
|
|
22
|
+
NO_COLOR = false;
|
|
23
|
+
FORCE_COLOR = false;
|
|
24
|
+
FORCE_HYPERLINK = false;
|
|
25
|
+
STACKTRACE = false;
|
|
26
|
+
INCLUDE_ERROR_DATA = false;
|
|
27
|
+
CI = false;
|
|
28
|
+
};
|
|
29
|
+
var BaseSecrets = class {};
|
|
30
|
+
function createEnvReflection(context, options = {}) {
|
|
31
|
+
const parent = options.superReflection ?? new require_type.type_exports.ReflectionClass({
|
|
32
|
+
kind: require_type.type_exports.ReflectionKind.class,
|
|
33
|
+
description: `The base environment configuration definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
34
|
+
classType: BaseEnv,
|
|
35
|
+
types: [],
|
|
36
|
+
implements: [{
|
|
37
|
+
kind: require_type.type_exports.ReflectionKind.objectLiteral,
|
|
38
|
+
typeName: "EnvInterface",
|
|
39
|
+
description: `The environment configuration interface definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
40
|
+
types: []
|
|
41
|
+
}]
|
|
42
|
+
});
|
|
43
|
+
parent.name = "Env";
|
|
44
|
+
const result = new require_type.type_exports.ReflectionClass(options.type ?? {
|
|
45
|
+
kind: require_type.type_exports.ReflectionKind.objectLiteral,
|
|
46
|
+
typeName: "Env",
|
|
47
|
+
description: `A schema describing the list of available environment variables that can be used by the ${context.config.name ? `${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} application` : "application"}.`,
|
|
48
|
+
types: []
|
|
49
|
+
}, parent);
|
|
50
|
+
result.name = "Env";
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function createSecretsReflection(context, options = {}) {
|
|
54
|
+
const parent = options.superReflection ?? new require_type.type_exports.ReflectionClass({
|
|
55
|
+
kind: require_type.type_exports.ReflectionKind.class,
|
|
56
|
+
description: `The base secrets configuration definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
57
|
+
classType: BaseSecrets,
|
|
58
|
+
types: [],
|
|
59
|
+
implements: [{
|
|
60
|
+
kind: require_type.type_exports.ReflectionKind.objectLiteral,
|
|
61
|
+
typeName: "SecretsInterface",
|
|
62
|
+
description: `The secrets configuration interface definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
63
|
+
types: []
|
|
64
|
+
}]
|
|
65
|
+
});
|
|
66
|
+
parent.name = "Secrets";
|
|
67
|
+
const result = new require_type.type_exports.ReflectionClass(options.type ?? {
|
|
68
|
+
kind: require_type.type_exports.ReflectionKind.objectLiteral,
|
|
69
|
+
typeName: "Secrets",
|
|
70
|
+
description: `A schema describing the list of available environment secrets that can be used by the ${context.config.name ? `${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} application` : "application"}.`,
|
|
71
|
+
types: []
|
|
72
|
+
}, parent);
|
|
73
|
+
result.name = "Secrets";
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
async function reflectEnv(context, file, name) {
|
|
77
|
+
let config;
|
|
78
|
+
if (file) config = (0, require_type.type_exports.resolveClassType)(await require_reflect_type.reflectType(context, {
|
|
79
|
+
file: !(0, __stryke_path_is_parent_path.isParentPath)(file, context.workspaceConfig.workspaceRoot) ? (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, file) : file,
|
|
80
|
+
name
|
|
81
|
+
}, { skipNodeModulesBundle: true }));
|
|
82
|
+
const defaultConfigType = await require_reflect_type.reflectType(context, await require_persistence.getEnvDefaultTypeDefinition(context));
|
|
83
|
+
return mergeEnvReflections(context, [
|
|
84
|
+
await require_persistence.readEnvTypeReflection(context, "env"),
|
|
85
|
+
config,
|
|
86
|
+
(0, require_type.type_exports.resolveClassType)(defaultConfigType)
|
|
87
|
+
].filter(Boolean));
|
|
88
|
+
}
|
|
89
|
+
async function reflectSecrets(context, file, name) {
|
|
90
|
+
let config;
|
|
91
|
+
if (file) config = (0, require_type.type_exports.resolveClassType)(await require_reflect_type.reflectType(context, {
|
|
92
|
+
file: !(0, __stryke_path_is_parent_path.isParentPath)(file, context.workspaceConfig.workspaceRoot) ? (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, file) : file,
|
|
93
|
+
name
|
|
94
|
+
}, { skipNodeModulesBundle: true }));
|
|
95
|
+
const defaultSecretsType = await require_reflect_type.reflectType(context, await require_persistence.getSecretsDefaultTypeDefinition(context));
|
|
96
|
+
return mergeSecretsReflections(context, [
|
|
97
|
+
await require_persistence.readSecretsReflection(context),
|
|
98
|
+
config,
|
|
99
|
+
(0, require_type.type_exports.resolveClassType)(defaultSecretsType)
|
|
100
|
+
].filter(Boolean));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
exports.BaseEnv = BaseEnv;
|
|
105
|
+
exports.BaseSecrets = BaseSecrets;
|
|
106
|
+
exports.createEnvReflection = createEnvReflection;
|
|
107
|
+
exports.createSecretsReflection = createSecretsReflection;
|
|
108
|
+
exports.mergeEnvReflections = mergeEnvReflections;
|
|
109
|
+
exports.mergeSecretsReflections = mergeSecretsReflections;
|
|
110
|
+
exports.reflectEnv = reflectEnv;
|
|
111
|
+
exports.reflectSecrets = reflectSecrets;
|
package/dist/helpers/reflect.mjs
CHANGED
|
@@ -1 +1,103 @@
|
|
|
1
|
-
import{type_exports
|
|
1
|
+
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
import { reflectType } from "../deepkit/src/reflect-type.mjs";
|
|
3
|
+
import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTypeReflection, readSecretsReflection } from "./persistence.mjs";
|
|
4
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
|
+
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
6
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
7
|
+
|
|
8
|
+
//#region src/helpers/reflect.ts
|
|
9
|
+
function mergeEnvReflections(context, reflections) {
|
|
10
|
+
return createEnvReflection(context, { type: (0, type_exports.merge)(reflections.map((reflection) => reflection.type)) });
|
|
11
|
+
}
|
|
12
|
+
function mergeSecretsReflections(context, reflections) {
|
|
13
|
+
return createSecretsReflection(context, { type: (0, type_exports.merge)(reflections.map((reflection) => reflection.type)) });
|
|
14
|
+
}
|
|
15
|
+
var BaseEnv = class {
|
|
16
|
+
PLATFORM = "neutral";
|
|
17
|
+
MODE = "production";
|
|
18
|
+
DEBUG = false;
|
|
19
|
+
TEST = false;
|
|
20
|
+
MINIMAL = false;
|
|
21
|
+
NO_COLOR = false;
|
|
22
|
+
FORCE_COLOR = false;
|
|
23
|
+
FORCE_HYPERLINK = false;
|
|
24
|
+
STACKTRACE = false;
|
|
25
|
+
INCLUDE_ERROR_DATA = false;
|
|
26
|
+
CI = false;
|
|
27
|
+
};
|
|
28
|
+
var BaseSecrets = class {};
|
|
29
|
+
function createEnvReflection(context, options = {}) {
|
|
30
|
+
const parent = options.superReflection ?? new type_exports.ReflectionClass({
|
|
31
|
+
kind: type_exports.ReflectionKind.class,
|
|
32
|
+
description: `The base environment configuration definition for the ${titleCase(context.config.name)} project.`,
|
|
33
|
+
classType: BaseEnv,
|
|
34
|
+
types: [],
|
|
35
|
+
implements: [{
|
|
36
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
37
|
+
typeName: "EnvInterface",
|
|
38
|
+
description: `The environment configuration interface definition for the ${titleCase(context.config.name)} project.`,
|
|
39
|
+
types: []
|
|
40
|
+
}]
|
|
41
|
+
});
|
|
42
|
+
parent.name = "Env";
|
|
43
|
+
const result = new type_exports.ReflectionClass(options.type ?? {
|
|
44
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
45
|
+
typeName: "Env",
|
|
46
|
+
description: `A schema describing the list of available environment variables that can be used by the ${context.config.name ? `${titleCase(context.config.name)} application` : "application"}.`,
|
|
47
|
+
types: []
|
|
48
|
+
}, parent);
|
|
49
|
+
result.name = "Env";
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
function createSecretsReflection(context, options = {}) {
|
|
53
|
+
const parent = options.superReflection ?? new type_exports.ReflectionClass({
|
|
54
|
+
kind: type_exports.ReflectionKind.class,
|
|
55
|
+
description: `The base secrets configuration definition for the ${titleCase(context.config.name)} project.`,
|
|
56
|
+
classType: BaseSecrets,
|
|
57
|
+
types: [],
|
|
58
|
+
implements: [{
|
|
59
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
60
|
+
typeName: "SecretsInterface",
|
|
61
|
+
description: `The secrets configuration interface definition for the ${titleCase(context.config.name)} project.`,
|
|
62
|
+
types: []
|
|
63
|
+
}]
|
|
64
|
+
});
|
|
65
|
+
parent.name = "Secrets";
|
|
66
|
+
const result = new type_exports.ReflectionClass(options.type ?? {
|
|
67
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
68
|
+
typeName: "Secrets",
|
|
69
|
+
description: `A schema describing the list of available environment secrets that can be used by the ${context.config.name ? `${titleCase(context.config.name)} application` : "application"}.`,
|
|
70
|
+
types: []
|
|
71
|
+
}, parent);
|
|
72
|
+
result.name = "Secrets";
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
async function reflectEnv(context, file, name) {
|
|
76
|
+
let config;
|
|
77
|
+
if (file) config = (0, type_exports.resolveClassType)(await reflectType(context, {
|
|
78
|
+
file: !isParentPath(file, context.workspaceConfig.workspaceRoot) ? joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
|
|
79
|
+
name
|
|
80
|
+
}, { skipNodeModulesBundle: true }));
|
|
81
|
+
const defaultConfigType = await reflectType(context, await getEnvDefaultTypeDefinition(context));
|
|
82
|
+
return mergeEnvReflections(context, [
|
|
83
|
+
await readEnvTypeReflection(context, "env"),
|
|
84
|
+
config,
|
|
85
|
+
(0, type_exports.resolveClassType)(defaultConfigType)
|
|
86
|
+
].filter(Boolean));
|
|
87
|
+
}
|
|
88
|
+
async function reflectSecrets(context, file, name) {
|
|
89
|
+
let config;
|
|
90
|
+
if (file) config = (0, type_exports.resolveClassType)(await reflectType(context, {
|
|
91
|
+
file: !isParentPath(file, context.workspaceConfig.workspaceRoot) ? joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
|
|
92
|
+
name
|
|
93
|
+
}, { skipNodeModulesBundle: true }));
|
|
94
|
+
const defaultSecretsType = await reflectType(context, await getSecretsDefaultTypeDefinition(context));
|
|
95
|
+
return mergeSecretsReflections(context, [
|
|
96
|
+
await readSecretsReflection(context),
|
|
97
|
+
config,
|
|
98
|
+
(0, type_exports.resolveClassType)(defaultSecretsType)
|
|
99
|
+
].filter(Boolean));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets };
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
3
|
+
let __stryke_env_types = require("@stryke/env/types");
|
|
4
|
+
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/source-file-env.ts
|
|
7
|
+
function removeEnvPrefix(env) {
|
|
8
|
+
if ((0, __stryke_type_checks_is_string.isString)(env)) {
|
|
9
|
+
let name = __stryke_env_types.ENV_PREFIXES.reduce((ret, prefix) => {
|
|
10
|
+
if (ret.startsWith(prefix)) ret = ret.slice(prefix.length);
|
|
11
|
+
return ret;
|
|
12
|
+
}, env.toUpperCase());
|
|
13
|
+
while (name.startsWith("_")) name = name.slice(1);
|
|
14
|
+
return name;
|
|
15
|
+
}
|
|
16
|
+
return Object.keys(env).reduce((ret, key) => {
|
|
17
|
+
const name = removeEnvPrefix(key);
|
|
18
|
+
if (name) ret[name] = env[key];
|
|
19
|
+
return ret;
|
|
20
|
+
}, {});
|
|
21
|
+
}
|
|
22
|
+
function formatEnvField(key) {
|
|
23
|
+
return (0, __stryke_string_format_camel_case.camelCase)(removeEnvPrefix(key));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.formatEnvField = formatEnvField;
|
|
28
|
+
exports.removeEnvPrefix = removeEnvPrefix;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import{isString
|
|
1
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
2
|
+
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
3
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/source-file-env.ts
|
|
6
|
+
function removeEnvPrefix(env) {
|
|
7
|
+
if (isString(env)) {
|
|
8
|
+
let name = ENV_PREFIXES.reduce((ret, prefix) => {
|
|
9
|
+
if (ret.startsWith(prefix)) ret = ret.slice(prefix.length);
|
|
10
|
+
return ret;
|
|
11
|
+
}, env.toUpperCase());
|
|
12
|
+
while (name.startsWith("_")) name = name.slice(1);
|
|
13
|
+
return name;
|
|
14
|
+
}
|
|
15
|
+
return Object.keys(env).reduce((ret, key) => {
|
|
16
|
+
const name = removeEnvPrefix(key);
|
|
17
|
+
if (name) ret[name] = env[key];
|
|
18
|
+
return ret;
|
|
19
|
+
}, {});
|
|
20
|
+
}
|
|
21
|
+
function formatEnvField(key) {
|
|
22
|
+
return camelCase(removeEnvPrefix(key));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { formatEnvField, removeEnvPrefix };
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_persistence = require('./persistence.cjs');
|
|
3
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/template-helpers.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates the reflection data used when generating runtime template files.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The context for the configuration plugin.
|
|
10
|
+
* @param name - The name of the configuration template.
|
|
11
|
+
* @returns The reflection for the specified configuration template.
|
|
12
|
+
*/
|
|
13
|
+
async function createTemplateReflection(context, name) {
|
|
14
|
+
const reflection = await require_persistence.readEnvTypeReflection(context, name);
|
|
15
|
+
reflection.getProperties().forEach((prop) => {
|
|
16
|
+
prop.getAlias().filter(Boolean).forEach((alias) => {
|
|
17
|
+
reflection.addProperty({
|
|
18
|
+
name: alias,
|
|
19
|
+
optional: prop.isOptional() ? true : void 0,
|
|
20
|
+
readonly: prop.isReadonly() ? true : void 0,
|
|
21
|
+
description: prop.getDescription(),
|
|
22
|
+
visibility: prop.getVisibility(),
|
|
23
|
+
type: prop.getType(),
|
|
24
|
+
default: prop.getDefaultValue(),
|
|
25
|
+
tags: {
|
|
26
|
+
hidden: prop.isHidden(),
|
|
27
|
+
ignore: prop.isIgnored(),
|
|
28
|
+
internal: prop.isInternal(),
|
|
29
|
+
alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
|
|
30
|
+
title: prop.getTitle() || (0, __stryke_string_format_title_case.titleCase)(prop.name),
|
|
31
|
+
readonly: prop.isReadonly(),
|
|
32
|
+
permission: prop.getPermission(),
|
|
33
|
+
domain: prop.getDomain()
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return reflection;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.createTemplateReflection = createTemplateReflection;
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
import{readEnvTypeReflection
|
|
1
|
+
import { readEnvTypeReflection } from "./persistence.mjs";
|
|
2
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/template-helpers.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates the reflection data used when generating runtime template files.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The context for the configuration plugin.
|
|
9
|
+
* @param name - The name of the configuration template.
|
|
10
|
+
* @returns The reflection for the specified configuration template.
|
|
11
|
+
*/
|
|
12
|
+
async function createTemplateReflection(context, name) {
|
|
13
|
+
const reflection = await readEnvTypeReflection(context, name);
|
|
14
|
+
reflection.getProperties().forEach((prop) => {
|
|
15
|
+
prop.getAlias().filter(Boolean).forEach((alias) => {
|
|
16
|
+
reflection.addProperty({
|
|
17
|
+
name: alias,
|
|
18
|
+
optional: prop.isOptional() ? true : void 0,
|
|
19
|
+
readonly: prop.isReadonly() ? true : void 0,
|
|
20
|
+
description: prop.getDescription(),
|
|
21
|
+
visibility: prop.getVisibility(),
|
|
22
|
+
type: prop.getType(),
|
|
23
|
+
default: prop.getDefaultValue(),
|
|
24
|
+
tags: {
|
|
25
|
+
hidden: prop.isHidden(),
|
|
26
|
+
ignore: prop.isIgnored(),
|
|
27
|
+
internal: prop.isInternal(),
|
|
28
|
+
alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
|
|
29
|
+
title: prop.getTitle() || titleCase(prop.name),
|
|
30
|
+
readonly: prop.isReadonly(),
|
|
31
|
+
permission: prop.getPermission(),
|
|
32
|
+
domain: prop.getDomain()
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return reflection;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { createTemplateReflection };
|