@tscircuit/cli 0.1.1108 → 0.1.1110
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/cli/main.js +133 -79
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -97678,8 +97678,11 @@ var registerStaticAssetLoaders = () => {
|
|
|
97678
97678
|
|
|
97679
97679
|
// cli/main.ts
|
|
97680
97680
|
var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
97681
|
+
|
|
97682
|
+
// lib/getVersion.ts
|
|
97683
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
97681
97684
|
// package.json
|
|
97682
|
-
var version = "0.1.
|
|
97685
|
+
var version = "0.1.1108";
|
|
97683
97686
|
var package_default = {
|
|
97684
97687
|
name: "@tscircuit/cli",
|
|
97685
97688
|
version,
|
|
@@ -97782,8 +97785,38 @@ var package_default = {
|
|
|
97782
97785
|
|
|
97783
97786
|
// lib/getVersion.ts
|
|
97784
97787
|
var import_semver = __toESM2(require_semver2(), 1);
|
|
97785
|
-
var
|
|
97786
|
-
|
|
97788
|
+
var require2 = createRequire2(import.meta.url);
|
|
97789
|
+
var resolvePackageVersionFromNodeModules = (packageName) => {
|
|
97790
|
+
try {
|
|
97791
|
+
const packageJson = require2(`${packageName}/package.json`);
|
|
97792
|
+
return packageJson.version;
|
|
97793
|
+
} catch {
|
|
97794
|
+
return;
|
|
97795
|
+
}
|
|
97796
|
+
};
|
|
97797
|
+
var getCliVersion = () => import_semver.default.inc(package_default.version, "patch") ?? package_default.version;
|
|
97798
|
+
var getVersionInfo = (resolvePackageVersion = resolvePackageVersionFromNodeModules) => {
|
|
97799
|
+
const cliVersion = getCliVersion();
|
|
97800
|
+
const tscircuitVersion = globalThis.TSCIRCUIT_VERSION ?? resolvePackageVersion("tscircuit");
|
|
97801
|
+
return {
|
|
97802
|
+
tscircuitVersion,
|
|
97803
|
+
cliVersion,
|
|
97804
|
+
runframeVersion: resolvePackageVersion("@tscircuit/runframe"),
|
|
97805
|
+
coreVersion: resolvePackageVersion("@tscircuit/core")
|
|
97806
|
+
};
|
|
97807
|
+
};
|
|
97808
|
+
var getVersion = ({ verbose = false } = {}) => {
|
|
97809
|
+
const versions = getVersionInfo();
|
|
97810
|
+
if (!verbose) {
|
|
97811
|
+
return versions.tscircuitVersion ?? versions.cliVersion;
|
|
97812
|
+
}
|
|
97813
|
+
return [
|
|
97814
|
+
`tscircuit: ${versions.tscircuitVersion ?? "not installed"}`,
|
|
97815
|
+
`@tscircuit/cli: ${versions.cliVersion}`,
|
|
97816
|
+
`@tscircuit/runframe: ${versions.runframeVersion ?? "not installed"}`,
|
|
97817
|
+
`@tscircuit/core: ${versions.coreVersion ?? "not installed"}`
|
|
97818
|
+
].join(`
|
|
97819
|
+
`);
|
|
97787
97820
|
};
|
|
97788
97821
|
|
|
97789
97822
|
// lib/shared/add-package.ts
|
|
@@ -105851,13 +105884,13 @@ function deriveComponentNameFromPath(filePath) {
|
|
|
105851
105884
|
}
|
|
105852
105885
|
|
|
105853
105886
|
// lib/shared/importFromUserLand.ts
|
|
105854
|
-
import { createRequire as
|
|
105887
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
105855
105888
|
import fs16 from "node:fs";
|
|
105856
105889
|
import path16 from "node:path";
|
|
105857
105890
|
async function importFromUserLand(moduleName) {
|
|
105858
105891
|
const userModulePath = path16.join(process.cwd(), "node_modules", moduleName);
|
|
105859
105892
|
if (fs16.existsSync(userModulePath)) {
|
|
105860
|
-
const userRequire =
|
|
105893
|
+
const userRequire = createRequire3(path16.join(process.cwd(), "noop.js"));
|
|
105861
105894
|
try {
|
|
105862
105895
|
const resolvedUserPath = userRequire.resolve(moduleName);
|
|
105863
105896
|
return await import(resolvedUserPath);
|
|
@@ -105867,7 +105900,7 @@ async function importFromUserLand(moduleName) {
|
|
|
105867
105900
|
}
|
|
105868
105901
|
}
|
|
105869
105902
|
}
|
|
105870
|
-
const cliRequire =
|
|
105903
|
+
const cliRequire = createRequire3(import.meta.url);
|
|
105871
105904
|
try {
|
|
105872
105905
|
const resolvedCliPath = cliRequire.resolve(moduleName);
|
|
105873
105906
|
return await import(resolvedCliPath);
|
|
@@ -220582,6 +220615,19 @@ var registerRegistryPackagesCreate = (program3) => {
|
|
|
220582
220615
|
};
|
|
220583
220616
|
|
|
220584
220617
|
// cli/registry/packages/update/register.ts
|
|
220618
|
+
import fs60 from "node:fs";
|
|
220619
|
+
import path63 from "node:path";
|
|
220620
|
+
var getCurrentDirectoryPackageName = () => {
|
|
220621
|
+
const packageJsonPath = path63.join(process.cwd(), "package.json");
|
|
220622
|
+
if (!fs60.existsSync(packageJsonPath))
|
|
220623
|
+
return;
|
|
220624
|
+
try {
|
|
220625
|
+
const packageJson = JSON.parse(fs60.readFileSync(packageJsonPath, "utf8"));
|
|
220626
|
+
return typeof packageJson.name === "string" ? packageJson.name : undefined;
|
|
220627
|
+
} catch {
|
|
220628
|
+
return;
|
|
220629
|
+
}
|
|
220630
|
+
};
|
|
220585
220631
|
var getPublicDistEnabledFromOptions = ({
|
|
220586
220632
|
enablePublicDist,
|
|
220587
220633
|
disablePublicDist
|
|
@@ -220593,7 +220639,15 @@ var getPublicDistEnabledFromOptions = ({
|
|
|
220593
220639
|
return;
|
|
220594
220640
|
};
|
|
220595
220641
|
var registerRegistryPackagesUpdate = (program3) => {
|
|
220596
|
-
program3.commands.find((command) => command.name() === "registry").commands.find((command) => command.name() === "packages").command("update").description("Update a package in the tscircuit registry").
|
|
220642
|
+
program3.commands.find((command) => command.name() === "registry").commands.find((command) => command.name() === "packages").command("update").description("Update a package in the tscircuit registry").option("--package-name <packageName>", "Package name to update").option("--enable-public-dist", "Enable public dist").option("--disable-public-dist", "Disable public dist").action(async (opts) => {
|
|
220643
|
+
const packageName = opts.packageName ?? getCurrentDirectoryPackageName();
|
|
220644
|
+
if (!opts.packageName && packageName) {
|
|
220645
|
+
console.warn("No package specified, using package in current directory...");
|
|
220646
|
+
}
|
|
220647
|
+
if (!packageName) {
|
|
220648
|
+
console.error("No package specified and no package name found in current directory package.json");
|
|
220649
|
+
process.exit(1);
|
|
220650
|
+
}
|
|
220597
220651
|
if (opts.enablePublicDist && opts.disablePublicDist) {
|
|
220598
220652
|
console.error("Cannot use both --enable-public-dist and --disable-public-dist");
|
|
220599
220653
|
process.exit(1);
|
|
@@ -220610,11 +220664,11 @@ var registerRegistryPackagesUpdate = (program3) => {
|
|
|
220610
220664
|
const ky3 = getRegistryApiKy();
|
|
220611
220665
|
await ky3.post("packages/update", {
|
|
220612
220666
|
json: {
|
|
220613
|
-
package_name:
|
|
220667
|
+
package_name: packageName,
|
|
220614
220668
|
public_dist_enabled: publicDistEnabled
|
|
220615
220669
|
}
|
|
220616
220670
|
});
|
|
220617
|
-
console.log(kleur_default.green(`Updated package ${
|
|
220671
|
+
console.log(kleur_default.green(`Updated package ${packageName}`));
|
|
220618
220672
|
} catch (error) {
|
|
220619
220673
|
console.error(error instanceof Error ? error.message : String(error));
|
|
220620
220674
|
process.exit(1);
|
|
@@ -220704,14 +220758,14 @@ class KeyStore {
|
|
|
220704
220758
|
}
|
|
220705
220759
|
}
|
|
220706
220760
|
function createKey(key) {
|
|
220707
|
-
let
|
|
220761
|
+
let path64 = null;
|
|
220708
220762
|
let id2 = null;
|
|
220709
220763
|
let src = null;
|
|
220710
220764
|
let weight = 1;
|
|
220711
220765
|
let getFn = null;
|
|
220712
220766
|
if (isString2(key) || isArray(key)) {
|
|
220713
220767
|
src = key;
|
|
220714
|
-
|
|
220768
|
+
path64 = createKeyPath(key);
|
|
220715
220769
|
id2 = createKeyId(key);
|
|
220716
220770
|
} else {
|
|
220717
220771
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -220725,11 +220779,11 @@ function createKey(key) {
|
|
|
220725
220779
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
220726
220780
|
}
|
|
220727
220781
|
}
|
|
220728
|
-
|
|
220782
|
+
path64 = createKeyPath(name);
|
|
220729
220783
|
id2 = createKeyId(name);
|
|
220730
220784
|
getFn = key.getFn;
|
|
220731
220785
|
}
|
|
220732
|
-
return { path:
|
|
220786
|
+
return { path: path64, id: id2, weight, src, getFn };
|
|
220733
220787
|
}
|
|
220734
220788
|
function createKeyPath(key) {
|
|
220735
220789
|
return isArray(key) ? key : key.split(".");
|
|
@@ -220737,34 +220791,34 @@ function createKeyPath(key) {
|
|
|
220737
220791
|
function createKeyId(key) {
|
|
220738
220792
|
return isArray(key) ? key.join(".") : key;
|
|
220739
220793
|
}
|
|
220740
|
-
function get(obj,
|
|
220794
|
+
function get(obj, path64) {
|
|
220741
220795
|
let list = [];
|
|
220742
220796
|
let arr = false;
|
|
220743
|
-
const deepGet = (obj2,
|
|
220797
|
+
const deepGet = (obj2, path65, index) => {
|
|
220744
220798
|
if (!isDefined(obj2)) {
|
|
220745
220799
|
return;
|
|
220746
220800
|
}
|
|
220747
|
-
if (!
|
|
220801
|
+
if (!path65[index]) {
|
|
220748
220802
|
list.push(obj2);
|
|
220749
220803
|
} else {
|
|
220750
|
-
let key =
|
|
220804
|
+
let key = path65[index];
|
|
220751
220805
|
const value = obj2[key];
|
|
220752
220806
|
if (!isDefined(value)) {
|
|
220753
220807
|
return;
|
|
220754
220808
|
}
|
|
220755
|
-
if (index ===
|
|
220809
|
+
if (index === path65.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
|
|
220756
220810
|
list.push(toString2(value));
|
|
220757
220811
|
} else if (isArray(value)) {
|
|
220758
220812
|
arr = true;
|
|
220759
220813
|
for (let i2 = 0, len = value.length;i2 < len; i2 += 1) {
|
|
220760
|
-
deepGet(value[i2],
|
|
220814
|
+
deepGet(value[i2], path65, index + 1);
|
|
220761
220815
|
}
|
|
220762
|
-
} else if (
|
|
220763
|
-
deepGet(value,
|
|
220816
|
+
} else if (path65.length) {
|
|
220817
|
+
deepGet(value, path65, index + 1);
|
|
220764
220818
|
}
|
|
220765
220819
|
}
|
|
220766
220820
|
};
|
|
220767
|
-
deepGet(obj, isString2(
|
|
220821
|
+
deepGet(obj, isString2(path64) ? path64.split(".") : path64, 0);
|
|
220768
220822
|
return arr ? list : list[0];
|
|
220769
220823
|
}
|
|
220770
220824
|
var MatchOptions = {
|
|
@@ -221960,9 +222014,9 @@ var registerSearch = (program3) => {
|
|
|
221960
222014
|
}
|
|
221961
222015
|
if (opts.json) {
|
|
221962
222016
|
const unifiedResults = [
|
|
221963
|
-
...kicadResults.map((
|
|
222017
|
+
...kicadResults.map((path64) => ({
|
|
221964
222018
|
source: "kicad",
|
|
221965
|
-
path:
|
|
222019
|
+
path: path64
|
|
221966
222020
|
})),
|
|
221967
222021
|
...results.packages.map((pkg) => ({
|
|
221968
222022
|
source: "tscircuit",
|
|
@@ -221990,8 +222044,8 @@ var registerSearch = (program3) => {
|
|
|
221990
222044
|
}
|
|
221991
222045
|
if (kicadResults.length) {
|
|
221992
222046
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
221993
|
-
kicadResults.forEach((
|
|
221994
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
222047
|
+
kicadResults.forEach((path64, idx) => {
|
|
222048
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path64.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
221995
222049
|
});
|
|
221996
222050
|
}
|
|
221997
222051
|
if (results.packages.length) {
|
|
@@ -222015,22 +222069,22 @@ var registerSearch = (program3) => {
|
|
|
222015
222069
|
};
|
|
222016
222070
|
|
|
222017
222071
|
// lib/shared/setup-github-actions.ts
|
|
222018
|
-
import
|
|
222019
|
-
import
|
|
222072
|
+
import fs61 from "node:fs";
|
|
222073
|
+
import path64 from "node:path";
|
|
222020
222074
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
222021
222075
|
const findGitRoot = (startDir) => {
|
|
222022
|
-
let dir =
|
|
222023
|
-
while (dir !==
|
|
222024
|
-
if (
|
|
222076
|
+
let dir = path64.resolve(startDir);
|
|
222077
|
+
while (dir !== path64.parse(dir).root) {
|
|
222078
|
+
if (fs61.existsSync(path64.join(dir, ".git"))) {
|
|
222025
222079
|
return dir;
|
|
222026
222080
|
}
|
|
222027
|
-
dir =
|
|
222081
|
+
dir = path64.dirname(dir);
|
|
222028
222082
|
}
|
|
222029
222083
|
return null;
|
|
222030
222084
|
};
|
|
222031
222085
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
222032
|
-
const workflowsDir =
|
|
222033
|
-
|
|
222086
|
+
const workflowsDir = path64.join(gitRoot, ".github", "workflows");
|
|
222087
|
+
fs61.mkdirSync(workflowsDir, { recursive: true });
|
|
222034
222088
|
const buildWorkflow = `name: tscircuit Build
|
|
222035
222089
|
|
|
222036
222090
|
on:
|
|
@@ -222069,8 +222123,8 @@ jobs:
|
|
|
222069
222123
|
- run: bun install
|
|
222070
222124
|
- run: bunx tsci snapshot
|
|
222071
222125
|
`;
|
|
222072
|
-
writeFileIfNotExists(
|
|
222073
|
-
writeFileIfNotExists(
|
|
222126
|
+
writeFileIfNotExists(path64.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
222127
|
+
writeFileIfNotExists(path64.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
222074
222128
|
};
|
|
222075
222129
|
|
|
222076
222130
|
// cli/setup/register.ts
|
|
@@ -222237,22 +222291,22 @@ function applyCameraPreset(preset, cam) {
|
|
|
222237
222291
|
}
|
|
222238
222292
|
|
|
222239
222293
|
// lib/shared/snapshot-project.ts
|
|
222240
|
-
import
|
|
222241
|
-
import
|
|
222294
|
+
import fs65 from "node:fs";
|
|
222295
|
+
import path67 from "node:path";
|
|
222242
222296
|
|
|
222243
222297
|
// cli/snapshot/worker-pool.ts
|
|
222244
|
-
import
|
|
222245
|
-
import
|
|
222298
|
+
import fs62 from "node:fs";
|
|
222299
|
+
import path65 from "node:path";
|
|
222246
222300
|
var getWorkerEntrypointPath2 = () => {
|
|
222247
|
-
const tsPath =
|
|
222248
|
-
if (
|
|
222301
|
+
const tsPath = path65.join(import.meta.dir, "snapshot.worker.ts");
|
|
222302
|
+
if (fs62.existsSync(tsPath)) {
|
|
222249
222303
|
return tsPath;
|
|
222250
222304
|
}
|
|
222251
|
-
const jsBundledPath =
|
|
222252
|
-
if (
|
|
222305
|
+
const jsBundledPath = path65.join(import.meta.dir, "snapshot", "snapshot.worker.js");
|
|
222306
|
+
if (fs62.existsSync(jsBundledPath)) {
|
|
222253
222307
|
return jsBundledPath;
|
|
222254
222308
|
}
|
|
222255
|
-
return
|
|
222309
|
+
return path65.join(import.meta.dir, "snapshot.worker.js");
|
|
222256
222310
|
};
|
|
222257
222311
|
var snapshotFilesWithWorkerPool = async (options) => {
|
|
222258
222312
|
const cancellationError = new Error("Snapshot cancelled due to file failure");
|
|
@@ -222319,8 +222373,8 @@ var snapshotFilesWithWorkerPool = async (options) => {
|
|
|
222319
222373
|
};
|
|
222320
222374
|
|
|
222321
222375
|
// lib/shared/process-snapshot-file.ts
|
|
222322
|
-
import
|
|
222323
|
-
import
|
|
222376
|
+
import fs64 from "node:fs";
|
|
222377
|
+
import path66 from "node:path";
|
|
222324
222378
|
import {
|
|
222325
222379
|
convertCircuitJsonToGltf as convertCircuitJsonToGltf5,
|
|
222326
222380
|
getBestCameraPosition
|
|
@@ -222333,7 +222387,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
222333
222387
|
|
|
222334
222388
|
// lib/shared/compare-images.ts
|
|
222335
222389
|
import looksSame from "looks-same";
|
|
222336
|
-
import
|
|
222390
|
+
import fs63 from "node:fs/promises";
|
|
222337
222391
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
222338
222392
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
222339
222393
|
strict: false,
|
|
@@ -222349,7 +222403,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
|
|
|
222349
222403
|
tolerance: 2
|
|
222350
222404
|
});
|
|
222351
222405
|
} else {
|
|
222352
|
-
await
|
|
222406
|
+
await fs63.writeFile(diffPath, buffer2);
|
|
222353
222407
|
}
|
|
222354
222408
|
}
|
|
222355
222409
|
return { equal: equal2 };
|
|
@@ -222369,7 +222423,7 @@ var processSnapshotFile = async ({
|
|
|
222369
222423
|
createDiff,
|
|
222370
222424
|
cameraPreset
|
|
222371
222425
|
}) => {
|
|
222372
|
-
const relativeFilePath =
|
|
222426
|
+
const relativeFilePath = path66.relative(projectDir, file);
|
|
222373
222427
|
const successPaths = [];
|
|
222374
222428
|
const warningMessages = [];
|
|
222375
222429
|
const mismatches = [];
|
|
@@ -222379,7 +222433,7 @@ var processSnapshotFile = async ({
|
|
|
222379
222433
|
let schSvg;
|
|
222380
222434
|
try {
|
|
222381
222435
|
if (isCircuitJsonFile(file)) {
|
|
222382
|
-
const parsed = JSON.parse(
|
|
222436
|
+
const parsed = JSON.parse(fs64.readFileSync(file, "utf-8"));
|
|
222383
222437
|
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
222384
222438
|
} else {
|
|
222385
222439
|
const completePlatformConfig = getCompletePlatformConfig(platformConfig2);
|
|
@@ -222450,12 +222504,12 @@ var processSnapshotFile = async ({
|
|
|
222450
222504
|
} catch (error) {
|
|
222451
222505
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
222452
222506
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
222453
|
-
const fileDir =
|
|
222454
|
-
const relativeDir =
|
|
222455
|
-
const snapDir2 = snapshotsDirName ?
|
|
222456
|
-
const base2 =
|
|
222457
|
-
const snap3dPath =
|
|
222458
|
-
const existing3dSnapshot =
|
|
222507
|
+
const fileDir = path66.dirname(file);
|
|
222508
|
+
const relativeDir = path66.relative(projectDir, fileDir);
|
|
222509
|
+
const snapDir2 = snapshotsDirName ? path66.join(projectDir, snapshotsDirName, relativeDir) : path66.join(fileDir, "__snapshots__");
|
|
222510
|
+
const base2 = path66.basename(file).replace(/\.[^.]+$/, "");
|
|
222511
|
+
const snap3dPath = path66.join(snapDir2, `${base2}-3d.snap.png`);
|
|
222512
|
+
const existing3dSnapshot = fs64.existsSync(snap3dPath);
|
|
222459
222513
|
if (existing3dSnapshot) {
|
|
222460
222514
|
return {
|
|
222461
222515
|
ok: false,
|
|
@@ -222466,7 +222520,7 @@ var processSnapshotFile = async ({
|
|
|
222466
222520
|
errorMessage: kleur_default.red(`
|
|
222467
222521
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
222468
222522
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
222469
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
222523
|
+
`) + kleur_default.red(` Existing snapshot: ${path66.relative(projectDir, snap3dPath)}
|
|
222470
222524
|
`)
|
|
222471
222525
|
};
|
|
222472
222526
|
}
|
|
@@ -222487,9 +222541,9 @@ var processSnapshotFile = async ({
|
|
|
222487
222541
|
}
|
|
222488
222542
|
}
|
|
222489
222543
|
}
|
|
222490
|
-
const snapDir = snapshotsDirName ?
|
|
222491
|
-
|
|
222492
|
-
const base =
|
|
222544
|
+
const snapDir = snapshotsDirName ? path66.join(projectDir, snapshotsDirName, path66.relative(projectDir, path66.dirname(file))) : path66.join(path66.dirname(file), "__snapshots__");
|
|
222545
|
+
fs64.mkdirSync(snapDir, { recursive: true });
|
|
222546
|
+
const base = path66.basename(file).replace(/\.[^.]+$/, "");
|
|
222493
222547
|
const snapshots = [];
|
|
222494
222548
|
if (pcbOnly || !schematicOnly) {
|
|
222495
222549
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -222503,31 +222557,31 @@ var processSnapshotFile = async ({
|
|
|
222503
222557
|
for (const snapshot of snapshots) {
|
|
222504
222558
|
const { type } = snapshot;
|
|
222505
222559
|
const is3d = type === "3d";
|
|
222506
|
-
const snapPath =
|
|
222507
|
-
const existing =
|
|
222560
|
+
const snapPath = path66.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
222561
|
+
const existing = fs64.existsSync(snapPath);
|
|
222508
222562
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
222509
222563
|
const newContentForFile = snapshot.content;
|
|
222510
222564
|
if (!existing) {
|
|
222511
|
-
|
|
222512
|
-
successPaths.push(
|
|
222565
|
+
fs64.writeFileSync(snapPath, newContentForFile);
|
|
222566
|
+
successPaths.push(path66.relative(projectDir, snapPath));
|
|
222513
222567
|
didUpdate = true;
|
|
222514
222568
|
continue;
|
|
222515
222569
|
}
|
|
222516
|
-
const oldContentBuffer =
|
|
222570
|
+
const oldContentBuffer = fs64.readFileSync(snapPath);
|
|
222517
222571
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
222518
222572
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, createDiff);
|
|
222519
222573
|
if (update) {
|
|
222520
222574
|
if (!forceUpdate && equal2) {
|
|
222521
|
-
successPaths.push(
|
|
222575
|
+
successPaths.push(path66.relative(projectDir, snapPath));
|
|
222522
222576
|
} else {
|
|
222523
|
-
|
|
222524
|
-
successPaths.push(
|
|
222577
|
+
fs64.writeFileSync(snapPath, newContentForFile);
|
|
222578
|
+
successPaths.push(path66.relative(projectDir, snapPath));
|
|
222525
222579
|
didUpdate = true;
|
|
222526
222580
|
}
|
|
222527
222581
|
} else if (!equal2) {
|
|
222528
222582
|
mismatches.push(createDiff ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
222529
222583
|
} else {
|
|
222530
|
-
successPaths.push(
|
|
222584
|
+
successPaths.push(path66.relative(projectDir, snapPath));
|
|
222531
222585
|
}
|
|
222532
222586
|
}
|
|
222533
222587
|
return {
|
|
@@ -222569,12 +222623,12 @@ var snapshotProject = async ({
|
|
|
222569
222623
|
...DEFAULT_IGNORED_PATTERNS,
|
|
222570
222624
|
...ignored.map(normalizeIgnorePattern)
|
|
222571
222625
|
];
|
|
222572
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
222626
|
+
const resolvedPaths = filePaths.map((f2) => path67.resolve(projectDir, f2));
|
|
222573
222627
|
const explicitDirectoryTarget = resolvedPaths.find((resolvedPath) => {
|
|
222574
|
-
if (!
|
|
222628
|
+
if (!fs65.existsSync(resolvedPath)) {
|
|
222575
222629
|
return false;
|
|
222576
222630
|
}
|
|
222577
|
-
return
|
|
222631
|
+
return fs65.statSync(resolvedPath).isDirectory();
|
|
222578
222632
|
});
|
|
222579
222633
|
const boardFiles = findBoardFiles({
|
|
222580
222634
|
projectDir,
|
|
@@ -222583,7 +222637,7 @@ var snapshotProject = async ({
|
|
|
222583
222637
|
});
|
|
222584
222638
|
if (boardFiles.length === 0) {
|
|
222585
222639
|
if (explicitDirectoryTarget) {
|
|
222586
|
-
const relativeDirectory =
|
|
222640
|
+
const relativeDirectory = path67.relative(projectDir, explicitDirectoryTarget) || ".";
|
|
222587
222641
|
const includeBoardFilePatterns = getBoardFilePatterns(projectDir);
|
|
222588
222642
|
const patternSourceMessage = hasConfiguredIncludeBoardFiles(projectDir) ? "Searched using tscircuit.config.json includeBoardFiles" : "Searched using default includeBoardFiles";
|
|
222589
222643
|
onError([
|
|
@@ -222716,7 +222770,7 @@ var registerSnapshot = (program3) => {
|
|
|
222716
222770
|
};
|
|
222717
222771
|
|
|
222718
222772
|
// cli/transpile/register.ts
|
|
222719
|
-
import
|
|
222773
|
+
import path68 from "node:path";
|
|
222720
222774
|
var registerTranspile = (program3) => {
|
|
222721
222775
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
222722
222776
|
try {
|
|
@@ -222724,7 +222778,7 @@ var registerTranspile = (program3) => {
|
|
|
222724
222778
|
fileOrDir: file,
|
|
222725
222779
|
includeBoardFiles: false
|
|
222726
222780
|
});
|
|
222727
|
-
const distDir =
|
|
222781
|
+
const distDir = path68.join(projectDir, "dist");
|
|
222728
222782
|
validateMainInDist(projectDir, distDir);
|
|
222729
222783
|
console.log("Transpiling entry file...");
|
|
222730
222784
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -222803,11 +222857,11 @@ registerImport(program2);
|
|
|
222803
222857
|
registerConvert(program2);
|
|
222804
222858
|
registerSimulate(program2);
|
|
222805
222859
|
if (process.argv.includes("--version") || process.argv.includes("-v") || process.argv.includes("-V")) {
|
|
222806
|
-
console.log(getVersion());
|
|
222860
|
+
console.log(getVersion({ verbose: process.argv.includes("--verbose") }));
|
|
222807
222861
|
process.exit(0);
|
|
222808
222862
|
}
|
|
222809
|
-
program2.command("version").description("Print CLI version").action(() => {
|
|
222810
|
-
console.log(getVersion());
|
|
222863
|
+
program2.command("version").description("Print CLI version").option("--verbose", "Print tscircuit + CLI dependency versions").action((options) => {
|
|
222864
|
+
console.log(getVersion({ verbose: options.verbose }));
|
|
222811
222865
|
});
|
|
222812
222866
|
if (process.argv.length === 2) {
|
|
222813
222867
|
import_perfect_cli.perfectCli(program2, process.argv).catch((err) => {
|
package/dist/lib/index.js
CHANGED
|
@@ -60445,7 +60445,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
60445
60445
|
}));
|
|
60446
60446
|
};
|
|
60447
60447
|
// package.json
|
|
60448
|
-
var version = "0.1.
|
|
60448
|
+
var version = "0.1.1108";
|
|
60449
60449
|
var package_default = {
|
|
60450
60450
|
name: "@tscircuit/cli",
|
|
60451
60451
|
version,
|