@tscircuit/cli 0.1.980 → 0.1.981
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 +54 -25
- 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.980";
|
|
74399
74399
|
var package_default = {
|
|
74400
74400
|
name: "@tscircuit/cli",
|
|
74401
74401
|
main: "dist/cli/main.js",
|
|
@@ -174707,8 +174707,8 @@ var applyCiBuildOptions = async ({
|
|
|
174707
174707
|
};
|
|
174708
174708
|
|
|
174709
174709
|
// cli/build/build-file.ts
|
|
174710
|
-
import path45 from "node:path";
|
|
174711
174710
|
import fs45 from "node:fs";
|
|
174711
|
+
import path45 from "node:path";
|
|
174712
174712
|
|
|
174713
174713
|
// lib/shared/circuit-json-diagnostics.ts
|
|
174714
174714
|
function analyzeCircuitJson(circuitJson) {
|
|
@@ -174808,15 +174808,24 @@ function getCompletePlatformConfig(userConfig) {
|
|
|
174808
174808
|
var buildFile = async (input, output, projectDir, options) => {
|
|
174809
174809
|
try {
|
|
174810
174810
|
console.log("Generating circuit JSON...");
|
|
174811
|
+
const isPrebuiltCircuitJson = input.toLowerCase().endsWith(".circuit.json");
|
|
174812
|
+
let circuitJson = [];
|
|
174813
|
+
if (isPrebuiltCircuitJson) {
|
|
174814
|
+
const parsed = JSON.parse(fs45.readFileSync(input, "utf-8"));
|
|
174815
|
+
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
174816
|
+
}
|
|
174811
174817
|
const completePlatformConfig = getCompletePlatformConfig(options?.platformConfig);
|
|
174812
|
-
|
|
174813
|
-
|
|
174814
|
-
|
|
174815
|
-
|
|
174818
|
+
if (!isPrebuiltCircuitJson) {
|
|
174819
|
+
const result = await generateCircuitJson({
|
|
174820
|
+
filePath: input,
|
|
174821
|
+
platformConfig: completePlatformConfig
|
|
174822
|
+
});
|
|
174823
|
+
circuitJson = result.circuitJson;
|
|
174824
|
+
}
|
|
174816
174825
|
fs45.mkdirSync(path45.dirname(output), { recursive: true });
|
|
174817
|
-
fs45.writeFileSync(output, JSON.stringify(
|
|
174826
|
+
fs45.writeFileSync(output, JSON.stringify(circuitJson, null, 2));
|
|
174818
174827
|
console.log(`Circuit JSON written to ${path45.relative(projectDir, output)}`);
|
|
174819
|
-
const { errors, warnings } = analyzeCircuitJson(
|
|
174828
|
+
const { errors, warnings } = analyzeCircuitJson(circuitJson);
|
|
174820
174829
|
if (!options?.ignoreWarnings) {
|
|
174821
174830
|
for (const warn of warnings) {
|
|
174822
174831
|
const msg = warn.message || JSON.stringify(warn);
|
|
@@ -174838,7 +174847,7 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
174838
174847
|
} else {
|
|
174839
174848
|
return {
|
|
174840
174849
|
ok: true,
|
|
174841
|
-
circuitJson
|
|
174850
|
+
circuitJson
|
|
174842
174851
|
};
|
|
174843
174852
|
}
|
|
174844
174853
|
} catch (err) {
|
|
@@ -175248,6 +175257,7 @@ async function getBuildEntrypoints({
|
|
|
175248
175257
|
const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
|
|
175249
175258
|
const buildFromProjectDir = async () => {
|
|
175250
175259
|
const projectConfig2 = loadProjectConfig(resolvedRoot);
|
|
175260
|
+
const hasConfiguredIncludeBoardFiles = Boolean(projectConfig2?.includeBoardFiles?.some((pattern) => pattern.trim()));
|
|
175251
175261
|
const resolvedPreviewComponentPath = projectConfig2?.previewComponentPath ? path51.resolve(resolvedRoot, projectConfig2.previewComponentPath) : undefined;
|
|
175252
175262
|
const resolvedSiteDefaultComponentPath = projectConfig2?.siteDefaultComponentPath ? path51.resolve(resolvedRoot, projectConfig2.siteDefaultComponentPath) : undefined;
|
|
175253
175263
|
if (includeBoardFiles) {
|
|
@@ -175260,6 +175270,14 @@ async function getBuildEntrypoints({
|
|
|
175260
175270
|
circuitFiles: files
|
|
175261
175271
|
};
|
|
175262
175272
|
}
|
|
175273
|
+
if (hasConfiguredIncludeBoardFiles) {
|
|
175274
|
+
return {
|
|
175275
|
+
projectDir: resolvedRoot,
|
|
175276
|
+
previewComponentPath: resolvedPreviewComponentPath,
|
|
175277
|
+
siteDefaultComponentPath: resolvedSiteDefaultComponentPath,
|
|
175278
|
+
circuitFiles: []
|
|
175279
|
+
};
|
|
175280
|
+
}
|
|
175263
175281
|
}
|
|
175264
175282
|
const mainEntrypoint = await getEntrypoint({
|
|
175265
175283
|
projectDir: resolvedRoot,
|
|
@@ -175886,9 +175904,11 @@ async function buildFilesWithWorkerPool(options) {
|
|
|
175886
175904
|
|
|
175887
175905
|
// cli/build/register.ts
|
|
175888
175906
|
var normalizeRelativePath = (projectDir, targetPath) => path55.relative(projectDir, targetPath).split(path55.sep).join("/");
|
|
175907
|
+
var getOutputDirName = (relativePath) => relativePath.replace(/(\.board|\.circuit)?\.tsx$/, "").replace(/\.circuit\.json$/, "");
|
|
175889
175908
|
var registerBuild = (program3) => {
|
|
175890
175909
|
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--kicad-project", "Generate KiCad project directories for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--kicad-library-name <name>", "Specify the name of the KiCad library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--glbs", "Generate GLB 3D model files for every successful build").option("--profile", "Log per-circuit circuit.json generation time during build").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").action(async (file, options) => {
|
|
175891
175910
|
try {
|
|
175911
|
+
const transpileExplicitlyRequested = options?.transpile === true;
|
|
175892
175912
|
const resolvedRoot = path55.resolve(process.cwd());
|
|
175893
175913
|
let projectDir;
|
|
175894
175914
|
if (file) {
|
|
@@ -175968,7 +175988,7 @@ var registerBuild = (program3) => {
|
|
|
175968
175988
|
};
|
|
175969
175989
|
const processBuildResult = async (filePath, outputPath, buildOutcome) => {
|
|
175970
175990
|
const relative10 = path55.relative(projectDir, filePath);
|
|
175971
|
-
const outputDirName = relative10
|
|
175991
|
+
const outputDirName = getOutputDirName(relative10);
|
|
175972
175992
|
builtFiles.push({
|
|
175973
175993
|
sourcePath: filePath,
|
|
175974
175994
|
outputPath,
|
|
@@ -176014,7 +176034,7 @@ var registerBuild = (program3) => {
|
|
|
176014
176034
|
for (const filePath of circuitFiles) {
|
|
176015
176035
|
const relative10 = path55.relative(projectDir, filePath);
|
|
176016
176036
|
console.log(`Building ${relative10}...`);
|
|
176017
|
-
const outputDirName = relative10
|
|
176037
|
+
const outputDirName = getOutputDirName(relative10);
|
|
176018
176038
|
const outputPath = path55.join(distDir, outputDirName, "circuit.json");
|
|
176019
176039
|
const startedAt = resolvedOptions?.profile ? performance.now() : 0;
|
|
176020
176040
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, buildOptions);
|
|
@@ -176032,7 +176052,7 @@ var registerBuild = (program3) => {
|
|
|
176032
176052
|
const buildWithWorkers = async () => {
|
|
176033
176053
|
const filesToBuild = circuitFiles.map((filePath) => {
|
|
176034
176054
|
const relative10 = path55.relative(projectDir, filePath);
|
|
176035
|
-
const outputDirName = relative10
|
|
176055
|
+
const outputDirName = getOutputDirName(relative10);
|
|
176036
176056
|
const outputPath = path55.join(distDir, outputDirName, "circuit.json");
|
|
176037
176057
|
return { filePath, outputPath };
|
|
176038
176058
|
});
|
|
@@ -176110,25 +176130,34 @@ var registerBuild = (program3) => {
|
|
|
176110
176130
|
});
|
|
176111
176131
|
}
|
|
176112
176132
|
if (resolvedOptions?.transpile) {
|
|
176133
|
+
const includeBoardPatterns = projectConfig2?.includeBoardFiles?.filter((pattern) => pattern.trim()) ?? [];
|
|
176134
|
+
const hasConfiguredIncludeBoardFiles = includeBoardPatterns.length > 0;
|
|
176113
176135
|
validateMainInDist(projectDir, distDir);
|
|
176114
176136
|
console.log("Transpiling entry file...");
|
|
176115
176137
|
const { mainEntrypoint: transpileEntrypoint } = await getBuildEntrypoints({
|
|
176116
176138
|
fileOrDir: file,
|
|
176117
176139
|
includeBoardFiles: false
|
|
176118
176140
|
});
|
|
176119
|
-
const
|
|
176141
|
+
const resolvedFileArgPath = file ? path55.resolve(projectDir, file) : undefined;
|
|
176142
|
+
const fileArgIsDirectFile = Boolean(resolvedFileArgPath && fs54.existsSync(resolvedFileArgPath) && fs54.statSync(resolvedFileArgPath).isFile());
|
|
176143
|
+
const entryFile = fileArgIsDirectFile ? resolvedFileArgPath : transpileEntrypoint;
|
|
176120
176144
|
if (!entryFile) {
|
|
176121
|
-
|
|
176122
|
-
|
|
176123
|
-
|
|
176124
|
-
|
|
176125
|
-
|
|
176126
|
-
|
|
176127
|
-
|
|
176128
|
-
|
|
176129
|
-
|
|
176130
|
-
|
|
176131
|
-
|
|
176145
|
+
if (hasConfiguredIncludeBoardFiles && !transpileExplicitlyRequested) {
|
|
176146
|
+
console.log("Skipping transpilation because includeBoardFiles is configured and no library entrypoint was found.");
|
|
176147
|
+
} else {
|
|
176148
|
+
console.error("No entry file found for transpilation. Make sure you have a lib/index.ts or set mainEntrypoint in tscircuit.config.json");
|
|
176149
|
+
process.exit(1);
|
|
176150
|
+
}
|
|
176151
|
+
} else {
|
|
176152
|
+
const transpileSuccess = await transpileFile({
|
|
176153
|
+
input: entryFile,
|
|
176154
|
+
outputDir: distDir,
|
|
176155
|
+
projectDir
|
|
176156
|
+
});
|
|
176157
|
+
if (!transpileSuccess) {
|
|
176158
|
+
console.error("Transpilation failed");
|
|
176159
|
+
process.exit(1);
|
|
176160
|
+
}
|
|
176132
176161
|
}
|
|
176133
176162
|
}
|
|
176134
176163
|
if (resolvedOptions?.site) {
|
|
@@ -176233,7 +176262,7 @@ var registerBuild = (program3) => {
|
|
|
176233
176262
|
console.log(kleur_default.bold("Profile Summary (slowest first)"));
|
|
176234
176263
|
const sortedProfileEntries = [...profileEntries].sort((a3, b3) => b3.durationMs - a3.durationMs);
|
|
176235
176264
|
for (const profileEntry of sortedProfileEntries) {
|
|
176236
|
-
console.log(` ${kleur_default.cyan(profileEntry.durationMs.toFixed(1)
|
|
176265
|
+
console.log(` ${kleur_default.cyan(`${profileEntry.durationMs.toFixed(1)}ms`)} ${profileEntry.filePath}`);
|
|
176237
176266
|
}
|
|
176238
176267
|
}
|
|
176239
176268
|
console.log("");
|
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.980";
|
|
60418
60418
|
var package_default = {
|
|
60419
60419
|
name: "@tscircuit/cli",
|
|
60420
60420
|
main: "dist/cli/main.js",
|