@tscircuit/cli 0.1.192 → 0.1.193

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.
Files changed (2) hide show
  1. package/dist/main.js +23 -18
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -68081,7 +68081,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
68081
68081
  import { execSync as execSync2 } from "node:child_process";
68082
68082
  var import_semver2 = __toESM2(require_semver2(), 1);
68083
68083
  // package.json
68084
- var version = "0.1.191";
68084
+ var version = "0.1.192";
68085
68085
  var package_default = {
68086
68086
  name: "@tscircuit/cli",
68087
68087
  version,
@@ -77944,7 +77944,7 @@ var registerBuild = (program3) => {
77944
77944
  };
77945
77945
 
77946
77946
  // lib/shared/snapshot-project.ts
77947
- import fs27 from "node:fs";
77947
+ import fs28 from "node:fs";
77948
77948
  import path27 from "node:path";
77949
77949
  var import_sharp = __toESM2(require_lib2(), 1);
77950
77950
  import looksSame2 from "looks-same";
@@ -77956,19 +77956,24 @@ import { convertCircuitJsonToSimple3dSvg } from "circuit-json-to-simple-3d";
77956
77956
 
77957
77957
  // lib/shared/compare-images.ts
77958
77958
  import looksSame from "looks-same";
77959
+ import fs27 from "node:fs/promises";
77959
77960
  var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
77960
77961
  const { equal } = await looksSame(buffer1, buffer2, {
77961
77962
  strict: false,
77962
77963
  tolerance: 2
77963
77964
  });
77964
77965
  if (!equal) {
77965
- await looksSame.createDiff({
77966
- reference: buffer1,
77967
- current: buffer2,
77968
- diff: diffPath,
77969
- highlightColor: "#ff00ff",
77970
- tolerance: 2
77971
- });
77966
+ if (diffPath.endsWith(".png")) {
77967
+ await looksSame.createDiff({
77968
+ reference: buffer1,
77969
+ current: buffer2,
77970
+ diff: diffPath,
77971
+ highlightColor: "#ff00ff",
77972
+ tolerance: 2
77973
+ });
77974
+ } else {
77975
+ await fs27.writeFile(diffPath, buffer2);
77976
+ }
77972
77977
  }
77973
77978
  return { equal };
77974
77979
  };
@@ -78007,7 +78012,7 @@ var snapshotProject = async ({
78007
78012
  const schSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
78008
78013
  const svg3d = threeD ? await convertCircuitJsonToSimple3dSvg(circuitJson) : null;
78009
78014
  const snapDir = path27.join(path27.dirname(file), "__snapshots__");
78010
- fs27.mkdirSync(snapDir, { recursive: true });
78015
+ fs28.mkdirSync(snapDir, { recursive: true });
78011
78016
  const base = path27.basename(file).replace(/\.tsx$/, "");
78012
78017
  const pairs2 = [];
78013
78018
  if (pcbOnly || !schematicOnly)
@@ -78023,23 +78028,23 @@ var snapshotProject = async ({
78023
78028
  for (const [type, newSvg] of pairs2) {
78024
78029
  const is3d = type === "3d";
78025
78030
  const snapPath = path27.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
78026
- const existing = fs27.existsSync(snapPath);
78031
+ const existing = fs28.existsSync(snapPath);
78027
78032
  const newContentBuffer = is3d ? await import_sharp.default(Buffer.from(newSvg)).png().toBuffer() : Buffer.from(newSvg, "utf8");
78028
78033
  const newContentForFile = is3d ? newContentBuffer : newSvg;
78029
78034
  if (!existing) {
78030
- fs27.writeFileSync(snapPath, newContentForFile);
78035
+ fs28.writeFileSync(snapPath, newContentForFile);
78031
78036
  console.log("✅", kleur_default.gray(path27.relative(projectDir, snapPath)));
78032
78037
  didUpdate = true;
78033
78038
  continue;
78034
78039
  }
78035
- const oldContentBuffer = fs27.readFileSync(snapPath);
78036
- const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", ".diff.png");
78040
+ const oldContentBuffer = fs28.readFileSync(snapPath);
78041
+ const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
78037
78042
  const { equal } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
78038
78043
  if (update) {
78039
78044
  if (!forceUpdate && equal) {
78040
78045
  console.log("✅", kleur_default.gray(path27.relative(projectDir, snapPath)));
78041
78046
  } else {
78042
- fs27.writeFileSync(snapPath, newContentForFile);
78047
+ fs28.writeFileSync(snapPath, newContentForFile);
78043
78048
  console.log("✅", kleur_default.gray(path27.relative(projectDir, snapPath)));
78044
78049
  didUpdate = true;
78045
78050
  }
@@ -78084,13 +78089,13 @@ var registerSnapshot = (program3) => {
78084
78089
  };
78085
78090
 
78086
78091
  // lib/shared/setup-github-actions.ts
78087
- import fs28 from "node:fs";
78092
+ import fs29 from "node:fs";
78088
78093
  import path28 from "node:path";
78089
78094
  var setupGithubActions = (projectDir = process.cwd()) => {
78090
78095
  const findGitRoot = (startDir) => {
78091
78096
  let dir = path28.resolve(startDir);
78092
78097
  while (dir !== path28.parse(dir).root) {
78093
- if (fs28.existsSync(path28.join(dir, ".git"))) {
78098
+ if (fs29.existsSync(path28.join(dir, ".git"))) {
78094
78099
  return dir;
78095
78100
  }
78096
78101
  dir = path28.dirname(dir);
@@ -78099,7 +78104,7 @@ var setupGithubActions = (projectDir = process.cwd()) => {
78099
78104
  };
78100
78105
  const gitRoot = findGitRoot(projectDir) ?? projectDir;
78101
78106
  const workflowsDir = path28.join(gitRoot, ".github", "workflows");
78102
- fs28.mkdirSync(workflowsDir, { recursive: true });
78107
+ fs29.mkdirSync(workflowsDir, { recursive: true });
78103
78108
  const buildWorkflow = `name: tscircuit Build
78104
78109
 
78105
78110
  on:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.192",
3
+ "version": "0.1.193",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",