toiljs 0.0.16 → 0.0.20
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/CHANGELOG.md +128 -0
- package/README.md +313 -128
- package/as-pect.config.js +1 -1
- package/build/backend/.tsbuildinfo +1 -1
- package/build/backend/index.d.ts +1 -0
- package/build/backend/index.js +20 -1
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/index.js +1320 -697
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/dev/devtools.js +42 -5
- package/build/client/errors.d.ts +1 -0
- package/build/client/errors.js +3 -0
- package/build/client/index.d.ts +2 -0
- package/build/client/index.js +2 -0
- package/build/client/rpc.d.ts +1 -0
- package/build/client/rpc.js +37 -0
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/config.js +3 -1
- package/build/compiler/docs.js +69 -7
- package/build/compiler/generate.js +5 -4
- package/build/compiler/index.d.ts +1 -0
- package/build/compiler/index.js +30 -1
- package/build/compiler/plugin.js +80 -8
- package/build/compiler/seo.js +15 -1
- package/build/compiler/ssg.js +7 -1
- package/build/compiler/vite.js +25 -0
- package/build/io/.tsbuildinfo +1 -1
- package/build/io/codec.d.ts +54 -0
- package/build/io/codec.js +143 -0
- package/build/io/index.d.ts +1 -2
- package/build/io/index.js +1 -2
- package/eslint.config.js +1 -1
- package/examples/basic/client/routes/features/index.tsx +1 -1
- package/examples/basic/client/routes/io.tsx +6 -7
- package/examples/basic/client/routes/rest.tsx +84 -0
- package/examples/basic/client/routes/rpc.tsx +43 -0
- package/package.json +19 -7
- package/presets/prettier-plugin.js +51 -0
- package/presets/prettier.json +1 -0
- package/server/runtime/README.md +97 -0
- package/server/runtime/abort/abort.ts +27 -0
- package/server/runtime/env/Server.ts +61 -0
- package/server/runtime/envelope.ts +191 -0
- package/server/runtime/exports/index.ts +52 -0
- package/server/runtime/handlers/ToilHandler.ts +34 -0
- package/server/runtime/index.ts +26 -0
- package/server/runtime/lang/Potential.ts +5 -0
- package/server/runtime/memory.ts +81 -0
- package/server/runtime/request.ts +55 -0
- package/server/runtime/response.ts +86 -0
- package/server/runtime/rest/Rest.ts +39 -0
- package/server/runtime/rest/RestHandler.ts +20 -0
- package/server/runtime/rest/RouteContext.ts +82 -0
- package/server/runtime/rest/match.ts +48 -0
- package/server/runtime/tsconfig.json +7 -0
- package/src/backend/index.ts +45 -3
- package/src/cli/create.ts +16 -6
- package/src/cli/diagnostics.ts +81 -0
- package/src/cli/doctor.ts +384 -7
- package/src/cli/index.ts +11 -2
- package/src/client/dev/devtools.tsx +49 -4
- package/src/client/errors.ts +11 -0
- package/src/client/index.ts +2 -0
- package/src/client/rpc.ts +64 -0
- package/src/compiler/config.ts +3 -1
- package/src/compiler/docs.ts +69 -7
- package/src/compiler/generate.ts +6 -5
- package/src/compiler/index.ts +50 -1
- package/src/compiler/plugin.ts +99 -11
- package/src/compiler/seo.ts +23 -3
- package/src/compiler/ssg.ts +10 -1
- package/src/compiler/vite.ts +34 -0
- package/src/io/FastMap.ts +24 -0
- package/src/io/FastSet.ts +15 -1
- package/src/io/codec.ts +217 -0
- package/src/io/index.ts +1 -2
- package/src/io/types.ts +2 -1
- package/test/assembly/example.spec.ts +14 -4
- package/test/doctor.test.ts +65 -0
- package/test/errors.test.ts +21 -0
- package/test/io.test.ts +65 -41
- package/test/prettier-plugin.test.ts +46 -0
- package/test/rpc.test.ts +50 -0
- package/tests/data-parity/generated-parity.ts +99 -0
- package/tests/data-parity/parity.ts +80 -0
- package/tests/data-parity/spec.ts +46 -0
- package/tsconfig.json +1 -1
- package/tsconfig.server.json +1 -1
- package/build/io/BinaryReader.d.ts +0 -44
- package/build/io/BinaryReader.js +0 -244
- package/build/io/BinaryWriter.d.ts +0 -44
- package/build/io/BinaryWriter.js +0 -297
- package/build/server/release.wasm +0 -0
- package/build/server/release.wat +0 -9
- package/src/io/BinaryReader.ts +0 -340
- package/src/io/BinaryWriter.ts +0 -385
- package/src/server/index.ts +0 -10
- package/src/server/main.ts +0 -13
- package/src/server/tsconfig.json +0 -4
- package/toilconfig.json +0 -30
package/build/cli/index.js
CHANGED
|
@@ -32,15 +32,15 @@ var require_src = __commonJS({
|
|
|
32
32
|
var ESC2 = "\x1B";
|
|
33
33
|
var CSI2 = `${ESC2}[`;
|
|
34
34
|
var beep = "\x07";
|
|
35
|
-
var
|
|
36
|
-
to(
|
|
37
|
-
if (!y) return `${CSI2}${
|
|
38
|
-
return `${CSI2}${y + 1};${
|
|
35
|
+
var cursor3 = {
|
|
36
|
+
to(x, y) {
|
|
37
|
+
if (!y) return `${CSI2}${x + 1}G`;
|
|
38
|
+
return `${CSI2}${y + 1};${x + 1}H`;
|
|
39
39
|
},
|
|
40
|
-
move(
|
|
40
|
+
move(x, y) {
|
|
41
41
|
let ret = "";
|
|
42
|
-
if (
|
|
43
|
-
else if (
|
|
42
|
+
if (x < 0) ret += `${CSI2}${-x}D`;
|
|
43
|
+
else if (x > 0) ret += `${CSI2}${x}C`;
|
|
44
44
|
if (y < 0) ret += `${CSI2}${-y}A`;
|
|
45
45
|
else if (y > 0) ret += `${CSI2}${y}B`;
|
|
46
46
|
return ret;
|
|
@@ -61,7 +61,7 @@ var require_src = __commonJS({
|
|
|
61
61
|
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
62
62
|
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
63
63
|
};
|
|
64
|
-
var
|
|
64
|
+
var erase3 = {
|
|
65
65
|
screen: `${CSI2}2J`,
|
|
66
66
|
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
67
67
|
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
@@ -70,82 +70,82 @@ var require_src = __commonJS({
|
|
|
70
70
|
lineStart: `${CSI2}1K`,
|
|
71
71
|
lines(count) {
|
|
72
72
|
let clear = "";
|
|
73
|
-
for (let
|
|
74
|
-
clear += this.line + (
|
|
73
|
+
for (let i2 = 0; i2 < count; i2++)
|
|
74
|
+
clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
|
|
75
75
|
if (count)
|
|
76
|
-
clear +=
|
|
76
|
+
clear += cursor3.left;
|
|
77
77
|
return clear;
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
module.exports = { cursor, scroll, erase, beep };
|
|
80
|
+
module.exports = { cursor: cursor3, scroll, erase: erase3, beep };
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
// node_modules/picocolors/picocolors.js
|
|
85
85
|
var require_picocolors = __commonJS({
|
|
86
86
|
"node_modules/picocolors/picocolors.js"(exports, module) {
|
|
87
|
-
var
|
|
88
|
-
var argv =
|
|
89
|
-
var env =
|
|
90
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") ||
|
|
87
|
+
var p = process || {};
|
|
88
|
+
var argv = p.argv || [];
|
|
89
|
+
var env = p.env || {};
|
|
90
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
91
91
|
var formatter = (open, close, replace = open) => (input) => {
|
|
92
92
|
let string = "" + input, index = string.indexOf(close, open.length);
|
|
93
93
|
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
94
94
|
};
|
|
95
95
|
var replaceClose = (string, close, replace, index) => {
|
|
96
|
-
let result = "",
|
|
96
|
+
let result = "", cursor3 = 0;
|
|
97
97
|
do {
|
|
98
|
-
result += string.substring(
|
|
99
|
-
|
|
100
|
-
index = string.indexOf(close,
|
|
98
|
+
result += string.substring(cursor3, index) + replace;
|
|
99
|
+
cursor3 = index + close.length;
|
|
100
|
+
index = string.indexOf(close, cursor3);
|
|
101
101
|
} while (~index);
|
|
102
|
-
return result + string.substring(
|
|
102
|
+
return result + string.substring(cursor3);
|
|
103
103
|
};
|
|
104
104
|
var createColors = (enabled = isColorSupported) => {
|
|
105
|
-
let
|
|
105
|
+
let f = enabled ? formatter : () => String;
|
|
106
106
|
return {
|
|
107
107
|
isColorSupported: enabled,
|
|
108
|
-
reset:
|
|
109
|
-
bold:
|
|
110
|
-
dim:
|
|
111
|
-
italic:
|
|
112
|
-
underline:
|
|
113
|
-
inverse:
|
|
114
|
-
hidden:
|
|
115
|
-
strikethrough:
|
|
116
|
-
black:
|
|
117
|
-
red:
|
|
118
|
-
green:
|
|
119
|
-
yellow:
|
|
120
|
-
blue:
|
|
121
|
-
magenta:
|
|
122
|
-
cyan:
|
|
123
|
-
white:
|
|
124
|
-
gray:
|
|
125
|
-
bgBlack:
|
|
126
|
-
bgRed:
|
|
127
|
-
bgGreen:
|
|
128
|
-
bgYellow:
|
|
129
|
-
bgBlue:
|
|
130
|
-
bgMagenta:
|
|
131
|
-
bgCyan:
|
|
132
|
-
bgWhite:
|
|
133
|
-
blackBright:
|
|
134
|
-
redBright:
|
|
135
|
-
greenBright:
|
|
136
|
-
yellowBright:
|
|
137
|
-
blueBright:
|
|
138
|
-
magentaBright:
|
|
139
|
-
cyanBright:
|
|
140
|
-
whiteBright:
|
|
141
|
-
bgBlackBright:
|
|
142
|
-
bgRedBright:
|
|
143
|
-
bgGreenBright:
|
|
144
|
-
bgYellowBright:
|
|
145
|
-
bgBlueBright:
|
|
146
|
-
bgMagentaBright:
|
|
147
|
-
bgCyanBright:
|
|
148
|
-
bgWhiteBright:
|
|
108
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
109
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
110
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
111
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
112
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
113
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
114
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
115
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
116
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
117
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
118
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
119
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
120
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
121
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
122
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
123
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
124
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
125
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
126
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
127
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
128
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
129
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
130
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
131
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
132
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
133
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
134
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
135
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
136
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
137
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
138
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
139
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
140
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
141
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
142
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
143
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
144
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
145
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
146
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
147
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
148
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
module.exports = createColors();
|
|
@@ -161,10 +161,10 @@ import fs2 from "node:fs/promises";
|
|
|
161
161
|
import path2 from "node:path";
|
|
162
162
|
|
|
163
163
|
// node_modules/@clack/core/dist/index.mjs
|
|
164
|
-
import { styleText
|
|
165
|
-
import { stdout
|
|
166
|
-
import * as
|
|
167
|
-
import
|
|
164
|
+
import { styleText } from "node:util";
|
|
165
|
+
import { stdout, stdin } from "node:process";
|
|
166
|
+
import * as l from "node:readline";
|
|
167
|
+
import l__default from "node:readline";
|
|
168
168
|
|
|
169
169
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
170
170
|
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
@@ -178,11 +178,11 @@ var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
|
178
178
|
return input.length - surrogatePairsNr;
|
|
179
179
|
};
|
|
180
180
|
})();
|
|
181
|
-
var isFullWidth = (
|
|
182
|
-
return
|
|
181
|
+
var isFullWidth = (x) => {
|
|
182
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
183
183
|
};
|
|
184
|
-
var isWideNotCJKTNotEmoji = (
|
|
185
|
-
return
|
|
184
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
185
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
186
186
|
};
|
|
187
187
|
|
|
188
188
|
// node_modules/fast-string-truncated-width/dist/index.js
|
|
@@ -252,8 +252,8 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
252
252
|
if (index >= length) {
|
|
253
253
|
break outer;
|
|
254
254
|
}
|
|
255
|
-
for (let
|
|
256
|
-
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[
|
|
255
|
+
for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
|
|
256
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
|
|
257
257
|
BLOCK_RE.lastIndex = index;
|
|
258
258
|
if (BLOCK_RE.test(input)) {
|
|
259
259
|
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
@@ -456,8 +456,8 @@ var exec = (string, columns, options = {}) => {
|
|
|
456
456
|
}
|
|
457
457
|
const preString = rows.join("\n");
|
|
458
458
|
let inSurrogate = false;
|
|
459
|
-
for (let
|
|
460
|
-
const character = preString[
|
|
459
|
+
for (let i2 = 0; i2 < preString.length; i2++) {
|
|
460
|
+
const character = preString[i2];
|
|
461
461
|
returnValue += character;
|
|
462
462
|
if (!inSurrogate) {
|
|
463
463
|
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
@@ -468,7 +468,7 @@ var exec = (string, columns, options = {}) => {
|
|
|
468
468
|
inSurrogate = false;
|
|
469
469
|
}
|
|
470
470
|
if (character === ESC || character === CSI) {
|
|
471
|
-
GROUP_REGEX.lastIndex =
|
|
471
|
+
GROUP_REGEX.lastIndex = i2 + 1;
|
|
472
472
|
const groupsResult = GROUP_REGEX.exec(preString);
|
|
473
473
|
const groups = groupsResult?.groups;
|
|
474
474
|
if (groups?.code !== void 0) {
|
|
@@ -478,7 +478,7 @@ var exec = (string, columns, options = {}) => {
|
|
|
478
478
|
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
if (preString[
|
|
481
|
+
if (preString[i2 + 1] === "\n") {
|
|
482
482
|
if (escapeUrl) {
|
|
483
483
|
returnValue += wrapAnsiHyperlink("");
|
|
484
484
|
}
|
|
@@ -504,78 +504,144 @@ function wrapAnsi(string, columns, options) {
|
|
|
504
504
|
|
|
505
505
|
// node_modules/@clack/core/dist/index.mjs
|
|
506
506
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
507
|
-
import { ReadStream
|
|
508
|
-
function
|
|
509
|
-
if (!
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
var
|
|
515
|
-
var
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
507
|
+
import { ReadStream } from "node:tty";
|
|
508
|
+
function findCursor(s, o2, l2) {
|
|
509
|
+
if (!l2.some((r2) => !r2.disabled))
|
|
510
|
+
return s;
|
|
511
|
+
const t2 = s + o2, n2 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n2 : t2 > n2 ? 0 : t2;
|
|
512
|
+
return l2[e].disabled ? findCursor(e, o2 < 0 ? -1 : 1, l2) : e;
|
|
513
|
+
}
|
|
514
|
+
var a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
515
|
+
var t = [
|
|
516
|
+
"January",
|
|
517
|
+
"February",
|
|
518
|
+
"March",
|
|
519
|
+
"April",
|
|
520
|
+
"May",
|
|
521
|
+
"June",
|
|
522
|
+
"July",
|
|
523
|
+
"August",
|
|
524
|
+
"September",
|
|
525
|
+
"October",
|
|
526
|
+
"November",
|
|
527
|
+
"December"
|
|
528
|
+
];
|
|
529
|
+
var settings = {
|
|
530
|
+
actions: new Set(a$2),
|
|
531
|
+
aliases: /* @__PURE__ */ new Map([
|
|
532
|
+
// vim support
|
|
533
|
+
["k", "up"],
|
|
534
|
+
["j", "down"],
|
|
535
|
+
["h", "left"],
|
|
536
|
+
["l", "right"],
|
|
537
|
+
["", "cancel"],
|
|
538
|
+
// opinionated defaults!
|
|
539
|
+
["escape", "cancel"]
|
|
540
|
+
]),
|
|
541
|
+
messages: {
|
|
542
|
+
cancel: "Canceled",
|
|
543
|
+
error: "Something went wrong"
|
|
544
|
+
},
|
|
545
|
+
withGuide: true,
|
|
546
|
+
date: {
|
|
547
|
+
monthNames: [...t],
|
|
548
|
+
messages: {
|
|
549
|
+
required: "Please enter a valid date",
|
|
550
|
+
invalidMonth: "There are only 12 months in a year",
|
|
551
|
+
invalidDay: (n2, e) => `There are only ${n2} days in ${e}`,
|
|
552
|
+
afterMin: (n2) => `Date must be on or after ${n2.toISOString().slice(0, 10)}`,
|
|
553
|
+
beforeMax: (n2) => `Date must be on or before ${n2.toISOString().slice(0, 10)}`
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
function isActionKey(n2, e) {
|
|
558
|
+
if (typeof n2 == "string")
|
|
559
|
+
return settings.aliases.get(n2) === e;
|
|
560
|
+
for (const s of n2)
|
|
561
|
+
if (s !== void 0 && isActionKey(s, e))
|
|
562
|
+
return true;
|
|
519
563
|
return false;
|
|
520
564
|
}
|
|
521
|
-
function
|
|
522
|
-
if (
|
|
523
|
-
const
|
|
524
|
-
`),
|
|
525
|
-
`),
|
|
526
|
-
for (let
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
565
|
+
function diffLines(i2, s) {
|
|
566
|
+
if (i2 === s) return;
|
|
567
|
+
const e = i2.split(`
|
|
568
|
+
`), t2 = s.split(`
|
|
569
|
+
`), r2 = Math.max(e.length, t2.length), f = [];
|
|
570
|
+
for (let n2 = 0; n2 < r2; n2++)
|
|
571
|
+
e[n2] !== t2[n2] && f.push(n2);
|
|
572
|
+
return {
|
|
573
|
+
lines: f,
|
|
574
|
+
numLinesBefore: e.length,
|
|
575
|
+
numLinesAfter: t2.length,
|
|
576
|
+
numLines: r2
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
var R = globalThis.process.platform.startsWith("win");
|
|
580
|
+
var CANCEL_SYMBOL = /* @__PURE__ */ Symbol("clack:cancel");
|
|
581
|
+
function isCancel(e) {
|
|
582
|
+
return e === CANCEL_SYMBOL;
|
|
583
|
+
}
|
|
584
|
+
function setRawMode(e, r2) {
|
|
585
|
+
const o2 = e;
|
|
586
|
+
o2.isTTY && o2.setRawMode(r2);
|
|
587
|
+
}
|
|
588
|
+
function block({
|
|
589
|
+
input: e = stdin,
|
|
590
|
+
output: r2 = stdout,
|
|
591
|
+
overwrite: o2 = true,
|
|
592
|
+
hideCursor: t2 = true
|
|
593
|
+
} = {}) {
|
|
594
|
+
const s = l.createInterface({
|
|
595
|
+
input: e,
|
|
596
|
+
output: r2,
|
|
597
|
+
prompt: "",
|
|
598
|
+
tabSize: 1
|
|
599
|
+
});
|
|
600
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
601
|
+
const n2 = (f, { name: a3, sequence: p }) => {
|
|
602
|
+
const c2 = String(f);
|
|
603
|
+
if (isActionKey([c2, a3, p], "cancel")) {
|
|
604
|
+
t2 && r2.write(import_sisteransi.cursor.show), process.exit(0);
|
|
545
605
|
return;
|
|
546
606
|
}
|
|
547
|
-
if (!
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
607
|
+
if (!o2) return;
|
|
608
|
+
const i2 = a3 === "return" ? 0 : -1, m = a3 === "return" ? -1 : 0;
|
|
609
|
+
l.moveCursor(r2, i2, m, () => {
|
|
610
|
+
l.clearLine(r2, 1, () => {
|
|
611
|
+
e.once("keypress", n2);
|
|
552
612
|
});
|
|
553
613
|
});
|
|
554
614
|
};
|
|
555
|
-
return
|
|
556
|
-
|
|
615
|
+
return t2 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", n2), () => {
|
|
616
|
+
e.off("keypress", n2), t2 && r2.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
557
617
|
};
|
|
558
618
|
}
|
|
559
|
-
var
|
|
560
|
-
var
|
|
561
|
-
function
|
|
562
|
-
const
|
|
563
|
-
return wrapAnsi(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
619
|
+
var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
|
|
620
|
+
var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
621
|
+
function wrapTextWithPrefix(e, r2, o2, t2 = o2, s = o2, n2) {
|
|
622
|
+
const f = getColumns(e ?? stdout);
|
|
623
|
+
return wrapAnsi(r2, f - o2.length, {
|
|
624
|
+
hard: true,
|
|
625
|
+
trim: false
|
|
626
|
+
}).split(`
|
|
627
|
+
`).map((c2, i2, m) => {
|
|
628
|
+
const d2 = n2 ? n2(c2, i2) : c2;
|
|
629
|
+
return i2 === 0 ? `${t2}${d2}` : i2 === m.length - 1 ? `${s}${d2}` : `${o2}${d2}`;
|
|
567
630
|
}).join(`
|
|
568
631
|
`);
|
|
569
632
|
}
|
|
570
|
-
function
|
|
571
|
-
if ("~standard" in
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
|
|
633
|
+
function runValidation(e, n2) {
|
|
634
|
+
if ("~standard" in e) {
|
|
635
|
+
const a3 = e["~standard"].validate(n2);
|
|
636
|
+
if (a3 instanceof Promise)
|
|
637
|
+
throw new TypeError(
|
|
638
|
+
"Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
|
|
639
|
+
);
|
|
640
|
+
return a3.issues?.at(0)?.message;
|
|
575
641
|
}
|
|
576
|
-
return
|
|
642
|
+
return e(n2);
|
|
577
643
|
}
|
|
578
|
-
var
|
|
644
|
+
var V = class {
|
|
579
645
|
input;
|
|
580
646
|
output;
|
|
581
647
|
_abortSignal;
|
|
@@ -590,171 +656,215 @@ var m = class {
|
|
|
590
656
|
error = "";
|
|
591
657
|
value;
|
|
592
658
|
userInput = "";
|
|
593
|
-
constructor(
|
|
594
|
-
const { input:
|
|
595
|
-
this.opts =
|
|
659
|
+
constructor(t2, e = true) {
|
|
660
|
+
const { input: i2 = stdin, output: n2 = stdout, render: s, signal: r2, ...o2 } = t2;
|
|
661
|
+
this.opts = o2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r2, this.input = i2, this.output = n2;
|
|
596
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Unsubscribe all listeners
|
|
665
|
+
*/
|
|
597
666
|
unsubscribe() {
|
|
598
667
|
this._subscribers.clear();
|
|
599
668
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
this.
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
669
|
+
/**
|
|
670
|
+
* Set a subscriber with opts
|
|
671
|
+
* @param event - The event name
|
|
672
|
+
*/
|
|
673
|
+
setSubscriber(t2, e) {
|
|
674
|
+
const i2 = this._subscribers.get(t2) ?? [];
|
|
675
|
+
i2.push(e), this._subscribers.set(t2, i2);
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Subscribe to an event
|
|
679
|
+
* @param event - The event name
|
|
680
|
+
* @param cb - The callback
|
|
681
|
+
*/
|
|
682
|
+
on(t2, e) {
|
|
683
|
+
this.setSubscriber(t2, { cb: e });
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Subscribe to an event once
|
|
687
|
+
* @param event - The event name
|
|
688
|
+
* @param cb - The callback
|
|
689
|
+
*/
|
|
690
|
+
once(t2, e) {
|
|
691
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Emit an event with data
|
|
695
|
+
* @param event - The event name
|
|
696
|
+
* @param data - The data to pass to the callback
|
|
697
|
+
*/
|
|
698
|
+
emit(t2, ...e) {
|
|
699
|
+
const i2 = this._subscribers.get(t2) ?? [], n2 = [];
|
|
700
|
+
for (const s of i2)
|
|
701
|
+
s.cb(...e), s.once && n2.push(() => i2.splice(i2.indexOf(s), 1));
|
|
702
|
+
for (const s of n2)
|
|
703
|
+
s();
|
|
614
704
|
}
|
|
615
705
|
prompt() {
|
|
616
|
-
return new Promise((
|
|
706
|
+
return new Promise((t2) => {
|
|
617
707
|
if (this._abortSignal) {
|
|
618
|
-
if (this._abortSignal.aborted)
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
708
|
+
if (this._abortSignal.aborted)
|
|
709
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
710
|
+
this._abortSignal.addEventListener(
|
|
711
|
+
"abort",
|
|
712
|
+
() => {
|
|
713
|
+
this.state = "cancel", this.close();
|
|
714
|
+
},
|
|
715
|
+
{ once: true }
|
|
716
|
+
);
|
|
622
717
|
}
|
|
623
|
-
this.rl =
|
|
624
|
-
|
|
718
|
+
this.rl = l__default.createInterface({
|
|
719
|
+
input: this.input,
|
|
720
|
+
tabSize: 2,
|
|
721
|
+
prompt: "",
|
|
722
|
+
escapeCodeTimeout: 50,
|
|
723
|
+
terminal: true
|
|
724
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && 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", () => {
|
|
725
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
625
726
|
}), this.once("cancel", () => {
|
|
626
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render),
|
|
727
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
627
728
|
});
|
|
628
729
|
});
|
|
629
730
|
}
|
|
630
|
-
_isActionKey(
|
|
631
|
-
return
|
|
731
|
+
_isActionKey(t2, e) {
|
|
732
|
+
return t2 === " ";
|
|
632
733
|
}
|
|
633
|
-
_shouldSubmit(
|
|
734
|
+
_shouldSubmit(t2, e) {
|
|
634
735
|
return true;
|
|
635
736
|
}
|
|
636
|
-
_setValue(
|
|
637
|
-
this.value =
|
|
737
|
+
_setValue(t2) {
|
|
738
|
+
this.value = t2, this.emit("value", this.value);
|
|
638
739
|
}
|
|
639
|
-
_setUserInput(
|
|
640
|
-
this.userInput =
|
|
740
|
+
_setUserInput(t2, e) {
|
|
741
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
641
742
|
}
|
|
642
743
|
_clearUserInput() {
|
|
643
744
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
644
745
|
}
|
|
645
|
-
onKeypress(
|
|
646
|
-
if (this._track &&
|
|
746
|
+
onKeypress(t2, e) {
|
|
747
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
647
748
|
if (this.opts.validate) {
|
|
648
|
-
const
|
|
649
|
-
|
|
749
|
+
const i2 = runValidation(this.opts.validate, this.value);
|
|
750
|
+
i2 && (this.error = i2 instanceof Error ? i2.message : i2, this.state = "error", this.rl?.write(this.userInput));
|
|
650
751
|
}
|
|
651
752
|
this.state !== "error" && (this.state = "submit");
|
|
652
753
|
}
|
|
653
|
-
|
|
754
|
+
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
654
755
|
}
|
|
655
756
|
close() {
|
|
656
757
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
657
|
-
`),
|
|
758
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
658
759
|
}
|
|
659
760
|
restoreCursor() {
|
|
660
|
-
const
|
|
761
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
661
762
|
`).length - 1;
|
|
662
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
763
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
663
764
|
}
|
|
664
765
|
render() {
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
766
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
767
|
+
hard: true,
|
|
768
|
+
trim: false
|
|
769
|
+
});
|
|
770
|
+
if (t2 !== this._prevFrame) {
|
|
771
|
+
if (this.state === "initial")
|
|
772
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
668
773
|
else {
|
|
669
|
-
const
|
|
670
|
-
if (this.restoreCursor(),
|
|
671
|
-
const
|
|
672
|
-
let
|
|
673
|
-
if (
|
|
674
|
-
this._prevFrame =
|
|
774
|
+
const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
|
|
775
|
+
if (this.restoreCursor(), e) {
|
|
776
|
+
const n2 = Math.max(0, e.numLinesAfter - i2), s = Math.max(0, e.numLinesBefore - i2);
|
|
777
|
+
let r2 = e.lines.find((o2) => o2 >= n2);
|
|
778
|
+
if (r2 === void 0) {
|
|
779
|
+
this._prevFrame = t2;
|
|
675
780
|
return;
|
|
676
781
|
}
|
|
677
|
-
if (
|
|
678
|
-
this.output.write(import_sisteransi.cursor.move(0,
|
|
679
|
-
const
|
|
782
|
+
if (e.lines.length === 1) {
|
|
783
|
+
this.output.write(import_sisteransi.cursor.move(0, r2 - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
784
|
+
const o2 = t2.split(`
|
|
680
785
|
`);
|
|
681
|
-
this.output.write(
|
|
786
|
+
this.output.write(o2[r2]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o2.length - r2 - 1));
|
|
682
787
|
return;
|
|
683
|
-
} else if (
|
|
684
|
-
if (
|
|
788
|
+
} else if (e.lines.length > 1) {
|
|
789
|
+
if (n2 < s)
|
|
790
|
+
r2 = n2;
|
|
685
791
|
else {
|
|
686
|
-
const
|
|
687
|
-
|
|
792
|
+
const h2 = r2 - s;
|
|
793
|
+
h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
|
|
688
794
|
}
|
|
689
795
|
this.output.write(import_sisteransi.erase.down());
|
|
690
|
-
const
|
|
691
|
-
`).slice(
|
|
692
|
-
this.output.write(
|
|
693
|
-
`)), this._prevFrame =
|
|
796
|
+
const f = t2.split(`
|
|
797
|
+
`).slice(r2);
|
|
798
|
+
this.output.write(f.join(`
|
|
799
|
+
`)), this._prevFrame = t2;
|
|
694
800
|
return;
|
|
695
801
|
}
|
|
696
802
|
}
|
|
697
803
|
this.output.write(import_sisteransi.erase.down());
|
|
698
804
|
}
|
|
699
|
-
this.output.write(
|
|
805
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
700
806
|
}
|
|
701
807
|
}
|
|
702
808
|
};
|
|
703
|
-
var
|
|
809
|
+
var r = class extends V {
|
|
704
810
|
get cursor() {
|
|
705
811
|
return this.value ? 0 : 1;
|
|
706
812
|
}
|
|
707
813
|
get _value() {
|
|
708
814
|
return this.cursor === 0;
|
|
709
815
|
}
|
|
710
|
-
constructor(
|
|
711
|
-
super(
|
|
816
|
+
constructor(t2) {
|
|
817
|
+
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
712
818
|
this.value = this._value;
|
|
713
|
-
}), this.on("confirm", (
|
|
714
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value =
|
|
819
|
+
}), this.on("confirm", (i2) => {
|
|
820
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
|
|
715
821
|
}), this.on("cursor", () => {
|
|
716
822
|
this.value = !this.value;
|
|
717
823
|
});
|
|
718
824
|
}
|
|
719
825
|
};
|
|
720
|
-
var
|
|
826
|
+
var a$1 = class a extends V {
|
|
721
827
|
options;
|
|
722
828
|
cursor = 0;
|
|
723
829
|
get _value() {
|
|
724
830
|
return this.options[this.cursor].value;
|
|
725
831
|
}
|
|
726
832
|
get _enabledOptions() {
|
|
727
|
-
return this.options.filter((
|
|
833
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
728
834
|
}
|
|
729
835
|
toggleAll() {
|
|
730
|
-
const
|
|
731
|
-
this.value =
|
|
836
|
+
const e = this._enabledOptions, i2 = this.value !== void 0 && this.value.length === e.length;
|
|
837
|
+
this.value = i2 ? [] : e.map((t2) => t2.value);
|
|
732
838
|
}
|
|
733
839
|
toggleInvert() {
|
|
734
|
-
const
|
|
735
|
-
if (!
|
|
736
|
-
|
|
737
|
-
|
|
840
|
+
const e = this.value;
|
|
841
|
+
if (!e)
|
|
842
|
+
return;
|
|
843
|
+
const i2 = this._enabledOptions.filter((t2) => !e.includes(t2.value));
|
|
844
|
+
this.value = i2.map((t2) => t2.value);
|
|
738
845
|
}
|
|
739
846
|
toggleValue() {
|
|
740
847
|
this.value === void 0 && (this.value = []);
|
|
741
|
-
const
|
|
742
|
-
this.value =
|
|
743
|
-
}
|
|
744
|
-
constructor(
|
|
745
|
-
super(
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
848
|
+
const e = this.value.includes(this._value);
|
|
849
|
+
this.value = e ? this.value.filter((i2) => i2 !== this._value) : [...this.value, this._value];
|
|
850
|
+
}
|
|
851
|
+
constructor(e) {
|
|
852
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
853
|
+
const i2 = Math.max(
|
|
854
|
+
this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
|
|
855
|
+
0
|
|
856
|
+
);
|
|
857
|
+
this.cursor = this.options[i2].disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, l2) => {
|
|
858
|
+
l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
|
|
859
|
+
}), this.on("cursor", (t2) => {
|
|
860
|
+
switch (t2) {
|
|
751
861
|
case "left":
|
|
752
862
|
case "up":
|
|
753
|
-
this.cursor =
|
|
863
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
754
864
|
break;
|
|
755
865
|
case "down":
|
|
756
866
|
case "right":
|
|
757
|
-
this.cursor =
|
|
867
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
758
868
|
break;
|
|
759
869
|
case "space":
|
|
760
870
|
this.toggleValue();
|
|
@@ -763,7 +873,7 @@ var ut = class extends m {
|
|
|
763
873
|
});
|
|
764
874
|
}
|
|
765
875
|
};
|
|
766
|
-
var
|
|
876
|
+
var a2 = class extends V {
|
|
767
877
|
options;
|
|
768
878
|
cursor = 0;
|
|
769
879
|
get _selectedValue() {
|
|
@@ -772,383 +882,568 @@ var ht = class extends m {
|
|
|
772
882
|
changeValue() {
|
|
773
883
|
this.value = this._selectedValue.value;
|
|
774
884
|
}
|
|
775
|
-
constructor(
|
|
776
|
-
super(
|
|
777
|
-
const
|
|
778
|
-
this.cursor = this.options[
|
|
779
|
-
switch (
|
|
885
|
+
constructor(t2) {
|
|
886
|
+
super(t2, false), this.options = t2.options;
|
|
887
|
+
const i2 = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i2 === -1 ? 0 : i2;
|
|
888
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
889
|
+
switch (s) {
|
|
780
890
|
case "left":
|
|
781
891
|
case "up":
|
|
782
|
-
this.cursor =
|
|
892
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
783
893
|
break;
|
|
784
894
|
case "down":
|
|
785
895
|
case "right":
|
|
786
|
-
this.cursor =
|
|
896
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
787
897
|
break;
|
|
788
898
|
}
|
|
789
899
|
this.changeValue();
|
|
790
900
|
});
|
|
791
901
|
}
|
|
792
902
|
};
|
|
793
|
-
var
|
|
903
|
+
var n = class extends V {
|
|
794
904
|
get userInputWithCursor() {
|
|
795
|
-
if (this.state === "submit")
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
905
|
+
if (this.state === "submit")
|
|
906
|
+
return this.userInput;
|
|
907
|
+
const t2 = this.userInput;
|
|
908
|
+
if (this.cursor >= t2.length)
|
|
909
|
+
return `${this.userInput}\u2588`;
|
|
910
|
+
const e = t2.slice(0, this.cursor), [s, ...r2] = t2.slice(this.cursor);
|
|
911
|
+
return `${e}${styleText("inverse", s)}${r2.join("")}`;
|
|
800
912
|
}
|
|
801
913
|
get cursor() {
|
|
802
914
|
return this._cursor;
|
|
803
915
|
}
|
|
804
|
-
constructor(
|
|
805
|
-
super({
|
|
806
|
-
|
|
916
|
+
constructor(t2) {
|
|
917
|
+
super({
|
|
918
|
+
...t2,
|
|
919
|
+
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
920
|
+
}), this.on("userInput", (e) => {
|
|
921
|
+
this._setValue(e);
|
|
807
922
|
}), this.on("finalize", () => {
|
|
808
|
-
this.value || (this.value =
|
|
923
|
+
this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
|
|
809
924
|
});
|
|
810
925
|
}
|
|
811
926
|
};
|
|
812
927
|
|
|
813
928
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
814
|
-
import { styleText as
|
|
815
|
-
import
|
|
929
|
+
import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
930
|
+
import process$1 from "node:process";
|
|
816
931
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
817
|
-
function
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
var
|
|
824
|
-
var
|
|
825
|
-
var
|
|
826
|
-
var
|
|
827
|
-
var
|
|
828
|
-
var
|
|
829
|
-
var
|
|
830
|
-
var
|
|
831
|
-
var
|
|
832
|
-
var
|
|
833
|
-
var
|
|
834
|
-
var
|
|
835
|
-
var
|
|
836
|
-
var
|
|
837
|
-
var
|
|
838
|
-
var
|
|
839
|
-
var
|
|
840
|
-
var
|
|
841
|
-
var
|
|
842
|
-
var
|
|
843
|
-
var
|
|
844
|
-
var
|
|
845
|
-
var
|
|
846
|
-
var
|
|
847
|
-
var
|
|
848
|
-
var
|
|
849
|
-
|
|
932
|
+
function isUnicodeSupported() {
|
|
933
|
+
if (process$1.platform !== "win32") {
|
|
934
|
+
return process$1.env.TERM !== "linux";
|
|
935
|
+
}
|
|
936
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
937
|
+
}
|
|
938
|
+
var unicode = isUnicodeSupported();
|
|
939
|
+
var isCI = () => process.env.CI === "true";
|
|
940
|
+
var unicodeOr = (e, o2) => unicode ? e : o2;
|
|
941
|
+
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
942
|
+
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
943
|
+
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
944
|
+
var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
|
|
945
|
+
var S_BAR_START = unicodeOr("\u250C", "T");
|
|
946
|
+
var S_BAR = unicodeOr("\u2502", "|");
|
|
947
|
+
var S_BAR_END = unicodeOr("\u2514", "\u2014");
|
|
948
|
+
var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
|
|
949
|
+
var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
|
|
950
|
+
var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
|
|
951
|
+
var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
|
|
952
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
|
|
953
|
+
var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
|
|
954
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
|
|
955
|
+
var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
|
|
956
|
+
var S_BAR_H = unicodeOr("\u2500", "-");
|
|
957
|
+
var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
|
|
958
|
+
var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
|
|
959
|
+
var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
|
|
960
|
+
var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
|
|
961
|
+
var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
|
|
962
|
+
var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
963
|
+
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
964
|
+
var S_WARN = unicodeOr("\u25B2", "!");
|
|
965
|
+
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
966
|
+
var symbol = (e) => {
|
|
967
|
+
switch (e) {
|
|
850
968
|
case "initial":
|
|
851
969
|
case "active":
|
|
852
|
-
return
|
|
970
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
853
971
|
case "cancel":
|
|
854
|
-
return
|
|
972
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
855
973
|
case "error":
|
|
856
|
-
return
|
|
974
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
857
975
|
case "submit":
|
|
858
|
-
return
|
|
976
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
859
977
|
}
|
|
860
978
|
};
|
|
861
|
-
var
|
|
862
|
-
switch (
|
|
979
|
+
var symbolBar = (e) => {
|
|
980
|
+
switch (e) {
|
|
863
981
|
case "initial":
|
|
864
982
|
case "active":
|
|
865
|
-
return
|
|
983
|
+
return styleText2("cyan", S_BAR);
|
|
866
984
|
case "cancel":
|
|
867
|
-
return
|
|
985
|
+
return styleText2("red", S_BAR);
|
|
868
986
|
case "error":
|
|
869
|
-
return
|
|
987
|
+
return styleText2("yellow", S_BAR);
|
|
870
988
|
case "submit":
|
|
871
|
-
return
|
|
989
|
+
return styleText2("green", S_BAR);
|
|
872
990
|
}
|
|
873
991
|
};
|
|
874
|
-
var
|
|
875
|
-
let
|
|
876
|
-
if (
|
|
877
|
-
|
|
878
|
-
|
|
992
|
+
var E$1 = (l2, o2, g, c2, h2, O = false) => {
|
|
993
|
+
let r2 = o2, w = 0;
|
|
994
|
+
if (O)
|
|
995
|
+
for (let i2 = c2 - 1; i2 >= g && (r2 -= l2[i2].length, w++, !(r2 <= h2)); i2--)
|
|
996
|
+
;
|
|
997
|
+
else
|
|
998
|
+
for (let i2 = g; i2 < c2 && (r2 -= l2[i2].length, w++, !(r2 <= h2)); i2++)
|
|
999
|
+
;
|
|
1000
|
+
return { lineCount: r2, removals: w };
|
|
879
1001
|
};
|
|
880
|
-
var
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1002
|
+
var limitOptions = ({
|
|
1003
|
+
cursor: l2,
|
|
1004
|
+
options: o2,
|
|
1005
|
+
style: g,
|
|
1006
|
+
output: c2 = process.stdout,
|
|
1007
|
+
maxItems: h2 = Number.POSITIVE_INFINITY,
|
|
1008
|
+
columnPadding: O = 0,
|
|
1009
|
+
rowPadding: r2 = 4
|
|
1010
|
+
}) => {
|
|
1011
|
+
const i2 = getColumns(c2) - O, I = getRows(c2), C2 = styleText2("dim", "..."), x = Math.max(I - r2, 0), m = Math.max(Math.min(h2, x), 5);
|
|
1012
|
+
let p = 0;
|
|
1013
|
+
l2 >= m - 3 && (p = Math.max(
|
|
1014
|
+
Math.min(l2 - m + 3, o2.length - m),
|
|
1015
|
+
0
|
|
1016
|
+
));
|
|
1017
|
+
let f = m < o2.length && p > 0, u3 = m < o2.length && p + m < o2.length;
|
|
1018
|
+
const W2 = Math.min(
|
|
1019
|
+
p + m,
|
|
1020
|
+
o2.length
|
|
1021
|
+
), e = [];
|
|
1022
|
+
let d2 = 0;
|
|
1023
|
+
f && d2++, u3 && d2++;
|
|
1024
|
+
const v = p + (f ? 1 : 0), P = W2 - (u3 ? 1 : 0);
|
|
1025
|
+
for (let t2 = v; t2 < P; t2++) {
|
|
1026
|
+
const n2 = wrapAnsi(g(o2[t2], t2 === l2), i2, {
|
|
1027
|
+
hard: true,
|
|
1028
|
+
trim: false
|
|
1029
|
+
}).split(`
|
|
891
1030
|
`);
|
|
892
|
-
|
|
893
|
-
}
|
|
894
|
-
if (
|
|
895
|
-
let
|
|
896
|
-
const
|
|
897
|
-
let
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1031
|
+
e.push(n2), d2 += n2.length;
|
|
1032
|
+
}
|
|
1033
|
+
if (d2 > x) {
|
|
1034
|
+
let t2 = 0, n2 = 0, s = d2;
|
|
1035
|
+
const M = l2 - v;
|
|
1036
|
+
let a3 = x;
|
|
1037
|
+
const T = () => E$1(e, s, 0, M, a3), L = () => E$1(
|
|
1038
|
+
e,
|
|
1039
|
+
s,
|
|
1040
|
+
M + 1,
|
|
1041
|
+
e.length,
|
|
1042
|
+
a3,
|
|
1043
|
+
true
|
|
1044
|
+
);
|
|
1045
|
+
f ? ({ lineCount: s, removals: t2 } = T(), s > a3 && (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L())) : (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L(), s > a3 && (a3 -= 1, { lineCount: s, removals: t2 } = T())), t2 > 0 && (f = true, e.splice(0, t2)), n2 > 0 && (u3 = true, e.splice(e.length - n2, n2));
|
|
1046
|
+
}
|
|
1047
|
+
const b = [];
|
|
1048
|
+
f && b.push(C2);
|
|
1049
|
+
for (const t2 of e)
|
|
1050
|
+
for (const n2 of t2)
|
|
1051
|
+
b.push(n2);
|
|
1052
|
+
return u3 && b.push(C2), b;
|
|
905
1053
|
};
|
|
906
|
-
var
|
|
907
|
-
const
|
|
908
|
-
return new
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
${
|
|
1054
|
+
var confirm = (i2) => {
|
|
1055
|
+
const a3 = i2.active ?? "Yes", s = i2.inactive ?? "No";
|
|
1056
|
+
return new r({
|
|
1057
|
+
active: a3,
|
|
1058
|
+
inactive: s,
|
|
1059
|
+
signal: i2.signal,
|
|
1060
|
+
input: i2.input,
|
|
1061
|
+
output: i2.output,
|
|
1062
|
+
initialValue: i2.initialValue ?? true,
|
|
1063
|
+
render() {
|
|
1064
|
+
const e = i2.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l2 = e ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
|
|
1065
|
+
i2.output,
|
|
1066
|
+
i2.message,
|
|
1067
|
+
l2,
|
|
1068
|
+
u3
|
|
1069
|
+
), o2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
1070
|
+
` : ""}${f}
|
|
1071
|
+
`, c2 = this.value ? a3 : s;
|
|
1072
|
+
switch (this.state) {
|
|
1073
|
+
case "submit": {
|
|
1074
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1075
|
+
return `${o2}${r2}${styleText2("dim", c2)}`;
|
|
1076
|
+
}
|
|
1077
|
+
case "cancel": {
|
|
1078
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1079
|
+
return `${o2}${r2}${styleText2(["strikethrough", "dim"], c2)}${e ? `
|
|
1080
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1081
|
+
}
|
|
1082
|
+
default: {
|
|
1083
|
+
const r2 = e ? `${styleText2("cyan", S_BAR)} ` : "", g = e ? styleText2("cyan", S_BAR_END) : "";
|
|
1084
|
+
return `${o2}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a3}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a3)}`}${i2.vertical ? e ? `
|
|
1085
|
+
${styleText2("cyan", S_BAR)} ` : `
|
|
1086
|
+
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
|
|
1087
|
+
${g}
|
|
928
1088
|
`;
|
|
1089
|
+
}
|
|
929
1090
|
}
|
|
930
1091
|
}
|
|
931
|
-
}
|
|
1092
|
+
}).prompt();
|
|
932
1093
|
};
|
|
933
|
-
var
|
|
934
|
-
const
|
|
935
|
-
|
|
1094
|
+
var cancel = (o2 = "", t2) => {
|
|
1095
|
+
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1096
|
+
i2.write(`${e}${styleText2("red", o2)}
|
|
936
1097
|
|
|
937
1098
|
`);
|
|
938
1099
|
};
|
|
939
|
-
var
|
|
940
|
-
const
|
|
941
|
-
|
|
1100
|
+
var intro = (o2 = "", t2) => {
|
|
1101
|
+
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
1102
|
+
i2.write(`${e}${o2}
|
|
942
1103
|
`);
|
|
943
1104
|
};
|
|
944
|
-
var
|
|
945
|
-
const
|
|
946
|
-
${
|
|
947
|
-
|
|
1105
|
+
var outro = (o2 = "", t2) => {
|
|
1106
|
+
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
1107
|
+
${styleText2("gray", S_BAR_END)} ` : "";
|
|
1108
|
+
i2.write(`${e}${o2}
|
|
948
1109
|
|
|
949
1110
|
`);
|
|
950
1111
|
};
|
|
951
|
-
var
|
|
952
|
-
`).map((
|
|
1112
|
+
var d = (n2, a3) => n2.split(`
|
|
1113
|
+
`).map((m) => a3(m)).join(`
|
|
953
1114
|
`);
|
|
954
|
-
var
|
|
955
|
-
const
|
|
956
|
-
const
|
|
957
|
-
return
|
|
958
|
-
},
|
|
959
|
-
return new
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1115
|
+
var multiselect = (n2) => {
|
|
1116
|
+
const a3 = (t2, o2) => {
|
|
1117
|
+
const r2 = t2.label ?? String(t2.value);
|
|
1118
|
+
return o2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${d(r2, (l2) => styleText2(["strikethrough", "gray"], l2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : o2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${d(r2, (l2) => styleText2("dim", l2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "cancelled" ? `${d(r2, (l2) => styleText2(["strikethrough", "dim"], l2))}` : o2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "submitted" ? `${d(r2, (l2) => styleText2("dim", l2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${d(r2, (l2) => styleText2("dim", l2))}`;
|
|
1119
|
+
}, m = n2.required ?? true;
|
|
1120
|
+
return new a$1({
|
|
1121
|
+
options: n2.options,
|
|
1122
|
+
signal: n2.signal,
|
|
1123
|
+
input: n2.input,
|
|
1124
|
+
output: n2.output,
|
|
1125
|
+
initialValues: n2.initialValues,
|
|
1126
|
+
required: m,
|
|
1127
|
+
cursorAt: n2.cursorAt,
|
|
1128
|
+
validate(t2) {
|
|
1129
|
+
if (m && (t2 === void 0 || t2.length === 0))
|
|
1130
|
+
return `Please select at least one option.
|
|
1131
|
+
${styleText2(
|
|
1132
|
+
"reset",
|
|
1133
|
+
styleText2(
|
|
1134
|
+
"dim",
|
|
1135
|
+
`Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2(
|
|
1136
|
+
"gray",
|
|
1137
|
+
styleText2("bgWhite", styleText2("inverse", " enter "))
|
|
1138
|
+
)} to submit`
|
|
1139
|
+
)
|
|
1140
|
+
)}`;
|
|
1141
|
+
},
|
|
1142
|
+
render() {
|
|
1143
|
+
const t2 = n2.withGuide ?? settings.withGuide, o2 = wrapTextWithPrefix(
|
|
1144
|
+
n2.output,
|
|
1145
|
+
n2.message,
|
|
1146
|
+
t2 ? `${symbolBar(this.state)} ` : "",
|
|
1147
|
+
`${symbol(this.state)} `
|
|
1148
|
+
), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1149
|
+
` : ""}${o2}
|
|
1150
|
+
`, l2 = this.value ?? [], g = (i2, u3) => {
|
|
1151
|
+
if (i2.disabled)
|
|
1152
|
+
return a3(i2, "disabled");
|
|
1153
|
+
const s = l2.includes(i2.value);
|
|
1154
|
+
return u3 && s ? a3(i2, "active-selected") : s ? a3(i2, "selected") : a3(i2, u3 ? "active" : "inactive");
|
|
1155
|
+
};
|
|
1156
|
+
switch (this.state) {
|
|
1157
|
+
case "submit": {
|
|
1158
|
+
const i2 = this.options.filter(({ value: s }) => l2.includes(s)).map((s) => a3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), u3 = wrapTextWithPrefix(
|
|
1159
|
+
n2.output,
|
|
1160
|
+
i2,
|
|
1161
|
+
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
1162
|
+
);
|
|
1163
|
+
return `${r2}${u3}`;
|
|
1164
|
+
}
|
|
1165
|
+
case "cancel": {
|
|
1166
|
+
const i2 = this.options.filter(({ value: s }) => l2.includes(s)).map((s) => a3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1167
|
+
if (i2.trim() === "")
|
|
1168
|
+
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
1169
|
+
const u3 = wrapTextWithPrefix(
|
|
1170
|
+
n2.output,
|
|
1171
|
+
i2,
|
|
1172
|
+
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
1173
|
+
);
|
|
1174
|
+
return `${r2}${u3}${t2 ? `
|
|
1175
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1176
|
+
}
|
|
1177
|
+
case "error": {
|
|
1178
|
+
const i2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", u3 = this.error.split(`
|
|
1179
|
+
`).map(
|
|
1180
|
+
(h2, x) => x === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", h2)}` : ` ${h2}`
|
|
1181
|
+
).join(`
|
|
1182
|
+
`), s = r2.split(`
|
|
1183
|
+
`).length, v = u3.split(`
|
|
987
1184
|
`).length + 1;
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1185
|
+
return `${r2}${i2}${limitOptions({
|
|
1186
|
+
output: n2.output,
|
|
1187
|
+
options: this.options,
|
|
1188
|
+
cursor: this.cursor,
|
|
1189
|
+
maxItems: n2.maxItems,
|
|
1190
|
+
columnPadding: i2.length,
|
|
1191
|
+
rowPadding: s + v,
|
|
1192
|
+
style: g
|
|
1193
|
+
}).join(`
|
|
1194
|
+
${i2}`)}
|
|
1195
|
+
${u3}
|
|
991
1196
|
`;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
`).length,
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1197
|
+
}
|
|
1198
|
+
default: {
|
|
1199
|
+
const i2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", u3 = r2.split(`
|
|
1200
|
+
`).length, s = t2 ? 2 : 1;
|
|
1201
|
+
return `${r2}${i2}${limitOptions({
|
|
1202
|
+
output: n2.output,
|
|
1203
|
+
options: this.options,
|
|
1204
|
+
cursor: this.cursor,
|
|
1205
|
+
maxItems: n2.maxItems,
|
|
1206
|
+
columnPadding: i2.length,
|
|
1207
|
+
rowPadding: u3 + s,
|
|
1208
|
+
style: g
|
|
1209
|
+
}).join(`
|
|
1210
|
+
${i2}`)}
|
|
1211
|
+
${t2 ? styleText2("cyan", S_BAR_END) : ""}
|
|
999
1212
|
`;
|
|
1213
|
+
}
|
|
1000
1214
|
}
|
|
1001
1215
|
}
|
|
1002
|
-
}
|
|
1216
|
+
}).prompt();
|
|
1003
1217
|
};
|
|
1004
|
-
var
|
|
1005
|
-
var
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1008
|
-
|
|
1218
|
+
var W$1 = (o2) => styleText2("dim", o2);
|
|
1219
|
+
var C = (o2, e, s) => {
|
|
1220
|
+
const a3 = {
|
|
1221
|
+
hard: true,
|
|
1222
|
+
trim: false
|
|
1223
|
+
}, i2 = wrapAnsi(o2, e, a3).split(`
|
|
1224
|
+
`), c2 = i2.reduce((n2, r2) => Math.max(dist_default2(r2), n2), 0), u3 = i2.map(s).reduce((n2, r2) => Math.max(dist_default2(r2), n2), 0), g = e - (u3 - c2);
|
|
1225
|
+
return wrapAnsi(o2, g, a3);
|
|
1009
1226
|
};
|
|
1010
|
-
var
|
|
1011
|
-
const
|
|
1012
|
-
`).map(
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
${
|
|
1020
|
-
|
|
1021
|
-
`)
|
|
1227
|
+
var note = (o2 = "", e = "", s) => {
|
|
1228
|
+
const a3 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c2 = s?.format ?? W$1, g = ["", ...C(o2, getColumns(a3) - 6, c2).split(`
|
|
1229
|
+
`).map(c2), ""], n2 = dist_default2(e), r2 = Math.max(
|
|
1230
|
+
g.reduce((m, F) => {
|
|
1231
|
+
const O = dist_default2(F);
|
|
1232
|
+
return O > m ? O : m;
|
|
1233
|
+
}, 0),
|
|
1234
|
+
n2
|
|
1235
|
+
) + 2, h2 = g.map(
|
|
1236
|
+
(m) => `${styleText2("gray", S_BAR)} ${m}${" ".repeat(r2 - dist_default2(m))}${styleText2("gray", S_BAR)}`
|
|
1237
|
+
).join(`
|
|
1238
|
+
`), T = i2 ? `${styleText2("gray", S_BAR)}
|
|
1239
|
+
` : "", l$1 = i2 ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
1240
|
+
a3.write(
|
|
1241
|
+
`${T}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2(
|
|
1242
|
+
"gray",
|
|
1243
|
+
S_BAR_H.repeat(Math.max(r2 - n2 - 1, 1)) + S_CORNER_TOP_RIGHT
|
|
1244
|
+
)}
|
|
1245
|
+
${h2}
|
|
1246
|
+
${styleText2("gray", l$1 + S_BAR_H.repeat(r2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
1247
|
+
`
|
|
1248
|
+
);
|
|
1022
1249
|
};
|
|
1023
|
-
var
|
|
1024
|
-
var
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1250
|
+
var W = (l2) => styleText2("magenta", l2);
|
|
1251
|
+
var spinner = ({
|
|
1252
|
+
indicator: l2 = "dots",
|
|
1253
|
+
onCancel: h2,
|
|
1254
|
+
output: n2 = process.stdout,
|
|
1255
|
+
cancelMessage: G,
|
|
1256
|
+
errorMessage: O,
|
|
1257
|
+
frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
1258
|
+
delay: F = unicode ? 80 : 120,
|
|
1259
|
+
signal: m,
|
|
1260
|
+
...I
|
|
1261
|
+
} = {}) => {
|
|
1262
|
+
const u3 = isCI();
|
|
1263
|
+
let M, T, d2 = false, S = false, s = "", p, w = performance.now();
|
|
1264
|
+
const x = getColumns(n2), k = I?.styleFrame ?? W, g = (e) => {
|
|
1265
|
+
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1266
|
+
S = e === 1, d2 && (a3(r2, e), S && typeof h2 == "function" && h2());
|
|
1267
|
+
}, f = () => g(2), i2 = () => g(1), A = () => {
|
|
1268
|
+
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g), m && m.addEventListener("abort", i2);
|
|
1269
|
+
}, H = () => {
|
|
1270
|
+
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g), m && m.removeEventListener("abort", i2);
|
|
1271
|
+
}, y = () => {
|
|
1272
|
+
if (p === void 0) return;
|
|
1273
|
+
u3 && n2.write(`
|
|
1037
1274
|
`);
|
|
1038
|
-
const
|
|
1275
|
+
const r2 = wrapAnsi(p, x, {
|
|
1276
|
+
hard: true,
|
|
1277
|
+
trim: false
|
|
1278
|
+
}).split(`
|
|
1039
1279
|
`);
|
|
1040
|
-
|
|
1041
|
-
},
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
1044
|
-
},
|
|
1045
|
-
|
|
1280
|
+
r2.length > 1 && n2.write(import_sisteransi2.cursor.up(r2.length - 1)), n2.write(import_sisteransi2.cursor.to(0)), n2.write(import_sisteransi2.erase.down());
|
|
1281
|
+
}, C2 = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1282
|
+
const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o2 = Math.floor(r2 % 60);
|
|
1283
|
+
return t2 > 0 ? `[${t2}m ${o2}s]` : `[${o2}s]`;
|
|
1284
|
+
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1285
|
+
d2 = true, M = block({ output: n2 }), s = C2(e), w = performance.now(), N && n2.write(`${styleText2("gray", S_BAR)}
|
|
1046
1286
|
`);
|
|
1047
|
-
let
|
|
1048
|
-
|
|
1049
|
-
if (
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1287
|
+
let r2 = 0, t2 = 0;
|
|
1288
|
+
A(), T = setInterval(() => {
|
|
1289
|
+
if (u3 && s === p)
|
|
1290
|
+
return;
|
|
1291
|
+
y(), p = s;
|
|
1292
|
+
const o2 = k(E[r2]);
|
|
1293
|
+
let v;
|
|
1294
|
+
if (u3)
|
|
1295
|
+
v = `${o2} ${s}...`;
|
|
1296
|
+
else if (l2 === "timer")
|
|
1297
|
+
v = `${o2} ${s} ${_(w)}`;
|
|
1055
1298
|
else {
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1299
|
+
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
1300
|
+
v = `${o2} ${s}${B}`;
|
|
1058
1301
|
}
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1302
|
+
const j = wrapAnsi(v, x, {
|
|
1303
|
+
hard: true,
|
|
1304
|
+
trim: false
|
|
1305
|
+
});
|
|
1306
|
+
n2.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
1307
|
+
}, F);
|
|
1308
|
+
}, a3 = (e = "", r2 = 0, t2 = false) => {
|
|
1309
|
+
if (!d2) return;
|
|
1310
|
+
d2 = false, clearInterval(T), y();
|
|
1311
|
+
const o2 = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
1312
|
+
s = e ?? s, t2 || (l2 === "timer" ? n2.write(`${o2} ${s} ${_(w)}
|
|
1313
|
+
`) : n2.write(`${o2} ${s}
|
|
1314
|
+
`)), H(), M();
|
|
1315
|
+
};
|
|
1316
|
+
return {
|
|
1317
|
+
start: P,
|
|
1318
|
+
stop: (e = "") => a3(e, 0),
|
|
1319
|
+
message: (e = "") => {
|
|
1320
|
+
s = C2(e ?? s);
|
|
1321
|
+
},
|
|
1322
|
+
cancel: (e = "") => a3(e, 1),
|
|
1323
|
+
error: (e = "") => a3(e, 2),
|
|
1324
|
+
clear: () => a3("", 0, true),
|
|
1325
|
+
get isCancelled() {
|
|
1326
|
+
return S;
|
|
1327
|
+
}
|
|
1069
1328
|
};
|
|
1070
|
-
return { start: rt2, stop: (_ = "") => W2(_, 0), message: (_ = "") => {
|
|
1071
|
-
h2 = O2(_ ?? h2);
|
|
1072
|
-
}, cancel: (_ = "") => W2(_, 1), error: (_ = "") => W2(_, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
1073
|
-
return f2;
|
|
1074
|
-
} };
|
|
1075
1329
|
};
|
|
1076
|
-
var
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
var
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1330
|
+
var u2 = {
|
|
1331
|
+
light: unicodeOr("\u2500", "-"),
|
|
1332
|
+
heavy: unicodeOr("\u2501", "="),
|
|
1333
|
+
block: unicodeOr("\u2588", "#")
|
|
1334
|
+
};
|
|
1335
|
+
var c = (e, a3) => e.includes(`
|
|
1336
|
+
`) ? e.split(`
|
|
1337
|
+
`).map((t2) => a3(t2)).join(`
|
|
1338
|
+
`) : a3(e);
|
|
1339
|
+
var select = (e) => {
|
|
1340
|
+
const a3 = (t2, d2) => {
|
|
1341
|
+
const s = t2.label ?? String(t2.value);
|
|
1342
|
+
switch (d2) {
|
|
1085
1343
|
case "disabled":
|
|
1086
|
-
return `${
|
|
1344
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (n2) => styleText2("gray", n2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}`;
|
|
1087
1345
|
case "selected":
|
|
1088
|
-
return `${
|
|
1346
|
+
return `${c(s, (n2) => styleText2("dim", n2))}`;
|
|
1089
1347
|
case "active":
|
|
1090
|
-
return `${
|
|
1348
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}`;
|
|
1091
1349
|
case "cancelled":
|
|
1092
|
-
return `${
|
|
1350
|
+
return `${c(s, (n2) => styleText2(["strikethrough", "dim"], n2))}`;
|
|
1093
1351
|
default:
|
|
1094
|
-
return `${
|
|
1352
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (n2) => styleText2("dim", n2))}`;
|
|
1095
1353
|
}
|
|
1096
1354
|
};
|
|
1097
|
-
return new
|
|
1098
|
-
|
|
1099
|
-
|
|
1355
|
+
return new a2({
|
|
1356
|
+
options: e.options,
|
|
1357
|
+
signal: e.signal,
|
|
1358
|
+
input: e.input,
|
|
1359
|
+
output: e.output,
|
|
1360
|
+
initialValue: e.initialValue,
|
|
1361
|
+
render() {
|
|
1362
|
+
const t2 = e.withGuide ?? settings.withGuide, d2 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n2 = wrapTextWithPrefix(
|
|
1363
|
+
e.output,
|
|
1364
|
+
e.message,
|
|
1365
|
+
s,
|
|
1366
|
+
d2
|
|
1367
|
+
), u3 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1368
|
+
` : ""}${n2}
|
|
1369
|
+
`;
|
|
1370
|
+
switch (this.state) {
|
|
1371
|
+
case "submit": {
|
|
1372
|
+
const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(
|
|
1373
|
+
e.output,
|
|
1374
|
+
a3(this.options[this.cursor], "selected"),
|
|
1375
|
+
r2
|
|
1376
|
+
);
|
|
1377
|
+
return `${u3}${l2}`;
|
|
1378
|
+
}
|
|
1379
|
+
case "cancel": {
|
|
1380
|
+
const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(
|
|
1381
|
+
e.output,
|
|
1382
|
+
a3(this.options[this.cursor], "cancelled"),
|
|
1383
|
+
r2
|
|
1384
|
+
);
|
|
1385
|
+
return `${u3}${l2}${t2 ? `
|
|
1386
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1387
|
+
}
|
|
1388
|
+
default: {
|
|
1389
|
+
const r2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = t2 ? styleText2("cyan", S_BAR_END) : "", g = u3.split(`
|
|
1390
|
+
`).length, h2 = t2 ? 2 : 1;
|
|
1391
|
+
return `${u3}${r2}${limitOptions({
|
|
1392
|
+
output: e.output,
|
|
1393
|
+
cursor: this.cursor,
|
|
1394
|
+
options: this.options,
|
|
1395
|
+
maxItems: e.maxItems,
|
|
1396
|
+
columnPadding: r2.length,
|
|
1397
|
+
rowPadding: g + h2,
|
|
1398
|
+
style: (p, b) => a3(p, p.disabled ? "disabled" : b ? "active" : "inactive")
|
|
1399
|
+
}).join(`
|
|
1400
|
+
${r2}`)}
|
|
1401
|
+
${l2}
|
|
1100
1402
|
`;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}).prompt();
|
|
1407
|
+
};
|
|
1408
|
+
var i = `${styleText2("gray", S_BAR)} `;
|
|
1409
|
+
var text = (t2) => new n({
|
|
1410
|
+
validate: t2.validate,
|
|
1411
|
+
placeholder: t2.placeholder,
|
|
1412
|
+
defaultValue: t2.defaultValue,
|
|
1413
|
+
initialValue: t2.initialValue,
|
|
1414
|
+
output: t2.output,
|
|
1415
|
+
signal: t2.signal,
|
|
1416
|
+
input: t2.input,
|
|
1417
|
+
render() {
|
|
1418
|
+
const i2 = t2?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
|
|
1419
|
+
` : ""}${symbol(this.state)} `}${t2.message}
|
|
1420
|
+
`, c2 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : c2, a3 = this.value ?? "";
|
|
1101
1421
|
switch (this.state) {
|
|
1422
|
+
case "error": {
|
|
1423
|
+
const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d2 = i2 ? styleText2("yellow", S_BAR_END) : "";
|
|
1424
|
+
return `${s.trim()}
|
|
1425
|
+
${r2}${o2}
|
|
1426
|
+
${d2}${n2}
|
|
1427
|
+
`;
|
|
1428
|
+
}
|
|
1102
1429
|
case "submit": {
|
|
1103
|
-
const
|
|
1104
|
-
return `${
|
|
1430
|
+
const n2 = a3 ? ` ${styleText2("dim", a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1431
|
+
return `${s}${r2}${n2}`;
|
|
1105
1432
|
}
|
|
1106
1433
|
case "cancel": {
|
|
1107
|
-
const
|
|
1108
|
-
return `${
|
|
1109
|
-
${
|
|
1434
|
+
const n2 = a3 ? ` ${styleText2(["strikethrough", "dim"], a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1435
|
+
return `${s}${r2}${n2}${a3.trim() ? `
|
|
1436
|
+
${r2}` : ""}`;
|
|
1110
1437
|
}
|
|
1111
1438
|
default: {
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
${c}`)}
|
|
1116
|
-
${o}
|
|
1439
|
+
const n2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
|
|
1440
|
+
return `${s}${n2}${o2}
|
|
1441
|
+
${r2}
|
|
1117
1442
|
`;
|
|
1118
1443
|
}
|
|
1119
1444
|
}
|
|
1120
|
-
} }).prompt();
|
|
1121
|
-
};
|
|
1122
|
-
var Bt = `${e("gray", $)} `;
|
|
1123
|
-
var Re = (t) => new ct({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
1124
|
-
const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${e("gray", $)}
|
|
1125
|
-
` : ""}${P2(this.state)} `}${t.message}
|
|
1126
|
-
`, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1127
|
-
switch (this.state) {
|
|
1128
|
-
case "error": {
|
|
1129
|
-
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $)} ` : "", o = i ? e("yellow", x2) : "";
|
|
1130
|
-
return `${s.trim()}
|
|
1131
|
-
${c}${u}
|
|
1132
|
-
${o}${a}
|
|
1133
|
-
`;
|
|
1134
|
-
}
|
|
1135
|
-
case "submit": {
|
|
1136
|
-
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $) : "";
|
|
1137
|
-
return `${s}${c}${a}`;
|
|
1138
|
-
}
|
|
1139
|
-
case "cancel": {
|
|
1140
|
-
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $) : "";
|
|
1141
|
-
return `${s}${c}${a}${n.trim() ? `
|
|
1142
|
-
${c}` : ""}`;
|
|
1143
|
-
}
|
|
1144
|
-
default: {
|
|
1145
|
-
const a = i ? `${e("cyan", $)} ` : "", c = i ? e("cyan", x2) : "";
|
|
1146
|
-
return `${s}${a}${u}
|
|
1147
|
-
${c}
|
|
1148
|
-
`;
|
|
1149
|
-
}
|
|
1150
1445
|
}
|
|
1151
|
-
}
|
|
1446
|
+
}).prompt();
|
|
1152
1447
|
|
|
1153
1448
|
// src/cli/configure.ts
|
|
1154
1449
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
@@ -1179,55 +1474,55 @@ var PKG_VERSION = {
|
|
|
1179
1474
|
var TAILWIND_ENTRY = "styles/tailwind.css";
|
|
1180
1475
|
var TAILWIND_CSS = `@import 'tailwindcss';
|
|
1181
1476
|
`;
|
|
1182
|
-
function styleEntry(
|
|
1183
|
-
return `styles/main.${STYLE_EXT[
|
|
1477
|
+
function styleEntry(p) {
|
|
1478
|
+
return `styles/main.${STYLE_EXT[p]}`;
|
|
1184
1479
|
}
|
|
1185
1480
|
function preprocessorForExt(ext) {
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1188
|
-
return PREPROCESSORS.find((
|
|
1481
|
+
const e = ext.replace(/^\./, "");
|
|
1482
|
+
if (e === "sass") return "sass";
|
|
1483
|
+
return PREPROCESSORS.find((p) => STYLE_EXT[p] === e) ?? null;
|
|
1189
1484
|
}
|
|
1190
|
-
function requiredPackages(
|
|
1485
|
+
function requiredPackages(f) {
|
|
1191
1486
|
const pkgs = [];
|
|
1192
|
-
const pp = PREPROCESSOR_PKG[
|
|
1487
|
+
const pp = PREPROCESSOR_PKG[f.preprocessor];
|
|
1193
1488
|
if (pp) pkgs.push(pp);
|
|
1194
|
-
if (
|
|
1489
|
+
if (f.tailwind) pkgs.push(...TAILWIND_PKGS);
|
|
1195
1490
|
return pkgs;
|
|
1196
1491
|
}
|
|
1197
1492
|
function packageDiff(from, to) {
|
|
1198
1493
|
const want = new Set(requiredPackages(to));
|
|
1199
1494
|
const had = new Set(requiredPackages(from));
|
|
1200
1495
|
return {
|
|
1201
|
-
add: [...want].filter((
|
|
1202
|
-
remove: [...had].filter((
|
|
1496
|
+
add: [...want].filter((p) => !had.has(p)),
|
|
1497
|
+
remove: [...had].filter((p) => !want.has(p))
|
|
1203
1498
|
};
|
|
1204
1499
|
}
|
|
1205
|
-
function styleImportLines(
|
|
1500
|
+
function styleImportLines(f) {
|
|
1206
1501
|
const lines = [];
|
|
1207
|
-
if (
|
|
1208
|
-
lines.push(`import './${styleEntry(
|
|
1502
|
+
if (f.tailwind) lines.push(`import './${TAILWIND_ENTRY}';`);
|
|
1503
|
+
lines.push(`import './${styleEntry(f.preprocessor)}';`);
|
|
1209
1504
|
return lines;
|
|
1210
1505
|
}
|
|
1211
|
-
function setStyleImports(source,
|
|
1506
|
+
function setStyleImports(source, f) {
|
|
1212
1507
|
const stripped = source.replace(
|
|
1213
1508
|
/^[ \t]*import\s+['"]\.\/styles\/[^'"]+['"];?[ \t]*\r?\n/gm,
|
|
1214
1509
|
""
|
|
1215
1510
|
);
|
|
1216
|
-
const
|
|
1511
|
+
const block2 = styleImportLines(f).join("\n") + "\n";
|
|
1217
1512
|
const lines = stripped.split("\n");
|
|
1218
|
-
const routesIdx = lines.findIndex((
|
|
1513
|
+
const routesIdx = lines.findIndex((l2) => /from\s+['"]toiljs\/routes['"]/.test(l2));
|
|
1219
1514
|
let insertAt;
|
|
1220
1515
|
if (routesIdx !== -1) {
|
|
1221
1516
|
insertAt = routesIdx + 1;
|
|
1222
1517
|
} else {
|
|
1223
|
-
const lastImport = lines.reduce((acc,
|
|
1518
|
+
const lastImport = lines.reduce((acc, l2, i2) => /^\s*import\s/.test(l2) ? i2 : acc, -1);
|
|
1224
1519
|
insertAt = lastImport + 1;
|
|
1225
1520
|
}
|
|
1226
1521
|
const head = lines.slice(0, insertAt).join("\n");
|
|
1227
1522
|
const tail = lines.slice(insertAt).join("\n");
|
|
1228
1523
|
return `${head}
|
|
1229
1524
|
|
|
1230
|
-
${
|
|
1525
|
+
${block2}
|
|
1231
1526
|
${tail}`.replace(/\n{3,}/g, "\n\n");
|
|
1232
1527
|
}
|
|
1233
1528
|
function defaultConfigSource(images) {
|
|
@@ -1286,17 +1581,17 @@ function capture(cmd, args, cwd) {
|
|
|
1286
1581
|
return new Promise((resolve, reject) => {
|
|
1287
1582
|
const onWindows = process.platform === "win32";
|
|
1288
1583
|
const child = onWindows ? spawn([cmd, ...args].join(" "), { cwd, shell: true }) : spawn(cmd, args, { cwd });
|
|
1289
|
-
let
|
|
1584
|
+
let stdout2 = "";
|
|
1290
1585
|
let stderr = "";
|
|
1291
|
-
child.stdout?.on("data", (
|
|
1292
|
-
|
|
1586
|
+
child.stdout?.on("data", (d2) => {
|
|
1587
|
+
stdout2 += d2.toString();
|
|
1293
1588
|
});
|
|
1294
|
-
child.stderr?.on("data", (
|
|
1295
|
-
stderr +=
|
|
1589
|
+
child.stderr?.on("data", (d2) => {
|
|
1590
|
+
stderr += d2.toString();
|
|
1296
1591
|
});
|
|
1297
1592
|
child.on("error", reject);
|
|
1298
1593
|
child.on("close", (code) => {
|
|
1299
|
-
resolve({ stdout, stderr, code: code ?? 1 });
|
|
1594
|
+
resolve({ stdout: stdout2, stderr, code: code ?? 1 });
|
|
1300
1595
|
});
|
|
1301
1596
|
});
|
|
1302
1597
|
}
|
|
@@ -1337,24 +1632,24 @@ function success(s) {
|
|
|
1337
1632
|
}
|
|
1338
1633
|
var danger = import_picocolors.default.red;
|
|
1339
1634
|
var warn = import_picocolors.default.yellow;
|
|
1340
|
-
function lerp(
|
|
1341
|
-
return Math.round(
|
|
1635
|
+
function lerp(a3, b, t2) {
|
|
1636
|
+
return Math.round(a3 + (b - a3) * t2);
|
|
1342
1637
|
}
|
|
1343
|
-
function gradientAt(
|
|
1638
|
+
function gradientAt(t2) {
|
|
1344
1639
|
const segments = GRADIENT.length - 1;
|
|
1345
|
-
const scaled =
|
|
1346
|
-
const
|
|
1347
|
-
const
|
|
1348
|
-
const
|
|
1349
|
-
const localT = scaled -
|
|
1350
|
-
return [lerp(
|
|
1640
|
+
const scaled = t2 * segments;
|
|
1641
|
+
const i2 = Math.min(Math.floor(scaled), segments - 1);
|
|
1642
|
+
const a3 = GRADIENT[i2];
|
|
1643
|
+
const b = GRADIENT[i2 + 1];
|
|
1644
|
+
const localT = scaled - i2;
|
|
1645
|
+
return [lerp(a3[0], b[0], localT), lerp(a3[1], b[1], localT), lerp(a3[2], b[2], localT)];
|
|
1351
1646
|
}
|
|
1352
1647
|
function gradientLine(line) {
|
|
1353
|
-
const
|
|
1648
|
+
const n2 = line.length;
|
|
1354
1649
|
let out = "";
|
|
1355
|
-
for (let
|
|
1356
|
-
const [
|
|
1357
|
-
out += `\x1B[38;2;${
|
|
1650
|
+
for (let i2 = 0; i2 < n2; i2++) {
|
|
1651
|
+
const [r2, g, b] = gradientAt(n2 > 1 ? i2 / (n2 - 1) : 0);
|
|
1652
|
+
out += `\x1B[38;2;${r2};${g};${b}m${line[i2]}`;
|
|
1358
1653
|
}
|
|
1359
1654
|
return out + "\x1B[39m";
|
|
1360
1655
|
}
|
|
@@ -1393,9 +1688,9 @@ var CONFIG_FILES = [
|
|
|
1393
1688
|
];
|
|
1394
1689
|
async function readConfigFile(root) {
|
|
1395
1690
|
for (const name of CONFIG_FILES) {
|
|
1396
|
-
const
|
|
1691
|
+
const p = path2.join(root, name);
|
|
1397
1692
|
try {
|
|
1398
|
-
return { path:
|
|
1693
|
+
return { path: p, source: await fs2.readFile(p, "utf8") };
|
|
1399
1694
|
} catch {
|
|
1400
1695
|
}
|
|
1401
1696
|
}
|
|
@@ -1434,16 +1729,16 @@ var PREPROCESSOR_LABEL = {
|
|
|
1434
1729
|
stylus: "Stylus"
|
|
1435
1730
|
};
|
|
1436
1731
|
function bail(value) {
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1732
|
+
if (isCancel(value)) {
|
|
1733
|
+
cancel("Configuration cancelled.");
|
|
1439
1734
|
process.exit(0);
|
|
1440
1735
|
}
|
|
1441
1736
|
}
|
|
1442
1737
|
async function detectStylesheet(clientDir) {
|
|
1443
|
-
for (const
|
|
1738
|
+
for (const p of PREPROCESSORS) {
|
|
1444
1739
|
try {
|
|
1445
|
-
await fs2.access(path2.join(clientDir, styleEntry(
|
|
1446
|
-
return
|
|
1740
|
+
await fs2.access(path2.join(clientDir, styleEntry(p)));
|
|
1741
|
+
return p;
|
|
1447
1742
|
} catch {
|
|
1448
1743
|
}
|
|
1449
1744
|
}
|
|
@@ -1456,10 +1751,10 @@ async function detectStylesheet(clientDir) {
|
|
|
1456
1751
|
}
|
|
1457
1752
|
async function findMainStylesheet(clientDir) {
|
|
1458
1753
|
for (const ext of ["css", "scss", "sass", "less", "styl"]) {
|
|
1459
|
-
const
|
|
1754
|
+
const p = path2.join(clientDir, "styles", `main.${ext}`);
|
|
1460
1755
|
try {
|
|
1461
|
-
await fs2.access(
|
|
1462
|
-
return
|
|
1756
|
+
await fs2.access(p);
|
|
1757
|
+
return p;
|
|
1463
1758
|
} catch {
|
|
1464
1759
|
}
|
|
1465
1760
|
}
|
|
@@ -1522,7 +1817,7 @@ async function applyPackages(pkgPath, pkg, from, to) {
|
|
|
1522
1817
|
delete deps[name];
|
|
1523
1818
|
}
|
|
1524
1819
|
const sortedDev = Object.fromEntries(
|
|
1525
|
-
Object.entries(dev2).sort(([
|
|
1820
|
+
Object.entries(dev2).sort(([a3], [b]) => a3.localeCompare(b))
|
|
1526
1821
|
);
|
|
1527
1822
|
const next = { ...pkg, devDependencies: sortedDev };
|
|
1528
1823
|
if (Object.keys(deps).length) next.dependencies = deps;
|
|
@@ -1542,17 +1837,17 @@ function describe(from, to) {
|
|
|
1542
1837
|
const { add, remove } = packageDiff(from, to);
|
|
1543
1838
|
if (add.length) lines.push(`+ ${add.join(", ")}`);
|
|
1544
1839
|
if (remove.length) lines.push(`- ${remove.join(", ")}`);
|
|
1545
|
-
return lines.map((
|
|
1840
|
+
return lines.map((l2) => dim(" ") + l2).join("\n");
|
|
1546
1841
|
}
|
|
1547
1842
|
async function runConfigure(opts) {
|
|
1548
|
-
|
|
1843
|
+
intro(accent(" toiljs configure "));
|
|
1549
1844
|
const root = path2.resolve(opts.root ?? opts.cwd);
|
|
1550
1845
|
const pkgPath = path2.join(root, "package.json");
|
|
1551
1846
|
let pkg;
|
|
1552
1847
|
try {
|
|
1553
1848
|
pkg = JSON.parse(await fs2.readFile(pkgPath, "utf8"));
|
|
1554
1849
|
} catch {
|
|
1555
|
-
|
|
1850
|
+
cancel(`No package.json in ${import_picocolors2.default.cyan(root)}, run this inside a toiljs project.`);
|
|
1556
1851
|
process.exit(1);
|
|
1557
1852
|
}
|
|
1558
1853
|
const clientAbsDir = await resolveClientDir(root);
|
|
@@ -1572,18 +1867,18 @@ async function runConfigure(opts) {
|
|
|
1572
1867
|
};
|
|
1573
1868
|
targetImages = opts.images ?? currentImages;
|
|
1574
1869
|
} else {
|
|
1575
|
-
const ppChoice = await
|
|
1870
|
+
const ppChoice = await select({
|
|
1576
1871
|
message: "CSS preprocessor",
|
|
1577
1872
|
options: PREPROCESSORS.map((value) => ({ value, label: PREPROCESSOR_LABEL[value] })),
|
|
1578
1873
|
initialValue: current.preprocessor
|
|
1579
1874
|
});
|
|
1580
1875
|
bail(ppChoice);
|
|
1581
|
-
const twChoice = await
|
|
1876
|
+
const twChoice = await confirm({
|
|
1582
1877
|
message: "Use Tailwind CSS?",
|
|
1583
1878
|
initialValue: current.tailwind
|
|
1584
1879
|
});
|
|
1585
1880
|
bail(twChoice);
|
|
1586
|
-
const imChoice = await
|
|
1881
|
+
const imChoice = await confirm({
|
|
1587
1882
|
message: "Optimize images at build time?",
|
|
1588
1883
|
initialValue: currentImages
|
|
1589
1884
|
});
|
|
@@ -1594,10 +1889,10 @@ async function runConfigure(opts) {
|
|
|
1594
1889
|
const styleChanged = target.preprocessor !== current.preprocessor || target.tailwind !== current.tailwind;
|
|
1595
1890
|
const imagesChanged = targetImages !== currentImages;
|
|
1596
1891
|
if (!styleChanged && !imagesChanged) {
|
|
1597
|
-
|
|
1892
|
+
outro("No changes, your setup is already up to date.");
|
|
1598
1893
|
return;
|
|
1599
1894
|
}
|
|
1600
|
-
const s =
|
|
1895
|
+
const s = spinner();
|
|
1601
1896
|
s.start("Updating project files");
|
|
1602
1897
|
if (styleChanged) await applyConfigure(clientAbsDir, pkgPath, pkg, current, target);
|
|
1603
1898
|
let imagesWarning = "";
|
|
@@ -1610,15 +1905,15 @@ async function runConfigure(opts) {
|
|
|
1610
1905
|
if (styleChanged) {
|
|
1611
1906
|
const pm = await detectPackageManager(root);
|
|
1612
1907
|
if (opts.install === false) {
|
|
1613
|
-
|
|
1908
|
+
note(`${import_picocolors2.default.cyan(`${pm} install`)} to sync the dependency changes.`, "Next step");
|
|
1614
1909
|
} else {
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1910
|
+
const i2 = spinner();
|
|
1911
|
+
i2.start(`Syncing dependencies with ${pm}`);
|
|
1617
1912
|
try {
|
|
1618
1913
|
await run(pm, ["install"], root);
|
|
1619
|
-
|
|
1914
|
+
i2.stop("Dependencies synced");
|
|
1620
1915
|
} catch {
|
|
1621
|
-
|
|
1916
|
+
i2.stop(import_picocolors2.default.yellow(`Could not run \`${pm} install\`, run it yourself to finish`));
|
|
1622
1917
|
}
|
|
1623
1918
|
}
|
|
1624
1919
|
}
|
|
@@ -1627,8 +1922,8 @@ async function runConfigure(opts) {
|
|
|
1627
1922
|
imagesChanged ? dim(" ") + `image optimization: ${currentImages ? "on" : "off"} \u2192 ${targetImages ? "on" : "off"}` : "",
|
|
1628
1923
|
imagesWarning
|
|
1629
1924
|
].filter(Boolean).join("\n");
|
|
1630
|
-
|
|
1631
|
-
|
|
1925
|
+
note(summary, "Updated");
|
|
1926
|
+
outro(`Reconfigured, restart \`${accent("toiljs dev")}\` to pick up the changes.`);
|
|
1632
1927
|
}
|
|
1633
1928
|
|
|
1634
1929
|
// src/cli/create.ts
|
|
@@ -1665,8 +1960,8 @@ var PREPROCESSOR_LABEL2 = {
|
|
|
1665
1960
|
};
|
|
1666
1961
|
var DEFAULT_STYLE_CONTENT = ":root {\n color-scheme: dark;\n}\n\nbody {\n margin: 0;\n background: #080d11;\n color: #f5f6fa;\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.6;\n}\n\na {\n color: #2563ff;\n text-decoration: none;\n}\n\na:hover {\n color: #22e3ab;\n}\n\ncode {\n background: #11161f;\n color: #22e3ab;\n padding: 0.1rem 0.4rem;\n border-radius: 4px;\n font-size: 0.9em;\n}\n\nh1 {\n background: linear-gradient(90deg, #2563ff, #7c3aed, #22e3ab);\n -webkit-background-clip: text;\n background-clip: text;\n color: transparent;\n}\n";
|
|
1667
1962
|
function bail2(value) {
|
|
1668
|
-
if (
|
|
1669
|
-
|
|
1963
|
+
if (isCancel(value)) {
|
|
1964
|
+
cancel("Scaffolding cancelled.");
|
|
1670
1965
|
process.exit(0);
|
|
1671
1966
|
}
|
|
1672
1967
|
}
|
|
@@ -1685,7 +1980,7 @@ function scaffold(name, template, features, aiTools, images) {
|
|
|
1685
1980
|
"@types/react-dom": "^19.2.3",
|
|
1686
1981
|
eslint: "^10.2.0",
|
|
1687
1982
|
prettier: "^3.8.1",
|
|
1688
|
-
toilscript: "^0.1.
|
|
1983
|
+
toilscript: "^0.1.13",
|
|
1689
1984
|
typescript: "^6.0.3"
|
|
1690
1985
|
};
|
|
1691
1986
|
for (const dep of requiredPackages(features).sort()) {
|
|
@@ -1697,9 +1992,8 @@ function scaffold(name, template, features, aiTools, images) {
|
|
|
1697
1992
|
type: "module",
|
|
1698
1993
|
scripts: {
|
|
1699
1994
|
dev: "toiljs dev",
|
|
1700
|
-
build: "toiljs build
|
|
1701
|
-
"build:
|
|
1702
|
-
"build:server": "toilscript --target release",
|
|
1995
|
+
build: "toiljs build",
|
|
1996
|
+
"build:server": "toilscript --target release --rpcModule shared/server.ts",
|
|
1703
1997
|
lint: "eslint client",
|
|
1704
1998
|
typecheck: "tsc --noEmit",
|
|
1705
1999
|
format: 'prettier --write "client/**/*.{ts,tsx,css,scss,less}" "client/public/**/*.html"'
|
|
@@ -1722,10 +2016,13 @@ export default defineConfig({
|
|
|
1722
2016
|
},
|
|
1723
2017
|
});
|
|
1724
2018
|
`,
|
|
1725
|
-
"tsconfig.json": '{\n "extends": "toiljs/tsconfig",\n "include": ["client", "toil-env.d.ts", "toil-routes.d.ts"]\n}\n',
|
|
2019
|
+
"tsconfig.json": '{\n "extends": "toiljs/tsconfig",\n "compilerOptions": {\n "paths": { "shared/*": ["./shared/*"] }\n },\n "include": ["client", "shared", "toil-env.d.ts", "toil-routes.d.ts"]\n}\n',
|
|
1726
2020
|
"eslint.config.js": "import toiljs from 'toiljs/eslint';\n\nexport default toiljs;\n",
|
|
1727
2021
|
".prettierrc": '"toiljs/prettier"\n',
|
|
1728
|
-
|
|
2022
|
+
// Generated files don't need formatting. (toilscript server decorators like @main /
|
|
2023
|
+
// @remote-on-functions are handled by the toiljs/prettier-plugin, so server/ is not ignored.)
|
|
2024
|
+
".prettierignore": "node_modules\nbuild\n.toil\nshared/server.ts\ntoil-env.d.ts\ntoil-routes.d.ts\n",
|
|
2025
|
+
".gitignore": "node_modules\nbuild\n.toil\nshared/server.ts\ntoil-env.d.ts\ntoil-routes.d.ts\n",
|
|
1729
2026
|
// Use the project's pinned TypeScript (node_modules) instead of VS Code's bundled version.
|
|
1730
2027
|
".vscode/settings.json": JSON.stringify({ "typescript.tsdk": "node_modules/typescript/lib" }, null, 4) + "\n",
|
|
1731
2028
|
"toil-env.d.ts": TOIL_ENV_DTS,
|
|
@@ -1898,18 +2195,18 @@ async function writeFiles(dir, files) {
|
|
|
1898
2195
|
}
|
|
1899
2196
|
}
|
|
1900
2197
|
async function runCreate(opts) {
|
|
1901
|
-
|
|
2198
|
+
intro(accent(" toiljs create "));
|
|
1902
2199
|
let name = opts.name;
|
|
1903
2200
|
if (!name) {
|
|
1904
2201
|
if (opts.yes) {
|
|
1905
2202
|
name = "my-toil-app";
|
|
1906
2203
|
} else {
|
|
1907
|
-
const answer = await
|
|
2204
|
+
const answer = await text({
|
|
1908
2205
|
message: "Project name",
|
|
1909
2206
|
placeholder: "my-toil-app",
|
|
1910
2207
|
defaultValue: "my-toil-app",
|
|
1911
|
-
validate: (
|
|
1912
|
-
const result = isValidName(
|
|
2208
|
+
validate: (v) => {
|
|
2209
|
+
const result = isValidName(v || "my-toil-app");
|
|
1913
2210
|
return result === true ? void 0 : result;
|
|
1914
2211
|
}
|
|
1915
2212
|
});
|
|
@@ -1919,27 +2216,27 @@ async function runCreate(opts) {
|
|
|
1919
2216
|
}
|
|
1920
2217
|
const valid = isValidName(name);
|
|
1921
2218
|
if (valid !== true) {
|
|
1922
|
-
|
|
2219
|
+
cancel(valid);
|
|
1923
2220
|
process.exit(1);
|
|
1924
2221
|
}
|
|
1925
2222
|
const targetDir = resolveProjectDir(opts.cwd, name);
|
|
1926
2223
|
if (targetDir === null) {
|
|
1927
|
-
|
|
2224
|
+
cancel('Project name must stay inside the current directory (no "..", no absolute paths).');
|
|
1928
2225
|
process.exit(1);
|
|
1929
2226
|
}
|
|
1930
2227
|
const rel = path4.relative(opts.cwd, targetDir) || ".";
|
|
1931
2228
|
if (!await isEmptyDir(targetDir)) {
|
|
1932
2229
|
if (opts.yes) {
|
|
1933
|
-
|
|
2230
|
+
cancel(`Directory ${import_picocolors3.default.cyan(rel)} is not empty.`);
|
|
1934
2231
|
process.exit(1);
|
|
1935
2232
|
}
|
|
1936
|
-
const proceed = await
|
|
2233
|
+
const proceed = await confirm({
|
|
1937
2234
|
message: `Directory ${import_picocolors3.default.cyan(rel)} is not empty. Scaffold into it anyway?`,
|
|
1938
2235
|
initialValue: false
|
|
1939
2236
|
});
|
|
1940
2237
|
bail2(proceed);
|
|
1941
2238
|
if (!proceed) {
|
|
1942
|
-
|
|
2239
|
+
cancel("Scaffolding cancelled.");
|
|
1943
2240
|
process.exit(0);
|
|
1944
2241
|
}
|
|
1945
2242
|
}
|
|
@@ -1953,7 +2250,7 @@ async function runCreate(opts) {
|
|
|
1953
2250
|
},
|
|
1954
2251
|
{ value: "minimal", label: "Minimal", hint: "just a layout and a home route" }
|
|
1955
2252
|
];
|
|
1956
|
-
const choice = await
|
|
2253
|
+
const choice = await select({
|
|
1957
2254
|
message: "Which template?",
|
|
1958
2255
|
options: templateOptions,
|
|
1959
2256
|
initialValue: "app"
|
|
@@ -1965,7 +2262,7 @@ async function runCreate(opts) {
|
|
|
1965
2262
|
let tailwind = opts.tailwind ?? false;
|
|
1966
2263
|
if (!opts.yes) {
|
|
1967
2264
|
if (opts.preprocessor === void 0) {
|
|
1968
|
-
const choice = await
|
|
2265
|
+
const choice = await select({
|
|
1969
2266
|
message: "Styling",
|
|
1970
2267
|
options: PREPROCESSORS.map((value) => ({
|
|
1971
2268
|
value,
|
|
@@ -1977,7 +2274,7 @@ async function runCreate(opts) {
|
|
|
1977
2274
|
preprocessor = choice;
|
|
1978
2275
|
}
|
|
1979
2276
|
if (opts.tailwind === void 0) {
|
|
1980
|
-
const tw = await
|
|
2277
|
+
const tw = await confirm({ message: "Add Tailwind CSS?", initialValue: false });
|
|
1981
2278
|
bail2(tw);
|
|
1982
2279
|
tailwind = tw;
|
|
1983
2280
|
}
|
|
@@ -1985,7 +2282,7 @@ async function runCreate(opts) {
|
|
|
1985
2282
|
const features = { preprocessor, tailwind };
|
|
1986
2283
|
let aiTools = opts.ai === false ? [] : [...AI_HELPER_IDS];
|
|
1987
2284
|
if (opts.ai === void 0 && !opts.yes) {
|
|
1988
|
-
const picked = await
|
|
2285
|
+
const picked = await multiselect({
|
|
1989
2286
|
message: "AI assistant files (read by Claude, Cursor, Codex, Copilot)",
|
|
1990
2287
|
options: [
|
|
1991
2288
|
...AI_HELPERS.map((h2) => ({ value: h2.id, label: h2.label })),
|
|
@@ -1999,7 +2296,7 @@ async function runCreate(opts) {
|
|
|
1999
2296
|
}
|
|
2000
2297
|
let images = opts.images ?? true;
|
|
2001
2298
|
if (opts.images === void 0 && !opts.yes) {
|
|
2002
|
-
const im = await
|
|
2299
|
+
const im = await confirm({ message: "Optimize images at build time?", initialValue: true });
|
|
2003
2300
|
bail2(im);
|
|
2004
2301
|
images = im;
|
|
2005
2302
|
}
|
|
@@ -2007,12 +2304,12 @@ async function runCreate(opts) {
|
|
|
2007
2304
|
let install = opts.install ?? false;
|
|
2008
2305
|
const pm = opts.pm ?? "npm";
|
|
2009
2306
|
if (!isPackageManager(pm)) {
|
|
2010
|
-
|
|
2307
|
+
cancel(`Unsupported package manager: ${pm} (use npm, pnpm, yarn, or bun).`);
|
|
2011
2308
|
process.exit(1);
|
|
2012
2309
|
}
|
|
2013
2310
|
if (!opts.yes) {
|
|
2014
2311
|
if (opts.git === void 0) {
|
|
2015
|
-
const g = await
|
|
2312
|
+
const g = await confirm({
|
|
2016
2313
|
message: "Initialize a git repository?",
|
|
2017
2314
|
initialValue: true
|
|
2018
2315
|
});
|
|
@@ -2020,12 +2317,12 @@ async function runCreate(opts) {
|
|
|
2020
2317
|
initGit = g;
|
|
2021
2318
|
}
|
|
2022
2319
|
if (opts.install === void 0) {
|
|
2023
|
-
const
|
|
2024
|
-
bail2(
|
|
2025
|
-
install =
|
|
2320
|
+
const i2 = await confirm({ message: "Install dependencies now?", initialValue: false });
|
|
2321
|
+
bail2(i2);
|
|
2322
|
+
install = i2;
|
|
2026
2323
|
}
|
|
2027
2324
|
}
|
|
2028
|
-
const s =
|
|
2325
|
+
const s = spinner();
|
|
2029
2326
|
s.start("Scaffolding project");
|
|
2030
2327
|
await writeFiles(targetDir, scaffold(name, template, features, aiTools, images));
|
|
2031
2328
|
if (template === "app") {
|
|
@@ -2040,7 +2337,7 @@ async function runCreate(opts) {
|
|
|
2040
2337
|
}
|
|
2041
2338
|
s.stop(`Scaffolded ${import_picocolors3.default.cyan(rel)}`);
|
|
2042
2339
|
if (initGit) {
|
|
2043
|
-
const g =
|
|
2340
|
+
const g = spinner();
|
|
2044
2341
|
g.start("Initializing git repository");
|
|
2045
2342
|
try {
|
|
2046
2343
|
await run("git", ["init", "-q"], targetDir);
|
|
@@ -2051,13 +2348,13 @@ async function runCreate(opts) {
|
|
|
2051
2348
|
}
|
|
2052
2349
|
}
|
|
2053
2350
|
if (install) {
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2351
|
+
const i2 = spinner();
|
|
2352
|
+
i2.start(`Installing dependencies with ${pm}`);
|
|
2056
2353
|
try {
|
|
2057
2354
|
await run(pm, ["install"], targetDir);
|
|
2058
|
-
|
|
2355
|
+
i2.stop("Installed dependencies");
|
|
2059
2356
|
} catch {
|
|
2060
|
-
|
|
2357
|
+
i2.stop(import_picocolors3.default.yellow(`Could not install with ${pm}, run it yourself later`));
|
|
2061
2358
|
install = false;
|
|
2062
2359
|
}
|
|
2063
2360
|
}
|
|
@@ -2066,8 +2363,8 @@ async function runCreate(opts) {
|
|
|
2066
2363
|
if (!install) steps.push("npm install");
|
|
2067
2364
|
steps.push(`${accent("npm run dev")} ${dim("start the dev server")}`);
|
|
2068
2365
|
steps.push(`${accent("npm run build")} ${dim("build for production")}`);
|
|
2069
|
-
|
|
2070
|
-
|
|
2366
|
+
note(steps.map((l2) => dim(" ") + l2).join("\n"), "Next steps");
|
|
2367
|
+
outro(`Created ${accent(path4.basename(name))}, happy building! ${dim("\xB7 v" + version())}`);
|
|
2071
2368
|
}
|
|
2072
2369
|
|
|
2073
2370
|
// src/cli/doctor.ts
|
|
@@ -2078,17 +2375,17 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
|
2078
2375
|
import { loadConfig as loadConfig2, scanRoutes } from "toiljs/compiler";
|
|
2079
2376
|
|
|
2080
2377
|
// src/cli/diagnostics.ts
|
|
2081
|
-
function parseVersion(
|
|
2082
|
-
const
|
|
2083
|
-
if (!
|
|
2084
|
-
return [Number(
|
|
2378
|
+
function parseVersion(v) {
|
|
2379
|
+
const m = /(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(v);
|
|
2380
|
+
if (!m) return [0, 0, 0];
|
|
2381
|
+
return [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)];
|
|
2085
2382
|
}
|
|
2086
2383
|
function satisfiesMin(version2, range) {
|
|
2087
|
-
const [
|
|
2088
|
-
const [
|
|
2089
|
-
if (
|
|
2090
|
-
if (
|
|
2091
|
-
return
|
|
2384
|
+
const [a3, b, c2] = parseVersion(version2);
|
|
2385
|
+
const [x, y, z] = parseVersion(range);
|
|
2386
|
+
if (a3 !== x) return a3 > x;
|
|
2387
|
+
if (b !== y) return b > y;
|
|
2388
|
+
return c2 >= z;
|
|
2092
2389
|
}
|
|
2093
2390
|
function checkNode(current, requiredRange) {
|
|
2094
2391
|
const ok = satisfiesMin(current, requiredRange);
|
|
@@ -2210,9 +2507,9 @@ function checkRoutesPresent(routeCount) {
|
|
|
2210
2507
|
function checkDuplicatePatterns(patterns) {
|
|
2211
2508
|
const seen = /* @__PURE__ */ new Set();
|
|
2212
2509
|
const dupes = /* @__PURE__ */ new Set();
|
|
2213
|
-
for (const
|
|
2214
|
-
if (seen.has(
|
|
2215
|
-
else seen.add(
|
|
2510
|
+
for (const p of patterns) {
|
|
2511
|
+
if (seen.has(p)) dupes.add(p);
|
|
2512
|
+
else seen.add(p);
|
|
2216
2513
|
}
|
|
2217
2514
|
return dupes.size === 0 ? { id: "route-dupes", label: "Unique route patterns", status: "pass" } : {
|
|
2218
2515
|
id: "route-dupes",
|
|
@@ -2236,13 +2533,13 @@ function findRelativeAssets(files) {
|
|
|
2236
2533
|
const attr = /\b(?:src|href)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
2237
2534
|
for (const file of files) {
|
|
2238
2535
|
const lines = file.source.split("\n");
|
|
2239
|
-
for (let
|
|
2536
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
2240
2537
|
attr.lastIndex = 0;
|
|
2241
|
-
let
|
|
2242
|
-
while ((
|
|
2243
|
-
const value =
|
|
2538
|
+
let m;
|
|
2539
|
+
while ((m = attr.exec(lines[i2])) !== null) {
|
|
2540
|
+
const value = m[1] ?? m[2] ?? "";
|
|
2244
2541
|
if (isBrokenRelativeAsset(value)) {
|
|
2245
|
-
issues.push({ file: file.path, line:
|
|
2542
|
+
issues.push({ file: file.path, line: i2 + 1, value });
|
|
2246
2543
|
}
|
|
2247
2544
|
}
|
|
2248
2545
|
}
|
|
@@ -2251,7 +2548,7 @@ function findRelativeAssets(files) {
|
|
|
2251
2548
|
}
|
|
2252
2549
|
function checkRelativeAssets(issues) {
|
|
2253
2550
|
if (issues.length === 0) return { id: "rel-assets", label: "Asset paths", status: "pass" };
|
|
2254
|
-
const shown = issues.slice(0, 5).map((
|
|
2551
|
+
const shown = issues.slice(0, 5).map((i2) => `${i2.file}:${String(i2.line)} "${i2.value}"`).join("; ");
|
|
2255
2552
|
const more = issues.length > 5 ? `, and ${String(issues.length - 5)} more` : "";
|
|
2256
2553
|
return {
|
|
2257
2554
|
id: "rel-assets",
|
|
@@ -2297,18 +2594,18 @@ function checkSeoUrl(seoConfigured, hasUrl) {
|
|
|
2297
2594
|
fix: "Set client.seo.url so sitemap.xml and canonical links are absolute."
|
|
2298
2595
|
};
|
|
2299
2596
|
}
|
|
2300
|
-
function checkStyling(
|
|
2597
|
+
function checkStyling(f) {
|
|
2301
2598
|
const label = "Styling";
|
|
2302
|
-
if (
|
|
2599
|
+
if (f.preprocessorImported && f.preprocessorImported !== "css" && !f.preprocessorInstalled) {
|
|
2303
2600
|
return {
|
|
2304
2601
|
id: "styling",
|
|
2305
2602
|
label,
|
|
2306
2603
|
status: "fail",
|
|
2307
|
-
detail: `${
|
|
2308
|
-
fix: `Install ${
|
|
2604
|
+
detail: `${f.preprocessorImported} stylesheet imported but ${f.preprocessorImported} is not installed`,
|
|
2605
|
+
fix: `Install ${f.preprocessorImported}, or run toiljs configure.`
|
|
2309
2606
|
};
|
|
2310
2607
|
}
|
|
2311
|
-
if (
|
|
2608
|
+
if (f.tailwindImported && !f.tailwindInstalled) {
|
|
2312
2609
|
return {
|
|
2313
2610
|
id: "styling",
|
|
2314
2611
|
label,
|
|
@@ -2355,6 +2652,45 @@ function checkWasmBuilt(exists) {
|
|
|
2355
2652
|
fix: "Run your server build (toilscript) before toiljs start."
|
|
2356
2653
|
};
|
|
2357
2654
|
}
|
|
2655
|
+
var RPC_TOILSCRIPT_MIN = "0.1.13";
|
|
2656
|
+
function checkRpcWiring(f) {
|
|
2657
|
+
const missing = [];
|
|
2658
|
+
if (!f.toilscriptOk) missing.push(`toilscript >=${RPC_TOILSCRIPT_MIN}`);
|
|
2659
|
+
if (!f.buildServerWired) missing.push("build:server --rpcModule");
|
|
2660
|
+
if (!f.tsconfigWired) missing.push("tsconfig shared/ + alias");
|
|
2661
|
+
if (!f.gitignoreWired) missing.push(".gitignore shared/server.ts");
|
|
2662
|
+
if (missing.length === 0) {
|
|
2663
|
+
return { id: "rpc-wiring", label: "typed RPC wiring", status: "pass" };
|
|
2664
|
+
}
|
|
2665
|
+
return {
|
|
2666
|
+
id: "rpc-wiring",
|
|
2667
|
+
label: "typed RPC wiring",
|
|
2668
|
+
status: "warn",
|
|
2669
|
+
detail: `missing: ${missing.join(", ")}`,
|
|
2670
|
+
fix: "Run `toiljs doctor --fix` to wire @data/@remote RPC (build:server, tsconfig, .gitignore, toilscript)."
|
|
2671
|
+
};
|
|
2672
|
+
}
|
|
2673
|
+
function checkPrettierPlugin(present) {
|
|
2674
|
+
return present ? { id: "prettier-plugin", label: "prettier toilscript plugin", status: "pass" } : {
|
|
2675
|
+
id: "prettier-plugin",
|
|
2676
|
+
label: "prettier toilscript plugin",
|
|
2677
|
+
status: "warn",
|
|
2678
|
+
detail: "prettier will fail on @main / @remote-on-function in server code",
|
|
2679
|
+
fix: "Run `toiljs doctor --fix` to add toiljs/prettier-plugin to your prettier config."
|
|
2680
|
+
};
|
|
2681
|
+
}
|
|
2682
|
+
function checkRestDispatch(f) {
|
|
2683
|
+
if (!f.hasControllers || f.dispatched) {
|
|
2684
|
+
return { id: "rest-dispatch", label: "REST dispatch wiring", status: "pass" };
|
|
2685
|
+
}
|
|
2686
|
+
return {
|
|
2687
|
+
id: "rest-dispatch",
|
|
2688
|
+
label: "REST dispatch wiring",
|
|
2689
|
+
status: "warn",
|
|
2690
|
+
detail: "@rest controllers found, but nothing calls Rest.dispatch(req) - their routes will not be served",
|
|
2691
|
+
fix: "In your handler add `const hit = Rest.dispatch(req); if (hit != null) return hit;`, or set `Server.handler = () => new RestHandler()`."
|
|
2692
|
+
};
|
|
2693
|
+
}
|
|
2358
2694
|
function summarize(groups) {
|
|
2359
2695
|
let pass = 0;
|
|
2360
2696
|
let warn2 = 0;
|
|
@@ -2384,7 +2720,7 @@ function readJsonObject(file) {
|
|
|
2384
2720
|
function stringRecord(value) {
|
|
2385
2721
|
if (typeof value !== "object" || value === null) return {};
|
|
2386
2722
|
const out = {};
|
|
2387
|
-
for (const [
|
|
2723
|
+
for (const [k, v] of Object.entries(value)) if (typeof v === "string") out[k] = v;
|
|
2388
2724
|
return out;
|
|
2389
2725
|
}
|
|
2390
2726
|
function readFile(file) {
|
|
@@ -2394,6 +2730,255 @@ function readFile(file) {
|
|
|
2394
2730
|
return null;
|
|
2395
2731
|
}
|
|
2396
2732
|
}
|
|
2733
|
+
function writeFile(file, content) {
|
|
2734
|
+
fs4.writeFileSync(file, content);
|
|
2735
|
+
}
|
|
2736
|
+
function isPackageInstalled(root, name) {
|
|
2737
|
+
const require2 = createRequire(path5.join(root, "package.json"));
|
|
2738
|
+
for (const id of [`${name}/package.json`, name]) {
|
|
2739
|
+
try {
|
|
2740
|
+
require2.resolve(id);
|
|
2741
|
+
return true;
|
|
2742
|
+
} catch {
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
for (let dir = root; ; ) {
|
|
2746
|
+
if (fs4.existsSync(path5.join(dir, "node_modules", name, "package.json"))) return true;
|
|
2747
|
+
const parent = path5.dirname(dir);
|
|
2748
|
+
if (parent === dir) return false;
|
|
2749
|
+
dir = parent;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
function asRecord(value) {
|
|
2753
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
2754
|
+
}
|
|
2755
|
+
var RPC_MODULE_FLAG = "--rpcModule shared/server.ts";
|
|
2756
|
+
var RPC_GITIGNORE_LINE = "shared/server.ts";
|
|
2757
|
+
var RPC_GITIGNORE_RE = /(^|\n)\s*shared\/server\.ts\s*(\r?\n|$)/;
|
|
2758
|
+
function looksLikeSemverRange(range) {
|
|
2759
|
+
return /^\s*[v^~>=<]*\s*\d+\.\d+/.test(range);
|
|
2760
|
+
}
|
|
2761
|
+
function gatherRpcFacts(root) {
|
|
2762
|
+
const pkg = readJsonObject(path5.join(root, "package.json"));
|
|
2763
|
+
const scripts = pkg ? stringRecord(pkg.scripts) : {};
|
|
2764
|
+
const deps = {
|
|
2765
|
+
...pkg ? stringRecord(pkg.dependencies) : {},
|
|
2766
|
+
...pkg ? stringRecord(pkg.devDependencies) : {}
|
|
2767
|
+
};
|
|
2768
|
+
const tsconfig = readJsonObject(path5.join(root, "tsconfig.json"));
|
|
2769
|
+
const gitignore = readFile(path5.join(root, ".gitignore"));
|
|
2770
|
+
const buildServerWired = [scripts["build:server"], scripts["build"]].some(
|
|
2771
|
+
(s) => typeof s === "string" && s.includes("--rpcModule")
|
|
2772
|
+
);
|
|
2773
|
+
let tsconfigWired = false;
|
|
2774
|
+
if (tsconfig) {
|
|
2775
|
+
const include = tsconfig.include;
|
|
2776
|
+
const hasShared = !Array.isArray(include) || include.includes("shared");
|
|
2777
|
+
const paths = asRecord(asRecord(tsconfig.compilerOptions)?.paths);
|
|
2778
|
+
tsconfigWired = hasShared && paths !== null && "shared/*" in paths;
|
|
2779
|
+
}
|
|
2780
|
+
const gitignoreWired = gitignore !== null && RPC_GITIGNORE_RE.test(gitignore);
|
|
2781
|
+
const range = deps.toilscript;
|
|
2782
|
+
const toilscriptOk = range == null ? false : looksLikeSemverRange(range) ? satisfiesMin(range, RPC_TOILSCRIPT_MIN) : true;
|
|
2783
|
+
return { buildServerWired, tsconfigWired, gitignoreWired, toilscriptOk };
|
|
2784
|
+
}
|
|
2785
|
+
function serverSources(root, toilconfig) {
|
|
2786
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
2787
|
+
const entries = Array.isArray(toilconfig?.entries) ? toilconfig.entries.filter((e) => typeof e === "string") : [];
|
|
2788
|
+
for (const e of entries) dirs.add(path5.dirname(path5.resolve(root, e)));
|
|
2789
|
+
const out = [];
|
|
2790
|
+
const cap = 200;
|
|
2791
|
+
const maxDepth = 16;
|
|
2792
|
+
const visit = (current, depth) => {
|
|
2793
|
+
if (out.length >= cap || depth > maxDepth) return;
|
|
2794
|
+
let listing;
|
|
2795
|
+
try {
|
|
2796
|
+
listing = fs4.readdirSync(current, { withFileTypes: true });
|
|
2797
|
+
} catch {
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
for (const entry of listing) {
|
|
2801
|
+
if (out.length >= cap) break;
|
|
2802
|
+
const full = path5.join(current, entry.name);
|
|
2803
|
+
if (entry.isDirectory()) {
|
|
2804
|
+
if (entry.name !== "node_modules") visit(full, depth + 1);
|
|
2805
|
+
} else if (entry.name.endsWith(".ts") && !entry.name.endsWith(".d.ts")) {
|
|
2806
|
+
const src = readFile(full);
|
|
2807
|
+
if (src !== null) out.push(src);
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
};
|
|
2811
|
+
for (const dir of dirs) visit(dir, 0);
|
|
2812
|
+
return out;
|
|
2813
|
+
}
|
|
2814
|
+
function gatherRestFacts(root, toilconfig) {
|
|
2815
|
+
let hasControllers = false;
|
|
2816
|
+
let dispatched = false;
|
|
2817
|
+
for (const src of serverSources(root, toilconfig)) {
|
|
2818
|
+
if (/@rest\b/.test(src)) hasControllers = true;
|
|
2819
|
+
if (/\bRest\s*\.\s*dispatch\s*\(/.test(src) || /\bRestHandler\b/.test(src))
|
|
2820
|
+
dispatched = true;
|
|
2821
|
+
if (hasControllers && dispatched) break;
|
|
2822
|
+
}
|
|
2823
|
+
return { hasControllers, dispatched };
|
|
2824
|
+
}
|
|
2825
|
+
function applyRpcFix(root) {
|
|
2826
|
+
const changed = [];
|
|
2827
|
+
const skipped = [];
|
|
2828
|
+
const pkgPath = path5.join(root, "package.json");
|
|
2829
|
+
const pkgRaw = readFile(pkgPath);
|
|
2830
|
+
const pkg = pkgRaw !== null ? readJsonObject(pkgPath) : null;
|
|
2831
|
+
if (pkg !== null) {
|
|
2832
|
+
let touched = false;
|
|
2833
|
+
const scripts = asRecord(pkg.scripts) ?? {};
|
|
2834
|
+
for (const key of ["build", "build:server"]) {
|
|
2835
|
+
const value = scripts[key];
|
|
2836
|
+
if (typeof value === "string" && value.includes("toilscript") && !value.includes("--rpcModule")) {
|
|
2837
|
+
scripts[key] = `${value} ${RPC_MODULE_FLAG}`;
|
|
2838
|
+
pkg.scripts = scripts;
|
|
2839
|
+
touched = true;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
let toilscriptDeclared = false;
|
|
2843
|
+
for (const field of ["devDependencies", "dependencies"]) {
|
|
2844
|
+
const bag = asRecord(pkg[field]);
|
|
2845
|
+
const current = bag?.toilscript;
|
|
2846
|
+
if (bag && typeof current === "string") {
|
|
2847
|
+
toilscriptDeclared = true;
|
|
2848
|
+
if (looksLikeSemverRange(current) && !satisfiesMin(current, RPC_TOILSCRIPT_MIN)) {
|
|
2849
|
+
bag.toilscript = `^${RPC_TOILSCRIPT_MIN}`;
|
|
2850
|
+
touched = true;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
if (!toilscriptDeclared) {
|
|
2855
|
+
const dd = asRecord(pkg.devDependencies) ?? {};
|
|
2856
|
+
dd.toilscript = `^${RPC_TOILSCRIPT_MIN}`;
|
|
2857
|
+
pkg.devDependencies = dd;
|
|
2858
|
+
touched = true;
|
|
2859
|
+
}
|
|
2860
|
+
if (touched) {
|
|
2861
|
+
writeFile(pkgPath, JSON.stringify(pkg, null, 4) + "\n");
|
|
2862
|
+
changed.push("package.json");
|
|
2863
|
+
}
|
|
2864
|
+
} else if (pkgRaw !== null) {
|
|
2865
|
+
skipped.push("package.json (unparseable)");
|
|
2866
|
+
}
|
|
2867
|
+
const tsPath = path5.join(root, "tsconfig.json");
|
|
2868
|
+
const tsRaw = readFile(tsPath);
|
|
2869
|
+
const tsconfig = tsRaw !== null ? readJsonObject(tsPath) : null;
|
|
2870
|
+
if (tsconfig !== null) {
|
|
2871
|
+
let touched = false;
|
|
2872
|
+
if (Array.isArray(tsconfig.include)) {
|
|
2873
|
+
const include = [...tsconfig.include];
|
|
2874
|
+
if (!include.includes("shared")) {
|
|
2875
|
+
const at = include.indexOf("client");
|
|
2876
|
+
include.splice(at >= 0 ? at + 1 : include.length, 0, "shared");
|
|
2877
|
+
tsconfig.include = include;
|
|
2878
|
+
touched = true;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
const co = asRecord(tsconfig.compilerOptions) ?? {};
|
|
2882
|
+
const paths = asRecord(co.paths) ?? {};
|
|
2883
|
+
if (!("shared/*" in paths)) {
|
|
2884
|
+
paths["shared/*"] = ["./shared/*"];
|
|
2885
|
+
co.paths = paths;
|
|
2886
|
+
tsconfig.compilerOptions = co;
|
|
2887
|
+
touched = true;
|
|
2888
|
+
}
|
|
2889
|
+
if (touched) {
|
|
2890
|
+
writeFile(tsPath, JSON.stringify(tsconfig, null, 4) + "\n");
|
|
2891
|
+
changed.push("tsconfig.json");
|
|
2892
|
+
}
|
|
2893
|
+
} else if (tsRaw !== null) {
|
|
2894
|
+
skipped.push('tsconfig.json (JSON with comments, add "shared" + paths by hand)');
|
|
2895
|
+
}
|
|
2896
|
+
const giPath = path5.join(root, ".gitignore");
|
|
2897
|
+
const giRaw = readFile(giPath);
|
|
2898
|
+
if (giRaw === null) {
|
|
2899
|
+
writeFile(giPath, `${RPC_GITIGNORE_LINE}
|
|
2900
|
+
`);
|
|
2901
|
+
changed.push(".gitignore");
|
|
2902
|
+
} else if (!RPC_GITIGNORE_RE.test(giRaw)) {
|
|
2903
|
+
const sep = giRaw.length === 0 || giRaw.endsWith("\n") ? "" : "\n";
|
|
2904
|
+
writeFile(giPath, `${giRaw}${sep}${RPC_GITIGNORE_LINE}
|
|
2905
|
+
`);
|
|
2906
|
+
changed.push(".gitignore");
|
|
2907
|
+
}
|
|
2908
|
+
return { changed, skipped };
|
|
2909
|
+
}
|
|
2910
|
+
var PRETTIER_PLUGIN = "toiljs/prettier-plugin";
|
|
2911
|
+
var PRETTIER_MENTION = /toiljs\/prettier(-plugin)?/;
|
|
2912
|
+
var PRETTIER_CONFIG_FILES = [
|
|
2913
|
+
".prettierrc",
|
|
2914
|
+
".prettierrc.json",
|
|
2915
|
+
".prettierrc.json5",
|
|
2916
|
+
".prettierrc.yaml",
|
|
2917
|
+
".prettierrc.yml",
|
|
2918
|
+
".prettierrc.js",
|
|
2919
|
+
".prettierrc.cjs",
|
|
2920
|
+
".prettierrc.mjs",
|
|
2921
|
+
".prettierrc.ts",
|
|
2922
|
+
"prettier.config.js",
|
|
2923
|
+
"prettier.config.cjs",
|
|
2924
|
+
"prettier.config.mjs",
|
|
2925
|
+
"prettier.config.ts"
|
|
2926
|
+
];
|
|
2927
|
+
function prettierPluginPresent(root, pkg) {
|
|
2928
|
+
if (pkg && pkg.prettier !== void 0 && PRETTIER_MENTION.test(JSON.stringify(pkg.prettier))) {
|
|
2929
|
+
return true;
|
|
2930
|
+
}
|
|
2931
|
+
for (const name of PRETTIER_CONFIG_FILES) {
|
|
2932
|
+
const raw = readFile(path5.join(root, name));
|
|
2933
|
+
if (raw !== null && PRETTIER_MENTION.test(raw)) return true;
|
|
2934
|
+
}
|
|
2935
|
+
return false;
|
|
2936
|
+
}
|
|
2937
|
+
function applyPrettierFix(root, pkg) {
|
|
2938
|
+
const changed = [];
|
|
2939
|
+
const skipped = [];
|
|
2940
|
+
if (prettierPluginPresent(root, pkg)) return { changed, skipped };
|
|
2941
|
+
const pkgPath = path5.join(root, "package.json");
|
|
2942
|
+
const pkgConfig = pkg ? asRecord(pkg.prettier) : null;
|
|
2943
|
+
if (pkgConfig !== null) {
|
|
2944
|
+
const full = readJsonObject(pkgPath);
|
|
2945
|
+
const target = full ? asRecord(full.prettier) : null;
|
|
2946
|
+
if (full && target) {
|
|
2947
|
+
target.plugins = [
|
|
2948
|
+
...Array.isArray(target.plugins) ? target.plugins : [],
|
|
2949
|
+
PRETTIER_PLUGIN
|
|
2950
|
+
];
|
|
2951
|
+
writeFile(pkgPath, JSON.stringify(full, null, 4) + "\n");
|
|
2952
|
+
changed.push("package.json");
|
|
2953
|
+
return { changed, skipped };
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
for (const name of [".prettierrc", ".prettierrc.json"]) {
|
|
2957
|
+
const filePath = path5.join(root, name);
|
|
2958
|
+
const raw = readFile(filePath);
|
|
2959
|
+
if (raw === null) continue;
|
|
2960
|
+
const obj = readJsonObject(filePath);
|
|
2961
|
+
if (obj === null) {
|
|
2962
|
+
skipped.push(`${name} (add "${PRETTIER_PLUGIN}" to plugins by hand)`);
|
|
2963
|
+
return { changed, skipped };
|
|
2964
|
+
}
|
|
2965
|
+
obj.plugins = [...Array.isArray(obj.plugins) ? obj.plugins : [], PRETTIER_PLUGIN];
|
|
2966
|
+
writeFile(filePath, JSON.stringify(obj, null, 4) + "\n");
|
|
2967
|
+
changed.push(name);
|
|
2968
|
+
return { changed, skipped };
|
|
2969
|
+
}
|
|
2970
|
+
const jsConfig = PRETTIER_CONFIG_FILES.find((name) => readFile(path5.join(root, name)) !== null);
|
|
2971
|
+
if (jsConfig) {
|
|
2972
|
+
skipped.push(`${jsConfig} (add "${PRETTIER_PLUGIN}" to its plugins by hand)`);
|
|
2973
|
+
return { changed, skipped };
|
|
2974
|
+
}
|
|
2975
|
+
writeFile(
|
|
2976
|
+
path5.join(root, ".prettierrc.json"),
|
|
2977
|
+
JSON.stringify({ plugins: [PRETTIER_PLUGIN] }, null, 4) + "\n"
|
|
2978
|
+
);
|
|
2979
|
+
changed.push(".prettierrc.json");
|
|
2980
|
+
return { changed, skipped };
|
|
2981
|
+
}
|
|
2397
2982
|
function frameworkMeta() {
|
|
2398
2983
|
const pkgPath = path5.resolve(
|
|
2399
2984
|
path5.dirname(fileURLToPath3(import.meta.url)),
|
|
@@ -2487,7 +3072,7 @@ async function runDoctor(opts) {
|
|
|
2487
3072
|
const entrySource = readEntry(clientAbsDir);
|
|
2488
3073
|
const indexHtml = readFile(path5.join(publicDir, "index.html"));
|
|
2489
3074
|
const routes = scanRoutes(routesAbsDir);
|
|
2490
|
-
const mainPatterns = routes.filter((
|
|
3075
|
+
const mainPatterns = routes.filter((r2) => r2.slot === void 0).map((r2) => r2.pattern);
|
|
2491
3076
|
const assetIssues = findRelativeAssets(collectSources(root, clientAbsDir, 200));
|
|
2492
3077
|
let preprocessorImported = null;
|
|
2493
3078
|
let tailwindImported = false;
|
|
@@ -2504,14 +3089,9 @@ async function runDoctor(opts) {
|
|
|
2504
3089
|
let toilscriptInstalled = false;
|
|
2505
3090
|
let wasmExists = false;
|
|
2506
3091
|
if (toilconfig) {
|
|
2507
|
-
const entries = Array.isArray(toilconfig.entries) ? toilconfig.entries.filter((
|
|
2508
|
-
missingEntries = entries.filter((
|
|
2509
|
-
|
|
2510
|
-
createRequire(path5.join(root, "package.json")).resolve("toilscript");
|
|
2511
|
-
toilscriptInstalled = true;
|
|
2512
|
-
} catch {
|
|
2513
|
-
toilscriptInstalled = false;
|
|
2514
|
-
}
|
|
3092
|
+
const entries = Array.isArray(toilconfig.entries) ? toilconfig.entries.filter((e) => typeof e === "string") : [];
|
|
3093
|
+
missingEntries = entries.filter((e) => !fs4.existsSync(path5.join(root, e)));
|
|
3094
|
+
toilscriptInstalled = isPackageInstalled(root, "toilscript");
|
|
2515
3095
|
const targets = typeof toilconfig.targets === "object" && toilconfig.targets !== null ? toilconfig.targets : {};
|
|
2516
3096
|
const outFiles = [];
|
|
2517
3097
|
for (const target of Object.values(targets)) {
|
|
@@ -2520,17 +3100,29 @@ async function runDoctor(opts) {
|
|
|
2520
3100
|
if (typeof outFile === "string") outFiles.push(outFile);
|
|
2521
3101
|
}
|
|
2522
3102
|
}
|
|
2523
|
-
wasmExists = outFiles.some((
|
|
3103
|
+
wasmExists = outFiles.some((f) => fs4.existsSync(path5.join(root, f)));
|
|
2524
3104
|
if (!wasmExists && outFiles.length === 0) {
|
|
2525
3105
|
try {
|
|
2526
|
-
wasmExists = fs4.readdirSync(path5.join(root, "build", "server")).some((
|
|
3106
|
+
wasmExists = fs4.readdirSync(path5.join(root, "build", "server")).some((f) => f.endsWith(".wasm"));
|
|
2527
3107
|
} catch {
|
|
2528
3108
|
wasmExists = false;
|
|
2529
3109
|
}
|
|
2530
3110
|
}
|
|
2531
3111
|
}
|
|
2532
|
-
const peerName = (
|
|
3112
|
+
const peerName = (n2) => checkPeer(n2, deps[n2] ?? null, meta.peers[n2] ?? "*");
|
|
2533
3113
|
const peerChecks = Object.keys(meta.peers).map(peerName);
|
|
3114
|
+
const rpcFix = serverPresent && opts.fix ? applyRpcFix(root) : null;
|
|
3115
|
+
const prettierFix = serverPresent && opts.fix ? applyPrettierFix(root, projectPkg) : null;
|
|
3116
|
+
const rpcFacts = gatherRpcFacts(root);
|
|
3117
|
+
const restFacts = gatherRestFacts(root, toilconfig);
|
|
3118
|
+
const prettierPresent = prettierPluginPresent(
|
|
3119
|
+
root,
|
|
3120
|
+
readJsonObject(path5.join(root, "package.json"))
|
|
3121
|
+
);
|
|
3122
|
+
const serverFix = rpcFix || prettierFix ? {
|
|
3123
|
+
changed: [...rpcFix?.changed ?? [], ...prettierFix?.changed ?? []],
|
|
3124
|
+
skipped: [...rpcFix?.skipped ?? [], ...prettierFix?.skipped ?? []]
|
|
3125
|
+
} : null;
|
|
2534
3126
|
const groups = [
|
|
2535
3127
|
{
|
|
2536
3128
|
title: "Environment",
|
|
@@ -2538,7 +3130,7 @@ async function runDoctor(opts) {
|
|
|
2538
3130
|
checkNode(process.versions.node, meta.node),
|
|
2539
3131
|
checkToiljsInstalled("toiljs" in deps ? version() : null),
|
|
2540
3132
|
...peerChecks,
|
|
2541
|
-
checkPackageManager(LOCKFILES.filter((
|
|
3133
|
+
checkPackageManager(LOCKFILES.filter((f) => fs4.existsSync(path5.join(root, f))))
|
|
2542
3134
|
]
|
|
2543
3135
|
},
|
|
2544
3136
|
{
|
|
@@ -2583,29 +3175,53 @@ async function runDoctor(opts) {
|
|
|
2583
3175
|
checkToilconfig(true),
|
|
2584
3176
|
checkServerEntry(missingEntries),
|
|
2585
3177
|
checkToilscriptInstalled(toilscriptInstalled),
|
|
2586
|
-
checkWasmBuilt(wasmExists)
|
|
3178
|
+
checkWasmBuilt(wasmExists),
|
|
3179
|
+
checkRpcWiring(rpcFacts),
|
|
3180
|
+
checkRestDispatch(restFacts),
|
|
3181
|
+
checkPrettierPlugin(prettierPresent)
|
|
2587
3182
|
] : [checkToilconfig(false)]
|
|
2588
3183
|
}
|
|
2589
3184
|
];
|
|
2590
3185
|
const summary = summarize(groups);
|
|
2591
3186
|
if (opts.json) {
|
|
2592
|
-
process.stdout.write(JSON.stringify({ groups, summary }, null, 2) + "\n");
|
|
3187
|
+
process.stdout.write(JSON.stringify({ groups, summary, fixed: serverFix }, null, 2) + "\n");
|
|
2593
3188
|
} else {
|
|
2594
3189
|
process.stdout.write("\n" + accent(" Doctor") + dim(` ${root}`) + "\n\n");
|
|
2595
3190
|
renderHuman(groups);
|
|
3191
|
+
if (serverFix) renderRpcFix(serverFix);
|
|
3192
|
+
else if (opts.fix && !serverPresent) {
|
|
3193
|
+
process.stdout.write(
|
|
3194
|
+
" " + dim("--fix: no server (toilconfig.json) found, nothing to wire.") + "\n\n"
|
|
3195
|
+
);
|
|
3196
|
+
}
|
|
2596
3197
|
}
|
|
2597
3198
|
if (hasFailures(summary)) process.exitCode = 1;
|
|
2598
3199
|
}
|
|
3200
|
+
function renderRpcFix(result) {
|
|
3201
|
+
const out = [];
|
|
3202
|
+
if (result.changed.length > 0) {
|
|
3203
|
+
out.push(" " + success("fixed RPC wiring") + dim(` ${result.changed.join(", ")}`));
|
|
3204
|
+
if (result.changed.includes("package.json")) {
|
|
3205
|
+
out.push(
|
|
3206
|
+
" " + dim("run your installer (npm/pnpm/yarn) if the toilscript version changed.")
|
|
3207
|
+
);
|
|
3208
|
+
}
|
|
3209
|
+
} else {
|
|
3210
|
+
out.push(" " + dim("RPC wiring already in place, nothing to fix."));
|
|
3211
|
+
}
|
|
3212
|
+
for (const item of result.skipped) out.push(" " + warn("skipped") + dim(` ${item}`));
|
|
3213
|
+
process.stdout.write(out.join("\n") + "\n\n");
|
|
3214
|
+
}
|
|
2599
3215
|
|
|
2600
3216
|
// src/cli/update.ts
|
|
2601
3217
|
import fs5 from "node:fs";
|
|
2602
3218
|
import path6 from "node:path";
|
|
2603
3219
|
|
|
2604
3220
|
// src/cli/updates.ts
|
|
2605
|
-
function parseVersion2(
|
|
2606
|
-
const
|
|
2607
|
-
if (!
|
|
2608
|
-
return [Number(
|
|
3221
|
+
function parseVersion2(v) {
|
|
3222
|
+
const m = /(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(v);
|
|
3223
|
+
if (!m) return [0, 0, 0];
|
|
3224
|
+
return [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)];
|
|
2609
3225
|
}
|
|
2610
3226
|
function classifyBump(from, to) {
|
|
2611
3227
|
const [fa, fb, fc] = parseVersion2(from);
|
|
@@ -2615,15 +3231,15 @@ function classifyBump(from, to) {
|
|
|
2615
3231
|
if (tc !== fc) return "patch";
|
|
2616
3232
|
return "other";
|
|
2617
3233
|
}
|
|
2618
|
-
function parseNcuJson(
|
|
2619
|
-
const start2 =
|
|
2620
|
-
const end =
|
|
3234
|
+
function parseNcuJson(stdout2) {
|
|
3235
|
+
const start2 = stdout2.indexOf("{");
|
|
3236
|
+
const end = stdout2.lastIndexOf("}");
|
|
2621
3237
|
if (start2 === -1 || end <= start2) return {};
|
|
2622
3238
|
try {
|
|
2623
|
-
const parsed = JSON.parse(
|
|
3239
|
+
const parsed = JSON.parse(stdout2.slice(start2, end + 1));
|
|
2624
3240
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
2625
3241
|
const out = {};
|
|
2626
|
-
for (const [
|
|
3242
|
+
for (const [k, v] of Object.entries(parsed)) if (typeof v === "string") out[k] = v;
|
|
2627
3243
|
return out;
|
|
2628
3244
|
} catch {
|
|
2629
3245
|
return {};
|
|
@@ -2634,7 +3250,7 @@ function buildRows(upgraded, currentDeps) {
|
|
|
2634
3250
|
return Object.entries(upgraded).map(([name, to]) => {
|
|
2635
3251
|
const from = currentDeps[name] ?? "?";
|
|
2636
3252
|
return { name, from, to, bump: classifyBump(from, to) };
|
|
2637
|
-
}).sort((
|
|
3253
|
+
}).sort((a3, b) => SEVERITY[a3.bump] - SEVERITY[b.bump] || a3.name.localeCompare(b.name));
|
|
2638
3254
|
}
|
|
2639
3255
|
|
|
2640
3256
|
// src/cli/update.ts
|
|
@@ -2648,19 +3264,19 @@ function readDependencies(pkgPath) {
|
|
|
2648
3264
|
const parsed = JSON.parse(fs5.readFileSync(pkgPath, "utf8"));
|
|
2649
3265
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
2650
3266
|
const pkg = parsed;
|
|
2651
|
-
const merge = (
|
|
2652
|
-
if (typeof
|
|
3267
|
+
const merge = (v) => {
|
|
3268
|
+
if (typeof v !== "object" || v === null) return {};
|
|
2653
3269
|
const out = {};
|
|
2654
|
-
for (const [
|
|
3270
|
+
for (const [k, val] of Object.entries(v)) if (typeof val === "string") out[k] = val;
|
|
2655
3271
|
return out;
|
|
2656
3272
|
};
|
|
2657
3273
|
return { ...merge(pkg.dependencies), ...merge(pkg.devDependencies) };
|
|
2658
3274
|
}
|
|
2659
|
-
function bumpColor(bump,
|
|
2660
|
-
if (bump === "major") return danger(
|
|
2661
|
-
if (bump === "minor") return warn(
|
|
2662
|
-
if (bump === "patch") return success(
|
|
2663
|
-
return dim(
|
|
3275
|
+
function bumpColor(bump, text2) {
|
|
3276
|
+
if (bump === "major") return danger(text2);
|
|
3277
|
+
if (bump === "minor") return warn(text2);
|
|
3278
|
+
if (bump === "patch") return success(text2);
|
|
3279
|
+
return dim(text2);
|
|
2664
3280
|
}
|
|
2665
3281
|
function rowLine(row) {
|
|
2666
3282
|
return `${row.name} ${dim(row.from)} ${dim("->")} ${bumpColor(row.bump, row.to)}`;
|
|
@@ -2684,51 +3300,51 @@ async function runUpdate(opts) {
|
|
|
2684
3300
|
target,
|
|
2685
3301
|
...extra
|
|
2686
3302
|
];
|
|
2687
|
-
|
|
2688
|
-
const s =
|
|
3303
|
+
intro(accent("toiljs update"));
|
|
3304
|
+
const s = spinner();
|
|
2689
3305
|
s.start("Checking the registry for updates");
|
|
2690
3306
|
const res = await capture("npx", ncuArgs(["--jsonUpgraded"]), root);
|
|
2691
3307
|
if (res.code !== 0 && res.stdout.indexOf("{") === -1) {
|
|
2692
3308
|
s.stop("Could not check for updates");
|
|
2693
|
-
|
|
3309
|
+
note(dim(res.stderr.trim() || "npm-check-updates failed."), "Error");
|
|
2694
3310
|
process.exitCode = 1;
|
|
2695
3311
|
return;
|
|
2696
3312
|
}
|
|
2697
3313
|
const rows = buildRows(parseNcuJson(res.stdout), currentDeps);
|
|
2698
3314
|
if (rows.length === 0) {
|
|
2699
3315
|
s.stop("Everything is up to date");
|
|
2700
|
-
|
|
3316
|
+
outro(success("Nothing to update."));
|
|
2701
3317
|
return;
|
|
2702
3318
|
}
|
|
2703
3319
|
s.stop(`${String(rows.length)} update${rows.length === 1 ? "" : "s"} available`);
|
|
2704
3320
|
const counts = { major: 0, minor: 0, patch: 0, other: 0 };
|
|
2705
|
-
for (const
|
|
2706
|
-
|
|
3321
|
+
for (const r2 of rows) counts[r2.bump]++;
|
|
3322
|
+
note(
|
|
2707
3323
|
rows.map(rowLine).join("\n"),
|
|
2708
3324
|
`${danger(`${String(counts.major)} major`)} ${warn(`${String(counts.minor)} minor`)} ${success(`${String(counts.patch)} patch`)}`
|
|
2709
3325
|
);
|
|
2710
3326
|
let selected;
|
|
2711
3327
|
if (opts.yes) {
|
|
2712
|
-
selected = rows.map((
|
|
3328
|
+
selected = rows.map((r2) => r2.name);
|
|
2713
3329
|
} else {
|
|
2714
|
-
const answer = await
|
|
3330
|
+
const answer = await multiselect({
|
|
2715
3331
|
message: "Select packages to update (space to toggle, enter to confirm)",
|
|
2716
|
-
options: rows.map((
|
|
2717
|
-
value:
|
|
2718
|
-
label:
|
|
2719
|
-
hint: `${
|
|
3332
|
+
options: rows.map((r2) => ({
|
|
3333
|
+
value: r2.name,
|
|
3334
|
+
label: r2.name,
|
|
3335
|
+
hint: `${r2.from} -> ${r2.to}`
|
|
2720
3336
|
})),
|
|
2721
|
-
initialValues: rows.map((
|
|
3337
|
+
initialValues: rows.map((r2) => r2.name),
|
|
2722
3338
|
required: false
|
|
2723
3339
|
});
|
|
2724
|
-
if (
|
|
2725
|
-
|
|
3340
|
+
if (isCancel(answer)) {
|
|
3341
|
+
cancel("Update cancelled.");
|
|
2726
3342
|
return;
|
|
2727
3343
|
}
|
|
2728
3344
|
selected = answer;
|
|
2729
3345
|
}
|
|
2730
3346
|
if (selected.length === 0) {
|
|
2731
|
-
|
|
3347
|
+
outro(dim("No packages selected."));
|
|
2732
3348
|
return;
|
|
2733
3349
|
}
|
|
2734
3350
|
s.start("Updating package.json");
|
|
@@ -2738,7 +3354,7 @@ async function runUpdate(opts) {
|
|
|
2738
3354
|
s.start(`Installing with ${pm.name}`);
|
|
2739
3355
|
await run(pm.name, ["install"], root);
|
|
2740
3356
|
s.stop("Dependencies installed");
|
|
2741
|
-
|
|
3357
|
+
outro(
|
|
2742
3358
|
success(`Updated ${String(selected.length)} package${selected.length === 1 ? "" : "s"}.`)
|
|
2743
3359
|
);
|
|
2744
3360
|
}
|
|
@@ -2746,28 +3362,31 @@ async function runUpdate(opts) {
|
|
|
2746
3362
|
// src/cli/index.ts
|
|
2747
3363
|
function parseArgs(argv) {
|
|
2748
3364
|
const flags = {};
|
|
2749
|
-
for (let
|
|
2750
|
-
const arg = argv[
|
|
3365
|
+
for (let i2 = 0; i2 < argv.length; i2++) {
|
|
3366
|
+
const arg = argv[i2];
|
|
2751
3367
|
switch (arg) {
|
|
2752
3368
|
case "--root":
|
|
2753
|
-
flags.root = argv[++
|
|
3369
|
+
flags.root = argv[++i2];
|
|
2754
3370
|
break;
|
|
2755
3371
|
case "--port": {
|
|
2756
|
-
const port = Number(argv[++
|
|
3372
|
+
const port = Number(argv[++i2]);
|
|
2757
3373
|
if (!Number.isNaN(port)) flags.port = port;
|
|
2758
3374
|
break;
|
|
2759
3375
|
}
|
|
3376
|
+
case "--host":
|
|
3377
|
+
flags.host = argv[++i2];
|
|
3378
|
+
break;
|
|
2760
3379
|
case "--template":
|
|
2761
3380
|
case "-t": {
|
|
2762
|
-
const
|
|
2763
|
-
if (
|
|
3381
|
+
const t2 = argv[++i2];
|
|
3382
|
+
if (t2 === "app" || t2 === "minimal") flags.template = t2;
|
|
2764
3383
|
break;
|
|
2765
3384
|
}
|
|
2766
3385
|
case "--pm":
|
|
2767
|
-
flags.pm = argv[++
|
|
3386
|
+
flags.pm = argv[++i2];
|
|
2768
3387
|
break;
|
|
2769
3388
|
case "--style": {
|
|
2770
|
-
const s = argv[++
|
|
3389
|
+
const s = argv[++i2];
|
|
2771
3390
|
if (PREPROCESSORS.includes(s))
|
|
2772
3391
|
flags.preprocessor = s;
|
|
2773
3392
|
break;
|
|
@@ -2809,8 +3428,11 @@ function parseArgs(argv) {
|
|
|
2809
3428
|
case "--json":
|
|
2810
3429
|
flags.json = true;
|
|
2811
3430
|
break;
|
|
3431
|
+
case "--fix":
|
|
3432
|
+
flags.fix = true;
|
|
3433
|
+
break;
|
|
2812
3434
|
case "--target":
|
|
2813
|
-
flags.target = argv[++
|
|
3435
|
+
flags.target = argv[++i2];
|
|
2814
3436
|
break;
|
|
2815
3437
|
default:
|
|
2816
3438
|
if (!arg.startsWith("-") && flags.name === void 0) flags.name = arg;
|
|
@@ -2843,6 +3465,7 @@ function printHelp() {
|
|
|
2843
3465
|
cmd("-y, --yes", "create: accept defaults (non-interactive)"),
|
|
2844
3466
|
cmd("--no-install", "create: don't install dependencies"),
|
|
2845
3467
|
cmd("--json", "doctor: machine-readable output"),
|
|
3468
|
+
cmd("--fix", "doctor: auto-fix what it can (typed-RPC wiring)"),
|
|
2846
3469
|
cmd("--target <t>", "update: latest | minor | patch | newest | greatest"),
|
|
2847
3470
|
cmd("-v, --version", "print the toiljs version"),
|
|
2848
3471
|
""
|
|
@@ -2898,7 +3521,7 @@ async function main() {
|
|
|
2898
3521
|
case "start": {
|
|
2899
3522
|
banner();
|
|
2900
3523
|
process.stdout.write(dim(" self-hosting the built app\u2026") + "\n\n");
|
|
2901
|
-
const server = await start({ root: flags.root, port: flags.port });
|
|
3524
|
+
const server = await start({ root: flags.root, port: flags.port, host: flags.host });
|
|
2902
3525
|
process.stdout.write(
|
|
2903
3526
|
accent(" \u279C ") + bold(`http://localhost:${String(server.port)}`) + dim(` ws channel: ${server.wsPath}`) + "\n\n"
|
|
2904
3527
|
);
|
|
@@ -2906,7 +3529,7 @@ async function main() {
|
|
|
2906
3529
|
}
|
|
2907
3530
|
case "doctor":
|
|
2908
3531
|
if (!flags.json) banner();
|
|
2909
|
-
await runDoctor({ root: flags.root, cwd: process.cwd(), json: flags.json });
|
|
3532
|
+
await runDoctor({ root: flags.root, cwd: process.cwd(), json: flags.json, fix: flags.fix });
|
|
2910
3533
|
break;
|
|
2911
3534
|
case "update":
|
|
2912
3535
|
banner();
|