@tscircuit/cli 0.1.115 → 0.1.116
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/main.js +78 -1
- package/package.json +1 -1
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.115";
|
|
437167
437167
|
var package_default = {
|
|
437168
437168
|
name: "@tscircuit/cli",
|
|
437169
437169
|
version,
|
|
@@ -486310,6 +486310,82 @@ var registerRemove = (program3) => {
|
|
|
486310
486310
|
});
|
|
486311
486311
|
};
|
|
486312
486312
|
|
|
486313
|
+
// lib/shared/snapshot-project.ts
|
|
486314
|
+
import fs23 from "node:fs";
|
|
486315
|
+
import path23 from "node:path";
|
|
486316
|
+
init_dist4();
|
|
486317
|
+
var snapshotProject = async ({
|
|
486318
|
+
update = false,
|
|
486319
|
+
ignored = [],
|
|
486320
|
+
onExit = (code) => process.exit(code),
|
|
486321
|
+
onError = (msg) => console.error(msg),
|
|
486322
|
+
onSuccess = (msg) => console.log(msg)
|
|
486323
|
+
} = {}) => {
|
|
486324
|
+
const projectDir = process.cwd();
|
|
486325
|
+
const ignore = [
|
|
486326
|
+
...DEFAULT_IGNORED_PATTERNS,
|
|
486327
|
+
...ignored.map(normalizeIgnorePattern)
|
|
486328
|
+
];
|
|
486329
|
+
const boardFiles = globbySync("**/*.board.tsx", { cwd: projectDir, ignore });
|
|
486330
|
+
let files = boardFiles.map((f) => path23.join(projectDir, f));
|
|
486331
|
+
if (files.length === 0) {
|
|
486332
|
+
const entry = await getEntrypoint({
|
|
486333
|
+
projectDir,
|
|
486334
|
+
onError,
|
|
486335
|
+
onSuccess: () => {}
|
|
486336
|
+
});
|
|
486337
|
+
if (!entry)
|
|
486338
|
+
return onExit(1);
|
|
486339
|
+
files = [entry];
|
|
486340
|
+
}
|
|
486341
|
+
const mismatches = [];
|
|
486342
|
+
for (const file of files) {
|
|
486343
|
+
const { circuitJson } = await generateCircuitJson({ filePath: file });
|
|
486344
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
|
|
486345
|
+
const schSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
486346
|
+
const snapDir = path23.join(path23.dirname(file), "__snapshots__");
|
|
486347
|
+
fs23.mkdirSync(snapDir, { recursive: true });
|
|
486348
|
+
const base = path23.basename(file).replace(/\.tsx$/, "");
|
|
486349
|
+
for (const [type, svg] of [
|
|
486350
|
+
["pcb", pcbSvg],
|
|
486351
|
+
["schematic", schSvg]
|
|
486352
|
+
]) {
|
|
486353
|
+
const snapPath = path23.join(snapDir, `${base}-${type}.snap.svg`);
|
|
486354
|
+
if (update || !fs23.existsSync(snapPath)) {
|
|
486355
|
+
fs23.writeFileSync(snapPath, svg);
|
|
486356
|
+
} else {
|
|
486357
|
+
const existing = fs23.readFileSync(snapPath, "utf-8");
|
|
486358
|
+
if (existing !== svg)
|
|
486359
|
+
mismatches.push(snapPath);
|
|
486360
|
+
}
|
|
486361
|
+
}
|
|
486362
|
+
}
|
|
486363
|
+
if (update) {
|
|
486364
|
+
onSuccess("Created snapshots");
|
|
486365
|
+
return onExit(0);
|
|
486366
|
+
}
|
|
486367
|
+
if (mismatches.length > 0) {
|
|
486368
|
+
onError(`Snapshot mismatch:
|
|
486369
|
+
${mismatches.join(`
|
|
486370
|
+
`)}`);
|
|
486371
|
+
return onExit(1);
|
|
486372
|
+
}
|
|
486373
|
+
onSuccess("All snapshots match");
|
|
486374
|
+
return onExit(0);
|
|
486375
|
+
};
|
|
486376
|
+
|
|
486377
|
+
// cli/snapshot/register.ts
|
|
486378
|
+
var registerSnapshot = (program3) => {
|
|
486379
|
+
program3.command("snapshot").description("Generate schematic and PCB snapshots").option("-u, --update", "Update snapshots on disk").action(async (options) => {
|
|
486380
|
+
await snapshotProject({
|
|
486381
|
+
update: options.update ?? false,
|
|
486382
|
+
onExit: (code) => process.exit(code),
|
|
486383
|
+
onError: (msg) => console.error(msg),
|
|
486384
|
+
onSuccess: (msg) => console.log(msg)
|
|
486385
|
+
});
|
|
486386
|
+
});
|
|
486387
|
+
};
|
|
486388
|
+
|
|
486313
486389
|
// cli/main.ts
|
|
486314
486390
|
var program2 = new Command;
|
|
486315
486391
|
program2.name("tsci").description("CLI for developing tscircuit packages");
|
|
@@ -486328,6 +486404,7 @@ registerConfigSet(program2);
|
|
|
486328
486404
|
registerExport(program2);
|
|
486329
486405
|
registerAdd(program2);
|
|
486330
486406
|
registerRemove(program2);
|
|
486407
|
+
registerSnapshot(program2);
|
|
486331
486408
|
registerUpgradeCommand(program2);
|
|
486332
486409
|
registerSearch(program2);
|
|
486333
486410
|
if (process.argv.includes("--version") || process.argv.includes("-v") || process.argv.includes("-V")) {
|