@tscircuit/cli 0.1.970 → 0.1.972

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/cli/main.js +74 -30
  2. package/package.json +1 -1
package/dist/cli/main.js CHANGED
@@ -71991,6 +71991,12 @@ var shouldBeInteractive = () => {
71991
71991
  return false;
71992
71992
  if (process.env.TSCI_TEST_MODE)
71993
71993
  return false;
71994
+ if (process.argv.includes("--non-interactive"))
71995
+ return false;
71996
+ if (process.env.TSCIRCUIT_NON_INTERACTIVE === "1")
71997
+ return false;
71998
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
71999
+ return false;
71994
72000
  return true;
71995
72001
  };
71996
72002
 
@@ -72002,7 +72008,7 @@ var prompts = (...args) => {
72002
72008
  const result = {};
72003
72009
  promptArray.forEach((prompt) => {
72004
72010
  if (prompt.type === "confirm") {
72005
- result[prompt.name] = prompt.initial ?? true;
72011
+ result[prompt.name] = true;
72006
72012
  return;
72007
72013
  } else if (prompt.initial) {
72008
72014
  result[prompt.name] = prompt.initial;
@@ -83455,7 +83461,25 @@ var hasBinaryContent = (content) => {
83455
83461
  };
83456
83462
 
83457
83463
  // lib/shared/push-snippet.ts
83464
+ var import_jszip2 = __toESM2(require_lib4(), 1);
83458
83465
  var debug = Debug("tsci:push-snippet");
83466
+ var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
83467
+ const zip = new import_jszip2.default;
83468
+ for (const fullFilePath of filePaths) {
83469
+ const relativeFilePath = path24.relative(projectDir, fullFilePath);
83470
+ zip.file(relativeFilePath, fs22.readFileSync(fullFilePath));
83471
+ }
83472
+ const archive = await zip.generateAsync({
83473
+ type: "uint8array",
83474
+ compression: "DEFLATE",
83475
+ compressionOptions: { level: 9 }
83476
+ });
83477
+ return {
83478
+ package_name_with_version: packageNameWithVersion,
83479
+ archive_base64: Buffer.from(archive).toString("base64"),
83480
+ archive_format: "zip"
83481
+ };
83482
+ };
83459
83483
  var pushSnippet = async ({
83460
83484
  filePath,
83461
83485
  isPrivate,
@@ -83667,35 +83691,55 @@ var pushSnippet = async ({
83667
83691
  });
83668
83692
  const filePaths = getPackageFilePaths(projectDir, includeDist ? [] : ["**/dist/**"]);
83669
83693
  const uploadResults = { succeeded: [], failed: [] };
83670
- for (const fullFilePath of filePaths) {
83671
- const relativeFilePath = path24.relative(projectDir, fullFilePath);
83672
- const fileBuffer = fs22.readFileSync(fullFilePath);
83673
- const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
83674
- const payload = {
83675
- file_path: relativeFilePath,
83676
- package_name_with_version: `${scopedPackageName}@${releaseVersion}`
83677
- };
83678
- if (isBinary) {
83679
- payload.content_base64 = fileBuffer.toString("base64");
83680
- } else {
83681
- payload.content_text = fileBuffer.toString("utf-8");
83694
+ const packageNameWithVersion = `${scopedPackageName}@${releaseVersion}`;
83695
+ const shouldUploadArchive = process.env.TSCI_PUSH_ARCHIVE === "1";
83696
+ if (shouldUploadArchive) {
83697
+ log(kleur_default.gray("Uploading package archive..."));
83698
+ try {
83699
+ const archivePayload = await getArchivePayload(filePaths, projectDir, packageNameWithVersion);
83700
+ await ky2.post("package_files/upload_archive", {
83701
+ json: archivePayload
83702
+ });
83703
+ for (const fullFilePath of filePaths) {
83704
+ const relativeFilePath = path24.relative(projectDir, fullFilePath);
83705
+ uploadResults.succeeded.push(relativeFilePath);
83706
+ }
83707
+ log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
83708
+ } catch (error) {
83709
+ log(kleur_default.yellow(`Archive upload failed, falling back to file-by-file upload: ${error}`));
83682
83710
  }
83683
- await ky2.post("package_files/create", {
83684
- json: payload
83685
- }).then(() => {
83686
- const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
83687
- console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
83688
- uploadResults.succeeded.push(relativeFilePath);
83689
- }).catch(async (error) => {
83690
- const errorDetails = String(error)?.split(`
83711
+ }
83712
+ if (uploadResults.succeeded.length === 0) {
83713
+ for (const fullFilePath of filePaths) {
83714
+ const relativeFilePath = path24.relative(projectDir, fullFilePath);
83715
+ const fileBuffer = fs22.readFileSync(fullFilePath);
83716
+ const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
83717
+ const payload = {
83718
+ file_path: relativeFilePath,
83719
+ package_name_with_version: packageNameWithVersion
83720
+ };
83721
+ if (isBinary) {
83722
+ payload.content_base64 = fileBuffer.toString("base64");
83723
+ } else {
83724
+ payload.content_text = fileBuffer.toString("utf-8");
83725
+ }
83726
+ await ky2.post("package_files/create", {
83727
+ json: payload
83728
+ }).then(() => {
83729
+ const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
83730
+ console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
83731
+ uploadResults.succeeded.push(relativeFilePath);
83732
+ }).catch(async (error) => {
83733
+ const errorDetails = String(error)?.split(`
83691
83734
 
83692
83735
  Request Body:`)?.[0];
83693
- console.log(kleur_default.red(` ${relativeFilePath} - failed`));
83694
- uploadResults.failed.push({
83695
- file: relativeFilePath,
83696
- error: errorDetails
83736
+ console.log(kleur_default.red(` ${relativeFilePath} - failed`));
83737
+ uploadResults.failed.push({
83738
+ file: relativeFilePath,
83739
+ error: errorDetails
83740
+ });
83697
83741
  });
83698
- });
83742
+ }
83699
83743
  }
83700
83744
  log(`
83701
83745
  `);
@@ -85049,7 +85093,7 @@ import * as fs33 from "node:fs";
85049
85093
  import * as path35 from "node:path";
85050
85094
 
85051
85095
  // cli/clone/clone-bug-report.ts
85052
- var import_jszip2 = __toESM2(require_lib4(), 1);
85096
+ var import_jszip3 = __toESM2(require_lib4(), 1);
85053
85097
  var import_prompts8 = __toESM2(require_prompts3(), 1);
85054
85098
  import * as fs32 from "node:fs";
85055
85099
  import * as path34 from "node:path";
@@ -85144,7 +85188,7 @@ var cloneBugReport = async ({
85144
85188
  process.exit(1);
85145
85189
  }
85146
85190
  fs32.mkdirSync(dirPath, { recursive: true });
85147
- const zip = await import_jszip2.default.loadAsync(zipBuffer);
85191
+ const zip = await import_jszip3.default.loadAsync(zipBuffer);
85148
85192
  const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
85149
85193
  const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
85150
85194
  for (const [fileName, entry] of fileEntries) {
@@ -86556,7 +86600,7 @@ var debug9 = Debug9("dsn-converter:getViaCoords");
86556
86600
  var debug10 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
86557
86601
 
86558
86602
  // lib/shared/export-snippet.ts
86559
- var import_jszip3 = __toESM2(require_lib4(), 1);
86603
+ var import_jszip4 = __toESM2(require_lib4(), 1);
86560
86604
 
86561
86605
  // lib/shared/generate-circuit-json.tsx
86562
86606
  var import_make_vfs2 = __toESM2(require_dist8(), 1);
@@ -86783,7 +86827,7 @@ var exportSnippet = async ({
86783
86827
  schConverter.runUntilFinished();
86784
86828
  const pcbConverter = new CircuitJsonToKicadPcbConverter(circuitData.circuitJson);
86785
86829
  pcbConverter.runUntilFinished();
86786
- const zip = new import_jszip3.default;
86830
+ const zip = new import_jszip4.default;
86787
86831
  zip.file(`${outputBaseName}.kicad_sch`, schConverter.getOutputString());
86788
86832
  zip.file(`${outputBaseName}.kicad_pcb`, pcbConverter.getOutputString());
86789
86833
  outputContent = await zip.generateAsync({ type: "nodebuffer" });
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  ".": "./dist/cli/main.js",
6
6
  "./lib": "./dist/lib/index.js"
7
7
  },
8
- "version": "0.1.970",
8
+ "version": "0.1.972",
9
9
  "devDependencies": {
10
10
  "@babel/standalone": "^7.26.9",
11
11
  "@biomejs/biome": "^1.9.4",