@abhinav2-3/core 0.1.0
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/index.d.mts +115 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +2505 -0
- package/dist/index.mjs +2493 -0
- package/package.json +26 -0
- package/src/constants/paths.ts +55 -0
- package/src/environment/index.ts +16 -0
- package/src/features/apply-features.ts +171 -0
- package/src/features/index.ts +3 -0
- package/src/features/registry.ts +222 -0
- package/src/features/resolver.ts +19 -0
- package/src/filesystem/index.ts +45 -0
- package/src/generator/generateProject.ts +91 -0
- package/src/git/index.ts +22 -0
- package/src/index.ts +3 -0
- package/src/installers/base.ts +31 -0
- package/src/installers/implementations.ts +28 -0
- package/src/installers/index.ts +16 -0
- package/src/resolvers/templateResolver.ts +26 -0
- package/src/template-engine/index.ts +21 -0
- package/src/types.ts +38 -0
- package/tsconfig.json +13 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2505 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/isexe/windows.js
|
|
34
|
+
var require_windows = __commonJS({
|
|
35
|
+
"../../node_modules/isexe/windows.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
module2.exports = isexe;
|
|
38
|
+
isexe.sync = sync;
|
|
39
|
+
var fs8 = require("fs");
|
|
40
|
+
function checkPathExt(path8, options) {
|
|
41
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
42
|
+
if (!pathext) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
pathext = pathext.split(";");
|
|
46
|
+
if (pathext.indexOf("") !== -1) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
50
|
+
var p = pathext[i].toLowerCase();
|
|
51
|
+
if (p && path8.substr(-p.length).toLowerCase() === p) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
function checkStat(stat, path8, options) {
|
|
58
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return checkPathExt(path8, options);
|
|
62
|
+
}
|
|
63
|
+
function isexe(path8, options, cb) {
|
|
64
|
+
fs8.stat(path8, function(er, stat) {
|
|
65
|
+
cb(er, er ? false : checkStat(stat, path8, options));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function sync(path8, options) {
|
|
69
|
+
return checkStat(fs8.statSync(path8), path8, options);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/isexe/mode.js
|
|
75
|
+
var require_mode = __commonJS({
|
|
76
|
+
"../../node_modules/isexe/mode.js"(exports2, module2) {
|
|
77
|
+
"use strict";
|
|
78
|
+
module2.exports = isexe;
|
|
79
|
+
isexe.sync = sync;
|
|
80
|
+
var fs8 = require("fs");
|
|
81
|
+
function isexe(path8, options, cb) {
|
|
82
|
+
fs8.stat(path8, function(er, stat) {
|
|
83
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function sync(path8, options) {
|
|
87
|
+
return checkStat(fs8.statSync(path8), options);
|
|
88
|
+
}
|
|
89
|
+
function checkStat(stat, options) {
|
|
90
|
+
return stat.isFile() && checkMode(stat, options);
|
|
91
|
+
}
|
|
92
|
+
function checkMode(stat, options) {
|
|
93
|
+
var mod = stat.mode;
|
|
94
|
+
var uid = stat.uid;
|
|
95
|
+
var gid = stat.gid;
|
|
96
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
97
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
98
|
+
var u = parseInt("100", 8);
|
|
99
|
+
var g = parseInt("010", 8);
|
|
100
|
+
var o = parseInt("001", 8);
|
|
101
|
+
var ug = u | g;
|
|
102
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
103
|
+
return ret;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// ../../node_modules/isexe/index.js
|
|
109
|
+
var require_isexe = __commonJS({
|
|
110
|
+
"../../node_modules/isexe/index.js"(exports2, module2) {
|
|
111
|
+
"use strict";
|
|
112
|
+
var fs8 = require("fs");
|
|
113
|
+
var core;
|
|
114
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
115
|
+
core = require_windows();
|
|
116
|
+
} else {
|
|
117
|
+
core = require_mode();
|
|
118
|
+
}
|
|
119
|
+
module2.exports = isexe;
|
|
120
|
+
isexe.sync = sync;
|
|
121
|
+
function isexe(path8, options, cb) {
|
|
122
|
+
if (typeof options === "function") {
|
|
123
|
+
cb = options;
|
|
124
|
+
options = {};
|
|
125
|
+
}
|
|
126
|
+
if (!cb) {
|
|
127
|
+
if (typeof Promise !== "function") {
|
|
128
|
+
throw new TypeError("callback not provided");
|
|
129
|
+
}
|
|
130
|
+
return new Promise(function(resolve, reject) {
|
|
131
|
+
isexe(path8, options || {}, function(er, is) {
|
|
132
|
+
if (er) {
|
|
133
|
+
reject(er);
|
|
134
|
+
} else {
|
|
135
|
+
resolve(is);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
core(path8, options || {}, function(er, is) {
|
|
141
|
+
if (er) {
|
|
142
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
143
|
+
er = null;
|
|
144
|
+
is = false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
cb(er, is);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function sync(path8, options) {
|
|
151
|
+
try {
|
|
152
|
+
return core.sync(path8, options || {});
|
|
153
|
+
} catch (er) {
|
|
154
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
155
|
+
return false;
|
|
156
|
+
} else {
|
|
157
|
+
throw er;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// ../../node_modules/which/which.js
|
|
165
|
+
var require_which = __commonJS({
|
|
166
|
+
"../../node_modules/which/which.js"(exports2, module2) {
|
|
167
|
+
"use strict";
|
|
168
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
169
|
+
var path8 = require("path");
|
|
170
|
+
var COLON = isWindows ? ";" : ":";
|
|
171
|
+
var isexe = require_isexe();
|
|
172
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
173
|
+
var getPathInfo = (cmd, opt) => {
|
|
174
|
+
const colon = opt.colon || COLON;
|
|
175
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
176
|
+
// windows always checks the cwd first
|
|
177
|
+
...isWindows ? [process.cwd()] : [],
|
|
178
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
179
|
+
"").split(colon)
|
|
180
|
+
];
|
|
181
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
182
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
183
|
+
if (isWindows) {
|
|
184
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
185
|
+
pathExt.unshift("");
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
pathEnv,
|
|
189
|
+
pathExt,
|
|
190
|
+
pathExtExe
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
var which = (cmd, opt, cb) => {
|
|
194
|
+
if (typeof opt === "function") {
|
|
195
|
+
cb = opt;
|
|
196
|
+
opt = {};
|
|
197
|
+
}
|
|
198
|
+
if (!opt)
|
|
199
|
+
opt = {};
|
|
200
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
201
|
+
const found = [];
|
|
202
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
203
|
+
if (i === pathEnv.length)
|
|
204
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
205
|
+
const ppRaw = pathEnv[i];
|
|
206
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
207
|
+
const pCmd = path8.join(pathPart, cmd);
|
|
208
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
209
|
+
resolve(subStep(p, i, 0));
|
|
210
|
+
});
|
|
211
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
212
|
+
if (ii === pathExt.length)
|
|
213
|
+
return resolve(step(i + 1));
|
|
214
|
+
const ext = pathExt[ii];
|
|
215
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
216
|
+
if (!er && is) {
|
|
217
|
+
if (opt.all)
|
|
218
|
+
found.push(p + ext);
|
|
219
|
+
else
|
|
220
|
+
return resolve(p + ext);
|
|
221
|
+
}
|
|
222
|
+
return resolve(subStep(p, i, ii + 1));
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
226
|
+
};
|
|
227
|
+
var whichSync = (cmd, opt) => {
|
|
228
|
+
opt = opt || {};
|
|
229
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
230
|
+
const found = [];
|
|
231
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
232
|
+
const ppRaw = pathEnv[i];
|
|
233
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
234
|
+
const pCmd = path8.join(pathPart, cmd);
|
|
235
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
236
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
237
|
+
const cur = p + pathExt[j];
|
|
238
|
+
try {
|
|
239
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
240
|
+
if (is) {
|
|
241
|
+
if (opt.all)
|
|
242
|
+
found.push(cur);
|
|
243
|
+
else
|
|
244
|
+
return cur;
|
|
245
|
+
}
|
|
246
|
+
} catch (ex) {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (opt.all && found.length)
|
|
251
|
+
return found;
|
|
252
|
+
if (opt.nothrow)
|
|
253
|
+
return null;
|
|
254
|
+
throw getNotFoundError(cmd);
|
|
255
|
+
};
|
|
256
|
+
module2.exports = which;
|
|
257
|
+
which.sync = whichSync;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// ../../node_modules/path-key/index.js
|
|
262
|
+
var require_path_key = __commonJS({
|
|
263
|
+
"../../node_modules/path-key/index.js"(exports2, module2) {
|
|
264
|
+
"use strict";
|
|
265
|
+
var pathKey = (options = {}) => {
|
|
266
|
+
const environment = options.env || process.env;
|
|
267
|
+
const platform = options.platform || process.platform;
|
|
268
|
+
if (platform !== "win32") {
|
|
269
|
+
return "PATH";
|
|
270
|
+
}
|
|
271
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
272
|
+
};
|
|
273
|
+
module2.exports = pathKey;
|
|
274
|
+
module2.exports.default = pathKey;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ../../node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
279
|
+
var require_resolveCommand = __commonJS({
|
|
280
|
+
"../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
281
|
+
"use strict";
|
|
282
|
+
var path8 = require("path");
|
|
283
|
+
var which = require_which();
|
|
284
|
+
var getPathKey = require_path_key();
|
|
285
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
286
|
+
const env = parsed.options.env || process.env;
|
|
287
|
+
const cwd = process.cwd();
|
|
288
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
289
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
290
|
+
if (shouldSwitchCwd) {
|
|
291
|
+
try {
|
|
292
|
+
process.chdir(parsed.options.cwd);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
let resolved;
|
|
297
|
+
try {
|
|
298
|
+
resolved = which.sync(parsed.command, {
|
|
299
|
+
path: env[getPathKey({ env })],
|
|
300
|
+
pathExt: withoutPathExt ? path8.delimiter : void 0
|
|
301
|
+
});
|
|
302
|
+
} catch (e) {
|
|
303
|
+
} finally {
|
|
304
|
+
if (shouldSwitchCwd) {
|
|
305
|
+
process.chdir(cwd);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (resolved) {
|
|
309
|
+
resolved = path8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
310
|
+
}
|
|
311
|
+
return resolved;
|
|
312
|
+
}
|
|
313
|
+
function resolveCommand(parsed) {
|
|
314
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
315
|
+
}
|
|
316
|
+
module2.exports = resolveCommand;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// ../../node_modules/cross-spawn/lib/util/escape.js
|
|
321
|
+
var require_escape = __commonJS({
|
|
322
|
+
"../../node_modules/cross-spawn/lib/util/escape.js"(exports2, module2) {
|
|
323
|
+
"use strict";
|
|
324
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
325
|
+
function escapeCommand(arg) {
|
|
326
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
327
|
+
return arg;
|
|
328
|
+
}
|
|
329
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
330
|
+
arg = `${arg}`;
|
|
331
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
332
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
333
|
+
arg = `"${arg}"`;
|
|
334
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
335
|
+
if (doubleEscapeMetaChars) {
|
|
336
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
337
|
+
}
|
|
338
|
+
return arg;
|
|
339
|
+
}
|
|
340
|
+
module2.exports.command = escapeCommand;
|
|
341
|
+
module2.exports.argument = escapeArgument;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ../../node_modules/shebang-regex/index.js
|
|
346
|
+
var require_shebang_regex = __commonJS({
|
|
347
|
+
"../../node_modules/shebang-regex/index.js"(exports2, module2) {
|
|
348
|
+
"use strict";
|
|
349
|
+
module2.exports = /^#!(.*)/;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// ../../node_modules/shebang-command/index.js
|
|
354
|
+
var require_shebang_command = __commonJS({
|
|
355
|
+
"../../node_modules/shebang-command/index.js"(exports2, module2) {
|
|
356
|
+
"use strict";
|
|
357
|
+
var shebangRegex = require_shebang_regex();
|
|
358
|
+
module2.exports = (string = "") => {
|
|
359
|
+
const match = string.match(shebangRegex);
|
|
360
|
+
if (!match) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
364
|
+
const binary = path8.split("/").pop();
|
|
365
|
+
if (binary === "env") {
|
|
366
|
+
return argument;
|
|
367
|
+
}
|
|
368
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// ../../node_modules/cross-spawn/lib/util/readShebang.js
|
|
374
|
+
var require_readShebang = __commonJS({
|
|
375
|
+
"../../node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
376
|
+
"use strict";
|
|
377
|
+
var fs8 = require("fs");
|
|
378
|
+
var shebangCommand = require_shebang_command();
|
|
379
|
+
function readShebang(command) {
|
|
380
|
+
const size = 150;
|
|
381
|
+
const buffer = Buffer.alloc(size);
|
|
382
|
+
let fd;
|
|
383
|
+
try {
|
|
384
|
+
fd = fs8.openSync(command, "r");
|
|
385
|
+
fs8.readSync(fd, buffer, 0, size, 0);
|
|
386
|
+
fs8.closeSync(fd);
|
|
387
|
+
} catch (e) {
|
|
388
|
+
}
|
|
389
|
+
return shebangCommand(buffer.toString());
|
|
390
|
+
}
|
|
391
|
+
module2.exports = readShebang;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// ../../node_modules/cross-spawn/lib/parse.js
|
|
396
|
+
var require_parse = __commonJS({
|
|
397
|
+
"../../node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
398
|
+
"use strict";
|
|
399
|
+
var path8 = require("path");
|
|
400
|
+
var resolveCommand = require_resolveCommand();
|
|
401
|
+
var escape = require_escape();
|
|
402
|
+
var readShebang = require_readShebang();
|
|
403
|
+
var isWin = process.platform === "win32";
|
|
404
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
405
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
406
|
+
function detectShebang(parsed) {
|
|
407
|
+
parsed.file = resolveCommand(parsed);
|
|
408
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
409
|
+
if (shebang) {
|
|
410
|
+
parsed.args.unshift(parsed.file);
|
|
411
|
+
parsed.command = shebang;
|
|
412
|
+
return resolveCommand(parsed);
|
|
413
|
+
}
|
|
414
|
+
return parsed.file;
|
|
415
|
+
}
|
|
416
|
+
function parseNonShell(parsed) {
|
|
417
|
+
if (!isWin) {
|
|
418
|
+
return parsed;
|
|
419
|
+
}
|
|
420
|
+
const commandFile = detectShebang(parsed);
|
|
421
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
422
|
+
if (parsed.options.forceShell || needsShell) {
|
|
423
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
424
|
+
parsed.command = path8.normalize(parsed.command);
|
|
425
|
+
parsed.command = escape.command(parsed.command);
|
|
426
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
427
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
428
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
429
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
430
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
431
|
+
}
|
|
432
|
+
return parsed;
|
|
433
|
+
}
|
|
434
|
+
function parse(command, args, options) {
|
|
435
|
+
if (args && !Array.isArray(args)) {
|
|
436
|
+
options = args;
|
|
437
|
+
args = null;
|
|
438
|
+
}
|
|
439
|
+
args = args ? args.slice(0) : [];
|
|
440
|
+
options = Object.assign({}, options);
|
|
441
|
+
const parsed = {
|
|
442
|
+
command,
|
|
443
|
+
args,
|
|
444
|
+
options,
|
|
445
|
+
file: void 0,
|
|
446
|
+
original: {
|
|
447
|
+
command,
|
|
448
|
+
args
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
452
|
+
}
|
|
453
|
+
module2.exports = parse;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// ../../node_modules/cross-spawn/lib/enoent.js
|
|
458
|
+
var require_enoent = __commonJS({
|
|
459
|
+
"../../node_modules/cross-spawn/lib/enoent.js"(exports2, module2) {
|
|
460
|
+
"use strict";
|
|
461
|
+
var isWin = process.platform === "win32";
|
|
462
|
+
function notFoundError(original, syscall) {
|
|
463
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
464
|
+
code: "ENOENT",
|
|
465
|
+
errno: "ENOENT",
|
|
466
|
+
syscall: `${syscall} ${original.command}`,
|
|
467
|
+
path: original.command,
|
|
468
|
+
spawnargs: original.args
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
function hookChildProcess(cp, parsed) {
|
|
472
|
+
if (!isWin) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const originalEmit = cp.emit;
|
|
476
|
+
cp.emit = function(name, arg1) {
|
|
477
|
+
if (name === "exit") {
|
|
478
|
+
const err = verifyENOENT(arg1, parsed);
|
|
479
|
+
if (err) {
|
|
480
|
+
return originalEmit.call(cp, "error", err);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return originalEmit.apply(cp, arguments);
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function verifyENOENT(status, parsed) {
|
|
487
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
488
|
+
return notFoundError(parsed.original, "spawn");
|
|
489
|
+
}
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
function verifyENOENTSync(status, parsed) {
|
|
493
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
494
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
495
|
+
}
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
module2.exports = {
|
|
499
|
+
hookChildProcess,
|
|
500
|
+
verifyENOENT,
|
|
501
|
+
verifyENOENTSync,
|
|
502
|
+
notFoundError
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// ../../node_modules/cross-spawn/index.js
|
|
508
|
+
var require_cross_spawn = __commonJS({
|
|
509
|
+
"../../node_modules/cross-spawn/index.js"(exports2, module2) {
|
|
510
|
+
"use strict";
|
|
511
|
+
var cp = require("child_process");
|
|
512
|
+
var parse = require_parse();
|
|
513
|
+
var enoent = require_enoent();
|
|
514
|
+
function spawn(command, args, options) {
|
|
515
|
+
const parsed = parse(command, args, options);
|
|
516
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
517
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
518
|
+
return spawned;
|
|
519
|
+
}
|
|
520
|
+
function spawnSync(command, args, options) {
|
|
521
|
+
const parsed = parse(command, args, options);
|
|
522
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
523
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
524
|
+
return result;
|
|
525
|
+
}
|
|
526
|
+
module2.exports = spawn;
|
|
527
|
+
module2.exports.spawn = spawn;
|
|
528
|
+
module2.exports.sync = spawnSync;
|
|
529
|
+
module2.exports._parse = parse;
|
|
530
|
+
module2.exports._enoent = enoent;
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// ../../node_modules/strip-final-newline/index.js
|
|
535
|
+
var require_strip_final_newline = __commonJS({
|
|
536
|
+
"../../node_modules/strip-final-newline/index.js"(exports2, module2) {
|
|
537
|
+
"use strict";
|
|
538
|
+
module2.exports = (input) => {
|
|
539
|
+
const LF = typeof input === "string" ? "\n" : "\n".charCodeAt();
|
|
540
|
+
const CR = typeof input === "string" ? "\r" : "\r".charCodeAt();
|
|
541
|
+
if (input[input.length - 1] === LF) {
|
|
542
|
+
input = input.slice(0, input.length - 1);
|
|
543
|
+
}
|
|
544
|
+
if (input[input.length - 1] === CR) {
|
|
545
|
+
input = input.slice(0, input.length - 1);
|
|
546
|
+
}
|
|
547
|
+
return input;
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// ../../node_modules/npm-run-path/index.js
|
|
553
|
+
var require_npm_run_path = __commonJS({
|
|
554
|
+
"../../node_modules/npm-run-path/index.js"(exports2, module2) {
|
|
555
|
+
"use strict";
|
|
556
|
+
var path8 = require("path");
|
|
557
|
+
var pathKey = require_path_key();
|
|
558
|
+
var npmRunPath = (options) => {
|
|
559
|
+
options = {
|
|
560
|
+
cwd: process.cwd(),
|
|
561
|
+
path: process.env[pathKey()],
|
|
562
|
+
execPath: process.execPath,
|
|
563
|
+
...options
|
|
564
|
+
};
|
|
565
|
+
let previous;
|
|
566
|
+
let cwdPath = path8.resolve(options.cwd);
|
|
567
|
+
const result = [];
|
|
568
|
+
while (previous !== cwdPath) {
|
|
569
|
+
result.push(path8.join(cwdPath, "node_modules/.bin"));
|
|
570
|
+
previous = cwdPath;
|
|
571
|
+
cwdPath = path8.resolve(cwdPath, "..");
|
|
572
|
+
}
|
|
573
|
+
const execPathDir = path8.resolve(options.cwd, options.execPath, "..");
|
|
574
|
+
result.push(execPathDir);
|
|
575
|
+
return result.concat(options.path).join(path8.delimiter);
|
|
576
|
+
};
|
|
577
|
+
module2.exports = npmRunPath;
|
|
578
|
+
module2.exports.default = npmRunPath;
|
|
579
|
+
module2.exports.env = (options) => {
|
|
580
|
+
options = {
|
|
581
|
+
env: process.env,
|
|
582
|
+
...options
|
|
583
|
+
};
|
|
584
|
+
const env = { ...options.env };
|
|
585
|
+
const path9 = pathKey({ env });
|
|
586
|
+
options.path = env[path9];
|
|
587
|
+
env[path9] = module2.exports(options);
|
|
588
|
+
return env;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// ../../node_modules/mimic-fn/index.js
|
|
594
|
+
var require_mimic_fn = __commonJS({
|
|
595
|
+
"../../node_modules/mimic-fn/index.js"(exports2, module2) {
|
|
596
|
+
"use strict";
|
|
597
|
+
var mimicFn = (to, from) => {
|
|
598
|
+
for (const prop of Reflect.ownKeys(from)) {
|
|
599
|
+
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
|
|
600
|
+
}
|
|
601
|
+
return to;
|
|
602
|
+
};
|
|
603
|
+
module2.exports = mimicFn;
|
|
604
|
+
module2.exports.default = mimicFn;
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// ../../node_modules/onetime/index.js
|
|
609
|
+
var require_onetime = __commonJS({
|
|
610
|
+
"../../node_modules/onetime/index.js"(exports2, module2) {
|
|
611
|
+
"use strict";
|
|
612
|
+
var mimicFn = require_mimic_fn();
|
|
613
|
+
var calledFunctions = /* @__PURE__ */ new WeakMap();
|
|
614
|
+
var onetime = (function_, options = {}) => {
|
|
615
|
+
if (typeof function_ !== "function") {
|
|
616
|
+
throw new TypeError("Expected a function");
|
|
617
|
+
}
|
|
618
|
+
let returnValue;
|
|
619
|
+
let callCount = 0;
|
|
620
|
+
const functionName = function_.displayName || function_.name || "<anonymous>";
|
|
621
|
+
const onetime2 = function(...arguments_) {
|
|
622
|
+
calledFunctions.set(onetime2, ++callCount);
|
|
623
|
+
if (callCount === 1) {
|
|
624
|
+
returnValue = function_.apply(this, arguments_);
|
|
625
|
+
function_ = null;
|
|
626
|
+
} else if (options.throw === true) {
|
|
627
|
+
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
628
|
+
}
|
|
629
|
+
return returnValue;
|
|
630
|
+
};
|
|
631
|
+
mimicFn(onetime2, function_);
|
|
632
|
+
calledFunctions.set(onetime2, callCount);
|
|
633
|
+
return onetime2;
|
|
634
|
+
};
|
|
635
|
+
module2.exports = onetime;
|
|
636
|
+
module2.exports.default = onetime;
|
|
637
|
+
module2.exports.callCount = (function_) => {
|
|
638
|
+
if (!calledFunctions.has(function_)) {
|
|
639
|
+
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
640
|
+
}
|
|
641
|
+
return calledFunctions.get(function_);
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
// ../../node_modules/human-signals/build/src/core.js
|
|
647
|
+
var require_core = __commonJS({
|
|
648
|
+
"../../node_modules/human-signals/build/src/core.js"(exports2) {
|
|
649
|
+
"use strict";
|
|
650
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
651
|
+
exports2.SIGNALS = void 0;
|
|
652
|
+
var SIGNALS = [
|
|
653
|
+
{
|
|
654
|
+
name: "SIGHUP",
|
|
655
|
+
number: 1,
|
|
656
|
+
action: "terminate",
|
|
657
|
+
description: "Terminal closed",
|
|
658
|
+
standard: "posix"
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: "SIGINT",
|
|
662
|
+
number: 2,
|
|
663
|
+
action: "terminate",
|
|
664
|
+
description: "User interruption with CTRL-C",
|
|
665
|
+
standard: "ansi"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
name: "SIGQUIT",
|
|
669
|
+
number: 3,
|
|
670
|
+
action: "core",
|
|
671
|
+
description: "User interruption with CTRL-\\",
|
|
672
|
+
standard: "posix"
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: "SIGILL",
|
|
676
|
+
number: 4,
|
|
677
|
+
action: "core",
|
|
678
|
+
description: "Invalid machine instruction",
|
|
679
|
+
standard: "ansi"
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: "SIGTRAP",
|
|
683
|
+
number: 5,
|
|
684
|
+
action: "core",
|
|
685
|
+
description: "Debugger breakpoint",
|
|
686
|
+
standard: "posix"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
name: "SIGABRT",
|
|
690
|
+
number: 6,
|
|
691
|
+
action: "core",
|
|
692
|
+
description: "Aborted",
|
|
693
|
+
standard: "ansi"
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
name: "SIGIOT",
|
|
697
|
+
number: 6,
|
|
698
|
+
action: "core",
|
|
699
|
+
description: "Aborted",
|
|
700
|
+
standard: "bsd"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
name: "SIGBUS",
|
|
704
|
+
number: 7,
|
|
705
|
+
action: "core",
|
|
706
|
+
description: "Bus error due to misaligned, non-existing address or paging error",
|
|
707
|
+
standard: "bsd"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
name: "SIGEMT",
|
|
711
|
+
number: 7,
|
|
712
|
+
action: "terminate",
|
|
713
|
+
description: "Command should be emulated but is not implemented",
|
|
714
|
+
standard: "other"
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
name: "SIGFPE",
|
|
718
|
+
number: 8,
|
|
719
|
+
action: "core",
|
|
720
|
+
description: "Floating point arithmetic error",
|
|
721
|
+
standard: "ansi"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
name: "SIGKILL",
|
|
725
|
+
number: 9,
|
|
726
|
+
action: "terminate",
|
|
727
|
+
description: "Forced termination",
|
|
728
|
+
standard: "posix",
|
|
729
|
+
forced: true
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
name: "SIGUSR1",
|
|
733
|
+
number: 10,
|
|
734
|
+
action: "terminate",
|
|
735
|
+
description: "Application-specific signal",
|
|
736
|
+
standard: "posix"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: "SIGSEGV",
|
|
740
|
+
number: 11,
|
|
741
|
+
action: "core",
|
|
742
|
+
description: "Segmentation fault",
|
|
743
|
+
standard: "ansi"
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
name: "SIGUSR2",
|
|
747
|
+
number: 12,
|
|
748
|
+
action: "terminate",
|
|
749
|
+
description: "Application-specific signal",
|
|
750
|
+
standard: "posix"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
name: "SIGPIPE",
|
|
754
|
+
number: 13,
|
|
755
|
+
action: "terminate",
|
|
756
|
+
description: "Broken pipe or socket",
|
|
757
|
+
standard: "posix"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
name: "SIGALRM",
|
|
761
|
+
number: 14,
|
|
762
|
+
action: "terminate",
|
|
763
|
+
description: "Timeout or timer",
|
|
764
|
+
standard: "posix"
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
name: "SIGTERM",
|
|
768
|
+
number: 15,
|
|
769
|
+
action: "terminate",
|
|
770
|
+
description: "Termination",
|
|
771
|
+
standard: "ansi"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
name: "SIGSTKFLT",
|
|
775
|
+
number: 16,
|
|
776
|
+
action: "terminate",
|
|
777
|
+
description: "Stack is empty or overflowed",
|
|
778
|
+
standard: "other"
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
name: "SIGCHLD",
|
|
782
|
+
number: 17,
|
|
783
|
+
action: "ignore",
|
|
784
|
+
description: "Child process terminated, paused or unpaused",
|
|
785
|
+
standard: "posix"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
name: "SIGCLD",
|
|
789
|
+
number: 17,
|
|
790
|
+
action: "ignore",
|
|
791
|
+
description: "Child process terminated, paused or unpaused",
|
|
792
|
+
standard: "other"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
name: "SIGCONT",
|
|
796
|
+
number: 18,
|
|
797
|
+
action: "unpause",
|
|
798
|
+
description: "Unpaused",
|
|
799
|
+
standard: "posix",
|
|
800
|
+
forced: true
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
name: "SIGSTOP",
|
|
804
|
+
number: 19,
|
|
805
|
+
action: "pause",
|
|
806
|
+
description: "Paused",
|
|
807
|
+
standard: "posix",
|
|
808
|
+
forced: true
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
name: "SIGTSTP",
|
|
812
|
+
number: 20,
|
|
813
|
+
action: "pause",
|
|
814
|
+
description: 'Paused using CTRL-Z or "suspend"',
|
|
815
|
+
standard: "posix"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
name: "SIGTTIN",
|
|
819
|
+
number: 21,
|
|
820
|
+
action: "pause",
|
|
821
|
+
description: "Background process cannot read terminal input",
|
|
822
|
+
standard: "posix"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
name: "SIGBREAK",
|
|
826
|
+
number: 21,
|
|
827
|
+
action: "terminate",
|
|
828
|
+
description: "User interruption with CTRL-BREAK",
|
|
829
|
+
standard: "other"
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
name: "SIGTTOU",
|
|
833
|
+
number: 22,
|
|
834
|
+
action: "pause",
|
|
835
|
+
description: "Background process cannot write to terminal output",
|
|
836
|
+
standard: "posix"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
name: "SIGURG",
|
|
840
|
+
number: 23,
|
|
841
|
+
action: "ignore",
|
|
842
|
+
description: "Socket received out-of-band data",
|
|
843
|
+
standard: "bsd"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
name: "SIGXCPU",
|
|
847
|
+
number: 24,
|
|
848
|
+
action: "core",
|
|
849
|
+
description: "Process timed out",
|
|
850
|
+
standard: "bsd"
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
name: "SIGXFSZ",
|
|
854
|
+
number: 25,
|
|
855
|
+
action: "core",
|
|
856
|
+
description: "File too big",
|
|
857
|
+
standard: "bsd"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
name: "SIGVTALRM",
|
|
861
|
+
number: 26,
|
|
862
|
+
action: "terminate",
|
|
863
|
+
description: "Timeout or timer",
|
|
864
|
+
standard: "bsd"
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
name: "SIGPROF",
|
|
868
|
+
number: 27,
|
|
869
|
+
action: "terminate",
|
|
870
|
+
description: "Timeout or timer",
|
|
871
|
+
standard: "bsd"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
name: "SIGWINCH",
|
|
875
|
+
number: 28,
|
|
876
|
+
action: "ignore",
|
|
877
|
+
description: "Terminal window size changed",
|
|
878
|
+
standard: "bsd"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
name: "SIGIO",
|
|
882
|
+
number: 29,
|
|
883
|
+
action: "terminate",
|
|
884
|
+
description: "I/O is available",
|
|
885
|
+
standard: "other"
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
name: "SIGPOLL",
|
|
889
|
+
number: 29,
|
|
890
|
+
action: "terminate",
|
|
891
|
+
description: "Watched event",
|
|
892
|
+
standard: "other"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
name: "SIGINFO",
|
|
896
|
+
number: 29,
|
|
897
|
+
action: "ignore",
|
|
898
|
+
description: "Request for process information",
|
|
899
|
+
standard: "other"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
name: "SIGPWR",
|
|
903
|
+
number: 30,
|
|
904
|
+
action: "terminate",
|
|
905
|
+
description: "Device running out of power",
|
|
906
|
+
standard: "systemv"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
name: "SIGSYS",
|
|
910
|
+
number: 31,
|
|
911
|
+
action: "core",
|
|
912
|
+
description: "Invalid system call",
|
|
913
|
+
standard: "other"
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
name: "SIGUNUSED",
|
|
917
|
+
number: 31,
|
|
918
|
+
action: "terminate",
|
|
919
|
+
description: "Invalid system call",
|
|
920
|
+
standard: "other"
|
|
921
|
+
}
|
|
922
|
+
];
|
|
923
|
+
exports2.SIGNALS = SIGNALS;
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
// ../../node_modules/human-signals/build/src/realtime.js
|
|
928
|
+
var require_realtime = __commonJS({
|
|
929
|
+
"../../node_modules/human-signals/build/src/realtime.js"(exports2) {
|
|
930
|
+
"use strict";
|
|
931
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
932
|
+
exports2.SIGRTMAX = exports2.getRealtimeSignals = void 0;
|
|
933
|
+
var getRealtimeSignals = function() {
|
|
934
|
+
const length = SIGRTMAX - SIGRTMIN + 1;
|
|
935
|
+
return Array.from({ length }, getRealtimeSignal);
|
|
936
|
+
};
|
|
937
|
+
exports2.getRealtimeSignals = getRealtimeSignals;
|
|
938
|
+
var getRealtimeSignal = function(value, index) {
|
|
939
|
+
return {
|
|
940
|
+
name: `SIGRT${index + 1}`,
|
|
941
|
+
number: SIGRTMIN + index,
|
|
942
|
+
action: "terminate",
|
|
943
|
+
description: "Application-specific signal (realtime)",
|
|
944
|
+
standard: "posix"
|
|
945
|
+
};
|
|
946
|
+
};
|
|
947
|
+
var SIGRTMIN = 34;
|
|
948
|
+
var SIGRTMAX = 64;
|
|
949
|
+
exports2.SIGRTMAX = SIGRTMAX;
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
// ../../node_modules/human-signals/build/src/signals.js
|
|
954
|
+
var require_signals = __commonJS({
|
|
955
|
+
"../../node_modules/human-signals/build/src/signals.js"(exports2) {
|
|
956
|
+
"use strict";
|
|
957
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
958
|
+
exports2.getSignals = void 0;
|
|
959
|
+
var _os = require("os");
|
|
960
|
+
var _core = require_core();
|
|
961
|
+
var _realtime = require_realtime();
|
|
962
|
+
var getSignals = function() {
|
|
963
|
+
const realtimeSignals = (0, _realtime.getRealtimeSignals)();
|
|
964
|
+
const signals = [..._core.SIGNALS, ...realtimeSignals].map(normalizeSignal);
|
|
965
|
+
return signals;
|
|
966
|
+
};
|
|
967
|
+
exports2.getSignals = getSignals;
|
|
968
|
+
var normalizeSignal = function({
|
|
969
|
+
name,
|
|
970
|
+
number: defaultNumber,
|
|
971
|
+
description,
|
|
972
|
+
action,
|
|
973
|
+
forced = false,
|
|
974
|
+
standard
|
|
975
|
+
}) {
|
|
976
|
+
const {
|
|
977
|
+
signals: { [name]: constantSignal }
|
|
978
|
+
} = _os.constants;
|
|
979
|
+
const supported = constantSignal !== void 0;
|
|
980
|
+
const number = supported ? constantSignal : defaultNumber;
|
|
981
|
+
return { name, number, description, supported, action, forced, standard };
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// ../../node_modules/human-signals/build/src/main.js
|
|
987
|
+
var require_main = __commonJS({
|
|
988
|
+
"../../node_modules/human-signals/build/src/main.js"(exports2) {
|
|
989
|
+
"use strict";
|
|
990
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
991
|
+
exports2.signalsByNumber = exports2.signalsByName = void 0;
|
|
992
|
+
var _os = require("os");
|
|
993
|
+
var _signals = require_signals();
|
|
994
|
+
var _realtime = require_realtime();
|
|
995
|
+
var getSignalsByName = function() {
|
|
996
|
+
const signals = (0, _signals.getSignals)();
|
|
997
|
+
return signals.reduce(getSignalByName, {});
|
|
998
|
+
};
|
|
999
|
+
var getSignalByName = function(signalByNameMemo, { name, number, description, supported, action, forced, standard }) {
|
|
1000
|
+
return {
|
|
1001
|
+
...signalByNameMemo,
|
|
1002
|
+
[name]: { name, number, description, supported, action, forced, standard }
|
|
1003
|
+
};
|
|
1004
|
+
};
|
|
1005
|
+
var signalsByName = getSignalsByName();
|
|
1006
|
+
exports2.signalsByName = signalsByName;
|
|
1007
|
+
var getSignalsByNumber = function() {
|
|
1008
|
+
const signals = (0, _signals.getSignals)();
|
|
1009
|
+
const length = _realtime.SIGRTMAX + 1;
|
|
1010
|
+
const signalsA = Array.from({ length }, (value, number) => getSignalByNumber(number, signals));
|
|
1011
|
+
return Object.assign({}, ...signalsA);
|
|
1012
|
+
};
|
|
1013
|
+
var getSignalByNumber = function(number, signals) {
|
|
1014
|
+
const signal = findSignalByNumber(number, signals);
|
|
1015
|
+
if (signal === void 0) {
|
|
1016
|
+
return {};
|
|
1017
|
+
}
|
|
1018
|
+
const { name, description, supported, action, forced, standard } = signal;
|
|
1019
|
+
return {
|
|
1020
|
+
[number]: {
|
|
1021
|
+
name,
|
|
1022
|
+
number,
|
|
1023
|
+
description,
|
|
1024
|
+
supported,
|
|
1025
|
+
action,
|
|
1026
|
+
forced,
|
|
1027
|
+
standard
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
};
|
|
1031
|
+
var findSignalByNumber = function(number, signals) {
|
|
1032
|
+
const signal = signals.find(({ name }) => _os.constants.signals[name] === number);
|
|
1033
|
+
if (signal !== void 0) {
|
|
1034
|
+
return signal;
|
|
1035
|
+
}
|
|
1036
|
+
return signals.find((signalA) => signalA.number === number);
|
|
1037
|
+
};
|
|
1038
|
+
var signalsByNumber = getSignalsByNumber();
|
|
1039
|
+
exports2.signalsByNumber = signalsByNumber;
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
// ../../node_modules/execa/lib/error.js
|
|
1044
|
+
var require_error = __commonJS({
|
|
1045
|
+
"../../node_modules/execa/lib/error.js"(exports2, module2) {
|
|
1046
|
+
"use strict";
|
|
1047
|
+
var { signalsByName } = require_main();
|
|
1048
|
+
var getErrorPrefix = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
|
|
1049
|
+
if (timedOut) {
|
|
1050
|
+
return `timed out after ${timeout} milliseconds`;
|
|
1051
|
+
}
|
|
1052
|
+
if (isCanceled) {
|
|
1053
|
+
return "was canceled";
|
|
1054
|
+
}
|
|
1055
|
+
if (errorCode !== void 0) {
|
|
1056
|
+
return `failed with ${errorCode}`;
|
|
1057
|
+
}
|
|
1058
|
+
if (signal !== void 0) {
|
|
1059
|
+
return `was killed with ${signal} (${signalDescription})`;
|
|
1060
|
+
}
|
|
1061
|
+
if (exitCode !== void 0) {
|
|
1062
|
+
return `failed with exit code ${exitCode}`;
|
|
1063
|
+
}
|
|
1064
|
+
return "failed";
|
|
1065
|
+
};
|
|
1066
|
+
var makeError = ({
|
|
1067
|
+
stdout,
|
|
1068
|
+
stderr,
|
|
1069
|
+
all,
|
|
1070
|
+
error,
|
|
1071
|
+
signal,
|
|
1072
|
+
exitCode,
|
|
1073
|
+
command,
|
|
1074
|
+
timedOut,
|
|
1075
|
+
isCanceled,
|
|
1076
|
+
killed,
|
|
1077
|
+
parsed: { options: { timeout } }
|
|
1078
|
+
}) => {
|
|
1079
|
+
exitCode = exitCode === null ? void 0 : exitCode;
|
|
1080
|
+
signal = signal === null ? void 0 : signal;
|
|
1081
|
+
const signalDescription = signal === void 0 ? void 0 : signalsByName[signal].description;
|
|
1082
|
+
const errorCode = error && error.code;
|
|
1083
|
+
const prefix = getErrorPrefix({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled });
|
|
1084
|
+
const execaMessage = `Command ${prefix}: ${command}`;
|
|
1085
|
+
const isError = Object.prototype.toString.call(error) === "[object Error]";
|
|
1086
|
+
const shortMessage = isError ? `${execaMessage}
|
|
1087
|
+
${error.message}` : execaMessage;
|
|
1088
|
+
const message = [shortMessage, stderr, stdout].filter(Boolean).join("\n");
|
|
1089
|
+
if (isError) {
|
|
1090
|
+
error.originalMessage = error.message;
|
|
1091
|
+
error.message = message;
|
|
1092
|
+
} else {
|
|
1093
|
+
error = new Error(message);
|
|
1094
|
+
}
|
|
1095
|
+
error.shortMessage = shortMessage;
|
|
1096
|
+
error.command = command;
|
|
1097
|
+
error.exitCode = exitCode;
|
|
1098
|
+
error.signal = signal;
|
|
1099
|
+
error.signalDescription = signalDescription;
|
|
1100
|
+
error.stdout = stdout;
|
|
1101
|
+
error.stderr = stderr;
|
|
1102
|
+
if (all !== void 0) {
|
|
1103
|
+
error.all = all;
|
|
1104
|
+
}
|
|
1105
|
+
if ("bufferedData" in error) {
|
|
1106
|
+
delete error.bufferedData;
|
|
1107
|
+
}
|
|
1108
|
+
error.failed = true;
|
|
1109
|
+
error.timedOut = Boolean(timedOut);
|
|
1110
|
+
error.isCanceled = isCanceled;
|
|
1111
|
+
error.killed = killed && !timedOut;
|
|
1112
|
+
return error;
|
|
1113
|
+
};
|
|
1114
|
+
module2.exports = makeError;
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
// ../../node_modules/execa/lib/stdio.js
|
|
1119
|
+
var require_stdio = __commonJS({
|
|
1120
|
+
"../../node_modules/execa/lib/stdio.js"(exports2, module2) {
|
|
1121
|
+
"use strict";
|
|
1122
|
+
var aliases = ["stdin", "stdout", "stderr"];
|
|
1123
|
+
var hasAlias = (options) => aliases.some((alias) => options[alias] !== void 0);
|
|
1124
|
+
var normalizeStdio = (options) => {
|
|
1125
|
+
if (!options) {
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
const { stdio } = options;
|
|
1129
|
+
if (stdio === void 0) {
|
|
1130
|
+
return aliases.map((alias) => options[alias]);
|
|
1131
|
+
}
|
|
1132
|
+
if (hasAlias(options)) {
|
|
1133
|
+
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map((alias) => `\`${alias}\``).join(", ")}`);
|
|
1134
|
+
}
|
|
1135
|
+
if (typeof stdio === "string") {
|
|
1136
|
+
return stdio;
|
|
1137
|
+
}
|
|
1138
|
+
if (!Array.isArray(stdio)) {
|
|
1139
|
+
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
|
1140
|
+
}
|
|
1141
|
+
const length = Math.max(stdio.length, aliases.length);
|
|
1142
|
+
return Array.from({ length }, (value, index) => stdio[index]);
|
|
1143
|
+
};
|
|
1144
|
+
module2.exports = normalizeStdio;
|
|
1145
|
+
module2.exports.node = (options) => {
|
|
1146
|
+
const stdio = normalizeStdio(options);
|
|
1147
|
+
if (stdio === "ipc") {
|
|
1148
|
+
return "ipc";
|
|
1149
|
+
}
|
|
1150
|
+
if (stdio === void 0 || typeof stdio === "string") {
|
|
1151
|
+
return [stdio, stdio, stdio, "ipc"];
|
|
1152
|
+
}
|
|
1153
|
+
if (stdio.includes("ipc")) {
|
|
1154
|
+
return stdio;
|
|
1155
|
+
}
|
|
1156
|
+
return [...stdio, "ipc"];
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
// ../../node_modules/signal-exit/signals.js
|
|
1162
|
+
var require_signals2 = __commonJS({
|
|
1163
|
+
"../../node_modules/signal-exit/signals.js"(exports2, module2) {
|
|
1164
|
+
"use strict";
|
|
1165
|
+
module2.exports = [
|
|
1166
|
+
"SIGABRT",
|
|
1167
|
+
"SIGALRM",
|
|
1168
|
+
"SIGHUP",
|
|
1169
|
+
"SIGINT",
|
|
1170
|
+
"SIGTERM"
|
|
1171
|
+
];
|
|
1172
|
+
if (process.platform !== "win32") {
|
|
1173
|
+
module2.exports.push(
|
|
1174
|
+
"SIGVTALRM",
|
|
1175
|
+
"SIGXCPU",
|
|
1176
|
+
"SIGXFSZ",
|
|
1177
|
+
"SIGUSR2",
|
|
1178
|
+
"SIGTRAP",
|
|
1179
|
+
"SIGSYS",
|
|
1180
|
+
"SIGQUIT",
|
|
1181
|
+
"SIGIOT"
|
|
1182
|
+
// should detect profiler and enable/disable accordingly.
|
|
1183
|
+
// see #21
|
|
1184
|
+
// 'SIGPROF'
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
if (process.platform === "linux") {
|
|
1188
|
+
module2.exports.push(
|
|
1189
|
+
"SIGIO",
|
|
1190
|
+
"SIGPOLL",
|
|
1191
|
+
"SIGPWR",
|
|
1192
|
+
"SIGSTKFLT",
|
|
1193
|
+
"SIGUNUSED"
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
// ../../node_modules/signal-exit/index.js
|
|
1200
|
+
var require_signal_exit = __commonJS({
|
|
1201
|
+
"../../node_modules/signal-exit/index.js"(exports2, module2) {
|
|
1202
|
+
"use strict";
|
|
1203
|
+
var process2 = global.process;
|
|
1204
|
+
var processOk = function(process3) {
|
|
1205
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
1206
|
+
};
|
|
1207
|
+
if (!processOk(process2)) {
|
|
1208
|
+
module2.exports = function() {
|
|
1209
|
+
return function() {
|
|
1210
|
+
};
|
|
1211
|
+
};
|
|
1212
|
+
} else {
|
|
1213
|
+
assert = require("assert");
|
|
1214
|
+
signals = require_signals2();
|
|
1215
|
+
isWin = /^win/i.test(process2.platform);
|
|
1216
|
+
EE = require("events");
|
|
1217
|
+
if (typeof EE !== "function") {
|
|
1218
|
+
EE = EE.EventEmitter;
|
|
1219
|
+
}
|
|
1220
|
+
if (process2.__signal_exit_emitter__) {
|
|
1221
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1222
|
+
} else {
|
|
1223
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1224
|
+
emitter.count = 0;
|
|
1225
|
+
emitter.emitted = {};
|
|
1226
|
+
}
|
|
1227
|
+
if (!emitter.infinite) {
|
|
1228
|
+
emitter.setMaxListeners(Infinity);
|
|
1229
|
+
emitter.infinite = true;
|
|
1230
|
+
}
|
|
1231
|
+
module2.exports = function(cb, opts) {
|
|
1232
|
+
if (!processOk(global.process)) {
|
|
1233
|
+
return function() {
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1237
|
+
if (loaded === false) {
|
|
1238
|
+
load();
|
|
1239
|
+
}
|
|
1240
|
+
var ev = "exit";
|
|
1241
|
+
if (opts && opts.alwaysLast) {
|
|
1242
|
+
ev = "afterexit";
|
|
1243
|
+
}
|
|
1244
|
+
var remove = function() {
|
|
1245
|
+
emitter.removeListener(ev, cb);
|
|
1246
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1247
|
+
unload();
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
emitter.on(ev, cb);
|
|
1251
|
+
return remove;
|
|
1252
|
+
};
|
|
1253
|
+
unload = function unload2() {
|
|
1254
|
+
if (!loaded || !processOk(global.process)) {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
loaded = false;
|
|
1258
|
+
signals.forEach(function(sig) {
|
|
1259
|
+
try {
|
|
1260
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1261
|
+
} catch (er) {
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
process2.emit = originalProcessEmit;
|
|
1265
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1266
|
+
emitter.count -= 1;
|
|
1267
|
+
};
|
|
1268
|
+
module2.exports.unload = unload;
|
|
1269
|
+
emit = function emit2(event, code, signal) {
|
|
1270
|
+
if (emitter.emitted[event]) {
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
emitter.emitted[event] = true;
|
|
1274
|
+
emitter.emit(event, code, signal);
|
|
1275
|
+
};
|
|
1276
|
+
sigListeners = {};
|
|
1277
|
+
signals.forEach(function(sig) {
|
|
1278
|
+
sigListeners[sig] = function listener() {
|
|
1279
|
+
if (!processOk(global.process)) {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
var listeners = process2.listeners(sig);
|
|
1283
|
+
if (listeners.length === emitter.count) {
|
|
1284
|
+
unload();
|
|
1285
|
+
emit("exit", null, sig);
|
|
1286
|
+
emit("afterexit", null, sig);
|
|
1287
|
+
if (isWin && sig === "SIGHUP") {
|
|
1288
|
+
sig = "SIGINT";
|
|
1289
|
+
}
|
|
1290
|
+
process2.kill(process2.pid, sig);
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
});
|
|
1294
|
+
module2.exports.signals = function() {
|
|
1295
|
+
return signals;
|
|
1296
|
+
};
|
|
1297
|
+
loaded = false;
|
|
1298
|
+
load = function load2() {
|
|
1299
|
+
if (loaded || !processOk(global.process)) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
loaded = true;
|
|
1303
|
+
emitter.count += 1;
|
|
1304
|
+
signals = signals.filter(function(sig) {
|
|
1305
|
+
try {
|
|
1306
|
+
process2.on(sig, sigListeners[sig]);
|
|
1307
|
+
return true;
|
|
1308
|
+
} catch (er) {
|
|
1309
|
+
return false;
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
process2.emit = processEmit;
|
|
1313
|
+
process2.reallyExit = processReallyExit;
|
|
1314
|
+
};
|
|
1315
|
+
module2.exports.load = load;
|
|
1316
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1317
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1318
|
+
if (!processOk(global.process)) {
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1322
|
+
0;
|
|
1323
|
+
emit("exit", process2.exitCode, null);
|
|
1324
|
+
emit("afterexit", process2.exitCode, null);
|
|
1325
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1326
|
+
};
|
|
1327
|
+
originalProcessEmit = process2.emit;
|
|
1328
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1329
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1330
|
+
if (arg !== void 0) {
|
|
1331
|
+
process2.exitCode = arg;
|
|
1332
|
+
}
|
|
1333
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1334
|
+
emit("exit", process2.exitCode, null);
|
|
1335
|
+
emit("afterexit", process2.exitCode, null);
|
|
1336
|
+
return ret;
|
|
1337
|
+
} else {
|
|
1338
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
var assert;
|
|
1343
|
+
var signals;
|
|
1344
|
+
var isWin;
|
|
1345
|
+
var EE;
|
|
1346
|
+
var emitter;
|
|
1347
|
+
var unload;
|
|
1348
|
+
var emit;
|
|
1349
|
+
var sigListeners;
|
|
1350
|
+
var loaded;
|
|
1351
|
+
var load;
|
|
1352
|
+
var originalProcessReallyExit;
|
|
1353
|
+
var processReallyExit;
|
|
1354
|
+
var originalProcessEmit;
|
|
1355
|
+
var processEmit;
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1359
|
+
// ../../node_modules/execa/lib/kill.js
|
|
1360
|
+
var require_kill = __commonJS({
|
|
1361
|
+
"../../node_modules/execa/lib/kill.js"(exports2, module2) {
|
|
1362
|
+
"use strict";
|
|
1363
|
+
var os = require("os");
|
|
1364
|
+
var onExit = require_signal_exit();
|
|
1365
|
+
var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
|
|
1366
|
+
var spawnedKill = (kill, signal = "SIGTERM", options = {}) => {
|
|
1367
|
+
const killResult = kill(signal);
|
|
1368
|
+
setKillTimeout(kill, signal, options, killResult);
|
|
1369
|
+
return killResult;
|
|
1370
|
+
};
|
|
1371
|
+
var setKillTimeout = (kill, signal, options, killResult) => {
|
|
1372
|
+
if (!shouldForceKill(signal, options, killResult)) {
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
const timeout = getForceKillAfterTimeout(options);
|
|
1376
|
+
const t = setTimeout(() => {
|
|
1377
|
+
kill("SIGKILL");
|
|
1378
|
+
}, timeout);
|
|
1379
|
+
if (t.unref) {
|
|
1380
|
+
t.unref();
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
var shouldForceKill = (signal, { forceKillAfterTimeout }, killResult) => {
|
|
1384
|
+
return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|
1385
|
+
};
|
|
1386
|
+
var isSigterm = (signal) => {
|
|
1387
|
+
return signal === os.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
|
|
1388
|
+
};
|
|
1389
|
+
var getForceKillAfterTimeout = ({ forceKillAfterTimeout = true }) => {
|
|
1390
|
+
if (forceKillAfterTimeout === true) {
|
|
1391
|
+
return DEFAULT_FORCE_KILL_TIMEOUT;
|
|
1392
|
+
}
|
|
1393
|
+
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
|
|
1394
|
+
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
|
|
1395
|
+
}
|
|
1396
|
+
return forceKillAfterTimeout;
|
|
1397
|
+
};
|
|
1398
|
+
var spawnedCancel = (spawned, context) => {
|
|
1399
|
+
const killResult = spawned.kill();
|
|
1400
|
+
if (killResult) {
|
|
1401
|
+
context.isCanceled = true;
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
var timeoutKill = (spawned, signal, reject) => {
|
|
1405
|
+
spawned.kill(signal);
|
|
1406
|
+
reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
|
|
1407
|
+
};
|
|
1408
|
+
var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
|
|
1409
|
+
if (timeout === 0 || timeout === void 0) {
|
|
1410
|
+
return spawnedPromise;
|
|
1411
|
+
}
|
|
1412
|
+
if (!Number.isFinite(timeout) || timeout < 0) {
|
|
1413
|
+
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
|
|
1414
|
+
}
|
|
1415
|
+
let timeoutId;
|
|
1416
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
1417
|
+
timeoutId = setTimeout(() => {
|
|
1418
|
+
timeoutKill(spawned, killSignal, reject);
|
|
1419
|
+
}, timeout);
|
|
1420
|
+
});
|
|
1421
|
+
const safeSpawnedPromise = spawnedPromise.finally(() => {
|
|
1422
|
+
clearTimeout(timeoutId);
|
|
1423
|
+
});
|
|
1424
|
+
return Promise.race([timeoutPromise, safeSpawnedPromise]);
|
|
1425
|
+
};
|
|
1426
|
+
var setExitHandler = async (spawned, { cleanup, detached }, timedPromise) => {
|
|
1427
|
+
if (!cleanup || detached) {
|
|
1428
|
+
return timedPromise;
|
|
1429
|
+
}
|
|
1430
|
+
const removeExitHandler = onExit(() => {
|
|
1431
|
+
spawned.kill();
|
|
1432
|
+
});
|
|
1433
|
+
return timedPromise.finally(() => {
|
|
1434
|
+
removeExitHandler();
|
|
1435
|
+
});
|
|
1436
|
+
};
|
|
1437
|
+
module2.exports = {
|
|
1438
|
+
spawnedKill,
|
|
1439
|
+
spawnedCancel,
|
|
1440
|
+
setupTimeout,
|
|
1441
|
+
setExitHandler
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
|
|
1446
|
+
// ../../node_modules/is-stream/index.js
|
|
1447
|
+
var require_is_stream = __commonJS({
|
|
1448
|
+
"../../node_modules/is-stream/index.js"(exports2, module2) {
|
|
1449
|
+
"use strict";
|
|
1450
|
+
var isStream = (stream) => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
|
|
1451
|
+
isStream.writable = (stream) => isStream(stream) && stream.writable !== false && typeof stream._write === "function" && typeof stream._writableState === "object";
|
|
1452
|
+
isStream.readable = (stream) => isStream(stream) && stream.readable !== false && typeof stream._read === "function" && typeof stream._readableState === "object";
|
|
1453
|
+
isStream.duplex = (stream) => isStream.writable(stream) && isStream.readable(stream);
|
|
1454
|
+
isStream.transform = (stream) => isStream.duplex(stream) && typeof stream._transform === "function";
|
|
1455
|
+
module2.exports = isStream;
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
|
|
1459
|
+
// ../../node_modules/get-stream/buffer-stream.js
|
|
1460
|
+
var require_buffer_stream = __commonJS({
|
|
1461
|
+
"../../node_modules/get-stream/buffer-stream.js"(exports2, module2) {
|
|
1462
|
+
"use strict";
|
|
1463
|
+
var { PassThrough: PassThroughStream } = require("stream");
|
|
1464
|
+
module2.exports = (options) => {
|
|
1465
|
+
options = { ...options };
|
|
1466
|
+
const { array } = options;
|
|
1467
|
+
let { encoding } = options;
|
|
1468
|
+
const isBuffer = encoding === "buffer";
|
|
1469
|
+
let objectMode = false;
|
|
1470
|
+
if (array) {
|
|
1471
|
+
objectMode = !(encoding || isBuffer);
|
|
1472
|
+
} else {
|
|
1473
|
+
encoding = encoding || "utf8";
|
|
1474
|
+
}
|
|
1475
|
+
if (isBuffer) {
|
|
1476
|
+
encoding = null;
|
|
1477
|
+
}
|
|
1478
|
+
const stream = new PassThroughStream({ objectMode });
|
|
1479
|
+
if (encoding) {
|
|
1480
|
+
stream.setEncoding(encoding);
|
|
1481
|
+
}
|
|
1482
|
+
let length = 0;
|
|
1483
|
+
const chunks = [];
|
|
1484
|
+
stream.on("data", (chunk) => {
|
|
1485
|
+
chunks.push(chunk);
|
|
1486
|
+
if (objectMode) {
|
|
1487
|
+
length = chunks.length;
|
|
1488
|
+
} else {
|
|
1489
|
+
length += chunk.length;
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
stream.getBufferedValue = () => {
|
|
1493
|
+
if (array) {
|
|
1494
|
+
return chunks;
|
|
1495
|
+
}
|
|
1496
|
+
return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
|
|
1497
|
+
};
|
|
1498
|
+
stream.getBufferedLength = () => length;
|
|
1499
|
+
return stream;
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1504
|
+
// ../../node_modules/get-stream/index.js
|
|
1505
|
+
var require_get_stream = __commonJS({
|
|
1506
|
+
"../../node_modules/get-stream/index.js"(exports2, module2) {
|
|
1507
|
+
"use strict";
|
|
1508
|
+
var { constants: BufferConstants } = require("buffer");
|
|
1509
|
+
var stream = require("stream");
|
|
1510
|
+
var { promisify } = require("util");
|
|
1511
|
+
var bufferStream = require_buffer_stream();
|
|
1512
|
+
var streamPipelinePromisified = promisify(stream.pipeline);
|
|
1513
|
+
var MaxBufferError = class extends Error {
|
|
1514
|
+
constructor() {
|
|
1515
|
+
super("maxBuffer exceeded");
|
|
1516
|
+
this.name = "MaxBufferError";
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
async function getStream(inputStream, options) {
|
|
1520
|
+
if (!inputStream) {
|
|
1521
|
+
throw new Error("Expected a stream");
|
|
1522
|
+
}
|
|
1523
|
+
options = {
|
|
1524
|
+
maxBuffer: Infinity,
|
|
1525
|
+
...options
|
|
1526
|
+
};
|
|
1527
|
+
const { maxBuffer } = options;
|
|
1528
|
+
const stream2 = bufferStream(options);
|
|
1529
|
+
await new Promise((resolve, reject) => {
|
|
1530
|
+
const rejectPromise = (error) => {
|
|
1531
|
+
if (error && stream2.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
1532
|
+
error.bufferedData = stream2.getBufferedValue();
|
|
1533
|
+
}
|
|
1534
|
+
reject(error);
|
|
1535
|
+
};
|
|
1536
|
+
(async () => {
|
|
1537
|
+
try {
|
|
1538
|
+
await streamPipelinePromisified(inputStream, stream2);
|
|
1539
|
+
resolve();
|
|
1540
|
+
} catch (error) {
|
|
1541
|
+
rejectPromise(error);
|
|
1542
|
+
}
|
|
1543
|
+
})();
|
|
1544
|
+
stream2.on("data", () => {
|
|
1545
|
+
if (stream2.getBufferedLength() > maxBuffer) {
|
|
1546
|
+
rejectPromise(new MaxBufferError());
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
});
|
|
1550
|
+
return stream2.getBufferedValue();
|
|
1551
|
+
}
|
|
1552
|
+
module2.exports = getStream;
|
|
1553
|
+
module2.exports.buffer = (stream2, options) => getStream(stream2, { ...options, encoding: "buffer" });
|
|
1554
|
+
module2.exports.array = (stream2, options) => getStream(stream2, { ...options, array: true });
|
|
1555
|
+
module2.exports.MaxBufferError = MaxBufferError;
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
|
|
1559
|
+
// ../../node_modules/merge-stream/index.js
|
|
1560
|
+
var require_merge_stream = __commonJS({
|
|
1561
|
+
"../../node_modules/merge-stream/index.js"(exports2, module2) {
|
|
1562
|
+
"use strict";
|
|
1563
|
+
var { PassThrough } = require("stream");
|
|
1564
|
+
module2.exports = function() {
|
|
1565
|
+
var sources = [];
|
|
1566
|
+
var output = new PassThrough({ objectMode: true });
|
|
1567
|
+
output.setMaxListeners(0);
|
|
1568
|
+
output.add = add;
|
|
1569
|
+
output.isEmpty = isEmpty;
|
|
1570
|
+
output.on("unpipe", remove);
|
|
1571
|
+
Array.prototype.slice.call(arguments).forEach(add);
|
|
1572
|
+
return output;
|
|
1573
|
+
function add(source) {
|
|
1574
|
+
if (Array.isArray(source)) {
|
|
1575
|
+
source.forEach(add);
|
|
1576
|
+
return this;
|
|
1577
|
+
}
|
|
1578
|
+
sources.push(source);
|
|
1579
|
+
source.once("end", remove.bind(null, source));
|
|
1580
|
+
source.once("error", output.emit.bind(output, "error"));
|
|
1581
|
+
source.pipe(output, { end: false });
|
|
1582
|
+
return this;
|
|
1583
|
+
}
|
|
1584
|
+
function isEmpty() {
|
|
1585
|
+
return sources.length == 0;
|
|
1586
|
+
}
|
|
1587
|
+
function remove(source) {
|
|
1588
|
+
sources = sources.filter(function(it) {
|
|
1589
|
+
return it !== source;
|
|
1590
|
+
});
|
|
1591
|
+
if (!sources.length && output.readable) {
|
|
1592
|
+
output.end();
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
|
|
1599
|
+
// ../../node_modules/execa/lib/stream.js
|
|
1600
|
+
var require_stream = __commonJS({
|
|
1601
|
+
"../../node_modules/execa/lib/stream.js"(exports2, module2) {
|
|
1602
|
+
"use strict";
|
|
1603
|
+
var isStream = require_is_stream();
|
|
1604
|
+
var getStream = require_get_stream();
|
|
1605
|
+
var mergeStream = require_merge_stream();
|
|
1606
|
+
var handleInput = (spawned, input) => {
|
|
1607
|
+
if (input === void 0 || spawned.stdin === void 0) {
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
if (isStream(input)) {
|
|
1611
|
+
input.pipe(spawned.stdin);
|
|
1612
|
+
} else {
|
|
1613
|
+
spawned.stdin.end(input);
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
var makeAllStream = (spawned, { all }) => {
|
|
1617
|
+
if (!all || !spawned.stdout && !spawned.stderr) {
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
const mixed = mergeStream();
|
|
1621
|
+
if (spawned.stdout) {
|
|
1622
|
+
mixed.add(spawned.stdout);
|
|
1623
|
+
}
|
|
1624
|
+
if (spawned.stderr) {
|
|
1625
|
+
mixed.add(spawned.stderr);
|
|
1626
|
+
}
|
|
1627
|
+
return mixed;
|
|
1628
|
+
};
|
|
1629
|
+
var getBufferedData = async (stream, streamPromise) => {
|
|
1630
|
+
if (!stream) {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
stream.destroy();
|
|
1634
|
+
try {
|
|
1635
|
+
return await streamPromise;
|
|
1636
|
+
} catch (error) {
|
|
1637
|
+
return error.bufferedData;
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
var getStreamPromise = (stream, { encoding, buffer, maxBuffer }) => {
|
|
1641
|
+
if (!stream || !buffer) {
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
if (encoding) {
|
|
1645
|
+
return getStream(stream, { encoding, maxBuffer });
|
|
1646
|
+
}
|
|
1647
|
+
return getStream.buffer(stream, { maxBuffer });
|
|
1648
|
+
};
|
|
1649
|
+
var getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
|
|
1650
|
+
const stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer });
|
|
1651
|
+
const stderrPromise = getStreamPromise(stderr, { encoding, buffer, maxBuffer });
|
|
1652
|
+
const allPromise = getStreamPromise(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
|
|
1653
|
+
try {
|
|
1654
|
+
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
|
|
1655
|
+
} catch (error) {
|
|
1656
|
+
return Promise.all([
|
|
1657
|
+
{ error, signal: error.signal, timedOut: error.timedOut },
|
|
1658
|
+
getBufferedData(stdout, stdoutPromise),
|
|
1659
|
+
getBufferedData(stderr, stderrPromise),
|
|
1660
|
+
getBufferedData(all, allPromise)
|
|
1661
|
+
]);
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
var validateInputSync = ({ input }) => {
|
|
1665
|
+
if (isStream(input)) {
|
|
1666
|
+
throw new TypeError("The `input` option cannot be a stream in sync mode");
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
module2.exports = {
|
|
1670
|
+
handleInput,
|
|
1671
|
+
makeAllStream,
|
|
1672
|
+
getSpawnedResult,
|
|
1673
|
+
validateInputSync
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
|
|
1678
|
+
// ../../node_modules/execa/lib/promise.js
|
|
1679
|
+
var require_promise = __commonJS({
|
|
1680
|
+
"../../node_modules/execa/lib/promise.js"(exports2, module2) {
|
|
1681
|
+
"use strict";
|
|
1682
|
+
var nativePromisePrototype = (async () => {
|
|
1683
|
+
})().constructor.prototype;
|
|
1684
|
+
var descriptors = ["then", "catch", "finally"].map((property) => [
|
|
1685
|
+
property,
|
|
1686
|
+
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
|
|
1687
|
+
]);
|
|
1688
|
+
var mergePromise = (spawned, promise) => {
|
|
1689
|
+
for (const [property, descriptor] of descriptors) {
|
|
1690
|
+
const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
|
|
1691
|
+
Reflect.defineProperty(spawned, property, { ...descriptor, value });
|
|
1692
|
+
}
|
|
1693
|
+
return spawned;
|
|
1694
|
+
};
|
|
1695
|
+
var getSpawnedPromise = (spawned) => {
|
|
1696
|
+
return new Promise((resolve, reject) => {
|
|
1697
|
+
spawned.on("exit", (exitCode, signal) => {
|
|
1698
|
+
resolve({ exitCode, signal });
|
|
1699
|
+
});
|
|
1700
|
+
spawned.on("error", (error) => {
|
|
1701
|
+
reject(error);
|
|
1702
|
+
});
|
|
1703
|
+
if (spawned.stdin) {
|
|
1704
|
+
spawned.stdin.on("error", (error) => {
|
|
1705
|
+
reject(error);
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
};
|
|
1710
|
+
module2.exports = {
|
|
1711
|
+
mergePromise,
|
|
1712
|
+
getSpawnedPromise
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
|
|
1717
|
+
// ../../node_modules/execa/lib/command.js
|
|
1718
|
+
var require_command = __commonJS({
|
|
1719
|
+
"../../node_modules/execa/lib/command.js"(exports2, module2) {
|
|
1720
|
+
"use strict";
|
|
1721
|
+
var SPACES_REGEXP = / +/g;
|
|
1722
|
+
var joinCommand = (file, args = []) => {
|
|
1723
|
+
if (!Array.isArray(args)) {
|
|
1724
|
+
return file;
|
|
1725
|
+
}
|
|
1726
|
+
return [file, ...args].join(" ");
|
|
1727
|
+
};
|
|
1728
|
+
var parseCommand = (command) => {
|
|
1729
|
+
const tokens = [];
|
|
1730
|
+
for (const token of command.trim().split(SPACES_REGEXP)) {
|
|
1731
|
+
const previousToken = tokens[tokens.length - 1];
|
|
1732
|
+
if (previousToken && previousToken.endsWith("\\")) {
|
|
1733
|
+
tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
|
|
1734
|
+
} else {
|
|
1735
|
+
tokens.push(token);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
return tokens;
|
|
1739
|
+
};
|
|
1740
|
+
module2.exports = {
|
|
1741
|
+
joinCommand,
|
|
1742
|
+
parseCommand
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
|
|
1747
|
+
// ../../node_modules/execa/index.js
|
|
1748
|
+
var require_execa = __commonJS({
|
|
1749
|
+
"../../node_modules/execa/index.js"(exports2, module2) {
|
|
1750
|
+
"use strict";
|
|
1751
|
+
var path8 = require("path");
|
|
1752
|
+
var childProcess = require("child_process");
|
|
1753
|
+
var crossSpawn = require_cross_spawn();
|
|
1754
|
+
var stripFinalNewline = require_strip_final_newline();
|
|
1755
|
+
var npmRunPath = require_npm_run_path();
|
|
1756
|
+
var onetime = require_onetime();
|
|
1757
|
+
var makeError = require_error();
|
|
1758
|
+
var normalizeStdio = require_stdio();
|
|
1759
|
+
var { spawnedKill, spawnedCancel, setupTimeout, setExitHandler } = require_kill();
|
|
1760
|
+
var { handleInput, getSpawnedResult, makeAllStream, validateInputSync } = require_stream();
|
|
1761
|
+
var { mergePromise, getSpawnedPromise } = require_promise();
|
|
1762
|
+
var { joinCommand, parseCommand } = require_command();
|
|
1763
|
+
var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
|
|
1764
|
+
var getEnv = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
|
|
1765
|
+
const env = extendEnv ? { ...process.env, ...envOption } : envOption;
|
|
1766
|
+
if (preferLocal) {
|
|
1767
|
+
return npmRunPath.env({ env, cwd: localDir, execPath });
|
|
1768
|
+
}
|
|
1769
|
+
return env;
|
|
1770
|
+
};
|
|
1771
|
+
var handleArguments = (file, args, options = {}) => {
|
|
1772
|
+
const parsed = crossSpawn._parse(file, args, options);
|
|
1773
|
+
file = parsed.command;
|
|
1774
|
+
args = parsed.args;
|
|
1775
|
+
options = parsed.options;
|
|
1776
|
+
options = {
|
|
1777
|
+
maxBuffer: DEFAULT_MAX_BUFFER,
|
|
1778
|
+
buffer: true,
|
|
1779
|
+
stripFinalNewline: true,
|
|
1780
|
+
extendEnv: true,
|
|
1781
|
+
preferLocal: false,
|
|
1782
|
+
localDir: options.cwd || process.cwd(),
|
|
1783
|
+
execPath: process.execPath,
|
|
1784
|
+
encoding: "utf8",
|
|
1785
|
+
reject: true,
|
|
1786
|
+
cleanup: true,
|
|
1787
|
+
all: false,
|
|
1788
|
+
windowsHide: true,
|
|
1789
|
+
...options
|
|
1790
|
+
};
|
|
1791
|
+
options.env = getEnv(options);
|
|
1792
|
+
options.stdio = normalizeStdio(options);
|
|
1793
|
+
if (process.platform === "win32" && path8.basename(file, ".exe") === "cmd") {
|
|
1794
|
+
args.unshift("/q");
|
|
1795
|
+
}
|
|
1796
|
+
return { file, args, options, parsed };
|
|
1797
|
+
};
|
|
1798
|
+
var handleOutput = (options, value, error) => {
|
|
1799
|
+
if (typeof value !== "string" && !Buffer.isBuffer(value)) {
|
|
1800
|
+
return error === void 0 ? void 0 : "";
|
|
1801
|
+
}
|
|
1802
|
+
if (options.stripFinalNewline) {
|
|
1803
|
+
return stripFinalNewline(value);
|
|
1804
|
+
}
|
|
1805
|
+
return value;
|
|
1806
|
+
};
|
|
1807
|
+
var execa3 = (file, args, options) => {
|
|
1808
|
+
const parsed = handleArguments(file, args, options);
|
|
1809
|
+
const command = joinCommand(file, args);
|
|
1810
|
+
let spawned;
|
|
1811
|
+
try {
|
|
1812
|
+
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
|
|
1813
|
+
} catch (error) {
|
|
1814
|
+
const dummySpawned = new childProcess.ChildProcess();
|
|
1815
|
+
const errorPromise = Promise.reject(makeError({
|
|
1816
|
+
error,
|
|
1817
|
+
stdout: "",
|
|
1818
|
+
stderr: "",
|
|
1819
|
+
all: "",
|
|
1820
|
+
command,
|
|
1821
|
+
parsed,
|
|
1822
|
+
timedOut: false,
|
|
1823
|
+
isCanceled: false,
|
|
1824
|
+
killed: false
|
|
1825
|
+
}));
|
|
1826
|
+
return mergePromise(dummySpawned, errorPromise);
|
|
1827
|
+
}
|
|
1828
|
+
const spawnedPromise = getSpawnedPromise(spawned);
|
|
1829
|
+
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
|
|
1830
|
+
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
|
|
1831
|
+
const context = { isCanceled: false };
|
|
1832
|
+
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
|
|
1833
|
+
spawned.cancel = spawnedCancel.bind(null, spawned, context);
|
|
1834
|
+
const handlePromise = async () => {
|
|
1835
|
+
const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
|
|
1836
|
+
const stdout = handleOutput(parsed.options, stdoutResult);
|
|
1837
|
+
const stderr = handleOutput(parsed.options, stderrResult);
|
|
1838
|
+
const all = handleOutput(parsed.options, allResult);
|
|
1839
|
+
if (error || exitCode !== 0 || signal !== null) {
|
|
1840
|
+
const returnedError = makeError({
|
|
1841
|
+
error,
|
|
1842
|
+
exitCode,
|
|
1843
|
+
signal,
|
|
1844
|
+
stdout,
|
|
1845
|
+
stderr,
|
|
1846
|
+
all,
|
|
1847
|
+
command,
|
|
1848
|
+
parsed,
|
|
1849
|
+
timedOut,
|
|
1850
|
+
isCanceled: context.isCanceled,
|
|
1851
|
+
killed: spawned.killed
|
|
1852
|
+
});
|
|
1853
|
+
if (!parsed.options.reject) {
|
|
1854
|
+
return returnedError;
|
|
1855
|
+
}
|
|
1856
|
+
throw returnedError;
|
|
1857
|
+
}
|
|
1858
|
+
return {
|
|
1859
|
+
command,
|
|
1860
|
+
exitCode: 0,
|
|
1861
|
+
stdout,
|
|
1862
|
+
stderr,
|
|
1863
|
+
all,
|
|
1864
|
+
failed: false,
|
|
1865
|
+
timedOut: false,
|
|
1866
|
+
isCanceled: false,
|
|
1867
|
+
killed: false
|
|
1868
|
+
};
|
|
1869
|
+
};
|
|
1870
|
+
const handlePromiseOnce = onetime(handlePromise);
|
|
1871
|
+
handleInput(spawned, parsed.options.input);
|
|
1872
|
+
spawned.all = makeAllStream(spawned, parsed.options);
|
|
1873
|
+
return mergePromise(spawned, handlePromiseOnce);
|
|
1874
|
+
};
|
|
1875
|
+
module2.exports = execa3;
|
|
1876
|
+
module2.exports.sync = (file, args, options) => {
|
|
1877
|
+
const parsed = handleArguments(file, args, options);
|
|
1878
|
+
const command = joinCommand(file, args);
|
|
1879
|
+
validateInputSync(parsed.options);
|
|
1880
|
+
let result;
|
|
1881
|
+
try {
|
|
1882
|
+
result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
|
|
1883
|
+
} catch (error) {
|
|
1884
|
+
throw makeError({
|
|
1885
|
+
error,
|
|
1886
|
+
stdout: "",
|
|
1887
|
+
stderr: "",
|
|
1888
|
+
all: "",
|
|
1889
|
+
command,
|
|
1890
|
+
parsed,
|
|
1891
|
+
timedOut: false,
|
|
1892
|
+
isCanceled: false,
|
|
1893
|
+
killed: false
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
const stdout = handleOutput(parsed.options, result.stdout, result.error);
|
|
1897
|
+
const stderr = handleOutput(parsed.options, result.stderr, result.error);
|
|
1898
|
+
if (result.error || result.status !== 0 || result.signal !== null) {
|
|
1899
|
+
const error = makeError({
|
|
1900
|
+
stdout,
|
|
1901
|
+
stderr,
|
|
1902
|
+
error: result.error,
|
|
1903
|
+
signal: result.signal,
|
|
1904
|
+
exitCode: result.status,
|
|
1905
|
+
command,
|
|
1906
|
+
parsed,
|
|
1907
|
+
timedOut: result.error && result.error.code === "ETIMEDOUT",
|
|
1908
|
+
isCanceled: false,
|
|
1909
|
+
killed: result.signal !== null
|
|
1910
|
+
});
|
|
1911
|
+
if (!parsed.options.reject) {
|
|
1912
|
+
return error;
|
|
1913
|
+
}
|
|
1914
|
+
throw error;
|
|
1915
|
+
}
|
|
1916
|
+
return {
|
|
1917
|
+
command,
|
|
1918
|
+
exitCode: 0,
|
|
1919
|
+
stdout,
|
|
1920
|
+
stderr,
|
|
1921
|
+
failed: false,
|
|
1922
|
+
timedOut: false,
|
|
1923
|
+
isCanceled: false,
|
|
1924
|
+
killed: false
|
|
1925
|
+
};
|
|
1926
|
+
};
|
|
1927
|
+
module2.exports.command = (command, options) => {
|
|
1928
|
+
const [file, ...args] = parseCommand(command);
|
|
1929
|
+
return execa3(file, args, options);
|
|
1930
|
+
};
|
|
1931
|
+
module2.exports.commandSync = (command, options) => {
|
|
1932
|
+
const [file, ...args] = parseCommand(command);
|
|
1933
|
+
return execa3.sync(file, args, options);
|
|
1934
|
+
};
|
|
1935
|
+
module2.exports.node = (scriptPath, args, options = {}) => {
|
|
1936
|
+
if (args && !Array.isArray(args) && typeof args === "object") {
|
|
1937
|
+
options = args;
|
|
1938
|
+
args = [];
|
|
1939
|
+
}
|
|
1940
|
+
const stdio = normalizeStdio.node(options);
|
|
1941
|
+
const defaultExecArgv = process.execArgv.filter((arg) => !arg.startsWith("--inspect"));
|
|
1942
|
+
const {
|
|
1943
|
+
nodePath = process.execPath,
|
|
1944
|
+
nodeOptions = defaultExecArgv
|
|
1945
|
+
} = options;
|
|
1946
|
+
return execa3(
|
|
1947
|
+
nodePath,
|
|
1948
|
+
[
|
|
1949
|
+
...nodeOptions,
|
|
1950
|
+
scriptPath,
|
|
1951
|
+
...Array.isArray(args) ? args : []
|
|
1952
|
+
],
|
|
1953
|
+
{
|
|
1954
|
+
...options,
|
|
1955
|
+
stdin: void 0,
|
|
1956
|
+
stdout: void 0,
|
|
1957
|
+
stderr: void 0,
|
|
1958
|
+
stdio,
|
|
1959
|
+
shell: false
|
|
1960
|
+
}
|
|
1961
|
+
);
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
});
|
|
1965
|
+
|
|
1966
|
+
// src/index.ts
|
|
1967
|
+
var index_exports = {};
|
|
1968
|
+
__export(index_exports, {
|
|
1969
|
+
FeatureRegistry: () => FeatureRegistry,
|
|
1970
|
+
applyFeatures: () => applyFeatures,
|
|
1971
|
+
generateProject: () => generateProject,
|
|
1972
|
+
getFeatureRegistry: () => getFeatureRegistry,
|
|
1973
|
+
resolveFeatures: () => resolveFeatures
|
|
1974
|
+
});
|
|
1975
|
+
module.exports = __toCommonJS(index_exports);
|
|
1976
|
+
|
|
1977
|
+
// src/generator/generateProject.ts
|
|
1978
|
+
var import_path7 = __toESM(require("path"));
|
|
1979
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
1980
|
+
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
1981
|
+
|
|
1982
|
+
// src/resolvers/templateResolver.ts
|
|
1983
|
+
var import_path3 = __toESM(require("path"));
|
|
1984
|
+
|
|
1985
|
+
// src/filesystem/index.ts
|
|
1986
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1987
|
+
var import_path = __toESM(require("path"));
|
|
1988
|
+
var copyFile = async (src, dest) => {
|
|
1989
|
+
await import_fs_extra.default.ensureDir(import_path.default.dirname(dest));
|
|
1990
|
+
await import_fs_extra.default.copy(src, dest);
|
|
1991
|
+
};
|
|
1992
|
+
var writeRenderedFile = async (dest, content) => {
|
|
1993
|
+
await import_fs_extra.default.ensureDir(import_path.default.dirname(dest));
|
|
1994
|
+
await import_fs_extra.default.writeFile(dest, content, "utf-8");
|
|
1995
|
+
};
|
|
1996
|
+
var getAllFiles = async (dirPath) => {
|
|
1997
|
+
const files = [];
|
|
1998
|
+
const items = await import_fs_extra.default.readdir(dirPath, { withFileTypes: true });
|
|
1999
|
+
for (const item of items) {
|
|
2000
|
+
const fullPath = import_path.default.join(dirPath, item.name);
|
|
2001
|
+
if (item.isDirectory()) {
|
|
2002
|
+
files.push(...await getAllFiles(fullPath));
|
|
2003
|
+
} else {
|
|
2004
|
+
files.push(fullPath);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
return files;
|
|
2008
|
+
};
|
|
2009
|
+
var exists = async (path8) => {
|
|
2010
|
+
return import_fs_extra.default.pathExists(path8);
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
// src/constants/paths.ts
|
|
2014
|
+
var import_path2 = __toESM(require("path"));
|
|
2015
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
2016
|
+
var getAssetsRoot = () => {
|
|
2017
|
+
if (process.env.MONSTACK_ASSETS_PATH) {
|
|
2018
|
+
return process.env.MONSTACK_ASSETS_PATH;
|
|
2019
|
+
}
|
|
2020
|
+
const possiblePaths = [
|
|
2021
|
+
// Monorepo root (dev)
|
|
2022
|
+
import_path2.default.resolve(__dirname, "../../../../"),
|
|
2023
|
+
// Core package root (dist)
|
|
2024
|
+
import_path2.default.resolve(__dirname, "../../../"),
|
|
2025
|
+
// Current working directory
|
|
2026
|
+
process.cwd()
|
|
2027
|
+
];
|
|
2028
|
+
for (const root of possiblePaths) {
|
|
2029
|
+
const templatesExists = import_fs_extra2.default.pathExistsSync(import_path2.default.join(root, "templates"));
|
|
2030
|
+
const featuresExists = import_fs_extra2.default.pathExistsSync(import_path2.default.join(root, "features"));
|
|
2031
|
+
const pkgTemplatesExists = import_fs_extra2.default.pathExistsSync(import_path2.default.join(root, "packages/templates"));
|
|
2032
|
+
const pkgFeaturesExists = import_fs_extra2.default.pathExistsSync(import_path2.default.join(root, "packages/features"));
|
|
2033
|
+
if (templatesExists && featuresExists) {
|
|
2034
|
+
return root;
|
|
2035
|
+
}
|
|
2036
|
+
if (pkgTemplatesExists && pkgFeaturesExists) {
|
|
2037
|
+
return import_path2.default.join(root, "packages");
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
return import_path2.default.resolve(__dirname, "../../../../packages");
|
|
2041
|
+
};
|
|
2042
|
+
var getTemplatesPath = () => {
|
|
2043
|
+
return import_path2.default.join(getAssetsRoot(), "templates");
|
|
2044
|
+
};
|
|
2045
|
+
var getFeaturesPath = () => {
|
|
2046
|
+
return import_path2.default.join(getAssetsRoot(), "features");
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
// src/resolvers/templateResolver.ts
|
|
2050
|
+
var resolveTemplatePath = async (config, assetsRoot) => {
|
|
2051
|
+
const templateBaseDir = assetsRoot ? import_path3.default.join(assetsRoot, "templates") : getTemplatesPath();
|
|
2052
|
+
const templatePath = import_path3.default.join(
|
|
2053
|
+
templateBaseDir,
|
|
2054
|
+
config.framework,
|
|
2055
|
+
config.architecture,
|
|
2056
|
+
config.database
|
|
2057
|
+
);
|
|
2058
|
+
if (!await exists(templatePath)) {
|
|
2059
|
+
throw new Error(`Template not found at: ${templatePath}`);
|
|
2060
|
+
}
|
|
2061
|
+
return templatePath;
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
// src/template-engine/index.ts
|
|
2065
|
+
var import_ejs = __toESM(require("ejs"));
|
|
2066
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
2067
|
+
var renderTemplate = async (filePath, data) => {
|
|
2068
|
+
const templateContent = await import_fs_extra3.default.readFile(filePath, "utf-8");
|
|
2069
|
+
return import_ejs.default.render(templateContent, data);
|
|
2070
|
+
};
|
|
2071
|
+
var isTemplateFile = (filePath) => {
|
|
2072
|
+
return filePath.endsWith(".ejs");
|
|
2073
|
+
};
|
|
2074
|
+
var getTargetFileName = (filePath) => {
|
|
2075
|
+
if (isTemplateFile(filePath)) {
|
|
2076
|
+
return filePath.replace(/\.ejs$/, "");
|
|
2077
|
+
}
|
|
2078
|
+
return filePath;
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
// src/installers/base.ts
|
|
2082
|
+
var import_execa = __toESM(require_execa());
|
|
2083
|
+
var import_chalk = __toESM(require("chalk"));
|
|
2084
|
+
var BaseInstaller = class {
|
|
2085
|
+
async install(projectPath) {
|
|
2086
|
+
const { command, args } = this.getInstallCommand();
|
|
2087
|
+
console.log(
|
|
2088
|
+
import_chalk.default.cyan(`
|
|
2089
|
+
\u{1F4E6} Installing dependencies using ${this.getName()}...`)
|
|
2090
|
+
);
|
|
2091
|
+
try {
|
|
2092
|
+
await (0, import_execa.default)(command, args, {
|
|
2093
|
+
cwd: projectPath,
|
|
2094
|
+
stdio: "inherit"
|
|
2095
|
+
});
|
|
2096
|
+
} catch (error) {
|
|
2097
|
+
throw new Error(
|
|
2098
|
+
`Failed to install dependencies using ${this.getName()}: ${error}`
|
|
2099
|
+
);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
// src/installers/implementations.ts
|
|
2105
|
+
var NpmInstaller = class extends BaseInstaller {
|
|
2106
|
+
getName() {
|
|
2107
|
+
return "npm";
|
|
2108
|
+
}
|
|
2109
|
+
getInstallCommand() {
|
|
2110
|
+
return { command: "npm", args: ["install"] };
|
|
2111
|
+
}
|
|
2112
|
+
};
|
|
2113
|
+
var PnpmInstaller = class extends BaseInstaller {
|
|
2114
|
+
getName() {
|
|
2115
|
+
return "pnpm";
|
|
2116
|
+
}
|
|
2117
|
+
getInstallCommand() {
|
|
2118
|
+
return { command: "pnpm", args: ["install"] };
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
var YarnInstaller = class extends BaseInstaller {
|
|
2122
|
+
getName() {
|
|
2123
|
+
return "yarn";
|
|
2124
|
+
}
|
|
2125
|
+
getInstallCommand() {
|
|
2126
|
+
return { command: "yarn", args: ["install"] };
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
// src/installers/index.ts
|
|
2131
|
+
var resolveInstaller = (packageManager) => {
|
|
2132
|
+
switch (packageManager) {
|
|
2133
|
+
case "npm":
|
|
2134
|
+
return new NpmInstaller();
|
|
2135
|
+
case "pnpm":
|
|
2136
|
+
return new PnpmInstaller();
|
|
2137
|
+
case "yarn":
|
|
2138
|
+
return new YarnInstaller();
|
|
2139
|
+
default:
|
|
2140
|
+
return new NpmInstaller();
|
|
2141
|
+
}
|
|
2142
|
+
};
|
|
2143
|
+
|
|
2144
|
+
// src/git/index.ts
|
|
2145
|
+
var import_execa2 = __toESM(require_execa());
|
|
2146
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
2147
|
+
var initializeGit = async (projectPath) => {
|
|
2148
|
+
console.log(import_chalk2.default.cyan("\ngit Initializing git repository..."));
|
|
2149
|
+
try {
|
|
2150
|
+
await (0, import_execa2.default)("git", ["init"], { cwd: projectPath });
|
|
2151
|
+
await (0, import_execa2.default)("git", ["add", "."], { cwd: projectPath });
|
|
2152
|
+
await (0, import_execa2.default)("git", ["commit", "-m", "Initial commit from MonStack CLI"], {
|
|
2153
|
+
cwd: projectPath
|
|
2154
|
+
});
|
|
2155
|
+
console.log(import_chalk2.default.green("\u2705 Git initialized successfully."));
|
|
2156
|
+
} catch (error) {
|
|
2157
|
+
console.log(
|
|
2158
|
+
import_chalk2.default.yellow(
|
|
2159
|
+
"\u26A0\uFE0F Failed to initialize git repository. This is non-blocking."
|
|
2160
|
+
)
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
|
|
2165
|
+
// src/environment/index.ts
|
|
2166
|
+
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
2167
|
+
var import_path4 = __toESM(require("path"));
|
|
2168
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
2169
|
+
var setupEnvironmentFiles = async (projectPath) => {
|
|
2170
|
+
const examplePath = import_path4.default.join(projectPath, ".env.example");
|
|
2171
|
+
const envPath = import_path4.default.join(projectPath, ".env");
|
|
2172
|
+
if (await import_fs_extra4.default.pathExists(examplePath)) {
|
|
2173
|
+
console.log(import_chalk3.default.cyan("\u{1F4DD} Creating .env file..."));
|
|
2174
|
+
await import_fs_extra4.default.copy(examplePath, envPath);
|
|
2175
|
+
console.log(import_chalk3.default.green("\u2705 .env file created."));
|
|
2176
|
+
}
|
|
2177
|
+
};
|
|
2178
|
+
|
|
2179
|
+
// src/features/apply-features.ts
|
|
2180
|
+
var import_path6 = __toESM(require("path"));
|
|
2181
|
+
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
2182
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
2183
|
+
|
|
2184
|
+
// src/features/resolver.ts
|
|
2185
|
+
var resolveFeatures = (config) => {
|
|
2186
|
+
if (!config.features || config.features.length === 0) {
|
|
2187
|
+
return [];
|
|
2188
|
+
}
|
|
2189
|
+
const selectedFeatures = config.features.filter(
|
|
2190
|
+
(feature) => feature !== "none"
|
|
2191
|
+
);
|
|
2192
|
+
return [...new Set(selectedFeatures)];
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2195
|
+
// src/features/registry.ts
|
|
2196
|
+
var import_path5 = __toESM(require("path"));
|
|
2197
|
+
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
2198
|
+
var FeatureRegistry = class {
|
|
2199
|
+
constructor() {
|
|
2200
|
+
this.features = /* @__PURE__ */ new Map();
|
|
2201
|
+
this.featuresBaseDir = getFeaturesPath();
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Load and register all available features from the features directory
|
|
2205
|
+
*/
|
|
2206
|
+
async discoverFeatures() {
|
|
2207
|
+
const featuresDir = this.featuresBaseDir;
|
|
2208
|
+
if (!await import_fs_extra5.default.pathExists(featuresDir)) {
|
|
2209
|
+
console.warn(`Features directory not found at ${featuresDir}`);
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
const entries = await import_fs_extra5.default.readdir(featuresDir);
|
|
2213
|
+
for (const entry of entries) {
|
|
2214
|
+
const featurePath = import_path5.default.join(featuresDir, entry);
|
|
2215
|
+
const stat = await import_fs_extra5.default.stat(featurePath);
|
|
2216
|
+
if (!stat.isDirectory() || entry === "src") continue;
|
|
2217
|
+
await this.registerFeature(entry, featurePath);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* Register a single feature by loading its metadata
|
|
2222
|
+
*/
|
|
2223
|
+
async registerFeature(name, featurePath) {
|
|
2224
|
+
const metadataPath = import_path5.default.join(featurePath, "metadata.json");
|
|
2225
|
+
if (!await import_fs_extra5.default.pathExists(metadataPath)) {
|
|
2226
|
+
console.warn(`Metadata not found for feature: ${name}`);
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
try {
|
|
2230
|
+
const metadata = await import_fs_extra5.default.readJson(metadataPath);
|
|
2231
|
+
this.features.set(name, {
|
|
2232
|
+
name,
|
|
2233
|
+
metadata,
|
|
2234
|
+
path: featurePath
|
|
2235
|
+
});
|
|
2236
|
+
} catch (error) {
|
|
2237
|
+
console.error(`Failed to load metadata for feature ${name}:`, error);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Get a registered feature by name
|
|
2242
|
+
*/
|
|
2243
|
+
getFeature(name) {
|
|
2244
|
+
return this.features.get(name);
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Get metadata for a feature
|
|
2248
|
+
*/
|
|
2249
|
+
getFeatureMetadata(name) {
|
|
2250
|
+
return this.features.get(name)?.metadata;
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Get path to a feature directory
|
|
2254
|
+
*/
|
|
2255
|
+
getFeaturePath(name) {
|
|
2256
|
+
return this.features.get(name)?.path;
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Get all registered features
|
|
2260
|
+
*/
|
|
2261
|
+
getAllFeatures() {
|
|
2262
|
+
return Array.from(this.features.values());
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Check if a feature is registered
|
|
2266
|
+
*/
|
|
2267
|
+
hasFeature(name) {
|
|
2268
|
+
return this.features.has(name);
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Get features that support a specific framework
|
|
2272
|
+
*/
|
|
2273
|
+
getFeaturesByFramework(framework) {
|
|
2274
|
+
return Array.from(this.features.values()).filter(
|
|
2275
|
+
(f) => !f.metadata.frameworks || f.metadata.frameworks.includes(framework)
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Get features that support a specific architecture
|
|
2280
|
+
*/
|
|
2281
|
+
getFeaturesByArchitecture(architecture) {
|
|
2282
|
+
return Array.from(this.features.values()).filter(
|
|
2283
|
+
(f) => !f.metadata.architectures || f.metadata.architectures.includes(architecture)
|
|
2284
|
+
);
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Get features that support a specific database
|
|
2288
|
+
*/
|
|
2289
|
+
getFeaturesByDatabase(database) {
|
|
2290
|
+
return Array.from(this.features.values()).filter(
|
|
2291
|
+
(f) => !f.metadata.databases || f.metadata.databases.includes(database)
|
|
2292
|
+
);
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Get all features compatible with given config
|
|
2296
|
+
*/
|
|
2297
|
+
getCompatibleFeatures(framework, architecture, database) {
|
|
2298
|
+
return Array.from(this.features.values()).filter(
|
|
2299
|
+
(f) => (!f.metadata.frameworks || f.metadata.frameworks.includes(framework)) && (!f.metadata.architectures || f.metadata.architectures.includes(architecture)) && (!f.metadata.databases || f.metadata.databases.includes(database))
|
|
2300
|
+
);
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Validate that requested features are available and compatible
|
|
2304
|
+
*/
|
|
2305
|
+
validateFeatures(featureNames, framework, architecture, database) {
|
|
2306
|
+
const errors = [];
|
|
2307
|
+
for (const featureName of featureNames) {
|
|
2308
|
+
const feature = this.getFeature(featureName);
|
|
2309
|
+
if (!feature) {
|
|
2310
|
+
errors.push(`Feature "${featureName}" not found in registry`);
|
|
2311
|
+
continue;
|
|
2312
|
+
}
|
|
2313
|
+
const { metadata } = feature;
|
|
2314
|
+
if (metadata.frameworks && !metadata.frameworks.includes(framework)) {
|
|
2315
|
+
errors.push(
|
|
2316
|
+
`Feature "${featureName}" does not support framework "${framework}"`
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
2319
|
+
if (metadata.architectures && !metadata.architectures.includes(architecture)) {
|
|
2320
|
+
errors.push(
|
|
2321
|
+
`Feature "${featureName}" does not support architecture "${architecture}"`
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
if (metadata.databases && !metadata.databases.includes(database)) {
|
|
2325
|
+
errors.push(
|
|
2326
|
+
`Feature "${featureName}" does not support database "${database}"`
|
|
2327
|
+
);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
return {
|
|
2331
|
+
valid: errors.length === 0,
|
|
2332
|
+
errors
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
};
|
|
2336
|
+
var registryInstance = null;
|
|
2337
|
+
async function getFeatureRegistry() {
|
|
2338
|
+
if (!registryInstance) {
|
|
2339
|
+
registryInstance = new FeatureRegistry();
|
|
2340
|
+
await registryInstance.discoverFeatures();
|
|
2341
|
+
}
|
|
2342
|
+
return registryInstance;
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
// src/features/apply-features.ts
|
|
2346
|
+
var import_module = require("module");
|
|
2347
|
+
var customRequire = typeof require !== "undefined" ? require : (0, import_module.createRequire)(eval("import.meta.url"));
|
|
2348
|
+
var applyFeatures = async (projectPath, config, options = {}) => {
|
|
2349
|
+
const selectedFeatures = resolveFeatures(config);
|
|
2350
|
+
if (selectedFeatures.length === 0) return;
|
|
2351
|
+
const registry = await getFeatureRegistry();
|
|
2352
|
+
const validation = registry.validateFeatures(
|
|
2353
|
+
selectedFeatures,
|
|
2354
|
+
config.framework,
|
|
2355
|
+
config.architecture,
|
|
2356
|
+
config.database
|
|
2357
|
+
);
|
|
2358
|
+
if (!validation.valid) {
|
|
2359
|
+
console.error(import_chalk4.default.red("\n\u274C Feature validation failed:"));
|
|
2360
|
+
validation.errors.forEach((err) => console.error(import_chalk4.default.red(` - ${err}`)));
|
|
2361
|
+
throw new Error("Feature validation failed");
|
|
2362
|
+
}
|
|
2363
|
+
console.log(import_chalk4.default.cyan("\n\u{1F9E9} Applying features..."));
|
|
2364
|
+
for (const featureName of selectedFeatures) {
|
|
2365
|
+
const feature = registry.getFeature(featureName);
|
|
2366
|
+
await applySingleFeature(
|
|
2367
|
+
featureName,
|
|
2368
|
+
feature.path,
|
|
2369
|
+
projectPath,
|
|
2370
|
+
config,
|
|
2371
|
+
options.renderData
|
|
2372
|
+
);
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
var applySingleFeature = async (featureName, featureDir, projectPath, config, renderData) => {
|
|
2376
|
+
console.log(import_chalk4.default.blue(` - Applying ${featureName}...`));
|
|
2377
|
+
const filesDir = import_path6.default.join(featureDir, "files");
|
|
2378
|
+
if (await import_fs_extra6.default.pathExists(filesDir)) {
|
|
2379
|
+
const files = await getAllFiles(filesDir);
|
|
2380
|
+
for (const file of files) {
|
|
2381
|
+
const relativePath = import_path6.default.relative(filesDir, file);
|
|
2382
|
+
const targetPath = import_path6.default.join(
|
|
2383
|
+
projectPath,
|
|
2384
|
+
isTemplateFile(relativePath) ? getTargetFileName(relativePath) : relativePath
|
|
2385
|
+
);
|
|
2386
|
+
if (isTemplateFile(file)) {
|
|
2387
|
+
const templateData = renderData || {};
|
|
2388
|
+
const renderedContent = await renderTemplate(file, templateData);
|
|
2389
|
+
await import_fs_extra6.default.ensureDir(import_path6.default.dirname(targetPath));
|
|
2390
|
+
await import_fs_extra6.default.writeFile(targetPath, renderedContent, "utf-8");
|
|
2391
|
+
} else {
|
|
2392
|
+
await copyFile(file, targetPath);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
const depFile = import_path6.default.join(featureDir, "dependencies.json");
|
|
2397
|
+
if (await import_fs_extra6.default.pathExists(depFile)) {
|
|
2398
|
+
const deps = await import_fs_extra6.default.readJson(depFile);
|
|
2399
|
+
await mergeDependencies(projectPath, deps);
|
|
2400
|
+
}
|
|
2401
|
+
const hookFile = import_path6.default.join(featureDir, "index.ts");
|
|
2402
|
+
const hookFileJs = import_path6.default.join(featureDir, "index.js");
|
|
2403
|
+
let hookModule = null;
|
|
2404
|
+
if (await import_fs_extra6.default.pathExists(hookFile)) {
|
|
2405
|
+
try {
|
|
2406
|
+
customRequire("ts-node").register({
|
|
2407
|
+
transpileOnly: true,
|
|
2408
|
+
compilerOptions: {
|
|
2409
|
+
module: "CommonJS"
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
hookModule = customRequire(hookFile);
|
|
2413
|
+
} catch (error) {
|
|
2414
|
+
}
|
|
2415
|
+
} else if (await import_fs_extra6.default.pathExists(hookFileJs)) {
|
|
2416
|
+
hookModule = customRequire(hookFileJs);
|
|
2417
|
+
}
|
|
2418
|
+
if (hookModule && hookModule.postApply) {
|
|
2419
|
+
try {
|
|
2420
|
+
await hookModule.postApply(projectPath, config);
|
|
2421
|
+
} catch (error) {
|
|
2422
|
+
console.error(
|
|
2423
|
+
import_chalk4.default.red(` - Error running postApply hook for ${featureName}:`),
|
|
2424
|
+
error
|
|
2425
|
+
);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
var mergeDependencies = async (projectPath, featureDeps) => {
|
|
2430
|
+
const pkgPath = import_path6.default.join(projectPath, "package.json");
|
|
2431
|
+
if (!await import_fs_extra6.default.pathExists(pkgPath)) return;
|
|
2432
|
+
const pkg = await import_fs_extra6.default.readJson(pkgPath);
|
|
2433
|
+
if (featureDeps.dependencies) {
|
|
2434
|
+
pkg.dependencies = {
|
|
2435
|
+
...pkg.dependencies || {},
|
|
2436
|
+
...featureDeps.dependencies
|
|
2437
|
+
};
|
|
2438
|
+
}
|
|
2439
|
+
if (featureDeps.devDependencies) {
|
|
2440
|
+
pkg.devDependencies = {
|
|
2441
|
+
...pkg.devDependencies || {},
|
|
2442
|
+
...featureDeps.devDependencies
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
await import_fs_extra6.default.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
2446
|
+
};
|
|
2447
|
+
|
|
2448
|
+
// src/generator/generateProject.ts
|
|
2449
|
+
var generateProject = async (config, options = {}) => {
|
|
2450
|
+
const targetDir = import_path7.default.join(process.cwd(), config.projectName);
|
|
2451
|
+
if (await import_fs_extra7.default.pathExists(targetDir)) {
|
|
2452
|
+
throw new Error(`Target directory ${config.projectName} already exists.`);
|
|
2453
|
+
}
|
|
2454
|
+
console.log(import_chalk5.default.cyan(`
|
|
2455
|
+
\u{1F3D7}\uFE0F Generating project: ${config.projectName}...`));
|
|
2456
|
+
const templatePath = await resolveTemplatePath(config, options.assetsRoot);
|
|
2457
|
+
const files = await getAllFiles(templatePath);
|
|
2458
|
+
const renderData = {
|
|
2459
|
+
PROJECT_NAME: config.projectName,
|
|
2460
|
+
PORT: 3e3,
|
|
2461
|
+
// Default port for now
|
|
2462
|
+
PACKAGE_MANAGER: config.packageManager,
|
|
2463
|
+
NODE_ENV: "development",
|
|
2464
|
+
DATABASE: config.database,
|
|
2465
|
+
ORM: config.orm
|
|
2466
|
+
};
|
|
2467
|
+
for (const file of files) {
|
|
2468
|
+
const relativePath = import_path7.default.relative(templatePath, file);
|
|
2469
|
+
if (relativePath.includes("node_modules") || relativePath.includes("dist")) {
|
|
2470
|
+
continue;
|
|
2471
|
+
}
|
|
2472
|
+
const targetFilePath = import_path7.default.join(
|
|
2473
|
+
targetDir,
|
|
2474
|
+
getTargetFileName(relativePath)
|
|
2475
|
+
);
|
|
2476
|
+
if (isTemplateFile(file)) {
|
|
2477
|
+
const renderedContent = await renderTemplate(file, renderData);
|
|
2478
|
+
await writeRenderedFile(targetFilePath, renderedContent);
|
|
2479
|
+
} else {
|
|
2480
|
+
await copyFile(file, targetFilePath);
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
await setupEnvironmentFiles(targetDir);
|
|
2484
|
+
await applyFeatures(targetDir, config, {
|
|
2485
|
+
renderData,
|
|
2486
|
+
assetsRoot: options.assetsRoot
|
|
2487
|
+
});
|
|
2488
|
+
const installer = resolveInstaller(config.packageManager);
|
|
2489
|
+
await installer.install(targetDir);
|
|
2490
|
+
await initializeGit(targetDir);
|
|
2491
|
+
console.log(
|
|
2492
|
+
import_chalk5.default.green(
|
|
2493
|
+
`
|
|
2494
|
+
\u2705 Project ${config.projectName} generated successfully at ${targetDir}`
|
|
2495
|
+
)
|
|
2496
|
+
);
|
|
2497
|
+
};
|
|
2498
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2499
|
+
0 && (module.exports = {
|
|
2500
|
+
FeatureRegistry,
|
|
2501
|
+
applyFeatures,
|
|
2502
|
+
generateProject,
|
|
2503
|
+
getFeatureRegistry,
|
|
2504
|
+
resolveFeatures
|
|
2505
|
+
});
|