@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
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkOXK45X3Ljs = require('./chunk-OXK45X3L.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk6SJLAEJ3js = require('./chunk-6SJLAEJ3.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkH6XXDZ7Ajs = require('./chunk-H6XXDZ7A.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkXJEQHMOEjs = require('./chunk-XJEQHMOE.js');
|
|
14
|
+
|
|
15
|
+
// src/config-file/get-config-file.ts
|
|
16
|
+
_chunkXJEQHMOEjs.init_cjs_shims.call(void 0, );
|
|
17
|
+
|
|
18
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/index.mjs
|
|
19
|
+
_chunkXJEQHMOEjs.init_cjs_shims.call(void 0, );
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/shared/c12.B4fc1S0C.mjs
|
|
22
|
+
_chunkXJEQHMOEjs.init_cjs_shims.call(void 0, );
|
|
23
|
+
var _fs = require('fs');
|
|
24
|
+
var _promises = require('fs/promises');
|
|
25
|
+
var _os = require('os');
|
|
26
|
+
var _pathe = require('pathe');
|
|
27
|
+
var _jiti = require('jiti');
|
|
28
|
+
var _mlly = require('mlly');
|
|
29
|
+
var _rc9 = require('rc9'); var rc9 = _interopRequireWildcard(_rc9);
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
32
|
+
_chunkXJEQHMOEjs.init_cjs_shims.call(void 0, );
|
|
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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, 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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, _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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, 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
|
+
var _ohash = require('ohash');
|
|
105
|
+
var _pkgtypes = require('pkg-types');
|
|
106
|
+
var _dotenv = require('dotenv'); var dotenv = _interopRequireWildcard(_dotenv);
|
|
107
|
+
async function setupDotenv(options) {
|
|
108
|
+
const targetEnvironment = _nullishCoalesce(options.env, () => ( process.env));
|
|
109
|
+
const environment = await loadDotenv({
|
|
110
|
+
cwd: options.cwd,
|
|
111
|
+
fileName: _nullishCoalesce(options.fileName, () => ( ".env")),
|
|
112
|
+
env: targetEnvironment,
|
|
113
|
+
interpolate: _nullishCoalesce(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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, setupDotenv, "setupDotenv");
|
|
123
|
+
async function loadDotenv(options) {
|
|
124
|
+
const environment = /* @__PURE__ */ Object.create(null);
|
|
125
|
+
const dotenvFile = _pathe.resolve.call(void 0, options.cwd, options.fileName);
|
|
126
|
+
if (_fs.existsSync.call(void 0, dotenvFile)) {
|
|
127
|
+
const parsed = dotenv.parse(await _fs.promises.readFile(dotenvFile, "utf8"));
|
|
128
|
+
Object.assign(environment, parsed);
|
|
129
|
+
}
|
|
130
|
+
if (!_optionalChain([options, 'access', _ => _.env, 'optionalAccess', _2 => _2._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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, 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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, 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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, interpolate2, "interpolate2");
|
|
178
|
+
for (const key in target) {
|
|
179
|
+
target[key] = interpolate2(getValue(key));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
_chunkXJEQHMOEjs.__name.call(void 0, interpolate, "interpolate");
|
|
183
|
+
var _normalize = /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, (p) => _optionalChain([p, 'optionalAccess', _3 => _3.replace, 'call', _4 => _4(/\\/g, "/")]), "_normalize");
|
|
184
|
+
var ASYNC_LOADERS = {
|
|
185
|
+
".yaml": /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("confbox/yaml"))).then((r) => r.parseYAML), ".yaml"),
|
|
186
|
+
".yml": /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("confbox/yaml"))).then((r) => r.parseYAML), ".yml"),
|
|
187
|
+
".jsonc": /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("confbox/jsonc"))).then((r) => r.parseJSONC), ".jsonc"),
|
|
188
|
+
".json5": /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("confbox/json5"))).then((r) => r.parseJSON5), ".json5"),
|
|
189
|
+
".toml": /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("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 = _pathe.resolve.call(void 0, process.cwd(), options.cwd || ".");
|
|
209
|
+
options.name = options.name || "config";
|
|
210
|
+
options.envName = _nullishCoalesce(options.envName, () => ( process.env.NODE_ENV));
|
|
211
|
+
options.configFile = _nullishCoalesce(options.configFile, () => ( (options.name === "config" ? "config" : `${options.name}.config`)));
|
|
212
|
+
options.rcFile = _nullishCoalesce(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 || _jiti.createJiti.call(void 0, _pathe.join.call(void 0, 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: _pathe.resolve.call(void 0, 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 _pkgtypes.findWorkspaceDir.call(void 0, 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 _pkgtypes.readPackageJSON.call(void 0, options.cwd).catch(() => {
|
|
268
|
+
});
|
|
269
|
+
const values = keys.map((key) => _optionalChain([pkgJsonFile, 'optionalAccess', _5 => _5[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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, 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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, 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 Promise.resolve().then(() => _interopRequireWildcard(require("giget")));
|
|
389
|
+
const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + _ohash.hash.call(void 0, source);
|
|
390
|
+
let cloneDir;
|
|
391
|
+
const localNodeModules = _pathe.resolve.call(void 0, options.cwd, "node_modules");
|
|
392
|
+
const parentDir = _pathe.dirname.call(void 0, options.cwd);
|
|
393
|
+
if (_pathe.basename.call(void 0, parentDir) === ".c12") {
|
|
394
|
+
cloneDir = _pathe.join.call(void 0, parentDir, cloneName);
|
|
395
|
+
} else if (_fs.existsSync.call(void 0, localNodeModules)) {
|
|
396
|
+
cloneDir = _pathe.join.call(void 0, localNodeModules, ".c12", cloneName);
|
|
397
|
+
} else {
|
|
398
|
+
cloneDir = process.env.XDG_CACHE_HOME ? _pathe.resolve.call(void 0, process.env.XDG_CACHE_HOME, "c12", cloneName) : _pathe.resolve.call(void 0, _os.homedir.call(void 0, ), ".cache/c12", cloneName);
|
|
399
|
+
}
|
|
400
|
+
if (_fs.existsSync.call(void 0, cloneDir) && !sourceOptions.install) {
|
|
401
|
+
await _promises.rm.call(void 0, 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__ */ _chunkXJEQHMOEjs.__name.call(void 0, (id) => {
|
|
414
|
+
const resolved = options.jiti.esmResolve(id, { try: true });
|
|
415
|
+
return resolved ? _mlly.fileURLToPath.call(void 0, resolved) : void 0;
|
|
416
|
+
}, "tryResolve");
|
|
417
|
+
if (NPM_PACKAGE_RE.test(source)) {
|
|
418
|
+
source = tryResolve(source) || source;
|
|
419
|
+
}
|
|
420
|
+
const ext = _pathe.extname.call(void 0, source);
|
|
421
|
+
const isDir = !ext || ext === _pathe.basename.call(void 0, source);
|
|
422
|
+
const cwd = _pathe.resolve.call(void 0, options.cwd, isDir ? source : _pathe.dirname.call(void 0, 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(_pathe.resolve.call(void 0, cwd, source)) || tryResolve(_pathe.resolve.call(void 0, cwd, ".config", source.replace(/\.config$/, ""))) || tryResolve(_pathe.resolve.call(void 0, cwd, ".config", source)) || source;
|
|
434
|
+
if (!_fs.existsSync.call(void 0, res.configFile)) {
|
|
435
|
+
return res;
|
|
436
|
+
}
|
|
437
|
+
const configFileExt = _pathe.extname.call(void 0, res.configFile) || "";
|
|
438
|
+
if (configFileExt in ASYNC_LOADERS) {
|
|
439
|
+
const asyncLoader = await ASYNC_LOADERS[configFileExt]();
|
|
440
|
+
const contents = await _promises.readFile.call(void 0, 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
|
+
..._optionalChain([res, 'access', _6 => _6.config, 'access', _7 => _7.$env, 'optionalAccess', _8 => _8[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
|
+
_chunkXJEQHMOEjs.__name.call(void 0, resolveConfig, "resolveConfig");
|
|
469
|
+
|
|
470
|
+
// ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/index.mjs
|
|
471
|
+
var _perfectdebounce = require('perfect-debounce');
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
// src/config-file/get-config-file.ts
|
|
484
|
+
var getConfigFileByName = /* @__PURE__ */ _chunkXJEQHMOEjs.__name.call(void 0, async (fileName, filePath, options = {}) => {
|
|
485
|
+
const workspacePath = filePath || _chunk6SJLAEJ3js.findWorkspaceRoot.call(void 0, filePath);
|
|
486
|
+
let config = loadConfig({
|
|
487
|
+
cwd: workspacePath,
|
|
488
|
+
packageJson: true,
|
|
489
|
+
name: fileName,
|
|
490
|
+
envName: _optionalChain([fileName, 'optionalAccess', _9 => _9.toUpperCase, 'call', _10 => _10()]),
|
|
491
|
+
jitiOptions: {
|
|
492
|
+
debug: false,
|
|
493
|
+
cache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkH6XXDZ7Ajs.joinPaths.call(void 0, 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: _optionalChain([fileName, 'optionalAccess', _11 => _11.toUpperCase, 'call', _12 => _12()]),
|
|
503
|
+
jitiOptions: {
|
|
504
|
+
debug: false,
|
|
505
|
+
cache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkH6XXDZ7Ajs.joinPaths.call(void 0, 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__ */ _chunkXJEQHMOEjs.__name.call(void 0, async (filePath, additionalFileNames = []) => {
|
|
514
|
+
const workspacePath = filePath ? filePath : _chunk6SJLAEJ3js.findWorkspaceRoot.call(void 0, 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
|
+
_chunkOXK45X3Ljs.writeSystem.call(void 0, `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 (_optionalChain([result2, 'optionalAccess', _13 => _13.config]) && _optionalChain([result2, 'optionalAccess', _14 => _14.configFile]) && Object.keys(result2.config).length > 0) {
|
|
527
|
+
_chunkOXK45X3Ljs.writeSystem.call(void 0, `Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
|
|
528
|
+
logLevel: "all"
|
|
529
|
+
});
|
|
530
|
+
config = defu(_nullishCoalesce(result2.config, () => ( {})), _nullishCoalesce(config, () => ( {})));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (!config) {
|
|
535
|
+
return void 0;
|
|
536
|
+
}
|
|
537
|
+
config.configFile = configFile;
|
|
538
|
+
return config;
|
|
539
|
+
}, "getConfigFile");
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
exports.defu = defu; exports.getConfigFileByName = getConfigFileByName; exports.getConfigFile = getConfigFile;
|