@tscircuit/cli 0.1.214 → 0.1.216

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 (2) hide show
  1. package/dist/main.js +81 -43
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -58202,7 +58202,7 @@ var require_resvgjs_linux_x64_gnu = __commonJS((exports2, module2) => {
58202
58202
  // node_modules/@resvg/resvg-js/js-binding.js
58203
58203
  var require_js_binding = __commonJS((exports2, module2) => {
58204
58204
  var __dirname = "/home/runner/work/cli/cli/node_modules/@resvg/resvg-js";
58205
- var { existsSync: existsSync8, readFileSync: readFileSync7 } = __require("fs");
58205
+ var { existsSync: existsSync9, readFileSync: readFileSync7 } = __require("fs");
58206
58206
  var { join: join12 } = __require("path");
58207
58207
  var { platform, arch } = process;
58208
58208
  var nativeBinding = null;
@@ -58225,7 +58225,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58225
58225
  case "android":
58226
58226
  switch (arch) {
58227
58227
  case "arm64":
58228
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.android-arm64.node"));
58228
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.android-arm64.node"));
58229
58229
  try {
58230
58230
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.android-arm64.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-android-arm64");})();
58231
58231
  } catch (e) {
@@ -58233,7 +58233,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58233
58233
  }
58234
58234
  break;
58235
58235
  case "arm":
58236
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.android-arm-eabi.node"));
58236
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.android-arm-eabi.node"));
58237
58237
  try {
58238
58238
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.android-arm-eabi.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-android-arm-eabi");})();
58239
58239
  } catch (e) {
@@ -58247,7 +58247,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58247
58247
  case "win32":
58248
58248
  switch (arch) {
58249
58249
  case "x64":
58250
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.win32-x64-msvc.node"));
58250
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.win32-x64-msvc.node"));
58251
58251
  try {
58252
58252
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.win32-x64-msvc.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-win32-x64-msvc");})();
58253
58253
  } catch (e) {
@@ -58255,7 +58255,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58255
58255
  }
58256
58256
  break;
58257
58257
  case "ia32":
58258
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.win32-ia32-msvc.node"));
58258
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.win32-ia32-msvc.node"));
58259
58259
  try {
58260
58260
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.win32-ia32-msvc.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-win32-ia32-msvc");})();
58261
58261
  } catch (e) {
@@ -58263,7 +58263,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58263
58263
  }
58264
58264
  break;
58265
58265
  case "arm64":
58266
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.win32-arm64-msvc.node"));
58266
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.win32-arm64-msvc.node"));
58267
58267
  try {
58268
58268
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.win32-arm64-msvc.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-win32-arm64-msvc");})();
58269
58269
  } catch (e) {
@@ -58275,14 +58275,14 @@ var require_js_binding = __commonJS((exports2, module2) => {
58275
58275
  }
58276
58276
  break;
58277
58277
  case "darwin":
58278
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.darwin-universal.node"));
58278
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.darwin-universal.node"));
58279
58279
  try {
58280
58280
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.darwin-universal.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-darwin-universal");})();
58281
58281
  break;
58282
58282
  } catch {}
58283
58283
  switch (arch) {
58284
58284
  case "x64":
58285
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.darwin-x64.node"));
58285
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.darwin-x64.node"));
58286
58286
  try {
58287
58287
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.darwin-x64.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-darwin-x64");})();
58288
58288
  } catch (e) {
@@ -58290,7 +58290,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58290
58290
  }
58291
58291
  break;
58292
58292
  case "arm64":
58293
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.darwin-arm64.node"));
58293
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.darwin-arm64.node"));
58294
58294
  try {
58295
58295
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.darwin-arm64.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-darwin-arm64");})();
58296
58296
  } catch (e) {
@@ -58304,7 +58304,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58304
58304
  case "freebsd":
58305
58305
  if (arch !== "x64")
58306
58306
  throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
58307
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.freebsd-x64.node"));
58307
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.freebsd-x64.node"));
58308
58308
  try {
58309
58309
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.freebsd-x64.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-freebsd-x64");})();
58310
58310
  } catch (e) {
@@ -58315,14 +58315,14 @@ var require_js_binding = __commonJS((exports2, module2) => {
58315
58315
  switch (arch) {
58316
58316
  case "x64":
58317
58317
  if (isMusl()) {
58318
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-x64-musl.node"));
58318
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-x64-musl.node"));
58319
58319
  try {
58320
58320
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-x64-musl.node");})() : nativeBinding = require_resvgjs_linux_x64_musl();
58321
58321
  } catch (e) {
58322
58322
  loadError = e;
58323
58323
  }
58324
58324
  } else {
58325
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-x64-gnu.node"));
58325
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-x64-gnu.node"));
58326
58326
  try {
58327
58327
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-x64-gnu.node");})() : nativeBinding = require_resvgjs_linux_x64_gnu();
58328
58328
  } catch (e) {
@@ -58332,14 +58332,14 @@ var require_js_binding = __commonJS((exports2, module2) => {
58332
58332
  break;
58333
58333
  case "arm64":
58334
58334
  if (isMusl()) {
58335
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-arm64-musl.node"));
58335
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-arm64-musl.node"));
58336
58336
  try {
58337
58337
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-arm64-musl.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-linux-arm64-musl");})();
58338
58338
  } catch (e) {
58339
58339
  loadError = e;
58340
58340
  }
58341
58341
  } else {
58342
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-arm64-gnu.node"));
58342
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-arm64-gnu.node"));
58343
58343
  try {
58344
58344
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-arm64-gnu.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-linux-arm64-gnu");})();
58345
58345
  } catch (e) {
@@ -58348,7 +58348,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58348
58348
  }
58349
58349
  break;
58350
58350
  case "arm":
58351
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-arm-gnueabihf.node"));
58351
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-arm-gnueabihf.node"));
58352
58352
  try {
58353
58353
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-arm-gnueabihf.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-linux-arm-gnueabihf");})();
58354
58354
  } catch (e) {
@@ -58357,14 +58357,14 @@ var require_js_binding = __commonJS((exports2, module2) => {
58357
58357
  break;
58358
58358
  case "riscv64":
58359
58359
  if (isMusl()) {
58360
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-riscv64-musl.node"));
58360
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-riscv64-musl.node"));
58361
58361
  try {
58362
58362
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-riscv64-musl.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-linux-riscv64-musl");})();
58363
58363
  } catch (e) {
58364
58364
  loadError = e;
58365
58365
  }
58366
58366
  } else {
58367
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-riscv64-gnu.node"));
58367
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-riscv64-gnu.node"));
58368
58368
  try {
58369
58369
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-riscv64-gnu.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-linux-riscv64-gnu");})();
58370
58370
  } catch (e) {
@@ -58373,7 +58373,7 @@ var require_js_binding = __commonJS((exports2, module2) => {
58373
58373
  }
58374
58374
  break;
58375
58375
  case "s390x":
58376
- localFileExisted = existsSync8(join12(__dirname, "resvgjs.linux-s390x-gnu.node"));
58376
+ localFileExisted = existsSync9(join12(__dirname, "resvgjs.linux-s390x-gnu.node"));
58377
58377
  try {
58378
58378
  localFileExisted ? nativeBinding = (()=>{throw new Error("Cannot require module "+"./resvgjs.linux-s390x-gnu.node");})() : nativeBinding = (()=>{throw new Error("Cannot require module "+"@resvg/resvg-js-linux-s390x-gnu");})();
58379
58379
  } catch (e) {
@@ -63215,7 +63215,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
63215
63215
  import { execSync as execSync2 } from "node:child_process";
63216
63216
  var import_semver2 = __toESM2(require_semver2(), 1);
63217
63217
  // package.json
63218
- var version = "0.1.213";
63218
+ var version = "0.1.215";
63219
63219
  var package_default = {
63220
63220
  name: "@tscircuit/cli",
63221
63221
  version,
@@ -67982,6 +67982,13 @@ var getVersion = () => {
67982
67982
  };
67983
67983
 
67984
67984
  // cli/dev/register.ts
67985
+ var findSelectableTsxFiles = (projectDir) => {
67986
+ const files = globbySync(["**/*.tsx", "**/*.ts"], {
67987
+ cwd: projectDir,
67988
+ ignore: DEFAULT_IGNORED_PATTERNS
67989
+ });
67990
+ return files.map((file) => path19.resolve(projectDir, file)).filter((file) => fs19.existsSync(file)).sort();
67991
+ };
67985
67992
  var registerDev = (program3) => {
67986
67993
  program3.command("dev").description("Start development server for a package").argument("[file]", "Path to the package file").option("-p, --port <number>", "Port to run server on", "3020").action(async (file, options) => {
67987
67994
  let port = parseInt(options.port);
@@ -68003,7 +68010,7 @@ var registerDev = (program3) => {
68003
68010
  let absolutePath;
68004
68011
  if (file) {
68005
68012
  absolutePath = path19.resolve(file);
68006
- if (!absolutePath.endsWith(".tsx")) {
68013
+ if (!absolutePath.endsWith(".tsx") && !absolutePath.endsWith(".ts")) {
68007
68014
  console.error("Error: Only .tsx files are supported");
68008
68015
  return;
68009
68016
  }
@@ -68015,8 +68022,13 @@ var registerDev = (program3) => {
68015
68022
  absolutePath = entrypointPath;
68016
68023
  console.log("Found entrypoint at:", entrypointPath);
68017
68024
  } else {
68018
- console.log("No entrypoint found. Run 'tsci init' to bootstrap a basic project.");
68019
- return;
68025
+ const availableFiles = findSelectableTsxFiles(process.cwd());
68026
+ if (availableFiles.length === 0) {
68027
+ console.log("No .tsx or .ts files found in the project. Run 'tsci init' to bootstrap a basic project.");
68028
+ return;
68029
+ }
68030
+ absolutePath = availableFiles[0];
68031
+ console.log("Selected file:", path19.relative(process.cwd(), absolutePath));
68020
68032
  }
68021
68033
  }
68022
68034
  try {
@@ -68175,23 +68187,23 @@ var registerConfigPrint = (program3) => {
68175
68187
  import * as fs20 from "node:fs";
68176
68188
  import * as path20 from "node:path";
68177
68189
  var registerClone = (program3) => {
68178
- program3.command("clone").description("Clone a package from the registry").argument("<package>", "Package to clone (e.g. author/packageName or https://tscircuit.com/author/packageName)").option("-a, --include-author", "Include author name in the directory path").action(async (snippetPath, options) => {
68179
- const urlMatch = snippetPath.match(/^https:\/\/tscircuit\.com\/([^\/]+)\/([^\/]+)\/?$/i);
68180
- const originalMatch = !urlMatch && snippetPath.match(/^(?:@tsci\/)?([^/.]+)[/.]([^/.]+)$/);
68190
+ program3.command("clone").description("Clone a package from the registry").argument("<package>", "Package to clone (e.g. author/packageName or https://tscircuit.com/author/packageName)").option("-a, --include-author", "Include author name in the directory path").action(async (packagePath, options) => {
68191
+ const urlMatch = packagePath.match(/^https:\/\/tscircuit\.com\/([^\/]+)\/([^\/]+)\/?$/i);
68192
+ const originalMatch = !urlMatch && packagePath.match(/^(?:@tsci\/)?([^/.]+)[/.]([^/.]+)$/);
68181
68193
  const originalCwd = process.cwd();
68182
68194
  if (!urlMatch && !originalMatch) {
68183
- console.error(`Invalid package path "${snippetPath}". Accepted formats:
68184
- - author/snippetName
68185
- - author.snippetName
68186
- - @tsci/author.snippetName
68187
- - https://tscircuit.com/author/snippetName`);
68195
+ console.error(`Invalid package path "${packagePath}". Accepted formats:
68196
+ - author/packageName
68197
+ - author.packageName
68198
+ - @tsci/author.packageName
68199
+ - https://tscircuit.com/author/packageName`);
68188
68200
  process.exit(1);
68189
68201
  }
68190
68202
  const match = urlMatch || originalMatch;
68191
68203
  if (!match)
68192
68204
  throw new Error("No valid match found");
68193
- const [, author, snippetName] = match;
68194
- console.log(`Cloning ${author}/${snippetName}...`);
68205
+ const [, author, packageName] = match;
68206
+ console.log(`Cloning ${author}/${packageName}...`);
68195
68207
  const ky2 = getRegistryApiKy();
68196
68208
  let packageFileList = {
68197
68209
  package_files: []
@@ -68199,20 +68211,46 @@ var registerClone = (program3) => {
68199
68211
  try {
68200
68212
  packageFileList = await ky2.post("package_files/list", {
68201
68213
  json: {
68202
- package_name: `${author}/${snippetName}`,
68214
+ package_name: `${author}/${packageName}`,
68203
68215
  use_latest_version: true
68204
68216
  }
68205
68217
  }).json();
68206
68218
  } catch (error) {
68207
68219
  if (typeof error === "object" && error !== null && "response" in error && typeof error.response === "object" && error.response?.status === 404) {
68208
- console.error(`Snippet "${author}/${snippetName}" not found. Please check the name and try again.`);
68220
+ console.error(`Package "${author}/${packageName}" not found. Please check the name and try again.`);
68209
68221
  process.exit(1);
68210
68222
  }
68211
68223
  console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
68212
68224
  process.exit(1);
68213
68225
  }
68214
68226
  const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
68215
- const dirPath = userSettingToIncludeAuthor ? path20.resolve(`${author}.${snippetName}`) : path20.resolve(snippetName);
68227
+ const dirPath = userSettingToIncludeAuthor ? path20.resolve(`${author}.${packageName}`) : path20.resolve(packageName);
68228
+ if (fs20.existsSync(dirPath)) {
68229
+ const prompts2 = await Promise.resolve().then(() => __toESM2(require_prompts3(), 1));
68230
+ const response = await prompts2.default({
68231
+ type: "select",
68232
+ name: "action",
68233
+ message: `Directory "${path20.basename(dirPath)}" already exists. What would you like to do?`,
68234
+ choices: [
68235
+ { title: "Merge files into existing directory", value: "merge" },
68236
+ {
68237
+ title: "Delete existing directory and clone fresh",
68238
+ value: "delete"
68239
+ },
68240
+ { title: "Cancel", value: "cancel" }
68241
+ ]
68242
+ });
68243
+ if (!response.action || response.action === "cancel") {
68244
+ console.log("Clone cancelled.");
68245
+ process.exit(0);
68246
+ }
68247
+ if (response.action === "delete") {
68248
+ fs20.rmSync(dirPath, { recursive: true, force: true });
68249
+ console.log(`Deleted existing directory: ${dirPath}`);
68250
+ } else if (response.action === "merge") {
68251
+ console.log(`Merging files into existing directory: ${dirPath}`);
68252
+ }
68253
+ }
68216
68254
  fs20.mkdirSync(dirPath, { recursive: true });
68217
68255
  for (const fileInfo of packageFileList.package_files) {
68218
68256
  const filePath = fileInfo.file_path.replace(/^\/|dist\//g, "");
@@ -68223,7 +68261,7 @@ var registerClone = (program3) => {
68223
68261
  try {
68224
68262
  const fileContent = await ky2.post("package_files/get", {
68225
68263
  json: {
68226
- package_name: `${author}/${snippetName}`,
68264
+ package_name: `${author}/${packageName}`,
68227
68265
  file_path: fileInfo.file_path
68228
68266
  }
68229
68267
  }).json();
@@ -71317,7 +71355,7 @@ var debug10 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
71317
71355
  // lib/shared/generate-circuit-json.tsx
71318
71356
  var import_make_vfs2 = __toESM2(require_dist8(), 1);
71319
71357
  import path21 from "node:path/posix";
71320
- import { relative as relative7 } from "node:path";
71358
+ import { relative as relative8 } from "node:path";
71321
71359
  import fs21 from "node:fs";
71322
71360
  import Debug11 from "debug";
71323
71361
 
@@ -71379,7 +71417,7 @@ async function generateCircuitJson({
71379
71417
  });
71380
71418
  const projectDir = path21.dirname(filePath);
71381
71419
  const resolvedOutputDir = outputDir || projectDir;
71382
- const relativeComponentPath = relative7(projectDir, filePath);
71420
+ const relativeComponentPath = relative8(projectDir, filePath);
71383
71421
  const baseFileName = outputFileName || path21.basename(filePath).replace(/\.[^.]+$/, "");
71384
71422
  const outputPath = path21.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
71385
71423
  debug11(`Project directory: ${projectDir}`);
@@ -119158,10 +119196,10 @@ function compareDocumentPosition(nodeA, nodeB) {
119158
119196
  function uniqueSort(nodes) {
119159
119197
  nodes = nodes.filter((node, i, arr) => !arr.includes(node, i + 1));
119160
119198
  nodes.sort((a, b3) => {
119161
- const relative8 = compareDocumentPosition(a, b3);
119162
- if (relative8 & DocumentPosition.PRECEDING) {
119199
+ const relative9 = compareDocumentPosition(a, b3);
119200
+ if (relative9 & DocumentPosition.PRECEDING) {
119163
119201
  return -1;
119164
- } else if (relative8 & DocumentPosition.FOLLOWING) {
119202
+ } else if (relative9 & DocumentPosition.FOLLOWING) {
119165
119203
  return 1;
119166
119204
  }
119167
119205
  return 0;
@@ -172911,8 +172949,8 @@ var registerBuild = (program3) => {
172911
172949
  fs27.mkdirSync(distDir, { recursive: true });
172912
172950
  let hasErrors = false;
172913
172951
  for (const filePath of circuitFiles) {
172914
- const relative8 = path26.relative(projectDir, filePath);
172915
- const outputDirName = relative8.replace(/(\.board|\.circuit)?\.tsx$/, "");
172952
+ const relative9 = path26.relative(projectDir, filePath);
172953
+ const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
172916
172954
  const outputPath = path26.join(distDir, outputDirName, "circuit.json");
172917
172955
  const ok = await buildFile(filePath, outputPath, projectDir, options);
172918
172956
  if (!ok)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.214",
3
+ "version": "0.1.216",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",