@powerlines/plugin-date 0.12.151 → 0.12.152
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/components/date-fns.cjs +3 -2
- package/dist/components/date-fns.mjs +1 -1
- package/dist/components/dayjs.cjs +3 -2
- package/dist/components/dayjs.mjs +1 -1
- package/dist/components/luxon.cjs +3 -2
- package/dist/components/luxon.mjs +1 -1
- package/dist/components/moment.cjs +3 -2
- package/dist/components/moment.mjs +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs +43 -0
- package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs +42 -0
- package/dist/packages/plugin-alloy/src/types/components.d.mts +2 -0
- package/dist/{plugin-env → packages/plugin-env}/src/types/plugin.d.mts +1 -1
- package/dist/{powerlines → packages/powerlines}/src/types/build.d.mts +6 -6
- package/dist/{powerlines → packages/powerlines}/src/types/config.d.mts +1 -2
- package/dist/{powerlines → packages/powerlines}/src/types/tsconfig.d.mts +1 -1
- package/dist/types/plugin.d.mts +1 -1
- package/package.json +5 -5
- package/dist/deepkit/schemas/reflection.cjs +0 -3998
- package/dist/deepkit/schemas/reflection.mjs +0 -3996
- package/dist/deepkit/schemas/reflection2.cjs +0 -4112
- package/dist/deepkit/schemas/reflection2.mjs +0 -4110
- package/dist/deepkit/src/capnp.cjs +0 -913
- package/dist/deepkit/src/capnp.mjs +0 -911
- package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
- package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
- package/dist/deepkit/src/reflect-type.cjs +0 -22
- package/dist/deepkit/src/reflect-type.mjs +0 -20
- package/dist/deepkit/src/resolve-reflections.cjs +0 -16
- package/dist/deepkit/src/resolve-reflections.mjs +0 -15
- package/dist/deepkit/src/transformer.cjs +0 -52
- package/dist/deepkit/src/transformer.mjs +0 -49
- package/dist/deepkit/src/transpile.cjs +0 -29
- package/dist/deepkit/src/transpile.mjs +0 -27
- package/dist/deepkit/src/utilities.cjs +0 -66
- package/dist/deepkit/src/utilities.mjs +0 -65
- package/dist/plugin-alloy/src/core/components/output.cjs +0 -38
- package/dist/plugin-alloy/src/core/components/output.mjs +0 -37
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -20
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -19
- package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -60
- package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -58
- package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
- package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
- package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
- package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
- package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
- package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
- package/dist/plugin-alloy/src/index.cjs +0 -103
- package/dist/plugin-alloy/src/index.mjs +0 -101
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -7
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -9
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -5
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -7
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -17
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
- package/dist/plugin-alloy/src/types/components.d.mts +0 -3
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -47
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -46
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -75
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -73
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -359
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -350
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -153
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -150
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -53
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -52
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -94
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -93
- package/dist/plugin-automd/src/index.cjs +0 -101
- package/dist/plugin-automd/src/index.mjs +0 -98
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
- package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
- package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
- package/dist/plugin-babel/src/helpers/index.cjs +0 -5
- package/dist/plugin-babel/src/helpers/index.mjs +0 -7
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
- package/dist/plugin-babel/src/helpers/options.cjs +0 -50
- package/dist/plugin-babel/src/helpers/options.mjs +0 -47
- package/dist/plugin-babel/src/index.cjs +0 -91
- package/dist/plugin-babel/src/index.mjs +0 -89
- package/dist/plugin-env/src/babel/index.cjs +0 -1
- package/dist/plugin-env/src/babel/index.mjs +0 -3
- package/dist/plugin-env/src/babel/plugin.cjs +0 -121
- package/dist/plugin-env/src/babel/plugin.mjs +0 -119
- package/dist/plugin-env/src/components/docs.cjs +0 -9
- package/dist/plugin-env/src/components/docs.mjs +0 -11
- package/dist/plugin-env/src/components/env.cjs +0 -487
- package/dist/plugin-env/src/components/env.mjs +0 -484
- package/dist/plugin-env/src/components/index.cjs +0 -2
- package/dist/plugin-env/src/components/index.mjs +0 -4
- package/dist/plugin-env/src/helpers/automd-generator.cjs +0 -22
- package/dist/plugin-env/src/helpers/automd-generator.mjs +0 -21
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +0 -55
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +0 -54
- package/dist/plugin-env/src/helpers/index.cjs +0 -6
- package/dist/plugin-env/src/helpers/index.mjs +0 -8
- package/dist/plugin-env/src/helpers/load.cjs +0 -83
- package/dist/plugin-env/src/helpers/load.mjs +0 -80
- package/dist/plugin-env/src/helpers/persistence.cjs +0 -201
- package/dist/plugin-env/src/helpers/persistence.mjs +0 -190
- package/dist/plugin-env/src/helpers/reflect.cjs +0 -125
- package/dist/plugin-env/src/helpers/reflect.mjs +0 -117
- package/dist/plugin-env/src/helpers/source-file-env.cjs +0 -24
- package/dist/plugin-env/src/helpers/source-file-env.mjs +0 -23
- package/dist/plugin-env/src/helpers/template-helpers.cjs +0 -2
- package/dist/plugin-env/src/helpers/template-helpers.mjs +0 -4
- package/dist/plugin-env/src/index.cjs +0 -172
- package/dist/plugin-env/src/index.mjs +0 -170
- package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
- package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
- package/dist/powerlines/src/lib/entry.cjs +0 -12
- package/dist/powerlines/src/lib/entry.mjs +0 -14
- package/dist/powerlines/src/lib/logger.cjs +0 -41
- package/dist/powerlines/src/lib/logger.mjs +0 -39
- package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
- package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
- package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
- /package/dist/{deepkit → packages/deepkit}/schemas/reflection.d.mts +0 -0
- /package/dist/{deepkit → packages/deepkit}/src/types.d.mts +0 -0
- /package/dist/{plugin-alloy → packages/plugin-alloy}/src/types/index.d.mts +0 -0
- /package/dist/{plugin-alloy → packages/plugin-alloy}/src/types/plugin.d.mts +0 -0
- /package/dist/{plugin-automd → packages/plugin-automd}/src/types/plugin.d.mts +0 -0
- /package/dist/{plugin-automd → packages/plugin-automd}/src/types/toc.d.mts +0 -0
- /package/dist/{plugin-babel → packages/plugin-babel}/src/types/index.d.mts +0 -0
- /package/dist/{plugin-babel → packages/plugin-babel}/src/types/plugin.d.mts +0 -0
- /package/dist/{plugin-env → packages/plugin-env}/src/types/runtime.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/internal/helpers/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/api.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/babel.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/commands.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/context.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/fs.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/plugin.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/resolved.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/unplugin.d.mts +0 -0
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_source_file_env = require('./source-file-env.cjs');
|
|
3
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
4
|
-
let c12 = require("c12");
|
|
5
|
-
let defu = require("defu");
|
|
6
|
-
defu = require_rolldown_runtime.__toESM(defu);
|
|
7
|
-
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
8
|
-
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
9
|
-
let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
10
|
-
let __stryke_env_load_env = require("@stryke/env/load-env");
|
|
11
|
-
|
|
12
|
-
//#region ../plugin-env/src/helpers/load.ts
|
|
13
|
-
async function loadEnvFiles(options, mode, cwd) {
|
|
14
|
-
let env = await (0, __stryke_env_load_env.loadEnv)(cwd, mode);
|
|
15
|
-
if (options.additionalFiles && options.additionalFiles?.length > 0) {
|
|
16
|
-
const additionalEnvFiles = await Promise.all(options.additionalFiles.map(async (additionalEnvFile) => (0, __stryke_env_load_env.loadEnvFile)(additionalEnvFile, cwd)));
|
|
17
|
-
for (const additionalEnvFile of additionalEnvFiles) env = (0, defu.default)(additionalEnvFile, env);
|
|
18
|
-
}
|
|
19
|
-
return require_source_file_env.removeEnvPrefix(env);
|
|
20
|
-
}
|
|
21
|
-
async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
|
|
22
|
-
const [envResult, c12Result] = await Promise.all([loadEnvFiles(options, mode, directory), (0, c12.loadConfig)({
|
|
23
|
-
cwd: directory,
|
|
24
|
-
name: "storm",
|
|
25
|
-
envName: mode,
|
|
26
|
-
defaults: {
|
|
27
|
-
NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, ""),
|
|
28
|
-
MODE: mode,
|
|
29
|
-
ORG: workspaceConfig.organization
|
|
30
|
-
},
|
|
31
|
-
globalRc: true,
|
|
32
|
-
packageJson: true,
|
|
33
|
-
dotenv: true,
|
|
34
|
-
jitiOptions: {
|
|
35
|
-
fsCache: (0, __stryke_path_join_paths.joinPaths)(cacheDir, "jiti"),
|
|
36
|
-
moduleCache: true
|
|
37
|
-
}
|
|
38
|
-
})]);
|
|
39
|
-
return (0, defu.default)(envResult, c12Result.config, workspaceConfig);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Retrieves various dotenv configuration parameters from the context.
|
|
43
|
-
*
|
|
44
|
-
* @param context - The context to retrieve the dotenv configuration from.
|
|
45
|
-
* @param parsed - The parsed dotenv configuration.
|
|
46
|
-
* @returns An object containing the dotenv configuration.
|
|
47
|
-
*/
|
|
48
|
-
function loadEnvFromContext(context, parsed) {
|
|
49
|
-
return (0, defu.default)({
|
|
50
|
-
APP_NAME: (0, __stryke_string_format_kebab_case.kebabCase)(context.config.name || context.packageJson.name?.replace(`/${context.workspaceConfig.namespace}`, "")),
|
|
51
|
-
APP_VERSION: context.packageJson.version,
|
|
52
|
-
BUILD_ID: context.meta.buildId,
|
|
53
|
-
BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),
|
|
54
|
-
BUILD_CHECKSUM: context.meta.checksum,
|
|
55
|
-
RELEASE_ID: context.meta.releaseId,
|
|
56
|
-
RELEASE_TAG: `${(0, __stryke_string_format_kebab_case.kebabCase)(context.config.name)}@${context.packageJson.version}`,
|
|
57
|
-
DEFAULT_LOCALE: context.workspaceConfig.locale,
|
|
58
|
-
DEFAULT_TIMEZONE: context.workspaceConfig.timezone,
|
|
59
|
-
LOG_LEVEL: context.config.logLevel,
|
|
60
|
-
ERROR_URL: context.workspaceConfig.error?.url,
|
|
61
|
-
ORGANIZATION: (0, __stryke_type_checks_is_set_string.isSetString)(context.workspaceConfig.organization) ? context.workspaceConfig.organization : context.workspaceConfig.organization?.name,
|
|
62
|
-
PLATFORM: context.config.build.platform,
|
|
63
|
-
MODE: context.workspaceConfig.mode,
|
|
64
|
-
DEBUG: context.workspaceConfig.mode === "development",
|
|
65
|
-
STACKTRACE: context.workspaceConfig.mode === "development",
|
|
66
|
-
ENVIRONMENT: context.environment
|
|
67
|
-
}, (0, __stryke_type_checks_is_set_object.isSetObject)(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce((ret, prop) => {
|
|
68
|
-
ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
|
|
69
|
-
return ret;
|
|
70
|
-
}, {}) : {});
|
|
71
|
-
}
|
|
72
|
-
async function loadEnv(context, options) {
|
|
73
|
-
const [project, workspace, config] = await Promise.all([
|
|
74
|
-
loadEnvDirectory(options, context.config.projectRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
|
|
75
|
-
loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
|
|
76
|
-
loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)
|
|
77
|
-
]);
|
|
78
|
-
return (0, defu.default)(loadEnvFromContext(context, process.env), project, workspace, config);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
82
|
-
exports.loadEnv = loadEnv;
|
|
83
|
-
exports.loadEnvFromContext = loadEnvFromContext;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { removeEnvPrefix } from "./source-file-env.mjs";
|
|
2
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
3
|
-
import { loadConfig } from "c12";
|
|
4
|
-
import defu from "defu";
|
|
5
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
6
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
7
|
-
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
8
|
-
import { loadEnv, loadEnvFile } from "@stryke/env/load-env";
|
|
9
|
-
|
|
10
|
-
//#region ../plugin-env/src/helpers/load.ts
|
|
11
|
-
async function loadEnvFiles(options, mode, cwd) {
|
|
12
|
-
let env = await loadEnv(cwd, mode);
|
|
13
|
-
if (options.additionalFiles && options.additionalFiles?.length > 0) {
|
|
14
|
-
const additionalEnvFiles = await Promise.all(options.additionalFiles.map(async (additionalEnvFile) => loadEnvFile(additionalEnvFile, cwd)));
|
|
15
|
-
for (const additionalEnvFile of additionalEnvFiles) env = defu(additionalEnvFile, env);
|
|
16
|
-
}
|
|
17
|
-
return removeEnvPrefix(env);
|
|
18
|
-
}
|
|
19
|
-
async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
|
|
20
|
-
const [envResult, c12Result] = await Promise.all([loadEnvFiles(options, mode, directory), loadConfig({
|
|
21
|
-
cwd: directory,
|
|
22
|
-
name: "storm",
|
|
23
|
-
envName: mode,
|
|
24
|
-
defaults: {
|
|
25
|
-
NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, ""),
|
|
26
|
-
MODE: mode,
|
|
27
|
-
ORG: workspaceConfig.organization
|
|
28
|
-
},
|
|
29
|
-
globalRc: true,
|
|
30
|
-
packageJson: true,
|
|
31
|
-
dotenv: true,
|
|
32
|
-
jitiOptions: {
|
|
33
|
-
fsCache: joinPaths(cacheDir, "jiti"),
|
|
34
|
-
moduleCache: true
|
|
35
|
-
}
|
|
36
|
-
})]);
|
|
37
|
-
return defu(envResult, c12Result.config, workspaceConfig);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Retrieves various dotenv configuration parameters from the context.
|
|
41
|
-
*
|
|
42
|
-
* @param context - The context to retrieve the dotenv configuration from.
|
|
43
|
-
* @param parsed - The parsed dotenv configuration.
|
|
44
|
-
* @returns An object containing the dotenv configuration.
|
|
45
|
-
*/
|
|
46
|
-
function loadEnvFromContext(context, parsed) {
|
|
47
|
-
return defu({
|
|
48
|
-
APP_NAME: kebabCase(context.config.name || context.packageJson.name?.replace(`/${context.workspaceConfig.namespace}`, "")),
|
|
49
|
-
APP_VERSION: context.packageJson.version,
|
|
50
|
-
BUILD_ID: context.meta.buildId,
|
|
51
|
-
BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),
|
|
52
|
-
BUILD_CHECKSUM: context.meta.checksum,
|
|
53
|
-
RELEASE_ID: context.meta.releaseId,
|
|
54
|
-
RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,
|
|
55
|
-
DEFAULT_LOCALE: context.workspaceConfig.locale,
|
|
56
|
-
DEFAULT_TIMEZONE: context.workspaceConfig.timezone,
|
|
57
|
-
LOG_LEVEL: context.config.logLevel,
|
|
58
|
-
ERROR_URL: context.workspaceConfig.error?.url,
|
|
59
|
-
ORGANIZATION: isSetString(context.workspaceConfig.organization) ? context.workspaceConfig.organization : context.workspaceConfig.organization?.name,
|
|
60
|
-
PLATFORM: context.config.build.platform,
|
|
61
|
-
MODE: context.workspaceConfig.mode,
|
|
62
|
-
DEBUG: context.workspaceConfig.mode === "development",
|
|
63
|
-
STACKTRACE: context.workspaceConfig.mode === "development",
|
|
64
|
-
ENVIRONMENT: context.environment
|
|
65
|
-
}, isSetObject(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce((ret, prop) => {
|
|
66
|
-
ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
|
|
67
|
-
return ret;
|
|
68
|
-
}, {}) : {});
|
|
69
|
-
}
|
|
70
|
-
async function loadEnv$1(context, options) {
|
|
71
|
-
const [project, workspace, config] = await Promise.all([
|
|
72
|
-
loadEnvDirectory(options, context.config.projectRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
|
|
73
|
-
loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
|
|
74
|
-
loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)
|
|
75
|
-
]);
|
|
76
|
-
return defu(loadEnvFromContext(context, process.env), project, workspace, config);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
//#endregion
|
|
80
|
-
export { loadEnv$1 as loadEnv, loadEnvFromContext };
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_capnp = require('../../../deepkit/src/capnp.cjs');
|
|
3
|
-
const require_reflection = require('../../../deepkit/schemas/reflection2.cjs');
|
|
4
|
-
const require_resolve_reflections = require('../../../deepkit/src/resolve-reflections.cjs');
|
|
5
|
-
const require_reflect = require('./reflect.cjs');
|
|
6
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
8
|
-
let __stryke_capnp = require("@stryke/capnp");
|
|
9
|
-
__stryke_capnp = require_rolldown_runtime.__toESM(__stryke_capnp);
|
|
10
|
-
let __stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
11
|
-
let node_fs = require("node:fs");
|
|
12
|
-
let __stryke_type_checks_is_empty_object = require("@stryke/type-checks/is-empty-object");
|
|
13
|
-
|
|
14
|
-
//#region ../plugin-env/src/helpers/persistence.ts
|
|
15
|
-
/**
|
|
16
|
-
* Resolves the runtime type definition file for the environment variables.
|
|
17
|
-
*
|
|
18
|
-
* @param context - The plugin context.
|
|
19
|
-
* @returns The runtime type definition file for the environment variables.
|
|
20
|
-
*/
|
|
21
|
-
async function resolveRuntimeTypeFile(context) {
|
|
22
|
-
const resolved = await context.fs.resolve("@powerlines/plugin-env/types/runtime");
|
|
23
|
-
if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
|
|
24
|
-
return resolved;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Gets the default type definition for the environment variables.
|
|
28
|
-
*
|
|
29
|
-
* @param context - The plugin context.
|
|
30
|
-
* @returns The default type definition for the environment variables.
|
|
31
|
-
*/
|
|
32
|
-
async function getEnvDefaultTypeDefinition(context) {
|
|
33
|
-
return {
|
|
34
|
-
file: await resolveRuntimeTypeFile(context),
|
|
35
|
-
name: "EnvInterface"
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/** Gets the default type definition for the environment secrets.
|
|
39
|
-
*
|
|
40
|
-
* @param context - The plugin context.
|
|
41
|
-
* @returns The default type definition for the environment secrets.
|
|
42
|
-
*/
|
|
43
|
-
async function getSecretsDefaultTypeDefinition(context) {
|
|
44
|
-
return {
|
|
45
|
-
file: await resolveRuntimeTypeFile(context),
|
|
46
|
-
name: "SecretsInterface"
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Gets the path to the environment type reflections.
|
|
51
|
-
*
|
|
52
|
-
* @param context - The plugin context.
|
|
53
|
-
* @param name - The name of the type reflections.
|
|
54
|
-
* @returns The path to the environment type reflections.
|
|
55
|
-
*/
|
|
56
|
-
function getEnvTypeReflectionsPath(context, name = "env") {
|
|
57
|
-
return (0, __stryke_path_join_paths.joinPaths)(require_resolve_reflections.getReflectionsPath(context), "env", `${name}-types.bin`);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Reads the environment type reflection from the file system.
|
|
61
|
-
*
|
|
62
|
-
* @param context - The plugin context.
|
|
63
|
-
* @param name - The name of the type reflections.
|
|
64
|
-
* @returns The environment type reflection.
|
|
65
|
-
*/
|
|
66
|
-
async function readEnvTypeReflection(context, name = "env") {
|
|
67
|
-
const filePath = getEnvTypeReflectionsPath(context, name);
|
|
68
|
-
if (!(0, node_fs.existsSync)(filePath)) {
|
|
69
|
-
if (!context.env.types.env || (0, __stryke_type_checks_is_empty_object.isEmptyObject)(context.env.types.env)) {
|
|
70
|
-
const reflection$1 = require_reflect.createEnvReflection(context);
|
|
71
|
-
const message = new __stryke_capnp.Message();
|
|
72
|
-
reflection$1.messageRoot = message.initRoot(require_reflection.SerializedTypes);
|
|
73
|
-
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
74
|
-
context.env.types.env = reflection$1;
|
|
75
|
-
await writeEnvTypeReflection(context, context.env.types.env, name);
|
|
76
|
-
}
|
|
77
|
-
return context.env.types.env;
|
|
78
|
-
}
|
|
79
|
-
const buffer = await (0, __stryke_fs_buffer.readFileBuffer)(filePath);
|
|
80
|
-
const messageRoot = new __stryke_capnp.Message(buffer, false).getRoot(require_reflection.SerializedTypes);
|
|
81
|
-
const reflection = (0, __powerlines_deepkit_vendor_type.resolveClassType)((0, __powerlines_deepkit_vendor_type.deserializeType)(require_capnp.convertFromCapnp(messageRoot.types)));
|
|
82
|
-
context.env.types[name] = reflection;
|
|
83
|
-
context.env.types[name].messageRoot = messageRoot;
|
|
84
|
-
context.env.types[name].dataBuffer = buffer;
|
|
85
|
-
return reflection;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Writes the environment type reflection to the file system.
|
|
89
|
-
*
|
|
90
|
-
* @param context - The plugin context.
|
|
91
|
-
* @param reflection - The environment type reflection to write.
|
|
92
|
-
* @param name - The name of the type reflections.
|
|
93
|
-
*/
|
|
94
|
-
async function writeEnvTypeReflection(context, reflection, name = "env") {
|
|
95
|
-
const serialized = reflection.serializeType();
|
|
96
|
-
const message = new __stryke_capnp.Message();
|
|
97
|
-
require_capnp.convertToCapnp(serialized, message.initRoot(require_reflection.SerializedTypes)._initTypes(serialized.length));
|
|
98
|
-
await (0, __stryke_fs_buffer.writeFileBuffer)(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
|
|
99
|
-
}
|
|
100
|
-
function getEnvReflectionsPath(context, name) {
|
|
101
|
-
return (0, __stryke_path_join_paths.joinPaths)(require_resolve_reflections.getReflectionsPath(context), "env", `${name}.bin`);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Reads the environment reflection data from the file system.
|
|
105
|
-
*
|
|
106
|
-
* @param context - The plugin context.
|
|
107
|
-
* @returns The environment reflection data.
|
|
108
|
-
*/
|
|
109
|
-
async function readEnvReflection(context) {
|
|
110
|
-
const filePath = getEnvReflectionsPath(context, "env");
|
|
111
|
-
if (!(0, node_fs.existsSync)(filePath)) {
|
|
112
|
-
if (!context.env.types.env) context.env.types.env = await readEnvTypeReflection(context, "env");
|
|
113
|
-
if (!context.env.used.env || (0, __stryke_type_checks_is_empty_object.isEmptyObject)(context.env.used.env)) {
|
|
114
|
-
const reflection$1 = require_reflect.createEnvReflection(context, {
|
|
115
|
-
type: {
|
|
116
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
117
|
-
typeName: "Env",
|
|
118
|
-
description: `An object containing the environment configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
|
|
119
|
-
types: []
|
|
120
|
-
},
|
|
121
|
-
superReflection: context.env.types.env
|
|
122
|
-
});
|
|
123
|
-
reflection$1.name = "Env";
|
|
124
|
-
const message = new __stryke_capnp.Message();
|
|
125
|
-
reflection$1.messageRoot = message.initRoot(require_reflection.SerializedTypes);
|
|
126
|
-
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
127
|
-
context.env.used.env = reflection$1;
|
|
128
|
-
await writeEnvReflection(context, context.env.used.env, "env");
|
|
129
|
-
}
|
|
130
|
-
return context.env.used.env;
|
|
131
|
-
}
|
|
132
|
-
const buffer = await (0, __stryke_fs_buffer.readFileBuffer)(filePath);
|
|
133
|
-
const messageRoot = new __stryke_capnp.Message(buffer, false).getRoot(require_reflection.SerializedTypes);
|
|
134
|
-
const reflection = (0, __powerlines_deepkit_vendor_type.resolveClassType)((0, __powerlines_deepkit_vendor_type.deserializeType)(require_capnp.convertFromCapnp(messageRoot.types)));
|
|
135
|
-
context.env.used.env = reflection;
|
|
136
|
-
context.env.used.env.messageRoot = messageRoot;
|
|
137
|
-
context.env.used.env.dataBuffer = buffer;
|
|
138
|
-
return reflection;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Reads the secret environment reflection data from the file system.
|
|
142
|
-
*
|
|
143
|
-
* @param context - The plugin context.
|
|
144
|
-
* @returns The environment reflection data.
|
|
145
|
-
*/
|
|
146
|
-
async function readSecretsReflection(context) {
|
|
147
|
-
const filePath = getEnvReflectionsPath(context, "secrets");
|
|
148
|
-
if (!(0, node_fs.existsSync)(filePath)) {
|
|
149
|
-
if (!context.env.types.secrets) context.env.types.secrets = await readEnvTypeReflection(context, "secrets");
|
|
150
|
-
if (!context.env.used.secrets || (0, __stryke_type_checks_is_empty_object.isEmptyObject)(context.env.used.secrets)) {
|
|
151
|
-
const reflection$1 = require_reflect.createEnvReflection(context, {
|
|
152
|
-
type: {
|
|
153
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
154
|
-
typeName: "Secrets",
|
|
155
|
-
description: `An object containing the secret configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
|
|
156
|
-
types: []
|
|
157
|
-
},
|
|
158
|
-
superReflection: context.env.types.secrets
|
|
159
|
-
});
|
|
160
|
-
reflection$1.name = "Secrets";
|
|
161
|
-
const message = new __stryke_capnp.Message();
|
|
162
|
-
reflection$1.messageRoot = message.initRoot(require_reflection.SerializedTypes);
|
|
163
|
-
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
164
|
-
context.env.used.secrets = reflection$1;
|
|
165
|
-
await writeEnvReflection(context, context.env.used.secrets, "secrets");
|
|
166
|
-
}
|
|
167
|
-
return context.env.used.secrets;
|
|
168
|
-
}
|
|
169
|
-
const buffer = await (0, __stryke_fs_buffer.readFileBuffer)(filePath);
|
|
170
|
-
const messageRoot = new __stryke_capnp.Message(buffer, false).getRoot(require_reflection.SerializedTypes);
|
|
171
|
-
const reflection = (0, __powerlines_deepkit_vendor_type.resolveClassType)((0, __powerlines_deepkit_vendor_type.deserializeType)(require_capnp.convertFromCapnp(messageRoot.types)));
|
|
172
|
-
context.env.used.secrets = reflection;
|
|
173
|
-
context.env.used.secrets.messageRoot = messageRoot;
|
|
174
|
-
context.env.used.secrets.dataBuffer = buffer;
|
|
175
|
-
return reflection;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Writes the environment reflection data to the file system.
|
|
179
|
-
*
|
|
180
|
-
* @param context - The plugin context.
|
|
181
|
-
* @param reflection - The reflection data to write.
|
|
182
|
-
* @param name - The name of the reflection (either "env" or "secrets").
|
|
183
|
-
*/
|
|
184
|
-
async function writeEnvReflection(context, reflection, name = "env") {
|
|
185
|
-
const serialized = reflection.serializeType();
|
|
186
|
-
const message = new __stryke_capnp.Message();
|
|
187
|
-
require_capnp.convertToCapnp(serialized, message.initRoot(require_reflection.SerializedTypes)._initTypes(serialized.length));
|
|
188
|
-
await (0, __stryke_fs_buffer.writeFileBuffer)(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
//#endregion
|
|
192
|
-
exports.getEnvDefaultTypeDefinition = getEnvDefaultTypeDefinition;
|
|
193
|
-
exports.getEnvReflectionsPath = getEnvReflectionsPath;
|
|
194
|
-
exports.getEnvTypeReflectionsPath = getEnvTypeReflectionsPath;
|
|
195
|
-
exports.getSecretsDefaultTypeDefinition = getSecretsDefaultTypeDefinition;
|
|
196
|
-
exports.readEnvReflection = readEnvReflection;
|
|
197
|
-
exports.readEnvTypeReflection = readEnvTypeReflection;
|
|
198
|
-
exports.readSecretsReflection = readSecretsReflection;
|
|
199
|
-
exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
|
|
200
|
-
exports.writeEnvReflection = writeEnvReflection;
|
|
201
|
-
exports.writeEnvTypeReflection = writeEnvTypeReflection;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { convertFromCapnp, convertToCapnp } from "../../../deepkit/src/capnp.mjs";
|
|
2
|
-
import { SerializedTypes } from "../../../deepkit/schemas/reflection2.mjs";
|
|
3
|
-
import { getReflectionsPath } from "../../../deepkit/src/resolve-reflections.mjs";
|
|
4
|
-
import { createEnvReflection } from "./reflect.mjs";
|
|
5
|
-
import { ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
6
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
7
|
-
import * as capnp from "@stryke/capnp";
|
|
8
|
-
import { readFileBuffer, writeFileBuffer } from "@stryke/fs/buffer";
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
|
-
import { isEmptyObject } from "@stryke/type-checks/is-empty-object";
|
|
11
|
-
|
|
12
|
-
//#region ../plugin-env/src/helpers/persistence.ts
|
|
13
|
-
/**
|
|
14
|
-
* Resolves the runtime type definition file for the environment variables.
|
|
15
|
-
*
|
|
16
|
-
* @param context - The plugin context.
|
|
17
|
-
* @returns The runtime type definition file for the environment variables.
|
|
18
|
-
*/
|
|
19
|
-
async function resolveRuntimeTypeFile(context) {
|
|
20
|
-
const resolved = await context.fs.resolve("@powerlines/plugin-env/types/runtime");
|
|
21
|
-
if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
|
|
22
|
-
return resolved;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Gets the default type definition for the environment variables.
|
|
26
|
-
*
|
|
27
|
-
* @param context - The plugin context.
|
|
28
|
-
* @returns The default type definition for the environment variables.
|
|
29
|
-
*/
|
|
30
|
-
async function getEnvDefaultTypeDefinition(context) {
|
|
31
|
-
return {
|
|
32
|
-
file: await resolveRuntimeTypeFile(context),
|
|
33
|
-
name: "EnvInterface"
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/** Gets the default type definition for the environment secrets.
|
|
37
|
-
*
|
|
38
|
-
* @param context - The plugin context.
|
|
39
|
-
* @returns The default type definition for the environment secrets.
|
|
40
|
-
*/
|
|
41
|
-
async function getSecretsDefaultTypeDefinition(context) {
|
|
42
|
-
return {
|
|
43
|
-
file: await resolveRuntimeTypeFile(context),
|
|
44
|
-
name: "SecretsInterface"
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Gets the path to the environment type reflections.
|
|
49
|
-
*
|
|
50
|
-
* @param context - The plugin context.
|
|
51
|
-
* @param name - The name of the type reflections.
|
|
52
|
-
* @returns The path to the environment type reflections.
|
|
53
|
-
*/
|
|
54
|
-
function getEnvTypeReflectionsPath(context, name = "env") {
|
|
55
|
-
return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Reads the environment type reflection from the file system.
|
|
59
|
-
*
|
|
60
|
-
* @param context - The plugin context.
|
|
61
|
-
* @param name - The name of the type reflections.
|
|
62
|
-
* @returns The environment type reflection.
|
|
63
|
-
*/
|
|
64
|
-
async function readEnvTypeReflection(context, name = "env") {
|
|
65
|
-
const filePath = getEnvTypeReflectionsPath(context, name);
|
|
66
|
-
if (!existsSync(filePath)) {
|
|
67
|
-
if (!context.env.types.env || isEmptyObject(context.env.types.env)) {
|
|
68
|
-
const reflection$1 = createEnvReflection(context);
|
|
69
|
-
const message = new capnp.Message();
|
|
70
|
-
reflection$1.messageRoot = message.initRoot(SerializedTypes);
|
|
71
|
-
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
72
|
-
context.env.types.env = reflection$1;
|
|
73
|
-
await writeEnvTypeReflection(context, context.env.types.env, name);
|
|
74
|
-
}
|
|
75
|
-
return context.env.types.env;
|
|
76
|
-
}
|
|
77
|
-
const buffer = await readFileBuffer(filePath);
|
|
78
|
-
const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
|
|
79
|
-
const reflection = resolveClassType(deserializeType(convertFromCapnp(messageRoot.types)));
|
|
80
|
-
context.env.types[name] = reflection;
|
|
81
|
-
context.env.types[name].messageRoot = messageRoot;
|
|
82
|
-
context.env.types[name].dataBuffer = buffer;
|
|
83
|
-
return reflection;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Writes the environment type reflection to the file system.
|
|
87
|
-
*
|
|
88
|
-
* @param context - The plugin context.
|
|
89
|
-
* @param reflection - The environment type reflection to write.
|
|
90
|
-
* @param name - The name of the type reflections.
|
|
91
|
-
*/
|
|
92
|
-
async function writeEnvTypeReflection(context, reflection, name = "env") {
|
|
93
|
-
const serialized = reflection.serializeType();
|
|
94
|
-
const message = new capnp.Message();
|
|
95
|
-
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
96
|
-
await writeFileBuffer(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
|
|
97
|
-
}
|
|
98
|
-
function getEnvReflectionsPath(context, name) {
|
|
99
|
-
return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Reads the environment reflection data from the file system.
|
|
103
|
-
*
|
|
104
|
-
* @param context - The plugin context.
|
|
105
|
-
* @returns The environment reflection data.
|
|
106
|
-
*/
|
|
107
|
-
async function readEnvReflection(context) {
|
|
108
|
-
const filePath = getEnvReflectionsPath(context, "env");
|
|
109
|
-
if (!existsSync(filePath)) {
|
|
110
|
-
if (!context.env.types.env) context.env.types.env = await readEnvTypeReflection(context, "env");
|
|
111
|
-
if (!context.env.used.env || isEmptyObject(context.env.used.env)) {
|
|
112
|
-
const reflection$1 = createEnvReflection(context, {
|
|
113
|
-
type: {
|
|
114
|
-
kind: ReflectionKind.objectLiteral,
|
|
115
|
-
typeName: "Env",
|
|
116
|
-
description: `An object containing the environment configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
|
|
117
|
-
types: []
|
|
118
|
-
},
|
|
119
|
-
superReflection: context.env.types.env
|
|
120
|
-
});
|
|
121
|
-
reflection$1.name = "Env";
|
|
122
|
-
const message = new capnp.Message();
|
|
123
|
-
reflection$1.messageRoot = message.initRoot(SerializedTypes);
|
|
124
|
-
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
125
|
-
context.env.used.env = reflection$1;
|
|
126
|
-
await writeEnvReflection(context, context.env.used.env, "env");
|
|
127
|
-
}
|
|
128
|
-
return context.env.used.env;
|
|
129
|
-
}
|
|
130
|
-
const buffer = await readFileBuffer(filePath);
|
|
131
|
-
const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
|
|
132
|
-
const reflection = resolveClassType(deserializeType(convertFromCapnp(messageRoot.types)));
|
|
133
|
-
context.env.used.env = reflection;
|
|
134
|
-
context.env.used.env.messageRoot = messageRoot;
|
|
135
|
-
context.env.used.env.dataBuffer = buffer;
|
|
136
|
-
return reflection;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Reads the secret environment reflection data from the file system.
|
|
140
|
-
*
|
|
141
|
-
* @param context - The plugin context.
|
|
142
|
-
* @returns The environment reflection data.
|
|
143
|
-
*/
|
|
144
|
-
async function readSecretsReflection(context) {
|
|
145
|
-
const filePath = getEnvReflectionsPath(context, "secrets");
|
|
146
|
-
if (!existsSync(filePath)) {
|
|
147
|
-
if (!context.env.types.secrets) context.env.types.secrets = await readEnvTypeReflection(context, "secrets");
|
|
148
|
-
if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {
|
|
149
|
-
const reflection$1 = createEnvReflection(context, {
|
|
150
|
-
type: {
|
|
151
|
-
kind: ReflectionKind.objectLiteral,
|
|
152
|
-
typeName: "Secrets",
|
|
153
|
-
description: `An object containing the secret configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
|
|
154
|
-
types: []
|
|
155
|
-
},
|
|
156
|
-
superReflection: context.env.types.secrets
|
|
157
|
-
});
|
|
158
|
-
reflection$1.name = "Secrets";
|
|
159
|
-
const message = new capnp.Message();
|
|
160
|
-
reflection$1.messageRoot = message.initRoot(SerializedTypes);
|
|
161
|
-
reflection$1.dataBuffer = message.toArrayBuffer();
|
|
162
|
-
context.env.used.secrets = reflection$1;
|
|
163
|
-
await writeEnvReflection(context, context.env.used.secrets, "secrets");
|
|
164
|
-
}
|
|
165
|
-
return context.env.used.secrets;
|
|
166
|
-
}
|
|
167
|
-
const buffer = await readFileBuffer(filePath);
|
|
168
|
-
const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
|
|
169
|
-
const reflection = resolveClassType(deserializeType(convertFromCapnp(messageRoot.types)));
|
|
170
|
-
context.env.used.secrets = reflection;
|
|
171
|
-
context.env.used.secrets.messageRoot = messageRoot;
|
|
172
|
-
context.env.used.secrets.dataBuffer = buffer;
|
|
173
|
-
return reflection;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Writes the environment reflection data to the file system.
|
|
177
|
-
*
|
|
178
|
-
* @param context - The plugin context.
|
|
179
|
-
* @param reflection - The reflection data to write.
|
|
180
|
-
* @param name - The name of the reflection (either "env" or "secrets").
|
|
181
|
-
*/
|
|
182
|
-
async function writeEnvReflection(context, reflection, name = "env") {
|
|
183
|
-
const serialized = reflection.serializeType();
|
|
184
|
-
const message = new capnp.Message();
|
|
185
|
-
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
186
|
-
await writeFileBuffer(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
//#endregion
|
|
190
|
-
export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvTypeReflection };
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_reflect_type = require('../../../deepkit/src/reflect-type.cjs');
|
|
3
|
-
const require_persistence = require('./persistence.cjs');
|
|
4
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
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 ../plugin-env/src/helpers/reflect.ts
|
|
10
|
-
function mergeEnvReflections(context, reflections) {
|
|
11
|
-
return createEnvReflection(context, { type: (0, __powerlines_deepkit_vendor_type.merge)(reflections.map((reflection) => reflection.type)) });
|
|
12
|
-
}
|
|
13
|
-
function mergeSecretsReflections(context, reflections) {
|
|
14
|
-
return createSecretsReflection(context, { type: (0, __powerlines_deepkit_vendor_type.merge)(reflections.map((reflection) => reflection.type)) });
|
|
15
|
-
}
|
|
16
|
-
var BaseEnv = class {
|
|
17
|
-
APP_NAME;
|
|
18
|
-
APP_VERSION;
|
|
19
|
-
BUILD_ID;
|
|
20
|
-
BUILD_TIMESTAMP;
|
|
21
|
-
BUILD_CHECKSUM;
|
|
22
|
-
RELEASE_ID;
|
|
23
|
-
RELEASE_TAG;
|
|
24
|
-
ORGANIZATION;
|
|
25
|
-
PLATFORM = "neutral";
|
|
26
|
-
MODE = "production";
|
|
27
|
-
ENVIRONMENT;
|
|
28
|
-
DEBUG = false;
|
|
29
|
-
TEST = false;
|
|
30
|
-
MINIMAL = false;
|
|
31
|
-
NO_COLOR = false;
|
|
32
|
-
FORCE_COLOR = false;
|
|
33
|
-
FORCE_HYPERLINK = false;
|
|
34
|
-
STACKTRACE = false;
|
|
35
|
-
INCLUDE_ERROR_DATA = false;
|
|
36
|
-
ERROR_URL;
|
|
37
|
-
DEFAULT_TIMEZONE;
|
|
38
|
-
DEFAULT_LOCALE;
|
|
39
|
-
CI = false;
|
|
40
|
-
};
|
|
41
|
-
var BaseSecrets = class {
|
|
42
|
-
ENCRYPTION_KEY;
|
|
43
|
-
};
|
|
44
|
-
function createEnvReflection(context, options = {}) {
|
|
45
|
-
const parent = options.superReflection ?? new __powerlines_deepkit_vendor_type.ReflectionClass({
|
|
46
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.class,
|
|
47
|
-
description: `The base environment configuration definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
48
|
-
classType: BaseEnv,
|
|
49
|
-
types: [],
|
|
50
|
-
implements: [{
|
|
51
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
52
|
-
typeName: "EnvInterface",
|
|
53
|
-
description: `The environment configuration interface definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
54
|
-
types: []
|
|
55
|
-
}]
|
|
56
|
-
});
|
|
57
|
-
parent.name = "Env";
|
|
58
|
-
const result = new __powerlines_deepkit_vendor_type.ReflectionClass(options.type ?? {
|
|
59
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
60
|
-
typeName: "Env",
|
|
61
|
-
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"}.`,
|
|
62
|
-
types: []
|
|
63
|
-
}, parent);
|
|
64
|
-
result.name = "Env";
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
function createSecretsReflection(context, options = {}) {
|
|
68
|
-
const parent = options.superReflection ?? new __powerlines_deepkit_vendor_type.ReflectionClass({
|
|
69
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.class,
|
|
70
|
-
description: `The base secrets configuration definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
71
|
-
classType: BaseSecrets,
|
|
72
|
-
types: [],
|
|
73
|
-
implements: [{
|
|
74
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
75
|
-
typeName: "SecretsInterface",
|
|
76
|
-
description: `The secrets configuration interface definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
|
|
77
|
-
types: []
|
|
78
|
-
}]
|
|
79
|
-
});
|
|
80
|
-
parent.name = "Secrets";
|
|
81
|
-
const result = new __powerlines_deepkit_vendor_type.ReflectionClass(options.type ?? {
|
|
82
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
83
|
-
typeName: "Secrets",
|
|
84
|
-
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"}.`,
|
|
85
|
-
types: []
|
|
86
|
-
}, parent);
|
|
87
|
-
result.name = "Secrets";
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
async function reflectEnv(context, file, name) {
|
|
91
|
-
let config;
|
|
92
|
-
if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await require_reflect_type.reflectType(context, {
|
|
93
|
-
file: !(0, __stryke_path_is_parent_path.isParentPath)(file, context.workspaceConfig.workspaceRoot) ? (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, file) : file,
|
|
94
|
-
name
|
|
95
|
-
}));
|
|
96
|
-
const defaultConfigType = await require_reflect_type.reflectType(context, await require_persistence.getEnvDefaultTypeDefinition(context));
|
|
97
|
-
return mergeEnvReflections(context, [
|
|
98
|
-
await require_persistence.readEnvTypeReflection(context, "env"),
|
|
99
|
-
config,
|
|
100
|
-
(0, __powerlines_deepkit_vendor_type.resolveClassType)(defaultConfigType)
|
|
101
|
-
].filter(Boolean));
|
|
102
|
-
}
|
|
103
|
-
async function reflectSecrets(context, file, name) {
|
|
104
|
-
let config;
|
|
105
|
-
if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await require_reflect_type.reflectType(context, {
|
|
106
|
-
file: !(0, __stryke_path_is_parent_path.isParentPath)(file, context.workspaceConfig.workspaceRoot) ? (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, file) : file,
|
|
107
|
-
name
|
|
108
|
-
}));
|
|
109
|
-
const defaultSecretsType = await require_reflect_type.reflectType(context, await require_persistence.getSecretsDefaultTypeDefinition(context));
|
|
110
|
-
return mergeSecretsReflections(context, [
|
|
111
|
-
await require_persistence.readSecretsReflection(context),
|
|
112
|
-
config,
|
|
113
|
-
(0, __powerlines_deepkit_vendor_type.resolveClassType)(defaultSecretsType)
|
|
114
|
-
].filter(Boolean));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
//#endregion
|
|
118
|
-
exports.BaseEnv = BaseEnv;
|
|
119
|
-
exports.BaseSecrets = BaseSecrets;
|
|
120
|
-
exports.createEnvReflection = createEnvReflection;
|
|
121
|
-
exports.createSecretsReflection = createSecretsReflection;
|
|
122
|
-
exports.mergeEnvReflections = mergeEnvReflections;
|
|
123
|
-
exports.mergeSecretsReflections = mergeSecretsReflections;
|
|
124
|
-
exports.reflectEnv = reflectEnv;
|
|
125
|
-
exports.reflectSecrets = reflectSecrets;
|