@storm-software/config-tools 1.119.0 → 1.130.2
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/README.md +1 -1
- package/dist/chunk-4IYEDNYJ.mjs +426 -0
- package/dist/chunk-5QZ7AV2J.js +27 -0
- package/dist/chunk-64RYHF5D.mjs +51 -0
- package/dist/chunk-66ACWURQ.mjs +125 -0
- package/dist/chunk-6OYLNZFT.mjs +169 -0
- package/dist/chunk-6SJLAEJ3.js +70 -0
- package/dist/chunk-6WPG3DXV.js +32 -0
- package/dist/chunk-7KVSSDMX.mjs +545 -0
- package/dist/chunk-7XY63NME.js +44 -0
- package/dist/chunk-A7VLTBS6.mjs +271 -0
- package/dist/chunk-BS5OC5E6.js +426 -0
- package/dist/chunk-E3IN3SQD.mjs +6 -0
- package/dist/chunk-FW22KPOW.mjs +27 -0
- package/dist/chunk-GIZ23UUE.js +189 -0
- package/dist/chunk-GOQAHXJF.mjs +28 -0
- package/dist/chunk-H6XXDZ7A.js +28 -0
- package/dist/chunk-HCF3QA4H.js +102 -0
- package/dist/chunk-JDK3PXQR.js +545 -0
- package/dist/chunk-K6TQN2LZ.js +6 -0
- package/dist/chunk-LKZSRXS7.js +169 -0
- package/dist/chunk-MGI2M3SX.js +6 -0
- package/dist/chunk-N32EGEJB.js +90 -0
- package/dist/chunk-N4BRCEYB.js +27 -0
- package/dist/chunk-OXK45X3L.js +125 -0
- package/dist/chunk-PEHVR33I.js +67 -0
- package/dist/chunk-PQNCKJAR.js +271 -0
- package/dist/chunk-PVPSTJNJ.mjs +90 -0
- package/dist/chunk-QHVHX67K.js +6 -0
- package/dist/chunk-QUVGIEZZ.mjs +6 -0
- package/dist/chunk-RAWSXKTG.mjs +189 -0
- package/dist/chunk-SJO5XZQA.js +6 -0
- package/dist/chunk-TEKFJAJJ.mjs +70 -0
- package/dist/chunk-TTCXDK6S.mjs +27 -0
- package/dist/chunk-UCUOC6LA.mjs +70 -0
- package/dist/chunk-VQLOUFMG.mjs +32 -0
- package/dist/chunk-WRFJFYOU.mjs +51 -0
- package/dist/chunk-WXOSG64C.js +70 -0
- package/dist/chunk-WXYJGX4C.mjs +6 -0
- package/dist/chunk-X6VIYUJR.mjs +6 -0
- package/dist/chunk-XJEQHMOE.js +49 -0
- package/dist/chunk-XLMGW4ZW.mjs +67 -0
- package/dist/chunk-XXHENMLT.mjs +44 -0
- package/dist/chunk-Z2EXWNIQ.mjs +102 -0
- package/dist/chunk-ZVXEYJQO.js +51 -0
- package/dist/config-file/get-config-file.d.mts +20 -0
- package/dist/config-file/get-config-file.d.ts +20 -0
- package/dist/config-file/get-config-file.js +23 -0
- package/dist/config-file/get-config-file.mjs +23 -0
- package/dist/config-file/index.d.mts +4 -0
- package/dist/config-file/index.d.ts +4 -0
- package/dist/config-file/index.js +24 -0
- package/dist/config-file/index.mjs +24 -0
- package/dist/create-storm-config.d.mts +29 -0
- package/dist/create-storm-config.d.ts +29 -0
- package/dist/create-storm-config.js +30 -0
- package/dist/create-storm-config.mjs +30 -0
- package/dist/env/get-env.d.mts +19 -0
- package/dist/env/get-env.d.ts +19 -0
- package/dist/env/get-env.js +13 -0
- package/dist/env/get-env.mjs +13 -0
- package/dist/env/index.d.mts +5 -0
- package/dist/env/index.d.ts +5 -0
- package/dist/env/index.js +20 -0
- package/dist/env/index.mjs +20 -0
- package/{src/env/get-env.d.ts → dist/env/set-env.d.mts} +7 -4
- package/{src → dist}/env/set-env.d.ts +7 -3
- package/dist/env/set-env.js +12 -0
- package/dist/env/set-env.mjs +12 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +132 -0
- package/dist/index.mjs +132 -0
- package/dist/logger/chalk.d.mts +25 -0
- package/{src/utilities → dist/logger}/chalk.d.ts +4 -2
- package/dist/logger/chalk.js +7 -0
- package/dist/logger/chalk.mjs +7 -0
- package/dist/logger/console.d.mts +82 -0
- package/{src/utilities/logger.d.ts → dist/logger/console.d.ts} +18 -14
- package/dist/logger/console.js +35 -0
- package/dist/logger/console.mjs +35 -0
- package/dist/logger/get-log-level.d.mts +27 -0
- package/{src/utilities → dist/logger}/get-log-level.d.ts +9 -4
- package/dist/logger/get-log-level.js +12 -0
- package/dist/logger/get-log-level.mjs +12 -0
- package/dist/logger/index.d.mts +6 -0
- package/dist/logger/index.d.ts +6 -0
- package/dist/logger/index.js +46 -0
- package/dist/logger/index.mjs +46 -0
- package/dist/types-DGWqy1xb.d.mts +1395 -0
- package/dist/types-DGWqy1xb.d.ts +1395 -0
- package/dist/types.d.mts +40 -0
- package/{src → dist}/types.d.ts +14 -7
- package/dist/types.js +9 -0
- package/dist/types.mjs +9 -0
- package/dist/utilities/apply-workspace-tokens.d.mts +9 -0
- package/dist/utilities/apply-workspace-tokens.d.ts +9 -0
- package/dist/utilities/apply-workspace-tokens.js +14 -0
- package/dist/utilities/apply-workspace-tokens.mjs +14 -0
- package/dist/utilities/correct-paths.d.mts +19 -0
- package/dist/utilities/correct-paths.d.ts +19 -0
- package/dist/utilities/correct-paths.js +9 -0
- package/dist/utilities/correct-paths.mjs +9 -0
- package/dist/utilities/file-path-utils.d.mts +4 -0
- package/dist/utilities/file-path-utils.d.ts +4 -0
- package/dist/utilities/file-path-utils.js +9 -0
- package/dist/utilities/file-path-utils.mjs +9 -0
- package/dist/utilities/find-up.d.mts +6 -0
- package/dist/utilities/find-up.d.ts +6 -0
- package/dist/utilities/find-up.js +7 -0
- package/dist/utilities/find-up.mjs +7 -0
- package/dist/utilities/find-workspace-root.d.mts +16 -0
- package/{src → dist}/utilities/find-workspace-root.d.ts +4 -2
- package/dist/utilities/find-workspace-root.js +11 -0
- package/dist/utilities/find-workspace-root.mjs +11 -0
- package/dist/utilities/get-default-config.d.mts +15 -0
- package/dist/utilities/get-default-config.d.ts +15 -0
- package/dist/utilities/get-default-config.js +13 -0
- package/dist/utilities/get-default-config.mjs +13 -0
- package/dist/utilities/index.d.mts +11 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.js +58 -0
- package/dist/utilities/index.mjs +58 -0
- package/dist/utilities/process-handler.d.mts +8 -0
- package/dist/utilities/process-handler.d.ts +8 -0
- package/dist/utilities/process-handler.js +20 -0
- package/dist/utilities/process-handler.mjs +20 -0
- package/dist/utilities/run.d.mts +36 -0
- package/dist/utilities/run.d.ts +36 -0
- package/dist/utilities/run.js +11 -0
- package/dist/utilities/run.mjs +11 -0
- package/package.json +1 -24
- package/CHANGELOG.md +0 -3122
- package/declarations.d.ts +0 -304
- package/index.cjs +0 -67508
- package/index.js +0 -67463
- package/meta.cjs.json +0 -5352
- package/meta.esm.json +0 -5413
- package/src/config-file/get-config-file.d.ts +0 -16
- package/src/config-file/index.d.ts +0 -1
- package/src/create-storm-config.d.ts +0 -26
- package/src/env/index.d.ts +0 -2
- package/src/index.d.ts +0 -13
- package/src/utilities/apply-workspace-tokens.d.ts +0 -4
- package/src/utilities/correct-paths.d.ts +0 -1
- package/src/utilities/file-path-utils.d.ts +0 -2
- package/src/utilities/find-up.d.ts +0 -4
- package/src/utilities/get-default-config.d.ts +0 -15
- package/src/utilities/index.d.ts +0 -10
- package/src/utilities/process-handler.d.ts +0 -4
- package/src/utilities/run.d.ts +0 -18
- package/utilities/chalk.cjs +0 -1610
- package/utilities/chalk.js +0 -1605
- package/utilities/find-workspace-root.cjs +0 -118
- package/utilities/find-workspace-root.js +0 -91
- package/utilities/logger.cjs +0 -5914
- package/utilities/logger.js +0 -5897
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeSystem
|
|
3
|
+
} from "./chunk-66ACWURQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
findWorkspaceRoot
|
|
6
|
+
} from "./chunk-TEKFJAJJ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
joinPaths
|
|
9
|
+
} from "./chunk-GOQAHXJF.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__name,
|
|
12
|
+
init_esm_shims
|
|
13
|
+
} from "./chunk-WRFJFYOU.mjs";
|
|
14
|
+
|
|
15
|
+
// src/config-file/get-config-file.ts
|
|
16
|
+
init_esm_shims();
|
|
17
|
+
|
|
18
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/index.mjs
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/shared/c12.B4fc1S0C.mjs
|
|
22
|
+
init_esm_shims();
|
|
23
|
+
import { existsSync, promises } from "node:fs";
|
|
24
|
+
import { rm, readFile } from "node:fs/promises";
|
|
25
|
+
import { homedir } from "node:os";
|
|
26
|
+
import { resolve, join, dirname, basename, extname } from "pathe";
|
|
27
|
+
import { createJiti } from "jiti";
|
|
28
|
+
import { fileURLToPath } from "mlly";
|
|
29
|
+
import * as rc9 from "rc9";
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
32
|
+
init_esm_shims();
|
|
33
|
+
function isPlainObject(value) {
|
|
34
|
+
if (value === null || typeof value !== "object") {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const prototype = Object.getPrototypeOf(value);
|
|
38
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (Symbol.iterator in value) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (Symbol.toStringTag in value) {
|
|
45
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
__name(isPlainObject, "isPlainObject");
|
|
50
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
51
|
+
if (!isPlainObject(defaults)) {
|
|
52
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
53
|
+
}
|
|
54
|
+
const object = Object.assign({}, defaults);
|
|
55
|
+
for (const key in baseObject) {
|
|
56
|
+
if (key === "__proto__" || key === "constructor") {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const value = baseObject[key];
|
|
60
|
+
if (value === null || value === void 0) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
67
|
+
object[key] = [...value, ...object[key]];
|
|
68
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
69
|
+
object[key] = _defu(
|
|
70
|
+
value,
|
|
71
|
+
object[key],
|
|
72
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
73
|
+
merger
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
object[key] = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return object;
|
|
80
|
+
}
|
|
81
|
+
__name(_defu, "_defu");
|
|
82
|
+
function createDefu(merger) {
|
|
83
|
+
return (...arguments_) => (
|
|
84
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
85
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
__name(createDefu, "createDefu");
|
|
89
|
+
var defu = createDefu();
|
|
90
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
91
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
92
|
+
object[key] = currentValue(object[key]);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
97
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
98
|
+
object[key] = currentValue(object[key]);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/shared/c12.B4fc1S0C.mjs
|
|
104
|
+
import { hash } from "ohash";
|
|
105
|
+
import { findWorkspaceDir, readPackageJSON } from "pkg-types";
|
|
106
|
+
import * as dotenv from "dotenv";
|
|
107
|
+
async function setupDotenv(options) {
|
|
108
|
+
const targetEnvironment = options.env ?? process.env;
|
|
109
|
+
const environment = await loadDotenv({
|
|
110
|
+
cwd: options.cwd,
|
|
111
|
+
fileName: options.fileName ?? ".env",
|
|
112
|
+
env: targetEnvironment,
|
|
113
|
+
interpolate: options.interpolate ?? true
|
|
114
|
+
});
|
|
115
|
+
for (const key in environment) {
|
|
116
|
+
if (!key.startsWith("_") && targetEnvironment[key] === void 0) {
|
|
117
|
+
targetEnvironment[key] = environment[key];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return environment;
|
|
121
|
+
}
|
|
122
|
+
__name(setupDotenv, "setupDotenv");
|
|
123
|
+
async function loadDotenv(options) {
|
|
124
|
+
const environment = /* @__PURE__ */ Object.create(null);
|
|
125
|
+
const dotenvFile = resolve(options.cwd, options.fileName);
|
|
126
|
+
if (existsSync(dotenvFile)) {
|
|
127
|
+
const parsed = dotenv.parse(await promises.readFile(dotenvFile, "utf8"));
|
|
128
|
+
Object.assign(environment, parsed);
|
|
129
|
+
}
|
|
130
|
+
if (!options.env?._applied) {
|
|
131
|
+
Object.assign(environment, options.env);
|
|
132
|
+
environment._applied = true;
|
|
133
|
+
}
|
|
134
|
+
if (options.interpolate) {
|
|
135
|
+
interpolate(environment);
|
|
136
|
+
}
|
|
137
|
+
return environment;
|
|
138
|
+
}
|
|
139
|
+
__name(loadDotenv, "loadDotenv");
|
|
140
|
+
function interpolate(target, source = {}, parse2 = (v) => v) {
|
|
141
|
+
function getValue(key) {
|
|
142
|
+
return source[key] === void 0 ? target[key] : source[key];
|
|
143
|
+
}
|
|
144
|
+
__name(getValue, "getValue");
|
|
145
|
+
function interpolate2(value, parents = []) {
|
|
146
|
+
if (typeof value !== "string") {
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
const matches = value.match(/(.?\${?(?:[\w:]+)?}?)/g) || [];
|
|
150
|
+
return parse2(
|
|
151
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
152
|
+
matches.reduce((newValue, match) => {
|
|
153
|
+
const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
|
|
154
|
+
const prefix = parts[1];
|
|
155
|
+
let value2, replacePart;
|
|
156
|
+
if (prefix === "\\") {
|
|
157
|
+
replacePart = parts[0] || "";
|
|
158
|
+
value2 = replacePart.replace(String.raw`\$`, "$");
|
|
159
|
+
} else {
|
|
160
|
+
const key = parts[2];
|
|
161
|
+
replacePart = (parts[0] || "").slice(prefix.length);
|
|
162
|
+
if (parents.includes(key)) {
|
|
163
|
+
console.warn(
|
|
164
|
+
`Please avoid recursive environment variables ( loop: ${parents.join(
|
|
165
|
+
" > "
|
|
166
|
+
)} > ${key} )`
|
|
167
|
+
);
|
|
168
|
+
return "";
|
|
169
|
+
}
|
|
170
|
+
value2 = getValue(key);
|
|
171
|
+
value2 = interpolate2(value2, [...parents, key]);
|
|
172
|
+
}
|
|
173
|
+
return value2 === void 0 ? newValue : newValue.replace(replacePart, value2);
|
|
174
|
+
}, value)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
__name(interpolate2, "interpolate2");
|
|
178
|
+
for (const key in target) {
|
|
179
|
+
target[key] = interpolate2(getValue(key));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
__name(interpolate, "interpolate");
|
|
183
|
+
var _normalize = /* @__PURE__ */ __name((p) => p?.replace(/\\/g, "/"), "_normalize");
|
|
184
|
+
var ASYNC_LOADERS = {
|
|
185
|
+
".yaml": /* @__PURE__ */ __name(() => import("confbox/yaml").then((r) => r.parseYAML), ".yaml"),
|
|
186
|
+
".yml": /* @__PURE__ */ __name(() => import("confbox/yaml").then((r) => r.parseYAML), ".yml"),
|
|
187
|
+
".jsonc": /* @__PURE__ */ __name(() => import("confbox/jsonc").then((r) => r.parseJSONC), ".jsonc"),
|
|
188
|
+
".json5": /* @__PURE__ */ __name(() => import("confbox/json5").then((r) => r.parseJSON5), ".json5"),
|
|
189
|
+
".toml": /* @__PURE__ */ __name(() => import("confbox/toml").then((r) => r.parseTOML), ".toml")
|
|
190
|
+
};
|
|
191
|
+
var SUPPORTED_EXTENSIONS = [
|
|
192
|
+
// with jiti
|
|
193
|
+
".js",
|
|
194
|
+
".ts",
|
|
195
|
+
".mjs",
|
|
196
|
+
".cjs",
|
|
197
|
+
".mts",
|
|
198
|
+
".cts",
|
|
199
|
+
".json",
|
|
200
|
+
// with confbox
|
|
201
|
+
".jsonc",
|
|
202
|
+
".json5",
|
|
203
|
+
".yaml",
|
|
204
|
+
".yml",
|
|
205
|
+
".toml"
|
|
206
|
+
];
|
|
207
|
+
async function loadConfig(options) {
|
|
208
|
+
options.cwd = resolve(process.cwd(), options.cwd || ".");
|
|
209
|
+
options.name = options.name || "config";
|
|
210
|
+
options.envName = options.envName ?? process.env.NODE_ENV;
|
|
211
|
+
options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
|
|
212
|
+
options.rcFile = options.rcFile ?? `.${options.name}rc`;
|
|
213
|
+
if (options.extend !== false) {
|
|
214
|
+
options.extend = {
|
|
215
|
+
extendKey: "extends",
|
|
216
|
+
...options.extend
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const _merger = options.merger || defu;
|
|
220
|
+
options.jiti = options.jiti || createJiti(join(options.cwd, options.configFile), {
|
|
221
|
+
interopDefault: true,
|
|
222
|
+
moduleCache: false,
|
|
223
|
+
extensions: [...SUPPORTED_EXTENSIONS],
|
|
224
|
+
...options.jitiOptions
|
|
225
|
+
});
|
|
226
|
+
const r = {
|
|
227
|
+
config: {},
|
|
228
|
+
cwd: options.cwd,
|
|
229
|
+
configFile: resolve(options.cwd, options.configFile),
|
|
230
|
+
layers: []
|
|
231
|
+
};
|
|
232
|
+
const _configs = {
|
|
233
|
+
overrides: options.overrides,
|
|
234
|
+
main: void 0,
|
|
235
|
+
rc: void 0,
|
|
236
|
+
packageJson: void 0,
|
|
237
|
+
defaultConfig: options.defaultConfig
|
|
238
|
+
};
|
|
239
|
+
if (options.dotenv) {
|
|
240
|
+
await setupDotenv({
|
|
241
|
+
cwd: options.cwd,
|
|
242
|
+
...options.dotenv === true ? {} : options.dotenv
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const _mainConfig = await resolveConfig(".", options);
|
|
246
|
+
if (_mainConfig.configFile) {
|
|
247
|
+
_configs.main = _mainConfig.config;
|
|
248
|
+
r.configFile = _mainConfig.configFile;
|
|
249
|
+
}
|
|
250
|
+
if (options.rcFile) {
|
|
251
|
+
const rcSources = [];
|
|
252
|
+
rcSources.push(rc9.read({ name: options.rcFile, dir: options.cwd }));
|
|
253
|
+
if (options.globalRc) {
|
|
254
|
+
const workspaceDir = await findWorkspaceDir(options.cwd).catch(() => {
|
|
255
|
+
});
|
|
256
|
+
if (workspaceDir) {
|
|
257
|
+
rcSources.push(rc9.read({ name: options.rcFile, dir: workspaceDir }));
|
|
258
|
+
}
|
|
259
|
+
rcSources.push(rc9.readUser({ name: options.rcFile, dir: options.cwd }));
|
|
260
|
+
}
|
|
261
|
+
_configs.rc = _merger({}, ...rcSources);
|
|
262
|
+
}
|
|
263
|
+
if (options.packageJson) {
|
|
264
|
+
const keys = (Array.isArray(options.packageJson) ? options.packageJson : [
|
|
265
|
+
typeof options.packageJson === "string" ? options.packageJson : options.name
|
|
266
|
+
]).filter((t) => t && typeof t === "string");
|
|
267
|
+
const pkgJsonFile = await readPackageJSON(options.cwd).catch(() => {
|
|
268
|
+
});
|
|
269
|
+
const values = keys.map((key) => pkgJsonFile?.[key]);
|
|
270
|
+
_configs.packageJson = _merger({}, ...values);
|
|
271
|
+
}
|
|
272
|
+
const configs = {};
|
|
273
|
+
for (const key in _configs) {
|
|
274
|
+
const value = _configs[key];
|
|
275
|
+
configs[key] = await (typeof value === "function" ? value({ configs }) : value);
|
|
276
|
+
}
|
|
277
|
+
r.config = _merger(
|
|
278
|
+
configs.overrides,
|
|
279
|
+
configs.main,
|
|
280
|
+
configs.rc,
|
|
281
|
+
configs.packageJson,
|
|
282
|
+
configs.defaultConfig
|
|
283
|
+
);
|
|
284
|
+
if (options.extend) {
|
|
285
|
+
await extendConfig(r.config, options);
|
|
286
|
+
r.layers = r.config._layers;
|
|
287
|
+
delete r.config._layers;
|
|
288
|
+
r.config = _merger(r.config, ...r.layers.map((e) => e.config));
|
|
289
|
+
}
|
|
290
|
+
const baseLayers = [
|
|
291
|
+
configs.overrides && {
|
|
292
|
+
config: configs.overrides,
|
|
293
|
+
configFile: void 0,
|
|
294
|
+
cwd: void 0
|
|
295
|
+
},
|
|
296
|
+
{ config: configs.main, configFile: options.configFile, cwd: options.cwd },
|
|
297
|
+
configs.rc && { config: configs.rc, configFile: options.rcFile },
|
|
298
|
+
configs.packageJson && {
|
|
299
|
+
config: configs.packageJson,
|
|
300
|
+
configFile: "package.json"
|
|
301
|
+
}
|
|
302
|
+
].filter((l) => l && l.config);
|
|
303
|
+
r.layers = [...baseLayers, ...r.layers];
|
|
304
|
+
if (options.defaults) {
|
|
305
|
+
r.config = _merger(r.config, options.defaults);
|
|
306
|
+
}
|
|
307
|
+
if (options.omit$Keys) {
|
|
308
|
+
for (const key in r.config) {
|
|
309
|
+
if (key.startsWith("$")) {
|
|
310
|
+
delete r.config[key];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return r;
|
|
315
|
+
}
|
|
316
|
+
__name(loadConfig, "loadConfig");
|
|
317
|
+
async function extendConfig(config, options) {
|
|
318
|
+
config._layers = config._layers || [];
|
|
319
|
+
if (!options.extend) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
let keys = options.extend.extendKey;
|
|
323
|
+
if (typeof keys === "string") {
|
|
324
|
+
keys = [keys];
|
|
325
|
+
}
|
|
326
|
+
const extendSources = [];
|
|
327
|
+
for (const key of keys) {
|
|
328
|
+
extendSources.push(
|
|
329
|
+
...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(
|
|
330
|
+
Boolean
|
|
331
|
+
)
|
|
332
|
+
);
|
|
333
|
+
delete config[key];
|
|
334
|
+
}
|
|
335
|
+
for (let extendSource of extendSources) {
|
|
336
|
+
const originalExtendSource = extendSource;
|
|
337
|
+
let sourceOptions = {};
|
|
338
|
+
if (extendSource.source) {
|
|
339
|
+
sourceOptions = extendSource.options || {};
|
|
340
|
+
extendSource = extendSource.source;
|
|
341
|
+
}
|
|
342
|
+
if (Array.isArray(extendSource)) {
|
|
343
|
+
sourceOptions = extendSource[1] || {};
|
|
344
|
+
extendSource = extendSource[0];
|
|
345
|
+
}
|
|
346
|
+
if (typeof extendSource !== "string") {
|
|
347
|
+
console.warn(
|
|
348
|
+
`Cannot extend config from \`${JSON.stringify(
|
|
349
|
+
originalExtendSource
|
|
350
|
+
)}\` in ${options.cwd}`
|
|
351
|
+
);
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const _config = await resolveConfig(extendSource, options, sourceOptions);
|
|
355
|
+
if (!_config.config) {
|
|
356
|
+
console.warn(
|
|
357
|
+
`Cannot extend config from \`${extendSource}\` in ${options.cwd}`
|
|
358
|
+
);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
await extendConfig(_config.config, { ...options, cwd: _config.cwd });
|
|
362
|
+
config._layers.push(_config);
|
|
363
|
+
if (_config.config._layers) {
|
|
364
|
+
config._layers.push(..._config.config._layers);
|
|
365
|
+
delete _config.config._layers;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
__name(extendConfig, "extendConfig");
|
|
370
|
+
var GIGET_PREFIXES = [
|
|
371
|
+
"gh:",
|
|
372
|
+
"github:",
|
|
373
|
+
"gitlab:",
|
|
374
|
+
"bitbucket:",
|
|
375
|
+
"https://",
|
|
376
|
+
"http://"
|
|
377
|
+
];
|
|
378
|
+
var NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
|
|
379
|
+
async function resolveConfig(source, options, sourceOptions = {}) {
|
|
380
|
+
if (options.resolve) {
|
|
381
|
+
const res2 = await options.resolve(source, options);
|
|
382
|
+
if (res2) {
|
|
383
|
+
return res2;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const _merger = options.merger || defu;
|
|
387
|
+
if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
|
|
388
|
+
const { downloadTemplate } = await import("giget");
|
|
389
|
+
const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + hash(source);
|
|
390
|
+
let cloneDir;
|
|
391
|
+
const localNodeModules = resolve(options.cwd, "node_modules");
|
|
392
|
+
const parentDir = dirname(options.cwd);
|
|
393
|
+
if (basename(parentDir) === ".c12") {
|
|
394
|
+
cloneDir = join(parentDir, cloneName);
|
|
395
|
+
} else if (existsSync(localNodeModules)) {
|
|
396
|
+
cloneDir = join(localNodeModules, ".c12", cloneName);
|
|
397
|
+
} else {
|
|
398
|
+
cloneDir = process.env.XDG_CACHE_HOME ? resolve(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve(homedir(), ".cache/c12", cloneName);
|
|
399
|
+
}
|
|
400
|
+
if (existsSync(cloneDir) && !sourceOptions.install) {
|
|
401
|
+
await rm(cloneDir, { recursive: true });
|
|
402
|
+
}
|
|
403
|
+
const cloned = await downloadTemplate(source, {
|
|
404
|
+
dir: cloneDir,
|
|
405
|
+
install: sourceOptions.install,
|
|
406
|
+
force: sourceOptions.install,
|
|
407
|
+
auth: sourceOptions.auth,
|
|
408
|
+
...options.giget,
|
|
409
|
+
...sourceOptions.giget
|
|
410
|
+
});
|
|
411
|
+
source = cloned.dir;
|
|
412
|
+
}
|
|
413
|
+
const tryResolve = /* @__PURE__ */ __name((id) => {
|
|
414
|
+
const resolved = options.jiti.esmResolve(id, { try: true });
|
|
415
|
+
return resolved ? fileURLToPath(resolved) : void 0;
|
|
416
|
+
}, "tryResolve");
|
|
417
|
+
if (NPM_PACKAGE_RE.test(source)) {
|
|
418
|
+
source = tryResolve(source) || source;
|
|
419
|
+
}
|
|
420
|
+
const ext = extname(source);
|
|
421
|
+
const isDir = !ext || ext === basename(source);
|
|
422
|
+
const cwd = resolve(options.cwd, isDir ? source : dirname(source));
|
|
423
|
+
if (isDir) {
|
|
424
|
+
source = options.configFile;
|
|
425
|
+
}
|
|
426
|
+
const res = {
|
|
427
|
+
config: void 0,
|
|
428
|
+
configFile: void 0,
|
|
429
|
+
cwd,
|
|
430
|
+
source,
|
|
431
|
+
sourceOptions
|
|
432
|
+
};
|
|
433
|
+
res.configFile = tryResolve(resolve(cwd, source)) || tryResolve(resolve(cwd, ".config", source.replace(/\.config$/, ""))) || tryResolve(resolve(cwd, ".config", source)) || source;
|
|
434
|
+
if (!existsSync(res.configFile)) {
|
|
435
|
+
return res;
|
|
436
|
+
}
|
|
437
|
+
const configFileExt = extname(res.configFile) || "";
|
|
438
|
+
if (configFileExt in ASYNC_LOADERS) {
|
|
439
|
+
const asyncLoader = await ASYNC_LOADERS[configFileExt]();
|
|
440
|
+
const contents = await readFile(res.configFile, "utf8");
|
|
441
|
+
res.config = asyncLoader(contents);
|
|
442
|
+
} else {
|
|
443
|
+
res.config = await options.jiti.import(res.configFile, {
|
|
444
|
+
default: true
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
if (res.config instanceof Function) {
|
|
448
|
+
res.config = await res.config();
|
|
449
|
+
}
|
|
450
|
+
if (options.envName) {
|
|
451
|
+
const envConfig = {
|
|
452
|
+
...res.config["$" + options.envName],
|
|
453
|
+
...res.config.$env?.[options.envName]
|
|
454
|
+
};
|
|
455
|
+
if (Object.keys(envConfig).length > 0) {
|
|
456
|
+
res.config = _merger(envConfig, res.config);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
res.meta = defu(res.sourceOptions.meta, res.config.$meta);
|
|
460
|
+
delete res.config.$meta;
|
|
461
|
+
if (res.sourceOptions.overrides) {
|
|
462
|
+
res.config = _merger(res.sourceOptions.overrides, res.config);
|
|
463
|
+
}
|
|
464
|
+
res.configFile = _normalize(res.configFile);
|
|
465
|
+
res.source = _normalize(res.source);
|
|
466
|
+
return res;
|
|
467
|
+
}
|
|
468
|
+
__name(resolveConfig, "resolveConfig");
|
|
469
|
+
|
|
470
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/index.mjs
|
|
471
|
+
import { debounce } from "perfect-debounce";
|
|
472
|
+
import { resolve as resolve2 } from "pathe";
|
|
473
|
+
import { diff } from "ohash";
|
|
474
|
+
import "node:fs";
|
|
475
|
+
import "node:fs/promises";
|
|
476
|
+
import "node:os";
|
|
477
|
+
import "jiti";
|
|
478
|
+
import "mlly";
|
|
479
|
+
import "rc9";
|
|
480
|
+
import "pkg-types";
|
|
481
|
+
import "dotenv";
|
|
482
|
+
|
|
483
|
+
// src/config-file/get-config-file.ts
|
|
484
|
+
var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
|
|
485
|
+
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
486
|
+
let config = loadConfig({
|
|
487
|
+
cwd: workspacePath,
|
|
488
|
+
packageJson: true,
|
|
489
|
+
name: fileName,
|
|
490
|
+
envName: fileName?.toUpperCase(),
|
|
491
|
+
jitiOptions: {
|
|
492
|
+
debug: false,
|
|
493
|
+
cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
|
|
494
|
+
},
|
|
495
|
+
...options
|
|
496
|
+
});
|
|
497
|
+
if (!config || Object.keys(config).length === 0) {
|
|
498
|
+
config = loadConfig({
|
|
499
|
+
cwd: workspacePath,
|
|
500
|
+
packageJson: true,
|
|
501
|
+
name: fileName,
|
|
502
|
+
envName: fileName?.toUpperCase(),
|
|
503
|
+
jitiOptions: {
|
|
504
|
+
debug: false,
|
|
505
|
+
cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
|
|
506
|
+
},
|
|
507
|
+
configFile: fileName,
|
|
508
|
+
...options
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
return config;
|
|
512
|
+
}, "getConfigFileByName");
|
|
513
|
+
var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
|
|
514
|
+
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
515
|
+
const result = await getConfigFileByName("storm", workspacePath);
|
|
516
|
+
let config = result.config;
|
|
517
|
+
const configFile = result.configFile;
|
|
518
|
+
if (config && configFile && Object.keys(config).length > 0) {
|
|
519
|
+
writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
|
|
520
|
+
logLevel: "all"
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
524
|
+
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
|
|
525
|
+
for (const result2 of results) {
|
|
526
|
+
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
527
|
+
writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
|
|
528
|
+
logLevel: "all"
|
|
529
|
+
});
|
|
530
|
+
config = defu(result2.config ?? {}, config ?? {});
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (!config) {
|
|
535
|
+
return void 0;
|
|
536
|
+
}
|
|
537
|
+
config.configFile = configFile;
|
|
538
|
+
return config;
|
|
539
|
+
}, "getConfigFile");
|
|
540
|
+
|
|
541
|
+
export {
|
|
542
|
+
defu,
|
|
543
|
+
getConfigFileByName,
|
|
544
|
+
getConfigFile
|
|
545
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkXJEQHMOEjs = require('./chunk-XJEQHMOE.js');
|
|
5
|
+
|
|
6
|
+
// src/utilities/run.ts
|
|
7
|
+
_chunkXJEQHMOEjs.init_cjs_shims.call(void 0, );
|
|
8
|
+
var _child_process = require('child_process');
|
|
9
|
+
var LARGE_BUFFER = 1024 * 1e6;
|
|
10
|
+
var run = /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, (config, command, cwd = _nullishCoalesce(config.workspaceRoot, () => ( process.cwd())), stdio = "inherit", env = process.env) => {
|
|
11
|
+
return _child_process.execSync.call(void 0, command, {
|
|
12
|
+
cwd,
|
|
13
|
+
env: {
|
|
14
|
+
...process.env,
|
|
15
|
+
...env,
|
|
16
|
+
CLICOLOR: "true",
|
|
17
|
+
FORCE_COLOR: "true"
|
|
18
|
+
},
|
|
19
|
+
windowsHide: true,
|
|
20
|
+
stdio,
|
|
21
|
+
maxBuffer: LARGE_BUFFER,
|
|
22
|
+
killSignal: "SIGTERM"
|
|
23
|
+
});
|
|
24
|
+
}, "run");
|
|
25
|
+
var runAsync = /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, (config, command, cwd = _nullishCoalesce(config.workspaceRoot, () => ( process.cwd())), env = process.env) => {
|
|
26
|
+
return _child_process.exec.call(void 0, command, {
|
|
27
|
+
cwd,
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
...env,
|
|
31
|
+
CLICOLOR: "true",
|
|
32
|
+
FORCE_COLOR: "true"
|
|
33
|
+
},
|
|
34
|
+
windowsHide: true,
|
|
35
|
+
maxBuffer: LARGE_BUFFER,
|
|
36
|
+
killSignal: "SIGTERM"
|
|
37
|
+
});
|
|
38
|
+
}, "runAsync");
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
exports.LARGE_BUFFER = LARGE_BUFFER; exports.run = run; exports.runAsync = runAsync;
|