@tfl-inc/cli 0.0.1 → 0.0.2
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/index.js +1724 -891
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -129,14 +129,10 @@ var require_help = __commonJS((exports) => {
|
|
|
129
129
|
class Help {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.helpWidth = undefined;
|
|
132
|
-
this.minWidthToWrap = 40;
|
|
133
132
|
this.sortSubcommands = false;
|
|
134
133
|
this.sortOptions = false;
|
|
135
134
|
this.showGlobalOptions = false;
|
|
136
135
|
}
|
|
137
|
-
prepareContext(contextOptions) {
|
|
138
|
-
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
139
|
-
}
|
|
140
136
|
visibleCommands(cmd) {
|
|
141
137
|
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
142
138
|
const helpCommand = cmd._getHelpCommand();
|
|
@@ -211,22 +207,22 @@ var require_help = __commonJS((exports) => {
|
|
|
211
207
|
}
|
|
212
208
|
longestSubcommandTermLength(cmd, helper) {
|
|
213
209
|
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
214
|
-
return Math.max(max,
|
|
210
|
+
return Math.max(max, helper.subcommandTerm(command).length);
|
|
215
211
|
}, 0);
|
|
216
212
|
}
|
|
217
213
|
longestOptionTermLength(cmd, helper) {
|
|
218
214
|
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
219
|
-
return Math.max(max,
|
|
215
|
+
return Math.max(max, helper.optionTerm(option).length);
|
|
220
216
|
}, 0);
|
|
221
217
|
}
|
|
222
218
|
longestGlobalOptionTermLength(cmd, helper) {
|
|
223
219
|
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
224
|
-
return Math.max(max,
|
|
220
|
+
return Math.max(max, helper.optionTerm(option).length);
|
|
225
221
|
}, 0);
|
|
226
222
|
}
|
|
227
223
|
longestArgumentTermLength(cmd, helper) {
|
|
228
224
|
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
229
|
-
return Math.max(max,
|
|
225
|
+
return Math.max(max, helper.argumentTerm(argument).length);
|
|
230
226
|
}, 0);
|
|
231
227
|
}
|
|
232
228
|
commandUsage(cmd) {
|
|
@@ -277,199 +273,102 @@ var require_help = __commonJS((exports) => {
|
|
|
277
273
|
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
|
|
278
274
|
}
|
|
279
275
|
if (extraInfo.length > 0) {
|
|
280
|
-
const
|
|
276
|
+
const extraDescripton = `(${extraInfo.join(", ")})`;
|
|
281
277
|
if (argument.description) {
|
|
282
|
-
return `${argument.description} ${
|
|
278
|
+
return `${argument.description} ${extraDescripton}`;
|
|
283
279
|
}
|
|
284
|
-
return
|
|
280
|
+
return extraDescripton;
|
|
285
281
|
}
|
|
286
282
|
return argument.description;
|
|
287
283
|
}
|
|
288
284
|
formatHelp(cmd, helper) {
|
|
289
285
|
const termWidth = helper.padWidth(cmd, helper);
|
|
290
|
-
const helpWidth = helper.helpWidth
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
286
|
+
const helpWidth = helper.helpWidth || 80;
|
|
287
|
+
const itemIndentWidth = 2;
|
|
288
|
+
const itemSeparatorWidth = 2;
|
|
289
|
+
function formatItem(term, description) {
|
|
290
|
+
if (description) {
|
|
291
|
+
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
|
|
292
|
+
return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
|
|
293
|
+
}
|
|
294
|
+
return term;
|
|
295
|
+
}
|
|
296
|
+
function formatList(textArray) {
|
|
297
|
+
return textArray.join(`
|
|
298
|
+
`).replace(/^/gm, " ".repeat(itemIndentWidth));
|
|
299
|
+
}
|
|
300
|
+
let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
|
|
298
301
|
const commandDescription = helper.commandDescription(cmd);
|
|
299
302
|
if (commandDescription.length > 0) {
|
|
300
303
|
output = output.concat([
|
|
301
|
-
helper.
|
|
304
|
+
helper.wrap(commandDescription, helpWidth, 0),
|
|
302
305
|
""
|
|
303
306
|
]);
|
|
304
307
|
}
|
|
305
308
|
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
306
|
-
return
|
|
309
|
+
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
|
|
307
310
|
});
|
|
308
311
|
if (argumentList.length > 0) {
|
|
309
|
-
output = output.concat([
|
|
310
|
-
helper.styleTitle("Arguments:"),
|
|
311
|
-
...argumentList,
|
|
312
|
-
""
|
|
313
|
-
]);
|
|
312
|
+
output = output.concat(["Arguments:", formatList(argumentList), ""]);
|
|
314
313
|
}
|
|
315
314
|
const optionList = helper.visibleOptions(cmd).map((option) => {
|
|
316
|
-
return
|
|
315
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
317
316
|
});
|
|
318
317
|
if (optionList.length > 0) {
|
|
319
|
-
output = output.concat([
|
|
320
|
-
helper.styleTitle("Options:"),
|
|
321
|
-
...optionList,
|
|
322
|
-
""
|
|
323
|
-
]);
|
|
318
|
+
output = output.concat(["Options:", formatList(optionList), ""]);
|
|
324
319
|
}
|
|
325
|
-
if (
|
|
320
|
+
if (this.showGlobalOptions) {
|
|
326
321
|
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
327
|
-
return
|
|
322
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
328
323
|
});
|
|
329
324
|
if (globalOptionList.length > 0) {
|
|
330
325
|
output = output.concat([
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
"Global Options:",
|
|
327
|
+
formatList(globalOptionList),
|
|
333
328
|
""
|
|
334
329
|
]);
|
|
335
330
|
}
|
|
336
331
|
}
|
|
337
332
|
const commandList = helper.visibleCommands(cmd).map((cmd2) => {
|
|
338
|
-
return
|
|
333
|
+
return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
|
|
339
334
|
});
|
|
340
335
|
if (commandList.length > 0) {
|
|
341
|
-
output = output.concat([
|
|
342
|
-
helper.styleTitle("Commands:"),
|
|
343
|
-
...commandList,
|
|
344
|
-
""
|
|
345
|
-
]);
|
|
336
|
+
output = output.concat(["Commands:", formatList(commandList), ""]);
|
|
346
337
|
}
|
|
347
338
|
return output.join(`
|
|
348
339
|
`);
|
|
349
340
|
}
|
|
350
|
-
displayWidth(str) {
|
|
351
|
-
return stripColor(str).length;
|
|
352
|
-
}
|
|
353
|
-
styleTitle(str) {
|
|
354
|
-
return str;
|
|
355
|
-
}
|
|
356
|
-
styleUsage(str) {
|
|
357
|
-
return str.split(" ").map((word) => {
|
|
358
|
-
if (word === "[options]")
|
|
359
|
-
return this.styleOptionText(word);
|
|
360
|
-
if (word === "[command]")
|
|
361
|
-
return this.styleSubcommandText(word);
|
|
362
|
-
if (word[0] === "[" || word[0] === "<")
|
|
363
|
-
return this.styleArgumentText(word);
|
|
364
|
-
return this.styleCommandText(word);
|
|
365
|
-
}).join(" ");
|
|
366
|
-
}
|
|
367
|
-
styleCommandDescription(str) {
|
|
368
|
-
return this.styleDescriptionText(str);
|
|
369
|
-
}
|
|
370
|
-
styleOptionDescription(str) {
|
|
371
|
-
return this.styleDescriptionText(str);
|
|
372
|
-
}
|
|
373
|
-
styleSubcommandDescription(str) {
|
|
374
|
-
return this.styleDescriptionText(str);
|
|
375
|
-
}
|
|
376
|
-
styleArgumentDescription(str) {
|
|
377
|
-
return this.styleDescriptionText(str);
|
|
378
|
-
}
|
|
379
|
-
styleDescriptionText(str) {
|
|
380
|
-
return str;
|
|
381
|
-
}
|
|
382
|
-
styleOptionTerm(str) {
|
|
383
|
-
return this.styleOptionText(str);
|
|
384
|
-
}
|
|
385
|
-
styleSubcommandTerm(str) {
|
|
386
|
-
return str.split(" ").map((word) => {
|
|
387
|
-
if (word === "[options]")
|
|
388
|
-
return this.styleOptionText(word);
|
|
389
|
-
if (word[0] === "[" || word[0] === "<")
|
|
390
|
-
return this.styleArgumentText(word);
|
|
391
|
-
return this.styleSubcommandText(word);
|
|
392
|
-
}).join(" ");
|
|
393
|
-
}
|
|
394
|
-
styleArgumentTerm(str) {
|
|
395
|
-
return this.styleArgumentText(str);
|
|
396
|
-
}
|
|
397
|
-
styleOptionText(str) {
|
|
398
|
-
return str;
|
|
399
|
-
}
|
|
400
|
-
styleArgumentText(str) {
|
|
401
|
-
return str;
|
|
402
|
-
}
|
|
403
|
-
styleSubcommandText(str) {
|
|
404
|
-
return str;
|
|
405
|
-
}
|
|
406
|
-
styleCommandText(str) {
|
|
407
|
-
return str;
|
|
408
|
-
}
|
|
409
341
|
padWidth(cmd, helper) {
|
|
410
342
|
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
411
343
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const itemIndent = 2;
|
|
417
|
-
const itemIndentStr = " ".repeat(itemIndent);
|
|
418
|
-
if (!description)
|
|
419
|
-
return itemIndentStr + term;
|
|
420
|
-
const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
|
|
421
|
-
const spacerWidth = 2;
|
|
422
|
-
const helpWidth = this.helpWidth ?? 80;
|
|
423
|
-
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
424
|
-
let formattedDescription;
|
|
425
|
-
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
|
|
426
|
-
formattedDescription = description;
|
|
427
|
-
} else {
|
|
428
|
-
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
|
429
|
-
formattedDescription = wrappedDescription.replace(/\n/g, `
|
|
430
|
-
` + " ".repeat(termWidth + spacerWidth));
|
|
431
|
-
}
|
|
432
|
-
return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
|
|
433
|
-
${itemIndentStr}`);
|
|
434
|
-
}
|
|
435
|
-
boxWrap(str, width) {
|
|
436
|
-
if (width < this.minWidthToWrap)
|
|
344
|
+
wrap(str, width, indent, minColumnWidth = 40) {
|
|
345
|
+
const indents = " \\f\\t\\v - \uFEFF";
|
|
346
|
+
const manualIndent = new RegExp(`[\\n][${indents}]+`);
|
|
347
|
+
if (str.match(manualIndent))
|
|
437
348
|
return str;
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
const nextChunk = chunk.trimStart();
|
|
458
|
-
sumChunks = [nextChunk];
|
|
459
|
-
sumWidth = this.displayWidth(nextChunk);
|
|
460
|
-
});
|
|
461
|
-
wrappedLines.push(sumChunks.join(""));
|
|
462
|
-
});
|
|
463
|
-
return wrappedLines.join(`
|
|
349
|
+
const columnWidth = width - indent;
|
|
350
|
+
if (columnWidth < minColumnWidth)
|
|
351
|
+
return str;
|
|
352
|
+
const leadingStr = str.slice(0, indent);
|
|
353
|
+
const columnText = str.slice(indent).replace(`\r
|
|
354
|
+
`, `
|
|
355
|
+
`);
|
|
356
|
+
const indentString = " ".repeat(indent);
|
|
357
|
+
const zeroWidthSpace = "";
|
|
358
|
+
const breaks = `\\s${zeroWidthSpace}`;
|
|
359
|
+
const regex = new RegExp(`
|
|
360
|
+
|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
|
|
361
|
+
const lines = columnText.match(regex) || [];
|
|
362
|
+
return leadingStr + lines.map((line, i) => {
|
|
363
|
+
if (line === `
|
|
364
|
+
`)
|
|
365
|
+
return "";
|
|
366
|
+
return (i > 0 ? indentString : "") + line.trimEnd();
|
|
367
|
+
}).join(`
|
|
464
368
|
`);
|
|
465
369
|
}
|
|
466
370
|
}
|
|
467
|
-
function stripColor(str) {
|
|
468
|
-
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
469
|
-
return str.replace(sgrPattern, "");
|
|
470
|
-
}
|
|
471
371
|
exports.Help = Help;
|
|
472
|
-
exports.stripColor = stripColor;
|
|
473
372
|
});
|
|
474
373
|
|
|
475
374
|
// ../../node_modules/commander/lib/option.js
|
|
@@ -564,10 +463,7 @@ var require_option = __commonJS((exports) => {
|
|
|
564
463
|
return this.short.replace(/^-/, "");
|
|
565
464
|
}
|
|
566
465
|
attributeName() {
|
|
567
|
-
|
|
568
|
-
return camelcase(this.name().replace(/^no-/, ""));
|
|
569
|
-
}
|
|
570
|
-
return camelcase(this.name());
|
|
466
|
+
return camelcase(this.name().replace(/^no-/, ""));
|
|
571
467
|
}
|
|
572
468
|
is(arg) {
|
|
573
469
|
return this.short === arg || this.long === arg;
|
|
@@ -612,38 +508,14 @@ var require_option = __commonJS((exports) => {
|
|
|
612
508
|
function splitOptionFlags(flags) {
|
|
613
509
|
let shortFlag;
|
|
614
510
|
let longFlag;
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
const flagParts = flags.split(/[ |,]+/).concat("guard");
|
|
618
|
-
if (shortFlagExp.test(flagParts[0]))
|
|
619
|
-
shortFlag = flagParts.shift();
|
|
620
|
-
if (longFlagExp.test(flagParts[0]))
|
|
621
|
-
longFlag = flagParts.shift();
|
|
622
|
-
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
511
|
+
const flagParts = flags.split(/[ |,]+/);
|
|
512
|
+
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
|
|
623
513
|
shortFlag = flagParts.shift();
|
|
624
|
-
|
|
514
|
+
longFlag = flagParts.shift();
|
|
515
|
+
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
|
|
625
516
|
shortFlag = longFlag;
|
|
626
|
-
longFlag =
|
|
627
|
-
}
|
|
628
|
-
if (flagParts[0].startsWith("-")) {
|
|
629
|
-
const unsupportedFlag = flagParts[0];
|
|
630
|
-
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
631
|
-
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
632
|
-
throw new Error(`${baseError}
|
|
633
|
-
- a short flag is a single dash and a single character
|
|
634
|
-
- either use a single dash and a single character (for a short flag)
|
|
635
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
|
|
636
|
-
if (shortFlagExp.test(unsupportedFlag))
|
|
637
|
-
throw new Error(`${baseError}
|
|
638
|
-
- too many short flags`);
|
|
639
|
-
if (longFlagExp.test(unsupportedFlag))
|
|
640
|
-
throw new Error(`${baseError}
|
|
641
|
-
- too many long flags`);
|
|
642
|
-
throw new Error(`${baseError}
|
|
643
|
-
- unrecognised flag format`);
|
|
644
|
-
}
|
|
645
|
-
if (shortFlag === undefined && longFlag === undefined)
|
|
646
|
-
throw new Error(`option creation failed due to no flags found in '${flags}'.`);
|
|
517
|
+
longFlag = undefined;
|
|
518
|
+
}
|
|
647
519
|
return { shortFlag, longFlag };
|
|
648
520
|
}
|
|
649
521
|
exports.Option = Option;
|
|
@@ -732,7 +604,7 @@ var require_command = __commonJS((exports) => {
|
|
|
732
604
|
var process2 = __require("node:process");
|
|
733
605
|
var { Argument, humanReadableArgName } = require_argument();
|
|
734
606
|
var { CommanderError } = require_error();
|
|
735
|
-
var { Help
|
|
607
|
+
var { Help } = require_help();
|
|
736
608
|
var { Option, DualOptions } = require_option();
|
|
737
609
|
var { suggestSimilar } = require_suggestSimilar();
|
|
738
610
|
|
|
@@ -743,7 +615,7 @@ var require_command = __commonJS((exports) => {
|
|
|
743
615
|
this.options = [];
|
|
744
616
|
this.parent = null;
|
|
745
617
|
this._allowUnknownOption = false;
|
|
746
|
-
this._allowExcessArguments =
|
|
618
|
+
this._allowExcessArguments = true;
|
|
747
619
|
this.registeredArguments = [];
|
|
748
620
|
this._args = this.registeredArguments;
|
|
749
621
|
this.args = [];
|
|
@@ -770,16 +642,12 @@ var require_command = __commonJS((exports) => {
|
|
|
770
642
|
this._lifeCycleHooks = {};
|
|
771
643
|
this._showHelpAfterError = false;
|
|
772
644
|
this._showSuggestionAfterError = true;
|
|
773
|
-
this._savedState = null;
|
|
774
645
|
this._outputConfiguration = {
|
|
775
646
|
writeOut: (str) => process2.stdout.write(str),
|
|
776
647
|
writeErr: (str) => process2.stderr.write(str),
|
|
777
|
-
outputError: (str, write) => write(str),
|
|
778
648
|
getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
|
|
779
649
|
getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
|
|
780
|
-
|
|
781
|
-
getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
|
|
782
|
-
stripColor: (str) => stripColor(str)
|
|
650
|
+
outputError: (str, write) => write(str)
|
|
783
651
|
};
|
|
784
652
|
this._hidden = false;
|
|
785
653
|
this._helpOption = undefined;
|
|
@@ -1211,53 +1079,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1211
1079
|
return userArgs;
|
|
1212
1080
|
}
|
|
1213
1081
|
parse(argv, parseOptions) {
|
|
1214
|
-
this._prepareForParse();
|
|
1215
1082
|
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
1216
1083
|
this._parseCommand([], userArgs);
|
|
1217
1084
|
return this;
|
|
1218
1085
|
}
|
|
1219
1086
|
async parseAsync(argv, parseOptions) {
|
|
1220
|
-
this._prepareForParse();
|
|
1221
1087
|
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
1222
1088
|
await this._parseCommand([], userArgs);
|
|
1223
1089
|
return this;
|
|
1224
1090
|
}
|
|
1225
|
-
_prepareForParse() {
|
|
1226
|
-
if (this._savedState === null) {
|
|
1227
|
-
this.saveStateBeforeParse();
|
|
1228
|
-
} else {
|
|
1229
|
-
this.restoreStateBeforeParse();
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
saveStateBeforeParse() {
|
|
1233
|
-
this._savedState = {
|
|
1234
|
-
_name: this._name,
|
|
1235
|
-
_optionValues: { ...this._optionValues },
|
|
1236
|
-
_optionValueSources: { ...this._optionValueSources }
|
|
1237
|
-
};
|
|
1238
|
-
}
|
|
1239
|
-
restoreStateBeforeParse() {
|
|
1240
|
-
if (this._storeOptionsAsProperties)
|
|
1241
|
-
throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
1242
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);
|
|
1243
|
-
this._name = this._savedState._name;
|
|
1244
|
-
this._scriptPath = null;
|
|
1245
|
-
this.rawArgs = [];
|
|
1246
|
-
this._optionValues = { ...this._savedState._optionValues };
|
|
1247
|
-
this._optionValueSources = { ...this._savedState._optionValueSources };
|
|
1248
|
-
this.args = [];
|
|
1249
|
-
this.processedArgs = [];
|
|
1250
|
-
}
|
|
1251
|
-
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1252
|
-
if (fs.existsSync(executableFile))
|
|
1253
|
-
return;
|
|
1254
|
-
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
1255
|
-
const executableMissing = `'${executableFile}' does not exist
|
|
1256
|
-
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
1257
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
1258
|
-
- ${executableDirMessage}`;
|
|
1259
|
-
throw new Error(executableMissing);
|
|
1260
|
-
}
|
|
1261
1091
|
_executeSubCommand(subcommand, args) {
|
|
1262
1092
|
args = args.slice();
|
|
1263
1093
|
let launchWithNode = false;
|
|
@@ -1281,7 +1111,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1281
1111
|
let resolvedScriptPath;
|
|
1282
1112
|
try {
|
|
1283
1113
|
resolvedScriptPath = fs.realpathSync(this._scriptPath);
|
|
1284
|
-
} catch {
|
|
1114
|
+
} catch (err) {
|
|
1285
1115
|
resolvedScriptPath = this._scriptPath;
|
|
1286
1116
|
}
|
|
1287
1117
|
executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
|
|
@@ -1307,7 +1137,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1307
1137
|
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
1308
1138
|
}
|
|
1309
1139
|
} else {
|
|
1310
|
-
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
1311
1140
|
args.unshift(executableFile);
|
|
1312
1141
|
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1313
1142
|
proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
|
|
@@ -1333,7 +1162,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1333
1162
|
});
|
|
1334
1163
|
proc.on("error", (err) => {
|
|
1335
1164
|
if (err.code === "ENOENT") {
|
|
1336
|
-
|
|
1165
|
+
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
1166
|
+
const executableMissing = `'${executableFile}' does not exist
|
|
1167
|
+
- if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
1168
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
1169
|
+
- ${executableDirMessage}`;
|
|
1170
|
+
throw new Error(executableMissing);
|
|
1337
1171
|
} else if (err.code === "EACCES") {
|
|
1338
1172
|
throw new Error(`'${executableFile}' not executable`);
|
|
1339
1173
|
}
|
|
@@ -1351,7 +1185,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1351
1185
|
const subCommand = this._findCommand(commandName);
|
|
1352
1186
|
if (!subCommand)
|
|
1353
1187
|
this.help({ error: true });
|
|
1354
|
-
subCommand._prepareForParse();
|
|
1355
1188
|
let promiseChain;
|
|
1356
1189
|
promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
|
|
1357
1190
|
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
@@ -1870,38 +1703,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1870
1703
|
}
|
|
1871
1704
|
helpInformation(contextOptions) {
|
|
1872
1705
|
const helper = this.createHelp();
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
outputHasColors: context.hasColors
|
|
1878
|
-
});
|
|
1879
|
-
const text = helper.formatHelp(this, helper);
|
|
1880
|
-
if (context.hasColors)
|
|
1881
|
-
return text;
|
|
1882
|
-
return this._outputConfiguration.stripColor(text);
|
|
1706
|
+
if (helper.helpWidth === undefined) {
|
|
1707
|
+
helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
|
|
1708
|
+
}
|
|
1709
|
+
return helper.formatHelp(this, helper);
|
|
1883
1710
|
}
|
|
1884
|
-
|
|
1711
|
+
_getHelpContext(contextOptions) {
|
|
1885
1712
|
contextOptions = contextOptions || {};
|
|
1886
|
-
const
|
|
1887
|
-
let
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
if (error) {
|
|
1891
|
-
baseWrite = (str) => this._outputConfiguration.writeErr(str);
|
|
1892
|
-
hasColors = this._outputConfiguration.getErrHasColors();
|
|
1893
|
-
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
1713
|
+
const context = { error: !!contextOptions.error };
|
|
1714
|
+
let write;
|
|
1715
|
+
if (context.error) {
|
|
1716
|
+
write = (arg) => this._outputConfiguration.writeErr(arg);
|
|
1894
1717
|
} else {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
if (!hasColors)
|
|
1901
|
-
str = this._outputConfiguration.stripColor(str);
|
|
1902
|
-
return baseWrite(str);
|
|
1903
|
-
};
|
|
1904
|
-
return { error, write, hasColors, helpWidth };
|
|
1718
|
+
write = (arg) => this._outputConfiguration.writeOut(arg);
|
|
1719
|
+
}
|
|
1720
|
+
context.write = contextOptions.write || write;
|
|
1721
|
+
context.command = this;
|
|
1722
|
+
return context;
|
|
1905
1723
|
}
|
|
1906
1724
|
outputHelp(contextOptions) {
|
|
1907
1725
|
let deprecatedCallback;
|
|
@@ -1909,27 +1727,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1909
1727
|
deprecatedCallback = contextOptions;
|
|
1910
1728
|
contextOptions = undefined;
|
|
1911
1729
|
}
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
command: this
|
|
1917
|
-
};
|
|
1918
|
-
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
1919
|
-
this.emit("beforeHelp", eventContext);
|
|
1920
|
-
let helpInformation = this.helpInformation({ error: outputContext.error });
|
|
1730
|
+
const context = this._getHelpContext(contextOptions);
|
|
1731
|
+
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context));
|
|
1732
|
+
this.emit("beforeHelp", context);
|
|
1733
|
+
let helpInformation = this.helpInformation(context);
|
|
1921
1734
|
if (deprecatedCallback) {
|
|
1922
1735
|
helpInformation = deprecatedCallback(helpInformation);
|
|
1923
1736
|
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
|
|
1924
1737
|
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
1925
1738
|
}
|
|
1926
1739
|
}
|
|
1927
|
-
|
|
1740
|
+
context.write(helpInformation);
|
|
1928
1741
|
if (this._getHelpOption()?.long) {
|
|
1929
1742
|
this.emit(this._getHelpOption().long);
|
|
1930
1743
|
}
|
|
1931
|
-
this.emit("afterHelp",
|
|
1932
|
-
this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp",
|
|
1744
|
+
this.emit("afterHelp", context);
|
|
1745
|
+
this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", context));
|
|
1933
1746
|
}
|
|
1934
1747
|
helpOption(flags, description) {
|
|
1935
1748
|
if (typeof flags === "boolean") {
|
|
@@ -1957,7 +1770,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1957
1770
|
}
|
|
1958
1771
|
help(contextOptions) {
|
|
1959
1772
|
this.outputHelp(contextOptions);
|
|
1960
|
-
let exitCode =
|
|
1773
|
+
let exitCode = process2.exitCode || 0;
|
|
1961
1774
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
1962
1775
|
exitCode = 1;
|
|
1963
1776
|
}
|
|
@@ -2022,15 +1835,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2022
1835
|
return arg;
|
|
2023
1836
|
});
|
|
2024
1837
|
}
|
|
2025
|
-
function useColor() {
|
|
2026
|
-
if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
|
|
2027
|
-
return false;
|
|
2028
|
-
if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== undefined)
|
|
2029
|
-
return true;
|
|
2030
|
-
return;
|
|
2031
|
-
}
|
|
2032
1838
|
exports.Command = Command;
|
|
2033
|
-
exports.useColor = useColor;
|
|
2034
1839
|
});
|
|
2035
1840
|
|
|
2036
1841
|
// ../../node_modules/commander/index.js
|
|
@@ -2053,6 +1858,1523 @@ var require_commander = __commonJS((exports) => {
|
|
|
2053
1858
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2054
1859
|
});
|
|
2055
1860
|
|
|
1861
|
+
// ../../node_modules/color-name/index.js
|
|
1862
|
+
var require_color_name = __commonJS((exports, module) => {
|
|
1863
|
+
module.exports = {
|
|
1864
|
+
aliceblue: [240, 248, 255],
|
|
1865
|
+
antiquewhite: [250, 235, 215],
|
|
1866
|
+
aqua: [0, 255, 255],
|
|
1867
|
+
aquamarine: [127, 255, 212],
|
|
1868
|
+
azure: [240, 255, 255],
|
|
1869
|
+
beige: [245, 245, 220],
|
|
1870
|
+
bisque: [255, 228, 196],
|
|
1871
|
+
black: [0, 0, 0],
|
|
1872
|
+
blanchedalmond: [255, 235, 205],
|
|
1873
|
+
blue: [0, 0, 255],
|
|
1874
|
+
blueviolet: [138, 43, 226],
|
|
1875
|
+
brown: [165, 42, 42],
|
|
1876
|
+
burlywood: [222, 184, 135],
|
|
1877
|
+
cadetblue: [95, 158, 160],
|
|
1878
|
+
chartreuse: [127, 255, 0],
|
|
1879
|
+
chocolate: [210, 105, 30],
|
|
1880
|
+
coral: [255, 127, 80],
|
|
1881
|
+
cornflowerblue: [100, 149, 237],
|
|
1882
|
+
cornsilk: [255, 248, 220],
|
|
1883
|
+
crimson: [220, 20, 60],
|
|
1884
|
+
cyan: [0, 255, 255],
|
|
1885
|
+
darkblue: [0, 0, 139],
|
|
1886
|
+
darkcyan: [0, 139, 139],
|
|
1887
|
+
darkgoldenrod: [184, 134, 11],
|
|
1888
|
+
darkgray: [169, 169, 169],
|
|
1889
|
+
darkgreen: [0, 100, 0],
|
|
1890
|
+
darkgrey: [169, 169, 169],
|
|
1891
|
+
darkkhaki: [189, 183, 107],
|
|
1892
|
+
darkmagenta: [139, 0, 139],
|
|
1893
|
+
darkolivegreen: [85, 107, 47],
|
|
1894
|
+
darkorange: [255, 140, 0],
|
|
1895
|
+
darkorchid: [153, 50, 204],
|
|
1896
|
+
darkred: [139, 0, 0],
|
|
1897
|
+
darksalmon: [233, 150, 122],
|
|
1898
|
+
darkseagreen: [143, 188, 143],
|
|
1899
|
+
darkslateblue: [72, 61, 139],
|
|
1900
|
+
darkslategray: [47, 79, 79],
|
|
1901
|
+
darkslategrey: [47, 79, 79],
|
|
1902
|
+
darkturquoise: [0, 206, 209],
|
|
1903
|
+
darkviolet: [148, 0, 211],
|
|
1904
|
+
deeppink: [255, 20, 147],
|
|
1905
|
+
deepskyblue: [0, 191, 255],
|
|
1906
|
+
dimgray: [105, 105, 105],
|
|
1907
|
+
dimgrey: [105, 105, 105],
|
|
1908
|
+
dodgerblue: [30, 144, 255],
|
|
1909
|
+
firebrick: [178, 34, 34],
|
|
1910
|
+
floralwhite: [255, 250, 240],
|
|
1911
|
+
forestgreen: [34, 139, 34],
|
|
1912
|
+
fuchsia: [255, 0, 255],
|
|
1913
|
+
gainsboro: [220, 220, 220],
|
|
1914
|
+
ghostwhite: [248, 248, 255],
|
|
1915
|
+
gold: [255, 215, 0],
|
|
1916
|
+
goldenrod: [218, 165, 32],
|
|
1917
|
+
gray: [128, 128, 128],
|
|
1918
|
+
green: [0, 128, 0],
|
|
1919
|
+
greenyellow: [173, 255, 47],
|
|
1920
|
+
grey: [128, 128, 128],
|
|
1921
|
+
honeydew: [240, 255, 240],
|
|
1922
|
+
hotpink: [255, 105, 180],
|
|
1923
|
+
indianred: [205, 92, 92],
|
|
1924
|
+
indigo: [75, 0, 130],
|
|
1925
|
+
ivory: [255, 255, 240],
|
|
1926
|
+
khaki: [240, 230, 140],
|
|
1927
|
+
lavender: [230, 230, 250],
|
|
1928
|
+
lavenderblush: [255, 240, 245],
|
|
1929
|
+
lawngreen: [124, 252, 0],
|
|
1930
|
+
lemonchiffon: [255, 250, 205],
|
|
1931
|
+
lightblue: [173, 216, 230],
|
|
1932
|
+
lightcoral: [240, 128, 128],
|
|
1933
|
+
lightcyan: [224, 255, 255],
|
|
1934
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
1935
|
+
lightgray: [211, 211, 211],
|
|
1936
|
+
lightgreen: [144, 238, 144],
|
|
1937
|
+
lightgrey: [211, 211, 211],
|
|
1938
|
+
lightpink: [255, 182, 193],
|
|
1939
|
+
lightsalmon: [255, 160, 122],
|
|
1940
|
+
lightseagreen: [32, 178, 170],
|
|
1941
|
+
lightskyblue: [135, 206, 250],
|
|
1942
|
+
lightslategray: [119, 136, 153],
|
|
1943
|
+
lightslategrey: [119, 136, 153],
|
|
1944
|
+
lightsteelblue: [176, 196, 222],
|
|
1945
|
+
lightyellow: [255, 255, 224],
|
|
1946
|
+
lime: [0, 255, 0],
|
|
1947
|
+
limegreen: [50, 205, 50],
|
|
1948
|
+
linen: [250, 240, 230],
|
|
1949
|
+
magenta: [255, 0, 255],
|
|
1950
|
+
maroon: [128, 0, 0],
|
|
1951
|
+
mediumaquamarine: [102, 205, 170],
|
|
1952
|
+
mediumblue: [0, 0, 205],
|
|
1953
|
+
mediumorchid: [186, 85, 211],
|
|
1954
|
+
mediumpurple: [147, 112, 219],
|
|
1955
|
+
mediumseagreen: [60, 179, 113],
|
|
1956
|
+
mediumslateblue: [123, 104, 238],
|
|
1957
|
+
mediumspringgreen: [0, 250, 154],
|
|
1958
|
+
mediumturquoise: [72, 209, 204],
|
|
1959
|
+
mediumvioletred: [199, 21, 133],
|
|
1960
|
+
midnightblue: [25, 25, 112],
|
|
1961
|
+
mintcream: [245, 255, 250],
|
|
1962
|
+
mistyrose: [255, 228, 225],
|
|
1963
|
+
moccasin: [255, 228, 181],
|
|
1964
|
+
navajowhite: [255, 222, 173],
|
|
1965
|
+
navy: [0, 0, 128],
|
|
1966
|
+
oldlace: [253, 245, 230],
|
|
1967
|
+
olive: [128, 128, 0],
|
|
1968
|
+
olivedrab: [107, 142, 35],
|
|
1969
|
+
orange: [255, 165, 0],
|
|
1970
|
+
orangered: [255, 69, 0],
|
|
1971
|
+
orchid: [218, 112, 214],
|
|
1972
|
+
palegoldenrod: [238, 232, 170],
|
|
1973
|
+
palegreen: [152, 251, 152],
|
|
1974
|
+
paleturquoise: [175, 238, 238],
|
|
1975
|
+
palevioletred: [219, 112, 147],
|
|
1976
|
+
papayawhip: [255, 239, 213],
|
|
1977
|
+
peachpuff: [255, 218, 185],
|
|
1978
|
+
peru: [205, 133, 63],
|
|
1979
|
+
pink: [255, 192, 203],
|
|
1980
|
+
plum: [221, 160, 221],
|
|
1981
|
+
powderblue: [176, 224, 230],
|
|
1982
|
+
purple: [128, 0, 128],
|
|
1983
|
+
rebeccapurple: [102, 51, 153],
|
|
1984
|
+
red: [255, 0, 0],
|
|
1985
|
+
rosybrown: [188, 143, 143],
|
|
1986
|
+
royalblue: [65, 105, 225],
|
|
1987
|
+
saddlebrown: [139, 69, 19],
|
|
1988
|
+
salmon: [250, 128, 114],
|
|
1989
|
+
sandybrown: [244, 164, 96],
|
|
1990
|
+
seagreen: [46, 139, 87],
|
|
1991
|
+
seashell: [255, 245, 238],
|
|
1992
|
+
sienna: [160, 82, 45],
|
|
1993
|
+
silver: [192, 192, 192],
|
|
1994
|
+
skyblue: [135, 206, 235],
|
|
1995
|
+
slateblue: [106, 90, 205],
|
|
1996
|
+
slategray: [112, 128, 144],
|
|
1997
|
+
slategrey: [112, 128, 144],
|
|
1998
|
+
snow: [255, 250, 250],
|
|
1999
|
+
springgreen: [0, 255, 127],
|
|
2000
|
+
steelblue: [70, 130, 180],
|
|
2001
|
+
tan: [210, 180, 140],
|
|
2002
|
+
teal: [0, 128, 128],
|
|
2003
|
+
thistle: [216, 191, 216],
|
|
2004
|
+
tomato: [255, 99, 71],
|
|
2005
|
+
turquoise: [64, 224, 208],
|
|
2006
|
+
violet: [238, 130, 238],
|
|
2007
|
+
wheat: [245, 222, 179],
|
|
2008
|
+
white: [255, 255, 255],
|
|
2009
|
+
whitesmoke: [245, 245, 245],
|
|
2010
|
+
yellow: [255, 255, 0],
|
|
2011
|
+
yellowgreen: [154, 205, 50]
|
|
2012
|
+
};
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
// ../../node_modules/color-convert/conversions.js
|
|
2016
|
+
var require_conversions = __commonJS((exports, module) => {
|
|
2017
|
+
var cssKeywords = require_color_name();
|
|
2018
|
+
var reverseKeywords = {};
|
|
2019
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
2020
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
2021
|
+
}
|
|
2022
|
+
var convert = {
|
|
2023
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
2024
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
2025
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
2026
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
2027
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
2028
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
2029
|
+
lab: { channels: 3, labels: "lab" },
|
|
2030
|
+
lch: { channels: 3, labels: "lch" },
|
|
2031
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
2032
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
2033
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
2034
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
2035
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
2036
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
2037
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
2038
|
+
};
|
|
2039
|
+
module.exports = convert;
|
|
2040
|
+
for (const model of Object.keys(convert)) {
|
|
2041
|
+
if (!("channels" in convert[model])) {
|
|
2042
|
+
throw new Error("missing channels property: " + model);
|
|
2043
|
+
}
|
|
2044
|
+
if (!("labels" in convert[model])) {
|
|
2045
|
+
throw new Error("missing channel labels property: " + model);
|
|
2046
|
+
}
|
|
2047
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
2048
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
2049
|
+
}
|
|
2050
|
+
const { channels, labels } = convert[model];
|
|
2051
|
+
delete convert[model].channels;
|
|
2052
|
+
delete convert[model].labels;
|
|
2053
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
2054
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
2055
|
+
}
|
|
2056
|
+
convert.rgb.hsl = function(rgb) {
|
|
2057
|
+
const r = rgb[0] / 255;
|
|
2058
|
+
const g = rgb[1] / 255;
|
|
2059
|
+
const b = rgb[2] / 255;
|
|
2060
|
+
const min = Math.min(r, g, b);
|
|
2061
|
+
const max = Math.max(r, g, b);
|
|
2062
|
+
const delta = max - min;
|
|
2063
|
+
let h;
|
|
2064
|
+
let s;
|
|
2065
|
+
if (max === min) {
|
|
2066
|
+
h = 0;
|
|
2067
|
+
} else if (r === max) {
|
|
2068
|
+
h = (g - b) / delta;
|
|
2069
|
+
} else if (g === max) {
|
|
2070
|
+
h = 2 + (b - r) / delta;
|
|
2071
|
+
} else if (b === max) {
|
|
2072
|
+
h = 4 + (r - g) / delta;
|
|
2073
|
+
}
|
|
2074
|
+
h = Math.min(h * 60, 360);
|
|
2075
|
+
if (h < 0) {
|
|
2076
|
+
h += 360;
|
|
2077
|
+
}
|
|
2078
|
+
const l = (min + max) / 2;
|
|
2079
|
+
if (max === min) {
|
|
2080
|
+
s = 0;
|
|
2081
|
+
} else if (l <= 0.5) {
|
|
2082
|
+
s = delta / (max + min);
|
|
2083
|
+
} else {
|
|
2084
|
+
s = delta / (2 - max - min);
|
|
2085
|
+
}
|
|
2086
|
+
return [h, s * 100, l * 100];
|
|
2087
|
+
};
|
|
2088
|
+
convert.rgb.hsv = function(rgb) {
|
|
2089
|
+
let rdif;
|
|
2090
|
+
let gdif;
|
|
2091
|
+
let bdif;
|
|
2092
|
+
let h;
|
|
2093
|
+
let s;
|
|
2094
|
+
const r = rgb[0] / 255;
|
|
2095
|
+
const g = rgb[1] / 255;
|
|
2096
|
+
const b = rgb[2] / 255;
|
|
2097
|
+
const v = Math.max(r, g, b);
|
|
2098
|
+
const diff = v - Math.min(r, g, b);
|
|
2099
|
+
const diffc = function(c) {
|
|
2100
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
2101
|
+
};
|
|
2102
|
+
if (diff === 0) {
|
|
2103
|
+
h = 0;
|
|
2104
|
+
s = 0;
|
|
2105
|
+
} else {
|
|
2106
|
+
s = diff / v;
|
|
2107
|
+
rdif = diffc(r);
|
|
2108
|
+
gdif = diffc(g);
|
|
2109
|
+
bdif = diffc(b);
|
|
2110
|
+
if (r === v) {
|
|
2111
|
+
h = bdif - gdif;
|
|
2112
|
+
} else if (g === v) {
|
|
2113
|
+
h = 1 / 3 + rdif - bdif;
|
|
2114
|
+
} else if (b === v) {
|
|
2115
|
+
h = 2 / 3 + gdif - rdif;
|
|
2116
|
+
}
|
|
2117
|
+
if (h < 0) {
|
|
2118
|
+
h += 1;
|
|
2119
|
+
} else if (h > 1) {
|
|
2120
|
+
h -= 1;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
return [
|
|
2124
|
+
h * 360,
|
|
2125
|
+
s * 100,
|
|
2126
|
+
v * 100
|
|
2127
|
+
];
|
|
2128
|
+
};
|
|
2129
|
+
convert.rgb.hwb = function(rgb) {
|
|
2130
|
+
const r = rgb[0];
|
|
2131
|
+
const g = rgb[1];
|
|
2132
|
+
let b = rgb[2];
|
|
2133
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
2134
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
2135
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
2136
|
+
return [h, w * 100, b * 100];
|
|
2137
|
+
};
|
|
2138
|
+
convert.rgb.cmyk = function(rgb) {
|
|
2139
|
+
const r = rgb[0] / 255;
|
|
2140
|
+
const g = rgb[1] / 255;
|
|
2141
|
+
const b = rgb[2] / 255;
|
|
2142
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
2143
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
2144
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
2145
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
2146
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
2147
|
+
};
|
|
2148
|
+
function comparativeDistance(x, y) {
|
|
2149
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
2150
|
+
}
|
|
2151
|
+
convert.rgb.keyword = function(rgb) {
|
|
2152
|
+
const reversed = reverseKeywords[rgb];
|
|
2153
|
+
if (reversed) {
|
|
2154
|
+
return reversed;
|
|
2155
|
+
}
|
|
2156
|
+
let currentClosestDistance = Infinity;
|
|
2157
|
+
let currentClosestKeyword;
|
|
2158
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
2159
|
+
const value = cssKeywords[keyword];
|
|
2160
|
+
const distance = comparativeDistance(rgb, value);
|
|
2161
|
+
if (distance < currentClosestDistance) {
|
|
2162
|
+
currentClosestDistance = distance;
|
|
2163
|
+
currentClosestKeyword = keyword;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
return currentClosestKeyword;
|
|
2167
|
+
};
|
|
2168
|
+
convert.keyword.rgb = function(keyword) {
|
|
2169
|
+
return cssKeywords[keyword];
|
|
2170
|
+
};
|
|
2171
|
+
convert.rgb.xyz = function(rgb) {
|
|
2172
|
+
let r = rgb[0] / 255;
|
|
2173
|
+
let g = rgb[1] / 255;
|
|
2174
|
+
let b = rgb[2] / 255;
|
|
2175
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
2176
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
2177
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
2178
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
2179
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
2180
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
2181
|
+
return [x * 100, y * 100, z * 100];
|
|
2182
|
+
};
|
|
2183
|
+
convert.rgb.lab = function(rgb) {
|
|
2184
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
2185
|
+
let x = xyz[0];
|
|
2186
|
+
let y = xyz[1];
|
|
2187
|
+
let z = xyz[2];
|
|
2188
|
+
x /= 95.047;
|
|
2189
|
+
y /= 100;
|
|
2190
|
+
z /= 108.883;
|
|
2191
|
+
x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
2192
|
+
y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
2193
|
+
z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
2194
|
+
const l = 116 * y - 16;
|
|
2195
|
+
const a = 500 * (x - y);
|
|
2196
|
+
const b = 200 * (y - z);
|
|
2197
|
+
return [l, a, b];
|
|
2198
|
+
};
|
|
2199
|
+
convert.hsl.rgb = function(hsl) {
|
|
2200
|
+
const h = hsl[0] / 360;
|
|
2201
|
+
const s = hsl[1] / 100;
|
|
2202
|
+
const l = hsl[2] / 100;
|
|
2203
|
+
let t2;
|
|
2204
|
+
let t3;
|
|
2205
|
+
let val;
|
|
2206
|
+
if (s === 0) {
|
|
2207
|
+
val = l * 255;
|
|
2208
|
+
return [val, val, val];
|
|
2209
|
+
}
|
|
2210
|
+
if (l < 0.5) {
|
|
2211
|
+
t2 = l * (1 + s);
|
|
2212
|
+
} else {
|
|
2213
|
+
t2 = l + s - l * s;
|
|
2214
|
+
}
|
|
2215
|
+
const t1 = 2 * l - t2;
|
|
2216
|
+
const rgb = [0, 0, 0];
|
|
2217
|
+
for (let i = 0;i < 3; i++) {
|
|
2218
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
2219
|
+
if (t3 < 0) {
|
|
2220
|
+
t3++;
|
|
2221
|
+
}
|
|
2222
|
+
if (t3 > 1) {
|
|
2223
|
+
t3--;
|
|
2224
|
+
}
|
|
2225
|
+
if (6 * t3 < 1) {
|
|
2226
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
2227
|
+
} else if (2 * t3 < 1) {
|
|
2228
|
+
val = t2;
|
|
2229
|
+
} else if (3 * t3 < 2) {
|
|
2230
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
2231
|
+
} else {
|
|
2232
|
+
val = t1;
|
|
2233
|
+
}
|
|
2234
|
+
rgb[i] = val * 255;
|
|
2235
|
+
}
|
|
2236
|
+
return rgb;
|
|
2237
|
+
};
|
|
2238
|
+
convert.hsl.hsv = function(hsl) {
|
|
2239
|
+
const h = hsl[0];
|
|
2240
|
+
let s = hsl[1] / 100;
|
|
2241
|
+
let l = hsl[2] / 100;
|
|
2242
|
+
let smin = s;
|
|
2243
|
+
const lmin = Math.max(l, 0.01);
|
|
2244
|
+
l *= 2;
|
|
2245
|
+
s *= l <= 1 ? l : 2 - l;
|
|
2246
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
2247
|
+
const v = (l + s) / 2;
|
|
2248
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
2249
|
+
return [h, sv * 100, v * 100];
|
|
2250
|
+
};
|
|
2251
|
+
convert.hsv.rgb = function(hsv) {
|
|
2252
|
+
const h = hsv[0] / 60;
|
|
2253
|
+
const s = hsv[1] / 100;
|
|
2254
|
+
let v = hsv[2] / 100;
|
|
2255
|
+
const hi = Math.floor(h) % 6;
|
|
2256
|
+
const f = h - Math.floor(h);
|
|
2257
|
+
const p = 255 * v * (1 - s);
|
|
2258
|
+
const q = 255 * v * (1 - s * f);
|
|
2259
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
2260
|
+
v *= 255;
|
|
2261
|
+
switch (hi) {
|
|
2262
|
+
case 0:
|
|
2263
|
+
return [v, t, p];
|
|
2264
|
+
case 1:
|
|
2265
|
+
return [q, v, p];
|
|
2266
|
+
case 2:
|
|
2267
|
+
return [p, v, t];
|
|
2268
|
+
case 3:
|
|
2269
|
+
return [p, q, v];
|
|
2270
|
+
case 4:
|
|
2271
|
+
return [t, p, v];
|
|
2272
|
+
case 5:
|
|
2273
|
+
return [v, p, q];
|
|
2274
|
+
}
|
|
2275
|
+
};
|
|
2276
|
+
convert.hsv.hsl = function(hsv) {
|
|
2277
|
+
const h = hsv[0];
|
|
2278
|
+
const s = hsv[1] / 100;
|
|
2279
|
+
const v = hsv[2] / 100;
|
|
2280
|
+
const vmin = Math.max(v, 0.01);
|
|
2281
|
+
let sl;
|
|
2282
|
+
let l;
|
|
2283
|
+
l = (2 - s) * v;
|
|
2284
|
+
const lmin = (2 - s) * vmin;
|
|
2285
|
+
sl = s * vmin;
|
|
2286
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
2287
|
+
sl = sl || 0;
|
|
2288
|
+
l /= 2;
|
|
2289
|
+
return [h, sl * 100, l * 100];
|
|
2290
|
+
};
|
|
2291
|
+
convert.hwb.rgb = function(hwb) {
|
|
2292
|
+
const h = hwb[0] / 360;
|
|
2293
|
+
let wh = hwb[1] / 100;
|
|
2294
|
+
let bl = hwb[2] / 100;
|
|
2295
|
+
const ratio = wh + bl;
|
|
2296
|
+
let f;
|
|
2297
|
+
if (ratio > 1) {
|
|
2298
|
+
wh /= ratio;
|
|
2299
|
+
bl /= ratio;
|
|
2300
|
+
}
|
|
2301
|
+
const i = Math.floor(6 * h);
|
|
2302
|
+
const v = 1 - bl;
|
|
2303
|
+
f = 6 * h - i;
|
|
2304
|
+
if ((i & 1) !== 0) {
|
|
2305
|
+
f = 1 - f;
|
|
2306
|
+
}
|
|
2307
|
+
const n = wh + f * (v - wh);
|
|
2308
|
+
let r;
|
|
2309
|
+
let g;
|
|
2310
|
+
let b;
|
|
2311
|
+
switch (i) {
|
|
2312
|
+
default:
|
|
2313
|
+
case 6:
|
|
2314
|
+
case 0:
|
|
2315
|
+
r = v;
|
|
2316
|
+
g = n;
|
|
2317
|
+
b = wh;
|
|
2318
|
+
break;
|
|
2319
|
+
case 1:
|
|
2320
|
+
r = n;
|
|
2321
|
+
g = v;
|
|
2322
|
+
b = wh;
|
|
2323
|
+
break;
|
|
2324
|
+
case 2:
|
|
2325
|
+
r = wh;
|
|
2326
|
+
g = v;
|
|
2327
|
+
b = n;
|
|
2328
|
+
break;
|
|
2329
|
+
case 3:
|
|
2330
|
+
r = wh;
|
|
2331
|
+
g = n;
|
|
2332
|
+
b = v;
|
|
2333
|
+
break;
|
|
2334
|
+
case 4:
|
|
2335
|
+
r = n;
|
|
2336
|
+
g = wh;
|
|
2337
|
+
b = v;
|
|
2338
|
+
break;
|
|
2339
|
+
case 5:
|
|
2340
|
+
r = v;
|
|
2341
|
+
g = wh;
|
|
2342
|
+
b = n;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
return [r * 255, g * 255, b * 255];
|
|
2346
|
+
};
|
|
2347
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
2348
|
+
const c = cmyk[0] / 100;
|
|
2349
|
+
const m = cmyk[1] / 100;
|
|
2350
|
+
const y = cmyk[2] / 100;
|
|
2351
|
+
const k = cmyk[3] / 100;
|
|
2352
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
2353
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
2354
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
2355
|
+
return [r * 255, g * 255, b * 255];
|
|
2356
|
+
};
|
|
2357
|
+
convert.xyz.rgb = function(xyz) {
|
|
2358
|
+
const x = xyz[0] / 100;
|
|
2359
|
+
const y = xyz[1] / 100;
|
|
2360
|
+
const z = xyz[2] / 100;
|
|
2361
|
+
let r;
|
|
2362
|
+
let g;
|
|
2363
|
+
let b;
|
|
2364
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
2365
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
2366
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
2367
|
+
r = r > 0.0031308 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
2368
|
+
g = g > 0.0031308 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
2369
|
+
b = b > 0.0031308 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
2370
|
+
r = Math.min(Math.max(0, r), 1);
|
|
2371
|
+
g = Math.min(Math.max(0, g), 1);
|
|
2372
|
+
b = Math.min(Math.max(0, b), 1);
|
|
2373
|
+
return [r * 255, g * 255, b * 255];
|
|
2374
|
+
};
|
|
2375
|
+
convert.xyz.lab = function(xyz) {
|
|
2376
|
+
let x = xyz[0];
|
|
2377
|
+
let y = xyz[1];
|
|
2378
|
+
let z = xyz[2];
|
|
2379
|
+
x /= 95.047;
|
|
2380
|
+
y /= 100;
|
|
2381
|
+
z /= 108.883;
|
|
2382
|
+
x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
2383
|
+
y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
2384
|
+
z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
2385
|
+
const l = 116 * y - 16;
|
|
2386
|
+
const a = 500 * (x - y);
|
|
2387
|
+
const b = 200 * (y - z);
|
|
2388
|
+
return [l, a, b];
|
|
2389
|
+
};
|
|
2390
|
+
convert.lab.xyz = function(lab) {
|
|
2391
|
+
const l = lab[0];
|
|
2392
|
+
const a = lab[1];
|
|
2393
|
+
const b = lab[2];
|
|
2394
|
+
let x;
|
|
2395
|
+
let y;
|
|
2396
|
+
let z;
|
|
2397
|
+
y = (l + 16) / 116;
|
|
2398
|
+
x = a / 500 + y;
|
|
2399
|
+
z = y - b / 200;
|
|
2400
|
+
const y2 = y ** 3;
|
|
2401
|
+
const x2 = x ** 3;
|
|
2402
|
+
const z2 = z ** 3;
|
|
2403
|
+
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
|
2404
|
+
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
|
2405
|
+
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
|
2406
|
+
x *= 95.047;
|
|
2407
|
+
y *= 100;
|
|
2408
|
+
z *= 108.883;
|
|
2409
|
+
return [x, y, z];
|
|
2410
|
+
};
|
|
2411
|
+
convert.lab.lch = function(lab) {
|
|
2412
|
+
const l = lab[0];
|
|
2413
|
+
const a = lab[1];
|
|
2414
|
+
const b = lab[2];
|
|
2415
|
+
let h;
|
|
2416
|
+
const hr = Math.atan2(b, a);
|
|
2417
|
+
h = hr * 360 / 2 / Math.PI;
|
|
2418
|
+
if (h < 0) {
|
|
2419
|
+
h += 360;
|
|
2420
|
+
}
|
|
2421
|
+
const c = Math.sqrt(a * a + b * b);
|
|
2422
|
+
return [l, c, h];
|
|
2423
|
+
};
|
|
2424
|
+
convert.lch.lab = function(lch) {
|
|
2425
|
+
const l = lch[0];
|
|
2426
|
+
const c = lch[1];
|
|
2427
|
+
const h = lch[2];
|
|
2428
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
2429
|
+
const a = c * Math.cos(hr);
|
|
2430
|
+
const b = c * Math.sin(hr);
|
|
2431
|
+
return [l, a, b];
|
|
2432
|
+
};
|
|
2433
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
2434
|
+
const [r, g, b] = args;
|
|
2435
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
2436
|
+
value = Math.round(value / 50);
|
|
2437
|
+
if (value === 0) {
|
|
2438
|
+
return 30;
|
|
2439
|
+
}
|
|
2440
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
2441
|
+
if (value === 2) {
|
|
2442
|
+
ansi += 60;
|
|
2443
|
+
}
|
|
2444
|
+
return ansi;
|
|
2445
|
+
};
|
|
2446
|
+
convert.hsv.ansi16 = function(args) {
|
|
2447
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
2448
|
+
};
|
|
2449
|
+
convert.rgb.ansi256 = function(args) {
|
|
2450
|
+
const r = args[0];
|
|
2451
|
+
const g = args[1];
|
|
2452
|
+
const b = args[2];
|
|
2453
|
+
if (r === g && g === b) {
|
|
2454
|
+
if (r < 8) {
|
|
2455
|
+
return 16;
|
|
2456
|
+
}
|
|
2457
|
+
if (r > 248) {
|
|
2458
|
+
return 231;
|
|
2459
|
+
}
|
|
2460
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
2461
|
+
}
|
|
2462
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
2463
|
+
return ansi;
|
|
2464
|
+
};
|
|
2465
|
+
convert.ansi16.rgb = function(args) {
|
|
2466
|
+
let color = args % 10;
|
|
2467
|
+
if (color === 0 || color === 7) {
|
|
2468
|
+
if (args > 50) {
|
|
2469
|
+
color += 3.5;
|
|
2470
|
+
}
|
|
2471
|
+
color = color / 10.5 * 255;
|
|
2472
|
+
return [color, color, color];
|
|
2473
|
+
}
|
|
2474
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
2475
|
+
const r = (color & 1) * mult * 255;
|
|
2476
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
2477
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
2478
|
+
return [r, g, b];
|
|
2479
|
+
};
|
|
2480
|
+
convert.ansi256.rgb = function(args) {
|
|
2481
|
+
if (args >= 232) {
|
|
2482
|
+
const c = (args - 232) * 10 + 8;
|
|
2483
|
+
return [c, c, c];
|
|
2484
|
+
}
|
|
2485
|
+
args -= 16;
|
|
2486
|
+
let rem;
|
|
2487
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
2488
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
2489
|
+
const b = rem % 6 / 5 * 255;
|
|
2490
|
+
return [r, g, b];
|
|
2491
|
+
};
|
|
2492
|
+
convert.rgb.hex = function(args) {
|
|
2493
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
2494
|
+
const string = integer.toString(16).toUpperCase();
|
|
2495
|
+
return "000000".substring(string.length) + string;
|
|
2496
|
+
};
|
|
2497
|
+
convert.hex.rgb = function(args) {
|
|
2498
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
2499
|
+
if (!match) {
|
|
2500
|
+
return [0, 0, 0];
|
|
2501
|
+
}
|
|
2502
|
+
let colorString = match[0];
|
|
2503
|
+
if (match[0].length === 3) {
|
|
2504
|
+
colorString = colorString.split("").map((char) => {
|
|
2505
|
+
return char + char;
|
|
2506
|
+
}).join("");
|
|
2507
|
+
}
|
|
2508
|
+
const integer = parseInt(colorString, 16);
|
|
2509
|
+
const r = integer >> 16 & 255;
|
|
2510
|
+
const g = integer >> 8 & 255;
|
|
2511
|
+
const b = integer & 255;
|
|
2512
|
+
return [r, g, b];
|
|
2513
|
+
};
|
|
2514
|
+
convert.rgb.hcg = function(rgb) {
|
|
2515
|
+
const r = rgb[0] / 255;
|
|
2516
|
+
const g = rgb[1] / 255;
|
|
2517
|
+
const b = rgb[2] / 255;
|
|
2518
|
+
const max = Math.max(Math.max(r, g), b);
|
|
2519
|
+
const min = Math.min(Math.min(r, g), b);
|
|
2520
|
+
const chroma = max - min;
|
|
2521
|
+
let grayscale;
|
|
2522
|
+
let hue;
|
|
2523
|
+
if (chroma < 1) {
|
|
2524
|
+
grayscale = min / (1 - chroma);
|
|
2525
|
+
} else {
|
|
2526
|
+
grayscale = 0;
|
|
2527
|
+
}
|
|
2528
|
+
if (chroma <= 0) {
|
|
2529
|
+
hue = 0;
|
|
2530
|
+
} else if (max === r) {
|
|
2531
|
+
hue = (g - b) / chroma % 6;
|
|
2532
|
+
} else if (max === g) {
|
|
2533
|
+
hue = 2 + (b - r) / chroma;
|
|
2534
|
+
} else {
|
|
2535
|
+
hue = 4 + (r - g) / chroma;
|
|
2536
|
+
}
|
|
2537
|
+
hue /= 6;
|
|
2538
|
+
hue %= 1;
|
|
2539
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
2540
|
+
};
|
|
2541
|
+
convert.hsl.hcg = function(hsl) {
|
|
2542
|
+
const s = hsl[1] / 100;
|
|
2543
|
+
const l = hsl[2] / 100;
|
|
2544
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
2545
|
+
let f = 0;
|
|
2546
|
+
if (c < 1) {
|
|
2547
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
2548
|
+
}
|
|
2549
|
+
return [hsl[0], c * 100, f * 100];
|
|
2550
|
+
};
|
|
2551
|
+
convert.hsv.hcg = function(hsv) {
|
|
2552
|
+
const s = hsv[1] / 100;
|
|
2553
|
+
const v = hsv[2] / 100;
|
|
2554
|
+
const c = s * v;
|
|
2555
|
+
let f = 0;
|
|
2556
|
+
if (c < 1) {
|
|
2557
|
+
f = (v - c) / (1 - c);
|
|
2558
|
+
}
|
|
2559
|
+
return [hsv[0], c * 100, f * 100];
|
|
2560
|
+
};
|
|
2561
|
+
convert.hcg.rgb = function(hcg) {
|
|
2562
|
+
const h = hcg[0] / 360;
|
|
2563
|
+
const c = hcg[1] / 100;
|
|
2564
|
+
const g = hcg[2] / 100;
|
|
2565
|
+
if (c === 0) {
|
|
2566
|
+
return [g * 255, g * 255, g * 255];
|
|
2567
|
+
}
|
|
2568
|
+
const pure = [0, 0, 0];
|
|
2569
|
+
const hi = h % 1 * 6;
|
|
2570
|
+
const v = hi % 1;
|
|
2571
|
+
const w = 1 - v;
|
|
2572
|
+
let mg = 0;
|
|
2573
|
+
switch (Math.floor(hi)) {
|
|
2574
|
+
case 0:
|
|
2575
|
+
pure[0] = 1;
|
|
2576
|
+
pure[1] = v;
|
|
2577
|
+
pure[2] = 0;
|
|
2578
|
+
break;
|
|
2579
|
+
case 1:
|
|
2580
|
+
pure[0] = w;
|
|
2581
|
+
pure[1] = 1;
|
|
2582
|
+
pure[2] = 0;
|
|
2583
|
+
break;
|
|
2584
|
+
case 2:
|
|
2585
|
+
pure[0] = 0;
|
|
2586
|
+
pure[1] = 1;
|
|
2587
|
+
pure[2] = v;
|
|
2588
|
+
break;
|
|
2589
|
+
case 3:
|
|
2590
|
+
pure[0] = 0;
|
|
2591
|
+
pure[1] = w;
|
|
2592
|
+
pure[2] = 1;
|
|
2593
|
+
break;
|
|
2594
|
+
case 4:
|
|
2595
|
+
pure[0] = v;
|
|
2596
|
+
pure[1] = 0;
|
|
2597
|
+
pure[2] = 1;
|
|
2598
|
+
break;
|
|
2599
|
+
default:
|
|
2600
|
+
pure[0] = 1;
|
|
2601
|
+
pure[1] = 0;
|
|
2602
|
+
pure[2] = w;
|
|
2603
|
+
}
|
|
2604
|
+
mg = (1 - c) * g;
|
|
2605
|
+
return [
|
|
2606
|
+
(c * pure[0] + mg) * 255,
|
|
2607
|
+
(c * pure[1] + mg) * 255,
|
|
2608
|
+
(c * pure[2] + mg) * 255
|
|
2609
|
+
];
|
|
2610
|
+
};
|
|
2611
|
+
convert.hcg.hsv = function(hcg) {
|
|
2612
|
+
const c = hcg[1] / 100;
|
|
2613
|
+
const g = hcg[2] / 100;
|
|
2614
|
+
const v = c + g * (1 - c);
|
|
2615
|
+
let f = 0;
|
|
2616
|
+
if (v > 0) {
|
|
2617
|
+
f = c / v;
|
|
2618
|
+
}
|
|
2619
|
+
return [hcg[0], f * 100, v * 100];
|
|
2620
|
+
};
|
|
2621
|
+
convert.hcg.hsl = function(hcg) {
|
|
2622
|
+
const c = hcg[1] / 100;
|
|
2623
|
+
const g = hcg[2] / 100;
|
|
2624
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
2625
|
+
let s = 0;
|
|
2626
|
+
if (l > 0 && l < 0.5) {
|
|
2627
|
+
s = c / (2 * l);
|
|
2628
|
+
} else if (l >= 0.5 && l < 1) {
|
|
2629
|
+
s = c / (2 * (1 - l));
|
|
2630
|
+
}
|
|
2631
|
+
return [hcg[0], s * 100, l * 100];
|
|
2632
|
+
};
|
|
2633
|
+
convert.hcg.hwb = function(hcg) {
|
|
2634
|
+
const c = hcg[1] / 100;
|
|
2635
|
+
const g = hcg[2] / 100;
|
|
2636
|
+
const v = c + g * (1 - c);
|
|
2637
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
2638
|
+
};
|
|
2639
|
+
convert.hwb.hcg = function(hwb) {
|
|
2640
|
+
const w = hwb[1] / 100;
|
|
2641
|
+
const b = hwb[2] / 100;
|
|
2642
|
+
const v = 1 - b;
|
|
2643
|
+
const c = v - w;
|
|
2644
|
+
let g = 0;
|
|
2645
|
+
if (c < 1) {
|
|
2646
|
+
g = (v - c) / (1 - c);
|
|
2647
|
+
}
|
|
2648
|
+
return [hwb[0], c * 100, g * 100];
|
|
2649
|
+
};
|
|
2650
|
+
convert.apple.rgb = function(apple) {
|
|
2651
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
2652
|
+
};
|
|
2653
|
+
convert.rgb.apple = function(rgb) {
|
|
2654
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
2655
|
+
};
|
|
2656
|
+
convert.gray.rgb = function(args) {
|
|
2657
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
2658
|
+
};
|
|
2659
|
+
convert.gray.hsl = function(args) {
|
|
2660
|
+
return [0, 0, args[0]];
|
|
2661
|
+
};
|
|
2662
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
2663
|
+
convert.gray.hwb = function(gray) {
|
|
2664
|
+
return [0, 100, gray[0]];
|
|
2665
|
+
};
|
|
2666
|
+
convert.gray.cmyk = function(gray) {
|
|
2667
|
+
return [0, 0, 0, gray[0]];
|
|
2668
|
+
};
|
|
2669
|
+
convert.gray.lab = function(gray) {
|
|
2670
|
+
return [gray[0], 0, 0];
|
|
2671
|
+
};
|
|
2672
|
+
convert.gray.hex = function(gray) {
|
|
2673
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
2674
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
2675
|
+
const string = integer.toString(16).toUpperCase();
|
|
2676
|
+
return "000000".substring(string.length) + string;
|
|
2677
|
+
};
|
|
2678
|
+
convert.rgb.gray = function(rgb) {
|
|
2679
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
2680
|
+
return [val / 255 * 100];
|
|
2681
|
+
};
|
|
2682
|
+
});
|
|
2683
|
+
|
|
2684
|
+
// ../../node_modules/color-convert/route.js
|
|
2685
|
+
var require_route = __commonJS((exports, module) => {
|
|
2686
|
+
var conversions = require_conversions();
|
|
2687
|
+
function buildGraph() {
|
|
2688
|
+
const graph = {};
|
|
2689
|
+
const models = Object.keys(conversions);
|
|
2690
|
+
for (let len = models.length, i = 0;i < len; i++) {
|
|
2691
|
+
graph[models[i]] = {
|
|
2692
|
+
distance: -1,
|
|
2693
|
+
parent: null
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
return graph;
|
|
2697
|
+
}
|
|
2698
|
+
function deriveBFS(fromModel) {
|
|
2699
|
+
const graph = buildGraph();
|
|
2700
|
+
const queue = [fromModel];
|
|
2701
|
+
graph[fromModel].distance = 0;
|
|
2702
|
+
while (queue.length) {
|
|
2703
|
+
const current = queue.pop();
|
|
2704
|
+
const adjacents = Object.keys(conversions[current]);
|
|
2705
|
+
for (let len = adjacents.length, i = 0;i < len; i++) {
|
|
2706
|
+
const adjacent = adjacents[i];
|
|
2707
|
+
const node = graph[adjacent];
|
|
2708
|
+
if (node.distance === -1) {
|
|
2709
|
+
node.distance = graph[current].distance + 1;
|
|
2710
|
+
node.parent = current;
|
|
2711
|
+
queue.unshift(adjacent);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
return graph;
|
|
2716
|
+
}
|
|
2717
|
+
function link(from, to) {
|
|
2718
|
+
return function(args) {
|
|
2719
|
+
return to(from(args));
|
|
2720
|
+
};
|
|
2721
|
+
}
|
|
2722
|
+
function wrapConversion(toModel, graph) {
|
|
2723
|
+
const path2 = [graph[toModel].parent, toModel];
|
|
2724
|
+
let fn = conversions[graph[toModel].parent][toModel];
|
|
2725
|
+
let cur = graph[toModel].parent;
|
|
2726
|
+
while (graph[cur].parent) {
|
|
2727
|
+
path2.unshift(graph[cur].parent);
|
|
2728
|
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
2729
|
+
cur = graph[cur].parent;
|
|
2730
|
+
}
|
|
2731
|
+
fn.conversion = path2;
|
|
2732
|
+
return fn;
|
|
2733
|
+
}
|
|
2734
|
+
module.exports = function(fromModel) {
|
|
2735
|
+
const graph = deriveBFS(fromModel);
|
|
2736
|
+
const conversion = {};
|
|
2737
|
+
const models = Object.keys(graph);
|
|
2738
|
+
for (let len = models.length, i = 0;i < len; i++) {
|
|
2739
|
+
const toModel = models[i];
|
|
2740
|
+
const node = graph[toModel];
|
|
2741
|
+
if (node.parent === null) {
|
|
2742
|
+
continue;
|
|
2743
|
+
}
|
|
2744
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
2745
|
+
}
|
|
2746
|
+
return conversion;
|
|
2747
|
+
};
|
|
2748
|
+
});
|
|
2749
|
+
|
|
2750
|
+
// ../../node_modules/color-convert/index.js
|
|
2751
|
+
var require_color_convert = __commonJS((exports, module) => {
|
|
2752
|
+
var conversions = require_conversions();
|
|
2753
|
+
var route = require_route();
|
|
2754
|
+
var convert = {};
|
|
2755
|
+
var models = Object.keys(conversions);
|
|
2756
|
+
function wrapRaw(fn) {
|
|
2757
|
+
const wrappedFn = function(...args) {
|
|
2758
|
+
const arg0 = args[0];
|
|
2759
|
+
if (arg0 === undefined || arg0 === null) {
|
|
2760
|
+
return arg0;
|
|
2761
|
+
}
|
|
2762
|
+
if (arg0.length > 1) {
|
|
2763
|
+
args = arg0;
|
|
2764
|
+
}
|
|
2765
|
+
return fn(args);
|
|
2766
|
+
};
|
|
2767
|
+
if ("conversion" in fn) {
|
|
2768
|
+
wrappedFn.conversion = fn.conversion;
|
|
2769
|
+
}
|
|
2770
|
+
return wrappedFn;
|
|
2771
|
+
}
|
|
2772
|
+
function wrapRounded(fn) {
|
|
2773
|
+
const wrappedFn = function(...args) {
|
|
2774
|
+
const arg0 = args[0];
|
|
2775
|
+
if (arg0 === undefined || arg0 === null) {
|
|
2776
|
+
return arg0;
|
|
2777
|
+
}
|
|
2778
|
+
if (arg0.length > 1) {
|
|
2779
|
+
args = arg0;
|
|
2780
|
+
}
|
|
2781
|
+
const result = fn(args);
|
|
2782
|
+
if (typeof result === "object") {
|
|
2783
|
+
for (let len = result.length, i = 0;i < len; i++) {
|
|
2784
|
+
result[i] = Math.round(result[i]);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
return result;
|
|
2788
|
+
};
|
|
2789
|
+
if ("conversion" in fn) {
|
|
2790
|
+
wrappedFn.conversion = fn.conversion;
|
|
2791
|
+
}
|
|
2792
|
+
return wrappedFn;
|
|
2793
|
+
}
|
|
2794
|
+
models.forEach((fromModel) => {
|
|
2795
|
+
convert[fromModel] = {};
|
|
2796
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
2797
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
2798
|
+
const routes = route(fromModel);
|
|
2799
|
+
const routeModels = Object.keys(routes);
|
|
2800
|
+
routeModels.forEach((toModel) => {
|
|
2801
|
+
const fn = routes[toModel];
|
|
2802
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
2803
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
2804
|
+
});
|
|
2805
|
+
});
|
|
2806
|
+
module.exports = convert;
|
|
2807
|
+
});
|
|
2808
|
+
|
|
2809
|
+
// ../../node_modules/ansi-styles/index.js
|
|
2810
|
+
var require_ansi_styles = __commonJS((exports, module) => {
|
|
2811
|
+
var wrapAnsi16 = (fn, offset) => (...args) => {
|
|
2812
|
+
const code = fn(...args);
|
|
2813
|
+
return `\x1B[${code + offset}m`;
|
|
2814
|
+
};
|
|
2815
|
+
var wrapAnsi256 = (fn, offset) => (...args) => {
|
|
2816
|
+
const code = fn(...args);
|
|
2817
|
+
return `\x1B[${38 + offset};5;${code}m`;
|
|
2818
|
+
};
|
|
2819
|
+
var wrapAnsi16m = (fn, offset) => (...args) => {
|
|
2820
|
+
const rgb = fn(...args);
|
|
2821
|
+
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
2822
|
+
};
|
|
2823
|
+
var ansi2ansi = (n) => n;
|
|
2824
|
+
var rgb2rgb = (r, g, b) => [r, g, b];
|
|
2825
|
+
var setLazyProperty = (object, property, get) => {
|
|
2826
|
+
Object.defineProperty(object, property, {
|
|
2827
|
+
get: () => {
|
|
2828
|
+
const value = get();
|
|
2829
|
+
Object.defineProperty(object, property, {
|
|
2830
|
+
value,
|
|
2831
|
+
enumerable: true,
|
|
2832
|
+
configurable: true
|
|
2833
|
+
});
|
|
2834
|
+
return value;
|
|
2835
|
+
},
|
|
2836
|
+
enumerable: true,
|
|
2837
|
+
configurable: true
|
|
2838
|
+
});
|
|
2839
|
+
};
|
|
2840
|
+
var colorConvert;
|
|
2841
|
+
var makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
2842
|
+
if (colorConvert === undefined) {
|
|
2843
|
+
colorConvert = require_color_convert();
|
|
2844
|
+
}
|
|
2845
|
+
const offset = isBackground ? 10 : 0;
|
|
2846
|
+
const styles = {};
|
|
2847
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
|
2848
|
+
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
2849
|
+
if (sourceSpace === targetSpace) {
|
|
2850
|
+
styles[name] = wrap(identity, offset);
|
|
2851
|
+
} else if (typeof suite === "object") {
|
|
2852
|
+
styles[name] = wrap(suite[targetSpace], offset);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
return styles;
|
|
2856
|
+
};
|
|
2857
|
+
function assembleStyles() {
|
|
2858
|
+
const codes = new Map;
|
|
2859
|
+
const styles = {
|
|
2860
|
+
modifier: {
|
|
2861
|
+
reset: [0, 0],
|
|
2862
|
+
bold: [1, 22],
|
|
2863
|
+
dim: [2, 22],
|
|
2864
|
+
italic: [3, 23],
|
|
2865
|
+
underline: [4, 24],
|
|
2866
|
+
inverse: [7, 27],
|
|
2867
|
+
hidden: [8, 28],
|
|
2868
|
+
strikethrough: [9, 29]
|
|
2869
|
+
},
|
|
2870
|
+
color: {
|
|
2871
|
+
black: [30, 39],
|
|
2872
|
+
red: [31, 39],
|
|
2873
|
+
green: [32, 39],
|
|
2874
|
+
yellow: [33, 39],
|
|
2875
|
+
blue: [34, 39],
|
|
2876
|
+
magenta: [35, 39],
|
|
2877
|
+
cyan: [36, 39],
|
|
2878
|
+
white: [37, 39],
|
|
2879
|
+
blackBright: [90, 39],
|
|
2880
|
+
redBright: [91, 39],
|
|
2881
|
+
greenBright: [92, 39],
|
|
2882
|
+
yellowBright: [93, 39],
|
|
2883
|
+
blueBright: [94, 39],
|
|
2884
|
+
magentaBright: [95, 39],
|
|
2885
|
+
cyanBright: [96, 39],
|
|
2886
|
+
whiteBright: [97, 39]
|
|
2887
|
+
},
|
|
2888
|
+
bgColor: {
|
|
2889
|
+
bgBlack: [40, 49],
|
|
2890
|
+
bgRed: [41, 49],
|
|
2891
|
+
bgGreen: [42, 49],
|
|
2892
|
+
bgYellow: [43, 49],
|
|
2893
|
+
bgBlue: [44, 49],
|
|
2894
|
+
bgMagenta: [45, 49],
|
|
2895
|
+
bgCyan: [46, 49],
|
|
2896
|
+
bgWhite: [47, 49],
|
|
2897
|
+
bgBlackBright: [100, 49],
|
|
2898
|
+
bgRedBright: [101, 49],
|
|
2899
|
+
bgGreenBright: [102, 49],
|
|
2900
|
+
bgYellowBright: [103, 49],
|
|
2901
|
+
bgBlueBright: [104, 49],
|
|
2902
|
+
bgMagentaBright: [105, 49],
|
|
2903
|
+
bgCyanBright: [106, 49],
|
|
2904
|
+
bgWhiteBright: [107, 49]
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
styles.color.gray = styles.color.blackBright;
|
|
2908
|
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
2909
|
+
styles.color.grey = styles.color.blackBright;
|
|
2910
|
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
2911
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
2912
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
2913
|
+
styles[styleName] = {
|
|
2914
|
+
open: `\x1B[${style[0]}m`,
|
|
2915
|
+
close: `\x1B[${style[1]}m`
|
|
2916
|
+
};
|
|
2917
|
+
group[styleName] = styles[styleName];
|
|
2918
|
+
codes.set(style[0], style[1]);
|
|
2919
|
+
}
|
|
2920
|
+
Object.defineProperty(styles, groupName, {
|
|
2921
|
+
value: group,
|
|
2922
|
+
enumerable: false
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
2925
|
+
Object.defineProperty(styles, "codes", {
|
|
2926
|
+
value: codes,
|
|
2927
|
+
enumerable: false
|
|
2928
|
+
});
|
|
2929
|
+
styles.color.close = "\x1B[39m";
|
|
2930
|
+
styles.bgColor.close = "\x1B[49m";
|
|
2931
|
+
setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
2932
|
+
setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
2933
|
+
setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
2934
|
+
setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
2935
|
+
setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
2936
|
+
setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
2937
|
+
return styles;
|
|
2938
|
+
}
|
|
2939
|
+
Object.defineProperty(module, "exports", {
|
|
2940
|
+
enumerable: true,
|
|
2941
|
+
get: assembleStyles
|
|
2942
|
+
});
|
|
2943
|
+
});
|
|
2944
|
+
|
|
2945
|
+
// ../../node_modules/has-flag/index.js
|
|
2946
|
+
var require_has_flag = __commonJS((exports, module) => {
|
|
2947
|
+
module.exports = (flag, argv = process.argv) => {
|
|
2948
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
2949
|
+
const position = argv.indexOf(prefix + flag);
|
|
2950
|
+
const terminatorPosition = argv.indexOf("--");
|
|
2951
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2952
|
+
};
|
|
2953
|
+
});
|
|
2954
|
+
|
|
2955
|
+
// ../../node_modules/chalk/node_modules/supports-color/index.js
|
|
2956
|
+
var require_supports_color = __commonJS((exports, module) => {
|
|
2957
|
+
var os2 = __require("os");
|
|
2958
|
+
var tty = __require("tty");
|
|
2959
|
+
var hasFlag = require_has_flag();
|
|
2960
|
+
var { env: env2 } = process;
|
|
2961
|
+
var forceColor;
|
|
2962
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
2963
|
+
forceColor = 0;
|
|
2964
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
2965
|
+
forceColor = 1;
|
|
2966
|
+
}
|
|
2967
|
+
if ("FORCE_COLOR" in env2) {
|
|
2968
|
+
if (env2.FORCE_COLOR === "true") {
|
|
2969
|
+
forceColor = 1;
|
|
2970
|
+
} else if (env2.FORCE_COLOR === "false") {
|
|
2971
|
+
forceColor = 0;
|
|
2972
|
+
} else {
|
|
2973
|
+
forceColor = env2.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env2.FORCE_COLOR, 10), 3);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
function translateLevel(level) {
|
|
2977
|
+
if (level === 0) {
|
|
2978
|
+
return false;
|
|
2979
|
+
}
|
|
2980
|
+
return {
|
|
2981
|
+
level,
|
|
2982
|
+
hasBasic: true,
|
|
2983
|
+
has256: level >= 2,
|
|
2984
|
+
has16m: level >= 3
|
|
2985
|
+
};
|
|
2986
|
+
}
|
|
2987
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
2988
|
+
if (forceColor === 0) {
|
|
2989
|
+
return 0;
|
|
2990
|
+
}
|
|
2991
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
2992
|
+
return 3;
|
|
2993
|
+
}
|
|
2994
|
+
if (hasFlag("color=256")) {
|
|
2995
|
+
return 2;
|
|
2996
|
+
}
|
|
2997
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
2998
|
+
return 0;
|
|
2999
|
+
}
|
|
3000
|
+
const min = forceColor || 0;
|
|
3001
|
+
if (env2.TERM === "dumb") {
|
|
3002
|
+
return min;
|
|
3003
|
+
}
|
|
3004
|
+
if (process.platform === "win32") {
|
|
3005
|
+
const osRelease = os2.release().split(".");
|
|
3006
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
3007
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
3008
|
+
}
|
|
3009
|
+
return 1;
|
|
3010
|
+
}
|
|
3011
|
+
if ("CI" in env2) {
|
|
3012
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env2)) || env2.CI_NAME === "codeship") {
|
|
3013
|
+
return 1;
|
|
3014
|
+
}
|
|
3015
|
+
return min;
|
|
3016
|
+
}
|
|
3017
|
+
if ("TEAMCITY_VERSION" in env2) {
|
|
3018
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
|
|
3019
|
+
}
|
|
3020
|
+
if (env2.COLORTERM === "truecolor") {
|
|
3021
|
+
return 3;
|
|
3022
|
+
}
|
|
3023
|
+
if ("TERM_PROGRAM" in env2) {
|
|
3024
|
+
const version = parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
3025
|
+
switch (env2.TERM_PROGRAM) {
|
|
3026
|
+
case "iTerm.app":
|
|
3027
|
+
return version >= 3 ? 3 : 2;
|
|
3028
|
+
case "Apple_Terminal":
|
|
3029
|
+
return 2;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
if (/-256(color)?$/i.test(env2.TERM)) {
|
|
3033
|
+
return 2;
|
|
3034
|
+
}
|
|
3035
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
|
|
3036
|
+
return 1;
|
|
3037
|
+
}
|
|
3038
|
+
if ("COLORTERM" in env2) {
|
|
3039
|
+
return 1;
|
|
3040
|
+
}
|
|
3041
|
+
return min;
|
|
3042
|
+
}
|
|
3043
|
+
function getSupportLevel(stream) {
|
|
3044
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
3045
|
+
return translateLevel(level);
|
|
3046
|
+
}
|
|
3047
|
+
module.exports = {
|
|
3048
|
+
supportsColor: getSupportLevel,
|
|
3049
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
3050
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
3051
|
+
};
|
|
3052
|
+
});
|
|
3053
|
+
|
|
3054
|
+
// ../../node_modules/chalk/source/util.js
|
|
3055
|
+
var require_util = __commonJS((exports, module) => {
|
|
3056
|
+
var stringReplaceAll = (string, substring, replacer) => {
|
|
3057
|
+
let index = string.indexOf(substring);
|
|
3058
|
+
if (index === -1) {
|
|
3059
|
+
return string;
|
|
3060
|
+
}
|
|
3061
|
+
const substringLength = substring.length;
|
|
3062
|
+
let endIndex = 0;
|
|
3063
|
+
let returnValue = "";
|
|
3064
|
+
do {
|
|
3065
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
3066
|
+
endIndex = index + substringLength;
|
|
3067
|
+
index = string.indexOf(substring, endIndex);
|
|
3068
|
+
} while (index !== -1);
|
|
3069
|
+
returnValue += string.substr(endIndex);
|
|
3070
|
+
return returnValue;
|
|
3071
|
+
};
|
|
3072
|
+
var stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
|
3073
|
+
let endIndex = 0;
|
|
3074
|
+
let returnValue = "";
|
|
3075
|
+
do {
|
|
3076
|
+
const gotCR = string[index - 1] === "\r";
|
|
3077
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? `\r
|
|
3078
|
+
` : `
|
|
3079
|
+
`) + postfix;
|
|
3080
|
+
endIndex = index + 1;
|
|
3081
|
+
index = string.indexOf(`
|
|
3082
|
+
`, endIndex);
|
|
3083
|
+
} while (index !== -1);
|
|
3084
|
+
returnValue += string.substr(endIndex);
|
|
3085
|
+
return returnValue;
|
|
3086
|
+
};
|
|
3087
|
+
module.exports = {
|
|
3088
|
+
stringReplaceAll,
|
|
3089
|
+
stringEncaseCRLFWithFirstIndex
|
|
3090
|
+
};
|
|
3091
|
+
});
|
|
3092
|
+
|
|
3093
|
+
// ../../node_modules/chalk/source/templates.js
|
|
3094
|
+
var require_templates = __commonJS((exports, module) => {
|
|
3095
|
+
var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
3096
|
+
var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
3097
|
+
var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
3098
|
+
var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
3099
|
+
var ESCAPES = new Map([
|
|
3100
|
+
["n", `
|
|
3101
|
+
`],
|
|
3102
|
+
["r", "\r"],
|
|
3103
|
+
["t", "\t"],
|
|
3104
|
+
["b", "\b"],
|
|
3105
|
+
["f", "\f"],
|
|
3106
|
+
["v", "\v"],
|
|
3107
|
+
["0", "\x00"],
|
|
3108
|
+
["\\", "\\"],
|
|
3109
|
+
["e", "\x1B"],
|
|
3110
|
+
["a", "\x07"]
|
|
3111
|
+
]);
|
|
3112
|
+
function unescape(c) {
|
|
3113
|
+
const u = c[0] === "u";
|
|
3114
|
+
const bracket = c[1] === "{";
|
|
3115
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
3116
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
3117
|
+
}
|
|
3118
|
+
if (u && bracket) {
|
|
3119
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
3120
|
+
}
|
|
3121
|
+
return ESCAPES.get(c) || c;
|
|
3122
|
+
}
|
|
3123
|
+
function parseArguments(name, arguments_) {
|
|
3124
|
+
const results = [];
|
|
3125
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
3126
|
+
let matches;
|
|
3127
|
+
for (const chunk of chunks) {
|
|
3128
|
+
const number = Number(chunk);
|
|
3129
|
+
if (!Number.isNaN(number)) {
|
|
3130
|
+
results.push(number);
|
|
3131
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
3132
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
3133
|
+
} else {
|
|
3134
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
return results;
|
|
3138
|
+
}
|
|
3139
|
+
function parseStyle(style) {
|
|
3140
|
+
STYLE_REGEX.lastIndex = 0;
|
|
3141
|
+
const results = [];
|
|
3142
|
+
let matches;
|
|
3143
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
3144
|
+
const name = matches[1];
|
|
3145
|
+
if (matches[2]) {
|
|
3146
|
+
const args = parseArguments(name, matches[2]);
|
|
3147
|
+
results.push([name].concat(args));
|
|
3148
|
+
} else {
|
|
3149
|
+
results.push([name]);
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
return results;
|
|
3153
|
+
}
|
|
3154
|
+
function buildStyle(chalk, styles) {
|
|
3155
|
+
const enabled = {};
|
|
3156
|
+
for (const layer of styles) {
|
|
3157
|
+
for (const style of layer.styles) {
|
|
3158
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
let current = chalk;
|
|
3162
|
+
for (const [styleName, styles2] of Object.entries(enabled)) {
|
|
3163
|
+
if (!Array.isArray(styles2)) {
|
|
3164
|
+
continue;
|
|
3165
|
+
}
|
|
3166
|
+
if (!(styleName in current)) {
|
|
3167
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
3168
|
+
}
|
|
3169
|
+
current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
|
|
3170
|
+
}
|
|
3171
|
+
return current;
|
|
3172
|
+
}
|
|
3173
|
+
module.exports = (chalk, temporary) => {
|
|
3174
|
+
const styles = [];
|
|
3175
|
+
const chunks = [];
|
|
3176
|
+
let chunk = [];
|
|
3177
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
3178
|
+
if (escapeCharacter) {
|
|
3179
|
+
chunk.push(unescape(escapeCharacter));
|
|
3180
|
+
} else if (style) {
|
|
3181
|
+
const string = chunk.join("");
|
|
3182
|
+
chunk = [];
|
|
3183
|
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
|
3184
|
+
styles.push({ inverse, styles: parseStyle(style) });
|
|
3185
|
+
} else if (close) {
|
|
3186
|
+
if (styles.length === 0) {
|
|
3187
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
3188
|
+
}
|
|
3189
|
+
chunks.push(buildStyle(chalk, styles)(chunk.join("")));
|
|
3190
|
+
chunk = [];
|
|
3191
|
+
styles.pop();
|
|
3192
|
+
} else {
|
|
3193
|
+
chunk.push(character);
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
chunks.push(chunk.join(""));
|
|
3197
|
+
if (styles.length > 0) {
|
|
3198
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
|
|
3199
|
+
throw new Error(errMessage);
|
|
3200
|
+
}
|
|
3201
|
+
return chunks.join("");
|
|
3202
|
+
};
|
|
3203
|
+
});
|
|
3204
|
+
|
|
3205
|
+
// ../../node_modules/chalk/source/index.js
|
|
3206
|
+
var require_source = __commonJS((exports, module) => {
|
|
3207
|
+
var ansiStyles = require_ansi_styles();
|
|
3208
|
+
var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
|
|
3209
|
+
var {
|
|
3210
|
+
stringReplaceAll,
|
|
3211
|
+
stringEncaseCRLFWithFirstIndex
|
|
3212
|
+
} = require_util();
|
|
3213
|
+
var { isArray } = Array;
|
|
3214
|
+
var levelMapping = [
|
|
3215
|
+
"ansi",
|
|
3216
|
+
"ansi",
|
|
3217
|
+
"ansi256",
|
|
3218
|
+
"ansi16m"
|
|
3219
|
+
];
|
|
3220
|
+
var styles = Object.create(null);
|
|
3221
|
+
var applyOptions = (object, options = {}) => {
|
|
3222
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
3223
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
3224
|
+
}
|
|
3225
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
3226
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
|
3227
|
+
};
|
|
3228
|
+
|
|
3229
|
+
class ChalkClass {
|
|
3230
|
+
constructor(options) {
|
|
3231
|
+
return chalkFactory(options);
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
var chalkFactory = (options) => {
|
|
3235
|
+
const chalk2 = {};
|
|
3236
|
+
applyOptions(chalk2, options);
|
|
3237
|
+
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
3238
|
+
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
3239
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
3240
|
+
chalk2.template.constructor = () => {
|
|
3241
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
3242
|
+
};
|
|
3243
|
+
chalk2.template.Instance = ChalkClass;
|
|
3244
|
+
return chalk2.template;
|
|
3245
|
+
};
|
|
3246
|
+
function Chalk(options) {
|
|
3247
|
+
return chalkFactory(options);
|
|
3248
|
+
}
|
|
3249
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
3250
|
+
styles[styleName] = {
|
|
3251
|
+
get() {
|
|
3252
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
3253
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
3254
|
+
return builder;
|
|
3255
|
+
}
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
styles.visible = {
|
|
3259
|
+
get() {
|
|
3260
|
+
const builder = createBuilder(this, this._styler, true);
|
|
3261
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
3262
|
+
return builder;
|
|
3263
|
+
}
|
|
3264
|
+
};
|
|
3265
|
+
var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
3266
|
+
for (const model of usedModels) {
|
|
3267
|
+
styles[model] = {
|
|
3268
|
+
get() {
|
|
3269
|
+
const { level } = this;
|
|
3270
|
+
return function(...arguments_) {
|
|
3271
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
3272
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
3273
|
+
};
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
for (const model of usedModels) {
|
|
3278
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
3279
|
+
styles[bgModel] = {
|
|
3280
|
+
get() {
|
|
3281
|
+
const { level } = this;
|
|
3282
|
+
return function(...arguments_) {
|
|
3283
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
3284
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
3285
|
+
};
|
|
3286
|
+
}
|
|
3287
|
+
};
|
|
3288
|
+
}
|
|
3289
|
+
var proto = Object.defineProperties(() => {}, {
|
|
3290
|
+
...styles,
|
|
3291
|
+
level: {
|
|
3292
|
+
enumerable: true,
|
|
3293
|
+
get() {
|
|
3294
|
+
return this._generator.level;
|
|
3295
|
+
},
|
|
3296
|
+
set(level) {
|
|
3297
|
+
this._generator.level = level;
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
var createStyler = (open, close, parent) => {
|
|
3302
|
+
let openAll;
|
|
3303
|
+
let closeAll;
|
|
3304
|
+
if (parent === undefined) {
|
|
3305
|
+
openAll = open;
|
|
3306
|
+
closeAll = close;
|
|
3307
|
+
} else {
|
|
3308
|
+
openAll = parent.openAll + open;
|
|
3309
|
+
closeAll = close + parent.closeAll;
|
|
3310
|
+
}
|
|
3311
|
+
return {
|
|
3312
|
+
open,
|
|
3313
|
+
close,
|
|
3314
|
+
openAll,
|
|
3315
|
+
closeAll,
|
|
3316
|
+
parent
|
|
3317
|
+
};
|
|
3318
|
+
};
|
|
3319
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
3320
|
+
const builder = (...arguments_) => {
|
|
3321
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
3322
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
3323
|
+
}
|
|
3324
|
+
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
3325
|
+
};
|
|
3326
|
+
Object.setPrototypeOf(builder, proto);
|
|
3327
|
+
builder._generator = self;
|
|
3328
|
+
builder._styler = _styler;
|
|
3329
|
+
builder._isEmpty = _isEmpty;
|
|
3330
|
+
return builder;
|
|
3331
|
+
};
|
|
3332
|
+
var applyStyle = (self, string) => {
|
|
3333
|
+
if (self.level <= 0 || !string) {
|
|
3334
|
+
return self._isEmpty ? "" : string;
|
|
3335
|
+
}
|
|
3336
|
+
let styler = self._styler;
|
|
3337
|
+
if (styler === undefined) {
|
|
3338
|
+
return string;
|
|
3339
|
+
}
|
|
3340
|
+
const { openAll, closeAll } = styler;
|
|
3341
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
3342
|
+
while (styler !== undefined) {
|
|
3343
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
3344
|
+
styler = styler.parent;
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
const lfIndex = string.indexOf(`
|
|
3348
|
+
`);
|
|
3349
|
+
if (lfIndex !== -1) {
|
|
3350
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
3351
|
+
}
|
|
3352
|
+
return openAll + string + closeAll;
|
|
3353
|
+
};
|
|
3354
|
+
var template;
|
|
3355
|
+
var chalkTag = (chalk2, ...strings) => {
|
|
3356
|
+
const [firstString] = strings;
|
|
3357
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
3358
|
+
return strings.join(" ");
|
|
3359
|
+
}
|
|
3360
|
+
const arguments_ = strings.slice(1);
|
|
3361
|
+
const parts = [firstString.raw[0]];
|
|
3362
|
+
for (let i = 1;i < firstString.length; i++) {
|
|
3363
|
+
parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
|
|
3364
|
+
}
|
|
3365
|
+
if (template === undefined) {
|
|
3366
|
+
template = require_templates();
|
|
3367
|
+
}
|
|
3368
|
+
return template(chalk2, parts.join(""));
|
|
3369
|
+
};
|
|
3370
|
+
Object.defineProperties(Chalk.prototype, styles);
|
|
3371
|
+
var chalk = Chalk();
|
|
3372
|
+
chalk.supportsColor = stdoutColor;
|
|
3373
|
+
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
3374
|
+
chalk.stderr.supportsColor = stderrColor;
|
|
3375
|
+
module.exports = chalk;
|
|
3376
|
+
});
|
|
3377
|
+
|
|
2056
3378
|
// ../../node_modules/commander/esm.mjs
|
|
2057
3379
|
var import__ = __toESM(require_commander(), 1);
|
|
2058
3380
|
var {
|
|
@@ -2081,28 +3403,23 @@ import path from "node:path";
|
|
|
2081
3403
|
var ENV_API_URL = process.env.THOUGHTFUL_API_URL;
|
|
2082
3404
|
var ENV_NO_COLOR = process.env.THOUGHTFUL_NO_COLOR === "1" || process.env.THOUGHTFUL_NO_COLOR === "true";
|
|
2083
3405
|
var ENV_DEBUG = process.env.THOUGHTFUL_DEBUG === "1" || process.env.THOUGHTFUL_DEBUG === "true";
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
return true;
|
|
2087
|
-
}
|
|
2088
|
-
const currentFile = new URL(import.meta.url).pathname;
|
|
2089
|
-
return currentFile.includes("/src/");
|
|
2090
|
-
}
|
|
3406
|
+
var PRODUCTION_API_URL = "https://www.tokatsu.ai";
|
|
3407
|
+
var DEVELOPMENT_API_URL = "http://localhost:3000";
|
|
2091
3408
|
var environmentOverride = null;
|
|
2092
3409
|
function setEnvironmentOverride(env) {
|
|
2093
3410
|
environmentOverride = env;
|
|
2094
3411
|
}
|
|
2095
3412
|
function getDefaultApiUrl() {
|
|
2096
3413
|
if (environmentOverride === "dev") {
|
|
2097
|
-
return
|
|
3414
|
+
return DEVELOPMENT_API_URL;
|
|
2098
3415
|
}
|
|
2099
3416
|
if (environmentOverride === "prod") {
|
|
2100
|
-
return
|
|
3417
|
+
return PRODUCTION_API_URL;
|
|
2101
3418
|
}
|
|
2102
3419
|
if (ENV_API_URL) {
|
|
2103
3420
|
return ENV_API_URL;
|
|
2104
3421
|
}
|
|
2105
|
-
return
|
|
3422
|
+
return PRODUCTION_API_URL;
|
|
2106
3423
|
}
|
|
2107
3424
|
function getXdgConfigHome() {
|
|
2108
3425
|
return process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
@@ -2142,7 +3459,6 @@ function ensureConfigDir() {
|
|
|
2142
3459
|
}
|
|
2143
3460
|
function loadConfig() {
|
|
2144
3461
|
ensureConfigDir();
|
|
2145
|
-
const smartDefault = isDevelopmentMode() ? "http://localhost:3000" : "https://www.tokatsu.ai";
|
|
2146
3462
|
if (!fs.existsSync(CONFIG_FILE)) {
|
|
2147
3463
|
return {
|
|
2148
3464
|
apiUrl: getDefaultApiUrl()
|
|
@@ -2152,7 +3468,7 @@ function loadConfig() {
|
|
|
2152
3468
|
const content = fs.readFileSync(CONFIG_FILE, "utf-8");
|
|
2153
3469
|
const fileConfig = JSON.parse(content);
|
|
2154
3470
|
const config = {
|
|
2155
|
-
apiUrl:
|
|
3471
|
+
apiUrl: PRODUCTION_API_URL,
|
|
2156
3472
|
...fileConfig
|
|
2157
3473
|
};
|
|
2158
3474
|
if (environmentOverride || ENV_API_URL) {
|
|
@@ -2204,496 +3520,8 @@ function isLoggedIn() {
|
|
|
2204
3520
|
return Boolean(config.accessToken);
|
|
2205
3521
|
}
|
|
2206
3522
|
|
|
2207
|
-
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
2208
|
-
var ANSI_BACKGROUND_OFFSET = 10;
|
|
2209
|
-
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
2210
|
-
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
2211
|
-
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
2212
|
-
var styles = {
|
|
2213
|
-
modifier: {
|
|
2214
|
-
reset: [0, 0],
|
|
2215
|
-
bold: [1, 22],
|
|
2216
|
-
dim: [2, 22],
|
|
2217
|
-
italic: [3, 23],
|
|
2218
|
-
underline: [4, 24],
|
|
2219
|
-
overline: [53, 55],
|
|
2220
|
-
inverse: [7, 27],
|
|
2221
|
-
hidden: [8, 28],
|
|
2222
|
-
strikethrough: [9, 29]
|
|
2223
|
-
},
|
|
2224
|
-
color: {
|
|
2225
|
-
black: [30, 39],
|
|
2226
|
-
red: [31, 39],
|
|
2227
|
-
green: [32, 39],
|
|
2228
|
-
yellow: [33, 39],
|
|
2229
|
-
blue: [34, 39],
|
|
2230
|
-
magenta: [35, 39],
|
|
2231
|
-
cyan: [36, 39],
|
|
2232
|
-
white: [37, 39],
|
|
2233
|
-
blackBright: [90, 39],
|
|
2234
|
-
gray: [90, 39],
|
|
2235
|
-
grey: [90, 39],
|
|
2236
|
-
redBright: [91, 39],
|
|
2237
|
-
greenBright: [92, 39],
|
|
2238
|
-
yellowBright: [93, 39],
|
|
2239
|
-
blueBright: [94, 39],
|
|
2240
|
-
magentaBright: [95, 39],
|
|
2241
|
-
cyanBright: [96, 39],
|
|
2242
|
-
whiteBright: [97, 39]
|
|
2243
|
-
},
|
|
2244
|
-
bgColor: {
|
|
2245
|
-
bgBlack: [40, 49],
|
|
2246
|
-
bgRed: [41, 49],
|
|
2247
|
-
bgGreen: [42, 49],
|
|
2248
|
-
bgYellow: [43, 49],
|
|
2249
|
-
bgBlue: [44, 49],
|
|
2250
|
-
bgMagenta: [45, 49],
|
|
2251
|
-
bgCyan: [46, 49],
|
|
2252
|
-
bgWhite: [47, 49],
|
|
2253
|
-
bgBlackBright: [100, 49],
|
|
2254
|
-
bgGray: [100, 49],
|
|
2255
|
-
bgGrey: [100, 49],
|
|
2256
|
-
bgRedBright: [101, 49],
|
|
2257
|
-
bgGreenBright: [102, 49],
|
|
2258
|
-
bgYellowBright: [103, 49],
|
|
2259
|
-
bgBlueBright: [104, 49],
|
|
2260
|
-
bgMagentaBright: [105, 49],
|
|
2261
|
-
bgCyanBright: [106, 49],
|
|
2262
|
-
bgWhiteBright: [107, 49]
|
|
2263
|
-
}
|
|
2264
|
-
};
|
|
2265
|
-
var modifierNames = Object.keys(styles.modifier);
|
|
2266
|
-
var foregroundColorNames = Object.keys(styles.color);
|
|
2267
|
-
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
2268
|
-
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
2269
|
-
function assembleStyles() {
|
|
2270
|
-
const codes = new Map;
|
|
2271
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
|
2272
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
2273
|
-
styles[styleName] = {
|
|
2274
|
-
open: `\x1B[${style[0]}m`,
|
|
2275
|
-
close: `\x1B[${style[1]}m`
|
|
2276
|
-
};
|
|
2277
|
-
group[styleName] = styles[styleName];
|
|
2278
|
-
codes.set(style[0], style[1]);
|
|
2279
|
-
}
|
|
2280
|
-
Object.defineProperty(styles, groupName, {
|
|
2281
|
-
value: group,
|
|
2282
|
-
enumerable: false
|
|
2283
|
-
});
|
|
2284
|
-
}
|
|
2285
|
-
Object.defineProperty(styles, "codes", {
|
|
2286
|
-
value: codes,
|
|
2287
|
-
enumerable: false
|
|
2288
|
-
});
|
|
2289
|
-
styles.color.close = "\x1B[39m";
|
|
2290
|
-
styles.bgColor.close = "\x1B[49m";
|
|
2291
|
-
styles.color.ansi = wrapAnsi16();
|
|
2292
|
-
styles.color.ansi256 = wrapAnsi256();
|
|
2293
|
-
styles.color.ansi16m = wrapAnsi16m();
|
|
2294
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
2295
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
2296
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
2297
|
-
Object.defineProperties(styles, {
|
|
2298
|
-
rgbToAnsi256: {
|
|
2299
|
-
value(red, green, blue) {
|
|
2300
|
-
if (red === green && green === blue) {
|
|
2301
|
-
if (red < 8) {
|
|
2302
|
-
return 16;
|
|
2303
|
-
}
|
|
2304
|
-
if (red > 248) {
|
|
2305
|
-
return 231;
|
|
2306
|
-
}
|
|
2307
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
2308
|
-
}
|
|
2309
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
2310
|
-
},
|
|
2311
|
-
enumerable: false
|
|
2312
|
-
},
|
|
2313
|
-
hexToRgb: {
|
|
2314
|
-
value(hex) {
|
|
2315
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
2316
|
-
if (!matches) {
|
|
2317
|
-
return [0, 0, 0];
|
|
2318
|
-
}
|
|
2319
|
-
let [colorString] = matches;
|
|
2320
|
-
if (colorString.length === 3) {
|
|
2321
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
2322
|
-
}
|
|
2323
|
-
const integer = Number.parseInt(colorString, 16);
|
|
2324
|
-
return [
|
|
2325
|
-
integer >> 16 & 255,
|
|
2326
|
-
integer >> 8 & 255,
|
|
2327
|
-
integer & 255
|
|
2328
|
-
];
|
|
2329
|
-
},
|
|
2330
|
-
enumerable: false
|
|
2331
|
-
},
|
|
2332
|
-
hexToAnsi256: {
|
|
2333
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
2334
|
-
enumerable: false
|
|
2335
|
-
},
|
|
2336
|
-
ansi256ToAnsi: {
|
|
2337
|
-
value(code) {
|
|
2338
|
-
if (code < 8) {
|
|
2339
|
-
return 30 + code;
|
|
2340
|
-
}
|
|
2341
|
-
if (code < 16) {
|
|
2342
|
-
return 90 + (code - 8);
|
|
2343
|
-
}
|
|
2344
|
-
let red;
|
|
2345
|
-
let green;
|
|
2346
|
-
let blue;
|
|
2347
|
-
if (code >= 232) {
|
|
2348
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
2349
|
-
green = red;
|
|
2350
|
-
blue = red;
|
|
2351
|
-
} else {
|
|
2352
|
-
code -= 16;
|
|
2353
|
-
const remainder = code % 36;
|
|
2354
|
-
red = Math.floor(code / 36) / 5;
|
|
2355
|
-
green = Math.floor(remainder / 6) / 5;
|
|
2356
|
-
blue = remainder % 6 / 5;
|
|
2357
|
-
}
|
|
2358
|
-
const value = Math.max(red, green, blue) * 2;
|
|
2359
|
-
if (value === 0) {
|
|
2360
|
-
return 30;
|
|
2361
|
-
}
|
|
2362
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
2363
|
-
if (value === 2) {
|
|
2364
|
-
result += 60;
|
|
2365
|
-
}
|
|
2366
|
-
return result;
|
|
2367
|
-
},
|
|
2368
|
-
enumerable: false
|
|
2369
|
-
},
|
|
2370
|
-
rgbToAnsi: {
|
|
2371
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
2372
|
-
enumerable: false
|
|
2373
|
-
},
|
|
2374
|
-
hexToAnsi: {
|
|
2375
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
2376
|
-
enumerable: false
|
|
2377
|
-
}
|
|
2378
|
-
});
|
|
2379
|
-
return styles;
|
|
2380
|
-
}
|
|
2381
|
-
var ansiStyles = assembleStyles();
|
|
2382
|
-
var ansi_styles_default = ansiStyles;
|
|
2383
|
-
|
|
2384
|
-
// ../../node_modules/chalk/source/vendor/supports-color/index.js
|
|
2385
|
-
import process2 from "node:process";
|
|
2386
|
-
import os2 from "node:os";
|
|
2387
|
-
import tty from "node:tty";
|
|
2388
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
|
|
2389
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
2390
|
-
const position = argv.indexOf(prefix + flag);
|
|
2391
|
-
const terminatorPosition = argv.indexOf("--");
|
|
2392
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2393
|
-
}
|
|
2394
|
-
var { env: env2 } = process2;
|
|
2395
|
-
var flagForceColor;
|
|
2396
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
2397
|
-
flagForceColor = 0;
|
|
2398
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
2399
|
-
flagForceColor = 1;
|
|
2400
|
-
}
|
|
2401
|
-
function envForceColor() {
|
|
2402
|
-
if ("FORCE_COLOR" in env2) {
|
|
2403
|
-
if (env2.FORCE_COLOR === "true") {
|
|
2404
|
-
return 1;
|
|
2405
|
-
}
|
|
2406
|
-
if (env2.FORCE_COLOR === "false") {
|
|
2407
|
-
return 0;
|
|
2408
|
-
}
|
|
2409
|
-
return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
|
-
function translateLevel(level) {
|
|
2413
|
-
if (level === 0) {
|
|
2414
|
-
return false;
|
|
2415
|
-
}
|
|
2416
|
-
return {
|
|
2417
|
-
level,
|
|
2418
|
-
hasBasic: true,
|
|
2419
|
-
has256: level >= 2,
|
|
2420
|
-
has16m: level >= 3
|
|
2421
|
-
};
|
|
2422
|
-
}
|
|
2423
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
2424
|
-
const noFlagForceColor = envForceColor();
|
|
2425
|
-
if (noFlagForceColor !== undefined) {
|
|
2426
|
-
flagForceColor = noFlagForceColor;
|
|
2427
|
-
}
|
|
2428
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
2429
|
-
if (forceColor === 0) {
|
|
2430
|
-
return 0;
|
|
2431
|
-
}
|
|
2432
|
-
if (sniffFlags) {
|
|
2433
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
2434
|
-
return 3;
|
|
2435
|
-
}
|
|
2436
|
-
if (hasFlag("color=256")) {
|
|
2437
|
-
return 2;
|
|
2438
|
-
}
|
|
2439
|
-
}
|
|
2440
|
-
if ("TF_BUILD" in env2 && "AGENT_NAME" in env2) {
|
|
2441
|
-
return 1;
|
|
2442
|
-
}
|
|
2443
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
2444
|
-
return 0;
|
|
2445
|
-
}
|
|
2446
|
-
const min = forceColor || 0;
|
|
2447
|
-
if (env2.TERM === "dumb") {
|
|
2448
|
-
return min;
|
|
2449
|
-
}
|
|
2450
|
-
if (process2.platform === "win32") {
|
|
2451
|
-
const osRelease = os2.release().split(".");
|
|
2452
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
2453
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
2454
|
-
}
|
|
2455
|
-
return 1;
|
|
2456
|
-
}
|
|
2457
|
-
if ("CI" in env2) {
|
|
2458
|
-
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env2))) {
|
|
2459
|
-
return 3;
|
|
2460
|
-
}
|
|
2461
|
-
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env2)) || env2.CI_NAME === "codeship") {
|
|
2462
|
-
return 1;
|
|
2463
|
-
}
|
|
2464
|
-
return min;
|
|
2465
|
-
}
|
|
2466
|
-
if ("TEAMCITY_VERSION" in env2) {
|
|
2467
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
|
|
2468
|
-
}
|
|
2469
|
-
if (env2.COLORTERM === "truecolor") {
|
|
2470
|
-
return 3;
|
|
2471
|
-
}
|
|
2472
|
-
if (env2.TERM === "xterm-kitty") {
|
|
2473
|
-
return 3;
|
|
2474
|
-
}
|
|
2475
|
-
if (env2.TERM === "xterm-ghostty") {
|
|
2476
|
-
return 3;
|
|
2477
|
-
}
|
|
2478
|
-
if (env2.TERM === "wezterm") {
|
|
2479
|
-
return 3;
|
|
2480
|
-
}
|
|
2481
|
-
if ("TERM_PROGRAM" in env2) {
|
|
2482
|
-
const version = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
2483
|
-
switch (env2.TERM_PROGRAM) {
|
|
2484
|
-
case "iTerm.app": {
|
|
2485
|
-
return version >= 3 ? 3 : 2;
|
|
2486
|
-
}
|
|
2487
|
-
case "Apple_Terminal": {
|
|
2488
|
-
return 2;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
}
|
|
2492
|
-
if (/-256(color)?$/i.test(env2.TERM)) {
|
|
2493
|
-
return 2;
|
|
2494
|
-
}
|
|
2495
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
|
|
2496
|
-
return 1;
|
|
2497
|
-
}
|
|
2498
|
-
if ("COLORTERM" in env2) {
|
|
2499
|
-
return 1;
|
|
2500
|
-
}
|
|
2501
|
-
return min;
|
|
2502
|
-
}
|
|
2503
|
-
function createSupportsColor(stream, options = {}) {
|
|
2504
|
-
const level = _supportsColor(stream, {
|
|
2505
|
-
streamIsTTY: stream && stream.isTTY,
|
|
2506
|
-
...options
|
|
2507
|
-
});
|
|
2508
|
-
return translateLevel(level);
|
|
2509
|
-
}
|
|
2510
|
-
var supportsColor = {
|
|
2511
|
-
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
2512
|
-
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
2513
|
-
};
|
|
2514
|
-
var supports_color_default = supportsColor;
|
|
2515
|
-
|
|
2516
|
-
// ../../node_modules/chalk/source/utilities.js
|
|
2517
|
-
function stringReplaceAll(string, substring, replacer) {
|
|
2518
|
-
let index = string.indexOf(substring);
|
|
2519
|
-
if (index === -1) {
|
|
2520
|
-
return string;
|
|
2521
|
-
}
|
|
2522
|
-
const substringLength = substring.length;
|
|
2523
|
-
let endIndex = 0;
|
|
2524
|
-
let returnValue = "";
|
|
2525
|
-
do {
|
|
2526
|
-
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
2527
|
-
endIndex = index + substringLength;
|
|
2528
|
-
index = string.indexOf(substring, endIndex);
|
|
2529
|
-
} while (index !== -1);
|
|
2530
|
-
returnValue += string.slice(endIndex);
|
|
2531
|
-
return returnValue;
|
|
2532
|
-
}
|
|
2533
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
2534
|
-
let endIndex = 0;
|
|
2535
|
-
let returnValue = "";
|
|
2536
|
-
do {
|
|
2537
|
-
const gotCR = string[index - 1] === "\r";
|
|
2538
|
-
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
|
|
2539
|
-
` : `
|
|
2540
|
-
`) + postfix;
|
|
2541
|
-
endIndex = index + 1;
|
|
2542
|
-
index = string.indexOf(`
|
|
2543
|
-
`, endIndex);
|
|
2544
|
-
} while (index !== -1);
|
|
2545
|
-
returnValue += string.slice(endIndex);
|
|
2546
|
-
return returnValue;
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
// ../../node_modules/chalk/source/index.js
|
|
2550
|
-
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
2551
|
-
var GENERATOR = Symbol("GENERATOR");
|
|
2552
|
-
var STYLER = Symbol("STYLER");
|
|
2553
|
-
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
2554
|
-
var levelMapping = [
|
|
2555
|
-
"ansi",
|
|
2556
|
-
"ansi",
|
|
2557
|
-
"ansi256",
|
|
2558
|
-
"ansi16m"
|
|
2559
|
-
];
|
|
2560
|
-
var styles2 = Object.create(null);
|
|
2561
|
-
var applyOptions = (object, options = {}) => {
|
|
2562
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
2563
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
2564
|
-
}
|
|
2565
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
2566
|
-
object.level = options.level === undefined ? colorLevel : options.level;
|
|
2567
|
-
};
|
|
2568
|
-
var chalkFactory = (options) => {
|
|
2569
|
-
const chalk = (...strings) => strings.join(" ");
|
|
2570
|
-
applyOptions(chalk, options);
|
|
2571
|
-
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
2572
|
-
return chalk;
|
|
2573
|
-
};
|
|
2574
|
-
function createChalk(options) {
|
|
2575
|
-
return chalkFactory(options);
|
|
2576
|
-
}
|
|
2577
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
2578
|
-
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
2579
|
-
styles2[styleName] = {
|
|
2580
|
-
get() {
|
|
2581
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
2582
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
2583
|
-
return builder;
|
|
2584
|
-
}
|
|
2585
|
-
};
|
|
2586
|
-
}
|
|
2587
|
-
styles2.visible = {
|
|
2588
|
-
get() {
|
|
2589
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
2590
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
2591
|
-
return builder;
|
|
2592
|
-
}
|
|
2593
|
-
};
|
|
2594
|
-
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
2595
|
-
if (model === "rgb") {
|
|
2596
|
-
if (level === "ansi16m") {
|
|
2597
|
-
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
2598
|
-
}
|
|
2599
|
-
if (level === "ansi256") {
|
|
2600
|
-
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
2601
|
-
}
|
|
2602
|
-
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
2603
|
-
}
|
|
2604
|
-
if (model === "hex") {
|
|
2605
|
-
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
2606
|
-
}
|
|
2607
|
-
return ansi_styles_default[type][model](...arguments_);
|
|
2608
|
-
};
|
|
2609
|
-
var usedModels = ["rgb", "hex", "ansi256"];
|
|
2610
|
-
for (const model of usedModels) {
|
|
2611
|
-
styles2[model] = {
|
|
2612
|
-
get() {
|
|
2613
|
-
const { level } = this;
|
|
2614
|
-
return function(...arguments_) {
|
|
2615
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
2616
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
2617
|
-
};
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
2621
|
-
styles2[bgModel] = {
|
|
2622
|
-
get() {
|
|
2623
|
-
const { level } = this;
|
|
2624
|
-
return function(...arguments_) {
|
|
2625
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
2626
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
2627
|
-
};
|
|
2628
|
-
}
|
|
2629
|
-
};
|
|
2630
|
-
}
|
|
2631
|
-
var proto = Object.defineProperties(() => {}, {
|
|
2632
|
-
...styles2,
|
|
2633
|
-
level: {
|
|
2634
|
-
enumerable: true,
|
|
2635
|
-
get() {
|
|
2636
|
-
return this[GENERATOR].level;
|
|
2637
|
-
},
|
|
2638
|
-
set(level) {
|
|
2639
|
-
this[GENERATOR].level = level;
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
});
|
|
2643
|
-
var createStyler = (open, close, parent) => {
|
|
2644
|
-
let openAll;
|
|
2645
|
-
let closeAll;
|
|
2646
|
-
if (parent === undefined) {
|
|
2647
|
-
openAll = open;
|
|
2648
|
-
closeAll = close;
|
|
2649
|
-
} else {
|
|
2650
|
-
openAll = parent.openAll + open;
|
|
2651
|
-
closeAll = close + parent.closeAll;
|
|
2652
|
-
}
|
|
2653
|
-
return {
|
|
2654
|
-
open,
|
|
2655
|
-
close,
|
|
2656
|
-
openAll,
|
|
2657
|
-
closeAll,
|
|
2658
|
-
parent
|
|
2659
|
-
};
|
|
2660
|
-
};
|
|
2661
|
-
var createBuilder = (self, _styler, _isEmpty) => {
|
|
2662
|
-
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
2663
|
-
Object.setPrototypeOf(builder, proto);
|
|
2664
|
-
builder[GENERATOR] = self;
|
|
2665
|
-
builder[STYLER] = _styler;
|
|
2666
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
2667
|
-
return builder;
|
|
2668
|
-
};
|
|
2669
|
-
var applyStyle = (self, string) => {
|
|
2670
|
-
if (self.level <= 0 || !string) {
|
|
2671
|
-
return self[IS_EMPTY] ? "" : string;
|
|
2672
|
-
}
|
|
2673
|
-
let styler = self[STYLER];
|
|
2674
|
-
if (styler === undefined) {
|
|
2675
|
-
return string;
|
|
2676
|
-
}
|
|
2677
|
-
const { openAll, closeAll } = styler;
|
|
2678
|
-
if (string.includes("\x1B")) {
|
|
2679
|
-
while (styler !== undefined) {
|
|
2680
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
2681
|
-
styler = styler.parent;
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
const lfIndex = string.indexOf(`
|
|
2685
|
-
`);
|
|
2686
|
-
if (lfIndex !== -1) {
|
|
2687
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
2688
|
-
}
|
|
2689
|
-
return openAll + string + closeAll;
|
|
2690
|
-
};
|
|
2691
|
-
Object.defineProperties(createChalk.prototype, styles2);
|
|
2692
|
-
var chalk = createChalk();
|
|
2693
|
-
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2694
|
-
var source_default = chalk;
|
|
2695
|
-
|
|
2696
3523
|
// src/output.ts
|
|
3524
|
+
var import_chalk = __toESM(require_source(), 1);
|
|
2697
3525
|
var globalOptions = {};
|
|
2698
3526
|
function setGlobalOptions(options) {
|
|
2699
3527
|
globalOptions = { ...options };
|
|
@@ -2723,13 +3551,13 @@ function shouldDisableColors() {
|
|
|
2723
3551
|
return false;
|
|
2724
3552
|
}
|
|
2725
3553
|
var c = {
|
|
2726
|
-
blue: (text) => shouldDisableColors() ? text :
|
|
2727
|
-
green: (text) => shouldDisableColors() ? text :
|
|
2728
|
-
yellow: (text) => shouldDisableColors() ? text :
|
|
2729
|
-
red: (text) => shouldDisableColors() ? text :
|
|
2730
|
-
gray: (text) => shouldDisableColors() ? text :
|
|
2731
|
-
white: (text) => shouldDisableColors() ? text :
|
|
2732
|
-
cyan: (text) => shouldDisableColors() ? text :
|
|
3554
|
+
blue: (text) => shouldDisableColors() ? text : import_chalk.default.blue(text),
|
|
3555
|
+
green: (text) => shouldDisableColors() ? text : import_chalk.default.green(text),
|
|
3556
|
+
yellow: (text) => shouldDisableColors() ? text : import_chalk.default.yellow(text),
|
|
3557
|
+
red: (text) => shouldDisableColors() ? text : import_chalk.default.red(text),
|
|
3558
|
+
gray: (text) => shouldDisableColors() ? text : import_chalk.default.gray(text),
|
|
3559
|
+
white: (text) => shouldDisableColors() ? text : import_chalk.default.white(text),
|
|
3560
|
+
cyan: (text) => shouldDisableColors() ? text : import_chalk.default.cyan(text)
|
|
2733
3561
|
};
|
|
2734
3562
|
function isQuiet() {
|
|
2735
3563
|
return Boolean(globalOptions.quiet);
|
|
@@ -3290,6 +4118,7 @@ Examples:
|
|
|
3290
4118
|
}
|
|
3291
4119
|
|
|
3292
4120
|
// src/commands/orgs.ts
|
|
4121
|
+
var import_chalk2 = __toESM(require_source(), 1);
|
|
3293
4122
|
function registerOrgsCommands(program2) {
|
|
3294
4123
|
const orgs = program2.command("orgs").description("Manage organizations").addHelpText("after", `
|
|
3295
4124
|
Examples:
|
|
@@ -3315,7 +4144,7 @@ Examples:
|
|
|
3315
4144
|
if (json) {
|
|
3316
4145
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3317
4146
|
} else {
|
|
3318
|
-
console.log(
|
|
4147
|
+
console.log(import_chalk2.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3319
4148
|
}
|
|
3320
4149
|
process.exit(1);
|
|
3321
4150
|
}
|
|
@@ -3331,22 +4160,22 @@ Examples:
|
|
|
3331
4160
|
}))
|
|
3332
4161
|
}));
|
|
3333
4162
|
} else {
|
|
3334
|
-
console.log(
|
|
4163
|
+
console.log(import_chalk2.default.blue("Organizations"));
|
|
3335
4164
|
console.log();
|
|
3336
4165
|
if (data.memberships.length === 0) {
|
|
3337
|
-
console.log(
|
|
4166
|
+
console.log(import_chalk2.default.gray(" No organizations found"));
|
|
3338
4167
|
return;
|
|
3339
4168
|
}
|
|
3340
4169
|
for (const m of data.memberships) {
|
|
3341
4170
|
const isActive = m.id === data.activeMembershipId;
|
|
3342
|
-
const marker = isActive ?
|
|
3343
|
-
const name = isActive ?
|
|
3344
|
-
const domain = m.organizationDomain ?
|
|
4171
|
+
const marker = isActive ? import_chalk2.default.green("*") : " ";
|
|
4172
|
+
const name = isActive ? import_chalk2.default.white(m.organizationName) : import_chalk2.default.gray(m.organizationName);
|
|
4173
|
+
const domain = m.organizationDomain ? import_chalk2.default.gray(` (${m.organizationDomain})`) : "";
|
|
3345
4174
|
console.log(` ${marker} ${name}${domain}`);
|
|
3346
|
-
console.log(
|
|
4175
|
+
console.log(import_chalk2.default.gray(` ID: ${m.organizationId}`));
|
|
3347
4176
|
}
|
|
3348
4177
|
console.log();
|
|
3349
|
-
console.log(
|
|
4178
|
+
console.log(import_chalk2.default.gray("* = active organization"));
|
|
3350
4179
|
}
|
|
3351
4180
|
} catch (error) {
|
|
3352
4181
|
handleApiError(error);
|
|
@@ -3367,7 +4196,7 @@ Examples:
|
|
|
3367
4196
|
if (json) {
|
|
3368
4197
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3369
4198
|
} else {
|
|
3370
|
-
console.log(
|
|
4199
|
+
console.log(import_chalk2.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3371
4200
|
}
|
|
3372
4201
|
process.exit(1);
|
|
3373
4202
|
}
|
|
@@ -3401,8 +4230,8 @@ Examples:
|
|
|
3401
4230
|
}
|
|
3402
4231
|
}));
|
|
3403
4232
|
} else {
|
|
3404
|
-
console.log(
|
|
3405
|
-
console.log(
|
|
4233
|
+
console.log(import_chalk2.default.green(`Switched to organization: ${membership.organizationName}`));
|
|
4234
|
+
console.log(import_chalk2.default.gray(`Workspace: ${result.workspace.name}`));
|
|
3406
4235
|
}
|
|
3407
4236
|
} catch (error) {
|
|
3408
4237
|
handleApiError(error);
|
|
@@ -3411,6 +4240,7 @@ Examples:
|
|
|
3411
4240
|
}
|
|
3412
4241
|
|
|
3413
4242
|
// src/commands/workspaces.ts
|
|
4243
|
+
var import_chalk3 = __toESM(require_source(), 1);
|
|
3414
4244
|
function registerWorkspacesCommands(program2) {
|
|
3415
4245
|
const workspaces = program2.command("workspaces").description("Manage workspaces").addHelpText("after", `
|
|
3416
4246
|
Examples:
|
|
@@ -3439,7 +4269,7 @@ Examples:
|
|
|
3439
4269
|
if (json) {
|
|
3440
4270
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3441
4271
|
} else {
|
|
3442
|
-
console.log(
|
|
4272
|
+
console.log(import_chalk3.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3443
4273
|
}
|
|
3444
4274
|
process.exit(1);
|
|
3445
4275
|
}
|
|
@@ -3455,24 +4285,24 @@ Examples:
|
|
|
3455
4285
|
}))
|
|
3456
4286
|
}));
|
|
3457
4287
|
} else {
|
|
3458
|
-
console.log(
|
|
4288
|
+
console.log(import_chalk3.default.blue("Workspaces"));
|
|
3459
4289
|
console.log();
|
|
3460
4290
|
if (data.workspaces.length === 0) {
|
|
3461
|
-
console.log(
|
|
4291
|
+
console.log(import_chalk3.default.gray(" No workspaces found"));
|
|
3462
4292
|
return;
|
|
3463
4293
|
}
|
|
3464
4294
|
for (const w of data.workspaces) {
|
|
3465
4295
|
const isActive = w.id === data.activeWorkspaceId;
|
|
3466
|
-
const marker = isActive ?
|
|
3467
|
-
const name = isActive ?
|
|
4296
|
+
const marker = isActive ? import_chalk3.default.green("*") : " ";
|
|
4297
|
+
const name = isActive ? import_chalk3.default.white(w.name) : import_chalk3.default.gray(w.name);
|
|
3468
4298
|
console.log(` ${marker} ${name}`);
|
|
3469
4299
|
if (w.description) {
|
|
3470
|
-
console.log(
|
|
4300
|
+
console.log(import_chalk3.default.gray(` ${w.description}`));
|
|
3471
4301
|
}
|
|
3472
|
-
console.log(
|
|
4302
|
+
console.log(import_chalk3.default.gray(` ID: ${w.id}`));
|
|
3473
4303
|
}
|
|
3474
4304
|
console.log();
|
|
3475
|
-
console.log(
|
|
4305
|
+
console.log(import_chalk3.default.gray("* = active workspace"));
|
|
3476
4306
|
}
|
|
3477
4307
|
} catch (error) {
|
|
3478
4308
|
handleApiError(error);
|
|
@@ -3492,7 +4322,7 @@ Examples:
|
|
|
3492
4322
|
if (json) {
|
|
3493
4323
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3494
4324
|
} else {
|
|
3495
|
-
console.log(
|
|
4325
|
+
console.log(import_chalk3.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3496
4326
|
}
|
|
3497
4327
|
process.exit(1);
|
|
3498
4328
|
}
|
|
@@ -3521,7 +4351,7 @@ Examples:
|
|
|
3521
4351
|
}
|
|
3522
4352
|
}));
|
|
3523
4353
|
} else {
|
|
3524
|
-
console.log(
|
|
4354
|
+
console.log(import_chalk3.default.green(`Switched to workspace: ${workspace.name}`));
|
|
3525
4355
|
}
|
|
3526
4356
|
} catch (error) {
|
|
3527
4357
|
handleApiError(error);
|
|
@@ -3543,7 +4373,7 @@ Examples:
|
|
|
3543
4373
|
if (json) {
|
|
3544
4374
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3545
4375
|
} else {
|
|
3546
|
-
console.log(
|
|
4376
|
+
console.log(import_chalk3.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3547
4377
|
}
|
|
3548
4378
|
process.exit(1);
|
|
3549
4379
|
}
|
|
@@ -3565,9 +4395,9 @@ Examples:
|
|
|
3565
4395
|
}
|
|
3566
4396
|
}));
|
|
3567
4397
|
} else {
|
|
3568
|
-
console.log(
|
|
3569
|
-
console.log(
|
|
3570
|
-
console.log(
|
|
4398
|
+
console.log(import_chalk3.default.green(`Created workspace: ${result.workspace.name}`));
|
|
4399
|
+
console.log(import_chalk3.default.gray(`ID: ${result.workspace.id}`));
|
|
4400
|
+
console.log(import_chalk3.default.gray("Switched to the new workspace."));
|
|
3571
4401
|
}
|
|
3572
4402
|
} catch (error) {
|
|
3573
4403
|
handleApiError(error);
|
|
@@ -3576,6 +4406,7 @@ Examples:
|
|
|
3576
4406
|
}
|
|
3577
4407
|
|
|
3578
4408
|
// src/commands/pages.ts
|
|
4409
|
+
var import_chalk4 = __toESM(require_source(), 1);
|
|
3579
4410
|
function buildTree(pages) {
|
|
3580
4411
|
const nodeMap = new Map;
|
|
3581
4412
|
const roots = [];
|
|
@@ -3602,10 +4433,10 @@ function printTree(nodes, prefix = "", isLast = true) {
|
|
|
3602
4433
|
const node = nodes[i];
|
|
3603
4434
|
const isLastNode = i === nodes.length - 1;
|
|
3604
4435
|
const connector = prefix === "" ? "" : isLastNode ? "└─ " : "├─ ";
|
|
3605
|
-
const status = node.status ?
|
|
3606
|
-
const owner = node.ownerName ?
|
|
3607
|
-
console.log(`${prefix}${connector}${
|
|
3608
|
-
console.log(`${prefix}${isLastNode ? " " : "│ "}${
|
|
4436
|
+
const status = node.status ? import_chalk4.default.gray(` [${node.status}]`) : "";
|
|
4437
|
+
const owner = node.ownerName ? import_chalk4.default.gray(` @${node.ownerName}`) : "";
|
|
4438
|
+
console.log(`${prefix}${connector}${import_chalk4.default.white(node.title)}${status}${owner}`);
|
|
4439
|
+
console.log(`${prefix}${isLastNode ? " " : "│ "}${import_chalk4.default.gray(node.slug)}`);
|
|
3609
4440
|
if (node.children.length > 0) {
|
|
3610
4441
|
const newPrefix = prefix + (isLastNode ? " " : "│ ");
|
|
3611
4442
|
printTree(node.children, newPrefix, isLastNode);
|
|
@@ -3650,7 +4481,7 @@ Examples:
|
|
|
3650
4481
|
if (json) {
|
|
3651
4482
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3652
4483
|
} else {
|
|
3653
|
-
console.log(
|
|
4484
|
+
console.log(import_chalk4.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3654
4485
|
}
|
|
3655
4486
|
process.exit(1);
|
|
3656
4487
|
}
|
|
@@ -3661,17 +4492,17 @@ Examples:
|
|
|
3661
4492
|
return;
|
|
3662
4493
|
}
|
|
3663
4494
|
if (data.pages.length === 0) {
|
|
3664
|
-
console.log(
|
|
4495
|
+
console.log(import_chalk4.default.gray("No pages found"));
|
|
3665
4496
|
return;
|
|
3666
4497
|
}
|
|
3667
|
-
console.log(
|
|
4498
|
+
console.log(import_chalk4.default.blue("Pages"));
|
|
3668
4499
|
console.log();
|
|
3669
4500
|
if (flat) {
|
|
3670
4501
|
for (const page of data.pages) {
|
|
3671
|
-
const status = page.status ?
|
|
3672
|
-
const owner = page.ownerName ?
|
|
3673
|
-
console.log(` ${
|
|
3674
|
-
console.log(` ${
|
|
4502
|
+
const status = page.status ? import_chalk4.default.gray(` [${page.status}]`) : "";
|
|
4503
|
+
const owner = page.ownerName ? import_chalk4.default.gray(` @${page.ownerName}`) : "";
|
|
4504
|
+
console.log(` ${import_chalk4.default.white(page.title)}${status}${owner}`);
|
|
4505
|
+
console.log(` ${import_chalk4.default.gray(page.slug)}`);
|
|
3675
4506
|
console.log();
|
|
3676
4507
|
}
|
|
3677
4508
|
} else {
|
|
@@ -3702,7 +4533,7 @@ Examples:
|
|
|
3702
4533
|
if (json) {
|
|
3703
4534
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3704
4535
|
} else {
|
|
3705
|
-
console.log(
|
|
4536
|
+
console.log(import_chalk4.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3706
4537
|
}
|
|
3707
4538
|
process.exit(1);
|
|
3708
4539
|
}
|
|
@@ -3713,24 +4544,24 @@ Examples:
|
|
|
3713
4544
|
return;
|
|
3714
4545
|
}
|
|
3715
4546
|
const page = data.page;
|
|
3716
|
-
console.log(
|
|
4547
|
+
console.log(import_chalk4.default.blue(page.title));
|
|
3717
4548
|
console.log();
|
|
3718
|
-
console.log(` ${
|
|
3719
|
-
console.log(` ${
|
|
4549
|
+
console.log(` ${import_chalk4.default.gray("Slug:")} ${page.slug}`);
|
|
4550
|
+
console.log(` ${import_chalk4.default.gray("ID:")} ${page.id}`);
|
|
3720
4551
|
if (page.status) {
|
|
3721
|
-
console.log(` ${
|
|
4552
|
+
console.log(` ${import_chalk4.default.gray("Status:")} ${page.status}`);
|
|
3722
4553
|
}
|
|
3723
4554
|
if (page.ownerName) {
|
|
3724
|
-
console.log(` ${
|
|
4555
|
+
console.log(` ${import_chalk4.default.gray("Owner:")} ${page.ownerName}`);
|
|
3725
4556
|
}
|
|
3726
4557
|
if (page.parentSlug) {
|
|
3727
|
-
console.log(` ${
|
|
4558
|
+
console.log(` ${import_chalk4.default.gray("Parent:")} ${page.parentSlug}`);
|
|
3728
4559
|
}
|
|
3729
|
-
console.log(` ${
|
|
3730
|
-
console.log(` ${
|
|
4560
|
+
console.log(` ${import_chalk4.default.gray("Created:")} ${new Date(page.createdAt).toLocaleString()}`);
|
|
4561
|
+
console.log(` ${import_chalk4.default.gray("Updated:")} ${new Date(page.updatedAt).toLocaleString()}`);
|
|
3731
4562
|
if (page.description) {
|
|
3732
4563
|
console.log();
|
|
3733
|
-
console.log(
|
|
4564
|
+
console.log(import_chalk4.default.gray("Description:"));
|
|
3734
4565
|
console.log(page.description);
|
|
3735
4566
|
}
|
|
3736
4567
|
} catch (error) {
|
|
@@ -3760,7 +4591,7 @@ Examples:
|
|
|
3760
4591
|
if (json) {
|
|
3761
4592
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3762
4593
|
} else {
|
|
3763
|
-
console.log(
|
|
4594
|
+
console.log(import_chalk4.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3764
4595
|
}
|
|
3765
4596
|
process.exit(1);
|
|
3766
4597
|
}
|
|
@@ -3789,8 +4620,8 @@ Examples:
|
|
|
3789
4620
|
if (json) {
|
|
3790
4621
|
console.log(JSON.stringify({ success: true, page: data.page }));
|
|
3791
4622
|
} else {
|
|
3792
|
-
console.log(
|
|
3793
|
-
console.log(
|
|
4623
|
+
console.log(import_chalk4.default.green(`Created page: ${data.page.title}`));
|
|
4624
|
+
console.log(import_chalk4.default.gray(`Slug: ${data.page.slug}`));
|
|
3794
4625
|
}
|
|
3795
4626
|
} catch (error) {
|
|
3796
4627
|
handleApiError(error);
|
|
@@ -3820,7 +4651,7 @@ Examples:
|
|
|
3820
4651
|
if (json) {
|
|
3821
4652
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3822
4653
|
} else {
|
|
3823
|
-
console.log(
|
|
4654
|
+
console.log(import_chalk4.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3824
4655
|
}
|
|
3825
4656
|
process.exit(1);
|
|
3826
4657
|
}
|
|
@@ -3843,12 +4674,12 @@ Examples:
|
|
|
3843
4674
|
message: "No changes made (dry run)"
|
|
3844
4675
|
}));
|
|
3845
4676
|
} else {
|
|
3846
|
-
console.log(
|
|
4677
|
+
console.log(import_chalk4.default.blue("Dry run mode - no changes will be made"));
|
|
3847
4678
|
console.log();
|
|
3848
|
-
console.log(
|
|
3849
|
-
console.log(
|
|
4679
|
+
console.log(import_chalk4.default.gray(`Page: ${slug}`));
|
|
4680
|
+
console.log(import_chalk4.default.gray("Updates:"));
|
|
3850
4681
|
for (const [key, value] of Object.entries(updates)) {
|
|
3851
|
-
console.log(` ${
|
|
4682
|
+
console.log(` ${import_chalk4.default.gray(`${key}:`)} ${value}`);
|
|
3852
4683
|
}
|
|
3853
4684
|
}
|
|
3854
4685
|
return;
|
|
@@ -3858,7 +4689,7 @@ Examples:
|
|
|
3858
4689
|
if (json) {
|
|
3859
4690
|
console.log(JSON.stringify({ success: true, page: data.page }));
|
|
3860
4691
|
} else {
|
|
3861
|
-
console.log(
|
|
4692
|
+
console.log(import_chalk4.default.green(`Updated page: ${data.page.title}`));
|
|
3862
4693
|
}
|
|
3863
4694
|
} catch (error) {
|
|
3864
4695
|
handleApiError(error);
|
|
@@ -3888,7 +4719,7 @@ Examples:
|
|
|
3888
4719
|
if (json) {
|
|
3889
4720
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3890
4721
|
} else {
|
|
3891
|
-
console.log(
|
|
4722
|
+
console.log(import_chalk4.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3892
4723
|
}
|
|
3893
4724
|
process.exit(1);
|
|
3894
4725
|
}
|
|
@@ -3900,9 +4731,9 @@ Examples:
|
|
|
3900
4731
|
message: "No changes made (dry run)"
|
|
3901
4732
|
}));
|
|
3902
4733
|
} else {
|
|
3903
|
-
console.log(
|
|
4734
|
+
console.log(import_chalk4.default.blue("Dry run mode - no changes will be made"));
|
|
3904
4735
|
console.log();
|
|
3905
|
-
console.log(
|
|
4736
|
+
console.log(import_chalk4.default.gray(`Would delete page: ${slug}`));
|
|
3906
4737
|
}
|
|
3907
4738
|
return;
|
|
3908
4739
|
}
|
|
@@ -3910,7 +4741,7 @@ Examples:
|
|
|
3910
4741
|
try {
|
|
3911
4742
|
const shouldDelete = await confirm(`Are you sure you want to delete '${slug}'?`, { defaultValue: false });
|
|
3912
4743
|
if (!shouldDelete) {
|
|
3913
|
-
console.log(
|
|
4744
|
+
console.log(import_chalk4.default.yellow("Cancelled"));
|
|
3914
4745
|
return;
|
|
3915
4746
|
}
|
|
3916
4747
|
} catch (error) {
|
|
@@ -3925,7 +4756,7 @@ Examples:
|
|
|
3925
4756
|
if (json) {
|
|
3926
4757
|
console.log(JSON.stringify({ success: true }));
|
|
3927
4758
|
} else {
|
|
3928
|
-
console.log(
|
|
4759
|
+
console.log(import_chalk4.default.green(`Deleted page: ${slug}`));
|
|
3929
4760
|
}
|
|
3930
4761
|
} catch (error) {
|
|
3931
4762
|
handleApiError(error);
|
|
@@ -3951,7 +4782,7 @@ Examples:
|
|
|
3951
4782
|
if (json) {
|
|
3952
4783
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
3953
4784
|
} else {
|
|
3954
|
-
console.log(
|
|
4785
|
+
console.log(import_chalk4.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
3955
4786
|
}
|
|
3956
4787
|
process.exit(1);
|
|
3957
4788
|
}
|
|
@@ -3962,18 +4793,18 @@ Examples:
|
|
|
3962
4793
|
return;
|
|
3963
4794
|
}
|
|
3964
4795
|
if (data.pages.length === 0) {
|
|
3965
|
-
console.log(
|
|
4796
|
+
console.log(import_chalk4.default.gray(`No pages found matching '${query}'`));
|
|
3966
4797
|
return;
|
|
3967
4798
|
}
|
|
3968
|
-
console.log(
|
|
4799
|
+
console.log(import_chalk4.default.blue(`Search results for '${query}'`));
|
|
3969
4800
|
console.log();
|
|
3970
4801
|
for (const page of data.pages) {
|
|
3971
|
-
const status = page.status ?
|
|
3972
|
-
console.log(` ${
|
|
3973
|
-
console.log(` ${
|
|
4802
|
+
const status = page.status ? import_chalk4.default.gray(` [${page.status}]`) : "";
|
|
4803
|
+
console.log(` ${import_chalk4.default.white(page.title)}${status}`);
|
|
4804
|
+
console.log(` ${import_chalk4.default.gray(page.slug)}`);
|
|
3974
4805
|
if (page.description) {
|
|
3975
4806
|
const desc = page.description.length > 100 ? page.description.slice(0, 100) + "..." : page.description;
|
|
3976
|
-
console.log(` ${
|
|
4807
|
+
console.log(` ${import_chalk4.default.gray(desc)}`);
|
|
3977
4808
|
}
|
|
3978
4809
|
console.log();
|
|
3979
4810
|
}
|
|
@@ -3984,6 +4815,7 @@ Examples:
|
|
|
3984
4815
|
}
|
|
3985
4816
|
|
|
3986
4817
|
// src/commands/chat.ts
|
|
4818
|
+
var import_chalk5 = __toESM(require_source(), 1);
|
|
3987
4819
|
function registerChatCommands(program2) {
|
|
3988
4820
|
const threads = program2.command("threads").description("Manage chat threads").addHelpText("after", `
|
|
3989
4821
|
Examples:
|
|
@@ -4013,7 +4845,7 @@ Examples:
|
|
|
4013
4845
|
if (json) {
|
|
4014
4846
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
4015
4847
|
} else {
|
|
4016
|
-
console.log(
|
|
4848
|
+
console.log(import_chalk5.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
4017
4849
|
}
|
|
4018
4850
|
process.exit(1);
|
|
4019
4851
|
}
|
|
@@ -4024,17 +4856,17 @@ Examples:
|
|
|
4024
4856
|
return;
|
|
4025
4857
|
}
|
|
4026
4858
|
if (data.threads.length === 0) {
|
|
4027
|
-
console.log(
|
|
4859
|
+
console.log(import_chalk5.default.gray("No chat threads found"));
|
|
4028
4860
|
return;
|
|
4029
4861
|
}
|
|
4030
|
-
console.log(
|
|
4862
|
+
console.log(import_chalk5.default.blue("Chat Threads"));
|
|
4031
4863
|
console.log();
|
|
4032
4864
|
for (const thread of data.threads) {
|
|
4033
|
-
const title = thread.title ||
|
|
4865
|
+
const title = thread.title || import_chalk5.default.gray("(untitled)");
|
|
4034
4866
|
const date = thread.lastMessageAt ? new Date(thread.lastMessageAt).toLocaleDateString() : new Date(thread.createdAt).toLocaleDateString();
|
|
4035
|
-
console.log(` ${
|
|
4036
|
-
console.log(` ${
|
|
4037
|
-
console.log(` ${
|
|
4867
|
+
console.log(` ${import_chalk5.default.white(title)}`);
|
|
4868
|
+
console.log(` ${import_chalk5.default.gray(`ID: ${thread.providerThreadId}`)}`);
|
|
4869
|
+
console.log(` ${import_chalk5.default.gray(`Last activity: ${date}`)}`);
|
|
4038
4870
|
console.log();
|
|
4039
4871
|
}
|
|
4040
4872
|
} catch (error) {
|
|
@@ -4061,7 +4893,7 @@ Examples:
|
|
|
4061
4893
|
if (json) {
|
|
4062
4894
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
4063
4895
|
} else {
|
|
4064
|
-
console.log(
|
|
4896
|
+
console.log(import_chalk5.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
4065
4897
|
}
|
|
4066
4898
|
process.exit(1);
|
|
4067
4899
|
}
|
|
@@ -4070,10 +4902,10 @@ Examples:
|
|
|
4070
4902
|
if (json) {
|
|
4071
4903
|
console.log(JSON.stringify({ success: true, ...data }));
|
|
4072
4904
|
} else {
|
|
4073
|
-
console.log(
|
|
4074
|
-
console.log(
|
|
4905
|
+
console.log(import_chalk5.default.green("Created new chat thread"));
|
|
4906
|
+
console.log(import_chalk5.default.gray(`Thread ID: ${data.thread.providerThreadId}`));
|
|
4075
4907
|
if (message) {
|
|
4076
|
-
console.log(
|
|
4908
|
+
console.log(import_chalk5.default.gray("Sent initial message"));
|
|
4077
4909
|
}
|
|
4078
4910
|
}
|
|
4079
4911
|
} catch (error) {
|
|
@@ -4100,7 +4932,7 @@ Examples:
|
|
|
4100
4932
|
if (json) {
|
|
4101
4933
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
4102
4934
|
} else {
|
|
4103
|
-
console.log(
|
|
4935
|
+
console.log(import_chalk5.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
4104
4936
|
}
|
|
4105
4937
|
process.exit(1);
|
|
4106
4938
|
}
|
|
@@ -4111,16 +4943,16 @@ Examples:
|
|
|
4111
4943
|
return;
|
|
4112
4944
|
}
|
|
4113
4945
|
if (data.messages.length === 0) {
|
|
4114
|
-
console.log(
|
|
4946
|
+
console.log(import_chalk5.default.gray("No messages in this thread"));
|
|
4115
4947
|
return;
|
|
4116
4948
|
}
|
|
4117
|
-
console.log(
|
|
4949
|
+
console.log(import_chalk5.default.blue(`Thread ${threadId}`));
|
|
4118
4950
|
console.log();
|
|
4119
4951
|
for (const msg of data.messages) {
|
|
4120
|
-
const roleColor = msg.role === "user" ?
|
|
4952
|
+
const roleColor = msg.role === "user" ? import_chalk5.default.cyan : import_chalk5.default.green;
|
|
4121
4953
|
const roleLabel = msg.role === "user" ? "You" : "Assistant";
|
|
4122
4954
|
const date = new Date(msg.createdAt).toLocaleString();
|
|
4123
|
-
console.log(`${roleColor(roleLabel)} ${
|
|
4955
|
+
console.log(`${roleColor(roleLabel)} ${import_chalk5.default.gray(`(${date})`)}`);
|
|
4124
4956
|
console.log(msg.content);
|
|
4125
4957
|
console.log();
|
|
4126
4958
|
}
|
|
@@ -4152,7 +4984,7 @@ Examples:
|
|
|
4152
4984
|
if (json) {
|
|
4153
4985
|
console.log(JSON.stringify({ error: true, message: "Not logged in" }));
|
|
4154
4986
|
} else {
|
|
4155
|
-
console.log(
|
|
4987
|
+
console.log(import_chalk5.default.yellow("Not logged in. Run 'thoughtful login' first."));
|
|
4156
4988
|
}
|
|
4157
4989
|
process.exit(1);
|
|
4158
4990
|
}
|
|
@@ -4176,10 +5008,10 @@ Examples:
|
|
|
4176
5008
|
if (json) {
|
|
4177
5009
|
console.log(JSON.stringify({ success: true, message: data.message }));
|
|
4178
5010
|
} else {
|
|
4179
|
-
console.log(
|
|
5011
|
+
console.log(import_chalk5.default.green("Message sent"));
|
|
4180
5012
|
if (data.message.content) {
|
|
4181
5013
|
console.log();
|
|
4182
|
-
console.log(
|
|
5014
|
+
console.log(import_chalk5.default.gray("Response:"));
|
|
4183
5015
|
console.log(data.message.content);
|
|
4184
5016
|
}
|
|
4185
5017
|
}
|
|
@@ -4190,6 +5022,7 @@ Examples:
|
|
|
4190
5022
|
}
|
|
4191
5023
|
|
|
4192
5024
|
// src/commands/completion.ts
|
|
5025
|
+
var import_chalk6 = __toESM(require_source(), 1);
|
|
4193
5026
|
var bashCompletion = `
|
|
4194
5027
|
# Bash completion for thoughtful CLI
|
|
4195
5028
|
# Add this to your ~/.bashrc or ~/.bash_profile:
|
|
@@ -4398,21 +5231,21 @@ function registerCompletionCommand(program2) {
|
|
|
4398
5231
|
console.log(fishCompletion);
|
|
4399
5232
|
});
|
|
4400
5233
|
completion.action(() => {
|
|
4401
|
-
console.log(
|
|
5234
|
+
console.log(import_chalk6.default.blue("Shell Completion Installation"));
|
|
4402
5235
|
console.log();
|
|
4403
5236
|
console.log("Generate completion scripts for your shell:");
|
|
4404
5237
|
console.log();
|
|
4405
|
-
console.log(
|
|
5238
|
+
console.log(import_chalk6.default.cyan("Bash:"));
|
|
4406
5239
|
console.log(" Add to ~/.bashrc:");
|
|
4407
|
-
console.log(
|
|
5240
|
+
console.log(import_chalk6.default.gray(' eval "$(thoughtful completion bash)"'));
|
|
4408
5241
|
console.log();
|
|
4409
|
-
console.log(
|
|
5242
|
+
console.log(import_chalk6.default.cyan("Zsh:"));
|
|
4410
5243
|
console.log(" Add to ~/.zshrc:");
|
|
4411
|
-
console.log(
|
|
5244
|
+
console.log(import_chalk6.default.gray(' eval "$(thoughtful completion zsh)"'));
|
|
4412
5245
|
console.log();
|
|
4413
|
-
console.log(
|
|
5246
|
+
console.log(import_chalk6.default.cyan("Fish:"));
|
|
4414
5247
|
console.log(" Save to completions directory:");
|
|
4415
|
-
console.log(
|
|
5248
|
+
console.log(import_chalk6.default.gray(" thoughtful completion fish > ~/.config/fish/completions/thoughtful.fish"));
|
|
4416
5249
|
console.log();
|
|
4417
5250
|
console.log("After adding the completion script, restart your shell or source the config file.");
|
|
4418
5251
|
});
|