@scaffscript/create-project 0.1.2 → 0.1.4
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/cli.js +513 -20
- package/package.json +6 -2
- package/src/index.ts +8 -12
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,494 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
13
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
34
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
35
|
|
|
36
|
+
// node_modules/isexe/windows.js
|
|
37
|
+
var require_windows = __commonJS((exports, module) => {
|
|
38
|
+
module.exports = isexe;
|
|
39
|
+
isexe.sync = sync;
|
|
40
|
+
var fs = __require("fs");
|
|
41
|
+
function checkPathExt(path, options) {
|
|
42
|
+
var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
|
|
43
|
+
if (!pathext) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
pathext = pathext.split(";");
|
|
47
|
+
if (pathext.indexOf("") !== -1) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
for (var i = 0;i < pathext.length; i++) {
|
|
51
|
+
var p = pathext[i].toLowerCase();
|
|
52
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function checkStat(stat, path, options) {
|
|
59
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return checkPathExt(path, options);
|
|
63
|
+
}
|
|
64
|
+
function isexe(path, options, cb) {
|
|
65
|
+
fs.stat(path, function(er, stat) {
|
|
66
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function sync(path, options) {
|
|
70
|
+
return checkStat(fs.statSync(path), path, options);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// node_modules/isexe/mode.js
|
|
75
|
+
var require_mode = __commonJS((exports, module) => {
|
|
76
|
+
module.exports = isexe;
|
|
77
|
+
isexe.sync = sync;
|
|
78
|
+
var fs = __require("fs");
|
|
79
|
+
function isexe(path, options, cb) {
|
|
80
|
+
fs.stat(path, function(er, stat) {
|
|
81
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function sync(path, options) {
|
|
85
|
+
return checkStat(fs.statSync(path), options);
|
|
86
|
+
}
|
|
87
|
+
function checkStat(stat, options) {
|
|
88
|
+
return stat.isFile() && checkMode(stat, options);
|
|
89
|
+
}
|
|
90
|
+
function checkMode(stat, options) {
|
|
91
|
+
var mod = stat.mode;
|
|
92
|
+
var uid = stat.uid;
|
|
93
|
+
var gid = stat.gid;
|
|
94
|
+
var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
|
|
95
|
+
var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
|
|
96
|
+
var u = parseInt("100", 8);
|
|
97
|
+
var g = parseInt("010", 8);
|
|
98
|
+
var o = parseInt("001", 8);
|
|
99
|
+
var ug = u | g;
|
|
100
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
101
|
+
return ret;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// node_modules/isexe/index.js
|
|
106
|
+
var require_isexe = __commonJS((exports, module) => {
|
|
107
|
+
var fs = __require("fs");
|
|
108
|
+
var core;
|
|
109
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
110
|
+
core = require_windows();
|
|
111
|
+
} else {
|
|
112
|
+
core = require_mode();
|
|
113
|
+
}
|
|
114
|
+
module.exports = isexe;
|
|
115
|
+
isexe.sync = sync;
|
|
116
|
+
function isexe(path, options, cb) {
|
|
117
|
+
if (typeof options === "function") {
|
|
118
|
+
cb = options;
|
|
119
|
+
options = {};
|
|
120
|
+
}
|
|
121
|
+
if (!cb) {
|
|
122
|
+
if (typeof Promise !== "function") {
|
|
123
|
+
throw new TypeError("callback not provided");
|
|
124
|
+
}
|
|
125
|
+
return new Promise(function(resolve2, reject) {
|
|
126
|
+
isexe(path, options || {}, function(er, is) {
|
|
127
|
+
if (er) {
|
|
128
|
+
reject(er);
|
|
129
|
+
} else {
|
|
130
|
+
resolve2(is);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
core(path, options || {}, function(er, is) {
|
|
136
|
+
if (er) {
|
|
137
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
138
|
+
er = null;
|
|
139
|
+
is = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
cb(er, is);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function sync(path, options) {
|
|
146
|
+
try {
|
|
147
|
+
return core.sync(path, options || {});
|
|
148
|
+
} catch (er) {
|
|
149
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
150
|
+
return false;
|
|
151
|
+
} else {
|
|
152
|
+
throw er;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// node_modules/which/which.js
|
|
159
|
+
var require_which = __commonJS((exports, module) => {
|
|
160
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
161
|
+
var path = __require("path");
|
|
162
|
+
var COLON = isWindows ? ";" : ":";
|
|
163
|
+
var isexe = require_isexe();
|
|
164
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
165
|
+
var getPathInfo = (cmd, opt) => {
|
|
166
|
+
const colon = opt.colon || COLON;
|
|
167
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
168
|
+
...isWindows ? [process.cwd()] : [],
|
|
169
|
+
...(opt.path || process.env.PATH || "").split(colon)
|
|
170
|
+
];
|
|
171
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
172
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
173
|
+
if (isWindows) {
|
|
174
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
175
|
+
pathExt.unshift("");
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
pathEnv,
|
|
179
|
+
pathExt,
|
|
180
|
+
pathExtExe
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
var which = (cmd, opt, cb) => {
|
|
184
|
+
if (typeof opt === "function") {
|
|
185
|
+
cb = opt;
|
|
186
|
+
opt = {};
|
|
187
|
+
}
|
|
188
|
+
if (!opt)
|
|
189
|
+
opt = {};
|
|
190
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
191
|
+
const found = [];
|
|
192
|
+
const step = (i) => new Promise((resolve2, reject) => {
|
|
193
|
+
if (i === pathEnv.length)
|
|
194
|
+
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
195
|
+
const ppRaw = pathEnv[i];
|
|
196
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
197
|
+
const pCmd = path.join(pathPart, cmd);
|
|
198
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
199
|
+
resolve2(subStep(p, i, 0));
|
|
200
|
+
});
|
|
201
|
+
const subStep = (p, i, ii) => new Promise((resolve2, reject) => {
|
|
202
|
+
if (ii === pathExt.length)
|
|
203
|
+
return resolve2(step(i + 1));
|
|
204
|
+
const ext = pathExt[ii];
|
|
205
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
206
|
+
if (!er && is) {
|
|
207
|
+
if (opt.all)
|
|
208
|
+
found.push(p + ext);
|
|
209
|
+
else
|
|
210
|
+
return resolve2(p + ext);
|
|
211
|
+
}
|
|
212
|
+
return resolve2(subStep(p, i, ii + 1));
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
216
|
+
};
|
|
217
|
+
var whichSync = (cmd, opt) => {
|
|
218
|
+
opt = opt || {};
|
|
219
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
220
|
+
const found = [];
|
|
221
|
+
for (let i = 0;i < pathEnv.length; i++) {
|
|
222
|
+
const ppRaw = pathEnv[i];
|
|
223
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
224
|
+
const pCmd = path.join(pathPart, cmd);
|
|
225
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
226
|
+
for (let j = 0;j < pathExt.length; j++) {
|
|
227
|
+
const cur = p + pathExt[j];
|
|
228
|
+
try {
|
|
229
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
230
|
+
if (is) {
|
|
231
|
+
if (opt.all)
|
|
232
|
+
found.push(cur);
|
|
233
|
+
else
|
|
234
|
+
return cur;
|
|
235
|
+
}
|
|
236
|
+
} catch (ex) {}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (opt.all && found.length)
|
|
240
|
+
return found;
|
|
241
|
+
if (opt.nothrow)
|
|
242
|
+
return null;
|
|
243
|
+
throw getNotFoundError(cmd);
|
|
244
|
+
};
|
|
245
|
+
module.exports = which;
|
|
246
|
+
which.sync = whichSync;
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// node_modules/path-key/index.js
|
|
250
|
+
var require_path_key = __commonJS((exports, module) => {
|
|
251
|
+
var pathKey = (options = {}) => {
|
|
252
|
+
const environment = options.env || process.env;
|
|
253
|
+
const platform = options.platform || process.platform;
|
|
254
|
+
if (platform !== "win32") {
|
|
255
|
+
return "PATH";
|
|
256
|
+
}
|
|
257
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
258
|
+
};
|
|
259
|
+
module.exports = pathKey;
|
|
260
|
+
module.exports.default = pathKey;
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
264
|
+
var require_resolveCommand = __commonJS((exports, module) => {
|
|
265
|
+
var path = __require("path");
|
|
266
|
+
var which = require_which();
|
|
267
|
+
var getPathKey = require_path_key();
|
|
268
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
269
|
+
const env = parsed.options.env || process.env;
|
|
270
|
+
const cwd = process.cwd();
|
|
271
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
272
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|
273
|
+
if (shouldSwitchCwd) {
|
|
274
|
+
try {
|
|
275
|
+
process.chdir(parsed.options.cwd);
|
|
276
|
+
} catch (err) {}
|
|
277
|
+
}
|
|
278
|
+
let resolved;
|
|
279
|
+
try {
|
|
280
|
+
resolved = which.sync(parsed.command, {
|
|
281
|
+
path: env[getPathKey({ env })],
|
|
282
|
+
pathExt: withoutPathExt ? path.delimiter : undefined
|
|
283
|
+
});
|
|
284
|
+
} catch (e) {} finally {
|
|
285
|
+
if (shouldSwitchCwd) {
|
|
286
|
+
process.chdir(cwd);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (resolved) {
|
|
290
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
291
|
+
}
|
|
292
|
+
return resolved;
|
|
293
|
+
}
|
|
294
|
+
function resolveCommand(parsed) {
|
|
295
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
296
|
+
}
|
|
297
|
+
module.exports = resolveCommand;
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// node_modules/cross-spawn/lib/util/escape.js
|
|
301
|
+
var require_escape = __commonJS((exports, module) => {
|
|
302
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
303
|
+
function escapeCommand(arg) {
|
|
304
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
305
|
+
return arg;
|
|
306
|
+
}
|
|
307
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
308
|
+
arg = `${arg}`;
|
|
309
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
310
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
311
|
+
arg = `"${arg}"`;
|
|
312
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
313
|
+
if (doubleEscapeMetaChars) {
|
|
314
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
315
|
+
}
|
|
316
|
+
return arg;
|
|
317
|
+
}
|
|
318
|
+
exports.command = escapeCommand;
|
|
319
|
+
exports.argument = escapeArgument;
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// node_modules/shebang-regex/index.js
|
|
323
|
+
var require_shebang_regex = __commonJS((exports, module) => {
|
|
324
|
+
module.exports = /^#!(.*)/;
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// node_modules/shebang-command/index.js
|
|
328
|
+
var require_shebang_command = __commonJS((exports, module) => {
|
|
329
|
+
var shebangRegex = require_shebang_regex();
|
|
330
|
+
module.exports = (string = "") => {
|
|
331
|
+
const match = string.match(shebangRegex);
|
|
332
|
+
if (!match) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
336
|
+
const binary = path.split("/").pop();
|
|
337
|
+
if (binary === "env") {
|
|
338
|
+
return argument;
|
|
339
|
+
}
|
|
340
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// node_modules/cross-spawn/lib/util/readShebang.js
|
|
345
|
+
var require_readShebang = __commonJS((exports, module) => {
|
|
346
|
+
var fs = __require("fs");
|
|
347
|
+
var shebangCommand = require_shebang_command();
|
|
348
|
+
function readShebang(command) {
|
|
349
|
+
const size = 150;
|
|
350
|
+
const buffer = Buffer.alloc(size);
|
|
351
|
+
let fd;
|
|
352
|
+
try {
|
|
353
|
+
fd = fs.openSync(command, "r");
|
|
354
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
355
|
+
fs.closeSync(fd);
|
|
356
|
+
} catch (e) {}
|
|
357
|
+
return shebangCommand(buffer.toString());
|
|
358
|
+
}
|
|
359
|
+
module.exports = readShebang;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// node_modules/cross-spawn/lib/parse.js
|
|
363
|
+
var require_parse = __commonJS((exports, module) => {
|
|
364
|
+
var path = __require("path");
|
|
365
|
+
var resolveCommand = require_resolveCommand();
|
|
366
|
+
var escape = require_escape();
|
|
367
|
+
var readShebang = require_readShebang();
|
|
368
|
+
var isWin = process.platform === "win32";
|
|
369
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
370
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
371
|
+
function detectShebang(parsed) {
|
|
372
|
+
parsed.file = resolveCommand(parsed);
|
|
373
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
374
|
+
if (shebang) {
|
|
375
|
+
parsed.args.unshift(parsed.file);
|
|
376
|
+
parsed.command = shebang;
|
|
377
|
+
return resolveCommand(parsed);
|
|
378
|
+
}
|
|
379
|
+
return parsed.file;
|
|
380
|
+
}
|
|
381
|
+
function parseNonShell(parsed) {
|
|
382
|
+
if (!isWin) {
|
|
383
|
+
return parsed;
|
|
384
|
+
}
|
|
385
|
+
const commandFile = detectShebang(parsed);
|
|
386
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
387
|
+
if (parsed.options.forceShell || needsShell) {
|
|
388
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
389
|
+
parsed.command = path.normalize(parsed.command);
|
|
390
|
+
parsed.command = escape.command(parsed.command);
|
|
391
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
392
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
393
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
394
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
395
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
396
|
+
}
|
|
397
|
+
return parsed;
|
|
398
|
+
}
|
|
399
|
+
function parse(command, args, options) {
|
|
400
|
+
if (args && !Array.isArray(args)) {
|
|
401
|
+
options = args;
|
|
402
|
+
args = null;
|
|
403
|
+
}
|
|
404
|
+
args = args ? args.slice(0) : [];
|
|
405
|
+
options = Object.assign({}, options);
|
|
406
|
+
const parsed = {
|
|
407
|
+
command,
|
|
408
|
+
args,
|
|
409
|
+
options,
|
|
410
|
+
file: undefined,
|
|
411
|
+
original: {
|
|
412
|
+
command,
|
|
413
|
+
args
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
417
|
+
}
|
|
418
|
+
module.exports = parse;
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// node_modules/cross-spawn/lib/enoent.js
|
|
422
|
+
var require_enoent = __commonJS((exports, module) => {
|
|
423
|
+
var isWin = process.platform === "win32";
|
|
424
|
+
function notFoundError(original, syscall) {
|
|
425
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
426
|
+
code: "ENOENT",
|
|
427
|
+
errno: "ENOENT",
|
|
428
|
+
syscall: `${syscall} ${original.command}`,
|
|
429
|
+
path: original.command,
|
|
430
|
+
spawnargs: original.args
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function hookChildProcess(cp2, parsed) {
|
|
434
|
+
if (!isWin) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const originalEmit = cp2.emit;
|
|
438
|
+
cp2.emit = function(name, arg1) {
|
|
439
|
+
if (name === "exit") {
|
|
440
|
+
const err = verifyENOENT(arg1, parsed);
|
|
441
|
+
if (err) {
|
|
442
|
+
return originalEmit.call(cp2, "error", err);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return originalEmit.apply(cp2, arguments);
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function verifyENOENT(status, parsed) {
|
|
449
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
450
|
+
return notFoundError(parsed.original, "spawn");
|
|
451
|
+
}
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
function verifyENOENTSync(status, parsed) {
|
|
455
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
456
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
module.exports = {
|
|
461
|
+
hookChildProcess,
|
|
462
|
+
verifyENOENT,
|
|
463
|
+
verifyENOENTSync,
|
|
464
|
+
notFoundError
|
|
465
|
+
};
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// node_modules/cross-spawn/index.js
|
|
469
|
+
var require_cross_spawn = __commonJS((exports, module) => {
|
|
470
|
+
var cp2 = __require("child_process");
|
|
471
|
+
var parse = require_parse();
|
|
472
|
+
var enoent = require_enoent();
|
|
473
|
+
function spawn(command, args, options) {
|
|
474
|
+
const parsed = parse(command, args, options);
|
|
475
|
+
const spawned = cp2.spawn(parsed.command, parsed.args, parsed.options);
|
|
476
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
477
|
+
return spawned;
|
|
478
|
+
}
|
|
479
|
+
function spawnSync(command, args, options) {
|
|
480
|
+
const parsed = parse(command, args, options);
|
|
481
|
+
const result = cp2.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
482
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
483
|
+
return result;
|
|
484
|
+
}
|
|
485
|
+
module.exports = spawn;
|
|
486
|
+
module.exports.spawn = spawn;
|
|
487
|
+
module.exports.sync = spawnSync;
|
|
488
|
+
module.exports._parse = parse;
|
|
489
|
+
module.exports._enoent = enoent;
|
|
490
|
+
});
|
|
491
|
+
|
|
5
492
|
// src/utils.ts
|
|
6
493
|
var log = {
|
|
7
494
|
debug: (msg) => console.log("\x1B[90m[DEBUG]\x1B[0m ", msg),
|
|
@@ -169,14 +656,26 @@ async function copyGameMakerProject(target, projectName, ideVersion) {
|
|
|
169
656
|
}
|
|
170
657
|
|
|
171
658
|
// src/init.ts
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
659
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
660
|
+
function runSpawn(cmd, targetDir, args) {
|
|
661
|
+
return new Promise((resolve2, reject) => {
|
|
662
|
+
console.log("\x1B[0m");
|
|
663
|
+
const child = import_cross_spawn.default(cmd, Array.isArray(args) ? args : [args], {
|
|
176
664
|
cwd: targetDir,
|
|
177
|
-
stdio: "inherit"
|
|
178
|
-
|
|
665
|
+
stdio: "inherit"
|
|
666
|
+
});
|
|
667
|
+
child.on("error", reject);
|
|
668
|
+
child.on("close", (code) => {
|
|
669
|
+
if (code === 0)
|
|
670
|
+
resolve2(true);
|
|
671
|
+
else
|
|
672
|
+
reject(new Error(`Install failed with exit code ${code}`));
|
|
179
673
|
});
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
async function installDependencies(template, targetDir) {
|
|
677
|
+
try {
|
|
678
|
+
await runSpawn(template, targetDir, "install");
|
|
180
679
|
return true;
|
|
181
680
|
} catch (error) {
|
|
182
681
|
log.error(`Failed to install dependencies: ${error}`);
|
|
@@ -185,11 +684,7 @@ async function installDependencies(template, targetDir) {
|
|
|
185
684
|
}
|
|
186
685
|
async function initializeGit(targetDir) {
|
|
187
686
|
try {
|
|
188
|
-
|
|
189
|
-
cwd: targetDir,
|
|
190
|
-
stdio: "inherit",
|
|
191
|
-
shell: true
|
|
192
|
-
});
|
|
687
|
+
await runSpawn("git", targetDir, "init");
|
|
193
688
|
return true;
|
|
194
689
|
} catch (error) {
|
|
195
690
|
log.error(`Failed to initialize Git repository: ${error}`);
|
|
@@ -203,23 +698,21 @@ async function main() {
|
|
|
203
698
|
const args = process.argv.slice(2);
|
|
204
699
|
const input = await parseArgs(...args);
|
|
205
700
|
if (!input)
|
|
206
|
-
|
|
701
|
+
process.exit(1);
|
|
207
702
|
const copied = await copyTemplate(`../templates/${input.template}`, input.targetPath);
|
|
208
703
|
const installed = await installDependencies(input.template, input.targetPath);
|
|
209
704
|
if (input.initGit) {
|
|
210
705
|
const initGit = await initializeGit(input.targetPath);
|
|
211
706
|
if (!initGit)
|
|
212
|
-
|
|
707
|
+
process.exit(1);
|
|
213
708
|
}
|
|
214
709
|
if (input.projectName && input.ideVersion) {
|
|
215
710
|
await copyGameMakerProject(input.targetPath, input.projectName, input.ideVersion);
|
|
216
711
|
}
|
|
217
712
|
if (!copied || !installed)
|
|
218
|
-
|
|
219
|
-
|
|
713
|
+
process.exit(1);
|
|
714
|
+
console.log("");
|
|
715
|
+
log.info("ScaffScript project initialized successfully.");
|
|
716
|
+
log.info(`You can now use \x1B[32m${input.template} run <script> -- <command> [args]\x1B[0m. Use \x1B[32m${input.template} run help\x1B[0m for more information.`);
|
|
220
717
|
}
|
|
221
|
-
|
|
222
|
-
if (!input)
|
|
223
|
-
process.exit(1);
|
|
224
|
-
log.info("ScaffScript project initialized successfully.");
|
|
225
|
-
log.info(`You can now use \x1B[32m${input.template} run <script> -- <command> [args]\x1B[0m. Use \x1B[32m${input.template} run help\x1B[0m for more information.`);
|
|
718
|
+
await main();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaffscript/create-project",
|
|
3
3
|
"description": "ScaffScript project initializer",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -24,12 +24,16 @@
|
|
|
24
24
|
"@types/bun": "latest"
|
|
25
25
|
},
|
|
26
26
|
"bin": {
|
|
27
|
-
"create-
|
|
27
|
+
"create-project": "dist/cli.js"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "bun build src/index.ts --outfile dist/cli.js --target node"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"typescript": "^5"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@types/cross-spawn": "^6.0.6",
|
|
37
|
+
"cross-spawn": "^7.0.6"
|
|
34
38
|
}
|
|
35
39
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,12 +6,12 @@ import { installDependencies, initializeGit } from "./init";
|
|
|
6
6
|
|
|
7
7
|
async function main() {
|
|
8
8
|
log.info("Initializing ScaffScript project...");
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
const args = process.argv.slice(2);
|
|
11
11
|
const input = await parseArgs(...args);
|
|
12
12
|
|
|
13
13
|
if (!input)
|
|
14
|
-
|
|
14
|
+
process.exit(1);
|
|
15
15
|
|
|
16
16
|
const copied = await fs.copyTemplate(`../templates/${input.template}`, input.targetPath);
|
|
17
17
|
const installed = await installDependencies(input.template, input.targetPath);
|
|
@@ -20,7 +20,7 @@ async function main() {
|
|
|
20
20
|
const initGit = await initializeGit(input.targetPath);
|
|
21
21
|
|
|
22
22
|
if (!initGit)
|
|
23
|
-
|
|
23
|
+
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (input.projectName && input.ideVersion) {
|
|
@@ -28,15 +28,11 @@ async function main() {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (!copied || !installed)
|
|
31
|
-
|
|
31
|
+
process.exit(1);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
console.log("");
|
|
34
|
+
log.info("ScaffScript project initialized successfully.");
|
|
35
|
+
log.info(`You can now use \x1b[32m${input.template} run <script> -- <command> [args]\x1b[0m. Use \x1b[32m${input.template} run help\x1b[0m for more information.`);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!input)
|
|
39
|
-
process.exit(1);
|
|
40
|
-
|
|
41
|
-
log.info("ScaffScript project initialized successfully.");
|
|
42
|
-
log.info(`You can now use \x1b[32m${input.template} run <script> -- <command> [args]\x1b[0m. Use \x1b[32m${input.template} run help\x1b[0m for more information.`);
|
|
38
|
+
await main();
|