@tscircuit/cli 0.1.115 → 0.1.117
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/README.md +2 -0
- package/dist/main.js +104 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,9 +50,11 @@ Commands:
|
|
|
50
50
|
logout Logout from tscircuit registry
|
|
51
51
|
config Manage tscircuit CLI configuration
|
|
52
52
|
export [options] <file> Export tscircuit code to various formats
|
|
53
|
+
build [file] Run tscircuit eval and output circuit json
|
|
53
54
|
add <component> Add a tscircuit component package to your project
|
|
54
55
|
remove <component> Remove a tscircuit component package from your
|
|
55
56
|
project
|
|
57
|
+
snapshot [options] Generate schematic and PCB snapshots
|
|
56
58
|
upgrade Upgrade CLI to the latest version
|
|
57
59
|
search <query> Search for packages in the tscircuit registry
|
|
58
60
|
version Print CLI version
|
package/dist/main.js
CHANGED
|
@@ -437163,7 +437163,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
437163
437163
|
import { execSync as execSync2 } from "node:child_process";
|
|
437164
437164
|
var import_semver = __toESM2(require_semver2(), 1);
|
|
437165
437165
|
// package.json
|
|
437166
|
-
var version = "0.1.
|
|
437166
|
+
var version = "0.1.116";
|
|
437167
437167
|
var package_default = {
|
|
437168
437168
|
name: "@tscircuit/cli",
|
|
437169
437169
|
version,
|
|
@@ -486040,7 +486040,8 @@ async function generateCircuitJson({
|
|
|
486040
486040
|
})
|
|
486041
486041
|
};
|
|
486042
486042
|
await runner.executeWithFsMap({
|
|
486043
|
-
fsMap
|
|
486043
|
+
fsMap,
|
|
486044
|
+
mainComponentPath: relativeComponentPath
|
|
486044
486045
|
});
|
|
486045
486046
|
await runner.renderUntilSettled();
|
|
486046
486047
|
const circuitJson = await runner.getCircuitJson();
|
|
@@ -486310,6 +486311,105 @@ var registerRemove = (program3) => {
|
|
|
486310
486311
|
});
|
|
486311
486312
|
};
|
|
486312
486313
|
|
|
486314
|
+
// cli/build/register.ts
|
|
486315
|
+
import path23 from "node:path";
|
|
486316
|
+
import fs23 from "node:fs";
|
|
486317
|
+
var registerBuild = (program3) => {
|
|
486318
|
+
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
486319
|
+
const entrypoint = await getEntrypoint({ filePath: file });
|
|
486320
|
+
if (!entrypoint)
|
|
486321
|
+
return process.exit(1);
|
|
486322
|
+
const projectDir = path23.dirname(entrypoint);
|
|
486323
|
+
const distDir = path23.join(projectDir, "dist");
|
|
486324
|
+
const outputPath = path23.join(distDir, "circuit.json");
|
|
486325
|
+
fs23.mkdirSync(distDir, { recursive: true });
|
|
486326
|
+
try {
|
|
486327
|
+
const result = await generateCircuitJson({ filePath: entrypoint });
|
|
486328
|
+
fs23.writeFileSync(outputPath, JSON.stringify(result.circuitJson, null, 2));
|
|
486329
|
+
console.log(`Circuit JSON written to ${path23.relative(projectDir, outputPath)}`);
|
|
486330
|
+
} catch (err) {
|
|
486331
|
+
console.error(`Build failed: ${err}`);
|
|
486332
|
+
return process.exit(1);
|
|
486333
|
+
}
|
|
486334
|
+
});
|
|
486335
|
+
};
|
|
486336
|
+
|
|
486337
|
+
// lib/shared/snapshot-project.ts
|
|
486338
|
+
import fs24 from "node:fs";
|
|
486339
|
+
import path24 from "node:path";
|
|
486340
|
+
init_dist4();
|
|
486341
|
+
var snapshotProject = async ({
|
|
486342
|
+
update = false,
|
|
486343
|
+
ignored = [],
|
|
486344
|
+
onExit = (code) => process.exit(code),
|
|
486345
|
+
onError = (msg) => console.error(msg),
|
|
486346
|
+
onSuccess = (msg) => console.log(msg)
|
|
486347
|
+
} = {}) => {
|
|
486348
|
+
const projectDir = process.cwd();
|
|
486349
|
+
const ignore = [
|
|
486350
|
+
...DEFAULT_IGNORED_PATTERNS,
|
|
486351
|
+
...ignored.map(normalizeIgnorePattern)
|
|
486352
|
+
];
|
|
486353
|
+
const boardFiles = globbySync("**/*.board.tsx", { cwd: projectDir, ignore });
|
|
486354
|
+
let files = boardFiles.map((f) => path24.join(projectDir, f));
|
|
486355
|
+
if (files.length === 0) {
|
|
486356
|
+
const entry = await getEntrypoint({
|
|
486357
|
+
projectDir,
|
|
486358
|
+
onError,
|
|
486359
|
+
onSuccess: () => {}
|
|
486360
|
+
});
|
|
486361
|
+
if (!entry)
|
|
486362
|
+
return onExit(1);
|
|
486363
|
+
files = [entry];
|
|
486364
|
+
}
|
|
486365
|
+
const mismatches = [];
|
|
486366
|
+
for (const file of files) {
|
|
486367
|
+
const { circuitJson } = await generateCircuitJson({ filePath: file });
|
|
486368
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
|
|
486369
|
+
const schSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
486370
|
+
const snapDir = path24.join(path24.dirname(file), "__snapshots__");
|
|
486371
|
+
fs24.mkdirSync(snapDir, { recursive: true });
|
|
486372
|
+
const base = path24.basename(file).replace(/\.tsx$/, "");
|
|
486373
|
+
for (const [type, svg] of [
|
|
486374
|
+
["pcb", pcbSvg],
|
|
486375
|
+
["schematic", schSvg]
|
|
486376
|
+
]) {
|
|
486377
|
+
const snapPath = path24.join(snapDir, `${base}-${type}.snap.svg`);
|
|
486378
|
+
if (update || !fs24.existsSync(snapPath)) {
|
|
486379
|
+
fs24.writeFileSync(snapPath, svg);
|
|
486380
|
+
} else {
|
|
486381
|
+
const existing = fs24.readFileSync(snapPath, "utf-8");
|
|
486382
|
+
if (existing !== svg)
|
|
486383
|
+
mismatches.push(snapPath);
|
|
486384
|
+
}
|
|
486385
|
+
}
|
|
486386
|
+
}
|
|
486387
|
+
if (update) {
|
|
486388
|
+
onSuccess("Created snapshots");
|
|
486389
|
+
return onExit(0);
|
|
486390
|
+
}
|
|
486391
|
+
if (mismatches.length > 0) {
|
|
486392
|
+
onError(`Snapshot mismatch:
|
|
486393
|
+
${mismatches.join(`
|
|
486394
|
+
`)}`);
|
|
486395
|
+
return onExit(1);
|
|
486396
|
+
}
|
|
486397
|
+
onSuccess("All snapshots match");
|
|
486398
|
+
return onExit(0);
|
|
486399
|
+
};
|
|
486400
|
+
|
|
486401
|
+
// cli/snapshot/register.ts
|
|
486402
|
+
var registerSnapshot = (program3) => {
|
|
486403
|
+
program3.command("snapshot").description("Generate schematic and PCB snapshots").option("-u, --update", "Update snapshots on disk").action(async (options) => {
|
|
486404
|
+
await snapshotProject({
|
|
486405
|
+
update: options.update ?? false,
|
|
486406
|
+
onExit: (code) => process.exit(code),
|
|
486407
|
+
onError: (msg) => console.error(msg),
|
|
486408
|
+
onSuccess: (msg) => console.log(msg)
|
|
486409
|
+
});
|
|
486410
|
+
});
|
|
486411
|
+
};
|
|
486412
|
+
|
|
486313
486413
|
// cli/main.ts
|
|
486314
486414
|
var program2 = new Command;
|
|
486315
486415
|
program2.name("tsci").description("CLI for developing tscircuit packages");
|
|
@@ -486326,8 +486426,10 @@ registerConfig(program2);
|
|
|
486326
486426
|
registerConfigPrint(program2);
|
|
486327
486427
|
registerConfigSet(program2);
|
|
486328
486428
|
registerExport(program2);
|
|
486429
|
+
registerBuild(program2);
|
|
486329
486430
|
registerAdd(program2);
|
|
486330
486431
|
registerRemove(program2);
|
|
486432
|
+
registerSnapshot(program2);
|
|
486331
486433
|
registerUpgradeCommand(program2);
|
|
486332
486434
|
registerSearch(program2);
|
|
486333
486435
|
if (process.argv.includes("--version") || process.argv.includes("-v") || process.argv.includes("-V")) {
|