@scaffscript/create-project 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # @scaffscript/create-project
2
2
 
3
- A CLI tool for initializing a new ScaffScript project.
3
+ A CLI tool for initializing a new **ScaffScript** project.
4
+
5
+ > [!WARNING]
6
+ > This project is still in early development. The syntax and features are subject to change. Use at your own risk.
4
7
 
5
8
  ## Usage
6
9
 
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),
@@ -107,6 +594,9 @@ async function getIDEVersion() {
107
594
  return res;
108
595
  }
109
596
 
597
+ // src/index.ts
598
+ import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
599
+
110
600
  // src/fs.ts
111
601
  import { cp, mkdir, access, rename, readFile, writeFile } from "fs/promises";
112
602
  import { dirname, join, resolve } from "path";
@@ -169,14 +659,26 @@ async function copyGameMakerProject(target, projectName, ideVersion) {
169
659
  }
170
660
 
171
661
  // src/init.ts
172
- import { spawn } from "child_process";
173
- async function installDependencies(template, targetDir) {
174
- try {
175
- spawn(template, ["install"], {
662
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
663
+ function runSpawn(cmd, targetDir, args) {
664
+ return new Promise((resolve2, reject) => {
665
+ console.log("\x1B[0m");
666
+ const child = import_cross_spawn.default(cmd, Array.isArray(args) ? args : [args], {
176
667
  cwd: targetDir,
177
- stdio: "inherit",
178
- shell: true
668
+ stdio: "inherit"
669
+ });
670
+ child.on("error", reject);
671
+ child.on("close", (code) => {
672
+ if (code === 0)
673
+ resolve2(true);
674
+ else
675
+ reject(new Error(`Install failed with exit code ${code}`));
179
676
  });
677
+ });
678
+ }
679
+ async function installDependencies(template, targetDir) {
680
+ try {
681
+ await runSpawn(template, targetDir, "install");
180
682
  return true;
181
683
  } catch (error) {
182
684
  log.error(`Failed to install dependencies: ${error}`);
@@ -185,41 +687,44 @@ async function installDependencies(template, targetDir) {
185
687
  }
186
688
  async function initializeGit(targetDir) {
187
689
  try {
188
- spawn("git", ["init"], {
189
- cwd: targetDir,
190
- stdio: "inherit",
191
- shell: true
192
- });
690
+ await runSpawn("git", targetDir, "init");
193
691
  return true;
194
692
  } catch (error) {
195
693
  log.error(`Failed to initialize Git repository: ${error}`);
196
694
  return false;
197
695
  }
198
696
  }
697
+ async function getLatestVersion() {
698
+ const res = await fetch(`https://registry.npmjs.org/@scaffscript/core/latest`);
699
+ const data = await res.json();
700
+ return data.version;
701
+ }
199
702
 
200
703
  // src/index.ts
704
+ var COMPILER_VERSION = "0.1.3";
201
705
  async function main() {
202
706
  log.info("Initializing ScaffScript project...");
203
707
  const args = process.argv.slice(2);
204
708
  const input = await parseArgs(...args);
205
709
  if (!input)
206
- return null;
710
+ process.exit(1);
207
711
  const copied = await copyTemplate(`../templates/${input.template}`, input.targetPath);
712
+ const latestVersion = await getLatestVersion();
713
+ const pkg = (await readFile2(`${input.targetPath}/package.json`, "utf8")).replace("{LATEST_VERSION}", latestVersion).replace("{COMPILER_VERSION}", COMPILER_VERSION);
714
+ await writeFile2(`${input.targetPath}/package.json`, pkg);
208
715
  const installed = await installDependencies(input.template, input.targetPath);
209
716
  if (input.initGit) {
210
717
  const initGit = await initializeGit(input.targetPath);
211
718
  if (!initGit)
212
- return null;
719
+ process.exit(1);
213
720
  }
214
721
  if (input.projectName && input.ideVersion) {
215
722
  await copyGameMakerProject(input.targetPath, input.projectName, input.ideVersion);
216
723
  }
217
724
  if (!copied || !installed)
218
- return null;
219
- return input;
725
+ process.exit(1);
726
+ console.log("");
727
+ log.info("ScaffScript project initialized successfully.");
728
+ 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
729
  }
221
- var input = await main();
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.`);
730
+ 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.3",
4
+ "version": "0.1.5",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
7
7
  "type": "module",
@@ -31,5 +31,9 @@
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
@@ -1,26 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
  import { log } from "./utils";
3
3
  import { parseArgs } from "./args";
4
+ import { readFile, writeFile } from "node:fs/promises";
4
5
  import * as fs from "./fs";
5
- import { installDependencies, initializeGit } from "./init";
6
+ import { installDependencies, initializeGit, getLatestVersion } from "./init";
7
+
8
+ const COMPILER_VERSION = "0.1.3";
6
9
 
7
10
  async function main() {
8
11
  log.info("Initializing ScaffScript project...");
9
-
12
+
10
13
  const args = process.argv.slice(2);
11
14
  const input = await parseArgs(...args);
12
15
 
13
16
  if (!input)
14
- return null;
17
+ process.exit(1);
15
18
 
16
19
  const copied = await fs.copyTemplate(`../templates/${input.template}`, input.targetPath);
20
+
21
+ const latestVersion = await getLatestVersion();
22
+ const pkg = (await readFile(`${input.targetPath}/package.json`, "utf8"))
23
+ .replace("{LATEST_VERSION}", latestVersion)
24
+ .replace("{COMPILER_VERSION}", COMPILER_VERSION);
25
+ await writeFile(`${input.targetPath}/package.json`, pkg);
26
+
17
27
  const installed = await installDependencies(input.template, input.targetPath);
18
28
 
19
29
  if (input.initGit) {
20
30
  const initGit = await initializeGit(input.targetPath);
21
31
 
22
32
  if (!initGit)
23
- return null;
33
+ process.exit(1);
24
34
  }
25
35
 
26
36
  if (input.projectName && input.ideVersion) {
@@ -28,15 +38,11 @@ async function main() {
28
38
  }
29
39
 
30
40
  if (!copied || !installed)
31
- return null;
41
+ process.exit(1);
32
42
 
33
- return input;
43
+ console.log("");
44
+ log.info("ScaffScript project initialized successfully.");
45
+ 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
46
  }
35
47
 
36
- const input = await main();
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.`);
48
+ await main();
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "scaffscript-compiler",
3
- "version": "0.1.2",
3
+ "version": "{COMPILER_VERSION}",
4
4
  "description": "A ScaffScript compiler",
5
5
  "license": "MIT",
6
6
  "author": "Undervolta",
7
7
  "type": "module",
8
8
  "private": true,
9
9
  "devDependencies": {
10
- "@scaffscript/core": "^0.1.5",
10
+ "@scaffscript/core": "{LATEST_VERSION}",
11
11
  "@types/bun": "latest"
12
12
  },
13
13
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scaffscript-compiler",
3
- "version": "0.1.2",
3
+ "version": "{COMPILER_VERSION}",
4
4
  "description": "A ScaffScript compiler",
5
5
  "license": "MIT",
6
6
  "author": "Undervolta",
@@ -11,6 +11,6 @@
11
11
  "scaff": "scaff"
12
12
  },
13
13
  "devDependencies": {
14
- "@scaffscript/core": "^0.1.5"
14
+ "@scaffscript/core": "{LATEST_VERSION}"
15
15
  }
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scaffscript-compiler",
3
- "version": "0.1.2",
3
+ "version": "{COMPILER_VERSION}",
4
4
  "description": "A ScaffScript compiler",
5
5
  "license": "MIT",
6
6
  "author": "Undervolta",
@@ -11,6 +11,6 @@
11
11
  "scaff": "scaff"
12
12
  },
13
13
  "devDependencies": {
14
- "@scaffscript/core": "^0.1.5"
14
+ "@scaffscript/core": "{LATEST_VERSION}"
15
15
  }
16
16
  }