create-better-schemic 0.1.0-beta.5 → 0.1.0-beta.7

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.
Files changed (3) hide show
  1. package/lib/index.js +288 -303
  2. package/package.json +5 -6
  3. package/src/index.ts +186 -166
package/lib/index.js CHANGED
@@ -1,113 +1,15 @@
1
1
  #!/usr/bin/env node
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- if (mod && typeof mod === "object" || typeof mod === "function") {
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
- }
30
- if (canCache)
31
- cache.set(mod, to);
32
- return to;
33
- };
34
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
-
36
- // ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
37
- var require_src = __commonJS(function(exports, module) {
38
- var ESC = "\x1B";
39
- var CSI = `${ESC}[`;
40
- var beep = "\x07";
41
- var cursor = {
42
- to(x, y) {
43
- if (!y)
44
- return `${CSI}${x + 1}G`;
45
- return `${CSI}${y + 1};${x + 1}H`;
46
- },
47
- move(x, y) {
48
- let ret = "";
49
- if (x < 0)
50
- ret += `${CSI}${-x}D`;
51
- else if (x > 0)
52
- ret += `${CSI}${x}C`;
53
- if (y < 0)
54
- ret += `${CSI}${-y}A`;
55
- else if (y > 0)
56
- ret += `${CSI}${y}B`;
57
- return ret;
58
- },
59
- up: (count = 1) => `${CSI}${count}A`,
60
- down: (count = 1) => `${CSI}${count}B`,
61
- forward: (count = 1) => `${CSI}${count}C`,
62
- backward: (count = 1) => `${CSI}${count}D`,
63
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
64
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
65
- left: `${CSI}G`,
66
- hide: `${CSI}?25l`,
67
- show: `${CSI}?25h`,
68
- save: `${ESC}7`,
69
- restore: `${ESC}8`
70
- };
71
- var scroll = {
72
- up: (count = 1) => `${CSI}S`.repeat(count),
73
- down: (count = 1) => `${CSI}T`.repeat(count)
74
- };
75
- var erase = {
76
- screen: `${CSI}2J`,
77
- up: (count = 1) => `${CSI}1J`.repeat(count),
78
- down: (count = 1) => `${CSI}J`.repeat(count),
79
- line: `${CSI}2K`,
80
- lineEnd: `${CSI}K`,
81
- lineStart: `${CSI}1K`,
82
- lines(count) {
83
- let clear = "";
84
- for (let i = 0;i < count; i++)
85
- clear += this.line + (i < count - 1 ? cursor.up() : "");
86
- if (count)
87
- clear += cursor.left;
88
- return clear;
89
- }
90
- };
91
- module.exports = { cursor, scroll, erase, beep };
92
- });
93
-
94
2
  // src/index.ts
95
3
  import { spawnSync } from "node:child_process";
96
- import {
97
- existsSync,
98
- mkdirSync,
99
- readdirSync,
100
- readFileSync,
101
- writeFileSync
102
- } from "node:fs";
4
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
103
5
  import { createRequire } from "node:module";
104
- import { basename, dirname, join, resolve } from "node:path";
6
+ import nodePath from "node:path";
105
7
 
106
- // ../../node_modules/.bun/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
8
+ // ../../node_modules/.bun/@clack+core@1.6.0/node_modules/@clack/core/dist/index.mjs
107
9
  import { styleText } from "node:util";
108
10
  import { stdout, stdin } from "node:process";
109
- import * as l from "node:readline";
110
- import l__default from "node:readline";
11
+ import * as f$1 from "node:readline";
12
+ import f__default from "node:readline";
111
13
 
112
14
  // ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
