@tscircuit/cli 0.1.95 → 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 +32 -4
- 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,
|
|
@@ -439270,7 +439270,7 @@ var registerConfigPrint = (program3) => {
|
|
|
439270
439270
|
import * as fs19 from "node:fs";
|
|
439271
439271
|
import * as path19 from "node:path";
|
|
439272
439272
|
var registerClone = (program3) => {
|
|
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)").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) => {
|
|
439274
439274
|
const urlMatch = snippetPath.match(/^https:\/\/tscircuit\.com\/([^\/]+)\/([^\/]+)\/?$/i);
|
|
439275
439275
|
const originalMatch = !urlMatch && snippetPath.match(/^(?:@tsci\/)?([^/.]+)[/.]([^/.]+)$/);
|
|
439276
439276
|
const originalCwd = process.cwd();
|
|
@@ -439288,7 +439288,9 @@ var registerClone = (program3) => {
|
|
|
439288
439288
|
const [, author, snippetName] = match;
|
|
439289
439289
|
console.log(`Cloning ${author}/${snippetName}...`);
|
|
439290
439290
|
const ky2 = getRegistryApiKy();
|
|
439291
|
-
let packageFileList
|
|
439291
|
+
let packageFileList = {
|
|
439292
|
+
package_files: []
|
|
439293
|
+
};
|
|
439292
439294
|
try {
|
|
439293
439295
|
packageFileList = await ky2.post("package_files/list", {
|
|
439294
439296
|
json: {
|
|
@@ -439297,10 +439299,15 @@ var registerClone = (program3) => {
|
|
|
439297
439299
|
}
|
|
439298
439300
|
}).json();
|
|
439299
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
|
+
}
|
|
439300
439306
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
439301
439307
|
process.exit(1);
|
|
439302
439308
|
}
|
|
439303
|
-
const
|
|
439309
|
+
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
439310
|
+
const dirPath = userSettingToIncludeAuthor ? path19.resolve(`${author}.${snippetName}`) : path19.resolve(snippetName);
|
|
439304
439311
|
fs19.mkdirSync(dirPath, { recursive: true });
|
|
439305
439312
|
for (const fileInfo of packageFileList.package_files) {
|
|
439306
439313
|
const filePath = fileInfo.file_path.replace(/^\/|dist\//g, "");
|
|
@@ -464373,6 +464380,26 @@ function registerUpgradeCommand(program3) {
|
|
|
464373
464380
|
});
|
|
464374
464381
|
}
|
|
464375
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
|
+
|
|
464376
464403
|
// cli/main.ts
|
|
464377
464404
|
var program2 = new Command;
|
|
464378
464405
|
program2.name("tsci").description("CLI for developing tscircuit snippets").version(getVersion());
|
|
@@ -464387,6 +464414,7 @@ registerAuthPrintToken(program2);
|
|
|
464387
464414
|
registerAuthSetToken(program2);
|
|
464388
464415
|
registerConfig(program2);
|
|
464389
464416
|
registerConfigPrint(program2);
|
|
464417
|
+
registerConfigSet(program2);
|
|
464390
464418
|
registerExport(program2);
|
|
464391
464419
|
registerAdd(program2);
|
|
464392
464420
|
registerUpgradeCommand(program2);
|