@tscircuit/cli 0.1.981 → 0.1.982
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 +35 -20
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -74395,7 +74395,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74395
74395
|
import { execSync as execSync2 } from "node:child_process";
|
|
74396
74396
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74397
74397
|
// package.json
|
|
74398
|
-
var version = "0.1.
|
|
74398
|
+
var version = "0.1.981";
|
|
74399
74399
|
var package_default = {
|
|
74400
74400
|
name: "@tscircuit/cli",
|
|
74401
74401
|
main: "dist/cli/main.js",
|
|
@@ -175174,6 +175174,17 @@ var buildPreviewImages = async ({
|
|
|
175174
175174
|
});
|
|
175175
175175
|
};
|
|
175176
175176
|
|
|
175177
|
+
// cli/build/utils/exit-build.ts
|
|
175178
|
+
var exitBuild = (code, reason) => {
|
|
175179
|
+
const message = `Build exiting with code ${code}: ${reason}`;
|
|
175180
|
+
if (code === 0) {
|
|
175181
|
+
console.log(kleur_default.dim(message));
|
|
175182
|
+
} else {
|
|
175183
|
+
console.error(kleur_default.yellow(message));
|
|
175184
|
+
}
|
|
175185
|
+
process.exit(code);
|
|
175186
|
+
};
|
|
175187
|
+
|
|
175177
175188
|
// cli/build/generate-kicad-project.ts
|
|
175178
175189
|
import fs49 from "node:fs";
|
|
175179
175190
|
import path50 from "node:path";
|
|
@@ -175729,10 +175740,14 @@ class WorkerPool {
|
|
|
175729
175740
|
initialized = false;
|
|
175730
175741
|
stopped = false;
|
|
175731
175742
|
stopReason = null;
|
|
175743
|
+
stopOnFatal = false;
|
|
175744
|
+
cancellationError = null;
|
|
175732
175745
|
constructor(options) {
|
|
175733
175746
|
this.concurrency = options.concurrency;
|
|
175734
175747
|
this.onLog = options.onLog;
|
|
175735
175748
|
this.workerEntrypointPath = getWorkerEntrypointPath();
|
|
175749
|
+
this.stopOnFatal = options.stopOnFatal ?? false;
|
|
175750
|
+
this.cancellationError = options.cancellationError ?? null;
|
|
175736
175751
|
}
|
|
175737
175752
|
async initWorkers() {
|
|
175738
175753
|
if (this.initialized)
|
|
@@ -175761,6 +175776,9 @@ class WorkerPool {
|
|
|
175761
175776
|
const completedMsg = message;
|
|
175762
175777
|
const job = threadWorker.currentJob;
|
|
175763
175778
|
if (job) {
|
|
175779
|
+
if (this.stopOnFatal && completedMsg.isFatalError && this.cancellationError) {
|
|
175780
|
+
this.stop(this.cancellationError);
|
|
175781
|
+
}
|
|
175764
175782
|
job.resolve({
|
|
175765
175783
|
filePath: completedMsg.file_path,
|
|
175766
175784
|
outputPath: completedMsg.output_path,
|
|
@@ -175867,13 +175885,15 @@ class WorkerPool {
|
|
|
175867
175885
|
}
|
|
175868
175886
|
}
|
|
175869
175887
|
async function buildFilesWithWorkerPool(options) {
|
|
175888
|
+
const cancellationError = new Error("Build cancelled due fatal error");
|
|
175870
175889
|
const pool = new WorkerPool({
|
|
175871
175890
|
concurrency: options.concurrency,
|
|
175872
|
-
onLog: options.onLog
|
|
175891
|
+
onLog: options.onLog,
|
|
175892
|
+
stopOnFatal: options.stopOnFatal,
|
|
175893
|
+
cancellationError
|
|
175873
175894
|
});
|
|
175874
175895
|
const results = [];
|
|
175875
175896
|
const promises = [];
|
|
175876
|
-
const cancellationError = new Error("Build cancelled due fatal error");
|
|
175877
175897
|
for (const file of options.files) {
|
|
175878
175898
|
const promise = pool.queueJob({
|
|
175879
175899
|
filePath: file.filePath,
|
|
@@ -175885,9 +175905,6 @@ async function buildFilesWithWorkerPool(options) {
|
|
|
175885
175905
|
if (options.onJobComplete) {
|
|
175886
175906
|
await options.onJobComplete(result);
|
|
175887
175907
|
}
|
|
175888
|
-
if (options.stopOnFatal && result.isFatalError) {
|
|
175889
|
-
await pool.stop(cancellationError);
|
|
175890
|
-
}
|
|
175891
175908
|
return result;
|
|
175892
175909
|
});
|
|
175893
175910
|
promises.push(promise);
|
|
@@ -176088,9 +176105,6 @@ var registerBuild = (program3) => {
|
|
|
176088
176105
|
ok: result.ok,
|
|
176089
176106
|
isFatalError: result.isFatalError
|
|
176090
176107
|
});
|
|
176091
|
-
if (result.isFatalError) {
|
|
176092
|
-
process.exit(1);
|
|
176093
|
-
}
|
|
176094
176108
|
}
|
|
176095
176109
|
});
|
|
176096
176110
|
};
|
|
@@ -176099,9 +176113,6 @@ var registerBuild = (program3) => {
|
|
|
176099
176113
|
} else {
|
|
176100
176114
|
await buildSequentially();
|
|
176101
176115
|
}
|
|
176102
|
-
if (hasFatalErrors || hasErrors && !resolvedOptions?.ignoreErrors) {
|
|
176103
|
-
process.exit(1);
|
|
176104
|
-
}
|
|
176105
176116
|
const shouldGeneratePreviewImages = resolvedOptions?.previewImages || resolvedOptions?.allImages;
|
|
176106
176117
|
if (shouldGeneratePreviewImages) {
|
|
176107
176118
|
console.log(resolvedOptions?.allImages ? "Generating preview images for all builds..." : "Generating preview images...");
|
|
@@ -176146,7 +176157,7 @@ var registerBuild = (program3) => {
|
|
|
176146
176157
|
console.log("Skipping transpilation because includeBoardFiles is configured and no library entrypoint was found.");
|
|
176147
176158
|
} else {
|
|
176148
176159
|
console.error("No entry file found for transpilation. Make sure you have a lib/index.ts or set mainEntrypoint in tscircuit.config.json");
|
|
176149
|
-
|
|
176160
|
+
exitBuild(1, "transpile entry file not found");
|
|
176150
176161
|
}
|
|
176151
176162
|
} else {
|
|
176152
176163
|
const transpileSuccess = await transpileFile({
|
|
@@ -176156,7 +176167,7 @@ var registerBuild = (program3) => {
|
|
|
176156
176167
|
});
|
|
176157
176168
|
if (!transpileSuccess) {
|
|
176158
176169
|
console.error("Transpilation failed");
|
|
176159
|
-
|
|
176170
|
+
exitBuild(1, "transpile command failed");
|
|
176160
176171
|
}
|
|
176161
176172
|
}
|
|
176162
176173
|
}
|
|
@@ -176191,7 +176202,7 @@ var registerBuild = (program3) => {
|
|
|
176191
176202
|
if (!entryFile) {
|
|
176192
176203
|
console.error("No entry file found for KiCad library generation. Make sure you have a lib/index.ts or set mainEntrypoint/kicadLibraryEntrypointPath in tscircuit.config.json");
|
|
176193
176204
|
if (!resolvedOptions?.ignoreErrors) {
|
|
176194
|
-
|
|
176205
|
+
exitBuild(1, "kicad-library entry file not found");
|
|
176195
176206
|
}
|
|
176196
176207
|
} else {
|
|
176197
176208
|
const libraryName = resolvedOptions?.kicadLibraryName || resolveKicadLibraryName({ projectDir });
|
|
@@ -176206,7 +176217,7 @@ var registerBuild = (program3) => {
|
|
|
176206
176217
|
} catch (err) {
|
|
176207
176218
|
console.error(`Error generating KiCad library: ${err instanceof Error ? err.message : err}`);
|
|
176208
176219
|
if (!resolvedOptions?.ignoreErrors) {
|
|
176209
|
-
|
|
176220
|
+
exitBuild(1, "kicad-library generation failed");
|
|
176210
176221
|
}
|
|
176211
176222
|
}
|
|
176212
176223
|
}
|
|
@@ -176225,7 +176236,7 @@ var registerBuild = (program3) => {
|
|
|
176225
176236
|
if (!entryFile) {
|
|
176226
176237
|
console.error("No entry file found for KiCad PCM generation. Make sure you have a lib/index.ts or set mainEntrypoint/kicadLibraryEntrypointPath in tscircuit.config.json");
|
|
176227
176238
|
if (!resolvedOptions?.ignoreErrors) {
|
|
176228
|
-
|
|
176239
|
+
exitBuild(1, "kicad-pcm entry file not found");
|
|
176229
176240
|
}
|
|
176230
176241
|
} else {
|
|
176231
176242
|
try {
|
|
@@ -176238,11 +176249,12 @@ var registerBuild = (program3) => {
|
|
|
176238
176249
|
} catch (err) {
|
|
176239
176250
|
console.error(`Error generating KiCad PCM assets: ${err instanceof Error ? err.message : err}`);
|
|
176240
176251
|
if (!resolvedOptions?.ignoreErrors) {
|
|
176241
|
-
|
|
176252
|
+
exitBuild(1, "kicad-pcm generation failed");
|
|
176242
176253
|
}
|
|
176243
176254
|
}
|
|
176244
176255
|
}
|
|
176245
176256
|
}
|
|
176257
|
+
const shouldExitNonZero = hasFatalErrors || hasErrors && !resolvedOptions?.ignoreErrors;
|
|
176246
176258
|
const successCount = builtFiles.filter((f2) => f2.ok).length;
|
|
176247
176259
|
const failCount = builtFiles.length - successCount;
|
|
176248
176260
|
const enabledOpts = [
|
|
@@ -176278,11 +176290,14 @@ var registerBuild = (program3) => {
|
|
|
176278
176290
|
console.log(hasErrors ? kleur_default.yellow(`
|
|
176279
176291
|
⚠ Build completed with errors`) : kleur_default.green(`
|
|
176280
176292
|
✓ Done`));
|
|
176281
|
-
|
|
176293
|
+
if (shouldExitNonZero) {
|
|
176294
|
+
exitBuild(1, hasFatalErrors ? "fatal circuit build errors occurred" : "build errors occurred and --ignore-errors was not enabled");
|
|
176295
|
+
}
|
|
176296
|
+
exitBuild(0, "build finished successfully");
|
|
176282
176297
|
} catch (error) {
|
|
176283
176298
|
const message = error instanceof Error ? error.message : String(error);
|
|
176284
176299
|
console.error(message);
|
|
176285
|
-
|
|
176300
|
+
exitBuild(1, "unexpected exception");
|
|
176286
176301
|
}
|
|
176287
176302
|
});
|
|
176288
176303
|
};
|
package/dist/lib/index.js
CHANGED
|
@@ -60414,7 +60414,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
60414
60414
|
}));
|
|
60415
60415
|
};
|
|
60416
60416
|
// package.json
|
|
60417
|
-
var version = "0.1.
|
|
60417
|
+
var version = "0.1.981";
|
|
60418
60418
|
var package_default = {
|
|
60419
60419
|
name: "@tscircuit/cli",
|
|
60420
60420
|
main: "dist/cli/main.js",
|