@powerlines/plugin-nodejs 0.1.7 → 0.1.9

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.
Files changed (127) hide show
  1. package/dist/components/env.cjs +14 -14
  2. package/dist/components/env.mjs +6 -6
  3. package/dist/index.cjs +8 -6
  4. package/dist/index.mjs +5 -5
  5. package/dist/plugin-alloy/src/types/components.d.mts +1 -2
  6. package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +1 -1
  7. package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +2 -2
  8. package/dist/plugin-automd/src/types/plugin.d.mts +1 -3
  9. package/dist/plugin-env/src/types/plugin.d.mts +1 -2
  10. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -2
  11. package/dist/powerlines/src/types/build.d.mts +6 -6
  12. package/dist/powerlines/src/types/commands.d.mts +0 -1
  13. package/dist/powerlines/src/types/config.d.mts +2 -3
  14. package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
  15. package/dist/powerlines/src/types/unplugin.d.mts +0 -1
  16. package/package.json +11 -9
  17. package/dist/deepkit/schemas/reflection.cjs +0 -3940
  18. package/dist/deepkit/schemas/reflection.mjs +0 -3938
  19. package/dist/deepkit/schemas/reflection2.cjs +0 -4112
  20. package/dist/deepkit/schemas/reflection2.mjs +0 -4110
  21. package/dist/deepkit/src/capnp.cjs +0 -913
  22. package/dist/deepkit/src/capnp.mjs +0 -911
  23. package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
  24. package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
  25. package/dist/deepkit/src/reflect-type.cjs +0 -22
  26. package/dist/deepkit/src/reflect-type.mjs +0 -20
  27. package/dist/deepkit/src/resolve-reflections.cjs +0 -16
  28. package/dist/deepkit/src/resolve-reflections.mjs +0 -15
  29. package/dist/deepkit/src/transformer.cjs +0 -52
  30. package/dist/deepkit/src/transformer.mjs +0 -49
  31. package/dist/deepkit/src/transpile.cjs +0 -29
  32. package/dist/deepkit/src/transpile.mjs +0 -27
  33. package/dist/deepkit/src/utilities.cjs +0 -66
  34. package/dist/deepkit/src/utilities.mjs +0 -65
  35. package/dist/plugin-alloy/src/core/components/output.cjs +0 -45
  36. package/dist/plugin-alloy/src/core/components/output.mjs +0 -44
  37. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -22
  38. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -21
  39. package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -64
  40. package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -62
  41. package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
  42. package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
  43. package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
  44. package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
  45. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
  46. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
  47. package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
  48. package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
  49. package/dist/plugin-alloy/src/index.cjs +0 -106
  50. package/dist/plugin-alloy/src/index.mjs +0 -104
  51. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -7
  52. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -9
  53. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -5
  54. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -7
  55. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -17
  56. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
  57. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -57
  58. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -56
  59. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -126
  60. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -124
  61. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -442
  62. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -433
  63. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -212
  64. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -209
  65. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -68
  66. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -67
  67. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -124
  68. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -123
  69. package/dist/plugin-automd/src/index.cjs +0 -101
  70. package/dist/plugin-automd/src/index.mjs +0 -98
  71. package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
  72. package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
  73. package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
  74. package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
  75. package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
  76. package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
  77. package/dist/plugin-babel/src/helpers/index.cjs +0 -5
  78. package/dist/plugin-babel/src/helpers/index.mjs +0 -7
  79. package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
  80. package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
  81. package/dist/plugin-babel/src/helpers/options.cjs +0 -50
  82. package/dist/plugin-babel/src/helpers/options.mjs +0 -47
  83. package/dist/plugin-babel/src/index.cjs +0 -91
  84. package/dist/plugin-babel/src/index.mjs +0 -89
  85. package/dist/plugin-babel/src/types/index.d.mts +0 -1
  86. package/dist/plugin-env/src/babel/index.cjs +0 -1
  87. package/dist/plugin-env/src/babel/index.mjs +0 -3
  88. package/dist/plugin-env/src/babel/plugin.cjs +0 -121
  89. package/dist/plugin-env/src/babel/plugin.mjs +0 -119
  90. package/dist/plugin-env/src/components/docs.cjs +0 -9
  91. package/dist/plugin-env/src/components/docs.mjs +0 -11
  92. package/dist/plugin-env/src/components/env.cjs +0 -575
  93. package/dist/plugin-env/src/components/env.mjs +0 -572
  94. package/dist/plugin-env/src/components/index.cjs +0 -2
  95. package/dist/plugin-env/src/components/index.mjs +0 -4
  96. package/dist/plugin-env/src/helpers/automd-generator.cjs +0 -22
  97. package/dist/plugin-env/src/helpers/automd-generator.mjs +0 -21
  98. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +0 -55
  99. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +0 -54
  100. package/dist/plugin-env/src/helpers/index.cjs +0 -6
  101. package/dist/plugin-env/src/helpers/index.mjs +0 -8
  102. package/dist/plugin-env/src/helpers/load.cjs +0 -83
  103. package/dist/plugin-env/src/helpers/load.mjs +0 -80
  104. package/dist/plugin-env/src/helpers/persistence.cjs +0 -201
  105. package/dist/plugin-env/src/helpers/persistence.mjs +0 -190
  106. package/dist/plugin-env/src/helpers/reflect.cjs +0 -111
  107. package/dist/plugin-env/src/helpers/reflect.mjs +0 -103
  108. package/dist/plugin-env/src/helpers/source-file-env.cjs +0 -24
  109. package/dist/plugin-env/src/helpers/source-file-env.mjs +0 -23
  110. package/dist/plugin-env/src/helpers/template-helpers.cjs +0 -2
  111. package/dist/plugin-env/src/helpers/template-helpers.mjs +0 -4
  112. package/dist/plugin-env/src/index.cjs +0 -175
  113. package/dist/plugin-env/src/index.mjs +0 -173
  114. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  115. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  116. package/dist/powerlines/src/lib/entry.cjs +0 -12
  117. package/dist/powerlines/src/lib/entry.mjs +0 -14
  118. package/dist/powerlines/src/lib/logger.cjs +0 -41
  119. package/dist/powerlines/src/lib/logger.mjs +0 -39
  120. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -38
  121. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -35
  122. package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
  123. package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
  124. package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
  125. package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
  126. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
  127. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
