@tscircuit/cli 0.1.2372 → 0.1.2373

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/cli/main.js CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/cli/main.js
3
- size: 46949794 bytes
4
- sha256: 468eebf1113937d85bb431a271613806edb8f6d86d4b81da247eb21c18eef48a
3
+ size: 46951130 bytes
4
+ sha256: 7f0d1c6ae9572d5bfb510f1606d5e4f75c4dccfaf186e1258acf21b60b62cce3
package/dist/lib/index.js CHANGED
@@ -69121,7 +69121,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
69121
69121
  }));
69122
69122
  };
69123
69123
  // package.json
69124
- var version = "0.1.2368";
69124
+ var version = "0.1.2371";
69125
69125
  var package_default = {
69126
69126
  name: "@tscircuit/cli",
69127
69127
  version,
@@ -69144,7 +69144,7 @@ var package_default = {
69144
69144
  "@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.68.tgz",
69145
69145
  "@tscircuit/circuit-json-util": "^0.0.121",
69146
69146
  "@tscircuit/eval": "0.0.1619",
69147
- "@tscircuit/fake-snippets": "^0.0.182",
69147
+ "@tscircuit/fake-snippets": "^0.0.226",
69148
69148
  "@tscircuit/file-server": "^0.0.32",
69149
69149
  "@tscircuit/footprinter": "^0.0.438",
69150
69150
  "@tscircuit/image-utils": "^0.0.8",
@@ -69205,6 +69205,7 @@ var package_default = {
69205
69205
  ky: "^1.7.4",
69206
69206
  "make-vfs": "^1.0.15",
69207
69207
  md5: "^2.3.0",
69208
+ "mime-types": "^3.0.2",
69208
69209
  "pdf-lib": "^1.17.1",
69209
69210
  "perfect-cli": "^1.0.21",
69210
69211
  playwright: "^1.57.0",
@@ -84773,19 +84774,19 @@ var findPushProject = async ({
84773
84774
  }) ?? undefined;
84774
84775
  return { snippetFilePath, packageJsonPath, projectDir };
84775
84776
  };
84776
- var getArchivePayload = (filePaths, projectDir, packageNameWithVersion) => {
84777
- const files = filePaths.map((fullFilePath) => {
84778
- const relativeFilePath = path28.relative(projectDir, fullFilePath);
84779
- const fileBuffer = fs24.readFileSync(fullFilePath);
84780
- const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
84781
- return isBinary ? {
84782
- file_path: relativeFilePath,
84783
- content_base64: fileBuffer.toString("base64")
84784
- } : {
84785
- file_path: relativeFilePath,
84786
- content_text: fileBuffer.toString("utf8")
84787
- };
84788
- });
84777
+ var getUploadFiles = (filePaths, projectDir) => filePaths.map((fullFilePath) => {
84778
+ const relativeFilePath = path28.relative(projectDir, fullFilePath).split(path28.sep).join("/");
84779
+ const fileBuffer = fs24.readFileSync(fullFilePath);
84780
+ const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
84781
+ return isBinary ? {
84782
+ file_path: relativeFilePath,
84783
+ content_base64: fileBuffer.toString("base64")
84784
+ } : {
84785
+ file_path: relativeFilePath,
84786
+ content_text: fileBuffer.toString("utf8")
84787
+ };
84788
+ });
84789
+ var createArchivePayload = (files, packageNameWithVersion) => {
84789
84790
  const archive = gzipSync(JSON.stringify({ files }), { level: 9 });
84790
84791
  return {
84791
84792
  package_name_with_version: packageNameWithVersion,
@@ -84992,53 +84993,79 @@ var pushSnippet = async ({
84992
84993
  const filePaths = getPackageFilePaths(projectDir, includeDist ? [] : ["**/dist/**"]);
84993
84994
  const uploadResults = { succeeded: [], failed: [] };
84994
84995
  const packageNameWithVersion = `${scopedPackageName}@${releaseVersion}`;
84996
+ const files = getUploadFiles(filePaths, projectDir);
84997
+ let filesToUpload = files;
84995
84998
  if (compress) {
84996
84999
  log(kleur_default.gray("Uploading package archive..."));
84997
85000
  try {
84998
- const archivePayload = getArchivePayload(filePaths, projectDir, packageNameWithVersion);
85001
+ const archivePayload = createArchivePayload(files, packageNameWithVersion);
84999
85002
  await ky.post("package_files/upload_archive", {
85000
85003
  json: archivePayload
85001
85004
  });
85002
- for (const fullFilePath of filePaths) {
85003
- const relativeFilePath = path28.relative(projectDir, fullFilePath);
85004
- uploadResults.succeeded.push(relativeFilePath);
85005
+ for (const file of files) {
85006
+ uploadResults.succeeded.push(file.file_path);
85005
85007
  }
85008
+ filesToUpload = [];
85006
85009
  log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
85007
85010
  } catch (error) {
85008
- log(kleur_default.yellow(`Archive upload failed, falling back to file-by-file upload: ${error}`));
85009
- }
85010
- }
85011
- if (uploadResults.succeeded.length === 0) {
85012
- for (const fullFilePath of filePaths) {
85013
- const relativeFilePath = path28.relative(projectDir, fullFilePath);
85014
- const fileBuffer = fs24.readFileSync(fullFilePath);
85015
- const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
85016
- const payload = {
85017
- file_path: relativeFilePath,
85018
- package_name_with_version: packageNameWithVersion
85019
- };
85020
- if (isBinary) {
85021
- payload.content_base64 = fileBuffer.toString("base64");
85011
+ const status = error?.response?.status;
85012
+ if (status === undefined || status === 408 || status >= 500) {
85013
+ log(kleur_default.yellow(`Archive upload outcome unknown, checking release files: ${error}`));
85014
+ try {
85015
+ const { package_files: remoteFiles } = await ky.get("package_files/list", {
85016
+ searchParams: {
85017
+ package_name_with_version: packageNameWithVersion
85018
+ }
85019
+ }).json();
85020
+ const remoteIds = new Map(remoteFiles.map((file) => [file.file_path, file.package_file_id]));
85021
+ filesToUpload = [];
85022
+ for (const file of files) {
85023
+ const remoteId = remoteIds.get(file.file_path);
85024
+ if (remoteId) {
85025
+ const remoteContent = await ky.get("package_files/download", {
85026
+ searchParams: { package_file_id: remoteId }
85027
+ }).arrayBuffer();
85028
+ const localContent = file.content_base64 !== undefined ? Buffer.from(file.content_base64, "base64") : Buffer.from(file.content_text, "utf8");
85029
+ if (localContent.equals(Buffer.from(remoteContent))) {
85030
+ uploadResults.succeeded.push(file.file_path);
85031
+ continue;
85032
+ }
85033
+ }
85034
+ filesToUpload.push(file);
85035
+ }
85036
+ log(kleur_default.gray(`Verified ${uploadResults.succeeded.length} archive files; ${filesToUpload.length} files still need uploading`));
85037
+ } catch (verificationError) {
85038
+ onError(`Could not verify archive upload outcome: ${verificationError}. No files were retransmitted; check ${packageNameWithVersion} before retrying.`);
85039
+ return onExit(1);
85040
+ }
85022
85041
  } else {
85023
- payload.content_text = fileBuffer.toString("utf-8");
85042
+ log(kleur_default.yellow(`Archive upload failed, falling back to file-by-file upload: ${error}`));
85024
85043
  }
85025
- await ky.post("package_files/create", {
85026
- json: payload
85027
- }).then(() => {
85028
- const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
85029
- console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
85030
- uploadResults.succeeded.push(relativeFilePath);
85031
- }).catch(async (error) => {
85032
- const errorDetails = String(error)?.split(`
85044
+ }
85045
+ }
85046
+ for (const file of filesToUpload) {
85047
+ const relativeFilePath = file.file_path;
85048
+ const isBinary = file.content_base64 !== undefined;
85049
+ const payload = {
85050
+ ...file,
85051
+ package_name_with_version: packageNameWithVersion
85052
+ };
85053
+ await ky.post("package_files/create", {
85054
+ json: payload
85055
+ }).then(() => {
85056
+ const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
85057
+ console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
85058
+ uploadResults.succeeded.push(relativeFilePath);
85059
+ }).catch(async (error) => {
85060
+ const errorDetails = String(error)?.split(`
85033
85061
 
85034
85062
  Request Body:`)?.[0];
85035
- console.log(kleur_default.red(` ${relativeFilePath} - failed`));
85036
- uploadResults.failed.push({
85037
- file: relativeFilePath,
85038
- error: errorDetails
85039
- });
85063
+ console.log(kleur_default.red(` ${relativeFilePath} - failed`));
85064
+ uploadResults.failed.push({
85065
+ file: relativeFilePath,
85066
+ error: errorDetails
85040
85067
  });
85041
- }
85068
+ });
85042
85069
  }
85043
85070
  log(`
85044
85071
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.2372",
3
+ "version": "0.1.2373",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tscircuit/cli"
@@ -20,7 +20,7 @@
20
20
  "@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.68.tgz",
21
21
  "@tscircuit/circuit-json-util": "^0.0.121",
22
22
  "@tscircuit/eval": "0.0.1619",
23
- "@tscircuit/fake-snippets": "^0.0.182",
23
+ "@tscircuit/fake-snippets": "^0.0.226",
24
24
  "@tscircuit/file-server": "^0.0.32",
25
25
  "@tscircuit/footprinter": "^0.0.438",
26
26
  "@tscircuit/image-utils": "^0.0.8",
@@ -81,6 +81,7 @@
81
81
  "ky": "^1.7.4",
82
82
  "make-vfs": "^1.0.15",
83
83
  "md5": "^2.3.0",
84
+ "mime-types": "^3.0.2",
84
85
  "pdf-lib": "^1.17.1",
85
86
  "perfect-cli": "^1.0.21",
86
87
  "playwright": "^1.57.0",