@powerlines/plugin-env 0.16.67 → 0.16.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +0 -2
- package/dist/_virtual/_rolldown/runtime.mjs +2 -31
- package/dist/helpers/load.cjs +4 -4
- package/dist/helpers/load.mjs +2 -2
- package/dist/helpers/load.mjs.map +1 -1
- package/package.json +11 -26
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs +0 -346
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs +0 -347
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.cjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.cjs +0 -10
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.cjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.cjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.cjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.cjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.cjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.cjs +0 -13
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs +0 -14
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.cjs +0 -285
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs +0 -283
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.cjs +0 -71
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs +0 -69
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs.map +0 -1
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1008
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.cjs +0 -23
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +0 -14
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +0 -2695
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -2683
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs +0 -4457
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs +0 -4455
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.cjs +0 -29
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs +0 -30
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -181
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -177
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -22
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3967
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3963
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.cjs +0 -11766
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs +0 -11762
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -25
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs +0 -21
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.cjs +0 -20
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.cjs +0 -178
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs +0 -176
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.cjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.cjs +0 -3
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs +0 -3
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -145
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -139
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map +0 -1
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -128
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -127
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +0 -138
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +0 -137
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.cjs +0 -629
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs +0 -628
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs.map +0 -1
|
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
9
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
10
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -27,5 +26,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
26
|
|
|
28
27
|
//#endregion
|
|
29
28
|
|
|
30
|
-
exports.__commonJSMin = __commonJSMin;
|
|
31
29
|
exports.__toESM = __toESM;
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "node:module";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
-
key = keys[i];
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
-
__defProp(to, key, {
|
|
17
|
-
get: ((k) => from[k]).bind(null, key),
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
-
value: mod,
|
|
27
|
-
enumerable: true
|
|
28
|
-
}) : target, mod));
|
|
29
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { __commonJSMin, __require, __toESM };
|
|
3
|
+
export { };
|
package/dist/helpers/load.cjs
CHANGED
|
@@ -2,15 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
4
|
const require_helpers_source_file_env = require('./source-file-env.cjs');
|
|
5
|
-
const require_index = require('../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs');
|
|
6
5
|
let powerlines = require("powerlines");
|
|
7
6
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
8
7
|
let _stryke_env_load_env = require("@stryke/env/load-env");
|
|
9
8
|
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
10
9
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
10
|
+
let c12 = require("c12");
|
|
11
11
|
let defu = require("defu");
|
|
12
12
|
defu = require_runtime.__toESM(defu);
|
|
13
|
-
let
|
|
13
|
+
let powerlines_constants = require("powerlines/constants");
|
|
14
14
|
|
|
15
15
|
//#region src/helpers/load.ts
|
|
16
16
|
function __assignType(fn, args) {
|
|
@@ -38,7 +38,7 @@ loadEnvFiles.__type = [
|
|
|
38
38
|
"Pn!2\"&2#&2$\"`/%"
|
|
39
39
|
];
|
|
40
40
|
async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
|
|
41
|
-
const [envResult, c12Result] = await Promise.all([(loadEnvFiles.Ω = [["!"]], loadEnvFiles(options, mode, directory)),
|
|
41
|
+
const [envResult, c12Result] = await Promise.all([(loadEnvFiles.Ω = [["!"]], loadEnvFiles(options, mode, directory)), (0, c12.loadConfig)({
|
|
42
42
|
cwd: directory,
|
|
43
43
|
name: "storm",
|
|
44
44
|
envName: mode,
|
|
@@ -95,7 +95,7 @@ function loadEnvFromContext(context, parsed) {
|
|
|
95
95
|
TEST: context.config.mode === "test",
|
|
96
96
|
DEBUG: context.config.mode === "development",
|
|
97
97
|
STACKTRACE: context.config.mode !== "production",
|
|
98
|
-
ENVIRONMENT: !context.environment.name || context.environment.name ===
|
|
98
|
+
ENVIRONMENT: !context.environment.name || context.environment.name === powerlines_constants.DEFAULT_ENVIRONMENT ? context.config.mode : context.environment.name
|
|
99
99
|
}, (0, _stryke_type_checks_is_set_object.isSetObject)(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce(__assignType((ret, prop) => {
|
|
100
100
|
ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
|
|
101
101
|
return ret;
|
package/dist/helpers/load.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "../types/plugin.mjs";
|
|
2
2
|
import { removeEnvPrefix } from "./source-file-env.mjs";
|
|
3
|
-
import { loadConfig } from "../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs";
|
|
4
3
|
import { __ΩWorkspaceConfig } from "powerlines";
|
|
5
4
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
6
5
|
import { loadEnv as loadEnv$1, loadEnvFile } from "@stryke/env/load-env";
|
|
7
6
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
8
7
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
+
import { loadConfig } from "c12";
|
|
9
9
|
import defu from "defu";
|
|
10
|
-
import { DEFAULT_ENVIRONMENT } from "powerlines/
|
|
10
|
+
import { DEFAULT_ENVIRONMENT } from "powerlines/constants";
|
|
11
11
|
|
|
12
12
|
//#region src/helpers/load.ts
|
|
13
13
|
function __assignType(fn, args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/
|
|
1
|
+
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: workspaceConfig.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput\n) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-env",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.68",
|
|
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"],
|
|
@@ -306,10 +306,10 @@
|
|
|
306
306
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
307
307
|
"@babel/core": "^7.29.0",
|
|
308
308
|
"@babel/types": "^7.29.0",
|
|
309
|
-
"@powerlines/plugin-alloy": "^0.25.
|
|
310
|
-
"@powerlines/plugin-automd": "^0.1.
|
|
311
|
-
"@powerlines/plugin-babel": "^0.12.
|
|
312
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
309
|
+
"@powerlines/plugin-alloy": "^0.25.33",
|
|
310
|
+
"@powerlines/plugin-automd": "^0.1.348",
|
|
311
|
+
"@powerlines/plugin-babel": "^0.12.351",
|
|
312
|
+
"@powerlines/plugin-plugin": "^0.12.299",
|
|
313
313
|
"@storm-software/config-tools": "1.189.28",
|
|
314
314
|
"@stryke/capnp": "^0.12.83",
|
|
315
315
|
"@stryke/convert": "^0.6.53",
|
|
@@ -322,30 +322,15 @@
|
|
|
322
322
|
"@stryke/types": "^0.10.52",
|
|
323
323
|
"automd": "^0.4.3",
|
|
324
324
|
"defu": "^6.1.4",
|
|
325
|
-
"powerlines": "^0.41.
|
|
325
|
+
"powerlines": "^0.41.13",
|
|
326
|
+
"c12": "^3.3.3"
|
|
326
327
|
},
|
|
327
328
|
"devDependencies": {
|
|
328
|
-
"@powerlines/deepkit": "^0.6.
|
|
329
|
-
"@powerlines/plugin-deepkit": "^0.11.
|
|
329
|
+
"@powerlines/deepkit": "^0.6.127",
|
|
330
|
+
"@powerlines/plugin-deepkit": "^0.11.227",
|
|
330
331
|
"@types/node": "^25.5.0",
|
|
331
|
-
"vite": "8.0.0
|
|
332
|
+
"vite": "^8.0.0"
|
|
332
333
|
},
|
|
333
334
|
"publishConfig": { "access": "public" },
|
|
334
|
-
"
|
|
335
|
-
"c12": "3.3.3",
|
|
336
|
-
"confbox": "0.2.4",
|
|
337
|
-
"destr": "2.0.5",
|
|
338
|
-
"dotenv": "17.3.1",
|
|
339
|
-
"exsolve": "1.0.8",
|
|
340
|
-
"giget": "2.0.0",
|
|
341
|
-
"jiti": "2.6.1",
|
|
342
|
-
"node-fetch-native": "1.6.7",
|
|
343
|
-
"nypm": "0.6.5",
|
|
344
|
-
"ohash": "2.0.11",
|
|
345
|
-
"pathe": "2.0.3",
|
|
346
|
-
"pkg-types": "2.3.0",
|
|
347
|
-
"rc9": "2.1.2",
|
|
348
|
-
"tinyexec": "1.0.2"
|
|
349
|
-
},
|
|
350
|
-
"gitHead": "84f84362520b3532ac14ac03d6f634066e966127"
|
|
335
|
+
"gitHead": "0fcc7a33523c8b70c1b5f65684a8b6a15ab68eba"
|
|
351
336
|
}
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_pathe_M_eThtNZ = require('../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs');
|
|
3
|
-
const require_main$1 = require('../../../../dotenv@17.3.1/node_modules/dotenv/lib/main.cjs');
|
|
4
|
-
const require_index = require('../../../../exsolve@1.0.8/node_modules/exsolve/dist/index.cjs');
|
|
5
|
-
const require_jiti = require('../../../../jiti@2.6.1/node_modules/jiti/lib/jiti.cjs');
|
|
6
|
-
const require_index$1 = require('../../../../rc9@2.1.2/node_modules/rc9/dist/index.cjs');
|
|
7
|
-
const require_index$2 = require('../../../../pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs');
|
|
8
|
-
let node_fs = require("node:fs");
|
|
9
|
-
let node_os = require("node:os");
|
|
10
|
-
let node_fs_promises = require("node:fs/promises");
|
|
11
|
-
let node_url = require("node:url");
|
|
12
|
-
let defu = require("defu");
|
|
13
|
-
|
|
14
|
-
//#region ../../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs
|
|
15
|
-
var import_main = /* @__PURE__ */ require_runtime.__toESM(require_main$1.default, 1);
|
|
16
|
-
/**
|
|
17
|
-
* Load and interpolate environment variables into `process.env`.
|
|
18
|
-
* If you need more control (or access to the values), consider using `loadDotenv` instead
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
async function setupDotenv(options) {
|
|
22
|
-
const targetEnvironment = options.env ?? process.env;
|
|
23
|
-
const environment = await loadDotenv({
|
|
24
|
-
cwd: options.cwd,
|
|
25
|
-
fileName: options.fileName ?? ".env",
|
|
26
|
-
env: targetEnvironment,
|
|
27
|
-
interpolate: options.interpolate ?? true
|
|
28
|
-
});
|
|
29
|
-
const dotenvVars = getDotEnvVars(targetEnvironment);
|
|
30
|
-
for (const key in environment) {
|
|
31
|
-
if (key.startsWith("_")) continue;
|
|
32
|
-
if (targetEnvironment[key] === void 0 || dotenvVars.has(key)) targetEnvironment[key] = environment[key];
|
|
33
|
-
}
|
|
34
|
-
return environment;
|
|
35
|
-
}
|
|
36
|
-
/** Load environment variables into an object. */
|
|
37
|
-
async function loadDotenv(options) {
|
|
38
|
-
const environment = Object.create(null);
|
|
39
|
-
const cwd = require_pathe_M_eThtNZ.resolve(options.cwd || ".");
|
|
40
|
-
const _fileName = options.fileName || ".env";
|
|
41
|
-
const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
|
|
42
|
-
const dotenvVars = getDotEnvVars(options.env || {});
|
|
43
|
-
Object.assign(environment, options.env);
|
|
44
|
-
for (const file of dotenvFiles) {
|
|
45
|
-
const dotenvFile = require_pathe_M_eThtNZ.resolve(cwd, file);
|
|
46
|
-
if (!(0, node_fs.statSync)(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
|
|
47
|
-
const parsed = import_main.parse(await node_fs.promises.readFile(dotenvFile, "utf8"));
|
|
48
|
-
for (const key in parsed) {
|
|
49
|
-
if (key in environment && !dotenvVars.has(key)) continue;
|
|
50
|
-
environment[key] = parsed[key];
|
|
51
|
-
dotenvVars.add(key);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (options.interpolate) interpolate(environment);
|
|
55
|
-
return environment;
|
|
56
|
-
}
|
|
57
|
-
function interpolate(target, source = {}, parse = (v) => v) {
|
|
58
|
-
function getValue(key) {
|
|
59
|
-
return source[key] === void 0 ? target[key] : source[key];
|
|
60
|
-
}
|
|
61
|
-
function interpolate$1(value, parents = []) {
|
|
62
|
-
if (typeof value !== "string") return value;
|
|
63
|
-
return parse((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
|
|
64
|
-
const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
|
|
65
|
-
const prefix = parts[1];
|
|
66
|
-
let value$1, replacePart;
|
|
67
|
-
if (prefix === "\\") {
|
|
68
|
-
replacePart = parts[0] || "";
|
|
69
|
-
value$1 = replacePart.replace(String.raw`\$`, "$");
|
|
70
|
-
} else {
|
|
71
|
-
const key = parts[2];
|
|
72
|
-
replacePart = (parts[0] || "").slice(prefix.length);
|
|
73
|
-
if (parents.includes(key)) {
|
|
74
|
-
console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${key} )`);
|
|
75
|
-
return "";
|
|
76
|
-
}
|
|
77
|
-
value$1 = getValue(key);
|
|
78
|
-
value$1 = interpolate$1(value$1, [...parents, key]);
|
|
79
|
-
}
|
|
80
|
-
return value$1 === void 0 ? newValue : newValue.replace(replacePart, value$1);
|
|
81
|
-
}, value));
|
|
82
|
-
}
|
|
83
|
-
for (const key in target) target[key] = interpolate$1(getValue(key));
|
|
84
|
-
}
|
|
85
|
-
function getDotEnvVars(targetEnvironment) {
|
|
86
|
-
const globalRegistry = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
|
|
87
|
-
if (!globalRegistry.has(targetEnvironment)) globalRegistry.set(targetEnvironment, /* @__PURE__ */ new Set());
|
|
88
|
-
return globalRegistry.get(targetEnvironment);
|
|
89
|
-
}
|
|
90
|
-
const _normalize = (p) => p?.replace(/\\/g, "/");
|
|
91
|
-
const ASYNC_LOADERS = {
|
|
92
|
-
".yaml": () => Promise.resolve().then(() => require("../../../../confbox@0.2.4/node_modules/confbox/dist/yaml.cjs")).then((r) => r.parseYAML),
|
|
93
|
-
".yml": () => Promise.resolve().then(() => require("../../../../confbox@0.2.4/node_modules/confbox/dist/yaml.cjs")).then((r) => r.parseYAML),
|
|
94
|
-
".jsonc": () => Promise.resolve().then(() => require("../../../../confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs")).then((r) => r.parseJSONC),
|
|
95
|
-
".json5": () => Promise.resolve().then(() => require("../../../../confbox@0.2.4/node_modules/confbox/dist/json5.cjs")).then((r) => r.parseJSON5),
|
|
96
|
-
".toml": () => Promise.resolve().then(() => require("../../../../confbox@0.2.4/node_modules/confbox/dist/toml.cjs")).then((r) => r.parseTOML)
|
|
97
|
-
};
|
|
98
|
-
const SUPPORTED_EXTENSIONS = Object.freeze([
|
|
99
|
-
".js",
|
|
100
|
-
".ts",
|
|
101
|
-
".mjs",
|
|
102
|
-
".cjs",
|
|
103
|
-
".mts",
|
|
104
|
-
".cts",
|
|
105
|
-
".json",
|
|
106
|
-
".jsonc",
|
|
107
|
-
".json5",
|
|
108
|
-
".yaml",
|
|
109
|
-
".yml",
|
|
110
|
-
".toml"
|
|
111
|
-
]);
|
|
112
|
-
async function loadConfig(options) {
|
|
113
|
-
options.cwd = require_pathe_M_eThtNZ.resolve(process.cwd(), options.cwd || ".");
|
|
114
|
-
options.name = options.name || "config";
|
|
115
|
-
options.envName = options.envName ?? process.env.NODE_ENV;
|
|
116
|
-
options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
|
|
117
|
-
options.rcFile = options.rcFile ?? `.${options.name}rc`;
|
|
118
|
-
if (options.extend !== false) options.extend = {
|
|
119
|
-
extendKey: "extends",
|
|
120
|
-
...options.extend
|
|
121
|
-
};
|
|
122
|
-
const _merger = options.merger || defu.defu;
|
|
123
|
-
options.jiti = options.jiti || require_jiti.default(require_pathe_M_eThtNZ.join(options.cwd, options.configFile), {
|
|
124
|
-
interopDefault: true,
|
|
125
|
-
moduleCache: false,
|
|
126
|
-
extensions: [...SUPPORTED_EXTENSIONS],
|
|
127
|
-
...options.jitiOptions
|
|
128
|
-
});
|
|
129
|
-
const r = {
|
|
130
|
-
config: {},
|
|
131
|
-
cwd: options.cwd,
|
|
132
|
-
configFile: require_pathe_M_eThtNZ.resolve(options.cwd, options.configFile),
|
|
133
|
-
layers: [],
|
|
134
|
-
_configFile: void 0
|
|
135
|
-
};
|
|
136
|
-
const rawConfigs = {
|
|
137
|
-
overrides: options.overrides,
|
|
138
|
-
main: void 0,
|
|
139
|
-
rc: void 0,
|
|
140
|
-
packageJson: void 0,
|
|
141
|
-
defaultConfig: options.defaultConfig
|
|
142
|
-
};
|
|
143
|
-
if (options.dotenv) await setupDotenv({
|
|
144
|
-
cwd: options.cwd,
|
|
145
|
-
...options.dotenv === true ? {} : options.dotenv
|
|
146
|
-
});
|
|
147
|
-
const _mainConfig = await resolveConfig(".", options);
|
|
148
|
-
if (_mainConfig.configFile) {
|
|
149
|
-
rawConfigs.main = _mainConfig.config;
|
|
150
|
-
r.configFile = _mainConfig.configFile;
|
|
151
|
-
r._configFile = _mainConfig._configFile;
|
|
152
|
-
}
|
|
153
|
-
if (_mainConfig.meta) r.meta = _mainConfig.meta;
|
|
154
|
-
if (options.rcFile) {
|
|
155
|
-
const rcSources = [];
|
|
156
|
-
rcSources.push(require_index$1.read({
|
|
157
|
-
name: options.rcFile,
|
|
158
|
-
dir: options.cwd
|
|
159
|
-
}));
|
|
160
|
-
if (options.globalRc) {
|
|
161
|
-
const workspaceDir = await require_index$2.findWorkspaceDir(options.cwd).catch(() => {});
|
|
162
|
-
if (workspaceDir) rcSources.push(require_index$1.read({
|
|
163
|
-
name: options.rcFile,
|
|
164
|
-
dir: workspaceDir
|
|
165
|
-
}));
|
|
166
|
-
rcSources.push(require_index$1.readUser({
|
|
167
|
-
name: options.rcFile,
|
|
168
|
-
dir: options.cwd
|
|
169
|
-
}));
|
|
170
|
-
}
|
|
171
|
-
rawConfigs.rc = _merger({}, ...rcSources);
|
|
172
|
-
}
|
|
173
|
-
if (options.packageJson) {
|
|
174
|
-
const keys = (Array.isArray(options.packageJson) ? options.packageJson : [typeof options.packageJson === "string" ? options.packageJson : options.name]).filter((t) => t && typeof t === "string");
|
|
175
|
-
const pkgJsonFile = await require_index$2.readPackageJSON(options.cwd).catch(() => {});
|
|
176
|
-
rawConfigs.packageJson = _merger({}, ...keys.map((key) => pkgJsonFile?.[key]));
|
|
177
|
-
}
|
|
178
|
-
const configs = {};
|
|
179
|
-
for (const key in rawConfigs) {
|
|
180
|
-
const value = rawConfigs[key];
|
|
181
|
-
configs[key] = await (typeof value === "function" ? value({
|
|
182
|
-
configs,
|
|
183
|
-
rawConfigs
|
|
184
|
-
}) : value);
|
|
185
|
-
}
|
|
186
|
-
if (Array.isArray(configs.main)) r.config = configs.main;
|
|
187
|
-
else {
|
|
188
|
-
r.config = _merger(configs.overrides, configs.main, configs.rc, configs.packageJson, configs.defaultConfig);
|
|
189
|
-
if (options.extend) {
|
|
190
|
-
await extendConfig(r.config, options);
|
|
191
|
-
r.layers = r.config._layers;
|
|
192
|
-
delete r.config._layers;
|
|
193
|
-
r.config = _merger(r.config, ...r.layers.map((e) => e.config));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
r.layers = [...[
|
|
197
|
-
configs.overrides && {
|
|
198
|
-
config: configs.overrides,
|
|
199
|
-
configFile: void 0,
|
|
200
|
-
cwd: void 0
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
config: configs.main,
|
|
204
|
-
configFile: options.configFile,
|
|
205
|
-
cwd: options.cwd
|
|
206
|
-
},
|
|
207
|
-
configs.rc && {
|
|
208
|
-
config: configs.rc,
|
|
209
|
-
configFile: options.rcFile
|
|
210
|
-
},
|
|
211
|
-
configs.packageJson && {
|
|
212
|
-
config: configs.packageJson,
|
|
213
|
-
configFile: "package.json"
|
|
214
|
-
}
|
|
215
|
-
].filter((l) => l && l.config), ...r.layers];
|
|
216
|
-
if (options.defaults) r.config = _merger(r.config, options.defaults);
|
|
217
|
-
if (options.omit$Keys) {
|
|
218
|
-
for (const key in r.config) if (key.startsWith("$")) delete r.config[key];
|
|
219
|
-
}
|
|
220
|
-
if (options.configFileRequired && !r._configFile) throw new Error(`Required config (${r.configFile}) cannot be resolved.`);
|
|
221
|
-
return r;
|
|
222
|
-
}
|
|
223
|
-
async function extendConfig(config, options) {
|
|
224
|
-
config._layers = config._layers || [];
|
|
225
|
-
if (!options.extend) return;
|
|
226
|
-
let keys = options.extend.extendKey;
|
|
227
|
-
if (typeof keys === "string") keys = [keys];
|
|
228
|
-
const extendSources = [];
|
|
229
|
-
for (const key of keys) {
|
|
230
|
-
extendSources.push(...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(Boolean));
|
|
231
|
-
delete config[key];
|
|
232
|
-
}
|
|
233
|
-
for (let extendSource of extendSources) {
|
|
234
|
-
const originalExtendSource = extendSource;
|
|
235
|
-
let sourceOptions = {};
|
|
236
|
-
if (extendSource.source) {
|
|
237
|
-
sourceOptions = extendSource.options || {};
|
|
238
|
-
extendSource = extendSource.source;
|
|
239
|
-
}
|
|
240
|
-
if (Array.isArray(extendSource)) {
|
|
241
|
-
sourceOptions = extendSource[1] || {};
|
|
242
|
-
extendSource = extendSource[0];
|
|
243
|
-
}
|
|
244
|
-
if (typeof extendSource !== "string") {
|
|
245
|
-
console.warn(`Cannot extend config from \`${JSON.stringify(originalExtendSource)}\` in ${options.cwd}`);
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
const _config = await resolveConfig(extendSource, options, sourceOptions);
|
|
249
|
-
if (!_config.config) {
|
|
250
|
-
console.warn(`Cannot extend config from \`${extendSource}\` in ${options.cwd}`);
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
await extendConfig(_config.config, {
|
|
254
|
-
...options,
|
|
255
|
-
cwd: _config.cwd
|
|
256
|
-
});
|
|
257
|
-
config._layers.push(_config);
|
|
258
|
-
if (_config.config._layers) {
|
|
259
|
-
config._layers.push(..._config.config._layers);
|
|
260
|
-
delete _config.config._layers;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const GIGET_PREFIXES = [
|
|
265
|
-
"gh:",
|
|
266
|
-
"github:",
|
|
267
|
-
"gitlab:",
|
|
268
|
-
"bitbucket:",
|
|
269
|
-
"https://",
|
|
270
|
-
"http://"
|
|
271
|
-
];
|
|
272
|
-
const NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
|
|
273
|
-
async function resolveConfig(source, options, sourceOptions = {}) {
|
|
274
|
-
if (options.resolve) {
|
|
275
|
-
const res$1 = await options.resolve(source, options);
|
|
276
|
-
if (res$1) return res$1;
|
|
277
|
-
}
|
|
278
|
-
const _merger = options.merger || defu.defu;
|
|
279
|
-
const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
|
|
280
|
-
const gigetPrefixes = customProviderKeys.length > 0 ? [...new Set([...customProviderKeys, ...GIGET_PREFIXES])] : GIGET_PREFIXES;
|
|
281
|
-
if (options.giget !== false && gigetPrefixes.some((prefix) => source.startsWith(prefix))) {
|
|
282
|
-
const { downloadTemplate } = await Promise.resolve().then(() => require("../../../../giget@2.0.0/node_modules/giget/dist/index.cjs"));
|
|
283
|
-
const { digest } = await Promise.resolve().then(() => require("../../../../ohash@2.0.11/node_modules/ohash/dist/index.cjs"));
|
|
284
|
-
const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
|
|
285
|
-
let cloneDir;
|
|
286
|
-
const localNodeModules = require_pathe_M_eThtNZ.resolve(options.cwd, "node_modules");
|
|
287
|
-
const parentDir = require_pathe_M_eThtNZ.dirname(options.cwd);
|
|
288
|
-
if (require_pathe_M_eThtNZ.basename(parentDir) === ".c12") cloneDir = require_pathe_M_eThtNZ.join(parentDir, cloneName);
|
|
289
|
-
else if ((0, node_fs.existsSync)(localNodeModules)) cloneDir = require_pathe_M_eThtNZ.join(localNodeModules, ".c12", cloneName);
|
|
290
|
-
else cloneDir = process.env.XDG_CACHE_HOME ? require_pathe_M_eThtNZ.resolve(process.env.XDG_CACHE_HOME, "c12", cloneName) : require_pathe_M_eThtNZ.resolve((0, node_os.homedir)(), ".cache/c12", cloneName);
|
|
291
|
-
if ((0, node_fs.existsSync)(cloneDir) && !sourceOptions.install) await (0, node_fs_promises.rm)(cloneDir, { recursive: true });
|
|
292
|
-
source = (await downloadTemplate(source, {
|
|
293
|
-
dir: cloneDir,
|
|
294
|
-
install: sourceOptions.install,
|
|
295
|
-
force: sourceOptions.install,
|
|
296
|
-
auth: sourceOptions.auth,
|
|
297
|
-
...options.giget,
|
|
298
|
-
...sourceOptions.giget
|
|
299
|
-
})).dir;
|
|
300
|
-
}
|
|
301
|
-
if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
|
|
302
|
-
const ext = require_pathe_M_eThtNZ.extname(source);
|
|
303
|
-
const isDir = !ext || ext === require_pathe_M_eThtNZ.basename(source);
|
|
304
|
-
const cwd = require_pathe_M_eThtNZ.resolve(options.cwd, isDir ? source : require_pathe_M_eThtNZ.dirname(source));
|
|
305
|
-
if (isDir) source = options.configFile;
|
|
306
|
-
const res = {
|
|
307
|
-
config: void 0,
|
|
308
|
-
configFile: void 0,
|
|
309
|
-
cwd,
|
|
310
|
-
source,
|
|
311
|
-
sourceOptions
|
|
312
|
-
};
|
|
313
|
-
res.configFile = tryResolve(require_pathe_M_eThtNZ.resolve(cwd, source), options) || tryResolve(require_pathe_M_eThtNZ.resolve(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(require_pathe_M_eThtNZ.resolve(cwd, ".config", source), options) || source;
|
|
314
|
-
if (!(0, node_fs.existsSync)(res.configFile)) return res;
|
|
315
|
-
res._configFile = res.configFile;
|
|
316
|
-
const configFileExt = require_pathe_M_eThtNZ.extname(res.configFile) || "";
|
|
317
|
-
if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await (0, node_fs_promises.readFile)(res.configFile, "utf8"));
|
|
318
|
-
else res.config = await options.jiti.import(res.configFile, { default: true });
|
|
319
|
-
if (typeof res.config === "function") res.config = await res.config(options.context);
|
|
320
|
-
if (options.envName) {
|
|
321
|
-
const envConfig = {
|
|
322
|
-
...res.config["$" + options.envName],
|
|
323
|
-
...res.config.$env?.[options.envName]
|
|
324
|
-
};
|
|
325
|
-
if (Object.keys(envConfig).length > 0) res.config = _merger(envConfig, res.config);
|
|
326
|
-
}
|
|
327
|
-
res.meta = (0, defu.defu)(res.sourceOptions.meta, res.config.$meta);
|
|
328
|
-
delete res.config.$meta;
|
|
329
|
-
if (res.sourceOptions.overrides) res.config = _merger(res.sourceOptions.overrides, res.config);
|
|
330
|
-
res.configFile = _normalize(res.configFile);
|
|
331
|
-
res.source = _normalize(res.source);
|
|
332
|
-
return res;
|
|
333
|
-
}
|
|
334
|
-
function tryResolve(id, options) {
|
|
335
|
-
const res = require_index.resolveModulePath(id, {
|
|
336
|
-
try: true,
|
|
337
|
-
from: (0, node_url.pathToFileURL)(require_pathe_M_eThtNZ.join(options.cwd || ".", options.configFile || "/")),
|
|
338
|
-
suffixes: ["", "/index"],
|
|
339
|
-
extensions: SUPPORTED_EXTENSIONS,
|
|
340
|
-
cache: false
|
|
341
|
-
});
|
|
342
|
-
return res ? require_pathe_M_eThtNZ.normalize(res) : void 0;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
//#endregion
|
|
346
|
-
exports.loadConfig = loadConfig;
|