@khuongdo/vibe-kanban 0.1.45 → 0.1.47
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/bin/cli.js +622 -7
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
var require_package = __commonJS({
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
|
-
name: "
|
|
33
|
+
name: "vibe-kanban",
|
|
34
34
|
private: false,
|
|
35
|
-
version: "0.1.
|
|
35
|
+
version: "0.1.44",
|
|
36
36
|
main: "index.js",
|
|
37
37
|
bin: {
|
|
38
38
|
"vibe-kanban": "bin/cli.js"
|
|
@@ -45,7 +45,7 @@ var require_package = __commonJS({
|
|
|
45
45
|
author: "bloop",
|
|
46
46
|
repository: {
|
|
47
47
|
type: "git",
|
|
48
|
-
url: "https://github.com/
|
|
48
|
+
url: "https://github.com/BloopAI/vibe-kanban"
|
|
49
49
|
},
|
|
50
50
|
engines: {
|
|
51
51
|
node: ">=20.19.0"
|
|
@@ -71,7 +71,622 @@ var require_package = __commonJS({
|
|
|
71
71
|
var import_child_process2 = require("child_process");
|
|
72
72
|
var import_path3 = __toESM(require("path"));
|
|
73
73
|
var import_fs3 = __toESM(require("fs"));
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
// node_modules/cac/dist/index.js
|
|
76
|
+
function toArr(any) {
|
|
77
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
78
|
+
}
|
|
79
|
+
function toVal(out, key, val, opts) {
|
|
80
|
+
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;
|
|
81
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
82
|
+
}
|
|
83
|
+
function lib_default(args, opts) {
|
|
84
|
+
args = args || [];
|
|
85
|
+
opts = opts || {};
|
|
86
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
87
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
88
|
+
const alibi = opts.alias !== void 0;
|
|
89
|
+
const strict = opts.unknown !== void 0;
|
|
90
|
+
const defaults = opts.default !== void 0;
|
|
91
|
+
opts.alias = opts.alias || {};
|
|
92
|
+
opts.string = toArr(opts.string);
|
|
93
|
+
opts.boolean = toArr(opts.boolean);
|
|
94
|
+
if (alibi) for (k in opts.alias) {
|
|
95
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
96
|
+
for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
97
|
+
}
|
|
98
|
+
for (i = opts.boolean.length; i-- > 0; ) {
|
|
99
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
100
|
+
for (j = arr.length; j-- > 0; ) opts.boolean.push(arr[j]);
|
|
101
|
+
}
|
|
102
|
+
for (i = opts.string.length; i-- > 0; ) {
|
|
103
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
104
|
+
for (j = arr.length; j-- > 0; ) opts.string.push(arr[j]);
|
|
105
|
+
}
|
|
106
|
+
if (defaults) for (k in opts.default) {
|
|
107
|
+
name = typeof opts.default[k];
|
|
108
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
109
|
+
if (opts[name] !== void 0) {
|
|
110
|
+
opts[name].push(k);
|
|
111
|
+
for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
115
|
+
for (i = 0; i < len; i++) {
|
|
116
|
+
arg = args[i];
|
|
117
|
+
if (arg === "--") {
|
|
118
|
+
out._ = out._.concat(args.slice(++i));
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
|
|
122
|
+
if (j === 0) out._.push(arg);
|
|
123
|
+
else if (arg.substring(j, j + 3) === "no-") {
|
|
124
|
+
name = arg.substring(j + 3);
|
|
125
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
126
|
+
out[name] = false;
|
|
127
|
+
} else {
|
|
128
|
+
for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
|
|
129
|
+
name = arg.substring(j, idx);
|
|
130
|
+
val = arg.substring(++idx) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
|
|
131
|
+
arr = j === 2 ? [name] : name;
|
|
132
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
133
|
+
name = arr[idx];
|
|
134
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
135
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (defaults) {
|
|
140
|
+
for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
|
|
141
|
+
}
|
|
142
|
+
if (alibi) for (k in out) {
|
|
143
|
+
arr = opts.alias[k] || [];
|
|
144
|
+
while (arr.length > 0) out[arr.shift()] = out[k];
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
function removeBrackets(v) {
|
|
149
|
+
return v.replace(/[<[].+/, "").trim();
|
|
150
|
+
}
|
|
151
|
+
function findAllBrackets(v) {
|
|
152
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
153
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
154
|
+
const res = [];
|
|
155
|
+
const parse = (match) => {
|
|
156
|
+
let variadic = false;
|
|
157
|
+
let value = match[1];
|
|
158
|
+
if (value.startsWith("...")) {
|
|
159
|
+
value = value.slice(3);
|
|
160
|
+
variadic = true;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
required: match[0].startsWith("<"),
|
|
164
|
+
value,
|
|
165
|
+
variadic
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
let angledMatch;
|
|
169
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(angledMatch));
|
|
170
|
+
let squareMatch;
|
|
171
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(squareMatch));
|
|
172
|
+
return res;
|
|
173
|
+
}
|
|
174
|
+
function getMriOptions(options) {
|
|
175
|
+
const result = {
|
|
176
|
+
alias: {},
|
|
177
|
+
boolean: []
|
|
178
|
+
};
|
|
179
|
+
for (const [index, option] of options.entries()) {
|
|
180
|
+
if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
|
|
181
|
+
if (option.isBoolean) if (option.negated) {
|
|
182
|
+
if (!options.some((o, i) => {
|
|
183
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
184
|
+
})) result.boolean.push(option.names[0]);
|
|
185
|
+
} else result.boolean.push(option.names[0]);
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
function findLongest(arr) {
|
|
190
|
+
return arr.sort((a, b) => {
|
|
191
|
+
return a.length > b.length ? -1 : 1;
|
|
192
|
+
})[0];
|
|
193
|
+
}
|
|
194
|
+
function padRight(str, length) {
|
|
195
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
196
|
+
}
|
|
197
|
+
function camelcase(input) {
|
|
198
|
+
return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
199
|
+
return p1 + p2.toUpperCase();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function setDotProp(obj, keys, val) {
|
|
203
|
+
let current = obj;
|
|
204
|
+
for (let i = 0; i < keys.length; i++) {
|
|
205
|
+
const key = keys[i];
|
|
206
|
+
if (i === keys.length - 1) {
|
|
207
|
+
current[key] = val;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (current[key] == null) {
|
|
211
|
+
const nextKeyIsArrayIndex = +keys[i + 1] > -1;
|
|
212
|
+
current[key] = nextKeyIsArrayIndex ? [] : {};
|
|
213
|
+
}
|
|
214
|
+
current = current[key];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function setByType(obj, transforms) {
|
|
218
|
+
for (const key of Object.keys(transforms)) {
|
|
219
|
+
const transform = transforms[key];
|
|
220
|
+
if (transform.shouldTransform) {
|
|
221
|
+
obj[key] = [obj[key]].flat();
|
|
222
|
+
if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function getFileName(input) {
|
|
227
|
+
const m = /([^\\/]+)$/.exec(input);
|
|
228
|
+
return m ? m[1] : "";
|
|
229
|
+
}
|
|
230
|
+
function camelcaseOptionName(name) {
|
|
231
|
+
return name.split(".").map((v, i) => {
|
|
232
|
+
return i === 0 ? camelcase(v) : v;
|
|
233
|
+
}).join(".");
|
|
234
|
+
}
|
|
235
|
+
var CACError = class extends Error {
|
|
236
|
+
constructor(message) {
|
|
237
|
+
super(message);
|
|
238
|
+
this.name = "CACError";
|
|
239
|
+
if (typeof Error.captureStackTrace !== "function") this.stack = new Error(message).stack;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
var Option = class {
|
|
243
|
+
rawName;
|
|
244
|
+
description;
|
|
245
|
+
/** Option name */
|
|
246
|
+
name;
|
|
247
|
+
/** Option name and aliases */
|
|
248
|
+
names;
|
|
249
|
+
isBoolean;
|
|
250
|
+
required;
|
|
251
|
+
config;
|
|
252
|
+
negated;
|
|
253
|
+
constructor(rawName, description, config) {
|
|
254
|
+
this.rawName = rawName;
|
|
255
|
+
this.description = description;
|
|
256
|
+
this.config = Object.assign({}, config);
|
|
257
|
+
rawName = rawName.replaceAll(".*", "");
|
|
258
|
+
this.negated = false;
|
|
259
|
+
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
260
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
261
|
+
if (name.startsWith("no-")) {
|
|
262
|
+
this.negated = true;
|
|
263
|
+
name = name.replace(/^no-/, "");
|
|
264
|
+
}
|
|
265
|
+
return camelcaseOptionName(name);
|
|
266
|
+
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
267
|
+
this.name = this.names.at(-1);
|
|
268
|
+
if (this.negated && this.config.default == null) this.config.default = true;
|
|
269
|
+
if (rawName.includes("<")) this.required = true;
|
|
270
|
+
else if (rawName.includes("[")) this.required = false;
|
|
271
|
+
else this.isBoolean = true;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var runtimeProcessArgs;
|
|
275
|
+
var runtimeInfo;
|
|
276
|
+
if (typeof process !== "undefined") {
|
|
277
|
+
let runtimeName;
|
|
278
|
+
if (typeof Deno !== "undefined" && typeof Deno.version?.deno === "string") runtimeName = "deno";
|
|
279
|
+
else if (typeof Bun !== "undefined" && typeof Bun.version === "string") runtimeName = "bun";
|
|
280
|
+
else runtimeName = "node";
|
|
281
|
+
runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
|
|
282
|
+
runtimeProcessArgs = process.argv;
|
|
283
|
+
} else if (typeof navigator === "undefined") runtimeInfo = `unknown`;
|
|
284
|
+
else runtimeInfo = `${navigator.platform} ${navigator.userAgent}`;
|
|
285
|
+
var Command = class {
|
|
286
|
+
rawName;
|
|
287
|
+
description;
|
|
288
|
+
config;
|
|
289
|
+
cli;
|
|
290
|
+
options;
|
|
291
|
+
aliasNames;
|
|
292
|
+
name;
|
|
293
|
+
args;
|
|
294
|
+
commandAction;
|
|
295
|
+
usageText;
|
|
296
|
+
versionNumber;
|
|
297
|
+
examples;
|
|
298
|
+
helpCallback;
|
|
299
|
+
globalCommand;
|
|
300
|
+
constructor(rawName, description, config = {}, cli) {
|
|
301
|
+
this.rawName = rawName;
|
|
302
|
+
this.description = description;
|
|
303
|
+
this.config = config;
|
|
304
|
+
this.cli = cli;
|
|
305
|
+
this.options = [];
|
|
306
|
+
this.aliasNames = [];
|
|
307
|
+
this.name = removeBrackets(rawName);
|
|
308
|
+
this.args = findAllBrackets(rawName);
|
|
309
|
+
this.examples = [];
|
|
310
|
+
}
|
|
311
|
+
usage(text) {
|
|
312
|
+
this.usageText = text;
|
|
313
|
+
return this;
|
|
314
|
+
}
|
|
315
|
+
allowUnknownOptions() {
|
|
316
|
+
this.config.allowUnknownOptions = true;
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
ignoreOptionDefaultValue() {
|
|
320
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
321
|
+
return this;
|
|
322
|
+
}
|
|
323
|
+
version(version, customFlags = "-v, --version") {
|
|
324
|
+
this.versionNumber = version;
|
|
325
|
+
this.option(customFlags, "Display version number");
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
example(example) {
|
|
329
|
+
this.examples.push(example);
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Add a option for this command
|
|
334
|
+
* @param rawName Raw option name(s)
|
|
335
|
+
* @param description Option description
|
|
336
|
+
* @param config Option config
|
|
337
|
+
*/
|
|
338
|
+
option(rawName, description, config) {
|
|
339
|
+
const option = new Option(rawName, description, config);
|
|
340
|
+
this.options.push(option);
|
|
341
|
+
return this;
|
|
342
|
+
}
|
|
343
|
+
alias(name) {
|
|
344
|
+
this.aliasNames.push(name);
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
action(callback) {
|
|
348
|
+
this.commandAction = callback;
|
|
349
|
+
return this;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Check if a command name is matched by this command
|
|
353
|
+
* @param name Command name
|
|
354
|
+
*/
|
|
355
|
+
isMatched(name) {
|
|
356
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
357
|
+
}
|
|
358
|
+
get isDefaultCommand() {
|
|
359
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
360
|
+
}
|
|
361
|
+
get isGlobalCommand() {
|
|
362
|
+
return this instanceof GlobalCommand;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Check if an option is registered in this command
|
|
366
|
+
* @param name Option name
|
|
367
|
+
*/
|
|
368
|
+
hasOption(name) {
|
|
369
|
+
name = name.split(".")[0];
|
|
370
|
+
return this.options.find((option) => {
|
|
371
|
+
return option.names.includes(name);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
outputHelp() {
|
|
375
|
+
const { name, commands } = this.cli;
|
|
376
|
+
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
377
|
+
let sections = [{ body: `${name}${versionNumber ? `/${versionNumber}` : ""}` }];
|
|
378
|
+
sections.push({
|
|
379
|
+
title: "Usage",
|
|
380
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
381
|
+
});
|
|
382
|
+
if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
|
|
383
|
+
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
384
|
+
sections.push({
|
|
385
|
+
title: "Commands",
|
|
386
|
+
body: commands.map((command) => {
|
|
387
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
388
|
+
}).join("\n")
|
|
389
|
+
}, {
|
|
390
|
+
title: `For more info, run any command with the \`--help\` flag`,
|
|
391
|
+
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
395
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option) => option.name !== "version");
|
|
396
|
+
if (options.length > 0) {
|
|
397
|
+
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
398
|
+
sections.push({
|
|
399
|
+
title: "Options",
|
|
400
|
+
body: options.map((option) => {
|
|
401
|
+
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
|
|
402
|
+
}).join("\n")
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
if (this.examples.length > 0) sections.push({
|
|
406
|
+
title: "Examples",
|
|
407
|
+
body: this.examples.map((example) => {
|
|
408
|
+
if (typeof example === "function") return example(name);
|
|
409
|
+
return example;
|
|
410
|
+
}).join("\n")
|
|
411
|
+
});
|
|
412
|
+
if (helpCallback) sections = helpCallback(sections) || sections;
|
|
413
|
+
console.info(sections.map((section) => {
|
|
414
|
+
return section.title ? `${section.title}:
|
|
415
|
+
${section.body}` : section.body;
|
|
416
|
+
}).join("\n\n"));
|
|
417
|
+
}
|
|
418
|
+
outputVersion() {
|
|
419
|
+
const { name } = this.cli;
|
|
420
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
421
|
+
if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
|
|
422
|
+
}
|
|
423
|
+
checkRequiredArgs() {
|
|
424
|
+
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
425
|
+
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Check if the parsed options contain any unknown options
|
|
429
|
+
*
|
|
430
|
+
* Exit and output error when true
|
|
431
|
+
*/
|
|
432
|
+
checkUnknownOptions() {
|
|
433
|
+
const { options, globalCommand } = this.cli;
|
|
434
|
+
if (!this.config.allowUnknownOptions) {
|
|
435
|
+
for (const name of Object.keys(options)) if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Check if the required string-type options exist
|
|
440
|
+
*/
|
|
441
|
+
checkOptionValue() {
|
|
442
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
443
|
+
const options = [...globalCommand.options, ...this.options];
|
|
444
|
+
for (const option of options) {
|
|
445
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
446
|
+
if (option.required) {
|
|
447
|
+
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
448
|
+
if (value === true || value === false && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Check if the number of args is more than expected
|
|
454
|
+
*/
|
|
455
|
+
checkUnusedArgs() {
|
|
456
|
+
const maximumArgsCount = this.args.some((arg) => arg.variadic) ? Infinity : this.args.length;
|
|
457
|
+
if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg) => `\`${arg}\``).join(", ")}`);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
var GlobalCommand = class extends Command {
|
|
461
|
+
constructor(cli) {
|
|
462
|
+
super("@@global@@", "", {}, cli);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
var CAC = class extends EventTarget {
|
|
466
|
+
/** The program name to display in help and version message */
|
|
467
|
+
name;
|
|
468
|
+
commands;
|
|
469
|
+
globalCommand;
|
|
470
|
+
matchedCommand;
|
|
471
|
+
matchedCommandName;
|
|
472
|
+
/**
|
|
473
|
+
* Raw CLI arguments
|
|
474
|
+
*/
|
|
475
|
+
rawArgs;
|
|
476
|
+
/**
|
|
477
|
+
* Parsed CLI arguments
|
|
478
|
+
*/
|
|
479
|
+
args;
|
|
480
|
+
/**
|
|
481
|
+
* Parsed CLI options, camelCased
|
|
482
|
+
*/
|
|
483
|
+
options;
|
|
484
|
+
showHelpOnExit;
|
|
485
|
+
showVersionOnExit;
|
|
486
|
+
/**
|
|
487
|
+
* @param name The program name to display in help and version message
|
|
488
|
+
*/
|
|
489
|
+
constructor(name = "") {
|
|
490
|
+
super();
|
|
491
|
+
this.name = name;
|
|
492
|
+
this.commands = [];
|
|
493
|
+
this.rawArgs = [];
|
|
494
|
+
this.args = [];
|
|
495
|
+
this.options = {};
|
|
496
|
+
this.globalCommand = new GlobalCommand(this);
|
|
497
|
+
this.globalCommand.usage("<command> [options]");
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Add a global usage text.
|
|
501
|
+
*
|
|
502
|
+
* This is not used by sub-commands.
|
|
503
|
+
*/
|
|
504
|
+
usage(text) {
|
|
505
|
+
this.globalCommand.usage(text);
|
|
506
|
+
return this;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Add a sub-command
|
|
510
|
+
*/
|
|
511
|
+
command(rawName, description, config) {
|
|
512
|
+
const command = new Command(rawName, description || "", config, this);
|
|
513
|
+
command.globalCommand = this.globalCommand;
|
|
514
|
+
this.commands.push(command);
|
|
515
|
+
return command;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Add a global CLI option.
|
|
519
|
+
*
|
|
520
|
+
* Which is also applied to sub-commands.
|
|
521
|
+
*/
|
|
522
|
+
option(rawName, description, config) {
|
|
523
|
+
this.globalCommand.option(rawName, description, config);
|
|
524
|
+
return this;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Show help message when `-h, --help` flags appear.
|
|
528
|
+
*
|
|
529
|
+
*/
|
|
530
|
+
help(callback) {
|
|
531
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
532
|
+
this.globalCommand.helpCallback = callback;
|
|
533
|
+
this.showHelpOnExit = true;
|
|
534
|
+
return this;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Show version number when `-v, --version` flags appear.
|
|
538
|
+
*
|
|
539
|
+
*/
|
|
540
|
+
version(version, customFlags = "-v, --version") {
|
|
541
|
+
this.globalCommand.version(version, customFlags);
|
|
542
|
+
this.showVersionOnExit = true;
|
|
543
|
+
return this;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Add a global example.
|
|
547
|
+
*
|
|
548
|
+
* This example added here will not be used by sub-commands.
|
|
549
|
+
*/
|
|
550
|
+
example(example) {
|
|
551
|
+
this.globalCommand.example(example);
|
|
552
|
+
return this;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Output the corresponding help message
|
|
556
|
+
* When a sub-command is matched, output the help message for the command
|
|
557
|
+
* Otherwise output the global one.
|
|
558
|
+
*
|
|
559
|
+
*/
|
|
560
|
+
outputHelp() {
|
|
561
|
+
if (this.matchedCommand) this.matchedCommand.outputHelp();
|
|
562
|
+
else this.globalCommand.outputHelp();
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Output the version number.
|
|
566
|
+
*
|
|
567
|
+
*/
|
|
568
|
+
outputVersion() {
|
|
569
|
+
this.globalCommand.outputVersion();
|
|
570
|
+
}
|
|
571
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
572
|
+
this.args = args;
|
|
573
|
+
this.options = options;
|
|
574
|
+
if (matchedCommand) this.matchedCommand = matchedCommand;
|
|
575
|
+
if (matchedCommandName) this.matchedCommandName = matchedCommandName;
|
|
576
|
+
return this;
|
|
577
|
+
}
|
|
578
|
+
unsetMatchedCommand() {
|
|
579
|
+
this.matchedCommand = void 0;
|
|
580
|
+
this.matchedCommandName = void 0;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Parse argv
|
|
584
|
+
*/
|
|
585
|
+
parse(argv, { run = true } = {}) {
|
|
586
|
+
if (!argv) {
|
|
587
|
+
if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
|
|
588
|
+
argv = runtimeProcessArgs;
|
|
589
|
+
}
|
|
590
|
+
this.rawArgs = argv;
|
|
591
|
+
if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
592
|
+
let shouldParse = true;
|
|
593
|
+
for (const command of this.commands) {
|
|
594
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
595
|
+
const commandName = parsed.args[0];
|
|
596
|
+
if (command.isMatched(commandName)) {
|
|
597
|
+
shouldParse = false;
|
|
598
|
+
const parsedInfo = {
|
|
599
|
+
...parsed,
|
|
600
|
+
args: parsed.args.slice(1)
|
|
601
|
+
};
|
|
602
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
603
|
+
this.dispatchEvent(new CustomEvent(`command:${commandName}`, { detail: command }));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (shouldParse) {
|
|
607
|
+
for (const command of this.commands) if (command.isDefaultCommand) {
|
|
608
|
+
shouldParse = false;
|
|
609
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
610
|
+
this.setParsedInfo(parsed, command);
|
|
611
|
+
this.dispatchEvent(new CustomEvent("command:!", { detail: command }));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
if (shouldParse) {
|
|
615
|
+
const parsed = this.mri(argv.slice(2));
|
|
616
|
+
this.setParsedInfo(parsed);
|
|
617
|
+
}
|
|
618
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
619
|
+
this.outputHelp();
|
|
620
|
+
run = false;
|
|
621
|
+
this.unsetMatchedCommand();
|
|
622
|
+
}
|
|
623
|
+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
624
|
+
this.outputVersion();
|
|
625
|
+
run = false;
|
|
626
|
+
this.unsetMatchedCommand();
|
|
627
|
+
}
|
|
628
|
+
const parsedArgv = {
|
|
629
|
+
args: this.args,
|
|
630
|
+
options: this.options
|
|
631
|
+
};
|
|
632
|
+
if (run) this.runMatchedCommand();
|
|
633
|
+
if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] }));
|
|
634
|
+
return parsedArgv;
|
|
635
|
+
}
|
|
636
|
+
mri(argv, command) {
|
|
637
|
+
const cliOptions = [...this.globalCommand.options, ...command ? command.options : []];
|
|
638
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
639
|
+
let argsAfterDoubleDashes = [];
|
|
640
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
641
|
+
if (doubleDashesIndex !== -1) {
|
|
642
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
643
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
644
|
+
}
|
|
645
|
+
let parsed = lib_default(argv, mriOptions);
|
|
646
|
+
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
647
|
+
return {
|
|
648
|
+
...res,
|
|
649
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
650
|
+
};
|
|
651
|
+
}, { _: [] });
|
|
652
|
+
const args = parsed._;
|
|
653
|
+
const options = { "--": argsAfterDoubleDashes };
|
|
654
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
655
|
+
const transforms = /* @__PURE__ */ Object.create(null);
|
|
656
|
+
for (const cliOption of cliOptions) {
|
|
657
|
+
if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
|
|
658
|
+
if (Array.isArray(cliOption.config.type) && transforms[cliOption.name] === void 0) {
|
|
659
|
+
transforms[cliOption.name] = /* @__PURE__ */ Object.create(null);
|
|
660
|
+
transforms[cliOption.name].shouldTransform = true;
|
|
661
|
+
transforms[cliOption.name].transformFunction = cliOption.config.type[0];
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
for (const key of Object.keys(parsed)) if (key !== "_") {
|
|
665
|
+
setDotProp(options, key.split("."), parsed[key]);
|
|
666
|
+
setByType(options, transforms);
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
args,
|
|
670
|
+
options
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
runMatchedCommand() {
|
|
674
|
+
const { args, options, matchedCommand: command } = this;
|
|
675
|
+
if (!command || !command.commandAction) return;
|
|
676
|
+
command.checkUnknownOptions();
|
|
677
|
+
command.checkOptionValue();
|
|
678
|
+
command.checkRequiredArgs();
|
|
679
|
+
command.checkUnusedArgs();
|
|
680
|
+
const actionArgs = [];
|
|
681
|
+
command.args.forEach((arg, index) => {
|
|
682
|
+
if (arg.variadic) actionArgs.push(args.slice(index));
|
|
683
|
+
else actionArgs.push(args[index]);
|
|
684
|
+
});
|
|
685
|
+
actionArgs.push(options);
|
|
686
|
+
return command.commandAction.apply(this, actionArgs);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
var cac = (name = "") => new CAC(name);
|
|
75
690
|
|
|
76
691
|
// src/download.ts
|
|
77
692
|
var import_https = __toESM(require("https"));
|
|
@@ -79,8 +694,8 @@ var import_fs = __toESM(require("fs"));
|
|
|
79
694
|
var import_path = __toESM(require("path"));
|
|
80
695
|
var import_crypto = __toESM(require("crypto"));
|
|
81
696
|
var import_os = __toESM(require("os"));
|
|
82
|
-
var R2_BASE_URL = "
|
|
83
|
-
var BINARY_TAG = "
|
|
697
|
+
var R2_BASE_URL = "https://npm-cdn.vibekanban.com";
|
|
698
|
+
var BINARY_TAG = "v0.1.44-20260424091429";
|
|
84
699
|
var CACHE_DIR = import_path.default.join(import_os.default.homedir(), ".vibe-kanban", "bin");
|
|
85
700
|
var LOCAL_DIST_DIR = import_path.default.join(__dirname, "..", "dist");
|
|
86
701
|
var LOCAL_DEV_MODE = import_fs.default.existsSync(LOCAL_DIST_DIR) || process.env.VIBE_KANBAN_LOCAL === "1";
|
|
@@ -714,7 +1329,7 @@ function runOrExit(task) {
|
|
|
714
1329
|
}
|
|
715
1330
|
async function main() {
|
|
716
1331
|
import_fs3.default.mkdirSync(versionCacheDir, { recursive: true });
|
|
717
|
-
const cli =
|
|
1332
|
+
const cli = cac("vibe-kanban");
|
|
718
1333
|
cli.command("[...args]", "Launch the local vibe-kanban app").option("--desktop", "Launch the desktop app instead of browser mode").allowUnknownOptions().action((_args, options) => {
|
|
719
1334
|
runOrExit(runMain(Boolean(options.desktop)));
|
|
720
1335
|
});
|