@tscircuit/cli 0.1.2178 → 0.1.2180
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/build/build.worker.js +219 -177
- package/dist/cli/main.js +649 -607
- package/dist/cli/snapshot/snapshot.worker.js +127 -85
- package/dist/lib/index.js +3 -3
- package/package.json +3 -3
|
@@ -12965,8 +12965,8 @@ function convertCircuitJsonToPcbSvg2(elements, options = {}) {
|
|
|
12965
12965
|
}
|
|
12966
12966
|
|
|
12967
12967
|
// lib/shared/process-snapshot-file.ts
|
|
12968
|
-
import
|
|
12969
|
-
import
|
|
12968
|
+
import fs10 from "node:fs";
|
|
12969
|
+
import path9 from "node:path";
|
|
12970
12970
|
|
|
12971
12971
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
12972
12972
|
function normalizeDir(dir) {
|
|
@@ -13385,8 +13385,8 @@ var readCurrentCircuitJsonBuild = ({
|
|
|
13385
13385
|
};
|
|
13386
13386
|
|
|
13387
13387
|
// lib/shared/generate-circuit-json.tsx
|
|
13388
|
-
import
|
|
13389
|
-
import
|
|
13388
|
+
import fs7 from "node:fs";
|
|
13389
|
+
import path7 from "node:path";
|
|
13390
13390
|
import { pathToFileURL } from "node:url";
|
|
13391
13391
|
import Debug2 from "debug";
|
|
13392
13392
|
|
|
@@ -14040,14 +14040,55 @@ class AutorouterDiagnostics {
|
|
|
14040
14040
|
}
|
|
14041
14041
|
}
|
|
14042
14042
|
|
|
14043
|
-
// lib/shared/
|
|
14044
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
14043
|
+
// lib/shared/autorouting-artifacts.ts
|
|
14045
14044
|
import fs3 from "node:fs";
|
|
14046
14045
|
import path3 from "node:path";
|
|
14046
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
14047
|
+
function attachAutoroutingArtifacts(root, filePath, projectDir = process.cwd()) {
|
|
14048
|
+
const entryPath = path3.relative(projectDir, path3.resolve(projectDir, filePath));
|
|
14049
|
+
const entryKey = `${path3.basename(filePath).replace(/[^a-zA-Z0-9_-]/g, "-")}-${createHash2("sha256").update(entryPath).digest("hex").slice(0, 10)}`;
|
|
14050
|
+
const directory = path3.resolve(projectDir, ".tscircuit", "autorouting-artifacts", entryKey);
|
|
14051
|
+
let warnedUnsupportedVersion = false;
|
|
14052
|
+
root.on("autorouting:end", (event) => {
|
|
14053
|
+
try {
|
|
14054
|
+
if (event.pcbTracePathsUnavailableReason) {
|
|
14055
|
+
throw new Error(event.pcbTracePathsUnavailableReason);
|
|
14056
|
+
}
|
|
14057
|
+
if (event.pcbTracePaths === undefined || event._actualRoutingPhaseOrderIndex === undefined) {
|
|
14058
|
+
if (!warnedUnsupportedVersion) {
|
|
14059
|
+
console.warn("Autorouting paths were not provided by this router. Use local routing and update your project's tscircuit package to save replayable JSON.");
|
|
14060
|
+
warnedUnsupportedVersion = true;
|
|
14061
|
+
}
|
|
14062
|
+
return;
|
|
14063
|
+
}
|
|
14064
|
+
if (event.pcbTracePaths.length === 0)
|
|
14065
|
+
return;
|
|
14066
|
+
const phase = event.routingPhaseIndex ?? "default";
|
|
14067
|
+
const order = event._actualRoutingPhaseOrderIndex;
|
|
14068
|
+
const safeSubcircuit = event.subcircuit_id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
14069
|
+
const stage = event.phaseStageIndex === undefined ? "" : `-stage-${event.phaseStageIndex}`;
|
|
14070
|
+
const outputPath = path3.join(directory, `${safeSubcircuit}-phase-${phase}-order-${order}${stage}.pcb-trace-paths.json`);
|
|
14071
|
+
const contents = `${JSON.stringify(event.pcbTracePaths, null, 2)}
|
|
14072
|
+
`;
|
|
14073
|
+
fs3.mkdirSync(directory, { recursive: true });
|
|
14074
|
+
if (!fs3.existsSync(outputPath) || fs3.readFileSync(outputPath, "utf8") !== contents) {
|
|
14075
|
+
fs3.writeFileSync(outputPath, contents);
|
|
14076
|
+
}
|
|
14077
|
+
console.log(`Saved autorouting paths to ${path3.relative(projectDir, outputPath)} (import this JSON into <autoroutingphase pcbTracePaths={...} />).`);
|
|
14078
|
+
} catch (error) {
|
|
14079
|
+
console.warn(`Could not save autorouting paths for ${event.subcircuit_id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
14080
|
+
}
|
|
14081
|
+
});
|
|
14082
|
+
}
|
|
14083
|
+
|
|
14084
|
+
// lib/shared/importFromUserLand.ts
|
|
14085
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
14086
|
+
import fs4 from "node:fs";
|
|
14087
|
+
import path4 from "node:path";
|
|
14047
14088
|
async function importFromUserLand(moduleName, projectDir = process.cwd()) {
|
|
14048
|
-
const userModulePath =
|
|
14049
|
-
if (
|
|
14050
|
-
const userRequire = createRequire2(
|
|
14089
|
+
const userModulePath = path4.join(projectDir, "node_modules", moduleName);
|
|
14090
|
+
if (fs4.existsSync(userModulePath)) {
|
|
14091
|
+
const userRequire = createRequire2(path4.join(projectDir, "noop.js"));
|
|
14051
14092
|
try {
|
|
14052
14093
|
const resolvedUserPath = userRequire.resolve(moduleName);
|
|
14053
14094
|
return await import(resolvedUserPath);
|
|
@@ -14070,8 +14111,8 @@ async function importFromUserLand(moduleName, projectDir = process.cwd()) {
|
|
|
14070
14111
|
}
|
|
14071
14112
|
|
|
14072
14113
|
// lib/shared/register-static-asset-loaders.ts
|
|
14073
|
-
import
|
|
14074
|
-
import
|
|
14114
|
+
import fs5 from "node:fs";
|
|
14115
|
+
import path5 from "node:path";
|
|
14075
14116
|
var STATIC_ASSET_EXTENSIONS = [
|
|
14076
14117
|
".glb",
|
|
14077
14118
|
".gltf",
|
|
@@ -14098,15 +14139,15 @@ var TEXT_STATIC_ASSET_EXTENSIONS = new Set([
|
|
|
14098
14139
|
".kicad_sym"
|
|
14099
14140
|
]);
|
|
14100
14141
|
var readFileContentForStaticLoader = (filePath) => {
|
|
14101
|
-
const ext =
|
|
14142
|
+
const ext = path5.extname(filePath).toLowerCase();
|
|
14102
14143
|
if (TEXT_STATIC_ASSET_EXTENSIONS.has(ext)) {
|
|
14103
|
-
return
|
|
14144
|
+
return fs5.readFileSync(filePath, "utf-8");
|
|
14104
14145
|
}
|
|
14105
|
-
const buffer =
|
|
14146
|
+
const buffer = fs5.readFileSync(filePath);
|
|
14106
14147
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
14107
14148
|
};
|
|
14108
14149
|
var getStaticFileLoader = (filePath) => {
|
|
14109
|
-
const extWithDot =
|
|
14150
|
+
const extWithDot = path5.extname(filePath).toLowerCase();
|
|
14110
14151
|
const ext = extWithDot.replace(/^\./, "");
|
|
14111
14152
|
return activePlatformConfig?.staticFileLoaderMap?.[ext] ?? activePlatformConfig?.staticFileLoaderMap?.[extWithDot];
|
|
14112
14153
|
};
|
|
@@ -14120,12 +14161,12 @@ var normalizeStaticFileLoaderResult = (result) => {
|
|
|
14120
14161
|
};
|
|
14121
14162
|
};
|
|
14122
14163
|
var getBaseUrlFromTsConfig = (projectDir) => {
|
|
14123
|
-
const tsconfigPath =
|
|
14164
|
+
const tsconfigPath = path5.join(projectDir, "tsconfig.json");
|
|
14124
14165
|
try {
|
|
14125
|
-
if (!
|
|
14166
|
+
if (!fs5.existsSync(tsconfigPath)) {
|
|
14126
14167
|
return null;
|
|
14127
14168
|
}
|
|
14128
|
-
const tsconfigContent =
|
|
14169
|
+
const tsconfigContent = fs5.readFileSync(tsconfigPath, "utf-8");
|
|
14129
14170
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
14130
14171
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
14131
14172
|
return tsconfig.compilerOptions.baseUrl;
|
|
@@ -14152,8 +14193,8 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
14152
14193
|
loader: "object"
|
|
14153
14194
|
};
|
|
14154
14195
|
}
|
|
14155
|
-
const baseDir = baseUrl ?
|
|
14156
|
-
const relativePath =
|
|
14196
|
+
const baseDir = baseUrl ? path5.resolve(projectDir, baseUrl) : projectDir;
|
|
14197
|
+
const relativePath = path5.relative(baseDir, args.path).split(path5.sep).join("/");
|
|
14157
14198
|
const pathStr = `./${relativePath}`;
|
|
14158
14199
|
return {
|
|
14159
14200
|
exports: {
|
|
@@ -14169,8 +14210,8 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
14169
14210
|
};
|
|
14170
14211
|
|
|
14171
14212
|
// lib/shared/solver-diagnostics.ts
|
|
14172
|
-
import
|
|
14173
|
-
import
|
|
14213
|
+
import fs6 from "node:fs";
|
|
14214
|
+
import path6 from "node:path";
|
|
14174
14215
|
var escapeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
14175
14216
|
var cloneAsJson = (value, ancestors = new WeakMap, path = "#") => {
|
|
14176
14217
|
if (value === undefined)
|
|
@@ -14271,8 +14312,8 @@ class SolverDiagnostics {
|
|
|
14271
14312
|
finalize() {
|
|
14272
14313
|
if (!this.options.enabled)
|
|
14273
14314
|
return;
|
|
14274
|
-
|
|
14275
|
-
|
|
14315
|
+
fs6.mkdirSync(path6.dirname(this.options.outputPath), { recursive: true });
|
|
14316
|
+
fs6.writeFileSync(this.options.outputPath, `${JSON.stringify({
|
|
14276
14317
|
format: "tscircuit_solver_debug_v1",
|
|
14277
14318
|
entrypoint: this.options.entrypoint,
|
|
14278
14319
|
solvers: this.solverInvocations
|
|
@@ -14315,7 +14356,7 @@ async function generateCircuitJson({
|
|
|
14315
14356
|
}) {
|
|
14316
14357
|
debug2(`Generating circuit JSON for ${filePath}`);
|
|
14317
14358
|
const currentSourceFilesystemMd5Hash = sourceFilesystemMd5Hash ?? getSourceFilesystemMd5Hash(filePath);
|
|
14318
|
-
const projectRootDir =
|
|
14359
|
+
const projectRootDir = path7.resolve(projectDirOption ?? process.cwd());
|
|
14319
14360
|
const React = await importFromUserLand("react", projectRootDir);
|
|
14320
14361
|
globalThis.React = React;
|
|
14321
14362
|
registerStaticAssetLoaders(platformConfig, projectRootDir);
|
|
@@ -14327,12 +14368,13 @@ async function generateCircuitJson({
|
|
|
14327
14368
|
autorouterDiagnostics.attachToRootCircuit(runner);
|
|
14328
14369
|
const solverDiagnostics = solverDiagnosticsOptions ? new SolverDiagnostics(solverDiagnosticsOptions) : null;
|
|
14329
14370
|
solverDiagnostics?.attachToRootCircuit(runner);
|
|
14330
|
-
|
|
14331
|
-
const
|
|
14371
|
+
attachAutoroutingArtifacts(runner, filePath, projectRootDir);
|
|
14372
|
+
const absoluteFilePath = path7.isAbsolute(filePath) ? filePath : path7.resolve(projectRootDir, filePath);
|
|
14373
|
+
const sourceDir = path7.dirname(absoluteFilePath);
|
|
14332
14374
|
const resolvedOutputDir = outputDir ?? sourceDir;
|
|
14333
|
-
const relativeComponentPath =
|
|
14334
|
-
const baseFileName = outputFileName ||
|
|
14335
|
-
const outputPath =
|
|
14375
|
+
const relativeComponentPath = path7.relative(sourceDir, absoluteFilePath);
|
|
14376
|
+
const baseFileName = outputFileName || path7.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
14377
|
+
const outputPath = path7.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
14336
14378
|
debug2(`Project directory: ${sourceDir}`);
|
|
14337
14379
|
debug2(`Relative component path: ${relativeComponentPath}`);
|
|
14338
14380
|
debug2(`Output path: ${outputPath}`);
|
|
@@ -14352,7 +14394,7 @@ async function generateCircuitJson({
|
|
|
14352
14394
|
return false;
|
|
14353
14395
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
14354
14396
|
return false;
|
|
14355
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
14397
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path7.extname(normalizedFilePath)))
|
|
14356
14398
|
return false;
|
|
14357
14399
|
return true;
|
|
14358
14400
|
},
|
|
@@ -14389,7 +14431,7 @@ async function generateCircuitJson({
|
|
|
14389
14431
|
await autorouterDiagnostics.finalize(circuitJson);
|
|
14390
14432
|
if (saveToFile) {
|
|
14391
14433
|
debug2(`Saving circuit JSON to ${outputPath}`);
|
|
14392
|
-
|
|
14434
|
+
fs7.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
14393
14435
|
}
|
|
14394
14436
|
return {
|
|
14395
14437
|
circuitJson,
|
|
@@ -14423,9 +14465,9 @@ var getOrGenerateCircuitJson = async (options) => {
|
|
|
14423
14465
|
};
|
|
14424
14466
|
|
|
14425
14467
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
14426
|
-
import { createHash as
|
|
14427
|
-
import
|
|
14428
|
-
import
|
|
14468
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
14469
|
+
import fs8 from "node:fs";
|
|
14470
|
+
import path8 from "node:path";
|
|
14429
14471
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
14430
14472
|
|
|
14431
14473
|
// lib/shared/platform-config-utils.ts
|
|
@@ -14463,25 +14505,25 @@ var mergePlatformConfigs = (...configs) => {
|
|
|
14463
14505
|
};
|
|
14464
14506
|
|
|
14465
14507
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
14466
|
-
function createLocalCacheEngine(cacheDir =
|
|
14508
|
+
function createLocalCacheEngine(cacheDir = path8.join(process.cwd(), ".tscircuit", "cache")) {
|
|
14467
14509
|
return {
|
|
14468
14510
|
getItem: (key) => {
|
|
14469
14511
|
try {
|
|
14470
|
-
const hash =
|
|
14512
|
+
const hash = createHash3("md5").update(key).digest("hex");
|
|
14471
14513
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
14472
|
-
const filePath =
|
|
14473
|
-
return
|
|
14514
|
+
const filePath = path8.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
14515
|
+
return fs8.readFileSync(filePath, "utf-8");
|
|
14474
14516
|
} catch {
|
|
14475
14517
|
return null;
|
|
14476
14518
|
}
|
|
14477
14519
|
},
|
|
14478
14520
|
setItem: (key, value) => {
|
|
14479
14521
|
try {
|
|
14480
|
-
|
|
14481
|
-
const hash =
|
|
14522
|
+
fs8.mkdirSync(cacheDir, { recursive: true });
|
|
14523
|
+
const hash = createHash3("md5").update(key).digest("hex");
|
|
14482
14524
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
14483
|
-
const filePath =
|
|
14484
|
-
|
|
14525
|
+
const filePath = path8.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
14526
|
+
fs8.writeFileSync(filePath, value);
|
|
14485
14527
|
} catch {}
|
|
14486
14528
|
}
|
|
14487
14529
|
};
|
|
@@ -14489,7 +14531,7 @@ function createLocalCacheEngine(cacheDir = path7.join(process.cwd(), ".tscircuit
|
|
|
14489
14531
|
function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
14490
14532
|
const projectDir = options?.projectDir ?? process.cwd();
|
|
14491
14533
|
const basePlatformConfig = getPlatformConfig();
|
|
14492
|
-
const cacheDir =
|
|
14534
|
+
const cacheDir = path8.join(projectDir, ".tscircuit", "cache");
|
|
14493
14535
|
const defaultConfig = {
|
|
14494
14536
|
...basePlatformConfig,
|
|
14495
14537
|
localCacheEngine: createLocalCacheEngine(cacheDir),
|
|
@@ -14499,15 +14541,15 @@ function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
|
14499
14541
|
loadFromUrl: async (url) => {
|
|
14500
14542
|
let fetchUrl = url;
|
|
14501
14543
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
14502
|
-
const absolutePath =
|
|
14544
|
+
const absolutePath = path8.resolve(projectDir, url);
|
|
14503
14545
|
fetchUrl = `file://${absolutePath}`;
|
|
14504
14546
|
} else if (url.startsWith("/")) {
|
|
14505
|
-
if (
|
|
14547
|
+
if (fs8.existsSync(url)) {
|
|
14506
14548
|
fetchUrl = `file://${url}`;
|
|
14507
14549
|
} else {
|
|
14508
14550
|
const relativePath = `.${url}`;
|
|
14509
|
-
const absolutePath =
|
|
14510
|
-
if (
|
|
14551
|
+
const absolutePath = path8.resolve(projectDir, relativePath);
|
|
14552
|
+
if (fs8.existsSync(absolutePath)) {
|
|
14511
14553
|
fetchUrl = `file://${absolutePath}`;
|
|
14512
14554
|
} else {
|
|
14513
14555
|
fetchUrl = `file://${url}`;
|
|
@@ -14592,7 +14634,7 @@ var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
|
14592
14634
|
|
|
14593
14635
|
// lib/shared/compare-images.ts
|
|
14594
14636
|
import looksSame from "@tscircuit/image-utils/looks-same";
|
|
14595
|
-
import
|
|
14637
|
+
import fs9 from "node:fs/promises";
|
|
14596
14638
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
14597
14639
|
if (Buffer.from(buffer1).equals(Buffer.from(buffer2))) {
|
|
14598
14640
|
return { equal: true };
|
|
@@ -14612,9 +14654,9 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
|
|
|
14612
14654
|
highlightColor: "#ff00ff",
|
|
14613
14655
|
tolerance: 2
|
|
14614
14656
|
});
|
|
14615
|
-
await
|
|
14657
|
+
await fs9.writeFile(diffPath, diffBuffer);
|
|
14616
14658
|
} else {
|
|
14617
|
-
await
|
|
14659
|
+
await fs9.writeFile(diffPath, buffer2);
|
|
14618
14660
|
}
|
|
14619
14661
|
}
|
|
14620
14662
|
return { equal };
|
|
@@ -14643,7 +14685,7 @@ var processSnapshotFile = async ({
|
|
|
14643
14685
|
cameraPreset,
|
|
14644
14686
|
pcbLayer
|
|
14645
14687
|
}) => {
|
|
14646
|
-
const relativeFilePath =
|
|
14688
|
+
const relativeFilePath = path9.relative(projectDir, file);
|
|
14647
14689
|
const successPaths = [];
|
|
14648
14690
|
const warningMessages = [];
|
|
14649
14691
|
const mismatches = [];
|
|
@@ -14654,7 +14696,7 @@ var processSnapshotFile = async ({
|
|
|
14654
14696
|
let simulationSvgAssets = [];
|
|
14655
14697
|
try {
|
|
14656
14698
|
if (isCircuitJsonFile(file)) {
|
|
14657
|
-
const parsed = JSON.parse(
|
|
14699
|
+
const parsed = JSON.parse(fs10.readFileSync(file, "utf-8"));
|
|
14658
14700
|
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
14659
14701
|
} else {
|
|
14660
14702
|
const platformConfigWithCliDefaults = getPlatformConfigWithCliDefaults(platformConfig, { projectDir });
|
|
@@ -14739,12 +14781,12 @@ var processSnapshotFile = async ({
|
|
|
14739
14781
|
} catch (error) {
|
|
14740
14782
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
14741
14783
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
14742
|
-
const fileDir =
|
|
14743
|
-
const relativeDir =
|
|
14744
|
-
const snapDir = snapshotsDirName ?
|
|
14745
|
-
const base =
|
|
14746
|
-
const snap3dPath =
|
|
14747
|
-
const existing3dSnapshot =
|
|
14784
|
+
const fileDir = path9.dirname(file);
|
|
14785
|
+
const relativeDir = path9.relative(projectDir, fileDir);
|
|
14786
|
+
const snapDir = snapshotsDirName ? path9.join(projectDir, snapshotsDirName, relativeDir) : path9.join(fileDir, "__snapshots__");
|
|
14787
|
+
const base = path9.basename(file).replace(/\.[^.]+$/, "");
|
|
14788
|
+
const snap3dPath = path9.join(snapDir, `${base}-3d.snap.png`);
|
|
14789
|
+
const existing3dSnapshot = fs10.existsSync(snap3dPath);
|
|
14748
14790
|
if (existing3dSnapshot) {
|
|
14749
14791
|
return {
|
|
14750
14792
|
ok: false,
|
|
@@ -14755,7 +14797,7 @@ var processSnapshotFile = async ({
|
|
|
14755
14797
|
errorMessage: kleur_default.red(`
|
|
14756
14798
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
14757
14799
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
14758
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
14800
|
+
`) + kleur_default.red(` Existing snapshot: ${path9.relative(projectDir, snap3dPath)}
|
|
14759
14801
|
`)
|
|
14760
14802
|
};
|
|
14761
14803
|
}
|
|
@@ -14776,9 +14818,9 @@ var processSnapshotFile = async ({
|
|
|
14776
14818
|
}
|
|
14777
14819
|
}
|
|
14778
14820
|
}
|
|
14779
|
-
const snapDir = snapshotsDirName ?
|
|
14780
|
-
|
|
14781
|
-
const base =
|
|
14821
|
+
const snapDir = snapshotsDirName ? path9.join(projectDir, snapshotsDirName, path9.relative(projectDir, path9.dirname(file))) : path9.join(path9.dirname(file), "__snapshots__");
|
|
14822
|
+
fs10.mkdirSync(snapDir, { recursive: true });
|
|
14823
|
+
const base = path9.basename(file).replace(/\.[^.]+$/, "");
|
|
14782
14824
|
const snapshots = [];
|
|
14783
14825
|
if (!simulationOnly && (pcbOnly || !schematicOnly)) {
|
|
14784
14826
|
let pcbSnapshotType = "pcb";
|
|
@@ -14819,17 +14861,17 @@ var processSnapshotFile = async ({
|
|
|
14819
14861
|
for (const snapshot of snapshots) {
|
|
14820
14862
|
const { type } = snapshot;
|
|
14821
14863
|
const is3d = type === "3d";
|
|
14822
|
-
const snapPath =
|
|
14823
|
-
const existing =
|
|
14864
|
+
const snapPath = path9.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
14865
|
+
const existing = fs10.existsSync(snapPath);
|
|
14824
14866
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
14825
14867
|
const newContentForFile = snapshot.content;
|
|
14826
14868
|
if (!existing) {
|
|
14827
|
-
|
|
14828
|
-
successPaths.push(
|
|
14869
|
+
fs10.writeFileSync(snapPath, newContentForFile);
|
|
14870
|
+
successPaths.push(path9.relative(projectDir, snapPath));
|
|
14829
14871
|
didUpdate = true;
|
|
14830
14872
|
continue;
|
|
14831
14873
|
}
|
|
14832
|
-
const oldContentBuffer =
|
|
14874
|
+
const oldContentBuffer = fs10.readFileSync(snapPath);
|
|
14833
14875
|
let equal;
|
|
14834
14876
|
let diffPath;
|
|
14835
14877
|
if (update && !createDiff) {
|
|
@@ -14843,16 +14885,16 @@ var processSnapshotFile = async ({
|
|
|
14843
14885
|
}
|
|
14844
14886
|
if (update) {
|
|
14845
14887
|
if (!forceUpdate && equal) {
|
|
14846
|
-
successPaths.push(
|
|
14888
|
+
successPaths.push(path9.relative(projectDir, snapPath));
|
|
14847
14889
|
} else {
|
|
14848
|
-
|
|
14849
|
-
successPaths.push(
|
|
14890
|
+
fs10.writeFileSync(snapPath, newContentForFile);
|
|
14891
|
+
successPaths.push(path9.relative(projectDir, snapPath));
|
|
14850
14892
|
didUpdate = true;
|
|
14851
14893
|
}
|
|
14852
14894
|
} else if (!equal) {
|
|
14853
14895
|
mismatches.push(diffPath ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
14854
14896
|
} else {
|
|
14855
|
-
successPaths.push(
|
|
14897
|
+
successPaths.push(path9.relative(projectDir, snapPath));
|
|
14856
14898
|
}
|
|
14857
14899
|
}
|
|
14858
14900
|
return {
|
|
@@ -14865,8 +14907,8 @@ var processSnapshotFile = async ({
|
|
|
14865
14907
|
};
|
|
14866
14908
|
|
|
14867
14909
|
// lib/project-config/index.ts
|
|
14868
|
-
import * as
|
|
14869
|
-
import * as
|
|
14910
|
+
import * as fs11 from "node:fs";
|
|
14911
|
+
import * as path10 from "node:path";
|
|
14870
14912
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
14871
14913
|
|
|
14872
14914
|
// lib/project-config/project-config-schema.ts
|
|
@@ -14950,10 +14992,10 @@ var stripWrappingQuotes = (value) => {
|
|
|
14950
14992
|
var loadProjectEnv = (projectDir) => {
|
|
14951
14993
|
const initialEnvKeys = new Set(Object.keys(process.env));
|
|
14952
14994
|
for (const envFileName of ENV_FILENAMES) {
|
|
14953
|
-
const envPath =
|
|
14954
|
-
if (!
|
|
14995
|
+
const envPath = path10.join(projectDir, envFileName);
|
|
14996
|
+
if (!fs11.existsSync(envPath))
|
|
14955
14997
|
continue;
|
|
14956
|
-
const envContent =
|
|
14998
|
+
const envContent = fs11.readFileSync(envPath, "utf8");
|
|
14957
14999
|
for (const rawLine of envContent.split(/\r?\n/)) {
|
|
14958
15000
|
const line = rawLine.trim();
|
|
14959
15001
|
if (!line || line.startsWith("#"))
|
|
@@ -14971,12 +15013,12 @@ var loadProjectEnv = (projectDir) => {
|
|
|
14971
15013
|
}
|
|
14972
15014
|
};
|
|
14973
15015
|
var loadProjectConfigSync = (projectDir = process.cwd()) => {
|
|
14974
|
-
const configPath =
|
|
14975
|
-
if (!
|
|
15016
|
+
const configPath = path10.join(projectDir, CONFIG_FILENAME);
|
|
15017
|
+
if (!fs11.existsSync(configPath)) {
|
|
14976
15018
|
return null;
|
|
14977
15019
|
}
|
|
14978
15020
|
try {
|
|
14979
|
-
const configContent =
|
|
15021
|
+
const configContent = fs11.readFileSync(configPath, "utf8");
|
|
14980
15022
|
const parsedConfig = JSON.parse(configContent);
|
|
14981
15023
|
return projectConfigSchema.parse(parsedConfig);
|
|
14982
15024
|
} catch (error) {
|
|
@@ -14987,12 +15029,12 @@ var loadProjectConfigSync = (projectDir = process.cwd()) => {
|
|
|
14987
15029
|
var loadProjectConfigModule = async (projectDir) => {
|
|
14988
15030
|
loadProjectEnv(projectDir);
|
|
14989
15031
|
for (const configFileName of CONFIG_MODULE_FILENAMES) {
|
|
14990
|
-
const configPath =
|
|
14991
|
-
if (!
|
|
15032
|
+
const configPath = path10.join(projectDir, configFileName);
|
|
15033
|
+
if (!fs11.existsSync(configPath))
|
|
14992
15034
|
continue;
|
|
14993
15035
|
try {
|
|
14994
15036
|
const moduleUrl = pathToFileURL2(configPath);
|
|
14995
|
-
const stat =
|
|
15037
|
+
const stat = fs11.statSync(configPath);
|
|
14996
15038
|
moduleUrl.searchParams.set("tsci", String(stat.mtimeMs));
|
|
14997
15039
|
const importedModule = await import(moduleUrl.href);
|
|
14998
15040
|
const exportedConfig = importedModule.default ?? importedModule.config ?? importedModule;
|
|
@@ -15046,13 +15088,13 @@ var getSnapshotsDir = (projectDir = process.cwd()) => {
|
|
|
15046
15088
|
return config?.snapshotsDir;
|
|
15047
15089
|
};
|
|
15048
15090
|
var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
15049
|
-
const configPath =
|
|
15091
|
+
const configPath = path10.join(projectDir, CONFIG_FILENAME);
|
|
15050
15092
|
try {
|
|
15051
15093
|
const configWithSchema = {
|
|
15052
15094
|
$schema: CONFIG_SCHEMA_URL,
|
|
15053
15095
|
...config ?? {}
|
|
15054
15096
|
};
|
|
15055
|
-
|
|
15097
|
+
fs11.writeFileSync(configPath, JSON.stringify(configWithSchema, null, 2));
|
|
15056
15098
|
return true;
|
|
15057
15099
|
} catch (error) {
|
|
15058
15100
|
console.error(`Error saving tscircuit config: ${error}`);
|
package/dist/lib/index.js
CHANGED
|
@@ -69109,7 +69109,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
69109
69109
|
}));
|
|
69110
69110
|
};
|
|
69111
69111
|
// package.json
|
|
69112
|
-
var version = "0.1.
|
|
69112
|
+
var version = "0.1.2179";
|
|
69113
69113
|
var package_default = {
|
|
69114
69114
|
name: "@tscircuit/cli",
|
|
69115
69115
|
version,
|
|
@@ -69129,7 +69129,7 @@ var package_default = {
|
|
|
69129
69129
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.15",
|
|
69130
69130
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
69131
69131
|
"@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.11.tgz",
|
|
69132
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
69132
|
+
"@tscircuit/circuit-json-util": "^0.0.116",
|
|
69133
69133
|
"@tscircuit/eval": "0.0.1402",
|
|
69134
69134
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
69135
69135
|
"@tscircuit/file-server": "^0.0.32",
|
|
@@ -69205,7 +69205,7 @@ var package_default = {
|
|
|
69205
69205
|
spicets: "^0.0.4",
|
|
69206
69206
|
stepts: "^0.0.3",
|
|
69207
69207
|
tempy: "^3.1.0",
|
|
69208
|
-
tscircuit: "0.0.
|
|
69208
|
+
tscircuit: "0.0.2647-libonly",
|
|
69209
69209
|
tsx: "^4.7.1",
|
|
69210
69210
|
"typed-ky": "^0.0.4",
|
|
69211
69211
|
zod: "^3.23.8"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2180",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/cli"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.15",
|
|
18
18
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.8",
|
|
19
19
|
"@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.11.tgz",
|
|
20
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
20
|
+
"@tscircuit/circuit-json-util": "^0.0.116",
|
|
21
21
|
"@tscircuit/eval": "0.0.1402",
|
|
22
22
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
23
23
|
"@tscircuit/file-server": "^0.0.32",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"spicets": "^0.0.4",
|
|
94
94
|
"stepts": "^0.0.3",
|
|
95
95
|
"tempy": "^3.1.0",
|
|
96
|
-
"tscircuit": "0.0.
|
|
96
|
+
"tscircuit": "0.0.2647-libonly",
|
|
97
97
|
"tsx": "^4.7.1",
|
|
98
98
|
"typed-ky": "^0.0.4",
|
|
99
99
|
"zod": "^3.23.8"
|