@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.mjs
ADDED
|
@@ -0,0 +1,2493 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/isexe/windows.js
|
|
34
|
+
var require_windows = __commonJS({
|
|
35
|
+
"../../node_modules/isexe/windows.js"(exports, module) {
|
|
36
|
+
"use strict";
|
|
37
|
+
module.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"(exports, module) {
|
|
77
|
+
"use strict";
|
|
78
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.exports = pathKey;
|
|
274
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.exports.command = escapeCommand;
|
|
341
|
+
module.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"(exports, module) {
|
|
348
|
+
"use strict";
|
|
349
|
+
module.exports = /^#!(.*)/;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// ../../node_modules/shebang-command/index.js
|
|
354
|
+
var require_shebang_command = __commonJS({
|
|
355
|
+
"../../node_modules/shebang-command/index.js"(exports, module) {
|
|
356
|
+
"use strict";
|
|
357
|
+
var shebangRegex = require_shebang_regex();
|
|
358
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.exports = spawn;
|
|
527
|
+
module.exports.spawn = spawn;
|
|
528
|
+
module.exports.sync = spawnSync;
|
|
529
|
+
module.exports._parse = parse;
|
|
530
|
+
module.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"(exports, module) {
|
|
537
|
+
"use strict";
|
|
538
|
+
module.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"(exports, module) {
|
|
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
|
+
module.exports = npmRunPath;
|
|
578
|
+
module.exports.default = npmRunPath;
|
|
579
|
+
module.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] = module.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"(exports, module) {
|
|
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
|
+
module.exports = mimicFn;
|
|
604
|
+
module.exports.default = mimicFn;
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// ../../node_modules/onetime/index.js
|
|
609
|
+
var require_onetime = __commonJS({
|
|
610
|
+
"../../node_modules/onetime/index.js"(exports, module) {
|
|
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
|
+
module.exports = onetime;
|
|
636
|
+
module.exports.default = onetime;
|
|
637
|
+
module.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"(exports) {
|
|
649
|
+
"use strict";
|
|
650
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
651
|
+
exports.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
|
+
exports.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"(exports) {
|
|
930
|
+
"use strict";
|
|
931
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
932
|
+
exports.SIGRTMAX = exports.getRealtimeSignals = void 0;
|
|
933
|
+
var getRealtimeSignals = function() {
|
|
934
|
+
const length = SIGRTMAX - SIGRTMIN + 1;
|
|
935
|
+
return Array.from({ length }, getRealtimeSignal);
|
|
936
|
+
};
|
|
937
|
+
exports.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
|
+
exports.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"(exports) {
|
|
956
|
+
"use strict";
|
|
957
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
958
|
+
exports.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
|
+
exports.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"(exports) {
|
|
989
|
+
"use strict";
|
|
990
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
991
|
+
exports.signalsByNumber = exports.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
|
+
exports.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
|
+
exports.signalsByNumber = signalsByNumber;
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
// ../../node_modules/execa/lib/error.js
|
|
1044
|
+
var require_error = __commonJS({
|
|
1045
|
+
"../../node_modules/execa/lib/error.js"(exports, module) {
|
|
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
|
+
module.exports = makeError;
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
// ../../node_modules/execa/lib/stdio.js
|
|
1119
|
+
var require_stdio = __commonJS({
|
|
1120
|
+
"../../node_modules/execa/lib/stdio.js"(exports, module) {
|
|
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
|
+
module.exports = normalizeStdio;
|
|
1145
|
+
module.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"(exports, module) {
|
|
1164
|
+
"use strict";
|
|
1165
|
+
module.exports = [
|
|
1166
|
+
"SIGABRT",
|
|
1167
|
+
"SIGALRM",
|
|
1168
|
+
"SIGHUP",
|
|
1169
|
+
"SIGINT",
|
|
1170
|
+
"SIGTERM"
|
|
1171
|
+
];
|
|
1172
|
+
if (process.platform !== "win32") {
|
|
1173
|
+
module.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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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
|
+
module.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
|
+
module.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
|
+
module.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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
1462
|
+
"use strict";
|
|
1463
|
+
var { PassThrough: PassThroughStream } = __require("stream");
|
|
1464
|
+
module.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"(exports, module) {
|
|
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
|
+
module.exports = getStream;
|
|
1553
|
+
module.exports.buffer = (stream2, options) => getStream(stream2, { ...options, encoding: "buffer" });
|
|
1554
|
+
module.exports.array = (stream2, options) => getStream(stream2, { ...options, array: true });
|
|
1555
|
+
module.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"(exports, module) {
|
|
1562
|
+
"use strict";
|
|
1563
|
+
var { PassThrough } = __require("stream");
|
|
1564
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.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"(exports, module) {
|
|
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
|
+
module.exports = execa3;
|
|
1876
|
+
module.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
|
+
module.exports.command = (command, options) => {
|
|
1928
|
+
const [file, ...args] = parseCommand(command);
|
|
1929
|
+
return execa3(file, args, options);
|
|
1930
|
+
};
|
|
1931
|
+
module.exports.commandSync = (command, options) => {
|
|
1932
|
+
const [file, ...args] = parseCommand(command);
|
|
1933
|
+
return execa3.sync(file, args, options);
|
|
1934
|
+
};
|
|
1935
|
+
module.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/generator/generateProject.ts
|
|
1967
|
+
import path7 from "path";
|
|
1968
|
+
import chalk5 from "chalk";
|
|
1969
|
+
import fs7 from "fs-extra";
|
|
1970
|
+
|
|
1971
|
+
// src/resolvers/templateResolver.ts
|
|
1972
|
+
import path3 from "path";
|
|
1973
|
+
|
|
1974
|
+
// src/filesystem/index.ts
|
|
1975
|
+
import fs from "fs-extra";
|
|
1976
|
+
import path from "path";
|
|
1977
|
+
var copyFile = async (src, dest) => {
|
|
1978
|
+
await fs.ensureDir(path.dirname(dest));
|
|
1979
|
+
await fs.copy(src, dest);
|
|
1980
|
+
};
|
|
1981
|
+
var writeRenderedFile = async (dest, content) => {
|
|
1982
|
+
await fs.ensureDir(path.dirname(dest));
|
|
1983
|
+
await fs.writeFile(dest, content, "utf-8");
|
|
1984
|
+
};
|
|
1985
|
+
var getAllFiles = async (dirPath) => {
|
|
1986
|
+
const files = [];
|
|
1987
|
+
const items = await fs.readdir(dirPath, { withFileTypes: true });
|
|
1988
|
+
for (const item of items) {
|
|
1989
|
+
const fullPath = path.join(dirPath, item.name);
|
|
1990
|
+
if (item.isDirectory()) {
|
|
1991
|
+
files.push(...await getAllFiles(fullPath));
|
|
1992
|
+
} else {
|
|
1993
|
+
files.push(fullPath);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
return files;
|
|
1997
|
+
};
|
|
1998
|
+
var exists = async (path8) => {
|
|
1999
|
+
return fs.pathExists(path8);
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
// src/constants/paths.ts
|
|
2003
|
+
import path2 from "path";
|
|
2004
|
+
import fs2 from "fs-extra";
|
|
2005
|
+
var getAssetsRoot = () => {
|
|
2006
|
+
if (process.env.MONSTACK_ASSETS_PATH) {
|
|
2007
|
+
return process.env.MONSTACK_ASSETS_PATH;
|
|
2008
|
+
}
|
|
2009
|
+
const possiblePaths = [
|
|
2010
|
+
// Monorepo root (dev)
|
|
2011
|
+
path2.resolve(__dirname, "../../../../"),
|
|
2012
|
+
// Core package root (dist)
|
|
2013
|
+
path2.resolve(__dirname, "../../../"),
|
|
2014
|
+
// Current working directory
|
|
2015
|
+
process.cwd()
|
|
2016
|
+
];
|
|
2017
|
+
for (const root of possiblePaths) {
|
|
2018
|
+
const templatesExists = fs2.pathExistsSync(path2.join(root, "templates"));
|
|
2019
|
+
const featuresExists = fs2.pathExistsSync(path2.join(root, "features"));
|
|
2020
|
+
const pkgTemplatesExists = fs2.pathExistsSync(path2.join(root, "packages/templates"));
|
|
2021
|
+
const pkgFeaturesExists = fs2.pathExistsSync(path2.join(root, "packages/features"));
|
|
2022
|
+
if (templatesExists && featuresExists) {
|
|
2023
|
+
return root;
|
|
2024
|
+
}
|
|
2025
|
+
if (pkgTemplatesExists && pkgFeaturesExists) {
|
|
2026
|
+
return path2.join(root, "packages");
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
return path2.resolve(__dirname, "../../../../packages");
|
|
2030
|
+
};
|
|
2031
|
+
var getTemplatesPath = () => {
|
|
2032
|
+
return path2.join(getAssetsRoot(), "templates");
|
|
2033
|
+
};
|
|
2034
|
+
var getFeaturesPath = () => {
|
|
2035
|
+
return path2.join(getAssetsRoot(), "features");
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
// src/resolvers/templateResolver.ts
|
|
2039
|
+
var resolveTemplatePath = async (config, assetsRoot) => {
|
|
2040
|
+
const templateBaseDir = assetsRoot ? path3.join(assetsRoot, "templates") : getTemplatesPath();
|
|
2041
|
+
const templatePath = path3.join(
|
|
2042
|
+
templateBaseDir,
|
|
2043
|
+
config.framework,
|
|
2044
|
+
config.architecture,
|
|
2045
|
+
config.database
|
|
2046
|
+
);
|
|
2047
|
+
if (!await exists(templatePath)) {
|
|
2048
|
+
throw new Error(`Template not found at: ${templatePath}`);
|
|
2049
|
+
}
|
|
2050
|
+
return templatePath;
|
|
2051
|
+
};
|
|
2052
|
+
|
|
2053
|
+
// src/template-engine/index.ts
|
|
2054
|
+
import ejs from "ejs";
|
|
2055
|
+
import fs3 from "fs-extra";
|
|
2056
|
+
var renderTemplate = async (filePath, data) => {
|
|
2057
|
+
const templateContent = await fs3.readFile(filePath, "utf-8");
|
|
2058
|
+
return ejs.render(templateContent, data);
|
|
2059
|
+
};
|
|
2060
|
+
var isTemplateFile = (filePath) => {
|
|
2061
|
+
return filePath.endsWith(".ejs");
|
|
2062
|
+
};
|
|
2063
|
+
var getTargetFileName = (filePath) => {
|
|
2064
|
+
if (isTemplateFile(filePath)) {
|
|
2065
|
+
return filePath.replace(/\.ejs$/, "");
|
|
2066
|
+
}
|
|
2067
|
+
return filePath;
|
|
2068
|
+
};
|
|
2069
|
+
|
|
2070
|
+
// src/installers/base.ts
|
|
2071
|
+
var import_execa = __toESM(require_execa());
|
|
2072
|
+
import chalk from "chalk";
|
|
2073
|
+
var BaseInstaller = class {
|
|
2074
|
+
async install(projectPath) {
|
|
2075
|
+
const { command, args } = this.getInstallCommand();
|
|
2076
|
+
console.log(
|
|
2077
|
+
chalk.cyan(`
|
|
2078
|
+
\u{1F4E6} Installing dependencies using ${this.getName()}...`)
|
|
2079
|
+
);
|
|
2080
|
+
try {
|
|
2081
|
+
await (0, import_execa.default)(command, args, {
|
|
2082
|
+
cwd: projectPath,
|
|
2083
|
+
stdio: "inherit"
|
|
2084
|
+
});
|
|
2085
|
+
} catch (error) {
|
|
2086
|
+
throw new Error(
|
|
2087
|
+
`Failed to install dependencies using ${this.getName()}: ${error}`
|
|
2088
|
+
);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
|
|
2093
|
+
// src/installers/implementations.ts
|
|
2094
|
+
var NpmInstaller = class extends BaseInstaller {
|
|
2095
|
+
getName() {
|
|
2096
|
+
return "npm";
|
|
2097
|
+
}
|
|
2098
|
+
getInstallCommand() {
|
|
2099
|
+
return { command: "npm", args: ["install"] };
|
|
2100
|
+
}
|
|
2101
|
+
};
|
|
2102
|
+
var PnpmInstaller = class extends BaseInstaller {
|
|
2103
|
+
getName() {
|
|
2104
|
+
return "pnpm";
|
|
2105
|
+
}
|
|
2106
|
+
getInstallCommand() {
|
|
2107
|
+
return { command: "pnpm", args: ["install"] };
|
|
2108
|
+
}
|
|
2109
|
+
};
|
|
2110
|
+
var YarnInstaller = class extends BaseInstaller {
|
|
2111
|
+
getName() {
|
|
2112
|
+
return "yarn";
|
|
2113
|
+
}
|
|
2114
|
+
getInstallCommand() {
|
|
2115
|
+
return { command: "yarn", args: ["install"] };
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
|
|
2119
|
+
// src/installers/index.ts
|
|
2120
|
+
var resolveInstaller = (packageManager) => {
|
|
2121
|
+
switch (packageManager) {
|
|
2122
|
+
case "npm":
|
|
2123
|
+
return new NpmInstaller();
|
|
2124
|
+
case "pnpm":
|
|
2125
|
+
return new PnpmInstaller();
|
|
2126
|
+
case "yarn":
|
|
2127
|
+
return new YarnInstaller();
|
|
2128
|
+
default:
|
|
2129
|
+
return new NpmInstaller();
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
|
|
2133
|
+
// src/git/index.ts
|
|
2134
|
+
var import_execa2 = __toESM(require_execa());
|
|
2135
|
+
import chalk2 from "chalk";
|
|
2136
|
+
var initializeGit = async (projectPath) => {
|
|
2137
|
+
console.log(chalk2.cyan("\ngit Initializing git repository..."));
|
|
2138
|
+
try {
|
|
2139
|
+
await (0, import_execa2.default)("git", ["init"], { cwd: projectPath });
|
|
2140
|
+
await (0, import_execa2.default)("git", ["add", "."], { cwd: projectPath });
|
|
2141
|
+
await (0, import_execa2.default)("git", ["commit", "-m", "Initial commit from MonStack CLI"], {
|
|
2142
|
+
cwd: projectPath
|
|
2143
|
+
});
|
|
2144
|
+
console.log(chalk2.green("\u2705 Git initialized successfully."));
|
|
2145
|
+
} catch (error) {
|
|
2146
|
+
console.log(
|
|
2147
|
+
chalk2.yellow(
|
|
2148
|
+
"\u26A0\uFE0F Failed to initialize git repository. This is non-blocking."
|
|
2149
|
+
)
|
|
2150
|
+
);
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2154
|
+
// src/environment/index.ts
|
|
2155
|
+
import fs4 from "fs-extra";
|
|
2156
|
+
import path4 from "path";
|
|
2157
|
+
import chalk3 from "chalk";
|
|
2158
|
+
var setupEnvironmentFiles = async (projectPath) => {
|
|
2159
|
+
const examplePath = path4.join(projectPath, ".env.example");
|
|
2160
|
+
const envPath = path4.join(projectPath, ".env");
|
|
2161
|
+
if (await fs4.pathExists(examplePath)) {
|
|
2162
|
+
console.log(chalk3.cyan("\u{1F4DD} Creating .env file..."));
|
|
2163
|
+
await fs4.copy(examplePath, envPath);
|
|
2164
|
+
console.log(chalk3.green("\u2705 .env file created."));
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
|
|
2168
|
+
// src/features/apply-features.ts
|
|
2169
|
+
import path6 from "path";
|
|
2170
|
+
import fs6 from "fs-extra";
|
|
2171
|
+
import chalk4 from "chalk";
|
|
2172
|
+
|
|
2173
|
+
// src/features/resolver.ts
|
|
2174
|
+
var resolveFeatures = (config) => {
|
|
2175
|
+
if (!config.features || config.features.length === 0) {
|
|
2176
|
+
return [];
|
|
2177
|
+
}
|
|
2178
|
+
const selectedFeatures = config.features.filter(
|
|
2179
|
+
(feature) => feature !== "none"
|
|
2180
|
+
);
|
|
2181
|
+
return [...new Set(selectedFeatures)];
|
|
2182
|
+
};
|
|
2183
|
+
|
|
2184
|
+
// src/features/registry.ts
|
|
2185
|
+
import path5 from "path";
|
|
2186
|
+
import fs5 from "fs-extra";
|
|
2187
|
+
var FeatureRegistry = class {
|
|
2188
|
+
constructor() {
|
|
2189
|
+
this.features = /* @__PURE__ */ new Map();
|
|
2190
|
+
this.featuresBaseDir = getFeaturesPath();
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Load and register all available features from the features directory
|
|
2194
|
+
*/
|
|
2195
|
+
async discoverFeatures() {
|
|
2196
|
+
const featuresDir = this.featuresBaseDir;
|
|
2197
|
+
if (!await fs5.pathExists(featuresDir)) {
|
|
2198
|
+
console.warn(`Features directory not found at ${featuresDir}`);
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
const entries = await fs5.readdir(featuresDir);
|
|
2202
|
+
for (const entry of entries) {
|
|
2203
|
+
const featurePath = path5.join(featuresDir, entry);
|
|
2204
|
+
const stat = await fs5.stat(featurePath);
|
|
2205
|
+
if (!stat.isDirectory() || entry === "src") continue;
|
|
2206
|
+
await this.registerFeature(entry, featurePath);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Register a single feature by loading its metadata
|
|
2211
|
+
*/
|
|
2212
|
+
async registerFeature(name, featurePath) {
|
|
2213
|
+
const metadataPath = path5.join(featurePath, "metadata.json");
|
|
2214
|
+
if (!await fs5.pathExists(metadataPath)) {
|
|
2215
|
+
console.warn(`Metadata not found for feature: ${name}`);
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
try {
|
|
2219
|
+
const metadata = await fs5.readJson(metadataPath);
|
|
2220
|
+
this.features.set(name, {
|
|
2221
|
+
name,
|
|
2222
|
+
metadata,
|
|
2223
|
+
path: featurePath
|
|
2224
|
+
});
|
|
2225
|
+
} catch (error) {
|
|
2226
|
+
console.error(`Failed to load metadata for feature ${name}:`, error);
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Get a registered feature by name
|
|
2231
|
+
*/
|
|
2232
|
+
getFeature(name) {
|
|
2233
|
+
return this.features.get(name);
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Get metadata for a feature
|
|
2237
|
+
*/
|
|
2238
|
+
getFeatureMetadata(name) {
|
|
2239
|
+
return this.features.get(name)?.metadata;
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Get path to a feature directory
|
|
2243
|
+
*/
|
|
2244
|
+
getFeaturePath(name) {
|
|
2245
|
+
return this.features.get(name)?.path;
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Get all registered features
|
|
2249
|
+
*/
|
|
2250
|
+
getAllFeatures() {
|
|
2251
|
+
return Array.from(this.features.values());
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Check if a feature is registered
|
|
2255
|
+
*/
|
|
2256
|
+
hasFeature(name) {
|
|
2257
|
+
return this.features.has(name);
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Get features that support a specific framework
|
|
2261
|
+
*/
|
|
2262
|
+
getFeaturesByFramework(framework) {
|
|
2263
|
+
return Array.from(this.features.values()).filter(
|
|
2264
|
+
(f) => !f.metadata.frameworks || f.metadata.frameworks.includes(framework)
|
|
2265
|
+
);
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Get features that support a specific architecture
|
|
2269
|
+
*/
|
|
2270
|
+
getFeaturesByArchitecture(architecture) {
|
|
2271
|
+
return Array.from(this.features.values()).filter(
|
|
2272
|
+
(f) => !f.metadata.architectures || f.metadata.architectures.includes(architecture)
|
|
2273
|
+
);
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Get features that support a specific database
|
|
2277
|
+
*/
|
|
2278
|
+
getFeaturesByDatabase(database) {
|
|
2279
|
+
return Array.from(this.features.values()).filter(
|
|
2280
|
+
(f) => !f.metadata.databases || f.metadata.databases.includes(database)
|
|
2281
|
+
);
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Get all features compatible with given config
|
|
2285
|
+
*/
|
|
2286
|
+
getCompatibleFeatures(framework, architecture, database) {
|
|
2287
|
+
return Array.from(this.features.values()).filter(
|
|
2288
|
+
(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))
|
|
2289
|
+
);
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Validate that requested features are available and compatible
|
|
2293
|
+
*/
|
|
2294
|
+
validateFeatures(featureNames, framework, architecture, database) {
|
|
2295
|
+
const errors = [];
|
|
2296
|
+
for (const featureName of featureNames) {
|
|
2297
|
+
const feature = this.getFeature(featureName);
|
|
2298
|
+
if (!feature) {
|
|
2299
|
+
errors.push(`Feature "${featureName}" not found in registry`);
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
const { metadata } = feature;
|
|
2303
|
+
if (metadata.frameworks && !metadata.frameworks.includes(framework)) {
|
|
2304
|
+
errors.push(
|
|
2305
|
+
`Feature "${featureName}" does not support framework "${framework}"`
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
if (metadata.architectures && !metadata.architectures.includes(architecture)) {
|
|
2309
|
+
errors.push(
|
|
2310
|
+
`Feature "${featureName}" does not support architecture "${architecture}"`
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
if (metadata.databases && !metadata.databases.includes(database)) {
|
|
2314
|
+
errors.push(
|
|
2315
|
+
`Feature "${featureName}" does not support database "${database}"`
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
return {
|
|
2320
|
+
valid: errors.length === 0,
|
|
2321
|
+
errors
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
var registryInstance = null;
|
|
2326
|
+
async function getFeatureRegistry() {
|
|
2327
|
+
if (!registryInstance) {
|
|
2328
|
+
registryInstance = new FeatureRegistry();
|
|
2329
|
+
await registryInstance.discoverFeatures();
|
|
2330
|
+
}
|
|
2331
|
+
return registryInstance;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// src/features/apply-features.ts
|
|
2335
|
+
import { createRequire } from "module";
|
|
2336
|
+
var customRequire = typeof __require !== "undefined" ? __require : createRequire(eval("import.meta.url"));
|
|
2337
|
+
var applyFeatures = async (projectPath, config, options = {}) => {
|
|
2338
|
+
const selectedFeatures = resolveFeatures(config);
|
|
2339
|
+
if (selectedFeatures.length === 0) return;
|
|
2340
|
+
const registry = await getFeatureRegistry();
|
|
2341
|
+
const validation = registry.validateFeatures(
|
|
2342
|
+
selectedFeatures,
|
|
2343
|
+
config.framework,
|
|
2344
|
+
config.architecture,
|
|
2345
|
+
config.database
|
|
2346
|
+
);
|
|
2347
|
+
if (!validation.valid) {
|
|
2348
|
+
console.error(chalk4.red("\n\u274C Feature validation failed:"));
|
|
2349
|
+
validation.errors.forEach((err) => console.error(chalk4.red(` - ${err}`)));
|
|
2350
|
+
throw new Error("Feature validation failed");
|
|
2351
|
+
}
|
|
2352
|
+
console.log(chalk4.cyan("\n\u{1F9E9} Applying features..."));
|
|
2353
|
+
for (const featureName of selectedFeatures) {
|
|
2354
|
+
const feature = registry.getFeature(featureName);
|
|
2355
|
+
await applySingleFeature(
|
|
2356
|
+
featureName,
|
|
2357
|
+
feature.path,
|
|
2358
|
+
projectPath,
|
|
2359
|
+
config,
|
|
2360
|
+
options.renderData
|
|
2361
|
+
);
|
|
2362
|
+
}
|
|
2363
|
+
};
|
|
2364
|
+
var applySingleFeature = async (featureName, featureDir, projectPath, config, renderData) => {
|
|
2365
|
+
console.log(chalk4.blue(` - Applying ${featureName}...`));
|
|
2366
|
+
const filesDir = path6.join(featureDir, "files");
|
|
2367
|
+
if (await fs6.pathExists(filesDir)) {
|
|
2368
|
+
const files = await getAllFiles(filesDir);
|
|
2369
|
+
for (const file of files) {
|
|
2370
|
+
const relativePath = path6.relative(filesDir, file);
|
|
2371
|
+
const targetPath = path6.join(
|
|
2372
|
+
projectPath,
|
|
2373
|
+
isTemplateFile(relativePath) ? getTargetFileName(relativePath) : relativePath
|
|
2374
|
+
);
|
|
2375
|
+
if (isTemplateFile(file)) {
|
|
2376
|
+
const templateData = renderData || {};
|
|
2377
|
+
const renderedContent = await renderTemplate(file, templateData);
|
|
2378
|
+
await fs6.ensureDir(path6.dirname(targetPath));
|
|
2379
|
+
await fs6.writeFile(targetPath, renderedContent, "utf-8");
|
|
2380
|
+
} else {
|
|
2381
|
+
await copyFile(file, targetPath);
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
const depFile = path6.join(featureDir, "dependencies.json");
|
|
2386
|
+
if (await fs6.pathExists(depFile)) {
|
|
2387
|
+
const deps = await fs6.readJson(depFile);
|
|
2388
|
+
await mergeDependencies(projectPath, deps);
|
|
2389
|
+
}
|
|
2390
|
+
const hookFile = path6.join(featureDir, "index.ts");
|
|
2391
|
+
const hookFileJs = path6.join(featureDir, "index.js");
|
|
2392
|
+
let hookModule = null;
|
|
2393
|
+
if (await fs6.pathExists(hookFile)) {
|
|
2394
|
+
try {
|
|
2395
|
+
customRequire("ts-node").register({
|
|
2396
|
+
transpileOnly: true,
|
|
2397
|
+
compilerOptions: {
|
|
2398
|
+
module: "CommonJS"
|
|
2399
|
+
}
|
|
2400
|
+
});
|
|
2401
|
+
hookModule = customRequire(hookFile);
|
|
2402
|
+
} catch (error) {
|
|
2403
|
+
}
|
|
2404
|
+
} else if (await fs6.pathExists(hookFileJs)) {
|
|
2405
|
+
hookModule = customRequire(hookFileJs);
|
|
2406
|
+
}
|
|
2407
|
+
if (hookModule && hookModule.postApply) {
|
|
2408
|
+
try {
|
|
2409
|
+
await hookModule.postApply(projectPath, config);
|
|
2410
|
+
} catch (error) {
|
|
2411
|
+
console.error(
|
|
2412
|
+
chalk4.red(` - Error running postApply hook for ${featureName}:`),
|
|
2413
|
+
error
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
var mergeDependencies = async (projectPath, featureDeps) => {
|
|
2419
|
+
const pkgPath = path6.join(projectPath, "package.json");
|
|
2420
|
+
if (!await fs6.pathExists(pkgPath)) return;
|
|
2421
|
+
const pkg = await fs6.readJson(pkgPath);
|
|
2422
|
+
if (featureDeps.dependencies) {
|
|
2423
|
+
pkg.dependencies = {
|
|
2424
|
+
...pkg.dependencies || {},
|
|
2425
|
+
...featureDeps.dependencies
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
if (featureDeps.devDependencies) {
|
|
2429
|
+
pkg.devDependencies = {
|
|
2430
|
+
...pkg.devDependencies || {},
|
|
2431
|
+
...featureDeps.devDependencies
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
await fs6.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
// src/generator/generateProject.ts
|
|
2438
|
+
var generateProject = async (config, options = {}) => {
|
|
2439
|
+
const targetDir = path7.join(process.cwd(), config.projectName);
|
|
2440
|
+
if (await fs7.pathExists(targetDir)) {
|
|
2441
|
+
throw new Error(`Target directory ${config.projectName} already exists.`);
|
|
2442
|
+
}
|
|
2443
|
+
console.log(chalk5.cyan(`
|
|
2444
|
+
\u{1F3D7}\uFE0F Generating project: ${config.projectName}...`));
|
|
2445
|
+
const templatePath = await resolveTemplatePath(config, options.assetsRoot);
|
|
2446
|
+
const files = await getAllFiles(templatePath);
|
|
2447
|
+
const renderData = {
|
|
2448
|
+
PROJECT_NAME: config.projectName,
|
|
2449
|
+
PORT: 3e3,
|
|
2450
|
+
// Default port for now
|
|
2451
|
+
PACKAGE_MANAGER: config.packageManager,
|
|
2452
|
+
NODE_ENV: "development",
|
|
2453
|
+
DATABASE: config.database,
|
|
2454
|
+
ORM: config.orm
|
|
2455
|
+
};
|
|
2456
|
+
for (const file of files) {
|
|
2457
|
+
const relativePath = path7.relative(templatePath, file);
|
|
2458
|
+
if (relativePath.includes("node_modules") || relativePath.includes("dist")) {
|
|
2459
|
+
continue;
|
|
2460
|
+
}
|
|
2461
|
+
const targetFilePath = path7.join(
|
|
2462
|
+
targetDir,
|
|
2463
|
+
getTargetFileName(relativePath)
|
|
2464
|
+
);
|
|
2465
|
+
if (isTemplateFile(file)) {
|
|
2466
|
+
const renderedContent = await renderTemplate(file, renderData);
|
|
2467
|
+
await writeRenderedFile(targetFilePath, renderedContent);
|
|
2468
|
+
} else {
|
|
2469
|
+
await copyFile(file, targetFilePath);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
await setupEnvironmentFiles(targetDir);
|
|
2473
|
+
await applyFeatures(targetDir, config, {
|
|
2474
|
+
renderData,
|
|
2475
|
+
assetsRoot: options.assetsRoot
|
|
2476
|
+
});
|
|
2477
|
+
const installer = resolveInstaller(config.packageManager);
|
|
2478
|
+
await installer.install(targetDir);
|
|
2479
|
+
await initializeGit(targetDir);
|
|
2480
|
+
console.log(
|
|
2481
|
+
chalk5.green(
|
|
2482
|
+
`
|
|
2483
|
+
\u2705 Project ${config.projectName} generated successfully at ${targetDir}`
|
|
2484
|
+
)
|
|
2485
|
+
);
|
|
2486
|
+
};
|
|
2487
|
+
export {
|
|
2488
|
+
FeatureRegistry,
|
|
2489
|
+
applyFeatures,
|
|
2490
|
+
generateProject,
|
|
2491
|
+
getFeatureRegistry,
|
|
2492
|
+
resolveFeatures
|
|
2493
|
+
};
|