@tscircuit/cli 0.1.94 → 0.1.96
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/main.js +38 -488
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -433425,7 +433425,7 @@ import readline from "node:readline";
|
|
|
433425
433425
|
import { execSync as execSync2 } from "node:child_process";
|
|
433426
433426
|
var import_semver = __toESM2(require_semver2(), 1);
|
|
433427
433427
|
// package.json
|
|
433428
|
-
var version = "0.1.
|
|
433428
|
+
var version = "0.1.95";
|
|
433429
433429
|
var package_default = {
|
|
433430
433430
|
name: "@tscircuit/cli",
|
|
433431
433431
|
version,
|
|
@@ -439237,6 +439237,11 @@ Ready to use!`);
|
|
|
439237
439237
|
// cli/auth/logout/register.ts
|
|
439238
439238
|
var registerAuthLogout = (program3) => {
|
|
439239
439239
|
const logoutAction = () => {
|
|
439240
|
+
const session = getSessionToken();
|
|
439241
|
+
if (!session) {
|
|
439242
|
+
console.log("You are not logged in!");
|
|
439243
|
+
return;
|
|
439244
|
+
}
|
|
439240
439245
|
clearSession();
|
|
439241
439246
|
console.log("You have been logged out!");
|
|
439242
439247
|
};
|
|
@@ -439265,7 +439270,7 @@ var registerConfigPrint = (program3) => {
|
|
|
439265
439270
|
import * as fs19 from "node:fs";
|
|
439266
439271
|
import * as path19 from "node:path";
|
|
439267
439272
|
var registerClone = (program3) => {
|
|
439268
|
-
program3.command("clone").description("Clone a snippet from the registry").argument("<snippet>", "Snippet to clone (e.g. author/snippetName or https://tscircuit.com/author/snippetName)").action(async (snippetPath) => {
|
|
439273
|
+
program3.command("clone").description("Clone a snippet from the registry").argument("<snippet>", "Snippet to clone (e.g. author/snippetName or https://tscircuit.com/author/snippetName)").option("-a, --include-author", "Include author name in the directory path").action(async (snippetPath, options) => {
|
|
439269
439274
|
const urlMatch = snippetPath.match(/^https:\/\/tscircuit\.com\/([^\/]+)\/([^\/]+)\/?$/i);
|
|
439270
439275
|
const originalMatch = !urlMatch && snippetPath.match(/^(?:@tsci\/)?([^/.]+)[/.]([^/.]+)$/);
|
|
439271
439276
|
const originalCwd = process.cwd();
|
|
@@ -439283,7 +439288,9 @@ var registerClone = (program3) => {
|
|
|
439283
439288
|
const [, author, snippetName] = match;
|
|
439284
439289
|
console.log(`Cloning ${author}/${snippetName}...`);
|
|
439285
439290
|
const ky2 = getRegistryApiKy();
|
|
439286
|
-
let packageFileList
|
|
439291
|
+
let packageFileList = {
|
|
439292
|
+
package_files: []
|
|
439293
|
+
};
|
|
439287
439294
|
try {
|
|
439288
439295
|
packageFileList = await ky2.post("package_files/list", {
|
|
439289
439296
|
json: {
|
|
@@ -439292,10 +439299,15 @@ var registerClone = (program3) => {
|
|
|
439292
439299
|
}
|
|
439293
439300
|
}).json();
|
|
439294
439301
|
} catch (error) {
|
|
439302
|
+
if (typeof error === "object" && error !== null && "response" in error && typeof error.response === "object" && error.response?.status === 404) {
|
|
439303
|
+
console.error(`Snippet "${author}/${snippetName}" not found. Please check the name and try again.`);
|
|
439304
|
+
process.exit(1);
|
|
439305
|
+
}
|
|
439295
439306
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
439296
439307
|
process.exit(1);
|
|
439297
439308
|
}
|
|
439298
|
-
const
|
|
439309
|
+
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
439310
|
+
const dirPath = userSettingToIncludeAuthor ? path19.resolve(`${author}.${snippetName}`) : path19.resolve(snippetName);
|
|
439299
439311
|
fs19.mkdirSync(dirPath, { recursive: true });
|
|
439300
439312
|
for (const fileInfo of packageFileList.package_files) {
|
|
439301
439313
|
const filePath = fileInfo.file_path.replace(/^\/|dist\//g, "");
|
|
@@ -464358,499 +464370,36 @@ var registerAdd = (program3) => {
|
|
|
464358
464370
|
});
|
|
464359
464371
|
};
|
|
464360
464372
|
|
|
464361
|
-
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
464362
|
-
var ANSI_BACKGROUND_OFFSET = 10;
|
|
464363
|
-
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
464364
|
-
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
464365
|
-
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
464366
|
-
var styles = {
|
|
464367
|
-
modifier: {
|
|
464368
|
-
reset: [0, 0],
|
|
464369
|
-
bold: [1, 22],
|
|
464370
|
-
dim: [2, 22],
|
|
464371
|
-
italic: [3, 23],
|
|
464372
|
-
underline: [4, 24],
|
|
464373
|
-
overline: [53, 55],
|
|
464374
|
-
inverse: [7, 27],
|
|
464375
|
-
hidden: [8, 28],
|
|
464376
|
-
strikethrough: [9, 29]
|
|
464377
|
-
},
|
|
464378
|
-
color: {
|
|
464379
|
-
black: [30, 39],
|
|
464380
|
-
red: [31, 39],
|
|
464381
|
-
green: [32, 39],
|
|
464382
|
-
yellow: [33, 39],
|
|
464383
|
-
blue: [34, 39],
|
|
464384
|
-
magenta: [35, 39],
|
|
464385
|
-
cyan: [36, 39],
|
|
464386
|
-
white: [37, 39],
|
|
464387
|
-
blackBright: [90, 39],
|
|
464388
|
-
gray: [90, 39],
|
|
464389
|
-
grey: [90, 39],
|
|
464390
|
-
redBright: [91, 39],
|
|
464391
|
-
greenBright: [92, 39],
|
|
464392
|
-
yellowBright: [93, 39],
|
|
464393
|
-
blueBright: [94, 39],
|
|
464394
|
-
magentaBright: [95, 39],
|
|
464395
|
-
cyanBright: [96, 39],
|
|
464396
|
-
whiteBright: [97, 39]
|
|
464397
|
-
},
|
|
464398
|
-
bgColor: {
|
|
464399
|
-
bgBlack: [40, 49],
|
|
464400
|
-
bgRed: [41, 49],
|
|
464401
|
-
bgGreen: [42, 49],
|
|
464402
|
-
bgYellow: [43, 49],
|
|
464403
|
-
bgBlue: [44, 49],
|
|
464404
|
-
bgMagenta: [45, 49],
|
|
464405
|
-
bgCyan: [46, 49],
|
|
464406
|
-
bgWhite: [47, 49],
|
|
464407
|
-
bgBlackBright: [100, 49],
|
|
464408
|
-
bgGray: [100, 49],
|
|
464409
|
-
bgGrey: [100, 49],
|
|
464410
|
-
bgRedBright: [101, 49],
|
|
464411
|
-
bgGreenBright: [102, 49],
|
|
464412
|
-
bgYellowBright: [103, 49],
|
|
464413
|
-
bgBlueBright: [104, 49],
|
|
464414
|
-
bgMagentaBright: [105, 49],
|
|
464415
|
-
bgCyanBright: [106, 49],
|
|
464416
|
-
bgWhiteBright: [107, 49]
|
|
464417
|
-
}
|
|
464418
|
-
};
|
|
464419
|
-
var modifierNames = Object.keys(styles.modifier);
|
|
464420
|
-
var foregroundColorNames = Object.keys(styles.color);
|
|
464421
|
-
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
464422
|
-
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
464423
|
-
function assembleStyles() {
|
|
464424
|
-
const codes = new Map;
|
|
464425
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
|
464426
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
464427
|
-
styles[styleName] = {
|
|
464428
|
-
open: `\x1B[${style[0]}m`,
|
|
464429
|
-
close: `\x1B[${style[1]}m`
|
|
464430
|
-
};
|
|
464431
|
-
group[styleName] = styles[styleName];
|
|
464432
|
-
codes.set(style[0], style[1]);
|
|
464433
|
-
}
|
|
464434
|
-
Object.defineProperty(styles, groupName, {
|
|
464435
|
-
value: group,
|
|
464436
|
-
enumerable: false
|
|
464437
|
-
});
|
|
464438
|
-
}
|
|
464439
|
-
Object.defineProperty(styles, "codes", {
|
|
464440
|
-
value: codes,
|
|
464441
|
-
enumerable: false
|
|
464442
|
-
});
|
|
464443
|
-
styles.color.close = "\x1B[39m";
|
|
464444
|
-
styles.bgColor.close = "\x1B[49m";
|
|
464445
|
-
styles.color.ansi = wrapAnsi16();
|
|
464446
|
-
styles.color.ansi256 = wrapAnsi256();
|
|
464447
|
-
styles.color.ansi16m = wrapAnsi16m();
|
|
464448
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
464449
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
464450
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
464451
|
-
Object.defineProperties(styles, {
|
|
464452
|
-
rgbToAnsi256: {
|
|
464453
|
-
value(red, green, blue) {
|
|
464454
|
-
if (red === green && green === blue) {
|
|
464455
|
-
if (red < 8) {
|
|
464456
|
-
return 16;
|
|
464457
|
-
}
|
|
464458
|
-
if (red > 248) {
|
|
464459
|
-
return 231;
|
|
464460
|
-
}
|
|
464461
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
464462
|
-
}
|
|
464463
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
464464
|
-
},
|
|
464465
|
-
enumerable: false
|
|
464466
|
-
},
|
|
464467
|
-
hexToRgb: {
|
|
464468
|
-
value(hex) {
|
|
464469
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
464470
|
-
if (!matches) {
|
|
464471
|
-
return [0, 0, 0];
|
|
464472
|
-
}
|
|
464473
|
-
let [colorString] = matches;
|
|
464474
|
-
if (colorString.length === 3) {
|
|
464475
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
464476
|
-
}
|
|
464477
|
-
const integer = Number.parseInt(colorString, 16);
|
|
464478
|
-
return [
|
|
464479
|
-
integer >> 16 & 255,
|
|
464480
|
-
integer >> 8 & 255,
|
|
464481
|
-
integer & 255
|
|
464482
|
-
];
|
|
464483
|
-
},
|
|
464484
|
-
enumerable: false
|
|
464485
|
-
},
|
|
464486
|
-
hexToAnsi256: {
|
|
464487
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
464488
|
-
enumerable: false
|
|
464489
|
-
},
|
|
464490
|
-
ansi256ToAnsi: {
|
|
464491
|
-
value(code) {
|
|
464492
|
-
if (code < 8) {
|
|
464493
|
-
return 30 + code;
|
|
464494
|
-
}
|
|
464495
|
-
if (code < 16) {
|
|
464496
|
-
return 90 + (code - 8);
|
|
464497
|
-
}
|
|
464498
|
-
let red;
|
|
464499
|
-
let green;
|
|
464500
|
-
let blue;
|
|
464501
|
-
if (code >= 232) {
|
|
464502
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
464503
|
-
green = red;
|
|
464504
|
-
blue = red;
|
|
464505
|
-
} else {
|
|
464506
|
-
code -= 16;
|
|
464507
|
-
const remainder = code % 36;
|
|
464508
|
-
red = Math.floor(code / 36) / 5;
|
|
464509
|
-
green = Math.floor(remainder / 6) / 5;
|
|
464510
|
-
blue = remainder % 6 / 5;
|
|
464511
|
-
}
|
|
464512
|
-
const value2 = Math.max(red, green, blue) * 2;
|
|
464513
|
-
if (value2 === 0) {
|
|
464514
|
-
return 30;
|
|
464515
|
-
}
|
|
464516
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
464517
|
-
if (value2 === 2) {
|
|
464518
|
-
result += 60;
|
|
464519
|
-
}
|
|
464520
|
-
return result;
|
|
464521
|
-
},
|
|
464522
|
-
enumerable: false
|
|
464523
|
-
},
|
|
464524
|
-
rgbToAnsi: {
|
|
464525
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
464526
|
-
enumerable: false
|
|
464527
|
-
},
|
|
464528
|
-
hexToAnsi: {
|
|
464529
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
464530
|
-
enumerable: false
|
|
464531
|
-
}
|
|
464532
|
-
});
|
|
464533
|
-
return styles;
|
|
464534
|
-
}
|
|
464535
|
-
var ansiStyles = assembleStyles();
|
|
464536
|
-
var ansi_styles_default = ansiStyles;
|
|
464537
|
-
|
|
464538
|
-
// node_modules/chalk/source/vendor/supports-color/index.js
|
|
464539
|
-
import process10 from "node:process";
|
|
464540
|
-
import os3 from "node:os";
|
|
464541
|
-
import tty from "node:tty";
|
|
464542
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process10.argv) {
|
|
464543
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
464544
|
-
const position2 = argv.indexOf(prefix + flag);
|
|
464545
|
-
const terminatorPosition = argv.indexOf("--");
|
|
464546
|
-
return position2 !== -1 && (terminatorPosition === -1 || position2 < terminatorPosition);
|
|
464547
|
-
}
|
|
464548
|
-
var { env: env2 } = process10;
|
|
464549
|
-
var flagForceColor;
|
|
464550
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
464551
|
-
flagForceColor = 0;
|
|
464552
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
464553
|
-
flagForceColor = 1;
|
|
464554
|
-
}
|
|
464555
|
-
function envForceColor() {
|
|
464556
|
-
if ("FORCE_COLOR" in env2) {
|
|
464557
|
-
if (env2.FORCE_COLOR === "true") {
|
|
464558
|
-
return 1;
|
|
464559
|
-
}
|
|
464560
|
-
if (env2.FORCE_COLOR === "false") {
|
|
464561
|
-
return 0;
|
|
464562
|
-
}
|
|
464563
|
-
return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
|
|
464564
|
-
}
|
|
464565
|
-
}
|
|
464566
|
-
function translateLevel(level) {
|
|
464567
|
-
if (level === 0) {
|
|
464568
|
-
return false;
|
|
464569
|
-
}
|
|
464570
|
-
return {
|
|
464571
|
-
level,
|
|
464572
|
-
hasBasic: true,
|
|
464573
|
-
has256: level >= 2,
|
|
464574
|
-
has16m: level >= 3
|
|
464575
|
-
};
|
|
464576
|
-
}
|
|
464577
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
464578
|
-
const noFlagForceColor = envForceColor();
|
|
464579
|
-
if (noFlagForceColor !== undefined) {
|
|
464580
|
-
flagForceColor = noFlagForceColor;
|
|
464581
|
-
}
|
|
464582
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
464583
|
-
if (forceColor === 0) {
|
|
464584
|
-
return 0;
|
|
464585
|
-
}
|
|
464586
|
-
if (sniffFlags) {
|
|
464587
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
464588
|
-
return 3;
|
|
464589
|
-
}
|
|
464590
|
-
if (hasFlag("color=256")) {
|
|
464591
|
-
return 2;
|
|
464592
|
-
}
|
|
464593
|
-
}
|
|
464594
|
-
if ("TF_BUILD" in env2 && "AGENT_NAME" in env2) {
|
|
464595
|
-
return 1;
|
|
464596
|
-
}
|
|
464597
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
464598
|
-
return 0;
|
|
464599
|
-
}
|
|
464600
|
-
const min = forceColor || 0;
|
|
464601
|
-
if (env2.TERM === "dumb") {
|
|
464602
|
-
return min;
|
|
464603
|
-
}
|
|
464604
|
-
if (process10.platform === "win32") {
|
|
464605
|
-
const osRelease = os3.release().split(".");
|
|
464606
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
464607
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
464608
|
-
}
|
|
464609
|
-
return 1;
|
|
464610
|
-
}
|
|
464611
|
-
if ("CI" in env2) {
|
|
464612
|
-
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env2))) {
|
|
464613
|
-
return 3;
|
|
464614
|
-
}
|
|
464615
|
-
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env2)) || env2.CI_NAME === "codeship") {
|
|
464616
|
-
return 1;
|
|
464617
|
-
}
|
|
464618
|
-
return min;
|
|
464619
|
-
}
|
|
464620
|
-
if ("TEAMCITY_VERSION" in env2) {
|
|
464621
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
|
|
464622
|
-
}
|
|
464623
|
-
if (env2.COLORTERM === "truecolor") {
|
|
464624
|
-
return 3;
|
|
464625
|
-
}
|
|
464626
|
-
if (env2.TERM === "xterm-kitty") {
|
|
464627
|
-
return 3;
|
|
464628
|
-
}
|
|
464629
|
-
if ("TERM_PROGRAM" in env2) {
|
|
464630
|
-
const version2 = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
464631
|
-
switch (env2.TERM_PROGRAM) {
|
|
464632
|
-
case "iTerm.app": {
|
|
464633
|
-
return version2 >= 3 ? 3 : 2;
|
|
464634
|
-
}
|
|
464635
|
-
case "Apple_Terminal": {
|
|
464636
|
-
return 2;
|
|
464637
|
-
}
|
|
464638
|
-
}
|
|
464639
|
-
}
|
|
464640
|
-
if (/-256(color)?$/i.test(env2.TERM)) {
|
|
464641
|
-
return 2;
|
|
464642
|
-
}
|
|
464643
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
|
|
464644
|
-
return 1;
|
|
464645
|
-
}
|
|
464646
|
-
if ("COLORTERM" in env2) {
|
|
464647
|
-
return 1;
|
|
464648
|
-
}
|
|
464649
|
-
return min;
|
|
464650
|
-
}
|
|
464651
|
-
function createSupportsColor(stream, options = {}) {
|
|
464652
|
-
const level = _supportsColor(stream, {
|
|
464653
|
-
streamIsTTY: stream && stream.isTTY,
|
|
464654
|
-
...options
|
|
464655
|
-
});
|
|
464656
|
-
return translateLevel(level);
|
|
464657
|
-
}
|
|
464658
|
-
var supportsColor = {
|
|
464659
|
-
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
464660
|
-
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
464661
|
-
};
|
|
464662
|
-
var supports_color_default = supportsColor;
|
|
464663
|
-
|
|
464664
|
-
// node_modules/chalk/source/utilities.js
|
|
464665
|
-
function stringReplaceAll(string2, substring, replacer) {
|
|
464666
|
-
let index = string2.indexOf(substring);
|
|
464667
|
-
if (index === -1) {
|
|
464668
|
-
return string2;
|
|
464669
|
-
}
|
|
464670
|
-
const substringLength = substring.length;
|
|
464671
|
-
let endIndex = 0;
|
|
464672
|
-
let returnValue = "";
|
|
464673
|
-
do {
|
|
464674
|
-
returnValue += string2.slice(endIndex, index) + substring + replacer;
|
|
464675
|
-
endIndex = index + substringLength;
|
|
464676
|
-
index = string2.indexOf(substring, endIndex);
|
|
464677
|
-
} while (index !== -1);
|
|
464678
|
-
returnValue += string2.slice(endIndex);
|
|
464679
|
-
return returnValue;
|
|
464680
|
-
}
|
|
464681
|
-
function stringEncaseCRLFWithFirstIndex(string2, prefix, postfix, index) {
|
|
464682
|
-
let endIndex = 0;
|
|
464683
|
-
let returnValue = "";
|
|
464684
|
-
do {
|
|
464685
|
-
const gotCR = string2[index - 1] === "\r";
|
|
464686
|
-
returnValue += string2.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
|
|
464687
|
-
` : `
|
|
464688
|
-
`) + postfix;
|
|
464689
|
-
endIndex = index + 1;
|
|
464690
|
-
index = string2.indexOf(`
|
|
464691
|
-
`, endIndex);
|
|
464692
|
-
} while (index !== -1);
|
|
464693
|
-
returnValue += string2.slice(endIndex);
|
|
464694
|
-
return returnValue;
|
|
464695
|
-
}
|
|
464696
|
-
|
|
464697
|
-
// node_modules/chalk/source/index.js
|
|
464698
|
-
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
464699
|
-
var GENERATOR = Symbol("GENERATOR");
|
|
464700
|
-
var STYLER = Symbol("STYLER");
|
|
464701
|
-
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
464702
|
-
var levelMapping = [
|
|
464703
|
-
"ansi",
|
|
464704
|
-
"ansi",
|
|
464705
|
-
"ansi256",
|
|
464706
|
-
"ansi16m"
|
|
464707
|
-
];
|
|
464708
|
-
var styles2 = Object.create(null);
|
|
464709
|
-
var applyOptions = (object, options = {}) => {
|
|
464710
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
464711
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
464712
|
-
}
|
|
464713
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
464714
|
-
object.level = options.level === undefined ? colorLevel : options.level;
|
|
464715
|
-
};
|
|
464716
|
-
var chalkFactory = (options) => {
|
|
464717
|
-
const chalk = (...strings) => strings.join(" ");
|
|
464718
|
-
applyOptions(chalk, options);
|
|
464719
|
-
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
464720
|
-
return chalk;
|
|
464721
|
-
};
|
|
464722
|
-
function createChalk(options) {
|
|
464723
|
-
return chalkFactory(options);
|
|
464724
|
-
}
|
|
464725
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
464726
|
-
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
464727
|
-
styles2[styleName] = {
|
|
464728
|
-
get() {
|
|
464729
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
464730
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
464731
|
-
return builder;
|
|
464732
|
-
}
|
|
464733
|
-
};
|
|
464734
|
-
}
|
|
464735
|
-
styles2.visible = {
|
|
464736
|
-
get() {
|
|
464737
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
464738
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
464739
|
-
return builder;
|
|
464740
|
-
}
|
|
464741
|
-
};
|
|
464742
|
-
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
464743
|
-
if (model === "rgb") {
|
|
464744
|
-
if (level === "ansi16m") {
|
|
464745
|
-
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
464746
|
-
}
|
|
464747
|
-
if (level === "ansi256") {
|
|
464748
|
-
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
464749
|
-
}
|
|
464750
|
-
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
464751
|
-
}
|
|
464752
|
-
if (model === "hex") {
|
|
464753
|
-
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
464754
|
-
}
|
|
464755
|
-
return ansi_styles_default[type][model](...arguments_);
|
|
464756
|
-
};
|
|
464757
|
-
var usedModels = ["rgb", "hex", "ansi256"];
|
|
464758
|
-
for (const model of usedModels) {
|
|
464759
|
-
styles2[model] = {
|
|
464760
|
-
get() {
|
|
464761
|
-
const { level } = this;
|
|
464762
|
-
return function(...arguments_) {
|
|
464763
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
464764
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
464765
|
-
};
|
|
464766
|
-
}
|
|
464767
|
-
};
|
|
464768
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
464769
|
-
styles2[bgModel] = {
|
|
464770
|
-
get() {
|
|
464771
|
-
const { level } = this;
|
|
464772
|
-
return function(...arguments_) {
|
|
464773
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
464774
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
464775
|
-
};
|
|
464776
|
-
}
|
|
464777
|
-
};
|
|
464778
|
-
}
|
|
464779
|
-
var proto = Object.defineProperties(() => {}, {
|
|
464780
|
-
...styles2,
|
|
464781
|
-
level: {
|
|
464782
|
-
enumerable: true,
|
|
464783
|
-
get() {
|
|
464784
|
-
return this[GENERATOR].level;
|
|
464785
|
-
},
|
|
464786
|
-
set(level) {
|
|
464787
|
-
this[GENERATOR].level = level;
|
|
464788
|
-
}
|
|
464789
|
-
}
|
|
464790
|
-
});
|
|
464791
|
-
var createStyler = (open2, close, parent) => {
|
|
464792
|
-
let openAll;
|
|
464793
|
-
let closeAll;
|
|
464794
|
-
if (parent === undefined) {
|
|
464795
|
-
openAll = open2;
|
|
464796
|
-
closeAll = close;
|
|
464797
|
-
} else {
|
|
464798
|
-
openAll = parent.openAll + open2;
|
|
464799
|
-
closeAll = close + parent.closeAll;
|
|
464800
|
-
}
|
|
464801
|
-
return {
|
|
464802
|
-
open: open2,
|
|
464803
|
-
close,
|
|
464804
|
-
openAll,
|
|
464805
|
-
closeAll,
|
|
464806
|
-
parent
|
|
464807
|
-
};
|
|
464808
|
-
};
|
|
464809
|
-
var createBuilder = (self2, _styler, _isEmpty) => {
|
|
464810
|
-
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
464811
|
-
Object.setPrototypeOf(builder, proto);
|
|
464812
|
-
builder[GENERATOR] = self2;
|
|
464813
|
-
builder[STYLER] = _styler;
|
|
464814
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
464815
|
-
return builder;
|
|
464816
|
-
};
|
|
464817
|
-
var applyStyle = (self2, string2) => {
|
|
464818
|
-
if (self2.level <= 0 || !string2) {
|
|
464819
|
-
return self2[IS_EMPTY] ? "" : string2;
|
|
464820
|
-
}
|
|
464821
|
-
let styler = self2[STYLER];
|
|
464822
|
-
if (styler === undefined) {
|
|
464823
|
-
return string2;
|
|
464824
|
-
}
|
|
464825
|
-
const { openAll, closeAll } = styler;
|
|
464826
|
-
if (string2.includes("\x1B")) {
|
|
464827
|
-
while (styler !== undefined) {
|
|
464828
|
-
string2 = stringReplaceAll(string2, styler.close, styler.open);
|
|
464829
|
-
styler = styler.parent;
|
|
464830
|
-
}
|
|
464831
|
-
}
|
|
464832
|
-
const lfIndex = string2.indexOf(`
|
|
464833
|
-
`);
|
|
464834
|
-
if (lfIndex !== -1) {
|
|
464835
|
-
string2 = stringEncaseCRLFWithFirstIndex(string2, closeAll, openAll, lfIndex);
|
|
464836
|
-
}
|
|
464837
|
-
return openAll + string2 + closeAll;
|
|
464838
|
-
};
|
|
464839
|
-
Object.defineProperties(createChalk.prototype, styles2);
|
|
464840
|
-
var chalk = createChalk();
|
|
464841
|
-
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
464842
|
-
var source_default = chalk;
|
|
464843
|
-
|
|
464844
464373
|
// cli/upgrade/register.ts
|
|
464845
464374
|
function registerUpgradeCommand(program3) {
|
|
464846
464375
|
program3.command("upgrade").description("Upgrade CLI to the latest version").action(async () => {
|
|
464847
464376
|
const isUpdated = await checkForTsciUpdates();
|
|
464848
464377
|
if (!isUpdated) {
|
|
464849
|
-
console.log(
|
|
464378
|
+
console.log(kleur_default.green("You are already using the latest version of tsci."));
|
|
464850
464379
|
}
|
|
464851
464380
|
});
|
|
464852
464381
|
}
|
|
464853
464382
|
|
|
464383
|
+
// cli/config/set/register.ts
|
|
464384
|
+
var availableConfigKeys = [
|
|
464385
|
+
"alwaysCloneWithAuthorName"
|
|
464386
|
+
];
|
|
464387
|
+
var registerConfigSet = (program3) => {
|
|
464388
|
+
const configCommand = program3.commands.find((c) => c.name() === "config");
|
|
464389
|
+
configCommand.command("set").description("Set a configuration value").argument("<key>", "Configuration key to set (e.g., alwaysCloneWithAuthorName)").argument("<value>", "Value to set (e.g., true or false)").action((key, value2) => {
|
|
464390
|
+
if (!availableConfigKeys.includes(key)) {
|
|
464391
|
+
console.error(kleur_default.red(`Unknown configuration key: '${key}'`));
|
|
464392
|
+
console.log(kleur_default.cyan(`Available keys: ${availableConfigKeys.join(", ")}`));
|
|
464393
|
+
process.exit(1);
|
|
464394
|
+
}
|
|
464395
|
+
if (key === "alwaysCloneWithAuthorName") {
|
|
464396
|
+
const booleanValue = value2.toLowerCase() === "true";
|
|
464397
|
+
cliConfig.set(key, booleanValue);
|
|
464398
|
+
console.log(kleur_default.cyan(`Set ${kleur_default.yellow(key)} to ${kleur_default.yellow(booleanValue.toString())} successfully.`));
|
|
464399
|
+
}
|
|
464400
|
+
});
|
|
464401
|
+
};
|
|
464402
|
+
|
|
464854
464403
|
// cli/main.ts
|
|
464855
464404
|
var program2 = new Command;
|
|
464856
464405
|
program2.name("tsci").description("CLI for developing tscircuit snippets").version(getVersion());
|
|
@@ -464865,6 +464414,7 @@ registerAuthPrintToken(program2);
|
|
|
464865
464414
|
registerAuthSetToken(program2);
|
|
464866
464415
|
registerConfig(program2);
|
|
464867
464416
|
registerConfigPrint(program2);
|
|
464417
|
+
registerConfigSet(program2);
|
|
464868
464418
|
registerExport(program2);
|
|
464869
464419
|
registerAdd(program2);
|
|
464870
464420
|
registerUpgradeCommand(program2);
|