@@ -1,54 +0,0 @@
1
- import { readEnvTypeReflection } from "./persistence.mjs";
2
- import { loadEnvFromContext } from "./load.mjs";
3
- import { titleCase } from "@stryke/string-format/title-case";
4
- import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
5
- import { computed, createResource } from "@alloy-js/core";
6
-
7
- //#region ../plugin-env/src/helpers/create-reflection-resource.ts
8
- /**
9
- * Creates a reflection resource for the environment configuration.
10
- *
11
- * @param context - The environment plugin context.
12
- * @returns A resource that provides the reflection of the environment configuration.
13
- */
14
- function createReflectionResource(context) {
15
- const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
16
- return createResource(async () => {
17
- if (!context) return new ReflectionClass({
18
- kind: ReflectionKind.objectLiteral,
19
- description: `The initial environment configuration state for the Powerlines project.`,
20
- types: []
21
- });
22
- const result = await readEnvTypeReflection(context, "env");
23
- result.getProperties().forEach((prop) => {
24
- prop.getAlias().filter(Boolean).forEach((alias) => {
25
- result.addProperty({
26
- name: alias,
27
- optional: prop.isOptional() ? true : void 0,
28
- readonly: prop.isReadonly() ? true : void 0,
29
- description: prop.getDescription(),
30
- visibility: prop.getVisibility(),
31
- type: prop.getType(),
32
- default: prop.getDefaultValue(),
33
- tags: {
34
- hidden: prop.isHidden(),
35
- ignore: prop.isIgnored(),
36
- internal: prop.isInternal(),
37
- alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
38
- title: prop.getTitle() || titleCase(prop.name),
39
- readonly: prop.isReadonly(),
40
- permission: prop.getPermission(),
41
- domain: prop.getDomain()
42
- }
43
- });
44
- });
45
- });
46
- result.getProperties().forEach((prop) => {
47
- prop.setDefaultValue(defaultValue.value?.[prop.getNameAsString()] ?? prop.getAlias().reduce((ret, alias) => ret ?? defaultValue.value?.[alias], void 0) ?? prop.getDefaultValue());
48
- });
49
- return result;
50
- });
51
- }
52
-
53
- //#endregion
54
- export { createReflectionResource };
@@ -1,6 +0,0 @@
1
- const require_reflect = require('./reflect.cjs');
2
- const require_persistence = require('./persistence.cjs');
3
- const require_source_file_env = require('./source-file-env.cjs');
4
- const require_load = require('./load.cjs');
5
- const require_create_reflection_resource = require('./create-reflection-resource.cjs');
6
- require('./template-helpers.cjs');
@@ -1,8 +0,0 @@
1
- import { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./reflect.mjs";
2
- import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvTypeReflection } from "./persistence.mjs";
3
- import { removeEnvPrefix } from "./source-file-env.mjs";
4
- import { loadEnv, loadEnvFromContext } from "./load.mjs";
5
- import { createReflectionResource } from "./create-reflection-resource.mjs";
6
- import "./template-helpers.mjs";
7
-
8
- export { };
@@ -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_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
4
- let defu = require("defu");
5
- defu = require_rolldown_runtime.__toESM(defu);
6
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
7
- let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
8
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
9
- let c12 = require("c12");
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 { isSetObject } from "@stryke/type-checks/is-set-object";
3
- import defu from "defu";
4
- import { isSetString } from "@stryke/type-checks/is-set-string";
5
- import { kebabCase } from "@stryke/string-format/kebab-case";
6
- import { joinPaths } from "@stryke/path/join-paths";
7
- import { loadConfig } from "c12";
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 };