@tscircuit/cli 0.1.1797 → 0.1.1798
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/README.md +18 -0
- package/dist/cli/build/build.worker.js +272 -150
- package/dist/cli/main.js +1315 -1171
- package/dist/cli/snapshot/snapshot.worker.js +178 -60
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -2485,8 +2485,8 @@ export default {
|
|
|
2485
2485
|
import { parentPort } from "node:worker_threads";
|
|
2486
2486
|
|
|
2487
2487
|
// lib/shared/process-snapshot-file.ts
|
|
2488
|
-
import
|
|
2489
|
-
import
|
|
2488
|
+
import fs9 from "node:fs";
|
|
2489
|
+
import path8 from "node:path";
|
|
2490
2490
|
|
|
2491
2491
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
2492
2492
|
function normalizeDir(dir) {
|
|
@@ -2908,8 +2908,8 @@ var readCurrentCircuitJsonBuild = ({
|
|
|
2908
2908
|
};
|
|
2909
2909
|
|
|
2910
2910
|
// lib/shared/generate-circuit-json.tsx
|
|
2911
|
-
import
|
|
2912
|
-
import
|
|
2911
|
+
import fs6 from "node:fs";
|
|
2912
|
+
import path6 from "node:path";
|
|
2913
2913
|
import { pathToFileURL } from "node:url";
|
|
2914
2914
|
import Debug from "debug";
|
|
2915
2915
|
|
|
@@ -3615,6 +3615,120 @@ var registerStaticAssetLoaders = (platformConfig) => {
|
|
|
3615
3615
|
}
|
|
3616
3616
|
};
|
|
3617
3617
|
|
|
3618
|
+
// lib/shared/solver-diagnostics.ts
|
|
3619
|
+
import fs5 from "node:fs";
|
|
3620
|
+
import path5 from "node:path";
|
|
3621
|
+
var escapeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
3622
|
+
var cloneAsJson = (value, ancestors = new WeakMap, path6 = "#") => {
|
|
3623
|
+
if (value === undefined)
|
|
3624
|
+
return { value_type: "undefined" };
|
|
3625
|
+
if (typeof value === "bigint") {
|
|
3626
|
+
return { value_type: "bigint", value: value.toString() };
|
|
3627
|
+
}
|
|
3628
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
3629
|
+
return { value_type: "number", value: value.toString() };
|
|
3630
|
+
}
|
|
3631
|
+
if (typeof value === "number" && Object.is(value, -0)) {
|
|
3632
|
+
return { value_type: "number", value: "-0" };
|
|
3633
|
+
}
|
|
3634
|
+
if (typeof value === "symbol") {
|
|
3635
|
+
return { value_type: "symbol", value: value.description ?? null };
|
|
3636
|
+
}
|
|
3637
|
+
if (typeof value === "function") {
|
|
3638
|
+
return {
|
|
3639
|
+
value_type: "function",
|
|
3640
|
+
name: value.name || null,
|
|
3641
|
+
source: value.toString()
|
|
3642
|
+
};
|
|
3643
|
+
}
|
|
3644
|
+
if (value === null || typeof value !== "object")
|
|
3645
|
+
return value;
|
|
3646
|
+
const ancestorPath = ancestors.get(value);
|
|
3647
|
+
if (ancestorPath) {
|
|
3648
|
+
return { value_type: "circular_reference", path: ancestorPath };
|
|
3649
|
+
}
|
|
3650
|
+
ancestors.set(value, path6);
|
|
3651
|
+
try {
|
|
3652
|
+
if (Array.isArray(value)) {
|
|
3653
|
+
return value.map((item, index) => cloneAsJson(item, ancestors, `${path6}/${index}`));
|
|
3654
|
+
}
|
|
3655
|
+
if (value instanceof Date) {
|
|
3656
|
+
return { value_type: "date", value: value.toISOString() };
|
|
3657
|
+
}
|
|
3658
|
+
if (value instanceof RegExp) {
|
|
3659
|
+
return {
|
|
3660
|
+
value_type: "regexp",
|
|
3661
|
+
source: value.source,
|
|
3662
|
+
flags: value.flags
|
|
3663
|
+
};
|
|
3664
|
+
}
|
|
3665
|
+
if (value instanceof Map) {
|
|
3666
|
+
return {
|
|
3667
|
+
value_type: "map",
|
|
3668
|
+
entries: Array.from(value.entries(), ([key, item], index) => [
|
|
3669
|
+
cloneAsJson(key, ancestors, `${path6}/entries/${index}/0`),
|
|
3670
|
+
cloneAsJson(item, ancestors, `${path6}/entries/${index}/1`)
|
|
3671
|
+
])
|
|
3672
|
+
};
|
|
3673
|
+
}
|
|
3674
|
+
if (value instanceof Set) {
|
|
3675
|
+
return {
|
|
3676
|
+
value_type: "set",
|
|
3677
|
+
values: Array.from(value.values(), (item, index) => cloneAsJson(item, ancestors, `${path6}/values/${index}`))
|
|
3678
|
+
};
|
|
3679
|
+
}
|
|
3680
|
+
if (value instanceof Error) {
|
|
3681
|
+
return {
|
|
3682
|
+
value_type: "error",
|
|
3683
|
+
name: value.name,
|
|
3684
|
+
message: value.message,
|
|
3685
|
+
stack: value.stack
|
|
3686
|
+
};
|
|
3687
|
+
}
|
|
3688
|
+
const clonedObject = {};
|
|
3689
|
+
for (const [key, item] of Object.entries(value)) {
|
|
3690
|
+
clonedObject[key] = cloneAsJson(item, ancestors, `${path6}/${escapeJsonPointerSegment(key)}`);
|
|
3691
|
+
}
|
|
3692
|
+
return clonedObject;
|
|
3693
|
+
} finally {
|
|
3694
|
+
ancestors.delete(value);
|
|
3695
|
+
}
|
|
3696
|
+
};
|
|
3697
|
+
|
|
3698
|
+
class SolverDiagnostics {
|
|
3699
|
+
options;
|
|
3700
|
+
solverInvocations = [];
|
|
3701
|
+
constructor(options) {
|
|
3702
|
+
this.options = options;
|
|
3703
|
+
}
|
|
3704
|
+
attachToRootCircuit(rootCircuit) {
|
|
3705
|
+
if (!this.options.enabled)
|
|
3706
|
+
return;
|
|
3707
|
+
rootCircuit.on?.("solver:started", (rawEvent) => {
|
|
3708
|
+
const event = rawEvent;
|
|
3709
|
+
const constructorArgs = Array.isArray(event.solverConstructorArgs) ? event.solverConstructorArgs : [event.solverParams];
|
|
3710
|
+
this.solverInvocations.push({
|
|
3711
|
+
sequence: this.solverInvocations.length,
|
|
3712
|
+
solver_name: typeof event.solverName === "string" ? event.solverName : "unknown_solver",
|
|
3713
|
+
component_name: typeof event.componentName === "string" ? event.componentName : null,
|
|
3714
|
+
constructor_args: cloneAsJson(constructorArgs)
|
|
3715
|
+
});
|
|
3716
|
+
});
|
|
3717
|
+
}
|
|
3718
|
+
finalize() {
|
|
3719
|
+
if (!this.options.enabled)
|
|
3720
|
+
return;
|
|
3721
|
+
fs5.mkdirSync(path5.dirname(this.options.outputPath), { recursive: true });
|
|
3722
|
+
fs5.writeFileSync(this.options.outputPath, `${JSON.stringify({
|
|
3723
|
+
format: "tscircuit_solver_debug_v1",
|
|
3724
|
+
entrypoint: this.options.entrypoint,
|
|
3725
|
+
solvers: this.solverInvocations
|
|
3726
|
+
}, null, 2)}
|
|
3727
|
+
`);
|
|
3728
|
+
this.options.log?.(`Solver inputs written to ${this.options.outputPath}`);
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3618
3732
|
// lib/shared/generate-circuit-json.tsx
|
|
3619
3733
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
3620
3734
|
var debug = Debug("tsci:generate-circuit-json");
|
|
@@ -3642,6 +3756,7 @@ async function generateCircuitJson({
|
|
|
3642
3756
|
injectedProps,
|
|
3643
3757
|
onAsyncEffectStatus,
|
|
3644
3758
|
autorouterDiagnostics: autorouterDiagnosticsOptions,
|
|
3759
|
+
solverDiagnostics: solverDiagnosticsOptions,
|
|
3645
3760
|
sourceFilesystemMd5Hash
|
|
3646
3761
|
}) {
|
|
3647
3762
|
debug(`Generating circuit JSON for ${filePath}`);
|
|
@@ -3655,12 +3770,14 @@ async function generateCircuitJson({
|
|
|
3655
3770
|
});
|
|
3656
3771
|
const autorouterDiagnostics = new AutorouterDiagnostics(autorouterDiagnosticsOptions);
|
|
3657
3772
|
autorouterDiagnostics.attachToRootCircuit(runner);
|
|
3658
|
-
const
|
|
3659
|
-
|
|
3773
|
+
const solverDiagnostics = solverDiagnosticsOptions ? new SolverDiagnostics(solverDiagnosticsOptions) : null;
|
|
3774
|
+
solverDiagnostics?.attachToRootCircuit(runner);
|
|
3775
|
+
const absoluteFilePath = path6.isAbsolute(filePath) ? filePath : path6.resolve(process.cwd(), filePath);
|
|
3776
|
+
const projectDir = path6.dirname(absoluteFilePath);
|
|
3660
3777
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
3661
|
-
const relativeComponentPath =
|
|
3662
|
-
const baseFileName = outputFileName ||
|
|
3663
|
-
const outputPath =
|
|
3778
|
+
const relativeComponentPath = path6.relative(projectDir, absoluteFilePath);
|
|
3779
|
+
const baseFileName = outputFileName || path6.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
3780
|
+
const outputPath = path6.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
3664
3781
|
debug(`Project directory: ${projectDir}`);
|
|
3665
3782
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
3666
3783
|
debug(`Output path: ${outputPath}`);
|
|
@@ -3680,7 +3797,7 @@ async function generateCircuitJson({
|
|
|
3680
3797
|
return false;
|
|
3681
3798
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
3682
3799
|
return false;
|
|
3683
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
3800
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path6.extname(normalizedFilePath)))
|
|
3684
3801
|
return false;
|
|
3685
3802
|
return true;
|
|
3686
3803
|
},
|
|
@@ -3712,11 +3829,12 @@ async function generateCircuitJson({
|
|
|
3712
3829
|
runner.render();
|
|
3713
3830
|
}
|
|
3714
3831
|
runner.emit("renderComplete");
|
|
3832
|
+
solverDiagnostics?.finalize();
|
|
3715
3833
|
const circuitJson = addSourceFilesystemHash(await runner.getCircuitJson(), currentSourceFilesystemMd5Hash);
|
|
3716
3834
|
await autorouterDiagnostics.finalize(circuitJson);
|
|
3717
3835
|
if (saveToFile) {
|
|
3718
3836
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
3719
|
-
|
|
3837
|
+
fs6.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
3720
3838
|
}
|
|
3721
3839
|
return {
|
|
3722
3840
|
circuitJson,
|
|
@@ -3751,28 +3869,28 @@ var getOrGenerateCircuitJson = async (options) => {
|
|
|
3751
3869
|
|
|
3752
3870
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
3753
3871
|
import { createHash as createHash2 } from "node:crypto";
|
|
3754
|
-
import
|
|
3755
|
-
import
|
|
3872
|
+
import fs7 from "node:fs";
|
|
3873
|
+
import path7 from "node:path";
|
|
3756
3874
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
3757
|
-
function createLocalCacheEngine(cacheDir =
|
|
3875
|
+
function createLocalCacheEngine(cacheDir = path7.join(process.cwd(), ".tscircuit", "cache")) {
|
|
3758
3876
|
return {
|
|
3759
3877
|
getItem: (key) => {
|
|
3760
3878
|
try {
|
|
3761
3879
|
const hash = createHash2("md5").update(key).digest("hex");
|
|
3762
3880
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
3763
|
-
const filePath =
|
|
3764
|
-
return
|
|
3881
|
+
const filePath = path7.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
3882
|
+
return fs7.readFileSync(filePath, "utf-8");
|
|
3765
3883
|
} catch {
|
|
3766
3884
|
return null;
|
|
3767
3885
|
}
|
|
3768
3886
|
},
|
|
3769
3887
|
setItem: (key, value) => {
|
|
3770
3888
|
try {
|
|
3771
|
-
|
|
3889
|
+
fs7.mkdirSync(cacheDir, { recursive: true });
|
|
3772
3890
|
const hash = createHash2("md5").update(key).digest("hex");
|
|
3773
3891
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
3774
|
-
const filePath =
|
|
3775
|
-
|
|
3892
|
+
const filePath = path7.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
3893
|
+
fs7.writeFileSync(filePath, value);
|
|
3776
3894
|
} catch {}
|
|
3777
3895
|
}
|
|
3778
3896
|
};
|
|
@@ -3788,15 +3906,15 @@ function getPlatformConfigWithCliDefaults(userConfig) {
|
|
|
3788
3906
|
loadFromUrl: async (url) => {
|
|
3789
3907
|
let fetchUrl = url;
|
|
3790
3908
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
3791
|
-
const absolutePath =
|
|
3909
|
+
const absolutePath = path7.resolve(process.cwd(), url);
|
|
3792
3910
|
fetchUrl = `file://${absolutePath}`;
|
|
3793
3911
|
} else if (url.startsWith("/")) {
|
|
3794
|
-
if (
|
|
3912
|
+
if (fs7.existsSync(url)) {
|
|
3795
3913
|
fetchUrl = `file://${url}`;
|
|
3796
3914
|
} else {
|
|
3797
3915
|
const relativePath = `.${url}`;
|
|
3798
|
-
const absolutePath =
|
|
3799
|
-
if (
|
|
3916
|
+
const absolutePath = path7.resolve(process.cwd(), relativePath);
|
|
3917
|
+
if (fs7.existsSync(absolutePath)) {
|
|
3800
3918
|
fetchUrl = `file://${absolutePath}`;
|
|
3801
3919
|
} else {
|
|
3802
3920
|
fetchUrl = `file://${url}`;
|
|
@@ -3895,7 +4013,7 @@ var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
|
3895
4013
|
|
|
3896
4014
|
// lib/shared/compare-images.ts
|
|
3897
4015
|
import looksSame from "@tscircuit/image-utils/looks-same";
|
|
3898
|
-
import
|
|
4016
|
+
import fs8 from "node:fs/promises";
|
|
3899
4017
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
3900
4018
|
const b1 = Buffer.from(buffer1);
|
|
3901
4019
|
const b2 = Buffer.from(buffer2);
|
|
@@ -3911,9 +4029,9 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
|
|
|
3911
4029
|
highlightColor: "#ff00ff",
|
|
3912
4030
|
tolerance: 2
|
|
3913
4031
|
});
|
|
3914
|
-
await
|
|
4032
|
+
await fs8.writeFile(diffPath, diffBuffer);
|
|
3915
4033
|
} else {
|
|
3916
|
-
await
|
|
4034
|
+
await fs8.writeFile(diffPath, buffer2);
|
|
3917
4035
|
}
|
|
3918
4036
|
}
|
|
3919
4037
|
return { equal };
|
|
@@ -3942,7 +4060,7 @@ var processSnapshotFile = async ({
|
|
|
3942
4060
|
cameraPreset,
|
|
3943
4061
|
pcbLayer
|
|
3944
4062
|
}) => {
|
|
3945
|
-
const relativeFilePath =
|
|
4063
|
+
const relativeFilePath = path8.relative(projectDir, file);
|
|
3946
4064
|
const successPaths = [];
|
|
3947
4065
|
const warningMessages = [];
|
|
3948
4066
|
const mismatches = [];
|
|
@@ -3953,7 +4071,7 @@ var processSnapshotFile = async ({
|
|
|
3953
4071
|
let simulationSvgAssets = [];
|
|
3954
4072
|
try {
|
|
3955
4073
|
if (isCircuitJsonFile(file)) {
|
|
3956
|
-
const parsed = JSON.parse(
|
|
4074
|
+
const parsed = JSON.parse(fs9.readFileSync(file, "utf-8"));
|
|
3957
4075
|
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
3958
4076
|
} else {
|
|
3959
4077
|
const platformConfigWithCliDefaults = getPlatformConfigWithCliDefaults(platformConfig);
|
|
@@ -4037,12 +4155,12 @@ var processSnapshotFile = async ({
|
|
|
4037
4155
|
} catch (error) {
|
|
4038
4156
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4039
4157
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
4040
|
-
const fileDir =
|
|
4041
|
-
const relativeDir =
|
|
4042
|
-
const snapDir2 = snapshotsDirName ?
|
|
4043
|
-
const base2 =
|
|
4044
|
-
const snap3dPath =
|
|
4045
|
-
const existing3dSnapshot =
|
|
4158
|
+
const fileDir = path8.dirname(file);
|
|
4159
|
+
const relativeDir = path8.relative(projectDir, fileDir);
|
|
4160
|
+
const snapDir2 = snapshotsDirName ? path8.join(projectDir, snapshotsDirName, relativeDir) : path8.join(fileDir, "__snapshots__");
|
|
4161
|
+
const base2 = path8.basename(file).replace(/\.[^.]+$/, "");
|
|
4162
|
+
const snap3dPath = path8.join(snapDir2, `${base2}-3d.snap.png`);
|
|
4163
|
+
const existing3dSnapshot = fs9.existsSync(snap3dPath);
|
|
4046
4164
|
if (existing3dSnapshot) {
|
|
4047
4165
|
return {
|
|
4048
4166
|
ok: false,
|
|
@@ -4053,7 +4171,7 @@ var processSnapshotFile = async ({
|
|
|
4053
4171
|
errorMessage: kleur_default.red(`
|
|
4054
4172
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
4055
4173
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
4056
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
4174
|
+
`) + kleur_default.red(` Existing snapshot: ${path8.relative(projectDir, snap3dPath)}
|
|
4057
4175
|
`)
|
|
4058
4176
|
};
|
|
4059
4177
|
}
|
|
@@ -4074,9 +4192,9 @@ var processSnapshotFile = async ({
|
|
|
4074
4192
|
}
|
|
4075
4193
|
}
|
|
4076
4194
|
}
|
|
4077
|
-
const snapDir = snapshotsDirName ?
|
|
4078
|
-
|
|
4079
|
-
const base =
|
|
4195
|
+
const snapDir = snapshotsDirName ? path8.join(projectDir, snapshotsDirName, path8.relative(projectDir, path8.dirname(file))) : path8.join(path8.dirname(file), "__snapshots__");
|
|
4196
|
+
fs9.mkdirSync(snapDir, { recursive: true });
|
|
4197
|
+
const base = path8.basename(file).replace(/\.[^.]+$/, "");
|
|
4080
4198
|
const snapshots = [];
|
|
4081
4199
|
if (!simulationOnly && (pcbOnly || !schematicOnly)) {
|
|
4082
4200
|
let pcbSnapshotType = "pcb";
|
|
@@ -4115,17 +4233,17 @@ var processSnapshotFile = async ({
|
|
|
4115
4233
|
for (const snapshot of snapshots) {
|
|
4116
4234
|
const { type } = snapshot;
|
|
4117
4235
|
const is3d = type === "3d";
|
|
4118
|
-
const snapPath =
|
|
4119
|
-
const existing =
|
|
4236
|
+
const snapPath = path8.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
4237
|
+
const existing = fs9.existsSync(snapPath);
|
|
4120
4238
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
4121
4239
|
const newContentForFile = snapshot.content;
|
|
4122
4240
|
if (!existing) {
|
|
4123
|
-
|
|
4124
|
-
successPaths.push(
|
|
4241
|
+
fs9.writeFileSync(snapPath, newContentForFile);
|
|
4242
|
+
successPaths.push(path8.relative(projectDir, snapPath));
|
|
4125
4243
|
didUpdate = true;
|
|
4126
4244
|
continue;
|
|
4127
4245
|
}
|
|
4128
|
-
const oldContentBuffer =
|
|
4246
|
+
const oldContentBuffer = fs9.readFileSync(snapPath);
|
|
4129
4247
|
let equal;
|
|
4130
4248
|
let diffPath;
|
|
4131
4249
|
if (createDiff) {
|
|
@@ -4137,16 +4255,16 @@ var processSnapshotFile = async ({
|
|
|
4137
4255
|
}
|
|
4138
4256
|
if (update) {
|
|
4139
4257
|
if (!forceUpdate && equal) {
|
|
4140
|
-
successPaths.push(
|
|
4258
|
+
successPaths.push(path8.relative(projectDir, snapPath));
|
|
4141
4259
|
} else {
|
|
4142
|
-
|
|
4143
|
-
successPaths.push(
|
|
4260
|
+
fs9.writeFileSync(snapPath, newContentForFile);
|
|
4261
|
+
successPaths.push(path8.relative(projectDir, snapPath));
|
|
4144
4262
|
didUpdate = true;
|
|
4145
4263
|
}
|
|
4146
4264
|
} else if (!equal) {
|
|
4147
4265
|
mismatches.push(diffPath ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
4148
4266
|
} else {
|
|
4149
|
-
successPaths.push(
|
|
4267
|
+
successPaths.push(path8.relative(projectDir, snapPath));
|
|
4150
4268
|
}
|
|
4151
4269
|
}
|
|
4152
4270
|
return {
|
|
@@ -4159,8 +4277,8 @@ var processSnapshotFile = async ({
|
|
|
4159
4277
|
};
|
|
4160
4278
|
|
|
4161
4279
|
// lib/project-config/index.ts
|
|
4162
|
-
import * as
|
|
4163
|
-
import * as
|
|
4280
|
+
import * as fs10 from "node:fs";
|
|
4281
|
+
import * as path9 from "node:path";
|
|
4164
4282
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
4165
4283
|
|
|
4166
4284
|
// lib/project-config/project-config-schema.ts
|
|
@@ -4240,10 +4358,10 @@ var stripWrappingQuotes = (value) => {
|
|
|
4240
4358
|
var loadProjectEnv = (projectDir) => {
|
|
4241
4359
|
const initialEnvKeys = new Set(Object.keys(process.env));
|
|
4242
4360
|
for (const envFileName of ENV_FILENAMES) {
|
|
4243
|
-
const envPath =
|
|
4244
|
-
if (!
|
|
4361
|
+
const envPath = path9.join(projectDir, envFileName);
|
|
4362
|
+
if (!fs10.existsSync(envPath))
|
|
4245
4363
|
continue;
|
|
4246
|
-
const envContent =
|
|
4364
|
+
const envContent = fs10.readFileSync(envPath, "utf8");
|
|
4247
4365
|
for (const rawLine of envContent.split(/\r?\n/)) {
|
|
4248
4366
|
const line = rawLine.trim();
|
|
4249
4367
|
if (!line || line.startsWith("#"))
|
|
@@ -4261,12 +4379,12 @@ var loadProjectEnv = (projectDir) => {
|
|
|
4261
4379
|
}
|
|
4262
4380
|
};
|
|
4263
4381
|
var loadProjectConfigSync = (projectDir = process.cwd()) => {
|
|
4264
|
-
const configPath =
|
|
4265
|
-
if (!
|
|
4382
|
+
const configPath = path9.join(projectDir, CONFIG_FILENAME);
|
|
4383
|
+
if (!fs10.existsSync(configPath)) {
|
|
4266
4384
|
return null;
|
|
4267
4385
|
}
|
|
4268
4386
|
try {
|
|
4269
|
-
const configContent =
|
|
4387
|
+
const configContent = fs10.readFileSync(configPath, "utf8");
|
|
4270
4388
|
const parsedConfig = JSON.parse(configContent);
|
|
4271
4389
|
return projectConfigSchema.parse(parsedConfig);
|
|
4272
4390
|
} catch (error) {
|
|
@@ -4277,12 +4395,12 @@ var loadProjectConfigSync = (projectDir = process.cwd()) => {
|
|
|
4277
4395
|
var loadProjectConfigModule = async (projectDir) => {
|
|
4278
4396
|
loadProjectEnv(projectDir);
|
|
4279
4397
|
for (const configFileName of CONFIG_MODULE_FILENAMES) {
|
|
4280
|
-
const configPath =
|
|
4281
|
-
if (!
|
|
4398
|
+
const configPath = path9.join(projectDir, configFileName);
|
|
4399
|
+
if (!fs10.existsSync(configPath))
|
|
4282
4400
|
continue;
|
|
4283
4401
|
try {
|
|
4284
4402
|
const moduleUrl = pathToFileURL2(configPath);
|
|
4285
|
-
const stat =
|
|
4403
|
+
const stat = fs10.statSync(configPath);
|
|
4286
4404
|
moduleUrl.searchParams.set("tsci", String(stat.mtimeMs));
|
|
4287
4405
|
const importedModule = await import(moduleUrl.href);
|
|
4288
4406
|
const exportedConfig = importedModule.default ?? importedModule.config ?? importedModule;
|
|
@@ -4329,13 +4447,13 @@ var getSnapshotsDir = (projectDir = process.cwd()) => {
|
|
|
4329
4447
|
return config?.snapshotsDir;
|
|
4330
4448
|
};
|
|
4331
4449
|
var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
4332
|
-
const configPath =
|
|
4450
|
+
const configPath = path9.join(projectDir, CONFIG_FILENAME);
|
|
4333
4451
|
try {
|
|
4334
4452
|
const configWithSchema = {
|
|
4335
4453
|
$schema: CONFIG_SCHEMA_URL,
|
|
4336
4454
|
...config ?? {}
|
|
4337
4455
|
};
|
|
4338
|
-
|
|
4456
|
+
fs10.writeFileSync(configPath, JSON.stringify(configWithSchema, null, 2));
|
|
4339
4457
|
return true;
|
|
4340
4458
|
} catch (error) {
|
|
4341
4459
|
console.error(`Error saving tscircuit config: ${error}`);
|
package/dist/lib/index.js
CHANGED
|
@@ -65757,7 +65757,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65757
65757
|
}));
|
|
65758
65758
|
};
|
|
65759
65759
|
// package.json
|
|
65760
|
-
var version = "0.1.
|
|
65760
|
+
var version = "0.1.1797";
|
|
65761
65761
|
var package_default = {
|
|
65762
65762
|
name: "@tscircuit/cli",
|
|
65763
65763
|
version,
|