@tscircuit/cli 0.1.555 → 0.1.556

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/main.js +31 -23
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -108,4 +108,4 @@ runframe each time you'd like to load a new version of runframe.
108
108
  export RUNFRAME_STANDALONE_FILE_PATH=../runframe/dist/standalone.min.js
109
109
  cd ../runframe && bun run build
110
110
  cd ../cli && bun run dev
111
- ```
111
+ ```
package/dist/main.js CHANGED
@@ -72387,7 +72387,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
72387
72387
  import { execSync as execSync2 } from "node:child_process";
72388
72388
  var import_semver2 = __toESM2(require_semver2(), 1);
72389
72389
  // package.json
72390
- var version = "0.1.554";
72390
+ var version = "0.1.555";
72391
72391
  var package_default = {
72392
72392
  name: "@tscircuit/cli",
72393
72393
  version,
@@ -77036,25 +77036,32 @@ async function resolveTarballUrlFromRegistry(packageName) {
77036
77036
  }
77037
77037
 
77038
77038
  // lib/shared/add-package.ts
77039
- function normalizePackageNameToNpm(componentPath) {
77040
- if (componentPath.startsWith("@tscircuit/")) {
77041
- return componentPath;
77042
- } else if (componentPath.startsWith("@tsci/")) {
77043
- return componentPath;
77044
- } else {
77045
- const match = componentPath.match(/^([^/.]+)[/.](.+)$/);
77046
- if (!match) {
77047
- throw new Error("Invalid component path. Use format: author/component-name, author.component-name, @tscircuit/package-name, or @tsci/author.component-name");
77048
- }
77039
+ function normalizeTscircuitPackageName(packageSpec) {
77040
+ if (packageSpec.startsWith("@tscircuit/") || packageSpec.startsWith("@tsci/")) {
77041
+ return packageSpec;
77042
+ }
77043
+ if (packageSpec.startsWith("http://") || packageSpec.startsWith("https://") || packageSpec.startsWith("git+") || packageSpec.startsWith("git://")) {
77044
+ return null;
77045
+ }
77046
+ if (packageSpec.includes("@") && !packageSpec.startsWith("@")) {
77047
+ return null;
77048
+ }
77049
+ if (packageSpec.startsWith("@") && !packageSpec.startsWith("@tsci/") && !packageSpec.startsWith("@tscircuit/")) {
77050
+ return null;
77051
+ }
77052
+ const match = packageSpec.match(/^([^/.@]+)[/.]([^/.@]+)$/);
77053
+ if (match) {
77049
77054
  const [, author, componentName] = match;
77050
77055
  return `@tsci/${author}.${componentName}`;
77051
77056
  }
77057
+ return null;
77052
77058
  }
77053
- async function addPackage(componentPath, projectDir = process.cwd()) {
77054
- const packageName = normalizePackageNameToNpm(componentPath);
77055
- console.log(`Adding ${packageName}...`);
77056
- let installTarget = packageName;
77057
- if (packageName.startsWith("@tsci/")) {
77059
+ async function addPackage(packageSpec, projectDir = process.cwd()) {
77060
+ const normalizedName = normalizeTscircuitPackageName(packageSpec);
77061
+ const displayName = normalizedName || packageSpec;
77062
+ let installTarget = normalizedName || packageSpec;
77063
+ console.log(`Adding ${displayName}...`);
77064
+ if (normalizedName && normalizedName.startsWith("@tsci/")) {
77058
77065
  const npmrcPath = path17.join(projectDir, ".npmrc");
77059
77066
  const npmrcContent = fs17.existsSync(npmrcPath) ? fs17.readFileSync(npmrcPath, "utf-8") : "";
77060
77067
  let hasTsciRegistry = /@tsci[/:]/.test(npmrcContent);
@@ -77078,17 +77085,17 @@ async function addPackage(componentPath, projectDir = process.cwd()) {
77078
77085
  }
77079
77086
  }
77080
77087
  if (!hasTsciRegistry) {
77081
- installTarget = await resolveTarballUrlFromRegistry(packageName);
77088
+ installTarget = await resolveTarballUrlFromRegistry(normalizedName);
77082
77089
  }
77083
77090
  }
77084
77091
  const packageManager = getPackageManager();
77085
77092
  try {
77086
77093
  packageManager.install({ name: installTarget, cwd: projectDir });
77087
- console.log(`Added ${packageName} successfully.`);
77094
+ console.log(`Added ${displayName} successfully.`);
77088
77095
  } catch (error) {
77089
77096
  const errorMessage = error instanceof Error ? error.message : String(error);
77090
- console.error(`Failed to add ${packageName}:`, errorMessage);
77091
- throw new Error(`Failed to add ${packageName}: ${errorMessage}`);
77097
+ console.error(`Failed to add ${displayName}:`, errorMessage);
77098
+ throw new Error(`Failed to add ${displayName}: ${errorMessage}`);
77092
77099
  }
77093
77100
  }
77094
77101
 
@@ -95044,9 +95051,9 @@ var registerPush = (program3) => {
95044
95051
 
95045
95052
  // cli/add/register.ts
95046
95053
  var registerAdd = (program3) => {
95047
- program3.command("add").description("Add a tscircuit component package to your project").argument("<component>", "Component to add (e.g. author/component-name)").action(async (componentPath) => {
95054
+ program3.command("add").description("Add a tscircuit component package to your project").argument("<packageSpec>", "Package to add (e.g. package-name, author/component, https://github.com/user/repo, package@version)").action(async (packageSpec) => {
95048
95055
  try {
95049
- await addPackage(componentPath);
95056
+ await addPackage(packageSpec);
95050
95057
  } catch (error) {
95051
95058
  process.exit(1);
95052
95059
  }
@@ -196251,7 +196258,8 @@ var registerImport = (program3) => {
196251
196258
 
196252
196259
  // lib/shared/remove-package.ts
196253
196260
  async function removePackage(componentPath, projectDir = process.cwd()) {
196254
- const packageName = normalizePackageNameToNpm(componentPath);
196261
+ const normalizedName = normalizeTscircuitPackageName(componentPath);
196262
+ const packageName = normalizedName || componentPath;
196255
196263
  console.log(`Removing ${packageName}...`);
196256
196264
  const packageManager = getPackageManager();
196257
196265
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.555",
3
+ "version": "0.1.556",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",