@tscircuit/cli 0.1.778 → 0.1.779
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/build/build-worker-entrypoint.js +2746 -0
- package/dist/main.js +32 -23
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -74129,7 +74129,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74129
74129
|
import { execSync as execSync2 } from "node:child_process";
|
|
74130
74130
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74131
74131
|
// package.json
|
|
74132
|
-
var version = "0.1.
|
|
74132
|
+
var version = "0.1.778";
|
|
74133
74133
|
var package_default = {
|
|
74134
74134
|
name: "@tscircuit/cli",
|
|
74135
74135
|
version,
|
|
@@ -172428,7 +172428,7 @@ var registerRemove = (program3) => {
|
|
|
172428
172428
|
|
|
172429
172429
|
// cli/build/register.ts
|
|
172430
172430
|
import path48 from "node:path";
|
|
172431
|
-
import
|
|
172431
|
+
import fs48 from "node:fs";
|
|
172432
172432
|
|
|
172433
172433
|
// cli/build/build-file.ts
|
|
172434
172434
|
import path35 from "node:path";
|
|
@@ -173683,9 +173683,18 @@ async function getLatestTscircuitCdnUrl() {
|
|
|
173683
173683
|
|
|
173684
173684
|
// cli/build/worker-pool.ts
|
|
173685
173685
|
import path47 from "node:path";
|
|
173686
|
+
import fs47 from "node:fs";
|
|
173686
173687
|
import { Worker } from "node:worker_threads";
|
|
173687
173688
|
var getWorkerEntrypointPath = () => {
|
|
173688
|
-
|
|
173689
|
+
const tsPath = path47.join(import.meta.dir, "build-worker-entrypoint.ts");
|
|
173690
|
+
if (fs47.existsSync(tsPath)) {
|
|
173691
|
+
return tsPath;
|
|
173692
|
+
}
|
|
173693
|
+
const jsBundledPath = path47.join(import.meta.dir, "build", "build-worker-entrypoint.js");
|
|
173694
|
+
if (fs47.existsSync(jsBundledPath)) {
|
|
173695
|
+
return jsBundledPath;
|
|
173696
|
+
}
|
|
173697
|
+
return path47.join(import.meta.dir, "build-worker-entrypoint.js");
|
|
173689
173698
|
};
|
|
173690
173699
|
|
|
173691
173700
|
class WorkerPool {
|
|
@@ -173875,7 +173884,7 @@ var registerBuild = (program3) => {
|
|
|
173875
173884
|
return config;
|
|
173876
173885
|
})();
|
|
173877
173886
|
const distDir = path48.join(projectDir, "dist");
|
|
173878
|
-
|
|
173887
|
+
fs48.mkdirSync(distDir, { recursive: true });
|
|
173879
173888
|
const concurrencyValue = Math.max(1, Number.parseInt(resolvedOptions?.concurrency || "1", 10));
|
|
173880
173889
|
if (concurrencyValue > 1) {
|
|
173881
173890
|
console.log(`Building ${circuitFiles.length} file(s) with concurrency ${concurrencyValue}...`);
|
|
@@ -173913,8 +173922,8 @@ var registerBuild = (program3) => {
|
|
|
173913
173922
|
}
|
|
173914
173923
|
if (buildOutcome.ok && shouldGenerateKicad) {
|
|
173915
173924
|
let circuitJson = buildOutcome.circuitJson;
|
|
173916
|
-
if (!circuitJson &&
|
|
173917
|
-
circuitJson = JSON.parse(
|
|
173925
|
+
if (!circuitJson && fs48.existsSync(outputPath)) {
|
|
173926
|
+
circuitJson = JSON.parse(fs48.readFileSync(outputPath, "utf-8"));
|
|
173918
173927
|
}
|
|
173919
173928
|
if (circuitJson) {
|
|
173920
173929
|
const projectOutputDir = path48.join(distDir, outputDirName, "kicad");
|
|
@@ -174030,14 +174039,14 @@ var registerBuild = (program3) => {
|
|
|
174030
174039
|
if (resolvedOptions?.useCdnJavascript) {
|
|
174031
174040
|
standaloneScriptSrc = await getLatestTscircuitCdnUrl();
|
|
174032
174041
|
} else {
|
|
174033
|
-
|
|
174042
|
+
fs48.writeFileSync(path48.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
174034
174043
|
}
|
|
174035
174044
|
const indexHtml = getStaticIndexHtmlFile({
|
|
174036
174045
|
files: staticFileReferences,
|
|
174037
174046
|
standaloneScriptSrc,
|
|
174038
174047
|
defaultMainComponentPath: siteDefaultComponentPath ? normalizeRelativePath(projectDir, siteDefaultComponentPath) : undefined
|
|
174039
174048
|
});
|
|
174040
|
-
|
|
174049
|
+
fs48.writeFileSync(path48.join(distDir, "index.html"), indexHtml);
|
|
174041
174050
|
}
|
|
174042
174051
|
if (resolvedOptions?.kicadFootprintLibrary) {
|
|
174043
174052
|
console.log("Generating KiCad footprint library...");
|
|
@@ -174136,7 +174145,7 @@ var registerBuild = (program3) => {
|
|
|
174136
174145
|
};
|
|
174137
174146
|
|
|
174138
174147
|
// lib/shared/snapshot-project.ts
|
|
174139
|
-
import
|
|
174148
|
+
import fs50 from "node:fs";
|
|
174140
174149
|
import path49 from "node:path";
|
|
174141
174150
|
import looksSame2 from "looks-same";
|
|
174142
174151
|
import {
|
|
@@ -174148,7 +174157,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
174148
174157
|
|
|
174149
174158
|
// lib/shared/compare-images.ts
|
|
174150
174159
|
import looksSame from "looks-same";
|
|
174151
|
-
import
|
|
174160
|
+
import fs49 from "node:fs/promises";
|
|
174152
174161
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
174153
174162
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
174154
174163
|
strict: false,
|
|
@@ -174164,7 +174173,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
174164
174173
|
tolerance: 2
|
|
174165
174174
|
});
|
|
174166
174175
|
} else {
|
|
174167
|
-
await
|
|
174176
|
+
await fs49.writeFile(diffPath, buffer2);
|
|
174168
174177
|
}
|
|
174169
174178
|
}
|
|
174170
174179
|
return { equal: equal2 };
|
|
@@ -174263,7 +174272,7 @@ var snapshotProject = async ({
|
|
|
174263
174272
|
const snapDir2 = snapshotsDirName ? path49.join(projectDir, snapshotsDirName, relativeDir) : path49.join(fileDir, "__snapshots__");
|
|
174264
174273
|
const base2 = path49.basename(file).replace(/\.tsx$/, "");
|
|
174265
174274
|
const snap3dPath = path49.join(snapDir2, `${base2}-3d.snap.png`);
|
|
174266
|
-
const existing3dSnapshot =
|
|
174275
|
+
const existing3dSnapshot = fs50.existsSync(snap3dPath);
|
|
174267
174276
|
if (existing3dSnapshot) {
|
|
174268
174277
|
onError(kleur_default.red(`
|
|
174269
174278
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
@@ -174285,7 +174294,7 @@ var snapshotProject = async ({
|
|
|
174285
174294
|
}
|
|
174286
174295
|
}
|
|
174287
174296
|
const snapDir = snapshotsDirName ? path49.join(projectDir, snapshotsDirName, path49.relative(projectDir, path49.dirname(file))) : path49.join(path49.dirname(file), "__snapshots__");
|
|
174288
|
-
|
|
174297
|
+
fs50.mkdirSync(snapDir, { recursive: true });
|
|
174289
174298
|
const base = path49.basename(file).replace(/\.tsx$/, "");
|
|
174290
174299
|
const snapshots = [];
|
|
174291
174300
|
if (pcbOnly || !schematicOnly) {
|
|
@@ -174305,23 +174314,23 @@ var snapshotProject = async ({
|
|
|
174305
174314
|
const { type } = snapshot;
|
|
174306
174315
|
const is3d = type === "3d";
|
|
174307
174316
|
const snapPath = path49.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
174308
|
-
const existing =
|
|
174317
|
+
const existing = fs50.existsSync(snapPath);
|
|
174309
174318
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
174310
174319
|
const newContentForFile = snapshot.content;
|
|
174311
174320
|
if (!existing) {
|
|
174312
|
-
|
|
174321
|
+
fs50.writeFileSync(snapPath, newContentForFile);
|
|
174313
174322
|
console.log("✅", kleur_default.gray(path49.relative(projectDir, snapPath)));
|
|
174314
174323
|
didUpdate = true;
|
|
174315
174324
|
continue;
|
|
174316
174325
|
}
|
|
174317
|
-
const oldContentBuffer =
|
|
174326
|
+
const oldContentBuffer = fs50.readFileSync(snapPath);
|
|
174318
174327
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
174319
174328
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
174320
174329
|
if (update) {
|
|
174321
174330
|
if (!forceUpdate && equal2) {
|
|
174322
174331
|
console.log("✅", kleur_default.gray(path49.relative(projectDir, snapPath)));
|
|
174323
174332
|
} else {
|
|
174324
|
-
|
|
174333
|
+
fs50.writeFileSync(snapPath, newContentForFile);
|
|
174325
174334
|
console.log("✅", kleur_default.gray(path49.relative(projectDir, snapPath)));
|
|
174326
174335
|
didUpdate = true;
|
|
174327
174336
|
}
|
|
@@ -174367,13 +174376,13 @@ var registerSnapshot = (program3) => {
|
|
|
174367
174376
|
};
|
|
174368
174377
|
|
|
174369
174378
|
// lib/shared/setup-github-actions.ts
|
|
174370
|
-
import
|
|
174379
|
+
import fs51 from "node:fs";
|
|
174371
174380
|
import path50 from "node:path";
|
|
174372
174381
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
174373
174382
|
const findGitRoot = (startDir) => {
|
|
174374
174383
|
let dir = path50.resolve(startDir);
|
|
174375
174384
|
while (dir !== path50.parse(dir).root) {
|
|
174376
|
-
if (
|
|
174385
|
+
if (fs51.existsSync(path50.join(dir, ".git"))) {
|
|
174377
174386
|
return dir;
|
|
174378
174387
|
}
|
|
174379
174388
|
dir = path50.dirname(dir);
|
|
@@ -174382,7 +174391,7 @@ var setupGithubActions = (projectDir = process.cwd()) => {
|
|
|
174382
174391
|
};
|
|
174383
174392
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
174384
174393
|
const workflowsDir = path50.join(gitRoot, ".github", "workflows");
|
|
174385
|
-
|
|
174394
|
+
fs51.mkdirSync(workflowsDir, { recursive: true });
|
|
174386
174395
|
const buildWorkflow = `name: tscircuit Build
|
|
174387
174396
|
|
|
174388
174397
|
on:
|
|
@@ -174460,7 +174469,7 @@ function registerAuthSetupNpmrc(program3) {
|
|
|
174460
174469
|
}
|
|
174461
174470
|
|
|
174462
174471
|
// cli/convert/register.ts
|
|
174463
|
-
import
|
|
174472
|
+
import fs52 from "node:fs/promises";
|
|
174464
174473
|
import path51 from "node:path";
|
|
174465
174474
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
174466
174475
|
|
|
@@ -174583,14 +174592,14 @@ var registerConvert = (program3) => {
|
|
|
174583
174592
|
program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
174584
174593
|
try {
|
|
174585
174594
|
const inputPath = path51.resolve(file);
|
|
174586
|
-
const modContent = await
|
|
174595
|
+
const modContent = await fs52.readFile(inputPath, "utf-8");
|
|
174587
174596
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
174588
174597
|
const componentName = options.name ?? path51.basename(inputPath, ".kicad_mod");
|
|
174589
174598
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
174590
174599
|
componentName
|
|
174591
174600
|
});
|
|
174592
174601
|
const outputPath = options.output ? path51.resolve(options.output) : path51.join(path51.dirname(inputPath), `${componentName}.tsx`);
|
|
174593
|
-
await
|
|
174602
|
+
await fs52.writeFile(outputPath, tsx);
|
|
174594
174603
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
174595
174604
|
} catch (error) {
|
|
174596
174605
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|