@tscircuit/cli 0.1.73 → 0.1.74
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/README.md +4 -0
- package/dist/main.js +54 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,9 @@ tsci dev ./path/to/file.tsx
|
|
|
12
12
|
|
|
13
13
|
# Clone a snippet from the registry
|
|
14
14
|
tsci clone author/snippetName
|
|
15
|
+
|
|
16
|
+
# Add a component from tscircuit.com
|
|
17
|
+
tsci add author/component-name
|
|
15
18
|
```
|
|
16
19
|
|
|
17
20
|
> Note: The snippets CLI uses the same configuration files as the [@tscircuit/cli](https://github.com/tscircuit/cli), so you may need to also install `npm install -g @tscircuit/cli` and run `tsci login` to authenticate!
|
|
@@ -40,6 +43,7 @@ Commands:
|
|
|
40
43
|
dev [options] [file] Start development server for a snippet
|
|
41
44
|
clone <snippet> Clone a snippet from the registry
|
|
42
45
|
push [options] [file] Save snippet code to Registry API
|
|
46
|
+
add <component> Add a component from tscircuit.com
|
|
43
47
|
auth Login/logout
|
|
44
48
|
login Login to tscircuit registry
|
|
45
49
|
logout Logout from tscircuit registry
|
package/dist/main.js
CHANGED
|
@@ -426994,7 +426994,7 @@ import readline from "node:readline";
|
|
|
426994
426994
|
import { execSync as execSync2 } from "node:child_process";
|
|
426995
426995
|
var import_semver = __toESM2(require_semver2(), 1);
|
|
426996
426996
|
// package.json
|
|
426997
|
-
var version = "0.1.
|
|
426997
|
+
var version = "0.1.73";
|
|
426998
426998
|
var package_default = {
|
|
426999
426999
|
name: "@tscircuit/cli",
|
|
427000
427000
|
version,
|
|
@@ -456911,6 +456911,58 @@ var registerPush = (program3) => {
|
|
|
456911
456911
|
});
|
|
456912
456912
|
};
|
|
456913
456913
|
|
|
456914
|
+
// cli/add/register.ts
|
|
456915
|
+
import * as fs20 from "node:fs";
|
|
456916
|
+
import * as path19 from "node:path";
|
|
456917
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
456918
|
+
var registerAdd = (program3) => {
|
|
456919
|
+
program3.command("add").description("Add a component from tscircuit.com").argument("<component>", "Component to add (e.g. author/component-name)").action(async (componentPath) => {
|
|
456920
|
+
await checkForTsciUpdates();
|
|
456921
|
+
let packageName;
|
|
456922
|
+
if (componentPath.startsWith("@tscircuit/")) {
|
|
456923
|
+
packageName = componentPath;
|
|
456924
|
+
} else if (componentPath.startsWith("@tsci/")) {
|
|
456925
|
+
packageName = componentPath;
|
|
456926
|
+
} else {
|
|
456927
|
+
const match = componentPath.match(/^([^/.]+)[/.](.+)$/);
|
|
456928
|
+
if (!match) {
|
|
456929
|
+
console.error("Invalid component path. Use format: author/component-name, author.component-name, @tscircuit/package-name, or @tsci/author.component-name");
|
|
456930
|
+
process.exit(1);
|
|
456931
|
+
}
|
|
456932
|
+
const [, author, componentName] = match;
|
|
456933
|
+
packageName = `@tsci/${author}.${componentName}`;
|
|
456934
|
+
}
|
|
456935
|
+
console.log(`Adding ${packageName}...`);
|
|
456936
|
+
const npmrcPath = path19.join(process.cwd(), ".npmrc");
|
|
456937
|
+
const npmrcContent = fs20.existsSync(npmrcPath) ? fs20.readFileSync(npmrcPath, "utf-8") : "";
|
|
456938
|
+
if (!npmrcContent.includes("@tsci:registry=https://npm.tscircuit.com")) {
|
|
456939
|
+
fs20.writeFileSync(npmrcPath, `${npmrcContent}
|
|
456940
|
+
@tsci:registry=https://npm.tscircuit.com
|
|
456941
|
+
`);
|
|
456942
|
+
console.log("Updated .npmrc with tscircuit registry");
|
|
456943
|
+
}
|
|
456944
|
+
const isTestMode = process.env.TSCI_TEST_MODE === "true";
|
|
456945
|
+
if (isTestMode) {
|
|
456946
|
+
const pkgJsonPath = path19.join(process.cwd(), "package.json");
|
|
456947
|
+
const pkgJson = JSON.parse(fs20.readFileSync(pkgJsonPath, "utf-8"));
|
|
456948
|
+
pkgJson.dependencies = pkgJson.dependencies || {};
|
|
456949
|
+
pkgJson.dependencies[packageName] = "^1.0.0";
|
|
456950
|
+
fs20.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
456951
|
+
console.log(`Added ${packageName} successfully.`);
|
|
456952
|
+
return;
|
|
456953
|
+
}
|
|
456954
|
+
const packageManager = detectPackageManager();
|
|
456955
|
+
const installCommand = packageManager === "yarn" ? `yarn add ${packageName}` : packageManager === "pnpm" ? `pnpm add ${packageName}` : packageManager === "bun" ? `bun add ${packageName}` : `npm install ${packageName}`;
|
|
456956
|
+
try {
|
|
456957
|
+
execSync3(installCommand, { stdio: "pipe" });
|
|
456958
|
+
console.log(`Added ${packageName} successfully.`);
|
|
456959
|
+
} catch (error) {
|
|
456960
|
+
console.error(`Failed to add ${packageName}:`, error instanceof Error ? error.message : error);
|
|
456961
|
+
process.exit(1);
|
|
456962
|
+
}
|
|
456963
|
+
});
|
|
456964
|
+
};
|
|
456965
|
+
|
|
456914
456966
|
// cli/main.ts
|
|
456915
456967
|
var program2 = new Command;
|
|
456916
456968
|
program2.name("tsci").description("CLI for developing tscircuit snippets").version(getVersion());
|
|
@@ -456926,6 +456978,7 @@ registerAuthSetToken(program2);
|
|
|
456926
456978
|
registerConfig(program2);
|
|
456927
456979
|
registerConfigPrint(program2);
|
|
456928
456980
|
registerExport(program2);
|
|
456981
|
+
registerAdd(program2);
|
|
456929
456982
|
if (process.argv.length === 2) {
|
|
456930
456983
|
import_perfect_cli.perfectCli(program2, process.argv);
|
|
456931
456984
|
} else {
|