113
15
  var getCodePointsLength = (() => {
@@ -450,14 +352,66 @@ function wrapAnsi(string, columns, options) {
450
352
  `);
451
353
  }
452
354
 
453
- // ../../node_modules/.bun/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
454
- var import_sisteransi = __toESM(require_src(), 1);
355
+ // ../../node_modules/.bun/sisteransi@2.0.0/node_modules/sisteransi/dist/index.js
356
+ var ESC2 = "\x1B";
357
+ var CSI2 = `${ESC2}[`;
358
+ var cursor = {
359
+ to(x, y) {
360
+ if (!y)
361
+ return `${CSI2}${x + 1}G`;
362
+ return `${CSI2}${y + 1};${x + 1}H`;
363
+ },
364
+ move(x, y) {
365
+ let ret = "";
366
+ if (x < 0)
367
+ ret += `${CSI2}${-x}D`;
368
+ else if (x > 0)
369
+ ret += `${CSI2}${x}C`;
370
+ if (y < 0)
371
+ ret += `${CSI2}${-y}A`;
372
+ else if (y > 0)
373
+ ret += `${CSI2}${y}B`;
374
+ return ret;
375
+ },
376
+ up: (count = 1) => `${CSI2}${count}A`,
377
+ down: (count = 1) => `${CSI2}${count}B`,
378
+ forward: (count = 1) => `${CSI2}${count}C`,
379
+ backward: (count = 1) => `${CSI2}${count}D`,
380
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
381
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
382
+ left: `${CSI2}G`,
383
+ hide: `${CSI2}?25l`,
384
+ show: `${CSI2}?25h`,
385
+ save: `${ESC2}7`,
386
+ restore: `${ESC2}8`
387
+ };
388
+ var erase = {
389
+ screen: `${CSI2}2J`,
390
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
391
+ down: (count = 1) => `${CSI2}J`.repeat(count),
392
+ line: `${CSI2}2K`,
393
+ lineEnd: `${CSI2}K`,
394
+ lineStart: `${CSI2}1K`,
395
+ lines(count) {
396
+ let clear = "";
397
+ for (let i = 0;i < count; i++)
398
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
399
+ if (count)
400
+ clear += cursor.left;
401
+ return clear;
402
+ }
403
+ };
404
+ var clear = {
405
+ screen: `${ESC2}c`
406
+ };
407
+
408
+ // ../../node_modules/.bun/@clack+core@1.6.0/node_modules/@clack/core/dist/index.mjs
455
409
  import { ReadStream } from "node:tty";
456
- function findCursor(s, o, l) {
410
+ function findCursor(o, s, l) {
457
411
  if (!l.some((r) => !r.disabled))
458
- return s;
459
- const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
460
- return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
412
+ return o;
413
+ const t = o + s, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
414
+ return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
461
415
  }
462
416
  var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
463
417
  var t = [
@@ -547,43 +501,43 @@ function block({
547
501
  overwrite: o = true,
548
502
  hideCursor: n = true
549
503
  } = {}) {
550
- const s = l.createInterface({
504
+ const s = f$1.createInterface({
551
505
  input: e,
552
506
  output: r,
553
507
  prompt: "",
554
508
  tabSize: 1
555
509
  });
556
- l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
557
- const t = (f, { name: a, sequence: w }) => {
558
- const c = String(f);
559
- if (isActionKey([c, a, w], "cancel")) {
560
- n && r.write(import_sisteransi.cursor.show), process.exit(0);
510
+ f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
511
+ const t = (l, { name: i, sequence: p }) => {
512
+ const w = String(l);
513
+ if (isActionKey([w, i, p], "cancel")) {
514
+ n && r.write(cursor.show), process.exit(0);
561
515
  return;
562
516
  }
563
517
  if (!o)
564
518
  return;
565
- const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
566
- l.moveCursor(r, i, m, () => {
567
- l.clearLine(r, 1, () => {
519
+ const c = i === "return" ? 0 : -1, a = i === "return" ? -1 : 0;
520
+ f$1.moveCursor(r, c, a, () => {
521
+ f$1.clearLine(r, 1, () => {
568
522
  e.once("keypress", t);
569
523
  });
570
524
  });
571
525
  };
572
- return n && r.write(import_sisteransi.cursor.hide), e.once("keypress", t), () => {
573
- e.off("keypress", t), n && r.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
526
+ return n && r.write(cursor.hide), e.once("keypress", t), () => {
527
+ e.off("keypress", t), n && r.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
574
528
  };
575
529
  }
576
530
  var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
577
531
  var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
578
532
  function wrapTextWithPrefix(e, r, o, n = o, s = o, t) {
579
- const f = getColumns(e ?? stdout);
580
- return wrapAnsi(r, f - o.length, {
533
+ const l = getColumns(e ?? stdout), i = dist_default2(o);
534
+ return wrapAnsi(r, l - i, {
581
535
  hard: true,
582
536
  trim: false
583
537
  }).split(`
584
- `).map((c, i, m) => {
585
- const d = t ? t(c, i) : c;
586
- return i === 0 ? `${n}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
538
+ `).map((c, a, g) => {
539
+ const m = t ? t(c, a) : c;
540
+ return a === 0 ? `${n}${m}` : a === g.length - 1 ? `${s}${m}` : `${o}${m}`;
587
541
  }).join(`
588
542
  `);
589
543
  }
@@ -594,8 +548,7 @@ function runValidation(e, a) {
594
548
  }
595
549
  return e(a);
596
550
  }
597
-
598
- class y {
551
+ var C$1 = class C {
599
552
  input;
600
553
  output;
601
554
  _abortSignal;
@@ -646,16 +599,16 @@ class y {
646
599
  this.state = "cancel", this.close();
647
600
  }, { once: true });
648
601
  }
649
- this.rl = l__default.createInterface({
602
+ this.rl = f__default.createInterface({
650
603
  input: this.input,
651
604
  tabSize: 2,
652
605
  prompt: "",
653
606
  escapeCodeTimeout: 50,
654
607
  terminal: true
655
608
  }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
656
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
609
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
657
610
  }), this.once("cancel", () => {
658
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
611
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
659
612
  });
660
613
  });
661
614
  }
@@ -692,18 +645,18 @@ class y {
692
645
  `), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
693
646
  }
694
647
  restoreCursor() {
695
- const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
648
+ const t = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
696
649
  `).length - 1;
697
- this.output.write(import_sisteransi.cursor.move(-999, t * -1));
650
+ this.output.write(cursor.move(-999, t * -1));
698
651
  }
699
652
  render() {
700
- const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
653
+ const t = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
701
654
  hard: true,
702
655
  trim: false
703
656
  });
704
657
  if (t !== this._prevFrame) {
705
658
  if (this.state === "initial")
706
- this.output.write(import_sisteransi.cursor.hide);
659
+ this.output.write(cursor.hide);
707
660
  else {
708
661
  const e = diffLines(this._prevFrame, t), i = getRows(this.output);
709
662
  if (this.restoreCursor(), e) {
@@ -714,33 +667,33 @@ class y {
714
667
  return;
715
668
  }
716
669
  if (e.lines.length === 1) {
717
- this.output.write(import_sisteransi.cursor.move(0, n - r)), this.output.write(import_sisteransi.erase.lines(1));
670
+ this.output.write(cursor.move(0, n - r)), this.output.write(erase.lines(1));
718
671
  const o = t.split(`
719
672
  `);
720
- this.output.write(o[n]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, o.length - n - 1));
673
+ this.output.write(o[n]), this._prevFrame = t, this.output.write(cursor.move(0, o.length - n - 1));
721
674
  return;
722
675
  } else if (e.lines.length > 1) {
723
676
  if (s < r)
724
677
  n = s;
725
678
  else {
726
679
  const h = n - r;
727
- h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
680
+ h > 0 && this.output.write(cursor.move(0, h));
728
681
  }
729
- this.output.write(import_sisteransi.erase.down());
730
- const f = t.split(`
682
+ this.output.write(erase.down());
683
+ const m = t.split(`
731
684
  `).slice(n);
732
- this.output.write(f.join(`
685
+ this.output.write(m.join(`
733
686
  `)), this._prevFrame = t;
734
687
  return;
735
688
  }
736
689
  }
737
- this.output.write(import_sisteransi.erase.down());
690
+ this.output.write(erase.down());
738
691
  }
739
692
  this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
740
693
  }
741
694
  }
742
- }
743
- class r extends y {
695
+ };
696
+ class r extends C$1 {
744
697
  get cursor() {
745
698
  return this.value ? 0 : 1;
746
699
  }
@@ -751,13 +704,13 @@ class r extends y {
751
704
  super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
752
705
  this.value = this._value;
753
706
  }), this.on("confirm", (i) => {
754
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
707
+ this.output.write(cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
755
708
  }), this.on("cursor", () => {
756
709
  this.value = !this.value;
757
710
  });
758
711
  }
759
712
  }
760
- var n$1 = class n extends y {
713
+ var n$1 = class n extends C$1 {
761
714
  options;
762
715
  cursor = 0;
763
716
  get _selectedValue() {
@@ -785,7 +738,7 @@ var n$1 = class n extends y {
785
738
  });
786
739
  }
787
740
  };
788
- class n extends y {
741
+ class n extends C$1 {
789
742
  get userInputWithCursor() {
790
743
  if (this.state === "submit")
791
744
  return this.userInput;
@@ -810,10 +763,9 @@ class n extends y {
810
763
  }
811
764
  }
812
765
 
813
- // ../../node_modules/.bun/@clack+prompts@1.8.1/node_modules/@clack/prompts/dist/index.mjs
766
+ // ../../node_modules/.bun/@clack+prompts@1.9.0/node_modules/@clack/prompts/dist/index.mjs
814
767
  import { styleText as styleText2, stripVTControlCharacters } from "node:util";
815
768
  import process$1 from "node:process";
816
- var import_sisteransi2 = __toESM(require_src(), 1);
817
769
  function isUnicodeSupported() {
818
770
  if (process$1.platform !== "win32") {
819
771
  return process$1.env.TERM !== "linux";
@@ -822,7 +774,7 @@ function isUnicodeSupported() {
822
774
  }
823
775
  var unicode = isUnicodeSupported();
824
776
  var isCI = () => process.env.CI === "true";
825
- var unicodeOr = (o, e) => unicode ? o : e;
777
+ var unicodeOr = (e, o) => unicode ? e : o;
826
778
  var S_STEP_ACTIVE = unicodeOr("◆", "*");
827
779
  var S_STEP_CANCEL = unicodeOr("■", "x");
828
780
  var S_STEP_ERROR = unicodeOr("▲", "x");
@@ -848,8 +800,8 @@ var S_INFO = unicodeOr("●", "•");
848
800
  var S_SUCCESS = unicodeOr("◆", "*");
849
801
  var S_WARN = unicodeOr("▲", "!");
850
802
  var S_ERROR = unicodeOr("■", "x");
851
- var symbol = (o) => {
852
- switch (o) {
803
+ var symbol = (e) => {
804
+ switch (e) {
853
805
  case "initial":
854
806
  case "active":
855
807
  return styleText2("cyan", S_STEP_ACTIVE);
@@ -863,8 +815,8 @@ var symbol = (o) => {
863
815
  return styleText2("dim", S_STEP_ACTIVE);
864
816
  }
865
817
  };
866
- var symbolBar = (o) => {
867
- switch (o) {
818
+ var symbolBar = (e) => {
819
+ switch (e) {
868
820
  case "initial":
869
821
  case "active":
870
822
  return styleText2("cyan", S_BAR);
@@ -876,11 +828,12 @@ var symbolBar = (o) => {
876
828
  return styleText2("green", S_BAR);
877
829
  }
878
830
  };
879
- function formatInstructionFooter(o, e) {
880
- const r = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" • ")}`];
881
- return e && r.push(styleText2("cyan", S_BAR_END)), r;
831
+ function formatInstructionFooter(e, o, r) {
832
+ const s = r ? `${styleText2("cyan", S_BAR)} ` : "", n = wrapTextWithPrefix(e, o.join(" • "), s).split(`
833
+ `);
834
+ return r && n.push(styleText2("cyan", S_BAR_END)), n;
882
835
  }
883
- var I = (l, e, w, p, b, C = false) => {
836
+ var E$1 = (l, e, w, p, b, C = false) => {
884
837
  let r = e, O = 0;
885
838
  if (C)
886
839
  for (let i = p - 1;i >= w; i--) {
@@ -909,12 +862,12 @@ var limitOptions = ({
909
862
  let f = 0;
910
863
  l >= a - 3 && (f = Math.max(Math.min(l - a + 3, e.length - a), 0));
911
864
  let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
912
- const W = Math.min(f + a, e.length), s = [];
865
+ const I = Math.min(f + a, e.length), s = [];
913
866
  let g = 0;
914
867
  d && g++, c && g++;
915
- const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
916
- for (let t = T;t < y; t++) {
917
- const n = e[t], o = n ? w(n, t === l) : "", h = wrapAnsi(o, i, {
868
+ const T = f + (d ? 1 : 0), W = I - (c ? 1 : 0);
869
+ for (let t = T;t < W; t++) {
870
+ const n = e[t], o = n !== undefined ? w(n, t === l) : "", h = wrapAnsi(o, i, {
918
871
  hard: true,
919
872
  trim: false
920
873
  }).split(`
@@ -925,8 +878,8 @@ var limitOptions = ({
925
878
  let t = 0, n = 0, o = g;
926
879
  const h = l - T;
927
880
  let u = v;
928
- const L = () => I(s, o, 0, h, u), E = () => I(s, o, h + 1, s.length, u, true);
929
- d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } = E())) : (c || (u -= 1), { lineCount: o, removals: n } = E(), o > u && (u -= 1, { lineCount: o, removals: t } = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
881
+ const L = () => E$1(s, o, 0, h, u), y = () => E$1(s, o, h + 1, s.length, u, true);
882
+ d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } = y())) : (c || (u -= 1), { lineCount: o, removals: n } = y(), o > u && (u -= 1, { lineCount: o, removals: t } = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
930
883
  }
931
884
  const x = [];
932
885
  d && x.push(M);
@@ -1035,7 +988,7 @@ ${styleText2("gray", S_BAR_END)} ` : "";
1035
988
 
1036
989
  `);
1037
990
  };
1038
- var W$1 = (o) => o;
991
+ var W = (o) => o;
1039
992
  var C = (o, e, s) => {
1040
993
  const a = {
1041
994
  hard: true,
@@ -1045,7 +998,7 @@ var C = (o, e, s) => {
1045
998
  return wrapAnsi(o, g, a);
1046
999
  };
1047
1000
  var note = (o = "", e = "", s) => {
1048
- const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = ["", ...C(o, getColumns(a) - 6, c).split(`
1001
+ const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W, g = ["", ...C(o, getColumns(a) - 6, c).split(`
1049
1002
  `).map(c), ""], n = dist_default2(e), t = Math.max(g.reduce((m, F) => {
1050
1003
  const O = dist_default2(F);
1051
1004
  return O > m ? O : m;
@@ -1057,85 +1010,103 @@ ${h}
1057
1010
  ${styleText2("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
1058
1011
  `);
1059
1012
  };
1060
- var W = (l) => styleText2("magenta", l);
1013
+ var Y = 30000;
1014
+ var Z = (c) => styleText2("magenta", c);
1061
1015
  var spinner = ({
1062
- indicator: l = "dots",
1063
- onCancel: h,
1016
+ indicator: c = "dots",
1017
+ onCancel: b,
1064
1018
  output: n = process.stdout,
1065
- cancelMessage: G,
1066
- errorMessage: O,
1067
- frames: E = unicode ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"],
1068
- delay: F = unicode ? 80 : 120,
1069
- signal: m,
1070
- ...I
1019
+ cancelMessage: _,
1020
+ errorMessage: C,
1021
+ frames: M = unicode ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"],
1022
+ delay: O = unicode ? 80 : 120,
1023
+ signal: g,
1024
+ ...E
1071
1025
  } = {}) => {
1072
- const u = isCI();
1073
- let M, T, d = false, S = false, s = "", p, w = performance.now();
1074
- const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
1075
- const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
1076
- S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
1077
- }, f = () => g(2), i = () => g(1), A = () => {
1078
- process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
1079
- }, H = () => {
1080
- process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
1081
- }, y = () => {
1082
- if (p === undefined)
1026
+ const u = isCI(), h = isAccessible(E.accessible);
1027
+ let x, I, p = false, l = false, r = "", v, w = performance.now();
1028
+ const y = getColumns(n), F = E?.styleFrame ?? Z, S = (e) => {
1029
+ const s = e > 1 ? C ?? settings.messages.error : _ ?? settings.messages.cancel;
1030
+ l = e === 1, p && (m(s, e), l && typeof b == "function" && b());
1031
+ }, $ = () => S(2), a = () => S(1), H = () => {
1032
+ process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a), process.on("SIGTERM", a), process.on("exit", S), g && g.addEventListener("abort", a);
1033
+ }, B = () => {
1034
+ process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a), process.removeListener("SIGTERM", a), process.removeListener("exit", S), g && g.removeEventListener("abort", a);
1035
+ }, R = () => {
1036
+ if (v === undefined)
1083
1037
  return;
1084
1038
  u && n.write(`
1085
1039
  `);
1086
- const r = wrapAnsi(p, x, {
1040
+ const s = wrapAnsi(v, y, {
1087
1041
  hard: true,
1088
1042
  trim: false
1089
1043
  }).split(`
1090
1044
  `);
1091
- r.length > 1 && n.write(import_sisteransi2.cursor.up(r.length - 1)), n.write(import_sisteransi2.cursor.to(0)), n.write(import_sisteransi2.erase.down());
1092
- }, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
1093
- const r = (performance.now() - e) / 1000, t = Math.floor(r / 60), o = Math.floor(r % 60);
1094
- return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
1095
- }, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
1096
- d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText2("gray", S_BAR)}
1045
+ s.length > 1 && n.write(cursor.up(s.length - 1)), n.write(cursor.to(0)), n.write(erase.down());
1046
+ }, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
1047
+ const s = (performance.now() - e) / 1000, i = Math.floor(s / 60), t = Math.floor(s % 60);
1048
+ return i > 0 ? `[${i}m ${t}s]` : `[${t}s]`;
1049
+ }, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
1050
+ if (p = true, l = false, r = L(e), w = performance.now(), H(), h) {
1051
+ r !== "" && n.write(`${r}
1052
+ `), I = setInterval(() => {
1053
+ n.write(r === "" ? `still working
1054
+ ` : `still working: ${r}
1097
1055
  `);
1098
- let r = 0, t = 0;
1099
- A(), T = setInterval(() => {
1100
- if (u && s === p)
1056
+ }, Y);
1057
+ return;
1058
+ }
1059
+ x = block({ output: n }), N && n.write(`${styleText2("gray", S_BAR)}
1060
+ `);
1061
+ let s = 0, i = 0;
1062
+ I = setInterval(() => {
1063
+ if (u && r === v)
1101
1064
  return;
1102
- y(), p = s;
1103
- const o = k(E[r]);
1104
- let v;
1065
+ R(), v = r;
1066
+ const t = F(M[s]);
1067
+ let o;
1105
1068
  if (u)
1106
- v = `${o} ${s}...`;
1107
- else if (l === "timer")
1108
- v = `${o} ${s} ${_(w)}`;
1069
+ o = `${t} ${r}...`;
1070
+ else if (c === "timer")
1071
+ o = `${t} ${r} ${T(w)}`;
1109
1072
  else {
1110
- const B = ".".repeat(Math.floor(t)).slice(0, 3);
1111
- v = `${o} ${s}${B}`;
1073
+ const j = ".".repeat(Math.floor(i)).slice(0, 3);
1074
+ o = `${t} ${r}${j}`;
1112
1075
  }
1113
- const j = wrapAnsi(v, x, {
1076
+ const D = wrapAnsi(o, y, {
1114
1077
  hard: true,
1115
1078
  trim: false
1116
1079
  });
1117
- n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + 0.125 : 0;
1118
- }, F);
1119
- }, a = (e = "", r = 0, t = false) => {
1120
- if (!d)
1121
- return;
1122
- d = false, clearInterval(T), y();
1123
- const o = r === 0 ? styleText2("green", S_STEP_SUBMIT) : r === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
1124
- s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
1125
- `) : n.write(`${o} ${s}
1126
- `)), H(), M();
1080
+ n.write(D), s = s + 1 < M.length ? s + 1 : 0, i = i < 4 ? i + 0.125 : 0;
1081
+ }, O);
1082
+ }, m = (e = "", s = 0, i = false) => {
1083
+ if (p) {
1084
+ if (p = false, l = s === 1, clearInterval(I), h || R(), r = e ?? r, !i)
1085
+ if (h) {
1086
+ const t = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C ?? settings.messages.error : "Done", o = r || t;
1087
+ c === "timer" ? n.write(`${o} ${T(w)}
1088
+ `) : n.write(`${o}
1089
+ `);
1090
+ } else {
1091
+ const t = s === 0 ? styleText2("green", S_STEP_SUBMIT) : s === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
1092
+ c === "timer" ? n.write(`${t} ${r} ${T(w)}
1093
+ `) : n.write(`${t} ${r}
1094
+ `);
1095
+ }
1096
+ B(), x?.();
1097
+ }
1127
1098
  };
1128
1099
  return {
1129
1100
  start: P,
1130
- stop: (e = "") => a(e, 0),
1101
+ stop: (e = "") => m(e, 0),
1131
1102
  message: (e = "") => {
1132
- s = C(e ?? s);
1103
+ r = L(e ?? r);
1133
1104
  },
1134
- cancel: (e = "") => a(e, 1),
1135
- error: (e = "") => a(e, 2),
1136
- clear: () => a("", 0, true),
1105
+ cancel: (e = "") => m(e, 1),
1106
+ error: (e = "") => m(e, 2),
1107
+ clear: () => m("", 0, true),
1137
1108
  get isCancelled() {
1138
- return S;
1109
+ return l;
1139
1110
  }
1140
1111
  };
1141
1112
  };
@@ -1148,7 +1119,7 @@ var SELECT_INSTRUCTIONS = [
1148
1119
  `${styleText2("dim", "↑/↓")} to navigate`,
1149
1120
  `${styleText2("dim", "Enter:")} confirm`
1150
1121
  ];
1151
- var c = (t, o) => t.includes(`
1122
+ var c2 = (t, o) => t.includes(`
1152
1123
  `) ? t.split(`
1153
1124
  `).map((d) => o(d)).join(`
1154
1125
  `) : o(t);
@@ -1159,15 +1130,15 @@ var select = (t) => {
1159
1130
  const s = n.label ?? String(n.value);
1160
1131
  switch (m) {
1161
1132
  case "disabled":
1162
- return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (i) => styleText2("gray", i))}${n.hint ? ` ${styleText2("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
1133
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (i) => styleText2("gray", i))}${n.hint ? ` ${styleText2("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
1163
1134
  case "selected":
1164
- return `${c(s, (i) => styleText2("dim", i))}`;
1135
+ return `${c2(s, (i) => styleText2("dim", i))}`;
1165
1136
  case "active":
1166
1137
  return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${styleText2("dim", `(${n.hint})`)}` : ""}`;
1167
1138
  case "cancelled":
1168
- return `${c(s, (i) => styleText2(["strikethrough", "dim"], i))}`;
1139
+ return `${c2(s, (i) => styleText2(["strikethrough", "dim"], i))}`;
1169
1140
  default:
1170
- return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (i) => styleText2("dim", i))}`;
1141
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (i) => styleText2("dim", i))}`;
1171
1142
  }
1172
1143
  }, d = t.showInstructions ?? true;
1173
1144
  return new n$1({
@@ -1192,7 +1163,7 @@ ${styleText2("gray", S_BAR)}` : ""}`;
1192
1163
  }
1193
1164
  default: {
1194
1165
  const r = n ? `${styleText2("cyan", S_BAR)} ` : "", a = u.split(`
1195
- `).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n) : n ? [styleText2("cyan", S_BAR_END)] : [], f = p.join(`
1166
+ `).length, p = d ? formatInstructionFooter(t.output, SELECT_INSTRUCTIONS, n) : n ? [styleText2("cyan", S_BAR_END)] : [], f = p.join(`
1196
1167
  `), b = p.length + 1;
1197
1168
  return `${u}${r}${limitOptions({
1198
1169
  output: t.output,
@@ -1257,40 +1228,52 @@ ${i}
1257
1228
  }
1258
1229
  }).prompt();
1259
1230
  // package.json
1260
- var version = "0.1.0-beta.5";
1231
+ var version = "0.1.0-beta.7";
1261
1232
 
1262
1233
  // src/index.ts
1263
1234
  var RANGE = `^${version}`;
1235
+ var JSON_INDENT = 2;
1236
+ var ARGV_START = 2;
1237
+ var INSTALL_ERROR_TAIL = 8;
1238
+ var ARG_STEP = 2;
1264
1239
  var bold = (s) => `\x1B[1m${s}\x1B[0m`;
1265
1240
  var dim = (s) => `\x1B[2m${s}\x1B[0m`;
1241
+ var exitProcess = process.exit.bind(process);
1242
+ var exit = (code) => Reflect.apply(exitProcess, undefined, [code]);
1266
1243
  var PMS = ["bun", "npm", "pnpm", "yarn"];
1267
1244
  function parseArgs(argv) {
1268
1245
  const o = { git: true, yes: false };
1269
- for (let i = 0;i < argv.length; i++) {
1270
- const a = argv[i];
1246
+ const consume = (index) => {
1247
+ if (index >= argv.length)
1248
+ return;
1249
+ const a = argv[index];
1271
1250
  if (a === "-y" || a === "--yes")
1272
1251
  o.yes = true;
1273
1252
  else if (a === "--no-install")
1274
1253
  o.install = false;
1275
1254
  else if (a === "--no-git")
1276
1255
  o.git = false;
1277
- else if (a === "--pm")
1278
- o.pm = argv[++i];
1279
- else if (a === "-h" || a === "--help") {
1256
+ else if (a === "--pm") {
1257
+ o.pm = argv[index + 1];
1258
+ consume(index + ARG_STEP);
1259
+ return;
1260
+ } else if (a === "-h" || a === "--help") {
1280
1261
  printHelp();
1281
- process.exit(0);
1262
+ exit(0);
1282
1263
  } else if (a.startsWith("-"))
1283
1264
  unknownOption(a);
1284
- else if (o.dir === undefined)
1285
- o.dir = a;
1286
- }
1265
+ else
1266
+ o.dir ??= a;
1267
+ consume(index + 1);
1268
+ };
1269
+ consume(0);
1287
1270
  return o;
1288
1271
  }
1289
1272
  function unknownOption(option) {
1290
1273
  console.error(`Unknown option: ${option}
1291
1274
  `);
1292
1275
  printHelp();
1293
- process.exit(1);
1276
+ exit(1);
1294
1277
  }
1295
1278
  function printHelp() {
1296
1279
  console.log(`create-better-schemic — scaffold a new Better-schemic project
@@ -1304,17 +1287,15 @@ Options:
1304
1287
  -y, --yes accept defaults, no prompts
1305
1288
  -h, --help show this help`);
1306
1289
  }
1290
+ var text2 = (value) => typeof value === "string" ? value : "";
1307
1291
  function detectPm() {
1308
1292
  const ua = process.env.npm_config_user_agent ?? "";
1309
- for (const pm of PMS)
1310
- if (ua.startsWith(pm))
1311
- return pm;
1312
- return "npm";
1293
+ return PMS.find((pm) => ua.startsWith(pm)) ?? "npm";
1313
1294
  }
1314
1295
  function abortIfCancel(value) {
1315
1296
  if (isCancel(value)) {
1316
1297
  cancel("Cancelled.");
1317
- process.exit(1);
1298
+ exit(1);
1318
1299
  }
1319
1300
  return value;
1320
1301
  }
@@ -1326,56 +1307,58 @@ function depMap() {
1326
1307
  }
1327
1308
  var TSCONFIG = `${JSON.stringify({
1328
1309
  compilerOptions: {
1329
- target: "ESNext",
1310
+ lib: ["ESNext"],
1330
1311
  module: "ESNext",
1331
- moduleResolution: "bundler",
1332
1312
  moduleDetection: "force",
1333
- strict: true,
1334
- skipLibCheck: true,
1335
- resolveJsonModule: true,
1313
+ moduleResolution: "bundler",
1336
1314
  noEmit: true,
1337
- lib: ["ESNext"],
1315
+ resolveJsonModule: true,
1316
+ skipLibCheck: true,
1317
+ strict: true,
1318
+ target: "ESNext",
1338
1319
  types: ["node"]
1339
1320
  },
1340
1321
  exclude: ["node_modules"]
1341
- }, null, 2)}
1322
+ }, null, JSON_INDENT)}
1342
1323
  `;
1343
1324
  function applyPackageJson(target, name) {
1344
- const path = join(target, "package.json");
1325
+ const path = nodePath.join(target, "package.json");
1345
1326
  const deps = depMap();
1346
1327
  if (!existsSync(path)) {
1347
1328
  const fresh = {
1329
+ dependencies: Object.fromEntries(Object.entries(deps).sort()),
1330
+ devDependencies: { "@types/node": "^20", typescript: "^5" },
1348
1331
  name,
1349
- version: "0.0.0",
1350
1332
  private: true,
1351
- type: "module",
1352
1333
  scripts: SCRIPTS,
1353
- dependencies: Object.fromEntries(Object.entries(deps).sort()),
1354
- devDependencies: { "@types/node": "^20", typescript: "^5" }
1334
+ type: "module",
1335
+ version: "0.0.0"
1355
1336
  };
1356
- writeFileSync(path, `${JSON.stringify(fresh, null, 2)}
1337
+ writeFileSync(path, `${JSON.stringify(fresh, null, JSON_INDENT)}
1357
1338
  `);
1358
1339
  return "+ package.json";
1359
1340
  }
1360
1341
  const pkg = JSON.parse(readFileSync(path, "utf8"));
1361
- pkg.dependencies ??= {};
1342
+ const dependencies = pkg.dependencies ??= {};
1362
1343
  const added = [];
1363
- for (const [k, v] of Object.entries(deps))
1364
- if (!(k in pkg.dependencies)) {
1365
- pkg.dependencies[k] = v;
1344
+ Object.entries(deps).forEach(([k, v]) => {
1345
+ if (!(k in dependencies)) {
1346
+ dependencies[k] = v;
1366
1347
  added.push(k);
1367
1348
  }
1368
- pkg.dependencies = Object.fromEntries(Object.entries(pkg.dependencies).sort());
1369
- pkg.scripts ??= {};
1370
- for (const [k, v] of Object.entries(SCRIPTS))
1371
- if (!(k in pkg.scripts))
1372
- pkg.scripts[k] = v;
1373
- writeFileSync(path, `${JSON.stringify(pkg, null, 2)}
1349
+ });
1350
+ pkg.dependencies = Object.fromEntries(Object.entries(dependencies).sort());
1351
+ const scripts = pkg.scripts ??= {};
1352
+ Object.entries(SCRIPTS).forEach(([k, v]) => {
1353
+ if (!(k in scripts))
1354
+ scripts[k] = v;
1355
+ });
1356
+ writeFileSync(path, `${JSON.stringify(pkg, null, JSON_INDENT)}
1374
1357
  `);
1375
- return added.length ? `~ package.json (added ${added.join(", ")})` : dim("· package.json (deps already present)");
1358
+ return added.length > 0 ? `~ package.json (added ${added.join(", ")})` : dim("· package.json (deps already present)");
1376
1359
  }
1377
1360
  function applyTsconfig(target) {
1378
- const path = join(target, "tsconfig.json");
1361
+ const path = nodePath.join(target, "tsconfig.json");
1379
1362
  if (!existsSync(path)) {
1380
1363
  writeFileSync(path, TSCONFIG);
1381
1364
  return "+ tsconfig.json";
@@ -1388,7 +1371,7 @@ var GITIGNORE = `node_modules/
1388
1371
  .DS_Store
1389
1372
  `;
1390
1373
  function writeIfAbsent(dir, file, content) {
1391
- const path = join(dir, file);
1374
+ const path = nodePath.join(dir, file);
1392
1375
  if (existsSync(path))
1393
1376
  return dim(`· ${file} (exists, skipped)`);
1394
1377
  writeFileSync(path, content);
@@ -1397,68 +1380,68 @@ function writeIfAbsent(dir, file, content) {
1397
1380
  function run(cmd, args, cwd, capture = false) {
1398
1381
  const r = spawnSync(cmd, args, {
1399
1382
  cwd,
1400
- stdio: capture ? "pipe" : "inherit",
1401
- encoding: "utf8"
1383
+ encoding: "utf8",
1384
+ stdio: capture ? "pipe" : "inherit"
1402
1385
  });
1403
- return { ok: r.status === 0, out: `${r.stdout ?? ""}${r.stderr ?? ""}` };
1386
+ return { ok: r.status === 0, out: `${text2(r.stdout)}${text2(r.stderr)}` };
1404
1387
  }
1405
1388
  function resolveCliEntry(target) {
1406
- const require2 = createRequire(join(target, "package.json"));
1389
+ const require2 = createRequire(nodePath.join(target, "package.json"));
1407
1390
  const manifestPath = require2.resolve("better-schemic/package.json");
1408
1391
  const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
1409
1392
  const bin = manifest.bin;
1410
1393
  const rel = typeof bin === "string" ? bin : bin?.["better-schemic"];
1411
- if (!rel)
1394
+ if (!rel) {
1412
1395
  throw new Error("the installed `better-schemic` package exposes no `better-schemic` bin — reinstall it.");
1413
- return join(dirname(manifestPath), rel);
1396
+ }
1397
+ return nodePath.join(nodePath.dirname(manifestPath), rel);
1414
1398
  }
1415
1399
  async function main() {
1416
- const opts = parseArgs(process.argv.slice(2));
1417
- const tty = !!process.stdin.isTTY && !opts.yes;
1400
+ const opts = parseArgs(process.argv.slice(ARGV_START));
1401
+ const tty = process.stdin.isTTY && !opts.yes;
1418
1402
  intro(bold("create-better-schemic"));
1419
1403
  let dir = opts.dir;
1420
1404
  if (!dir && tty) {
1421
1405
  dir = abortIfCancel(await text({
1406
+ defaultValue: "better-schemic-app",
1422
1407
  message: "Project directory",
1423
- placeholder: "better-schemic-app",
1424
- defaultValue: "better-schemic-app"
1408
+ placeholder: "better-schemic-app"
1425
1409
  }));
1426
1410
  }
1427
- dir ||= "better-schemic-app";
1428
- const target = resolve(process.cwd(), dir);
1429
- const name = basename(target);
1411
+ dir = dir && dir.length > 0 ? dir : "better-schemic-app";
1412
+ const target = nodePath.resolve(process.cwd(), dir);
1413
+ const name = nodePath.basename(target);
1430
1414
  mkdirSync(target, { recursive: true });
1431
- const isExisting = existsSync(join(target, "package.json"));
1432
- if (readdirSync(target).length && !isExisting && tty) {
1415
+ const isExisting = existsSync(nodePath.join(target, "package.json"));
1416
+ if (readdirSync(target).length > 0 && !isExisting && tty) {
1433
1417
  const ok = abortIfCancel(await confirm({
1434
- message: `${bold(dir)} is not empty — continue?`,
1435
- initialValue: false
1418
+ initialValue: false,
1419
+ message: `${bold(dir)} is not empty — continue?`
1436
1420
  }));
1437
1421
  if (!ok) {
1438
1422
  cancel("Aborted.");
1439
- process.exit(1);
1423
+ exit(1);
1440
1424
  }
1441
1425
  }
1442
1426
  const detected = detectPm();
1443
1427
  let install = opts.install;
1444
- if (install === undefined)
1445
- install = tty ? abortIfCancel(await confirm({
1446
- message: "Install dependencies now?",
1447
- initialValue: true
1448
- })) : true;
1428
+ install ??= tty ? abortIfCancel(await confirm({
1429
+ initialValue: true,
1430
+ message: "Install dependencies now?"
1431
+ })) : true;
1449
1432
  let pm = opts.pm ?? detected;
1450
1433
  if (!PMS.includes(pm)) {
1451
1434
  cancel(`Unknown package manager "${pm}". Known: ${PMS.join(", ")}.`);
1452
- process.exit(1);
1435
+ exit(1);
1453
1436
  }
1454
1437
  if (install && !opts.pm && tty) {
1455
1438
  pm = abortIfCancel(await select({
1439
+ initialValue: detected,
1456
1440
  message: "Install with which package manager?",
1457
1441
  options: [detected, ...PMS.filter((x) => x !== detected)].map((m) => ({
1458
- value: m,
1459
- label: m === detected ? `${m} (detected)` : m
1460
- })),
1461
- initialValue: detected
1442
+ label: m === detected ? `${m} (detected)` : m,
1443
+ value: m
1444
+ }))
1462
1445
  }));
1463
1446
  }
1464
1447
  const written = [
@@ -1470,7 +1453,7 @@ async function main() {
1470
1453
  log.step(`${bold(header)} ${dim("(SurrealDB)")}
1471
1454
  ${written.join(`
1472
1455
  `)}`);
1473
- if (opts.git && !existsSync(join(target, ".git")))
1456
+ if (opts.git && !existsSync(nodePath.join(target, ".git")))
1474
1457
  run("git", ["init", "-q"], target);
1475
1458
  if (install) {
1476
1459
  const s = spinner();
@@ -1479,10 +1462,10 @@ ${written.join(`
1479
1462
  if (!r.ok) {
1480
1463
  s.stop(`${pm} install failed`);
1481
1464
  log.error(r.out.trim().split(`
1482
- `).slice(-8).join(`
1465
+ `).slice(-INSTALL_ERROR_TAIL).join(`
1483
1466
  `));
1484
1467
  outro(`Fix the install, then run ${bold("better-schemic init")}.`);
1485
- process.exit(1);
1468
+ exit(1);
1486
1469
  }
1487
1470
  s.stop("Dependencies installed");
1488
1471
  log.step("Scaffolding the schema");
@@ -1502,7 +1485,9 @@ ${dbCmd("gen")}`;
1502
1485
  note(steps, "Next steps");
1503
1486
  outro(`${bold(name)} is ready.`);
1504
1487
  }
1505
- main().catch((e) => {
1506
- log.error(e instanceof Error ? e.message : String(e));
1507
- process.exit(1);
1508
- });
1488
+ try {
1489
+ await main();
1490
+ } catch (error) {
1491
+ log.error(error instanceof Error ? error.message : String(error));
1492
+ exit(1);
1493
+ }