@stacksjs/bun-router 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-1mvtv6jw.js → chunk-j0e7z7hd.js} +7549 -2508
- package/dist/cli.js +1023 -858
- package/dist/index.js +60 -25
- package/dist/response/macros.d.ts +19 -8
- package/dist/router/router.d.ts +39 -16
- package/dist/types.d.ts +12 -0
- package/package.json +3 -6
- package/src/middleware/auth.ts +2 -1
- package/src/middleware/file_upload.ts +11 -0
- package/src/response/macros.ts +65 -12
- package/src/router/file-based-routing.ts +20 -0
- package/src/router/file-streaming.ts +15 -4
- package/src/router/route-building.ts +29 -20
- package/src/router/router.ts +39 -16
- package/src/types.ts +12 -0
package/dist/cli.js
CHANGED
|
@@ -1,212 +1,248 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
middleware
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-j0e7z7hd.js";
|
|
5
5
|
|
|
6
6
|
// src/cli/index.ts
|
|
7
|
-
import
|
|
7
|
+
import process15 from "process";
|
|
8
8
|
|
|
9
9
|
// ../../node_modules/@stacksjs/clapp/dist/index.js
|
|
10
|
+
import { existsSync } from "fs";
|
|
11
|
+
import fs from "fs/promises";
|
|
12
|
+
import os from "os";
|
|
13
|
+
import path from "path";
|
|
14
|
+
import process from "process";
|
|
10
15
|
import { EventEmitter } from "events";
|
|
16
|
+
import process5 from "process";
|
|
11
17
|
import process2 from "process";
|
|
12
18
|
import process3 from "process";
|
|
13
19
|
import process4 from "process";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
20
|
+
import process7 from "process";
|
|
21
|
+
import tty from "tty";
|
|
22
|
+
import process8, { stdin, stdout } from "process";
|
|
23
|
+
import process9, { stdin as stdin2, stdout as stdout2 } from "process";
|
|
16
24
|
import readline2 from "readline";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
-
var require_lib = __commonJS((exports, module) => {
|
|
35
|
-
function toArr(any) {
|
|
36
|
-
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
37
|
-
}
|
|
38
|
-
function toVal(out, key, val, opts) {
|
|
39
|
-
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
40
|
-
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
41
|
-
}
|
|
42
|
-
module.exports = function(args, opts) {
|
|
43
|
-
args = args || [];
|
|
44
|
-
opts = opts || {};
|
|
45
|
-
var k, arr, arg, name, val, out = { _: [] };
|
|
46
|
-
var i = 0, j = 0, idx = 0, len = args.length;
|
|
47
|
-
const alibi = opts.alias !== undefined;
|
|
48
|
-
const strict = opts.unknown !== undefined;
|
|
49
|
-
const defaults = opts.default !== undefined;
|
|
50
|
-
opts.alias = opts.alias || {};
|
|
51
|
-
opts.string = toArr(opts.string);
|
|
52
|
-
opts.boolean = toArr(opts.boolean);
|
|
53
|
-
if (alibi) {
|
|
54
|
-
for (k in opts.alias) {
|
|
55
|
-
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
56
|
-
for (i = 0;i < arr.length; i++) {
|
|
57
|
-
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
25
|
+
class Telemetry {
|
|
26
|
+
configPath;
|
|
27
|
+
config = null;
|
|
28
|
+
events = [];
|
|
29
|
+
retryCount = 0;
|
|
30
|
+
maxRetries = 3;
|
|
31
|
+
retryDelayMs = 1000;
|
|
32
|
+
constructor() {
|
|
33
|
+
const homeDir = os.homedir();
|
|
34
|
+
const configDir = path.join(homeDir, ".config", "clapp");
|
|
35
|
+
this.configPath = path.join(configDir, "telemetry.json");
|
|
36
|
+
}
|
|
37
|
+
async isEnabled() {
|
|
38
|
+
if (process.env.DO_NOT_TRACK === "1" || process.env.DO_NOT_TRACK === "true") {
|
|
39
|
+
return false;
|
|
60
40
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (j = arr.length;j-- > 0; )
|
|
64
|
-
opts.boolean.push(arr[j]);
|
|
65
|
-
}
|
|
66
|
-
for (i = opts.string.length;i-- > 0; ) {
|
|
67
|
-
arr = opts.alias[opts.string[i]] || [];
|
|
68
|
-
for (j = arr.length;j-- > 0; )
|
|
69
|
-
opts.string.push(arr[j]);
|
|
70
|
-
}
|
|
71
|
-
if (defaults) {
|
|
72
|
-
for (k in opts.default) {
|
|
73
|
-
name = typeof opts.default[k];
|
|
74
|
-
arr = opts.alias[k] = opts.alias[k] || [];
|
|
75
|
-
if (opts[name] !== undefined) {
|
|
76
|
-
opts[name].push(k);
|
|
77
|
-
for (i = 0;i < arr.length; i++) {
|
|
78
|
-
opts[name].push(arr[i]);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
41
|
+
if (process.env.NO_TELEMETRY === "1" || process.env.NO_TELEMETRY === "true") {
|
|
42
|
+
return false;
|
|
82
43
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
44
|
+
const config = await this.loadConfig();
|
|
45
|
+
return config.enabled;
|
|
46
|
+
}
|
|
47
|
+
async enable() {
|
|
48
|
+
const config = await this.loadConfig();
|
|
49
|
+
config.enabled = true;
|
|
50
|
+
if (!config.userId) {
|
|
51
|
+
config.userId = this.generateUserId();
|
|
52
|
+
}
|
|
53
|
+
await this.saveConfig(config);
|
|
54
|
+
}
|
|
55
|
+
async disable() {
|
|
56
|
+
const config = await this.loadConfig();
|
|
57
|
+
config.enabled = false;
|
|
58
|
+
await this.saveConfig(config);
|
|
59
|
+
}
|
|
60
|
+
async track(event, data) {
|
|
61
|
+
const enabled = await this.isEnabled();
|
|
62
|
+
if (!enabled) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const telemetryEvent = {
|
|
66
|
+
event,
|
|
67
|
+
...data,
|
|
68
|
+
timestamp: Date.now(),
|
|
69
|
+
platform: os.platform(),
|
|
70
|
+
nodeVersion: process.version
|
|
71
|
+
};
|
|
72
|
+
this.events.push(telemetryEvent);
|
|
73
|
+
if (this.events.length >= 10) {
|
|
74
|
+
await this.send();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async trackCommand(command, duration) {
|
|
78
|
+
await this.track("command", {
|
|
79
|
+
command,
|
|
80
|
+
duration
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async trackError(error, command) {
|
|
84
|
+
await this.track("error", {
|
|
85
|
+
error,
|
|
86
|
+
command
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async send() {
|
|
90
|
+
const enabled = await this.isEnabled();
|
|
91
|
+
if (!enabled || this.events.length === 0) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
this.events = [];
|
|
96
|
+
this.retryCount = 0;
|
|
97
|
+
const config = await this.loadConfig();
|
|
98
|
+
config.lastSent = Date.now();
|
|
99
|
+
await this.saveConfig(config);
|
|
100
|
+
return true;
|
|
101
|
+
} catch {
|
|
102
|
+
if (this.retryCount < this.maxRetries) {
|
|
103
|
+
this.retryCount++;
|
|
104
|
+
const delay = this.retryDelayMs * 2 ** (this.retryCount - 1);
|
|
105
|
+
await this.sleep(delay);
|
|
106
|
+
return this.send();
|
|
107
|
+
}
|
|
108
|
+
this.events = [];
|
|
109
|
+
this.retryCount = 0;
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async flush() {
|
|
114
|
+
if (this.events.length === 0) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return this.send();
|
|
118
|
+
}
|
|
119
|
+
sleep(ms) {
|
|
120
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
121
|
+
}
|
|
122
|
+
async status() {
|
|
123
|
+
const config = await this.loadConfig();
|
|
124
|
+
return {
|
|
125
|
+
enabled: config.enabled,
|
|
126
|
+
doNotTrack: process.env.DO_NOT_TRACK === "1" || process.env.DO_NOT_TRACK === "true",
|
|
127
|
+
eventsQueued: this.events.length,
|
|
128
|
+
lastSent: config.lastSent
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async loadConfig() {
|
|
132
|
+
if (this.config) {
|
|
133
|
+
return this.config;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
if (existsSync(this.configPath)) {
|
|
137
|
+
const data = await fs.readFile(this.configPath, "utf-8");
|
|
138
|
+
this.config = JSON.parse(data);
|
|
139
|
+
return this.config;
|
|
93
140
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
141
|
+
} catch {}
|
|
142
|
+
this.config = {
|
|
143
|
+
enabled: false
|
|
144
|
+
};
|
|
145
|
+
return this.config;
|
|
146
|
+
}
|
|
147
|
+
async saveConfig(config) {
|
|
148
|
+
this.config = config;
|
|
149
|
+
try {
|
|
150
|
+
const configDir = path.dirname(this.configPath);
|
|
151
|
+
await fs.mkdir(configDir, { recursive: true });
|
|
152
|
+
await fs.writeFile(this.configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
153
|
+
} catch {}
|
|
154
|
+
}
|
|
155
|
+
generateUserId() {
|
|
156
|
+
const random = Math.random().toString(36).substring(2, 15);
|
|
157
|
+
const timestamp = Date.now().toString(36);
|
|
158
|
+
return `${random}-${timestamp}`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var telemetry = new Telemetry;
|
|
162
|
+
function parseArgv(argv, opts = {}) {
|
|
163
|
+
const result = { _: [] };
|
|
164
|
+
const alias = opts.alias || {};
|
|
165
|
+
const booleans = new Set(opts.boolean || []);
|
|
166
|
+
const aliasOf = {};
|
|
167
|
+
for (const key of Object.keys(alias)) {
|
|
168
|
+
for (const a of alias[key]) {
|
|
169
|
+
aliasOf[a] = key;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
for (const b of booleans) {
|
|
173
|
+
if (alias[b]) {
|
|
174
|
+
for (const a of alias[b])
|
|
175
|
+
booleans.add(a);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function setKey(key, value) {
|
|
179
|
+
const canonical = aliasOf[key] || key;
|
|
180
|
+
result[canonical] = value;
|
|
181
|
+
if (alias[canonical]) {
|
|
182
|
+
for (const a of alias[canonical])
|
|
183
|
+
result[a] = value;
|
|
184
|
+
}
|
|
185
|
+
if (aliasOf[key] && alias[aliasOf[key]]) {
|
|
186
|
+
for (const a of alias[aliasOf[key]])
|
|
187
|
+
result[a] = value;
|
|
188
|
+
}
|
|
189
|
+
result[key] = value;
|
|
190
|
+
}
|
|
191
|
+
for (let i = 0;i < argv.length; i++) {
|
|
192
|
+
const arg = argv[i];
|
|
193
|
+
if (arg === "--") {
|
|
194
|
+
result._.push(...argv.slice(i + 1));
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
if (arg.startsWith("--")) {
|
|
198
|
+
const eqIdx = arg.indexOf("=");
|
|
199
|
+
if (eqIdx !== -1) {
|
|
200
|
+
const key = arg.slice(2, eqIdx);
|
|
201
|
+
const value = arg.slice(eqIdx + 1);
|
|
202
|
+
setKey(key, value);
|
|
102
203
|
} else {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
109
|
-
arr = j === 2 ? [name] : name;
|
|
110
|
-
for (idx = 0;idx < arr.length; idx++) {
|
|
111
|
-
name = arr[idx];
|
|
112
|
-
if (strict && !~keys.indexOf(name))
|
|
113
|
-
return opts.unknown("-".repeat(j) + name);
|
|
114
|
-
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
204
|
+
const key = arg.slice(2);
|
|
205
|
+
if (key.startsWith("no-")) {
|
|
206
|
+
const actualKey = key.slice(3);
|
|
207
|
+
setKey(actualKey, false);
|
|
208
|
+
continue;
|
|
115
209
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
210
|
+
const canonical = aliasOf[key] || key;
|
|
211
|
+
if (booleans.has(canonical) || booleans.has(key)) {
|
|
212
|
+
setKey(key, true);
|
|
213
|
+
} else {
|
|
214
|
+
const next = argv[i + 1];
|
|
215
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
216
|
+
setKey(key, next);
|
|
217
|
+
i++;
|
|
218
|
+
} else {
|
|
219
|
+
setKey(key, true);
|
|
220
|
+
}
|
|
122
221
|
}
|
|
123
222
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
for (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
223
|
+
} else if (arg.startsWith("-") && arg.length > 1) {
|
|
224
|
+
const chars = arg.slice(1);
|
|
225
|
+
for (let j = 0;j < chars.length; j++) {
|
|
226
|
+
const ch = chars[j];
|
|
227
|
+
const canonical = aliasOf[ch] || ch;
|
|
228
|
+
if (j === chars.length - 1 && !booleans.has(canonical) && !booleans.has(ch)) {
|
|
229
|
+
const next = argv[i + 1];
|
|
230
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
231
|
+
setKey(ch, next);
|
|
232
|
+
i++;
|
|
233
|
+
} else {
|
|
234
|
+
setKey(ch, true);
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
setKey(ch, true);
|
|
130
238
|
}
|
|
131
239
|
}
|
|
240
|
+
} else {
|
|
241
|
+
result._.push(arg);
|
|
132
242
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
137
|
-
var p = process || {};
|
|
138
|
-
var argv = p.argv || [];
|
|
139
|
-
var env = p.env || {};
|
|
140
|
-
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);
|
|
141
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
142
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
143
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
144
|
-
};
|
|
145
|
-
var replaceClose = (string, close, replace, index) => {
|
|
146
|
-
let result = "", cursor2 = 0;
|
|
147
|
-
do {
|
|
148
|
-
result += string.substring(cursor2, index) + replace;
|
|
149
|
-
cursor2 = index + close.length;
|
|
150
|
-
index = string.indexOf(close, cursor2);
|
|
151
|
-
} while (~index);
|
|
152
|
-
return result + string.substring(cursor2);
|
|
153
|
-
};
|
|
154
|
-
var createColors = (enabled = isColorSupported) => {
|
|
155
|
-
let f = enabled ? formatter : () => String;
|
|
156
|
-
return {
|
|
157
|
-
isColorSupported: enabled,
|
|
158
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
159
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
160
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
161
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
162
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
163
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
164
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
165
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
166
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
167
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
168
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
169
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
170
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
171
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
172
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
173
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
174
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
175
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
176
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
177
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
178
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
179
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
180
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
181
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
182
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
183
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
184
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
185
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
186
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
187
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
188
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
189
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
190
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
191
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
192
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
193
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
194
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
195
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
196
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
197
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
198
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
module.exports = createColors();
|
|
202
|
-
module.exports.createColors = createColors;
|
|
203
|
-
});
|
|
204
|
-
var require_emoji_regex = __commonJS((exports, module) => {
|
|
205
|
-
module.exports = () => {
|
|
206
|
-
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
var import_mri = __toESM(require_lib(), 1);
|
|
243
|
+
}
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
210
246
|
function removeBrackets(v) {
|
|
211
247
|
return v.replace(/[<[].+/, "").trim();
|
|
212
248
|
}
|
|
@@ -259,9 +295,7 @@ function getMriOptions(options) {
|
|
|
259
295
|
return result;
|
|
260
296
|
}
|
|
261
297
|
function findLongest(arr) {
|
|
262
|
-
return arr.
|
|
263
|
-
return a.length > b.length ? -1 : 1;
|
|
264
|
-
})[0];
|
|
298
|
+
return arr.reduce((a, b) => a.length >= b.length ? a : b, "");
|
|
265
299
|
}
|
|
266
300
|
function padRight(str, length) {
|
|
267
301
|
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
@@ -303,6 +337,8 @@ function camelcaseOptionName(name) {
|
|
|
303
337
|
}
|
|
304
338
|
|
|
305
339
|
class ClappError extends Error {
|
|
340
|
+
exitCode = 2;
|
|
341
|
+
isUsageError = true;
|
|
306
342
|
constructor(message) {
|
|
307
343
|
super(message);
|
|
308
344
|
this.name = this.constructor.name;
|
|
@@ -312,6 +348,15 @@ class ClappError extends Error {
|
|
|
312
348
|
this.stack = new Error(message).stack;
|
|
313
349
|
}
|
|
314
350
|
}
|
|
351
|
+
format(showStack = false) {
|
|
352
|
+
if (showStack && this.stack) {
|
|
353
|
+
return `${this.message}
|
|
354
|
+
|
|
355
|
+
Stack trace:
|
|
356
|
+
${this.stack}`;
|
|
357
|
+
}
|
|
358
|
+
return this.message;
|
|
359
|
+
}
|
|
315
360
|
}
|
|
316
361
|
function isUnicodeSupported() {
|
|
317
362
|
const { env } = process2;
|
|
@@ -372,6 +417,28 @@ var erase = {
|
|
|
372
417
|
var clear = {
|
|
373
418
|
screen: `${ESC}c`
|
|
374
419
|
};
|
|
420
|
+
function levenshteinDistance(a, b) {
|
|
421
|
+
const matrix = [];
|
|
422
|
+
for (let i = 0;i <= b.length; i++) {
|
|
423
|
+
matrix[i] = [i];
|
|
424
|
+
}
|
|
425
|
+
for (let j = 0;j <= a.length; j++) {
|
|
426
|
+
matrix[0][j] = j;
|
|
427
|
+
}
|
|
428
|
+
for (let i = 1;i <= b.length; i++) {
|
|
429
|
+
for (let j = 1;j <= a.length; j++) {
|
|
430
|
+
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
|
431
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
432
|
+
} else {
|
|
433
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return matrix[b.length][a.length];
|
|
438
|
+
}
|
|
439
|
+
function findSimilarCommands(input, commands, maxDistance = 2, maxSuggestions = 3) {
|
|
440
|
+
return commands.map((cmd) => ({ cmd, distance: levenshteinDistance(input, cmd) })).filter(({ distance }) => distance <= maxDistance).sort((a, b) => a.distance - b.distance).slice(0, maxSuggestions).map(({ cmd }) => cmd);
|
|
441
|
+
}
|
|
375
442
|
|
|
376
443
|
class Option {
|
|
377
444
|
rawName;
|
|
@@ -422,6 +489,7 @@ class Command {
|
|
|
422
489
|
options;
|
|
423
490
|
aliasNames;
|
|
424
491
|
name;
|
|
492
|
+
namespace;
|
|
425
493
|
args;
|
|
426
494
|
commandAction;
|
|
427
495
|
usageText;
|
|
@@ -429,6 +497,9 @@ class Command {
|
|
|
429
497
|
examples;
|
|
430
498
|
helpCallback;
|
|
431
499
|
globalCommand;
|
|
500
|
+
beforeHooks;
|
|
501
|
+
afterHooks;
|
|
502
|
+
middleware;
|
|
432
503
|
constructor(rawName, description, config, cli) {
|
|
433
504
|
this.rawName = rawName;
|
|
434
505
|
this.description = description;
|
|
@@ -437,8 +508,17 @@ class Command {
|
|
|
437
508
|
this.options = [];
|
|
438
509
|
this.aliasNames = [];
|
|
439
510
|
this.name = removeBrackets(rawName);
|
|
511
|
+
const nameWithoutBrackets = removeBrackets(rawName);
|
|
512
|
+
const colonIndex = nameWithoutBrackets.indexOf(":");
|
|
513
|
+
if (colonIndex > 0) {
|
|
514
|
+
this.namespace = nameWithoutBrackets.substring(0, colonIndex);
|
|
515
|
+
this.name = nameWithoutBrackets.substring(colonIndex + 1);
|
|
516
|
+
}
|
|
440
517
|
this.args = findAllBrackets(rawName);
|
|
441
518
|
this.examples = [];
|
|
519
|
+
this.beforeHooks = [];
|
|
520
|
+
this.afterHooks = [];
|
|
521
|
+
this.middleware = [];
|
|
442
522
|
if (!config) {
|
|
443
523
|
this.config = {};
|
|
444
524
|
}
|
|
@@ -477,8 +557,26 @@ class Command {
|
|
|
477
557
|
this.commandAction = callback;
|
|
478
558
|
return this;
|
|
479
559
|
}
|
|
560
|
+
before(handler) {
|
|
561
|
+
this.beforeHooks.push(handler);
|
|
562
|
+
return this;
|
|
563
|
+
}
|
|
564
|
+
after(handler) {
|
|
565
|
+
this.afterHooks.push(handler);
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
use(handler) {
|
|
569
|
+
this.middleware.push(handler);
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
480
572
|
isMatched(name) {
|
|
481
|
-
|
|
573
|
+
if (this.aliasNames.includes(name))
|
|
574
|
+
return true;
|
|
575
|
+
if (this.name === name)
|
|
576
|
+
return true;
|
|
577
|
+
if (this.namespace && `${this.namespace}:${this.name}` === name)
|
|
578
|
+
return true;
|
|
579
|
+
return false;
|
|
482
580
|
}
|
|
483
581
|
get isDefaultCommand() {
|
|
484
582
|
return this.name === "" || this.aliasNames.includes("!");
|
|
@@ -511,12 +609,43 @@ class Command {
|
|
|
511
609
|
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
512
610
|
if (showCommands) {
|
|
513
611
|
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
612
|
+
const namespaceGroups = new Map;
|
|
613
|
+
const noNamespaceCommands = [];
|
|
614
|
+
for (const command of commands) {
|
|
615
|
+
if (command.namespace) {
|
|
616
|
+
if (!namespaceGroups.has(command.namespace)) {
|
|
617
|
+
namespaceGroups.set(command.namespace, []);
|
|
618
|
+
}
|
|
619
|
+
namespaceGroups.get(command.namespace).push(command);
|
|
620
|
+
} else {
|
|
621
|
+
noNamespaceCommands.push(command);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
let commandBody = "";
|
|
625
|
+
if (noNamespaceCommands.length > 0) {
|
|
626
|
+
commandBody += noNamespaceCommands.map((command) => {
|
|
517
627
|
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
518
628
|
}).join(`
|
|
519
|
-
`)
|
|
629
|
+
`);
|
|
630
|
+
}
|
|
631
|
+
const sortedNamespaces = Array.from(namespaceGroups.keys()).sort();
|
|
632
|
+
for (const namespace of sortedNamespaces) {
|
|
633
|
+
const namespaceCommands = namespaceGroups.get(namespace);
|
|
634
|
+
if (commandBody.length > 0) {
|
|
635
|
+
commandBody += `
|
|
636
|
+
|
|
637
|
+
`;
|
|
638
|
+
}
|
|
639
|
+
commandBody += ` ${namespace}:
|
|
640
|
+
`;
|
|
641
|
+
commandBody += namespaceCommands.map((command) => {
|
|
642
|
+
return ` ${padRight(command.rawName, longestCommandName.length - 2)} ${command.description}`;
|
|
643
|
+
}).join(`
|
|
644
|
+
`);
|
|
645
|
+
}
|
|
646
|
+
sections.push({
|
|
647
|
+
title: "Commands",
|
|
648
|
+
body: commandBody
|
|
520
649
|
});
|
|
521
650
|
sections.push({
|
|
522
651
|
title: `For more info, run any command with the \`--help\` flag`,
|
|
@@ -564,19 +693,19 @@ ${section.body}` : section.body;
|
|
|
564
693
|
const { name } = this.cli;
|
|
565
694
|
const { versionNumber } = this.cli.globalCommand;
|
|
566
695
|
if (versionNumber) {
|
|
567
|
-
|
|
568
|
-
if (Bun) {
|
|
569
|
-
platformInfo3 = platformInfo;
|
|
570
|
-
} else {
|
|
571
|
-
platformInfo3 = platformInfo2;
|
|
572
|
-
}
|
|
696
|
+
const platformInfo3 = typeof Bun !== "undefined" ? platformInfo : platformInfo2;
|
|
573
697
|
console.log(`${name}/${versionNumber} ${platformInfo3}`);
|
|
574
698
|
}
|
|
575
699
|
}
|
|
576
700
|
checkRequiredArgs() {
|
|
577
701
|
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
578
702
|
if (this.cli.args.length < minimalArgsCount) {
|
|
579
|
-
|
|
703
|
+
const requiredArgs = this.args.filter((arg) => arg.required);
|
|
704
|
+
const missingArgs = requiredArgs.slice(this.cli.args.length);
|
|
705
|
+
const argNames = missingArgs.map((arg) => `<${arg.value}>`).join(" ");
|
|
706
|
+
throw new ClappError(`Missing required argument${missingArgs.length > 1 ? "s" : ""}: ${argNames}
|
|
707
|
+
|
|
708
|
+
` + `Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`);
|
|
580
709
|
}
|
|
581
710
|
}
|
|
582
711
|
checkUnknownOptions() {
|
|
@@ -584,7 +713,25 @@ ${section.body}` : section.body;
|
|
|
584
713
|
if (!this.config.allowUnknownOptions) {
|
|
585
714
|
for (const name of Object.keys(options)) {
|
|
586
715
|
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
587
|
-
|
|
716
|
+
const allOptions = [...globalCommand.options, ...this.options];
|
|
717
|
+
const allOptionNames = allOptions.flatMap((opt) => opt.names);
|
|
718
|
+
const optionFlag = name.length > 1 ? `--${name}` : `-${name}`;
|
|
719
|
+
const suggestions = findSimilarCommands(name, allOptionNames);
|
|
720
|
+
let errorMsg = `Unknown option \`${optionFlag}\``;
|
|
721
|
+
if (suggestions.length > 0) {
|
|
722
|
+
errorMsg += `
|
|
723
|
+
|
|
724
|
+
Did you mean one of these?`;
|
|
725
|
+
suggestions.forEach((suggestion) => {
|
|
726
|
+
const suggestedFlag = suggestion.length > 1 ? `--${suggestion}` : `-${suggestion}`;
|
|
727
|
+
errorMsg += `
|
|
728
|
+
\u2022 ${suggestedFlag}`;
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
errorMsg += `
|
|
732
|
+
|
|
733
|
+
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`;
|
|
734
|
+
throw new ClappError(errorMsg);
|
|
588
735
|
}
|
|
589
736
|
}
|
|
590
737
|
}
|
|
@@ -597,7 +744,9 @@ ${section.body}` : section.body;
|
|
|
597
744
|
if (option.required) {
|
|
598
745
|
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
599
746
|
if (value === true || value === false && !hasNegated) {
|
|
600
|
-
throw new ClappError(`
|
|
747
|
+
throw new ClappError(`Option \`${option.rawName}\` requires a value.
|
|
748
|
+
|
|
749
|
+
` + `Example: ${this.cli.name} ${this.rawName} ${option.rawName} <value>`);
|
|
601
750
|
}
|
|
602
751
|
}
|
|
603
752
|
}
|
|
@@ -610,7 +759,88 @@ class GlobalCommand extends Command {
|
|
|
610
759
|
}
|
|
611
760
|
}
|
|
612
761
|
var Command_default = Command;
|
|
613
|
-
|
|
762
|
+
var codes = {
|
|
763
|
+
red: ["\x1B[31m", "\x1B[39m"],
|
|
764
|
+
green: ["\x1B[32m", "\x1B[39m"],
|
|
765
|
+
blue: ["\x1B[34m", "\x1B[39m"],
|
|
766
|
+
yellow: ["\x1B[33m", "\x1B[39m"],
|
|
767
|
+
cyan: ["\x1B[36m", "\x1B[39m"],
|
|
768
|
+
magenta: ["\x1B[35m", "\x1B[39m"],
|
|
769
|
+
white: ["\x1B[37m", "\x1B[39m"],
|
|
770
|
+
gray: ["\x1B[90m", "\x1B[39m"],
|
|
771
|
+
bgRed: ["\x1B[41m", "\x1B[49m"],
|
|
772
|
+
bgGreen: ["\x1B[42m", "\x1B[49m"],
|
|
773
|
+
bgBlue: ["\x1B[44m", "\x1B[49m"],
|
|
774
|
+
bgYellow: ["\x1B[43m", "\x1B[49m"],
|
|
775
|
+
bgCyan: ["\x1B[46m", "\x1B[49m"],
|
|
776
|
+
bgMagenta: ["\x1B[45m", "\x1B[49m"],
|
|
777
|
+
bold: ["\x1B[1m", "\x1B[22m"],
|
|
778
|
+
italic: ["\x1B[3m", "\x1B[23m"],
|
|
779
|
+
underline: ["\x1B[4m", "\x1B[24m"],
|
|
780
|
+
dim: ["\x1B[2m", "\x1B[22m"],
|
|
781
|
+
inverse: ["\x1B[7m", "\x1B[27m"],
|
|
782
|
+
hidden: ["\x1B[8m", "\x1B[28m"],
|
|
783
|
+
strikethrough: ["\x1B[9m", "\x1B[29m"]
|
|
784
|
+
};
|
|
785
|
+
var theme = {
|
|
786
|
+
primary: "blue",
|
|
787
|
+
secondary: "cyan",
|
|
788
|
+
success: "green",
|
|
789
|
+
warning: "yellow",
|
|
790
|
+
error: "red",
|
|
791
|
+
info: "magenta",
|
|
792
|
+
muted: "gray"
|
|
793
|
+
};
|
|
794
|
+
function detectColorSupport() {
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
function createStyler() {
|
|
798
|
+
const styler = {};
|
|
799
|
+
styler.supportsColor = detectColorSupport();
|
|
800
|
+
function createStyleFunction(styleName, styles = []) {
|
|
801
|
+
const styleList = styleName === "" ? [] : [...styles, styleName];
|
|
802
|
+
const fn = function(text) {
|
|
803
|
+
if (!styler.supportsColor)
|
|
804
|
+
return text;
|
|
805
|
+
let openCodes = "";
|
|
806
|
+
let closeCodes = "";
|
|
807
|
+
for (const style of styleList) {
|
|
808
|
+
if (style in theme && theme[style] in codes) {
|
|
809
|
+
const themeStyle = theme[style];
|
|
810
|
+
openCodes += codes[themeStyle][0];
|
|
811
|
+
closeCodes = codes[themeStyle][1] + closeCodes;
|
|
812
|
+
} else if (style in codes) {
|
|
813
|
+
openCodes += codes[style][0];
|
|
814
|
+
closeCodes = codes[style][1] + closeCodes;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return openCodes + text + closeCodes;
|
|
818
|
+
};
|
|
819
|
+
const allStyles2 = [...Object.keys(codes), ...Object.keys(theme)];
|
|
820
|
+
for (const style of allStyles2) {
|
|
821
|
+
if (!(style in fn)) {
|
|
822
|
+
Object.defineProperty(fn, style, {
|
|
823
|
+
get() {
|
|
824
|
+
return createStyleFunction(style, styleList);
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return fn;
|
|
830
|
+
}
|
|
831
|
+
const allStyles = [...Object.keys(codes), ...Object.keys(theme)];
|
|
832
|
+
for (const style of allStyles) {
|
|
833
|
+
if (!(style in styler)) {
|
|
834
|
+
Object.defineProperty(styler, style, {
|
|
835
|
+
get() {
|
|
836
|
+
return createStyleFunction(style);
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return styler;
|
|
842
|
+
}
|
|
843
|
+
var style = createStyler();
|
|
614
844
|
class CLI extends EventEmitter {
|
|
615
845
|
name;
|
|
616
846
|
commands;
|
|
@@ -622,6 +852,18 @@ class CLI extends EventEmitter {
|
|
|
622
852
|
options;
|
|
623
853
|
showHelpOnExit;
|
|
624
854
|
showVersionOnExit;
|
|
855
|
+
enableDidYouMean = true;
|
|
856
|
+
signalHandlersSet = false;
|
|
857
|
+
isVerbose = false;
|
|
858
|
+
isQuiet = false;
|
|
859
|
+
isDebug = false;
|
|
860
|
+
isNoInteraction = false;
|
|
861
|
+
environment;
|
|
862
|
+
isDryRun = false;
|
|
863
|
+
isForce = false;
|
|
864
|
+
useEmoji = true;
|
|
865
|
+
theme;
|
|
866
|
+
isNoCache = false;
|
|
625
867
|
constructor(name = "") {
|
|
626
868
|
super();
|
|
627
869
|
this.name = name;
|
|
@@ -632,6 +874,72 @@ class CLI extends EventEmitter {
|
|
|
632
874
|
this.globalCommand = new GlobalCommand(this);
|
|
633
875
|
this.globalCommand.usage("<command> [options]");
|
|
634
876
|
}
|
|
877
|
+
handleSignals(cleanup) {
|
|
878
|
+
if (this.signalHandlersSet) {
|
|
879
|
+
return this;
|
|
880
|
+
}
|
|
881
|
+
const handleSignal = async (signal) => {
|
|
882
|
+
console.log(`
|
|
883
|
+
|
|
884
|
+
Received ${signal}, cleaning up...`);
|
|
885
|
+
if (cleanup) {
|
|
886
|
+
try {
|
|
887
|
+
await cleanup();
|
|
888
|
+
} catch (error) {
|
|
889
|
+
console.error("Error during cleanup:", error);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
process5.exit(0);
|
|
893
|
+
};
|
|
894
|
+
process5.on("SIGINT", () => handleSignal("SIGINT"));
|
|
895
|
+
process5.on("SIGTERM", () => handleSignal("SIGTERM"));
|
|
896
|
+
this.signalHandlersSet = true;
|
|
897
|
+
return this;
|
|
898
|
+
}
|
|
899
|
+
didYouMean(enabled = true) {
|
|
900
|
+
this.enableDidYouMean = enabled;
|
|
901
|
+
return this;
|
|
902
|
+
}
|
|
903
|
+
verbose() {
|
|
904
|
+
this.globalCommand.option("-v, --verbose", "Enable verbose output");
|
|
905
|
+
return this;
|
|
906
|
+
}
|
|
907
|
+
quiet() {
|
|
908
|
+
this.globalCommand.option("-q, --quiet", "Suppress non-essential output");
|
|
909
|
+
return this;
|
|
910
|
+
}
|
|
911
|
+
debug() {
|
|
912
|
+
this.globalCommand.option("--debug", "Enable debug mode with detailed error information");
|
|
913
|
+
return this;
|
|
914
|
+
}
|
|
915
|
+
noInteraction() {
|
|
916
|
+
this.globalCommand.option("-n, --no-interaction", "Do not ask any interactive questions (for CI/CD)");
|
|
917
|
+
return this;
|
|
918
|
+
}
|
|
919
|
+
env() {
|
|
920
|
+
this.globalCommand.option("--env <environment>", "Target environment (e.g., production, staging, local)");
|
|
921
|
+
return this;
|
|
922
|
+
}
|
|
923
|
+
dryRun() {
|
|
924
|
+
this.globalCommand.option("--dry-run", "Preview actions without executing them");
|
|
925
|
+
return this;
|
|
926
|
+
}
|
|
927
|
+
force() {
|
|
928
|
+
this.globalCommand.option("-f, --force", "Skip confirmation prompts");
|
|
929
|
+
return this;
|
|
930
|
+
}
|
|
931
|
+
emoji() {
|
|
932
|
+
this.globalCommand.option("--no-emoji", "Disable emoji in output");
|
|
933
|
+
return this;
|
|
934
|
+
}
|
|
935
|
+
themes() {
|
|
936
|
+
this.globalCommand.option("--theme <theme>", "Color theme (default, dracula, nord, solarized, monokai)");
|
|
937
|
+
return this;
|
|
938
|
+
}
|
|
939
|
+
cache() {
|
|
940
|
+
this.globalCommand.option("--no-cache", "Disable caching");
|
|
941
|
+
return this;
|
|
942
|
+
}
|
|
635
943
|
usage(text) {
|
|
636
944
|
this.globalCommand.usage(text);
|
|
637
945
|
return this;
|
|
@@ -689,34 +997,70 @@ class CLI extends EventEmitter {
|
|
|
689
997
|
this.matchedCommand = undefined;
|
|
690
998
|
this.matchedCommandName = undefined;
|
|
691
999
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
1000
|
+
showCommandNotFound(input) {
|
|
1001
|
+
console.log(style.red(`
|
|
1002
|
+
\u2717 Command "${input}" not found.
|
|
1003
|
+
`));
|
|
1004
|
+
if (this.enableDidYouMean) {
|
|
1005
|
+
const allCommandNames = [];
|
|
1006
|
+
for (const command of this.commands) {
|
|
1007
|
+
if (command.name) {
|
|
1008
|
+
allCommandNames.push(command.name);
|
|
1009
|
+
}
|
|
1010
|
+
if (command.aliasNames) {
|
|
1011
|
+
allCommandNames.push(...command.aliasNames);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
const suggestions = findSimilarCommands(input, allCommandNames);
|
|
1015
|
+
if (suggestions.length > 0) {
|
|
1016
|
+
console.log(style.yellow("Did you mean one of these?"));
|
|
1017
|
+
suggestions.forEach((cmd) => console.log(` ${style.dim("\u2022")} ${this.name} ${cmd}`));
|
|
1018
|
+
console.log("");
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
console.log(style.dim("Run"), `${this.name} --help`, style.dim("to see all available commands"));
|
|
1022
|
+
process5.exit(1);
|
|
1023
|
+
}
|
|
1024
|
+
async parse(argv = processArgs2, options = {}) {
|
|
1025
|
+
let { run = true, exitOnError = false } = options;
|
|
1026
|
+
if (exitOnError) {
|
|
1027
|
+
try {
|
|
1028
|
+
return await this.parse(argv, { run });
|
|
1029
|
+
} catch (err) {
|
|
1030
|
+
this.handleUsageError(err);
|
|
1031
|
+
throw err;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
695
1034
|
this.rawArgs = argv;
|
|
696
1035
|
if (!this.name) {
|
|
697
1036
|
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
698
1037
|
}
|
|
699
1038
|
let shouldParse = true;
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1039
|
+
const slicedArgv = argv.slice(2);
|
|
1040
|
+
const candidateName = slicedArgv[0];
|
|
1041
|
+
if (candidateName && !candidateName.startsWith("-")) {
|
|
1042
|
+
for (const command of this.commands) {
|
|
1043
|
+
if (command.isMatched(candidateName)) {
|
|
1044
|
+
const parsed = this.mri(slicedArgv, command);
|
|
1045
|
+
shouldParse = false;
|
|
1046
|
+
const parsedInfo = {
|
|
1047
|
+
...parsed,
|
|
1048
|
+
args: parsed.args.slice(1)
|
|
1049
|
+
};
|
|
1050
|
+
this.setParsedInfo(parsedInfo, command, candidateName);
|
|
1051
|
+
this.emit(`command:${candidateName}`, command);
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
711
1054
|
}
|
|
712
1055
|
}
|
|
713
1056
|
if (shouldParse) {
|
|
714
1057
|
for (const command of this.commands) {
|
|
715
1058
|
if (command.name === "") {
|
|
716
1059
|
shouldParse = false;
|
|
717
|
-
const parsed = this.mri(
|
|
1060
|
+
const parsed = this.mri(slicedArgv, command);
|
|
718
1061
|
this.setParsedInfo(parsed, command);
|
|
719
1062
|
this.emit(`command:!`, command);
|
|
1063
|
+
break;
|
|
720
1064
|
}
|
|
721
1065
|
}
|
|
722
1066
|
}
|
|
@@ -724,6 +1068,36 @@ class CLI extends EventEmitter {
|
|
|
724
1068
|
const parsed = this.mri(argv.slice(2));
|
|
725
1069
|
this.setParsedInfo(parsed);
|
|
726
1070
|
}
|
|
1071
|
+
if (this.options.verbose) {
|
|
1072
|
+
this.isVerbose = true;
|
|
1073
|
+
}
|
|
1074
|
+
if (this.options.quiet) {
|
|
1075
|
+
this.isQuiet = true;
|
|
1076
|
+
}
|
|
1077
|
+
if (this.options.debug) {
|
|
1078
|
+
this.isDebug = true;
|
|
1079
|
+
}
|
|
1080
|
+
if (this.options.noInteraction) {
|
|
1081
|
+
this.isNoInteraction = true;
|
|
1082
|
+
}
|
|
1083
|
+
if (this.options.env) {
|
|
1084
|
+
this.environment = String(this.options.env);
|
|
1085
|
+
}
|
|
1086
|
+
if (this.options.dryRun) {
|
|
1087
|
+
this.isDryRun = true;
|
|
1088
|
+
}
|
|
1089
|
+
if (this.options.force) {
|
|
1090
|
+
this.isForce = true;
|
|
1091
|
+
}
|
|
1092
|
+
if (this.options.noEmoji !== undefined) {
|
|
1093
|
+
this.useEmoji = !this.options.noEmoji;
|
|
1094
|
+
}
|
|
1095
|
+
if (this.options.theme) {
|
|
1096
|
+
this.theme = String(this.options.theme);
|
|
1097
|
+
}
|
|
1098
|
+
if (this.options.noCache !== undefined) {
|
|
1099
|
+
this.isNoCache = Boolean(this.options.noCache);
|
|
1100
|
+
}
|
|
727
1101
|
if (this.options.help && this.showHelpOnExit) {
|
|
728
1102
|
this.outputHelp();
|
|
729
1103
|
run = false;
|
|
@@ -736,10 +1110,14 @@ class CLI extends EventEmitter {
|
|
|
736
1110
|
}
|
|
737
1111
|
const parsedArgv = { args: this.args, options: this.options };
|
|
738
1112
|
if (run) {
|
|
739
|
-
this.runMatchedCommand();
|
|
1113
|
+
await this.runMatchedCommand();
|
|
740
1114
|
}
|
|
741
1115
|
if (!this.matchedCommand && this.args[0]) {
|
|
742
1116
|
this.emit("command:*");
|
|
1117
|
+
const hasWildcardListener = this.listenerCount("command:*") > 0;
|
|
1118
|
+
if (!hasWildcardListener) {
|
|
1119
|
+
this.showCommandNotFound(this.args[0]);
|
|
1120
|
+
}
|
|
743
1121
|
}
|
|
744
1122
|
return parsedArgv;
|
|
745
1123
|
}
|
|
@@ -755,13 +1133,13 @@ class CLI extends EventEmitter {
|
|
|
755
1133
|
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
756
1134
|
argv = argv.slice(0, doubleDashesIndex);
|
|
757
1135
|
}
|
|
758
|
-
|
|
759
|
-
parsed =
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
[camelcaseOptionName(name)]
|
|
763
|
-
}
|
|
764
|
-
}
|
|
1136
|
+
const raw = parseArgv(argv, mriOptions);
|
|
1137
|
+
const parsed = { _: raw._ };
|
|
1138
|
+
for (const name of Object.keys(raw)) {
|
|
1139
|
+
if (name !== "_") {
|
|
1140
|
+
parsed[camelcaseOptionName(name)] = raw[name];
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
765
1143
|
const args = parsed._;
|
|
766
1144
|
const options = {
|
|
767
1145
|
"--": argsAfterDoubleDashes
|
|
@@ -776,44 +1154,300 @@ class CLI extends EventEmitter {
|
|
|
776
1154
|
}
|
|
777
1155
|
if (Array.isArray(cliOption.config.type)) {
|
|
778
1156
|
if (transforms[cliOption.name] === undefined) {
|
|
779
|
-
transforms[cliOption.name] =
|
|
780
|
-
|
|
781
|
-
|
|
1157
|
+
transforms[cliOption.name] = {
|
|
1158
|
+
shouldTransform: true,
|
|
1159
|
+
transformFunction: cliOption.config.type[0]
|
|
1160
|
+
};
|
|
782
1161
|
}
|
|
783
1162
|
}
|
|
784
1163
|
}
|
|
785
|
-
for (const key of Object.keys(parsed)) {
|
|
786
|
-
if (key !== "_") {
|
|
787
|
-
const keys = key.split(".");
|
|
788
|
-
setDotProp(options, keys, parsed[key]);
|
|
789
|
-
setByType(options, transforms);
|
|
790
|
-
}
|
|
1164
|
+
for (const key of Object.keys(parsed)) {
|
|
1165
|
+
if (key !== "_") {
|
|
1166
|
+
const keys = key.split(".");
|
|
1167
|
+
setDotProp(options, keys, parsed[key]);
|
|
1168
|
+
setByType(options, transforms);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
return {
|
|
1172
|
+
args,
|
|
1173
|
+
options
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
async run(argv = processArgs2) {
|
|
1177
|
+
return this.parse(argv, { run: true, exitOnError: true });
|
|
1178
|
+
}
|
|
1179
|
+
handleUsageError(err) {
|
|
1180
|
+
const isClappError = !!err && typeof err === "object" && err.name === "ClappError";
|
|
1181
|
+
const isUsage = isClappError && err.isUsageError !== false;
|
|
1182
|
+
if (!isUsage)
|
|
1183
|
+
return;
|
|
1184
|
+
const e = err;
|
|
1185
|
+
const raw = e.message ?? "command-line error";
|
|
1186
|
+
const label = this.name ? `${this.name}: ` : "";
|
|
1187
|
+
const suffix = /--help/.test(raw) ? "" : `
|
|
1188
|
+
Run \`${this.name ?? "cli"} --help\` for usage.`;
|
|
1189
|
+
process5.stderr.write(`${label}${raw}${suffix}
|
|
1190
|
+
`);
|
|
1191
|
+
process5.exit(e.exitCode ?? 2);
|
|
1192
|
+
}
|
|
1193
|
+
async runMatchedCommand() {
|
|
1194
|
+
const { args, options, matchedCommand: command } = this;
|
|
1195
|
+
if (!command || !command.commandAction)
|
|
1196
|
+
return;
|
|
1197
|
+
command.checkUnknownOptions();
|
|
1198
|
+
command.checkOptionValue();
|
|
1199
|
+
command.checkRequiredArgs();
|
|
1200
|
+
const actionArgs = [];
|
|
1201
|
+
command.args.forEach((arg, index) => {
|
|
1202
|
+
if (arg.variadic) {
|
|
1203
|
+
actionArgs.push(args.slice(index));
|
|
1204
|
+
} else {
|
|
1205
|
+
actionArgs.push(args[index]);
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
actionArgs.push(options);
|
|
1209
|
+
const context = {
|
|
1210
|
+
command,
|
|
1211
|
+
args: actionArgs,
|
|
1212
|
+
options
|
|
1213
|
+
};
|
|
1214
|
+
for (const hook of command.beforeHooks) {
|
|
1215
|
+
await hook(context);
|
|
1216
|
+
}
|
|
1217
|
+
let actionResult;
|
|
1218
|
+
const executeAction = async () => {
|
|
1219
|
+
const result = command.commandAction.apply(this, actionArgs);
|
|
1220
|
+
if (result instanceof Promise) {
|
|
1221
|
+
actionResult = await result;
|
|
1222
|
+
} else {
|
|
1223
|
+
actionResult = result;
|
|
1224
|
+
}
|
|
1225
|
+
return actionResult;
|
|
1226
|
+
};
|
|
1227
|
+
if (command.middleware.length > 0) {
|
|
1228
|
+
let index = 0;
|
|
1229
|
+
const next = async () => {
|
|
1230
|
+
if (index < command.middleware.length) {
|
|
1231
|
+
const middleware2 = command.middleware[index++];
|
|
1232
|
+
await middleware2({ ...context, next });
|
|
1233
|
+
} else {
|
|
1234
|
+
await executeAction();
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
await next();
|
|
1238
|
+
} else {
|
|
1239
|
+
await executeAction();
|
|
1240
|
+
}
|
|
1241
|
+
for (const hook of command.afterHooks) {
|
|
1242
|
+
await hook(context);
|
|
1243
|
+
}
|
|
1244
|
+
return actionResult;
|
|
1245
|
+
}
|
|
1246
|
+
removeSignalHandlers() {
|
|
1247
|
+
if (!this.signalHandlersSet) {
|
|
1248
|
+
return this;
|
|
1249
|
+
}
|
|
1250
|
+
process5.removeAllListeners("SIGINT");
|
|
1251
|
+
process5.removeAllListeners("SIGTERM");
|
|
1252
|
+
this.signalHandlersSet = false;
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
destroy() {
|
|
1256
|
+
this.removeSignalHandlers();
|
|
1257
|
+
this.commands = [];
|
|
1258
|
+
this.rawArgs = [];
|
|
1259
|
+
this.args = [];
|
|
1260
|
+
this.options = {};
|
|
1261
|
+
this.matchedCommand = undefined;
|
|
1262
|
+
this.matchedCommandName = undefined;
|
|
1263
|
+
this.removeAllListeners();
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
class CLICache {
|
|
1267
|
+
cache;
|
|
1268
|
+
enabled;
|
|
1269
|
+
cleanupInterval = null;
|
|
1270
|
+
hits = 0;
|
|
1271
|
+
misses = 0;
|
|
1272
|
+
constructor() {
|
|
1273
|
+
this.cache = new Map;
|
|
1274
|
+
this.enabled = true;
|
|
1275
|
+
this.startCleanupInterval();
|
|
1276
|
+
}
|
|
1277
|
+
startCleanupInterval() {
|
|
1278
|
+
if (this.cleanupInterval) {
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
this.cleanupInterval = setInterval(() => {
|
|
1282
|
+
this.cleanup();
|
|
1283
|
+
}, 30000);
|
|
1284
|
+
this.cleanupInterval.unref();
|
|
1285
|
+
}
|
|
1286
|
+
stopCleanup() {
|
|
1287
|
+
if (this.cleanupInterval) {
|
|
1288
|
+
clearInterval(this.cleanupInterval);
|
|
1289
|
+
this.cleanupInterval = null;
|
|
791
1290
|
}
|
|
792
|
-
return {
|
|
793
|
-
args,
|
|
794
|
-
options
|
|
795
|
-
};
|
|
796
1291
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
1292
|
+
isEnabled() {
|
|
1293
|
+
return this.enabled;
|
|
1294
|
+
}
|
|
1295
|
+
get(key) {
|
|
1296
|
+
if (!this.enabled) {
|
|
1297
|
+
this.misses++;
|
|
800
1298
|
return;
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
1299
|
+
}
|
|
1300
|
+
const entry = this.cache.get(key);
|
|
1301
|
+
if (!entry) {
|
|
1302
|
+
this.misses++;
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
const now = Date.now();
|
|
1306
|
+
if (now - entry.timestamp > entry.ttl) {
|
|
1307
|
+
this.cache.delete(key);
|
|
1308
|
+
this.misses++;
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
this.hits++;
|
|
1312
|
+
return entry.value;
|
|
1313
|
+
}
|
|
1314
|
+
set(key, value, ttl = 5000) {
|
|
1315
|
+
if (!this.enabled) {
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
this.cache.set(key, {
|
|
1319
|
+
value,
|
|
1320
|
+
timestamp: Date.now(),
|
|
1321
|
+
ttl
|
|
811
1322
|
});
|
|
812
|
-
actionArgs.push(options);
|
|
813
|
-
return command.commandAction.apply(this, actionArgs);
|
|
814
1323
|
}
|
|
815
|
-
|
|
816
|
-
|
|
1324
|
+
has(key) {
|
|
1325
|
+
if (!this.enabled) {
|
|
1326
|
+
return false;
|
|
1327
|
+
}
|
|
1328
|
+
const entry = this.cache.get(key);
|
|
1329
|
+
if (!entry) {
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
const now = Date.now();
|
|
1333
|
+
if (now - entry.timestamp > entry.ttl) {
|
|
1334
|
+
this.cache.delete(key);
|
|
1335
|
+
return false;
|
|
1336
|
+
}
|
|
1337
|
+
return true;
|
|
1338
|
+
}
|
|
1339
|
+
delete(key) {
|
|
1340
|
+
this.cache.delete(key);
|
|
1341
|
+
}
|
|
1342
|
+
clear() {
|
|
1343
|
+
this.cache.clear();
|
|
1344
|
+
}
|
|
1345
|
+
disable() {
|
|
1346
|
+
this.enabled = false;
|
|
1347
|
+
this.clear();
|
|
1348
|
+
}
|
|
1349
|
+
enable() {
|
|
1350
|
+
this.enabled = true;
|
|
1351
|
+
}
|
|
1352
|
+
stats() {
|
|
1353
|
+
return {
|
|
1354
|
+
size: this.cache.size,
|
|
1355
|
+
enabled: this.enabled,
|
|
1356
|
+
hits: this.hits,
|
|
1357
|
+
misses: this.misses
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
resetStats() {
|
|
1361
|
+
this.hits = 0;
|
|
1362
|
+
this.misses = 0;
|
|
1363
|
+
}
|
|
1364
|
+
keys() {
|
|
1365
|
+
return Array.from(this.cache.keys());
|
|
1366
|
+
}
|
|
1367
|
+
cleanup() {
|
|
1368
|
+
const now = Date.now();
|
|
1369
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
1370
|
+
if (now - entry.timestamp > entry.ttl) {
|
|
1371
|
+
this.cache.delete(key);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
destroy() {
|
|
1376
|
+
this.stopCleanup();
|
|
1377
|
+
this.clear();
|
|
1378
|
+
this.resetStats();
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
var cliCache = new CLICache;
|
|
1382
|
+
function detectColorSupport2() {
|
|
1383
|
+
if ("FORCE_COLOR" in process7.env) {
|
|
1384
|
+
return process7.env.FORCE_COLOR !== "0";
|
|
1385
|
+
}
|
|
1386
|
+
if ("NO_COLOR" in process7.env || process7.env.TERM === "dumb") {
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
if (process7.platform === "win32") {
|
|
1390
|
+
return true;
|
|
1391
|
+
}
|
|
1392
|
+
return tty.isatty(1) && tty.isatty(2);
|
|
1393
|
+
}
|
|
1394
|
+
var enabled = detectColorSupport2();
|
|
1395
|
+
function wrap(open, close) {
|
|
1396
|
+
if (!enabled)
|
|
1397
|
+
return (text) => text;
|
|
1398
|
+
return (text) => open + text + close;
|
|
1399
|
+
}
|
|
1400
|
+
var reset = wrap("\x1B[0m", "\x1B[0m");
|
|
1401
|
+
var red = wrap("\x1B[31m", "\x1B[39m");
|
|
1402
|
+
var green = wrap("\x1B[32m", "\x1B[39m");
|
|
1403
|
+
var yellow = wrap("\x1B[33m", "\x1B[39m");
|
|
1404
|
+
var blue = wrap("\x1B[34m", "\x1B[39m");
|
|
1405
|
+
var magenta = wrap("\x1B[35m", "\x1B[39m");
|
|
1406
|
+
var cyan = wrap("\x1B[36m", "\x1B[39m");
|
|
1407
|
+
var white = wrap("\x1B[37m", "\x1B[39m");
|
|
1408
|
+
var gray = wrap("\x1B[90m", "\x1B[39m");
|
|
1409
|
+
var bold = wrap("\x1B[1m", "\x1B[22m");
|
|
1410
|
+
var italic = wrap("\x1B[3m", "\x1B[23m");
|
|
1411
|
+
var underline = wrap("\x1B[4m", "\x1B[24m");
|
|
1412
|
+
var dim = wrap("\x1B[2m", "\x1B[22m");
|
|
1413
|
+
var inverse = wrap("\x1B[7m", "\x1B[27m");
|
|
1414
|
+
var hidden = wrap("\x1B[8m", "\x1B[28m");
|
|
1415
|
+
var strikethrough = wrap("\x1B[9m", "\x1B[29m");
|
|
1416
|
+
var bgRed = wrap("\x1B[41m", "\x1B[49m");
|
|
1417
|
+
var bgGreen = wrap("\x1B[42m", "\x1B[49m");
|
|
1418
|
+
var bgYellow = wrap("\x1B[43m", "\x1B[49m");
|
|
1419
|
+
var bgBlue = wrap("\x1B[44m", "\x1B[49m");
|
|
1420
|
+
var bgMagenta = wrap("\x1B[45m", "\x1B[49m");
|
|
1421
|
+
var bgCyan = wrap("\x1B[46m", "\x1B[49m");
|
|
1422
|
+
var bgWhite = wrap("\x1B[47m", "\x1B[49m");
|
|
1423
|
+
var isColorSupported = enabled;
|
|
1424
|
+
var colors = {
|
|
1425
|
+
reset,
|
|
1426
|
+
red,
|
|
1427
|
+
green,
|
|
1428
|
+
yellow,
|
|
1429
|
+
blue,
|
|
1430
|
+
magenta,
|
|
1431
|
+
cyan,
|
|
1432
|
+
white,
|
|
1433
|
+
gray,
|
|
1434
|
+
bold,
|
|
1435
|
+
italic,
|
|
1436
|
+
underline,
|
|
1437
|
+
dim,
|
|
1438
|
+
inverse,
|
|
1439
|
+
hidden,
|
|
1440
|
+
strikethrough,
|
|
1441
|
+
bgRed,
|
|
1442
|
+
bgGreen,
|
|
1443
|
+
bgYellow,
|
|
1444
|
+
bgBlue,
|
|
1445
|
+
bgMagenta,
|
|
1446
|
+
bgCyan,
|
|
1447
|
+
bgWhite,
|
|
1448
|
+
isColorSupported
|
|
1449
|
+
};
|
|
1450
|
+
var colors_default = colors;
|
|
817
1451
|
var actions = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
818
1452
|
var settings = {
|
|
819
1453
|
actions: new Set(actions),
|
|
@@ -857,429 +1491,60 @@ function diffLines(a, b) {
|
|
|
857
1491
|
}
|
|
858
1492
|
return diff;
|
|
859
1493
|
}
|
|
860
|
-
var isWindows =
|
|
1494
|
+
var isWindows = process8.platform.startsWith("win");
|
|
861
1495
|
var CANCEL_SYMBOL = Symbol("clapp:cancel");
|
|
862
1496
|
function setRawMode(input, value) {
|
|
863
1497
|
const i = input;
|
|
864
1498
|
if (i.isTTY)
|
|
865
1499
|
i.setRawMode(value);
|
|
866
1500
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
870
|
-
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
871
|
-
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
872
|
-
const pattern = `${osc}|${csi}`;
|
|
873
|
-
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
874
|
-
}
|
|
875
|
-
var regex = ansiRegex();
|
|
876
|
-
function stripAnsi(string2) {
|
|
877
|
-
if (typeof string2 !== "string") {
|
|
878
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string2}\``);
|
|
879
|
-
}
|
|
880
|
-
return string2.replace(regex, "");
|
|
881
|
-
}
|
|
882
|
-
function isAmbiguous(x) {
|
|
883
|
-
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
884
|
-
}
|
|
885
|
-
function isFullWidth(x) {
|
|
886
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
887
|
-
}
|
|
888
|
-
function isWide(x) {
|
|
889
|
-
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
1501
|
+
function stripAnsi(str) {
|
|
1502
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
890
1503
|
}
|
|
891
|
-
function
|
|
892
|
-
|
|
893
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
897
|
-
validate(codePoint);
|
|
898
|
-
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
899
|
-
return 2;
|
|
900
|
-
}
|
|
901
|
-
return 1;
|
|
1504
|
+
function stringWidth(str) {
|
|
1505
|
+
return stripAnsi(str).length;
|
|
902
1506
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
if (!countAnsiEscapeCodes) {
|
|
915
|
-
string2 = stripAnsi(string2);
|
|
916
|
-
}
|
|
917
|
-
if (string2.length === 0) {
|
|
918
|
-
return 0;
|
|
919
|
-
}
|
|
920
|
-
let width = 0;
|
|
921
|
-
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
922
|
-
for (const { segment: character } of segmenter.segment(string2)) {
|
|
923
|
-
const codePoint = character.codePointAt(0);
|
|
924
|
-
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
925
|
-
continue;
|
|
926
|
-
}
|
|
927
|
-
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
928
|
-
continue;
|
|
929
|
-
}
|
|
930
|
-
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
|
|
931
|
-
continue;
|
|
932
|
-
}
|
|
933
|
-
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
934
|
-
continue;
|
|
935
|
-
}
|
|
936
|
-
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
937
|
-
continue;
|
|
938
|
-
}
|
|
939
|
-
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
940
|
-
continue;
|
|
941
|
-
}
|
|
942
|
-
if (import_emoji_regex.default().test(character)) {
|
|
943
|
-
width += 2;
|
|
1507
|
+
function wrapAnsi(text, columns, options) {
|
|
1508
|
+
if (!columns || columns < 1)
|
|
1509
|
+
return text;
|
|
1510
|
+
const hard = options?.hard ?? false;
|
|
1511
|
+
const trim = options?.trim ?? true;
|
|
1512
|
+
const lines = text.split(`
|
|
1513
|
+
`);
|
|
1514
|
+
const result = [];
|
|
1515
|
+
for (const line of lines) {
|
|
1516
|
+
if (stringWidth(line) <= columns) {
|
|
1517
|
+
result.push(trim ? line.trimEnd() : line);
|
|
944
1518
|
continue;
|
|
945
1519
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
reset: [0, 0],
|
|
957
|
-
bold: [1, 22],
|
|
958
|
-
dim: [2, 22],
|
|
959
|
-
italic: [3, 23],
|
|
960
|
-
underline: [4, 24],
|
|
961
|
-
overline: [53, 55],
|
|
962
|
-
inverse: [7, 27],
|
|
963
|
-
hidden: [8, 28],
|
|
964
|
-
strikethrough: [9, 29]
|
|
965
|
-
},
|
|
966
|
-
color: {
|
|
967
|
-
black: [30, 39],
|
|
968
|
-
red: [31, 39],
|
|
969
|
-
green: [32, 39],
|
|
970
|
-
yellow: [33, 39],
|
|
971
|
-
blue: [34, 39],
|
|
972
|
-
magenta: [35, 39],
|
|
973
|
-
cyan: [36, 39],
|
|
974
|
-
white: [37, 39],
|
|
975
|
-
blackBright: [90, 39],
|
|
976
|
-
gray: [90, 39],
|
|
977
|
-
grey: [90, 39],
|
|
978
|
-
redBright: [91, 39],
|
|
979
|
-
greenBright: [92, 39],
|
|
980
|
-
yellowBright: [93, 39],
|
|
981
|
-
blueBright: [94, 39],
|
|
982
|
-
magentaBright: [95, 39],
|
|
983
|
-
cyanBright: [96, 39],
|
|
984
|
-
whiteBright: [97, 39]
|
|
985
|
-
},
|
|
986
|
-
bgColor: {
|
|
987
|
-
bgBlack: [40, 49],
|
|
988
|
-
bgRed: [41, 49],
|
|
989
|
-
bgGreen: [42, 49],
|
|
990
|
-
bgYellow: [43, 49],
|
|
991
|
-
bgBlue: [44, 49],
|
|
992
|
-
bgMagenta: [45, 49],
|
|
993
|
-
bgCyan: [46, 49],
|
|
994
|
-
bgWhite: [47, 49],
|
|
995
|
-
bgBlackBright: [100, 49],
|
|
996
|
-
bgGray: [100, 49],
|
|
997
|
-
bgGrey: [100, 49],
|
|
998
|
-
bgRedBright: [101, 49],
|
|
999
|
-
bgGreenBright: [102, 49],
|
|
1000
|
-
bgYellowBright: [103, 49],
|
|
1001
|
-
bgBlueBright: [104, 49],
|
|
1002
|
-
bgMagentaBright: [105, 49],
|
|
1003
|
-
bgCyanBright: [106, 49],
|
|
1004
|
-
bgWhiteBright: [107, 49]
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
var modifierNames = Object.keys(styles.modifier);
|
|
1008
|
-
var foregroundColorNames = Object.keys(styles.color);
|
|
1009
|
-
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
1010
|
-
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
1011
|
-
function assembleStyles() {
|
|
1012
|
-
const codes = new Map;
|
|
1013
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
|
1014
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
1015
|
-
styles[styleName] = {
|
|
1016
|
-
open: `\x1B[${style[0]}m`,
|
|
1017
|
-
close: `\x1B[${style[1]}m`
|
|
1018
|
-
};
|
|
1019
|
-
group[styleName] = styles[styleName];
|
|
1020
|
-
codes.set(style[0], style[1]);
|
|
1021
|
-
}
|
|
1022
|
-
Object.defineProperty(styles, groupName, {
|
|
1023
|
-
value: group,
|
|
1024
|
-
enumerable: false
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
Object.defineProperty(styles, "codes", {
|
|
1028
|
-
value: codes,
|
|
1029
|
-
enumerable: false
|
|
1030
|
-
});
|
|
1031
|
-
styles.color.close = "\x1B[39m";
|
|
1032
|
-
styles.bgColor.close = "\x1B[49m";
|
|
1033
|
-
styles.color.ansi = wrapAnsi16();
|
|
1034
|
-
styles.color.ansi256 = wrapAnsi256();
|
|
1035
|
-
styles.color.ansi16m = wrapAnsi16m();
|
|
1036
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
1037
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
1038
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
1039
|
-
Object.defineProperties(styles, {
|
|
1040
|
-
rgbToAnsi256: {
|
|
1041
|
-
value: (red, green, blue) => {
|
|
1042
|
-
if (red === green && green === blue) {
|
|
1043
|
-
if (red < 8) {
|
|
1044
|
-
return 16;
|
|
1045
|
-
}
|
|
1046
|
-
if (red > 248) {
|
|
1047
|
-
return 231;
|
|
1048
|
-
}
|
|
1049
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
1050
|
-
}
|
|
1051
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
1052
|
-
},
|
|
1053
|
-
enumerable: false
|
|
1054
|
-
},
|
|
1055
|
-
hexToRgb: {
|
|
1056
|
-
value: (hex) => {
|
|
1057
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
1058
|
-
if (!matches) {
|
|
1059
|
-
return [0, 0, 0];
|
|
1060
|
-
}
|
|
1061
|
-
let [colorString] = matches;
|
|
1062
|
-
if (colorString.length === 3) {
|
|
1063
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
1064
|
-
}
|
|
1065
|
-
const integer = Number.parseInt(colorString, 16);
|
|
1066
|
-
return [
|
|
1067
|
-
integer >> 16 & 255,
|
|
1068
|
-
integer >> 8 & 255,
|
|
1069
|
-
integer & 255
|
|
1070
|
-
];
|
|
1071
|
-
},
|
|
1072
|
-
enumerable: false
|
|
1073
|
-
},
|
|
1074
|
-
hexToAnsi256: {
|
|
1075
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
1076
|
-
enumerable: false
|
|
1077
|
-
},
|
|
1078
|
-
ansi256ToAnsi: {
|
|
1079
|
-
value: (code) => {
|
|
1080
|
-
if (code < 8) {
|
|
1081
|
-
return 30 + code;
|
|
1082
|
-
}
|
|
1083
|
-
if (code < 16) {
|
|
1084
|
-
return 90 + (code - 8);
|
|
1085
|
-
}
|
|
1086
|
-
let red;
|
|
1087
|
-
let green;
|
|
1088
|
-
let blue;
|
|
1089
|
-
if (code >= 232) {
|
|
1090
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
1091
|
-
green = red;
|
|
1092
|
-
blue = red;
|
|
1093
|
-
} else {
|
|
1094
|
-
code -= 16;
|
|
1095
|
-
const remainder = code % 36;
|
|
1096
|
-
red = Math.floor(code / 36) / 5;
|
|
1097
|
-
green = Math.floor(remainder / 6) / 5;
|
|
1098
|
-
blue = remainder % 6 / 5;
|
|
1520
|
+
if (hard) {
|
|
1521
|
+
let current = "";
|
|
1522
|
+
let currentWidth = 0;
|
|
1523
|
+
let i = 0;
|
|
1524
|
+
while (i < line.length) {
|
|
1525
|
+
const ansiMatch = line.slice(i).match(/^\x1b\[[0-9;]*m/);
|
|
1526
|
+
if (ansiMatch) {
|
|
1527
|
+
current += ansiMatch[0];
|
|
1528
|
+
i += ansiMatch[0].length;
|
|
1529
|
+
continue;
|
|
1099
1530
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1531
|
+
if (currentWidth >= columns) {
|
|
1532
|
+
result.push(trim ? current.trimEnd() : current);
|
|
1533
|
+
current = "";
|
|
1534
|
+
currentWidth = 0;
|
|
1103
1535
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
}
|
|
1108
|
-
return result;
|
|
1109
|
-
},
|
|
1110
|
-
enumerable: false
|
|
1111
|
-
},
|
|
1112
|
-
rgbToAnsi: {
|
|
1113
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
1114
|
-
enumerable: false
|
|
1115
|
-
},
|
|
1116
|
-
hexToAnsi: {
|
|
1117
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
1118
|
-
enumerable: false
|
|
1119
|
-
}
|
|
1120
|
-
});
|
|
1121
|
-
return styles;
|
|
1122
|
-
}
|
|
1123
|
-
var ansiStyles = assembleStyles();
|
|
1124
|
-
var ansi_styles_default = ansiStyles;
|
|
1125
|
-
var ESCAPES = new Set([
|
|
1126
|
-
"\x1B",
|
|
1127
|
-
"\x9B"
|
|
1128
|
-
]);
|
|
1129
|
-
var END_CODE = 39;
|
|
1130
|
-
var ANSI_ESCAPE_BELL = "\x07";
|
|
1131
|
-
var ANSI_CSI = "[";
|
|
1132
|
-
var ANSI_OSC = "]";
|
|
1133
|
-
var ANSI_SGR_TERMINATOR = "m";
|
|
1134
|
-
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
1135
|
-
var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
1136
|
-
var wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
1137
|
-
var wordLengths = (string2) => string2.split(" ").map((character) => stringWidth(character));
|
|
1138
|
-
var wrapWord = (rows, word, columns) => {
|
|
1139
|
-
const characters = [...word];
|
|
1140
|
-
let isInsideEscape = false;
|
|
1141
|
-
let isInsideLinkEscape = false;
|
|
1142
|
-
let visible = stringWidth(stripAnsi(rows.at(-1)));
|
|
1143
|
-
for (const [index, character] of characters.entries()) {
|
|
1144
|
-
const characterLength = stringWidth(character);
|
|
1145
|
-
if (visible + characterLength <= columns) {
|
|
1146
|
-
rows[rows.length - 1] += character;
|
|
1147
|
-
} else {
|
|
1148
|
-
rows.push(character);
|
|
1149
|
-
visible = 0;
|
|
1150
|
-
}
|
|
1151
|
-
if (ESCAPES.has(character)) {
|
|
1152
|
-
isInsideEscape = true;
|
|
1153
|
-
const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("");
|
|
1154
|
-
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
|
|
1155
|
-
}
|
|
1156
|
-
if (isInsideEscape) {
|
|
1157
|
-
if (isInsideLinkEscape) {
|
|
1158
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
1159
|
-
isInsideEscape = false;
|
|
1160
|
-
isInsideLinkEscape = false;
|
|
1161
|
-
}
|
|
1162
|
-
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
1163
|
-
isInsideEscape = false;
|
|
1164
|
-
}
|
|
1165
|
-
continue;
|
|
1166
|
-
}
|
|
1167
|
-
visible += characterLength;
|
|
1168
|
-
if (visible === columns && index < characters.length - 1) {
|
|
1169
|
-
rows.push("");
|
|
1170
|
-
visible = 0;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
|
|
1174
|
-
rows[rows.length - 2] += rows.pop();
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
|
-
var stringVisibleTrimSpacesRight = (string2) => {
|
|
1178
|
-
const words = string2.split(" ");
|
|
1179
|
-
let last = words.length;
|
|
1180
|
-
while (last > 0) {
|
|
1181
|
-
if (stringWidth(words[last - 1]) > 0) {
|
|
1182
|
-
break;
|
|
1183
|
-
}
|
|
1184
|
-
last--;
|
|
1185
|
-
}
|
|
1186
|
-
if (last === words.length) {
|
|
1187
|
-
return string2;
|
|
1188
|
-
}
|
|
1189
|
-
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
1190
|
-
};
|
|
1191
|
-
var exec = (string2, columns, options = {}) => {
|
|
1192
|
-
if (options.trim !== false && string2.trim() === "") {
|
|
1193
|
-
return "";
|
|
1194
|
-
}
|
|
1195
|
-
let returnValue = "";
|
|
1196
|
-
let escapeCode;
|
|
1197
|
-
let escapeUrl;
|
|
1198
|
-
const lengths = wordLengths(string2);
|
|
1199
|
-
let rows = [""];
|
|
1200
|
-
for (const [index, word] of string2.split(" ").entries()) {
|
|
1201
|
-
if (options.trim !== false) {
|
|
1202
|
-
rows[rows.length - 1] = rows.at(-1).trimStart();
|
|
1203
|
-
}
|
|
1204
|
-
let rowLength = stringWidth(rows.at(-1));
|
|
1205
|
-
if (index !== 0) {
|
|
1206
|
-
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
1207
|
-
rows.push("");
|
|
1208
|
-
rowLength = 0;
|
|
1209
|
-
}
|
|
1210
|
-
if (rowLength > 0 || options.trim === false) {
|
|
1211
|
-
rows[rows.length - 1] += " ";
|
|
1212
|
-
rowLength++;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
if (options.hard && lengths[index] > columns) {
|
|
1216
|
-
const remainingColumns = columns - rowLength;
|
|
1217
|
-
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
1218
|
-
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
|
1219
|
-
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
1220
|
-
rows.push("");
|
|
1221
|
-
}
|
|
1222
|
-
wrapWord(rows, word, columns);
|
|
1223
|
-
continue;
|
|
1224
|
-
}
|
|
1225
|
-
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
|
1226
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
1227
|
-
wrapWord(rows, word, columns);
|
|
1228
|
-
continue;
|
|
1229
|
-
}
|
|
1230
|
-
rows.push("");
|
|
1231
|
-
}
|
|
1232
|
-
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
1233
|
-
wrapWord(rows, word, columns);
|
|
1234
|
-
continue;
|
|
1235
|
-
}
|
|
1236
|
-
rows[rows.length - 1] += word;
|
|
1237
|
-
}
|
|
1238
|
-
if (options.trim !== false) {
|
|
1239
|
-
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
1240
|
-
}
|
|
1241
|
-
const preString = rows.join(`
|
|
1242
|
-
`);
|
|
1243
|
-
const pre = [...preString];
|
|
1244
|
-
let preStringIndex = 0;
|
|
1245
|
-
for (const [index, character] of pre.entries()) {
|
|
1246
|
-
returnValue += character;
|
|
1247
|
-
if (ESCAPES.has(character)) {
|
|
1248
|
-
const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
|
|
1249
|
-
if (groups.code !== undefined) {
|
|
1250
|
-
const code2 = Number.parseFloat(groups.code);
|
|
1251
|
-
escapeCode = code2 === END_CODE ? undefined : code2;
|
|
1252
|
-
} else if (groups.uri !== undefined) {
|
|
1253
|
-
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
const code = ansi_styles_default.codes.get(Number(escapeCode));
|
|
1257
|
-
if (pre[index + 1] === `
|
|
1258
|
-
`) {
|
|
1259
|
-
if (escapeUrl) {
|
|
1260
|
-
returnValue += wrapAnsiHyperlink("");
|
|
1261
|
-
}
|
|
1262
|
-
if (escapeCode && code) {
|
|
1263
|
-
returnValue += wrapAnsiCode(code);
|
|
1264
|
-
}
|
|
1265
|
-
} else if (character === `
|
|
1266
|
-
`) {
|
|
1267
|
-
if (escapeCode && code) {
|
|
1268
|
-
returnValue += wrapAnsiCode(escapeCode);
|
|
1536
|
+
current += line[i];
|
|
1537
|
+
currentWidth++;
|
|
1538
|
+
i++;
|
|
1269
1539
|
}
|
|
1270
|
-
if (
|
|
1271
|
-
|
|
1540
|
+
if (current) {
|
|
1541
|
+
result.push(trim ? current.trimEnd() : current);
|
|
1272
1542
|
}
|
|
1543
|
+
} else {
|
|
1544
|
+
result.push(trim ? line.trimEnd() : line);
|
|
1273
1545
|
}
|
|
1274
|
-
preStringIndex += character.length;
|
|
1275
1546
|
}
|
|
1276
|
-
return
|
|
1277
|
-
};
|
|
1278
|
-
function wrapAnsi(string2, columns, options) {
|
|
1279
|
-
return String(string2).normalize().replaceAll(`\r
|
|
1280
|
-
`, `
|
|
1281
|
-
`).split(`
|
|
1282
|
-
`).map((line) => exec(line, columns, options)).join(`
|
|
1547
|
+
return result.join(`
|
|
1283
1548
|
`);
|
|
1284
1549
|
}
|
|
1285
1550
|
|
|
@@ -1470,12 +1735,12 @@ class Prompt {
|
|
|
1470
1735
|
}
|
|
1471
1736
|
}
|
|
1472
1737
|
restoreCursor() {
|
|
1473
|
-
const lines = wrapAnsi(this._prevFrame,
|
|
1738
|
+
const lines = wrapAnsi(this._prevFrame, process9.stdout.columns, { hard: true, trim: false }).split(`
|
|
1474
1739
|
`).length - 1;
|
|
1475
1740
|
this.output.write(cursor.move(-999, lines * -1));
|
|
1476
1741
|
}
|
|
1477
1742
|
render() {
|
|
1478
|
-
const frame = wrapAnsi(this._render(this) ?? "",
|
|
1743
|
+
const frame = wrapAnsi(this._render(this) ?? "", process9.stdout.columns, {
|
|
1479
1744
|
hard: true,
|
|
1480
1745
|
trim: false
|
|
1481
1746
|
});
|
|
@@ -1559,14 +1824,14 @@ class AutocompletePrompt extends Prompt {
|
|
|
1559
1824
|
}
|
|
1560
1825
|
get userInputWithCursor() {
|
|
1561
1826
|
if (!this.userInput) {
|
|
1562
|
-
return
|
|
1827
|
+
return colors_default.inverse(colors_default.hidden("_"));
|
|
1563
1828
|
}
|
|
1564
1829
|
if (this._cursor >= this.userInput.length) {
|
|
1565
1830
|
return `${this.userInput}\u2588`;
|
|
1566
1831
|
}
|
|
1567
1832
|
const s1 = this.userInput.slice(0, this._cursor);
|
|
1568
1833
|
const [s2, ...s3] = this.userInput.slice(this._cursor);
|
|
1569
|
-
return `${s1}${
|
|
1834
|
+
return `${s1}${colors_default.inverse(s2)}${s3.join("")}`;
|
|
1570
1835
|
}
|
|
1571
1836
|
get options() {
|
|
1572
1837
|
if (typeof this.#options === "function") {
|
|
@@ -1746,91 +2011,6 @@ class GroupMultiSelectPrompt extends Prompt {
|
|
|
1746
2011
|
});
|
|
1747
2012
|
}
|
|
1748
2013
|
}
|
|
1749
|
-
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
1750
|
-
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
1751
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
1752
|
-
var codes = {
|
|
1753
|
-
red: ["\x1B[31m", "\x1B[39m"],
|
|
1754
|
-
green: ["\x1B[32m", "\x1B[39m"],
|
|
1755
|
-
blue: ["\x1B[34m", "\x1B[39m"],
|
|
1756
|
-
yellow: ["\x1B[33m", "\x1B[39m"],
|
|
1757
|
-
cyan: ["\x1B[36m", "\x1B[39m"],
|
|
1758
|
-
magenta: ["\x1B[35m", "\x1B[39m"],
|
|
1759
|
-
white: ["\x1B[37m", "\x1B[39m"],
|
|
1760
|
-
gray: ["\x1B[90m", "\x1B[39m"],
|
|
1761
|
-
bgRed: ["\x1B[41m", "\x1B[49m"],
|
|
1762
|
-
bgGreen: ["\x1B[42m", "\x1B[49m"],
|
|
1763
|
-
bgBlue: ["\x1B[44m", "\x1B[49m"],
|
|
1764
|
-
bgYellow: ["\x1B[43m", "\x1B[49m"],
|
|
1765
|
-
bgCyan: ["\x1B[46m", "\x1B[49m"],
|
|
1766
|
-
bgMagenta: ["\x1B[45m", "\x1B[49m"],
|
|
1767
|
-
bold: ["\x1B[1m", "\x1B[22m"],
|
|
1768
|
-
italic: ["\x1B[3m", "\x1B[23m"],
|
|
1769
|
-
underline: ["\x1B[4m", "\x1B[24m"],
|
|
1770
|
-
dim: ["\x1B[2m", "\x1B[22m"],
|
|
1771
|
-
inverse: ["\x1B[7m", "\x1B[27m"],
|
|
1772
|
-
hidden: ["\x1B[8m", "\x1B[28m"],
|
|
1773
|
-
strikethrough: ["\x1B[9m", "\x1B[29m"]
|
|
1774
|
-
};
|
|
1775
|
-
var theme = {
|
|
1776
|
-
primary: "blue",
|
|
1777
|
-
secondary: "cyan",
|
|
1778
|
-
success: "green",
|
|
1779
|
-
warning: "yellow",
|
|
1780
|
-
error: "red",
|
|
1781
|
-
info: "magenta",
|
|
1782
|
-
muted: "gray"
|
|
1783
|
-
};
|
|
1784
|
-
function detectColorSupport() {
|
|
1785
|
-
return true;
|
|
1786
|
-
}
|
|
1787
|
-
function createStyler() {
|
|
1788
|
-
const styler = {};
|
|
1789
|
-
styler.supportsColor = detectColorSupport();
|
|
1790
|
-
function createStyleFunction(styleName, styles2 = []) {
|
|
1791
|
-
const styleList = styleName === "" ? [] : [...styles2, styleName];
|
|
1792
|
-
const fn = function(text) {
|
|
1793
|
-
if (!styler.supportsColor)
|
|
1794
|
-
return text;
|
|
1795
|
-
let openCodes = "";
|
|
1796
|
-
let closeCodes = "";
|
|
1797
|
-
for (const style of styleList) {
|
|
1798
|
-
if (style in theme && theme[style] in codes) {
|
|
1799
|
-
const themeStyle = theme[style];
|
|
1800
|
-
openCodes += codes[themeStyle][0];
|
|
1801
|
-
closeCodes = codes[themeStyle][1] + closeCodes;
|
|
1802
|
-
} else if (style in codes) {
|
|
1803
|
-
openCodes += codes[style][0];
|
|
1804
|
-
closeCodes = codes[style][1] + closeCodes;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
return openCodes + text + closeCodes;
|
|
1808
|
-
};
|
|
1809
|
-
const allStyles2 = [...Object.keys(codes), ...Object.keys(theme)];
|
|
1810
|
-
for (const style of allStyles2) {
|
|
1811
|
-
if (!(style in fn)) {
|
|
1812
|
-
Object.defineProperty(fn, style, {
|
|
1813
|
-
get() {
|
|
1814
|
-
return createStyleFunction(style, styleList);
|
|
1815
|
-
}
|
|
1816
|
-
});
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
return fn;
|
|
1820
|
-
}
|
|
1821
|
-
const allStyles = [...Object.keys(codes), ...Object.keys(theme)];
|
|
1822
|
-
for (const style of allStyles) {
|
|
1823
|
-
if (!(style in styler)) {
|
|
1824
|
-
Object.defineProperty(styler, style, {
|
|
1825
|
-
get() {
|
|
1826
|
-
return createStyleFunction(style);
|
|
1827
|
-
}
|
|
1828
|
-
});
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
return styler;
|
|
1832
|
-
}
|
|
1833
|
-
var style = createStyler();
|
|
1834
2014
|
var unicode = isUnicodeSupported();
|
|
1835
2015
|
var unicodeOr = (c, fallback) => unicode ? c : fallback;
|
|
1836
2016
|
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
@@ -1854,40 +2034,25 @@ var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
|
1854
2034
|
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
1855
2035
|
var S_WARN = unicodeOr("\u25B2", "!");
|
|
1856
2036
|
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
1857
|
-
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
1858
|
-
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
1859
|
-
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
1860
|
-
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
1861
|
-
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
1862
|
-
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
1863
|
-
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
1864
|
-
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
1865
|
-
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
1866
|
-
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
1867
2037
|
var S_PROGRESS_CHAR = {
|
|
1868
2038
|
light: unicodeOr("\u2500", "-"),
|
|
1869
2039
|
heavy: unicodeOr("\u2501", "="),
|
|
1870
2040
|
block: unicodeOr("\u2588", "#")
|
|
1871
2041
|
};
|
|
1872
|
-
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
1873
|
-
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
1874
|
-
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
1875
2042
|
function getPrefix() {
|
|
1876
|
-
return `${
|
|
2043
|
+
return `${colors_default.gray(S_BAR)} `;
|
|
1877
2044
|
}
|
|
1878
2045
|
var prefix = getPrefix();
|
|
1879
|
-
var color18 = __toESM(require_picocolors(), 1);
|
|
1880
|
-
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
1881
2046
|
// package.json
|
|
1882
|
-
var version = "0.0.
|
|
2047
|
+
var version = "0.0.15";
|
|
1883
2048
|
|
|
1884
2049
|
// src/cli/middleware.ts
|
|
1885
|
-
import
|
|
1886
|
-
import
|
|
1887
|
-
import
|
|
2050
|
+
import fs2 from "fs/promises";
|
|
2051
|
+
import path2 from "path";
|
|
2052
|
+
import process6 from "process";
|
|
1888
2053
|
|
|
1889
2054
|
// src/cli/colors.ts
|
|
1890
|
-
var
|
|
2055
|
+
var colors2 = {
|
|
1891
2056
|
reset: "\x1B[0m",
|
|
1892
2057
|
bold: "\x1B[1m",
|
|
1893
2058
|
dim: "\x1B[2m",
|
|
@@ -1900,15 +2065,15 @@ var colors = {
|
|
|
1900
2065
|
gray: "\x1B[90m"
|
|
1901
2066
|
};
|
|
1902
2067
|
var chalk = {
|
|
1903
|
-
red: (text) => `${
|
|
1904
|
-
green: (text) => `${
|
|
1905
|
-
yellow: (text) => `${
|
|
1906
|
-
blue: (text) => `${
|
|
1907
|
-
cyan: (text) => `${
|
|
1908
|
-
white: (text) => `${
|
|
1909
|
-
gray: (text) => `${
|
|
1910
|
-
bold: (text) => `${
|
|
1911
|
-
dim: (text) => `${
|
|
2068
|
+
red: (text) => `${colors2.red}${text}${colors2.reset}`,
|
|
2069
|
+
green: (text) => `${colors2.green}${text}${colors2.reset}`,
|
|
2070
|
+
yellow: (text) => `${colors2.yellow}${text}${colors2.reset}`,
|
|
2071
|
+
blue: (text) => `${colors2.blue}${text}${colors2.reset}`,
|
|
2072
|
+
cyan: (text) => `${colors2.cyan}${text}${colors2.reset}`,
|
|
2073
|
+
white: (text) => `${colors2.white}${text}${colors2.reset}`,
|
|
2074
|
+
gray: (text) => `${colors2.gray}${text}${colors2.reset}`,
|
|
2075
|
+
bold: (text) => `${colors2.bold}${text}${colors2.reset}`,
|
|
2076
|
+
dim: (text) => `${colors2.dim}${text}${colors2.reset}`,
|
|
1912
2077
|
hex: (_color) => (text) => text
|
|
1913
2078
|
};
|
|
1914
2079
|
|
|
@@ -1950,13 +2115,13 @@ export function isValidMiddleware(name: string): name is MiddlewareName {
|
|
|
1950
2115
|
return [${middlewareInfo.map((m) => `'${m.name}'`).join(", ")}].includes(name)
|
|
1951
2116
|
}
|
|
1952
2117
|
`;
|
|
1953
|
-
await
|
|
2118
|
+
await fs2.writeFile(outputPath, typeContent);
|
|
1954
2119
|
}
|
|
1955
2120
|
async function findTsFiles(dir) {
|
|
1956
2121
|
const files = [];
|
|
1957
|
-
const entries = await
|
|
2122
|
+
const entries = await fs2.readdir(dir, { withFileTypes: true });
|
|
1958
2123
|
for (const entry of entries) {
|
|
1959
|
-
const fullPath =
|
|
2124
|
+
const fullPath = path2.join(dir, entry.name);
|
|
1960
2125
|
if (entry.isDirectory()) {
|
|
1961
2126
|
files.push(...await findTsFiles(fullPath));
|
|
1962
2127
|
} else if (entry.isFile() && entry.name.endsWith(".ts")) {
|
|
@@ -1968,13 +2133,13 @@ async function findTsFiles(dir) {
|
|
|
1968
2133
|
async function scanFileForMiddleware(filePath) {
|
|
1969
2134
|
const middlewareClasses = [];
|
|
1970
2135
|
try {
|
|
1971
|
-
const content = await
|
|
2136
|
+
const content = await fs2.readFile(filePath, "utf-8");
|
|
1972
2137
|
const classRegex = /export\s+(?:default\s+)?class\s+(\w+)\s+(?:implements\s+Middleware|\{[\s\S]*?handle\s*\([\s\S]*?\))/g;
|
|
1973
2138
|
let match = null;
|
|
1974
2139
|
while (match = classRegex.exec(content)) {
|
|
1975
2140
|
const className = match[1];
|
|
1976
2141
|
if (className.includes("Middleware") || match[0].includes("implements Middleware")) {
|
|
1977
|
-
const relativePath =
|
|
2142
|
+
const relativePath = path2.relative(process6.cwd(), filePath);
|
|
1978
2143
|
const importPath = relativePath.replace(/\.ts$/, "");
|
|
1979
2144
|
middlewareClasses.push({
|
|
1980
2145
|
name: className,
|
|
@@ -2038,7 +2203,7 @@ ${allMiddleware.map((m) => ` ${m.name}: ${m.name}`).join(`,
|
|
|
2038
2203
|
`)}
|
|
2039
2204
|
}
|
|
2040
2205
|
`;
|
|
2041
|
-
await
|
|
2206
|
+
await fs2.writeFile(outputPath, typeContent);
|
|
2042
2207
|
console.log(chalk.green(`\u2728 Middleware map generated at ${outputPath} with ${allMiddleware.length} middleware classes`));
|
|
2043
2208
|
console.log(chalk.blue("Found middleware classes:"));
|
|
2044
2209
|
for (const m of allMiddleware) {
|
|
@@ -2051,15 +2216,15 @@ ${allMiddleware.map((m) => ` ${m.name}: ${m.name}`).join(`,
|
|
|
2051
2216
|
}
|
|
2052
2217
|
async function watchDirectoryForMiddleware(directoryPath, outputPath) {
|
|
2053
2218
|
try {
|
|
2054
|
-
await
|
|
2219
|
+
await fs2.access(directoryPath);
|
|
2055
2220
|
} catch {
|
|
2056
2221
|
console.error(chalk.red(`Directory not found at ${directoryPath}`));
|
|
2057
|
-
|
|
2222
|
+
process6.exit(1);
|
|
2058
2223
|
}
|
|
2059
2224
|
await generateMiddlewareMap(directoryPath, outputPath);
|
|
2060
2225
|
console.log(chalk.blue(`Watching for changes in ${directoryPath}...`));
|
|
2061
2226
|
let timeoutId = null;
|
|
2062
|
-
const watcher =
|
|
2227
|
+
const watcher = fs2.watch(directoryPath, { recursive: true });
|
|
2063
2228
|
for await (const _event of watcher) {
|
|
2064
2229
|
if (timeoutId) {
|
|
2065
2230
|
clearTimeout(timeoutId);
|
|
@@ -2076,18 +2241,18 @@ async function watchDirectoryForMiddleware(directoryPath, outputPath) {
|
|
|
2076
2241
|
}
|
|
2077
2242
|
}
|
|
2078
2243
|
async function watchMiddlewareDirectory(outputPath) {
|
|
2079
|
-
const middlewarePath =
|
|
2244
|
+
const middlewarePath = path2.join(process6.cwd(), "src", "middleware");
|
|
2080
2245
|
try {
|
|
2081
|
-
await
|
|
2246
|
+
await fs2.access(middlewarePath);
|
|
2082
2247
|
} catch {
|
|
2083
2248
|
console.error(chalk.red(`Middleware directory not found at ${middlewarePath}`));
|
|
2084
|
-
|
|
2249
|
+
process6.exit(1);
|
|
2085
2250
|
}
|
|
2086
2251
|
await generateMiddlewareTypes(outputPath);
|
|
2087
2252
|
console.log(chalk.green(`\u2728 Middleware types generated at ${outputPath}`));
|
|
2088
2253
|
console.log(chalk.blue(`Watching for changes in ${middlewarePath}...`));
|
|
2089
2254
|
let timeoutId = null;
|
|
2090
|
-
const watcher =
|
|
2255
|
+
const watcher = fs2.watch(middlewarePath, { recursive: true });
|
|
2091
2256
|
for await (const _event of watcher) {
|
|
2092
2257
|
if (timeoutId) {
|
|
2093
2258
|
clearTimeout(timeoutId);
|
|
@@ -2106,15 +2271,15 @@ async function watchMiddlewareDirectory(outputPath) {
|
|
|
2106
2271
|
}
|
|
2107
2272
|
|
|
2108
2273
|
// src/cli/openapi.ts
|
|
2109
|
-
import
|
|
2110
|
-
import
|
|
2274
|
+
import fs3 from "fs/promises";
|
|
2275
|
+
import process10 from "process";
|
|
2111
2276
|
async function generateOpenAPISpec(options) {
|
|
2112
2277
|
try {
|
|
2113
|
-
const routesFile = `${
|
|
2278
|
+
const routesFile = `${process10.cwd()}/routes/index.ts`;
|
|
2114
2279
|
const { router } = await import(routesFile);
|
|
2115
2280
|
if (!router) {
|
|
2116
2281
|
console.error(chalk.red(`Could not find router instance in ${routesFile}.`));
|
|
2117
|
-
|
|
2282
|
+
process10.exit(1);
|
|
2118
2283
|
}
|
|
2119
2284
|
const routes = router.routes || [];
|
|
2120
2285
|
if (routes.length === 0) {
|
|
@@ -2175,12 +2340,12 @@ async function generateOpenAPISpec(options) {
|
|
|
2175
2340
|
}));
|
|
2176
2341
|
}
|
|
2177
2342
|
const outputPath = options.output || "openapi.json";
|
|
2178
|
-
await
|
|
2343
|
+
await fs3.writeFile(outputPath, JSON.stringify(openapi, null, 2));
|
|
2179
2344
|
console.log(chalk.green(`\u2728 OpenAPI specification generated at ${outputPath}`));
|
|
2180
2345
|
console.log(chalk.blue(`Import this file into Postman, Swagger UI, or other API tools to explore your API.`));
|
|
2181
2346
|
} catch (error) {
|
|
2182
2347
|
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
|
2183
|
-
console.error(chalk.red(`Routes file not found at ${
|
|
2348
|
+
console.error(chalk.red(`Routes file not found at ${process10.cwd()}/routes/index.ts`));
|
|
2184
2349
|
console.error(chalk.yellow('Make sure your routes are defined and exported as "router" in routes/index.ts'));
|
|
2185
2350
|
} else {
|
|
2186
2351
|
console.error(chalk.red(`Error generating OpenAPI specification: ${error.message}`));
|
|
@@ -2207,8 +2372,8 @@ function generateServers(options) {
|
|
|
2207
2372
|
}
|
|
2208
2373
|
return servers;
|
|
2209
2374
|
}
|
|
2210
|
-
function extractTagFromPath(
|
|
2211
|
-
const segments =
|
|
2375
|
+
function extractTagFromPath(path3) {
|
|
2376
|
+
const segments = path3.split("/").filter(Boolean);
|
|
2212
2377
|
if (segments.length > 0) {
|
|
2213
2378
|
if (segments[0].toLowerCase() === "api" && segments.length > 1) {
|
|
2214
2379
|
return segments[1];
|
|
@@ -2217,8 +2382,8 @@ function extractTagFromPath(path2) {
|
|
|
2217
2382
|
}
|
|
2218
2383
|
return "default";
|
|
2219
2384
|
}
|
|
2220
|
-
function generateOperationId(method,
|
|
2221
|
-
const pathWithoutParams =
|
|
2385
|
+
function generateOperationId(method, path3) {
|
|
2386
|
+
const pathWithoutParams = path3.replace(/\{([^}]+)\}/g, "_$1");
|
|
2222
2387
|
const segments = pathWithoutParams.split("/").filter(Boolean);
|
|
2223
2388
|
if (segments.length === 0) {
|
|
2224
2389
|
return method.toLowerCase();
|
|
@@ -2391,16 +2556,16 @@ function extractSecurityFromMiddleware(middleware2) {
|
|
|
2391
2556
|
}
|
|
2392
2557
|
|
|
2393
2558
|
// src/cli/router.ts
|
|
2394
|
-
import
|
|
2395
|
-
import
|
|
2396
|
-
import
|
|
2559
|
+
import fs4 from "fs/promises";
|
|
2560
|
+
import path3 from "path";
|
|
2561
|
+
import process12 from "process";
|
|
2397
2562
|
async function generateRouterTypes(outputPath) {
|
|
2398
2563
|
try {
|
|
2399
|
-
const routesFile = `${
|
|
2564
|
+
const routesFile = `${process12.cwd()}/routes/index.ts`;
|
|
2400
2565
|
const { router } = await import(routesFile);
|
|
2401
2566
|
if (!router) {
|
|
2402
2567
|
console.error(chalk.red(`Could not find router instance in ${routesFile}.`));
|
|
2403
|
-
|
|
2568
|
+
process12.exit(1);
|
|
2404
2569
|
}
|
|
2405
2570
|
const routerMethods = Object.getOwnPropertyNames(Object.getPrototypeOf(router)).filter((method) => !method.startsWith("_") && method !== "constructor" && typeof router[method] === "function");
|
|
2406
2571
|
const extendedProperties = Object.keys(router).filter((prop) => !["routes", "middleware", "hooks", "config"].includes(prop) && typeof prop === "string" && !prop.startsWith("_"));
|
|
@@ -2463,11 +2628,11 @@ export type RouterExtension = {
|
|
|
2463
2628
|
*/
|
|
2464
2629
|
export type ExtendRouter<T extends RouterExtension> = Router & T
|
|
2465
2630
|
`;
|
|
2466
|
-
await
|
|
2631
|
+
await fs4.writeFile(outputPath, typeContent);
|
|
2467
2632
|
console.log(chalk.green(`\u2728 Router types generated at ${outputPath}`));
|
|
2468
2633
|
} catch (error) {
|
|
2469
2634
|
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
|
2470
|
-
console.error(chalk.red(`Routes file not found at ${
|
|
2635
|
+
console.error(chalk.red(`Routes file not found at ${process12.cwd()}/routes/index.ts`));
|
|
2471
2636
|
console.error(chalk.yellow('Make sure your routes are defined and exported as "router" in routes/index.ts'));
|
|
2472
2637
|
} else {
|
|
2473
2638
|
console.error(chalk.red(`Error generating router types: ${error.message}`));
|
|
@@ -2477,20 +2642,20 @@ export type ExtendRouter<T extends RouterExtension> = Router & T
|
|
|
2477
2642
|
}
|
|
2478
2643
|
async function watchRouterFiles(outputPath) {
|
|
2479
2644
|
const routerFiles = [
|
|
2480
|
-
|
|
2481
|
-
|
|
2645
|
+
path3.join(process12.cwd(), "routes"),
|
|
2646
|
+
path3.join(process12.cwd(), "src")
|
|
2482
2647
|
];
|
|
2483
2648
|
let validPath = false;
|
|
2484
2649
|
for (const dirPath of routerFiles) {
|
|
2485
2650
|
try {
|
|
2486
|
-
await
|
|
2651
|
+
await fs4.access(dirPath);
|
|
2487
2652
|
validPath = true;
|
|
2488
2653
|
break;
|
|
2489
2654
|
} catch {}
|
|
2490
2655
|
}
|
|
2491
2656
|
if (!validPath) {
|
|
2492
2657
|
console.error(chalk.red(`No valid source directories found to watch.`));
|
|
2493
|
-
|
|
2658
|
+
process12.exit(1);
|
|
2494
2659
|
}
|
|
2495
2660
|
await generateRouterTypes(outputPath);
|
|
2496
2661
|
console.log(chalk.green(`\u2728 Router types generated at ${outputPath}`));
|
|
@@ -2498,7 +2663,7 @@ async function watchRouterFiles(outputPath) {
|
|
|
2498
2663
|
let timeoutId = null;
|
|
2499
2664
|
for (const dirPath of routerFiles) {
|
|
2500
2665
|
try {
|
|
2501
|
-
const watcher =
|
|
2666
|
+
const watcher = fs4.watch(dirPath, { recursive: true });
|
|
2502
2667
|
(async () => {
|
|
2503
2668
|
for await (const _event of watcher) {
|
|
2504
2669
|
if (timeoutId) {
|
|
@@ -2521,16 +2686,16 @@ async function watchRouterFiles(outputPath) {
|
|
|
2521
2686
|
}
|
|
2522
2687
|
|
|
2523
2688
|
// src/cli/routes.ts
|
|
2524
|
-
import
|
|
2525
|
-
import
|
|
2526
|
-
import
|
|
2689
|
+
import fs5 from "fs/promises";
|
|
2690
|
+
import path4 from "path";
|
|
2691
|
+
import process13 from "process";
|
|
2527
2692
|
async function displayRoutes(options) {
|
|
2528
2693
|
try {
|
|
2529
|
-
const routesFile = `${
|
|
2694
|
+
const routesFile = `${process13.cwd()}/routes/index.ts`;
|
|
2530
2695
|
const { router } = await import(routesFile);
|
|
2531
2696
|
if (!router) {
|
|
2532
2697
|
console.error(chalk.red(`Could not find router instance in ${routesFile}.`));
|
|
2533
|
-
|
|
2698
|
+
process13.exit(1);
|
|
2534
2699
|
}
|
|
2535
2700
|
const routes = router.routes || [];
|
|
2536
2701
|
if (routes.length === 0) {
|
|
@@ -2548,7 +2713,7 @@ Routes:`));
|
|
|
2548
2713
|
console.log(chalk.dim("+-----------------+-------------------------+------------------+----------------+"));
|
|
2549
2714
|
filteredRoutes.forEach((route) => {
|
|
2550
2715
|
const method = padString(route.method, 15);
|
|
2551
|
-
const
|
|
2716
|
+
const path5 = padString(route.path, 23);
|
|
2552
2717
|
const name = padString(route.name || "", 16);
|
|
2553
2718
|
let handler;
|
|
2554
2719
|
if (typeof route.handler === "string") {
|
|
@@ -2559,7 +2724,7 @@ Routes:`));
|
|
|
2559
2724
|
handler = "Class Handler";
|
|
2560
2725
|
}
|
|
2561
2726
|
handler = padString(handler, 14);
|
|
2562
|
-
console.log(chalk.dim("| ") + getMethodColor(route.method)(method) + chalk.dim(" | ") + chalk.green(
|
|
2727
|
+
console.log(chalk.dim("| ") + getMethodColor(route.method)(method) + chalk.dim(" | ") + chalk.green(path5) + chalk.dim(" | ") + chalk.yellow(name) + chalk.dim(" | ") + chalk.blue(handler) + chalk.dim(" |"));
|
|
2563
2728
|
if (options.verbose && route.middleware && route.middleware.length > 0) {
|
|
2564
2729
|
console.log(chalk.dim("| | ") + chalk.dim("Middleware: ") + route.middleware.map((m) => typeof m === "string" ? m : m.name || "Anonymous").join(", ") + chalk.dim(" |"));
|
|
2565
2730
|
}
|
|
@@ -2569,17 +2734,17 @@ Routes:`));
|
|
|
2569
2734
|
Showing ${filteredRoutes.length} routes`);
|
|
2570
2735
|
} catch (error) {
|
|
2571
2736
|
console.error(chalk.red(`Error: ${error.message}`));
|
|
2572
|
-
console.error(chalk.yellow(`Make sure your routes are defined in ${
|
|
2737
|
+
console.error(chalk.yellow(`Make sure your routes are defined in ${process13.cwd()}/routes/index.ts and export a 'router' instance.`));
|
|
2573
2738
|
throw error;
|
|
2574
2739
|
}
|
|
2575
2740
|
}
|
|
2576
2741
|
async function generateRouteTypes(outputPath) {
|
|
2577
2742
|
try {
|
|
2578
|
-
const routesFile = `${
|
|
2743
|
+
const routesFile = `${process13.cwd()}/routes/index.ts`;
|
|
2579
2744
|
const { router } = await import(routesFile);
|
|
2580
2745
|
if (!router) {
|
|
2581
2746
|
console.error(chalk.red(`Could not find router instance in ${routesFile}.`));
|
|
2582
|
-
|
|
2747
|
+
process13.exit(1);
|
|
2583
2748
|
}
|
|
2584
2749
|
const routes = router.routes || [];
|
|
2585
2750
|
if (routes.length === 0) {
|
|
@@ -2624,11 +2789,11 @@ export function isValidRouteName(name: string): name is RouteName {
|
|
|
2624
2789
|
return [${uniqueRouteNames.map((name) => `'${name}'`).join(", ")}].includes(name)
|
|
2625
2790
|
}
|
|
2626
2791
|
`;
|
|
2627
|
-
await
|
|
2792
|
+
await fs5.writeFile(outputPath, typeContent);
|
|
2628
2793
|
console.log(chalk.green(`\u2728 Route types generated at ${outputPath}`));
|
|
2629
2794
|
} catch (error) {
|
|
2630
2795
|
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
|
2631
|
-
console.error(chalk.red(`Routes file not found at ${
|
|
2796
|
+
console.error(chalk.red(`Routes file not found at ${process13.cwd()}/routes/index.ts`));
|
|
2632
2797
|
console.error(chalk.yellow('Make sure your routes are defined and exported as "router" in routes/index.ts'));
|
|
2633
2798
|
} else {
|
|
2634
2799
|
console.error(chalk.red(`Error generating route types: ${error.message}`));
|
|
@@ -2637,18 +2802,18 @@ export function isValidRouteName(name: string): name is RouteName {
|
|
|
2637
2802
|
}
|
|
2638
2803
|
}
|
|
2639
2804
|
async function watchRoutesDirectory(outputPath) {
|
|
2640
|
-
const routesPath =
|
|
2805
|
+
const routesPath = path4.join(process13.cwd(), "routes");
|
|
2641
2806
|
try {
|
|
2642
|
-
await
|
|
2807
|
+
await fs5.access(routesPath);
|
|
2643
2808
|
} catch {
|
|
2644
2809
|
console.error(chalk.red(`Routes directory not found at ${routesPath}`));
|
|
2645
|
-
|
|
2810
|
+
process13.exit(1);
|
|
2646
2811
|
}
|
|
2647
2812
|
await generateRouteTypes(outputPath);
|
|
2648
2813
|
console.log(chalk.green(`\u2728 Route types generated at ${outputPath}`));
|
|
2649
2814
|
console.log(chalk.blue(`Watching for changes in ${routesPath}...`));
|
|
2650
2815
|
let timeoutId = null;
|
|
2651
|
-
const watcher =
|
|
2816
|
+
const watcher = fs5.watch(routesPath, { recursive: true });
|
|
2652
2817
|
for await (const _event of watcher) {
|
|
2653
2818
|
if (timeoutId) {
|
|
2654
2819
|
clearTimeout(timeoutId);
|
|
@@ -2688,7 +2853,7 @@ function getMethodColor(method) {
|
|
|
2688
2853
|
}
|
|
2689
2854
|
|
|
2690
2855
|
// src/cli/utils.ts
|
|
2691
|
-
import
|
|
2856
|
+
import process14 from "process";
|
|
2692
2857
|
var format = {
|
|
2693
2858
|
success: (message) => chalk.green(`\u2728 ${message}`),
|
|
2694
2859
|
info: (message) => chalk.blue(message),
|
|
@@ -2706,16 +2871,16 @@ var logger = {
|
|
|
2706
2871
|
};
|
|
2707
2872
|
async function loadRouter() {
|
|
2708
2873
|
try {
|
|
2709
|
-
const routesFile = `${
|
|
2874
|
+
const routesFile = `${process14.cwd()}/routes/index.ts`;
|
|
2710
2875
|
const { router } = await import(routesFile);
|
|
2711
2876
|
if (!router) {
|
|
2712
2877
|
logger.error(`Could not find router instance in ${routesFile}.`);
|
|
2713
|
-
|
|
2878
|
+
process14.exit(1);
|
|
2714
2879
|
}
|
|
2715
2880
|
return router;
|
|
2716
2881
|
} catch (error) {
|
|
2717
2882
|
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
|
2718
|
-
logger.error(`Routes file not found at ${
|
|
2883
|
+
logger.error(`Routes file not found at ${process14.cwd()}/routes/index.ts`);
|
|
2719
2884
|
logger.warning('Make sure your routes are defined and exported as "router" in routes/index.ts');
|
|
2720
2885
|
} else {
|
|
2721
2886
|
logger.error(`Error loading router: ${error.message}`);
|
|
@@ -2893,7 +3058,7 @@ async function testRoutes(options) {
|
|
|
2893
3058
|
}
|
|
2894
3059
|
}
|
|
2895
3060
|
if (results.failed > 0) {
|
|
2896
|
-
|
|
3061
|
+
process14.exit(1);
|
|
2897
3062
|
} else {
|
|
2898
3063
|
logger.success("All tests passed!");
|
|
2899
3064
|
}
|
|
@@ -2902,12 +3067,12 @@ async function testRoutes(options) {
|
|
|
2902
3067
|
throw error;
|
|
2903
3068
|
}
|
|
2904
3069
|
}
|
|
2905
|
-
async function debugRoute(
|
|
3070
|
+
async function debugRoute(path5, options) {
|
|
2906
3071
|
const method = options.method?.toUpperCase() || "GET";
|
|
2907
|
-
logger.info(`\uD83D\uDD0D Debugging route matching for: ${method} ${
|
|
3072
|
+
logger.info(`\uD83D\uDD0D Debugging route matching for: ${method} ${path5}`);
|
|
2908
3073
|
try {
|
|
2909
3074
|
const router = await loadRouter();
|
|
2910
|
-
const match = router.matchRoute ? router.matchRoute(
|
|
3075
|
+
const match = router.matchRoute ? router.matchRoute(path5, method) : null;
|
|
2911
3076
|
if (match) {
|
|
2912
3077
|
logger.success(`\u2705 Route matched!`);
|
|
2913
3078
|
console.log(` Route: ${match.route.method} ${match.route.path}`);
|
|
@@ -2925,7 +3090,7 @@ async function debugRoute(path4, options) {
|
|
|
2925
3090
|
console.log(` Named route: ${match.route.name}`);
|
|
2926
3091
|
}
|
|
2927
3092
|
} else {
|
|
2928
|
-
logger.error(`\u274C No route matched for ${method} ${
|
|
3093
|
+
logger.error(`\u274C No route matched for ${method} ${path5}`);
|
|
2929
3094
|
if (options.verbose) {
|
|
2930
3095
|
console.log(`
|
|
2931
3096
|
\uD83D\uDCCB Available routes:`);
|
|
@@ -3050,7 +3215,7 @@ async function validateRoutes(options) {
|
|
|
3050
3215
|
logger.info("\uD83D\uDD27 Auto-fixing is not yet implemented");
|
|
3051
3216
|
}
|
|
3052
3217
|
if (issues.length > 0) {
|
|
3053
|
-
|
|
3218
|
+
process14.exit(1);
|
|
3054
3219
|
}
|
|
3055
3220
|
} catch (error) {
|
|
3056
3221
|
logger.error(`Route validation failed: ${error.message}`);
|
|
@@ -3076,7 +3241,7 @@ function registerRouteCommands(cli) {
|
|
|
3076
3241
|
await displayRoutes(options);
|
|
3077
3242
|
} catch (error) {
|
|
3078
3243
|
console.error(`Failed to list routes: ${error.message}`);
|
|
3079
|
-
|
|
3244
|
+
process15.exit(1);
|
|
3080
3245
|
}
|
|
3081
3246
|
});
|
|
3082
3247
|
cli.command("route:types", "Generate TypeScript types for route names").option("--output <file>", "Output file path", { default: "route-types.ts" }).option("--watch", "Watch for changes in routes directory").example("router route:types").example("router route:types --output src/types/routes.ts").example("router route:types --watch").action(async (options) => {
|
|
@@ -3089,7 +3254,7 @@ function registerRouteCommands(cli) {
|
|
|
3089
3254
|
}
|
|
3090
3255
|
} catch (error) {
|
|
3091
3256
|
console.error(`Failed to generate route types: ${error.message}`);
|
|
3092
|
-
|
|
3257
|
+
process15.exit(1);
|
|
3093
3258
|
}
|
|
3094
3259
|
});
|
|
3095
3260
|
}
|
|
@@ -3104,7 +3269,7 @@ function registerMiddlewareCommands(cli) {
|
|
|
3104
3269
|
}
|
|
3105
3270
|
} catch (error) {
|
|
3106
3271
|
console.error(`Failed to generate middleware types: ${error.message}`);
|
|
3107
|
-
|
|
3272
|
+
process15.exit(1);
|
|
3108
3273
|
}
|
|
3109
3274
|
});
|
|
3110
3275
|
cli.command("middleware:map", "Generate TypeScript types for all middleware in the project").option("--dir <directory>", "Directory to scan for middleware classes", { default: "src" }).option("--output <file>", "Output file path", { default: "middleware-map.ts" }).option("--watch", "Watch for changes in the specified directory").example("router middleware:map").example("router middleware:map --dir app").example("router middleware:map --output src/types/project-middleware.ts").example("router middleware:map --watch").action(async (options) => {
|
|
@@ -3118,7 +3283,7 @@ function registerMiddlewareCommands(cli) {
|
|
|
3118
3283
|
}
|
|
3119
3284
|
} catch (error) {
|
|
3120
3285
|
console.error(`Failed to generate middleware map: ${error.message}`);
|
|
3121
|
-
|
|
3286
|
+
process15.exit(1);
|
|
3122
3287
|
}
|
|
3123
3288
|
});
|
|
3124
3289
|
}
|
|
@@ -3133,7 +3298,7 @@ function registerRouterCommands(cli) {
|
|
|
3133
3298
|
}
|
|
3134
3299
|
} catch (error) {
|
|
3135
3300
|
console.error(`Failed to generate router types: ${error.message}`);
|
|
3136
|
-
|
|
3301
|
+
process15.exit(1);
|
|
3137
3302
|
}
|
|
3138
3303
|
});
|
|
3139
3304
|
}
|
|
@@ -3143,7 +3308,7 @@ function registerOpenAPICommands(cli) {
|
|
|
3143
3308
|
await generateOpenAPISpec(options);
|
|
3144
3309
|
} catch (error) {
|
|
3145
3310
|
console.error(`Failed to generate OpenAPI specification: ${error.message}`);
|
|
3146
|
-
|
|
3311
|
+
process15.exit(1);
|
|
3147
3312
|
}
|
|
3148
3313
|
});
|
|
3149
3314
|
}
|
|
@@ -3153,7 +3318,7 @@ function registerUtilityCommands(cli) {
|
|
|
3153
3318
|
await checkRouterHealth(options);
|
|
3154
3319
|
} catch (error) {
|
|
3155
3320
|
console.error(`Health check failed: ${error.message}`);
|
|
3156
|
-
|
|
3321
|
+
process15.exit(1);
|
|
3157
3322
|
}
|
|
3158
3323
|
});
|
|
3159
3324
|
cli.command("test:routes", "Test routes by making HTTP requests").option("--base-url <url>", "Base URL for testing", { default: "http://localhost:3000" }).option("--filter <pattern>", "Filter routes by path pattern").option("--method <methods>", "Test only specific HTTP methods (comma-separated)").option("--timeout <ms>", "Request timeout in milliseconds", { default: 5000 }).example("router test:routes").example("router test:routes --base-url http://localhost:8080").example('router test:routes --filter "/api/*"').example("router test:routes --method GET,POST").action(async (options) => {
|
|
@@ -3161,15 +3326,15 @@ function registerUtilityCommands(cli) {
|
|
|
3161
3326
|
await testRoutes(options);
|
|
3162
3327
|
} catch (error) {
|
|
3163
3328
|
console.error(`Route testing failed: ${error.message}`);
|
|
3164
|
-
|
|
3329
|
+
process15.exit(1);
|
|
3165
3330
|
}
|
|
3166
3331
|
});
|
|
3167
|
-
cli.command("debug:route <path>", "Debug route matching for a specific path").option("--method <method>", "HTTP method to test", { default: "GET" }).option("--verbose", "Show detailed matching information").example("router debug:route /api/users/123").example("router debug:route /api/users/123 --method POST --verbose").action(async (
|
|
3332
|
+
cli.command("debug:route <path>", "Debug route matching for a specific path").option("--method <method>", "HTTP method to test", { default: "GET" }).option("--verbose", "Show detailed matching information").example("router debug:route /api/users/123").example("router debug:route /api/users/123 --method POST --verbose").action(async (path5, options) => {
|
|
3168
3333
|
try {
|
|
3169
|
-
await debugRoute(
|
|
3334
|
+
await debugRoute(path5, options);
|
|
3170
3335
|
} catch (error) {
|
|
3171
3336
|
console.error(`Route debugging failed: ${error.message}`);
|
|
3172
|
-
|
|
3337
|
+
process15.exit(1);
|
|
3173
3338
|
}
|
|
3174
3339
|
});
|
|
3175
3340
|
cli.command("cache:clear", "Clear route caches").option("--stats", "Show cache statistics before clearing").example("router cache:clear").example("router cache:clear --stats").action(async (options) => {
|
|
@@ -3177,7 +3342,7 @@ function registerUtilityCommands(cli) {
|
|
|
3177
3342
|
await clearCaches(options);
|
|
3178
3343
|
} catch (error) {
|
|
3179
3344
|
console.error(`Cache clearing failed: ${error.message}`);
|
|
3180
|
-
|
|
3345
|
+
process15.exit(1);
|
|
3181
3346
|
}
|
|
3182
3347
|
});
|
|
3183
3348
|
cli.command("validate", "Validate route definitions and configuration").option("--strict", "Use strict validation rules").option("--fix", "Automatically fix simple issues").example("router validate").example("router validate --strict --fix").action(async (options) => {
|
|
@@ -3185,7 +3350,7 @@ function registerUtilityCommands(cli) {
|
|
|
3185
3350
|
await validateRoutes(options);
|
|
3186
3351
|
} catch (error) {
|
|
3187
3352
|
console.error(`Route validation failed: ${error.message}`);
|
|
3188
|
-
|
|
3353
|
+
process15.exit(1);
|
|
3189
3354
|
}
|
|
3190
3355
|
});
|
|
3191
3356
|
}
|