@powerlines/plugin-env 0.16.200 → 0.16.202
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/helpers/reflect.cjs
CHANGED
|
@@ -6,7 +6,7 @@ const require_helpers_persistence = require('./persistence.cjs');
|
|
|
6
6
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
7
7
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
8
8
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
9
|
-
let
|
|
9
|
+
let _powerlines_schema_resolve = require("@powerlines/schema/resolve");
|
|
10
10
|
let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
11
11
|
|
|
12
12
|
//#region src/helpers/reflect.ts
|
|
@@ -226,14 +226,14 @@ createSecretsReflection.__type = [
|
|
|
226
226
|
*/
|
|
227
227
|
async function reflectEnv(context, file, name) {
|
|
228
228
|
let config;
|
|
229
|
-
if (file) config = (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0,
|
|
229
|
+
if (file) config = (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_schema_resolve.resolveReflection)(context, {
|
|
230
230
|
file: !(0, _stryke_path_is_parent_path.isParentPath)(file, context.config.cwd) ? (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, file) : file,
|
|
231
231
|
name
|
|
232
232
|
}));
|
|
233
233
|
return mergeEnvReflections(context, [
|
|
234
234
|
await require_helpers_persistence.readEnvTypeReflection(context, "env"),
|
|
235
235
|
config,
|
|
236
|
-
(0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0,
|
|
236
|
+
(0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_schema_resolve.resolveReflection)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context)))
|
|
237
237
|
].filter(Boolean));
|
|
238
238
|
}
|
|
239
239
|
reflectEnv.__type = [
|
|
@@ -258,14 +258,14 @@ reflectEnv.__type = [
|
|
|
258
258
|
*/
|
|
259
259
|
async function reflectSecrets(context, file, name) {
|
|
260
260
|
let config;
|
|
261
|
-
if (file) config = (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0,
|
|
261
|
+
if (file) config = (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_schema_resolve.resolveReflection)(context, {
|
|
262
262
|
file: !(0, _stryke_path_is_parent_path.isParentPath)(file, context.config.cwd) ? (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, file) : file,
|
|
263
263
|
name
|
|
264
264
|
}));
|
|
265
265
|
return mergeSecretsReflections(context, [
|
|
266
266
|
await require_helpers_persistence.readSecretsReflection(context),
|
|
267
267
|
config,
|
|
268
|
-
(0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0,
|
|
268
|
+
(0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_schema_resolve.resolveReflection)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context)))
|
|
269
269
|
].filter(Boolean));
|
|
270
270
|
}
|
|
271
271
|
reflectSecrets.__type = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.d.cts","names":[],"sources":["../../src/helpers/reflect.ts"],"mappings":";;;;;iBAuCgB,mBAAA,CACd,OAAA,EAAS,gBAAA,EACT,WAAA,EAAa,eAAA,UACZ,eAAA;AAAA,iBAQa,uBAAA,CACd,OAAA,EAAS,gBAAA,EACT,WAAA,EAAa,eAAA,UACZ,eAAA;AAAA,UAQc,0BAAA;EACf,IAAA,GAAO,iBAAA,GAAoB,SAAA;EAC3B,eAAA,GAAkB,eAAA;AAAA;AAAA,cAGP,OAAA,YAAmB,YAAA;EAC9B,QAAA;EAEA,WAAA;EAEA,QAAA;EAEA,eAAA;EAEA,cAAA;EAEA,UAAA;EAEA,WAAA;EAEA,YAAA;EAEA,QAAA;EAEA,IAAA;EAEA,WAAA;EAEA,KAAA;EAEA,IAAA;EAEA,OAAA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;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"reflect.d.mts","names":[],"sources":["../../src/helpers/reflect.ts"],"mappings":";;;;;iBAuCgB,mBAAA,CACd,OAAA,EAAS,gBAAA,EACT,WAAA,EAAa,eAAA,UACZ,eAAA;AAAA,iBAQa,uBAAA,CACd,OAAA,EAAS,gBAAA,EACT,WAAA,EAAa,eAAA,UACZ,eAAA;AAAA,UAQc,0BAAA;EACf,IAAA,GAAO,iBAAA,GAAoB,SAAA;EAC3B,eAAA,GAAkB,eAAA;AAAA;AAAA,cAGP,OAAA,YAAmB,YAAA;EAC9B,QAAA;EAEA,WAAA;EAEA,QAAA;EAEA,eAAA;EAEA,cAAA;EAEA,UAAA;EAEA,WAAA;EAEA,YAAA;EAEA,QAAA;EAEA,IAAA;EAEA,WAAA;EAEA,KAAA;EAEA,IAAA;EAEA,OAAA;EAEA,QAAA;EAEA,WAAA;EAEA,eAAA;EAEA,UAAA;EAEA,kBAAA;EAEA,SAAA;EAEA,gBAAA;EAEA,cAAA;EAEA,EAAA;AAAA;AAAA,cAGW,WAAA,YAAuB,gBAAA;EAClC,cAAA;AAAA;AAAA,iBAGc,mBAAA,CACd,OAAA,EAAS,gBAAA,EACT,OAAA,GAAS,0BAAA,GACR,eAAA;AAAA,iBAyCa,uBAAA,CACd,OAAA,EAAS,gBAAA,EACT,OAAA,GAAS,0BAAA,GACR,eAAA;;;;;;;;;;;;iBAoDmB,UAAA,CACpB,OAAA,EAAS,gBAAA,EACT,IAAA,WACA,IAAA,YAAa,OAAA,CAAA,eAAA;;;;;;;;;;;;iBAwCO,cAAA,CACpB,OAAA,EAAS,gBAAA,EACT,IAAA,WACA,IAAA,YAAa,OAAA,CAAA,eAAA"}
|
package/dist/helpers/reflect.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTy
|
|
|
4
4
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
5
5
|
import { ReflectionClass, ReflectionKind, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
6
6
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
7
|
-
import {
|
|
7
|
+
import { resolveReflection } from "@powerlines/schema/resolve";
|
|
8
8
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
9
9
|
|
|
10
10
|
//#region src/helpers/reflect.ts
|
|
@@ -224,14 +224,14 @@ createSecretsReflection.__type = [
|
|
|
224
224
|
*/
|
|
225
225
|
async function reflectEnv(context, file, name) {
|
|
226
226
|
let config;
|
|
227
|
-
if (file) config = resolveClassType(await
|
|
227
|
+
if (file) config = resolveClassType(await resolveReflection(context, {
|
|
228
228
|
file: !isParentPath(file, context.config.cwd) ? joinPaths(context.config.cwd, file) : file,
|
|
229
229
|
name
|
|
230
230
|
}));
|
|
231
231
|
return mergeEnvReflections(context, [
|
|
232
232
|
await readEnvTypeReflection(context, "env"),
|
|
233
233
|
config,
|
|
234
|
-
resolveClassType(await
|
|
234
|
+
resolveClassType(await resolveReflection(context, await getEnvDefaultTypeDefinition(context)))
|
|
235
235
|
].filter(Boolean));
|
|
236
236
|
}
|
|
237
237
|
reflectEnv.__type = [
|
|
@@ -256,14 +256,14 @@ reflectEnv.__type = [
|
|
|
256
256
|
*/
|
|
257
257
|
async function reflectSecrets(context, file, name) {
|
|
258
258
|
let config;
|
|
259
|
-
if (file) config = resolveClassType(await
|
|
259
|
+
if (file) config = resolveClassType(await resolveReflection(context, {
|
|
260
260
|
file: !isParentPath(file, context.config.cwd) ? joinPaths(context.config.cwd, file) : file,
|
|
261
261
|
name
|
|
262
262
|
}));
|
|
263
263
|
return mergeSecretsReflections(context, [
|
|
264
264
|
await readSecretsReflection(context),
|
|
265
265
|
config,
|
|
266
|
-
resolveClassType(await
|
|
266
|
+
resolveClassType(await resolveReflection(context, await getSecretsDefaultTypeDefinition(context)))
|
|
267
267
|
].filter(Boolean));
|
|
268
268
|
}
|
|
269
269
|
reflectSecrets.__type = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvInterface, SecretsInterface } from \"../types/env\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC/B,IAAI,SAAS;;;AA0Bd,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CACQ;;AAEV,oBAAgB,SAAA;OAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;AACnC,SAAW,wBAAgB,SAAA,aAAA;AAIzB,QAHa,wBAAqB,SAAA,EACjC,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACtB,CACc;;;;;;;;;AAGhB,MAAE,gCAAiB;CAAA;CAAA;CAAA;CAAA;CA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AAC;CAAsB;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { resolveReflection } from \"@powerlines/schema/resolve\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvInterface, SecretsInterface } from \"../types/env\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await resolveReflection(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await resolveReflection(\n context,\n await getEnvDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await resolveReflection(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await resolveReflection(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC/B,IAAI,SAAS;;;AA0Bd,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CACQ;;AAEV,oBAAgB,SAAA;OAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;AACnC,SAAW,wBAAgB,SAAA,aAAA;AAIzB,QAHa,wBAAqB,SAAA,EACjC,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACtB,CACc;;;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A,CAAA;EAAA,CAAA,OAAA,QAAA,CAAA;;AAE3G,eAAe,SAAS;OAAC;CAAsB;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-env",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.202",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
|
|
6
6
|
"keywords": ["dotenv", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -119,13 +119,14 @@
|
|
|
119
119
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
120
120
|
"@babel/core": "8.0.0-rc.5",
|
|
121
121
|
"@babel/types": "8.0.0-rc.5",
|
|
122
|
-
"@powerlines/core": "^0.
|
|
123
|
-
"@powerlines/deepkit": "^0.
|
|
124
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
125
|
-
"@powerlines/plugin-automd": "^0.1.
|
|
126
|
-
"@powerlines/plugin-babel": "^0.13.
|
|
127
|
-
"@powerlines/plugin-deepkit": "^0.11.
|
|
128
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
122
|
+
"@powerlines/core": "^0.10.1",
|
|
123
|
+
"@powerlines/deepkit": "^0.10.1",
|
|
124
|
+
"@powerlines/plugin-alloy": "^0.26.94",
|
|
125
|
+
"@powerlines/plugin-automd": "^0.1.474",
|
|
126
|
+
"@powerlines/plugin-babel": "^0.13.10",
|
|
127
|
+
"@powerlines/plugin-deepkit": "^0.11.356",
|
|
128
|
+
"@powerlines/plugin-plugin": "^0.12.425",
|
|
129
|
+
"@powerlines/schema": "^0.10.1",
|
|
129
130
|
"@storm-software/config-tools": "^1.190.2",
|
|
130
131
|
"@stryke/capnp": "^0.12.101",
|
|
131
132
|
"@stryke/convert": "^0.7.6",
|
|
@@ -140,9 +141,9 @@
|
|
|
140
141
|
"automd": "^0.4.3",
|
|
141
142
|
"c12": "^3.3.4",
|
|
142
143
|
"defu": "^6.1.7",
|
|
143
|
-
"powerlines": "^0.47.
|
|
144
|
+
"powerlines": "^0.47.13"
|
|
144
145
|
},
|
|
145
146
|
"devDependencies": { "@types/node": "^25.7.0", "vite": "^8.0.12" },
|
|
146
147
|
"publishConfig": { "access": "public" },
|
|
147
|
-
"gitHead": "
|
|
148
|
+
"gitHead": "736cd33f1a3d05ab931feed3ffe1df16043c216b"
|
|
148
149
|
}
|