@tscircuit/cli 0.1.174 → 0.1.175
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 +47 -47
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -467116,7 +467116,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
467116
467116
|
import { execSync as execSync2 } from "node:child_process";
|
|
467117
467117
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
467118
467118
|
// package.json
|
|
467119
|
-
var version = "0.1.
|
|
467119
|
+
var version = "0.1.174";
|
|
467120
467120
|
var package_default = {
|
|
467121
467121
|
name: "@tscircuit/cli",
|
|
467122
467122
|
version,
|
|
@@ -535101,22 +535101,17 @@ var snapshotProject = async ({
|
|
|
535101
535101
|
...DEFAULT_IGNORED_PATTERNS,
|
|
535102
535102
|
...ignored.map(normalizeIgnorePattern)
|
|
535103
535103
|
];
|
|
535104
|
-
|
|
535105
|
-
|
|
535106
|
-
|
|
535107
|
-
}
|
|
535108
|
-
|
|
535109
|
-
|
|
535110
|
-
ignore
|
|
535111
|
-
});
|
|
535112
|
-
files = boardFiles.map((f) => path26.join(projectDir, f));
|
|
535113
|
-
}
|
|
535114
|
-
if (files.length === 0) {
|
|
535115
|
-
console.log("No entrypoint found. Run 'tsci init' to bootstrap a basic project or specify a file with 'tsci snapshot <file>'");
|
|
535104
|
+
const boardFiles = filePaths.length > 0 ? filePaths.map((f) => path26.resolve(projectDir, f)) : globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
535105
|
+
cwd: projectDir,
|
|
535106
|
+
ignore
|
|
535107
|
+
}).map((f) => path26.join(projectDir, f));
|
|
535108
|
+
if (boardFiles.length === 0) {
|
|
535109
|
+
console.log("No entrypoint found. Run 'tsci init' to bootstrap a project or specify a file with 'tsci snapshot <file>'");
|
|
535116
535110
|
return onExit(0);
|
|
535117
535111
|
}
|
|
535118
535112
|
const mismatches = [];
|
|
535119
|
-
|
|
535113
|
+
let didUpdate = false;
|
|
535114
|
+
for (const file of boardFiles) {
|
|
535120
535115
|
const { circuitJson } = await generateCircuitJson({ filePath: file });
|
|
535121
535116
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
|
|
535122
535117
|
const schSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
@@ -535124,58 +535119,63 @@ var snapshotProject = async ({
|
|
|
535124
535119
|
const snapDir = path26.join(path26.dirname(file), "__snapshots__");
|
|
535125
535120
|
fs26.mkdirSync(snapDir, { recursive: true });
|
|
535126
535121
|
const base = path26.basename(file).replace(/\.tsx$/, "");
|
|
535127
|
-
const
|
|
535128
|
-
|
|
535129
|
-
|
|
535130
|
-
if (
|
|
535131
|
-
|
|
535132
|
-
if (
|
|
535133
|
-
|
|
535134
|
-
|
|
535135
|
-
|
|
535136
|
-
|
|
535137
|
-
|
|
535122
|
+
const pairs3 = [];
|
|
535123
|
+
if (pcbOnly || !schematicOnly)
|
|
535124
|
+
pairs3.push(["pcb", pcbSvg]);
|
|
535125
|
+
if (schematicOnly || !pcbOnly)
|
|
535126
|
+
pairs3.push(["schematic", schSvg]);
|
|
535127
|
+
if (threeD && svg3d)
|
|
535128
|
+
pairs3.push(["3d", svg3d]);
|
|
535129
|
+
const looksSame = await loadLooksSame();
|
|
535130
|
+
if (!looksSame) {
|
|
535131
|
+
console.error("looks-same is required. Install it with 'bun add -d looks-same'");
|
|
535132
|
+
return onExit(1);
|
|
535133
|
+
}
|
|
535134
|
+
for (const [type, newSvg] of pairs3) {
|
|
535138
535135
|
const snapPath = path26.join(snapDir, `${base}-${type}.snap.svg`);
|
|
535139
|
-
const
|
|
535140
|
-
if (!
|
|
535141
|
-
fs26.writeFileSync(snapPath,
|
|
535136
|
+
const existing = fs26.existsSync(snapPath);
|
|
535137
|
+
if (!existing) {
|
|
535138
|
+
fs26.writeFileSync(snapPath, newSvg, "utf8");
|
|
535142
535139
|
console.log("✅", kleur_default.gray(path26.relative(projectDir, snapPath)));
|
|
535140
|
+
didUpdate = true;
|
|
535143
535141
|
continue;
|
|
535144
535142
|
}
|
|
535145
|
-
const
|
|
535146
|
-
const
|
|
535147
|
-
const
|
|
535143
|
+
const oldSvg = fs26.readFileSync(snapPath, "utf8");
|
|
535144
|
+
const bufNew = Buffer.from(newSvg, "utf8");
|
|
535145
|
+
const bufOld = Buffer.from(oldSvg, "utf8");
|
|
535146
|
+
const { equal } = await looksSame.default(bufNew, bufOld, {
|
|
535148
535147
|
strict: false,
|
|
535149
535148
|
tolerance: 2
|
|
535150
|
-
})
|
|
535149
|
+
});
|
|
535151
535150
|
if (update) {
|
|
535152
535151
|
if (!forceUpdate && equal) {
|
|
535153
535152
|
console.log("✅", kleur_default.gray(path26.relative(projectDir, snapPath)));
|
|
535154
535153
|
} else {
|
|
535155
|
-
fs26.writeFileSync(snapPath,
|
|
535154
|
+
fs26.writeFileSync(snapPath, newSvg, "utf8");
|
|
535156
535155
|
console.log("✅", kleur_default.gray(path26.relative(projectDir, snapPath)));
|
|
535156
|
+
didUpdate = true;
|
|
535157
535157
|
}
|
|
535158
535158
|
} else if (!equal) {
|
|
535159
|
-
|
|
535160
|
-
|
|
535161
|
-
|
|
535162
|
-
|
|
535163
|
-
|
|
535164
|
-
|
|
535165
|
-
|
|
535166
|
-
|
|
535167
|
-
|
|
535168
|
-
}
|
|
535169
|
-
|
|
535170
|
-
|
|
535159
|
+
const diffPath = snapPath.replace(".snap.svg", ".diff.png");
|
|
535160
|
+
const diffBuffer = await looksSame.createDiff({
|
|
535161
|
+
reference: bufOld,
|
|
535162
|
+
current: bufNew,
|
|
535163
|
+
highlightColor: "#ff00ff",
|
|
535164
|
+
tolerance: 2,
|
|
535165
|
+
extension: "png"
|
|
535166
|
+
});
|
|
535167
|
+
fs26.writeFileSync(diffPath, diffBuffer);
|
|
535168
|
+
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
535169
|
+
} else {
|
|
535170
|
+
console.log("✅", kleur_default.gray(path26.relative(projectDir, snapPath)));
|
|
535171
535171
|
}
|
|
535172
535172
|
}
|
|
535173
535173
|
}
|
|
535174
535174
|
if (update) {
|
|
535175
|
-
onSuccess("Created snapshots");
|
|
535175
|
+
didUpdate ? onSuccess("Created snapshots") : onSuccess("All snapshots already up to date");
|
|
535176
535176
|
return onExit(0);
|
|
535177
535177
|
}
|
|
535178
|
-
if (mismatches.length
|
|
535178
|
+
if (mismatches.length) {
|
|
535179
535179
|
onError(`Snapshot mismatch:
|
|
535180
535180
|
${mismatches.join(`
|
|
535181
535181
|
`)}
|