@tscircuit/cli 0.1.970 → 0.1.971
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 +67 -29
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -83455,7 +83455,25 @@ var hasBinaryContent = (content) => {
|
|
|
83455
83455
|
};
|
|
83456
83456
|
|
|
83457
83457
|
// lib/shared/push-snippet.ts
|
|
83458
|
+
var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
83458
83459
|
var debug = Debug("tsci:push-snippet");
|
|
83460
|
+
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
83461
|
+
const zip = new import_jszip2.default;
|
|
83462
|
+
for (const fullFilePath of filePaths) {
|
|
83463
|
+
const relativeFilePath = path24.relative(projectDir, fullFilePath);
|
|
83464
|
+
zip.file(relativeFilePath, fs22.readFileSync(fullFilePath));
|
|
83465
|
+
}
|
|
83466
|
+
const archive = await zip.generateAsync({
|
|
83467
|
+
type: "uint8array",
|
|
83468
|
+
compression: "DEFLATE",
|
|
83469
|
+
compressionOptions: { level: 9 }
|
|
83470
|
+
});
|
|
83471
|
+
return {
|
|
83472
|
+
package_name_with_version: packageNameWithVersion,
|
|
83473
|
+
archive_base64: Buffer.from(archive).toString("base64"),
|
|
83474
|
+
archive_format: "zip"
|
|
83475
|
+
};
|
|
83476
|
+
};
|
|
83459
83477
|
var pushSnippet = async ({
|
|
83460
83478
|
filePath,
|
|
83461
83479
|
isPrivate,
|
|
@@ -83667,35 +83685,55 @@ var pushSnippet = async ({
|
|
|
83667
83685
|
});
|
|
83668
83686
|
const filePaths = getPackageFilePaths(projectDir, includeDist ? [] : ["**/dist/**"]);
|
|
83669
83687
|
const uploadResults = { succeeded: [], failed: [] };
|
|
83670
|
-
|
|
83671
|
-
|
|
83672
|
-
|
|
83673
|
-
|
|
83674
|
-
|
|
83675
|
-
|
|
83676
|
-
|
|
83677
|
-
|
|
83678
|
-
|
|
83679
|
-
|
|
83680
|
-
|
|
83681
|
-
|
|
83688
|
+
const packageNameWithVersion = `${scopedPackageName}@${releaseVersion}`;
|
|
83689
|
+
const shouldUploadArchive = process.env.TSCI_PUSH_ARCHIVE === "1";
|
|
83690
|
+
if (shouldUploadArchive) {
|
|
83691
|
+
log(kleur_default.gray("Uploading package archive..."));
|
|
83692
|
+
try {
|
|
83693
|
+
const archivePayload = await getArchivePayload(filePaths, projectDir, packageNameWithVersion);
|
|
83694
|
+
await ky2.post("package_files/upload_archive", {
|
|
83695
|
+
json: archivePayload
|
|
83696
|
+
});
|
|
83697
|
+
for (const fullFilePath of filePaths) {
|
|
83698
|
+
const relativeFilePath = path24.relative(projectDir, fullFilePath);
|
|
83699
|
+
uploadResults.succeeded.push(relativeFilePath);
|
|
83700
|
+
}
|
|
83701
|
+
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
83702
|
+
} catch (error) {
|
|
83703
|
+
log(kleur_default.yellow(`Archive upload failed, falling back to file-by-file upload: ${error}`));
|
|
83682
83704
|
}
|
|
83683
|
-
|
|
83684
|
-
|
|
83685
|
-
|
|
83686
|
-
const
|
|
83687
|
-
|
|
83688
|
-
|
|
83689
|
-
|
|
83690
|
-
|
|
83705
|
+
}
|
|
83706
|
+
if (uploadResults.succeeded.length === 0) {
|
|
83707
|
+
for (const fullFilePath of filePaths) {
|
|
83708
|
+
const relativeFilePath = path24.relative(projectDir, fullFilePath);
|
|
83709
|
+
const fileBuffer = fs22.readFileSync(fullFilePath);
|
|
83710
|
+
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
83711
|
+
const payload = {
|
|
83712
|
+
file_path: relativeFilePath,
|
|
83713
|
+
package_name_with_version: packageNameWithVersion
|
|
83714
|
+
};
|
|
83715
|
+
if (isBinary) {
|
|
83716
|
+
payload.content_base64 = fileBuffer.toString("base64");
|
|
83717
|
+
} else {
|
|
83718
|
+
payload.content_text = fileBuffer.toString("utf-8");
|
|
83719
|
+
}
|
|
83720
|
+
await ky2.post("package_files/create", {
|
|
83721
|
+
json: payload
|
|
83722
|
+
}).then(() => {
|
|
83723
|
+
const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
|
|
83724
|
+
console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
|
|
83725
|
+
uploadResults.succeeded.push(relativeFilePath);
|
|
83726
|
+
}).catch(async (error) => {
|
|
83727
|
+
const errorDetails = String(error)?.split(`
|
|
83691
83728
|
|
|
83692
83729
|
Request Body:`)?.[0];
|
|
83693
|
-
|
|
83694
|
-
|
|
83695
|
-
|
|
83696
|
-
|
|
83730
|
+
console.log(kleur_default.red(` ${relativeFilePath} - failed`));
|
|
83731
|
+
uploadResults.failed.push({
|
|
83732
|
+
file: relativeFilePath,
|
|
83733
|
+
error: errorDetails
|
|
83734
|
+
});
|
|
83697
83735
|
});
|
|
83698
|
-
}
|
|
83736
|
+
}
|
|
83699
83737
|
}
|
|
83700
83738
|
log(`
|
|
83701
83739
|
`);
|
|
@@ -85049,7 +85087,7 @@ import * as fs33 from "node:fs";
|
|
|
85049
85087
|
import * as path35 from "node:path";
|
|
85050
85088
|
|
|
85051
85089
|
// cli/clone/clone-bug-report.ts
|
|
85052
|
-
var
|
|
85090
|
+
var import_jszip3 = __toESM2(require_lib4(), 1);
|
|
85053
85091
|
var import_prompts8 = __toESM2(require_prompts3(), 1);
|
|
85054
85092
|
import * as fs32 from "node:fs";
|
|
85055
85093
|
import * as path34 from "node:path";
|
|
@@ -85144,7 +85182,7 @@ var cloneBugReport = async ({
|
|
|
85144
85182
|
process.exit(1);
|
|
85145
85183
|
}
|
|
85146
85184
|
fs32.mkdirSync(dirPath, { recursive: true });
|
|
85147
|
-
const zip = await
|
|
85185
|
+
const zip = await import_jszip3.default.loadAsync(zipBuffer);
|
|
85148
85186
|
const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
|
|
85149
85187
|
const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
|
|
85150
85188
|
for (const [fileName, entry] of fileEntries) {
|
|
@@ -86556,7 +86594,7 @@ var debug9 = Debug9("dsn-converter:getViaCoords");
|
|
|
86556
86594
|
var debug10 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
|
|
86557
86595
|
|
|
86558
86596
|
// lib/shared/export-snippet.ts
|
|
86559
|
-
var
|
|
86597
|
+
var import_jszip4 = __toESM2(require_lib4(), 1);
|
|
86560
86598
|
|
|
86561
86599
|
// lib/shared/generate-circuit-json.tsx
|
|
86562
86600
|
var import_make_vfs2 = __toESM2(require_dist8(), 1);
|
|
@@ -86783,7 +86821,7 @@ var exportSnippet = async ({
|
|
|
86783
86821
|
schConverter.runUntilFinished();
|
|
86784
86822
|
const pcbConverter = new CircuitJsonToKicadPcbConverter(circuitData.circuitJson);
|
|
86785
86823
|
pcbConverter.runUntilFinished();
|
|
86786
|
-
const zip = new
|
|
86824
|
+
const zip = new import_jszip4.default;
|
|
86787
86825
|
zip.file(`${outputBaseName}.kicad_sch`, schConverter.getOutputString());
|
|
86788
86826
|
zip.file(`${outputBaseName}.kicad_pcb`, pcbConverter.getOutputString());
|
|
86789
86827
|
outputContent = await zip.generateAsync({ type: "nodebuffer" });
|