@tscircuit/cli 0.1.900 → 0.1.901
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 +230 -160
- package/dist/lib/index.js +2 -1
- package/package.json +1 -1
- package/types/tscircuit.config.schema.json +4 -0
package/dist/cli/main.js
CHANGED
|
@@ -73493,6 +73493,7 @@ var projectConfigSchema = z.object({
|
|
|
73493
73493
|
kicadLibrary: z.boolean().optional(),
|
|
73494
73494
|
kicadPcm: z.boolean().optional(),
|
|
73495
73495
|
previewImages: z.boolean().optional(),
|
|
73496
|
+
glbs: z.boolean().optional(),
|
|
73496
73497
|
typescriptLibrary: z.boolean().optional()
|
|
73497
73498
|
}).optional()
|
|
73498
73499
|
});
|
|
@@ -74383,7 +74384,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74383
74384
|
import { execSync as execSync2 } from "node:child_process";
|
|
74384
74385
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74385
74386
|
// package.json
|
|
74386
|
-
var version = "0.1.
|
|
74387
|
+
var version = "0.1.900";
|
|
74387
74388
|
var package_default = {
|
|
74388
74389
|
name: "@tscircuit/cli",
|
|
74389
74390
|
main: "dist/cli/main.js",
|
|
@@ -173892,8 +173893,8 @@ var registerRemove = (program3) => {
|
|
|
173892
173893
|
};
|
|
173893
173894
|
|
|
173894
173895
|
// cli/build/register.ts
|
|
173895
|
-
import
|
|
173896
|
-
import
|
|
173896
|
+
import path55 from "node:path";
|
|
173897
|
+
import fs54 from "node:fs";
|
|
173897
173898
|
|
|
173898
173899
|
// cli/build/build-file.ts
|
|
173899
173900
|
import path42 from "node:path";
|
|
@@ -174241,6 +174242,9 @@ var resolveBuildOptions = ({
|
|
|
174241
174242
|
if (!cliOptions?.previewImages && configBuild?.previewImages) {
|
|
174242
174243
|
configAppliedOpts.push("preview-images");
|
|
174243
174244
|
}
|
|
174245
|
+
if (!cliOptions?.glbs && configBuild?.glbs) {
|
|
174246
|
+
configAppliedOpts.push("glbs");
|
|
174247
|
+
}
|
|
174244
174248
|
if (!cliOptions?.transpile && configBuild?.typescriptLibrary) {
|
|
174245
174249
|
configAppliedOpts.push("transpile");
|
|
174246
174250
|
}
|
|
@@ -174250,6 +174254,7 @@ var resolveBuildOptions = ({
|
|
|
174250
174254
|
kicadLibrary: cliOptions?.kicadLibrary ?? configBuild?.kicadLibrary,
|
|
174251
174255
|
kicadPcm: cliOptions?.kicadPcm ?? configBuild?.kicadPcm,
|
|
174252
174256
|
previewImages: cliOptions?.previewImages ?? configBuild?.previewImages,
|
|
174257
|
+
glbs: cliOptions?.glbs ?? configBuild?.glbs,
|
|
174253
174258
|
transpile: cliOptions?.transpile ?? configBuild?.typescriptLibrary
|
|
174254
174259
|
};
|
|
174255
174260
|
return { options, configAppliedOpts };
|
|
@@ -174632,9 +174637,66 @@ var buildPreviewGltf = async ({
|
|
|
174632
174637
|
}
|
|
174633
174638
|
};
|
|
174634
174639
|
|
|
174635
|
-
// cli/build/
|
|
174640
|
+
// cli/build/build-glbs.ts
|
|
174636
174641
|
import fs48 from "node:fs";
|
|
174637
174642
|
import path49 from "node:path";
|
|
174643
|
+
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
174644
|
+
var viewToArrayBuffer2 = (view) => {
|
|
174645
|
+
const copy = new Uint8Array(view.byteLength);
|
|
174646
|
+
copy.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
|
|
174647
|
+
return copy.buffer;
|
|
174648
|
+
};
|
|
174649
|
+
var normalizeToUint8Array2 = (value) => {
|
|
174650
|
+
if (value instanceof Uint8Array) {
|
|
174651
|
+
return value;
|
|
174652
|
+
}
|
|
174653
|
+
if (value instanceof ArrayBuffer) {
|
|
174654
|
+
return new Uint8Array(value);
|
|
174655
|
+
}
|
|
174656
|
+
if (ArrayBuffer.isView(value)) {
|
|
174657
|
+
return new Uint8Array(viewToArrayBuffer2(value));
|
|
174658
|
+
}
|
|
174659
|
+
throw new Error("Expected Uint8Array, ArrayBuffer, or ArrayBufferView for GLB");
|
|
174660
|
+
};
|
|
174661
|
+
var buildGlbs = async ({
|
|
174662
|
+
builtFiles,
|
|
174663
|
+
distDir
|
|
174664
|
+
}) => {
|
|
174665
|
+
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
174666
|
+
if (successfulBuilds.length === 0) {
|
|
174667
|
+
console.warn("No successful build output available for GLB generation.");
|
|
174668
|
+
return;
|
|
174669
|
+
}
|
|
174670
|
+
for (const build of successfulBuilds) {
|
|
174671
|
+
const outputDir = path49.dirname(build.outputPath);
|
|
174672
|
+
const prefixRelative = path49.relative(distDir, outputDir) || ".";
|
|
174673
|
+
const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
|
|
174674
|
+
let circuitJson;
|
|
174675
|
+
try {
|
|
174676
|
+
const circuitJsonRaw = fs48.readFileSync(build.outputPath, "utf-8");
|
|
174677
|
+
circuitJson = JSON.parse(circuitJsonRaw);
|
|
174678
|
+
} catch (error) {
|
|
174679
|
+
console.error(`${prefix}Failed to read circuit JSON:`, error);
|
|
174680
|
+
continue;
|
|
174681
|
+
}
|
|
174682
|
+
try {
|
|
174683
|
+
console.log(`${prefix}Converting circuit to GLB...`);
|
|
174684
|
+
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
174685
|
+
const glbBuffer = await convertCircuitJsonToGltf4(circuitJsonWithFileUrls, {
|
|
174686
|
+
format: "glb"
|
|
174687
|
+
});
|
|
174688
|
+
const glbData = normalizeToUint8Array2(glbBuffer);
|
|
174689
|
+
fs48.writeFileSync(path49.join(outputDir, "3d.glb"), Buffer.from(glbData));
|
|
174690
|
+
console.log(`${prefix}Written 3d.glb`);
|
|
174691
|
+
} catch (error) {
|
|
174692
|
+
console.error(`${prefix}Failed to generate GLB:`, error);
|
|
174693
|
+
}
|
|
174694
|
+
}
|
|
174695
|
+
};
|
|
174696
|
+
|
|
174697
|
+
// cli/build/generate-kicad-project.ts
|
|
174698
|
+
import fs49 from "node:fs";
|
|
174699
|
+
import path50 from "node:path";
|
|
174638
174700
|
var createKicadProContent = ({
|
|
174639
174701
|
projectName,
|
|
174640
174702
|
schematicFileName,
|
|
@@ -174674,10 +174736,10 @@ var generateKicadProject = async ({
|
|
|
174674
174736
|
boardFileName
|
|
174675
174737
|
});
|
|
174676
174738
|
if (writeFiles) {
|
|
174677
|
-
|
|
174678
|
-
|
|
174679
|
-
|
|
174680
|
-
|
|
174739
|
+
fs49.mkdirSync(outputDir, { recursive: true });
|
|
174740
|
+
fs49.writeFileSync(path50.join(outputDir, schematicFileName), schContent);
|
|
174741
|
+
fs49.writeFileSync(path50.join(outputDir, boardFileName), pcbContent);
|
|
174742
|
+
fs49.writeFileSync(path50.join(outputDir, projectFileName), proContent);
|
|
174681
174743
|
}
|
|
174682
174744
|
return {
|
|
174683
174745
|
pcbContent,
|
|
@@ -174689,8 +174751,8 @@ var generateKicadProject = async ({
|
|
|
174689
174751
|
};
|
|
174690
174752
|
|
|
174691
174753
|
// cli/build/transpile/index.ts
|
|
174692
|
-
import
|
|
174693
|
-
import
|
|
174754
|
+
import path52 from "node:path";
|
|
174755
|
+
import fs51 from "node:fs";
|
|
174694
174756
|
import { rollup } from "rollup";
|
|
174695
174757
|
import typescript from "@rollup/plugin-typescript";
|
|
174696
174758
|
import resolve11 from "@rollup/plugin-node-resolve";
|
|
@@ -174699,11 +174761,11 @@ import json from "@rollup/plugin-json";
|
|
|
174699
174761
|
import dts from "rollup-plugin-dts";
|
|
174700
174762
|
|
|
174701
174763
|
// cli/build/transpile/static-asset-plugin.ts
|
|
174702
|
-
import
|
|
174703
|
-
import
|
|
174764
|
+
import fs50 from "node:fs";
|
|
174765
|
+
import path51 from "node:path";
|
|
174704
174766
|
import { createHash } from "node:crypto";
|
|
174705
174767
|
function normalizePathSeparators(filePath) {
|
|
174706
|
-
return filePath.split(
|
|
174768
|
+
return filePath.split(path51.sep).join("/");
|
|
174707
174769
|
}
|
|
174708
174770
|
var STATIC_ASSET_EXTENSIONS = new Set([
|
|
174709
174771
|
".glb",
|
|
@@ -174734,24 +174796,24 @@ var createStaticAssetPlugin = ({
|
|
|
174734
174796
|
return {
|
|
174735
174797
|
name: "tsci-static-assets",
|
|
174736
174798
|
resolveId(source, importer) {
|
|
174737
|
-
const ext =
|
|
174799
|
+
const ext = path51.extname(source).toLowerCase();
|
|
174738
174800
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
174739
174801
|
return null;
|
|
174740
|
-
if (
|
|
174741
|
-
return
|
|
174802
|
+
if (path51.isAbsolute(source)) {
|
|
174803
|
+
return fs50.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
|
|
174742
174804
|
}
|
|
174743
174805
|
if (importer) {
|
|
174744
|
-
const importerNative = importer.split("/").join(
|
|
174745
|
-
const resolvedFromImporter =
|
|
174746
|
-
if (
|
|
174806
|
+
const importerNative = importer.split("/").join(path51.sep);
|
|
174807
|
+
const resolvedFromImporter = path51.resolve(path51.dirname(importerNative), source);
|
|
174808
|
+
if (fs50.existsSync(resolvedFromImporter)) {
|
|
174747
174809
|
return {
|
|
174748
174810
|
id: normalizePathSeparators(resolvedFromImporter),
|
|
174749
174811
|
external: true
|
|
174750
174812
|
};
|
|
174751
174813
|
}
|
|
174752
174814
|
}
|
|
174753
|
-
const resolvedFromProject =
|
|
174754
|
-
if (
|
|
174815
|
+
const resolvedFromProject = path51.resolve(resolvedBaseUrl, source);
|
|
174816
|
+
if (fs50.existsSync(resolvedFromProject)) {
|
|
174755
174817
|
return {
|
|
174756
174818
|
id: normalizePathSeparators(resolvedFromProject),
|
|
174757
174819
|
external: true
|
|
@@ -174764,8 +174826,8 @@ var createStaticAssetPlugin = ({
|
|
|
174764
174826
|
const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
|
|
174765
174827
|
for (const target of targets) {
|
|
174766
174828
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
174767
|
-
const resolvedTarget =
|
|
174768
|
-
if (
|
|
174829
|
+
const resolvedTarget = path51.resolve(resolvedBaseUrl, targetPath);
|
|
174830
|
+
if (fs50.existsSync(resolvedTarget)) {
|
|
174769
174831
|
return {
|
|
174770
174832
|
id: normalizePathSeparators(resolvedTarget),
|
|
174771
174833
|
external: true
|
|
@@ -174791,18 +174853,18 @@ var createStaticAssetPlugin = ({
|
|
|
174791
174853
|
if (chunk.type !== "chunk")
|
|
174792
174854
|
continue;
|
|
174793
174855
|
for (const importedId of chunk.imports) {
|
|
174794
|
-
const ext =
|
|
174856
|
+
const ext = path51.extname(importedId).toLowerCase();
|
|
174795
174857
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
174796
174858
|
continue;
|
|
174797
174859
|
if (!copiedAssets.has(importedId)) {
|
|
174798
|
-
const assetDir =
|
|
174799
|
-
|
|
174800
|
-
const nativePath = importedId.split("/").join(
|
|
174801
|
-
const fileBuffer =
|
|
174860
|
+
const assetDir = path51.join(outputDir, "assets");
|
|
174861
|
+
fs50.mkdirSync(assetDir, { recursive: true });
|
|
174862
|
+
const nativePath = importedId.split("/").join(path51.sep);
|
|
174863
|
+
const fileBuffer = fs50.readFileSync(nativePath);
|
|
174802
174864
|
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
174803
|
-
const fileName = `${
|
|
174804
|
-
const outputFilePath =
|
|
174805
|
-
|
|
174865
|
+
const fileName = `${path51.basename(importedId, ext)}-${hash}${ext}`;
|
|
174866
|
+
const outputFilePath = path51.join(assetDir, fileName);
|
|
174867
|
+
fs50.writeFileSync(outputFilePath, fileBuffer);
|
|
174806
174868
|
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
174807
174869
|
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
174808
174870
|
}
|
|
@@ -174824,17 +174886,17 @@ function escapeRegExp(string) {
|
|
|
174824
174886
|
|
|
174825
174887
|
// cli/build/transpile/index.ts
|
|
174826
174888
|
var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
174827
|
-
if (id.startsWith(".") || id.startsWith("/") ||
|
|
174889
|
+
if (id.startsWith(".") || id.startsWith("/") || path52.isAbsolute(id)) {
|
|
174828
174890
|
return false;
|
|
174829
174891
|
}
|
|
174830
174892
|
let baseUrl = projectDir;
|
|
174831
174893
|
let pathMappings = {};
|
|
174832
|
-
if (tsconfigPath &&
|
|
174894
|
+
if (tsconfigPath && fs51.existsSync(tsconfigPath)) {
|
|
174833
174895
|
try {
|
|
174834
|
-
const tsconfigContent =
|
|
174896
|
+
const tsconfigContent = fs51.readFileSync(tsconfigPath, "utf-8");
|
|
174835
174897
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
174836
174898
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
174837
|
-
baseUrl =
|
|
174899
|
+
baseUrl = path52.resolve(path52.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
174838
174900
|
}
|
|
174839
174901
|
if (tsconfig.compilerOptions?.paths) {
|
|
174840
174902
|
pathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -174848,17 +174910,17 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
|
174848
174910
|
}
|
|
174849
174911
|
}
|
|
174850
174912
|
const potentialPaths = [
|
|
174851
|
-
|
|
174852
|
-
|
|
174853
|
-
|
|
174854
|
-
|
|
174855
|
-
|
|
174856
|
-
|
|
174857
|
-
|
|
174858
|
-
|
|
174859
|
-
|
|
174913
|
+
path52.join(baseUrl, id),
|
|
174914
|
+
path52.join(baseUrl, `${id}.ts`),
|
|
174915
|
+
path52.join(baseUrl, `${id}.tsx`),
|
|
174916
|
+
path52.join(baseUrl, `${id}.js`),
|
|
174917
|
+
path52.join(baseUrl, `${id}.jsx`),
|
|
174918
|
+
path52.join(baseUrl, id, "index.ts"),
|
|
174919
|
+
path52.join(baseUrl, id, "index.tsx"),
|
|
174920
|
+
path52.join(baseUrl, id, "index.js"),
|
|
174921
|
+
path52.join(baseUrl, id, "index.jsx")
|
|
174860
174922
|
];
|
|
174861
|
-
if (potentialPaths.some((p4) =>
|
|
174923
|
+
if (potentialPaths.some((p4) => fs51.existsSync(p4))) {
|
|
174862
174924
|
return false;
|
|
174863
174925
|
}
|
|
174864
174926
|
return true;
|
|
@@ -174869,17 +174931,17 @@ var transpileFile = async ({
|
|
|
174869
174931
|
projectDir
|
|
174870
174932
|
}) => {
|
|
174871
174933
|
try {
|
|
174872
|
-
|
|
174873
|
-
const tsconfigPath =
|
|
174874
|
-
const hasTsConfig =
|
|
174934
|
+
fs51.mkdirSync(outputDir, { recursive: true });
|
|
174935
|
+
const tsconfigPath = path52.join(projectDir, "tsconfig.json");
|
|
174936
|
+
const hasTsConfig = fs51.existsSync(tsconfigPath);
|
|
174875
174937
|
let tsconfigBaseUrl = projectDir;
|
|
174876
174938
|
let tsconfigPathMappings;
|
|
174877
174939
|
if (hasTsConfig) {
|
|
174878
174940
|
try {
|
|
174879
|
-
const tsconfigContent =
|
|
174941
|
+
const tsconfigContent = fs51.readFileSync(tsconfigPath, "utf-8");
|
|
174880
174942
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
174881
174943
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
174882
|
-
tsconfigBaseUrl =
|
|
174944
|
+
tsconfigBaseUrl = path52.resolve(path52.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
174883
174945
|
}
|
|
174884
174946
|
if (tsconfig.compilerOptions?.paths) {
|
|
174885
174947
|
tsconfigPathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -174934,27 +174996,27 @@ var transpileFile = async ({
|
|
|
174934
174996
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
174935
174997
|
plugins: getPlugins()
|
|
174936
174998
|
});
|
|
174937
|
-
const esmOutputPath =
|
|
174999
|
+
const esmOutputPath = path52.join(outputDir, "index.js");
|
|
174938
175000
|
await esmBundle.write({
|
|
174939
175001
|
file: esmOutputPath,
|
|
174940
175002
|
format: "es",
|
|
174941
175003
|
sourcemap: false
|
|
174942
175004
|
});
|
|
174943
|
-
console.log(`ESM bundle written to ${
|
|
175005
|
+
console.log(`ESM bundle written to ${path52.relative(projectDir, esmOutputPath)}`);
|
|
174944
175006
|
console.log("Building CommonJS bundle...");
|
|
174945
175007
|
const cjsBundle = await rollup({
|
|
174946
175008
|
input,
|
|
174947
175009
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
174948
175010
|
plugins: getPlugins()
|
|
174949
175011
|
});
|
|
174950
|
-
const cjsOutputPath =
|
|
175012
|
+
const cjsOutputPath = path52.join(outputDir, "index.cjs");
|
|
174951
175013
|
console.log("Writing CJS bundle to:", cjsOutputPath);
|
|
174952
175014
|
await cjsBundle.write({
|
|
174953
175015
|
file: cjsOutputPath,
|
|
174954
175016
|
format: "cjs",
|
|
174955
175017
|
sourcemap: false
|
|
174956
175018
|
});
|
|
174957
|
-
console.log(`CommonJS bundle written to ${
|
|
175019
|
+
console.log(`CommonJS bundle written to ${path52.relative(projectDir, cjsOutputPath)}`);
|
|
174958
175020
|
console.log("Generating type declarations...");
|
|
174959
175021
|
const dtsBundle = await rollup({
|
|
174960
175022
|
input,
|
|
@@ -174979,9 +175041,9 @@ var transpileFile = async ({
|
|
|
174979
175041
|
dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
|
|
174980
175042
|
dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
|
|
174981
175043
|
dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
|
|
174982
|
-
const dtsOutputPath =
|
|
174983
|
-
|
|
174984
|
-
console.log(`Type declarations written to ${
|
|
175044
|
+
const dtsOutputPath = path52.join(outputDir, "index.d.ts");
|
|
175045
|
+
fs51.writeFileSync(dtsOutputPath, dtsContent);
|
|
175046
|
+
console.log(`Type declarations written to ${path52.relative(projectDir, dtsOutputPath)}`);
|
|
174985
175047
|
console.log(kleur_default.green("Transpilation complete!"));
|
|
174986
175048
|
return true;
|
|
174987
175049
|
} catch (err) {
|
|
@@ -174994,17 +175056,17 @@ var transpileFile = async ({
|
|
|
174994
175056
|
};
|
|
174995
175057
|
|
|
174996
175058
|
// cli/utils/validate-main-in-dist.ts
|
|
174997
|
-
import
|
|
174998
|
-
import
|
|
175059
|
+
import fs52 from "node:fs";
|
|
175060
|
+
import path53 from "node:path";
|
|
174999
175061
|
var validateMainInDist = (projectDir, distDir) => {
|
|
175000
|
-
const packageJsonPath =
|
|
175001
|
-
if (!
|
|
175062
|
+
const packageJsonPath = path53.join(projectDir, "package.json");
|
|
175063
|
+
if (!fs52.existsSync(packageJsonPath))
|
|
175002
175064
|
return;
|
|
175003
|
-
const packageJson = JSON.parse(
|
|
175065
|
+
const packageJson = JSON.parse(fs52.readFileSync(packageJsonPath, "utf-8"));
|
|
175004
175066
|
if (typeof packageJson.main !== "string")
|
|
175005
175067
|
return;
|
|
175006
|
-
const resolvedMainPath =
|
|
175007
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
175068
|
+
const resolvedMainPath = path53.resolve(projectDir, packageJson.main);
|
|
175069
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path53.sep}`);
|
|
175008
175070
|
if (!isMainInDist) {
|
|
175009
175071
|
console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
175010
175072
|
}
|
|
@@ -175026,19 +175088,19 @@ async function getLatestTscircuitCdnUrl() {
|
|
|
175026
175088
|
}
|
|
175027
175089
|
|
|
175028
175090
|
// cli/build/worker-pool.ts
|
|
175029
|
-
import
|
|
175030
|
-
import
|
|
175091
|
+
import path54 from "node:path";
|
|
175092
|
+
import fs53 from "node:fs";
|
|
175031
175093
|
import { Worker } from "node:worker_threads";
|
|
175032
175094
|
var getWorkerEntrypointPath = () => {
|
|
175033
|
-
const tsPath =
|
|
175034
|
-
if (
|
|
175095
|
+
const tsPath = path54.join(import.meta.dir, "build-worker-entrypoint.ts");
|
|
175096
|
+
if (fs53.existsSync(tsPath)) {
|
|
175035
175097
|
return tsPath;
|
|
175036
175098
|
}
|
|
175037
|
-
const jsBundledPath =
|
|
175038
|
-
if (
|
|
175099
|
+
const jsBundledPath = path54.join(import.meta.dir, "build", "build-worker-entrypoint.js");
|
|
175100
|
+
if (fs53.existsSync(jsBundledPath)) {
|
|
175039
175101
|
return jsBundledPath;
|
|
175040
175102
|
}
|
|
175041
|
-
return
|
|
175103
|
+
return path54.join(import.meta.dir, "build-worker-entrypoint.js");
|
|
175042
175104
|
};
|
|
175043
175105
|
|
|
175044
175106
|
class WorkerPool {
|
|
@@ -175197,25 +175259,25 @@ async function buildFilesWithWorkerPool(options) {
|
|
|
175197
175259
|
}
|
|
175198
175260
|
|
|
175199
175261
|
// cli/build/register.ts
|
|
175200
|
-
var normalizeRelativePath = (projectDir, targetPath) =>
|
|
175262
|
+
var normalizeRelativePath = (projectDir, targetPath) => path55.relative(projectDir, targetPath).split(path55.sep).join("/");
|
|
175201
175263
|
var registerBuild = (program3) => {
|
|
175202
|
-
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", "Generate KiCad project directories for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").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) => {
|
|
175264
|
+
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", "Generate KiCad project directories for each successful build output").option("--kicad-library", "Generate KiCad library in dist/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("--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) => {
|
|
175203
175265
|
try {
|
|
175204
|
-
const resolvedRoot =
|
|
175266
|
+
const resolvedRoot = path55.resolve(process.cwd());
|
|
175205
175267
|
let projectDir;
|
|
175206
175268
|
if (file) {
|
|
175207
|
-
const resolved =
|
|
175208
|
-
if (
|
|
175269
|
+
const resolved = path55.resolve(resolvedRoot, file);
|
|
175270
|
+
if (fs54.existsSync(resolved) && fs54.statSync(resolved).isDirectory()) {
|
|
175209
175271
|
projectDir = resolvedRoot;
|
|
175210
175272
|
} else {
|
|
175211
|
-
let currentDir =
|
|
175212
|
-
while (currentDir !==
|
|
175213
|
-
if (
|
|
175273
|
+
let currentDir = path55.dirname(resolved);
|
|
175274
|
+
while (currentDir !== path55.dirname(currentDir)) {
|
|
175275
|
+
if (fs54.existsSync(path55.join(currentDir, "package.json"))) {
|
|
175214
175276
|
break;
|
|
175215
175277
|
}
|
|
175216
|
-
currentDir =
|
|
175278
|
+
currentDir = path55.dirname(currentDir);
|
|
175217
175279
|
}
|
|
175218
|
-
projectDir =
|
|
175280
|
+
projectDir = fs54.existsSync(path55.join(currentDir, "package.json")) ? currentDir : resolvedRoot;
|
|
175219
175281
|
}
|
|
175220
175282
|
} else {
|
|
175221
175283
|
projectDir = resolvedRoot;
|
|
@@ -175253,8 +175315,8 @@ var registerBuild = (program3) => {
|
|
|
175253
175315
|
}
|
|
175254
175316
|
return config;
|
|
175255
175317
|
})();
|
|
175256
|
-
const distDir =
|
|
175257
|
-
|
|
175318
|
+
const distDir = path55.join(projectDir, "dist");
|
|
175319
|
+
fs54.mkdirSync(distDir, { recursive: true });
|
|
175258
175320
|
const concurrencyValue = Math.max(1, Number.parseInt(resolvedOptions?.concurrency || "1", 10));
|
|
175259
175321
|
if (concurrencyValue > 1) {
|
|
175260
175322
|
console.log(`Building ${circuitFiles.length} file(s) with concurrency ${concurrencyValue}...`);
|
|
@@ -175273,7 +175335,7 @@ var registerBuild = (program3) => {
|
|
|
175273
175335
|
platformConfig: platformConfig2
|
|
175274
175336
|
};
|
|
175275
175337
|
const processBuildResult = async (filePath, outputPath, buildOutcome) => {
|
|
175276
|
-
const relative10 =
|
|
175338
|
+
const relative10 = path55.relative(projectDir, filePath);
|
|
175277
175339
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175278
175340
|
builtFiles.push({
|
|
175279
175341
|
sourcePath: filePath,
|
|
@@ -175287,9 +175349,9 @@ var registerBuild = (program3) => {
|
|
|
175287
175349
|
console.error(kleur_default.red(`Fatal error [${buildOutcome.isFatalError.errorType}]: ${buildOutcome.isFatalError.message}`));
|
|
175288
175350
|
}
|
|
175289
175351
|
} else if (resolvedOptions?.site) {
|
|
175290
|
-
const normalizedSourcePath = relative10.split(
|
|
175291
|
-
const relativeOutputPath =
|
|
175292
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
175352
|
+
const normalizedSourcePath = relative10.split(path55.sep).join("/");
|
|
175353
|
+
const relativeOutputPath = path55.join(outputDirName, "circuit.json");
|
|
175354
|
+
const normalizedOutputPath = relativeOutputPath.split(path55.sep).join("/");
|
|
175293
175355
|
staticFileReferences.push({
|
|
175294
175356
|
filePath: normalizedSourcePath,
|
|
175295
175357
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
@@ -175297,12 +175359,12 @@ var registerBuild = (program3) => {
|
|
|
175297
175359
|
}
|
|
175298
175360
|
if (buildOutcome.ok && shouldGenerateKicad) {
|
|
175299
175361
|
let circuitJson = buildOutcome.circuitJson;
|
|
175300
|
-
if (!circuitJson &&
|
|
175301
|
-
circuitJson = JSON.parse(
|
|
175362
|
+
if (!circuitJson && fs54.existsSync(outputPath)) {
|
|
175363
|
+
circuitJson = JSON.parse(fs54.readFileSync(outputPath, "utf-8"));
|
|
175302
175364
|
}
|
|
175303
175365
|
if (circuitJson) {
|
|
175304
|
-
const projectOutputDir =
|
|
175305
|
-
const projectName =
|
|
175366
|
+
const projectOutputDir = path55.join(distDir, outputDirName, "kicad");
|
|
175367
|
+
const projectName = path55.basename(outputDirName);
|
|
175306
175368
|
const project = await generateKicadProject({
|
|
175307
175369
|
circuitJson,
|
|
175308
175370
|
outputDir: projectOutputDir,
|
|
@@ -175318,19 +175380,19 @@ var registerBuild = (program3) => {
|
|
|
175318
175380
|
};
|
|
175319
175381
|
const buildSequentially = async () => {
|
|
175320
175382
|
for (const filePath of circuitFiles) {
|
|
175321
|
-
const relative10 =
|
|
175383
|
+
const relative10 = path55.relative(projectDir, filePath);
|
|
175322
175384
|
console.log(`Building ${relative10}...`);
|
|
175323
175385
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175324
|
-
const outputPath =
|
|
175386
|
+
const outputPath = path55.join(distDir, outputDirName, "circuit.json");
|
|
175325
175387
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, buildOptions);
|
|
175326
175388
|
await processBuildResult(filePath, outputPath, buildOutcome);
|
|
175327
175389
|
}
|
|
175328
175390
|
};
|
|
175329
175391
|
const buildWithWorkers = async () => {
|
|
175330
175392
|
const filesToBuild = circuitFiles.map((filePath) => {
|
|
175331
|
-
const relative10 =
|
|
175393
|
+
const relative10 = path55.relative(projectDir, filePath);
|
|
175332
175394
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175333
|
-
const outputPath =
|
|
175395
|
+
const outputPath = path55.join(distDir, outputDirName, "circuit.json");
|
|
175334
175396
|
return { filePath, outputPath };
|
|
175335
175397
|
});
|
|
175336
175398
|
await buildFilesWithWorkerPool({
|
|
@@ -175344,7 +175406,7 @@ var registerBuild = (program3) => {
|
|
|
175344
175406
|
}
|
|
175345
175407
|
},
|
|
175346
175408
|
onJobComplete: async (result) => {
|
|
175347
|
-
const relative10 =
|
|
175409
|
+
const relative10 = path55.relative(projectDir, result.filePath);
|
|
175348
175410
|
if (result.ok) {
|
|
175349
175411
|
console.log(kleur_default.green(`✓ ${relative10}`));
|
|
175350
175412
|
} else {
|
|
@@ -175388,6 +175450,13 @@ var registerBuild = (program3) => {
|
|
|
175388
175450
|
previewComponentPath
|
|
175389
175451
|
});
|
|
175390
175452
|
}
|
|
175453
|
+
if (resolvedOptions?.glbs) {
|
|
175454
|
+
console.log("Generating GLB models for all builds...");
|
|
175455
|
+
await buildGlbs({
|
|
175456
|
+
builtFiles,
|
|
175457
|
+
distDir
|
|
175458
|
+
});
|
|
175459
|
+
}
|
|
175391
175460
|
if (resolvedOptions?.transpile) {
|
|
175392
175461
|
validateMainInDist(projectDir, distDir);
|
|
175393
175462
|
console.log("Transpiling entry file...");
|
|
@@ -175415,14 +175484,14 @@ var registerBuild = (program3) => {
|
|
|
175415
175484
|
if (resolvedOptions?.useCdnJavascript) {
|
|
175416
175485
|
standaloneScriptSrc = await getLatestTscircuitCdnUrl();
|
|
175417
175486
|
} else {
|
|
175418
|
-
|
|
175487
|
+
fs54.writeFileSync(path55.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
175419
175488
|
}
|
|
175420
175489
|
const indexHtml = getStaticIndexHtmlFile({
|
|
175421
175490
|
files: staticFileReferences,
|
|
175422
175491
|
standaloneScriptSrc,
|
|
175423
175492
|
defaultMainComponentPath: siteDefaultComponentPath ? normalizeRelativePath(projectDir, siteDefaultComponentPath) : undefined
|
|
175424
175493
|
});
|
|
175425
|
-
|
|
175494
|
+
fs54.writeFileSync(path55.join(distDir, "index.html"), indexHtml);
|
|
175426
175495
|
}
|
|
175427
175496
|
if (resolvedOptions?.kicadLibrary) {
|
|
175428
175497
|
console.log("Generating KiCad library...");
|
|
@@ -175442,14 +175511,14 @@ var registerBuild = (program3) => {
|
|
|
175442
175511
|
}
|
|
175443
175512
|
} else {
|
|
175444
175513
|
const libraryName = resolveKicadLibraryName({ projectDir });
|
|
175445
|
-
const kicadLibOutputDir =
|
|
175514
|
+
const kicadLibOutputDir = path55.join(distDir, "kicad-library");
|
|
175446
175515
|
try {
|
|
175447
175516
|
await convertToKicadLibrary({
|
|
175448
175517
|
filePath: entryFile,
|
|
175449
175518
|
libraryName,
|
|
175450
175519
|
outputDir: kicadLibOutputDir
|
|
175451
175520
|
});
|
|
175452
|
-
console.log(` KiCad library generated at ${kleur_default.dim(
|
|
175521
|
+
console.log(` KiCad library generated at ${kleur_default.dim(path55.relative(process.cwd(), kicadLibOutputDir))}`);
|
|
175453
175522
|
} catch (err) {
|
|
175454
175523
|
console.error(`Error generating KiCad library: ${err instanceof Error ? err.message : err}`);
|
|
175455
175524
|
if (!resolvedOptions?.ignoreErrors) {
|
|
@@ -175496,6 +175565,7 @@ var registerBuild = (program3) => {
|
|
|
175496
175565
|
resolvedOptions?.transpile && "transpile",
|
|
175497
175566
|
resolvedOptions?.previewImages && "preview-images",
|
|
175498
175567
|
resolvedOptions?.allImages && "all-images",
|
|
175568
|
+
resolvedOptions?.glbs && "glbs",
|
|
175499
175569
|
resolvedOptions?.kicad && "kicad",
|
|
175500
175570
|
resolvedOptions?.kicadLibrary && "kicad-library",
|
|
175501
175571
|
resolvedOptions?.kicadPcm && "kicad-pcm",
|
|
@@ -175510,7 +175580,7 @@ var registerBuild = (program3) => {
|
|
|
175510
175580
|
if (configAppliedOpts.length > 0) {
|
|
175511
175581
|
console.log(` Config ${kleur_default.magenta(configAppliedOpts.join(", "))} ${kleur_default.dim("(from tscircuit.config.json)")}`);
|
|
175512
175582
|
}
|
|
175513
|
-
console.log(` Output ${kleur_default.dim(
|
|
175583
|
+
console.log(` Output ${kleur_default.dim(path55.relative(process.cwd(), distDir) || "dist")}`);
|
|
175514
175584
|
console.log(hasErrors ? kleur_default.yellow(`
|
|
175515
175585
|
⚠ Build completed with errors`) : kleur_default.green(`
|
|
175516
175586
|
✓ Done`));
|
|
@@ -175524,19 +175594,19 @@ var registerBuild = (program3) => {
|
|
|
175524
175594
|
};
|
|
175525
175595
|
|
|
175526
175596
|
// lib/shared/snapshot-project.ts
|
|
175527
|
-
import
|
|
175528
|
-
import
|
|
175597
|
+
import fs56 from "node:fs";
|
|
175598
|
+
import path56 from "node:path";
|
|
175529
175599
|
import looksSame2 from "looks-same";
|
|
175530
175600
|
import {
|
|
175531
175601
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
175532
175602
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg3
|
|
175533
175603
|
} from "circuit-to-svg";
|
|
175534
|
-
import { convertCircuitJsonToGltf as
|
|
175604
|
+
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf5 } from "circuit-json-to-gltf";
|
|
175535
175605
|
import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffer2 } from "poppygl";
|
|
175536
175606
|
|
|
175537
175607
|
// lib/shared/compare-images.ts
|
|
175538
175608
|
import looksSame from "looks-same";
|
|
175539
|
-
import
|
|
175609
|
+
import fs55 from "node:fs/promises";
|
|
175540
175610
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
175541
175611
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
175542
175612
|
strict: false,
|
|
@@ -175552,7 +175622,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
175552
175622
|
tolerance: 2
|
|
175553
175623
|
});
|
|
175554
175624
|
} else {
|
|
175555
|
-
await
|
|
175625
|
+
await fs55.writeFile(diffPath, buffer2);
|
|
175556
175626
|
}
|
|
175557
175627
|
}
|
|
175558
175628
|
return { equal: equal2 };
|
|
@@ -175577,7 +175647,7 @@ var snapshotProject = async ({
|
|
|
175577
175647
|
...DEFAULT_IGNORED_PATTERNS,
|
|
175578
175648
|
...ignored.map(normalizeIgnorePattern)
|
|
175579
175649
|
];
|
|
175580
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
175650
|
+
const resolvedPaths = filePaths.map((f2) => path56.resolve(projectDir, f2));
|
|
175581
175651
|
const boardFiles = findBoardFiles({
|
|
175582
175652
|
projectDir,
|
|
175583
175653
|
ignore,
|
|
@@ -175591,7 +175661,7 @@ var snapshotProject = async ({
|
|
|
175591
175661
|
const mismatches = [];
|
|
175592
175662
|
let didUpdate = false;
|
|
175593
175663
|
for (const file of boardFiles) {
|
|
175594
|
-
const relativeFilePath =
|
|
175664
|
+
const relativeFilePath = path56.relative(projectDir, file);
|
|
175595
175665
|
let circuitJson;
|
|
175596
175666
|
let pcbSvg;
|
|
175597
175667
|
let schSvg;
|
|
@@ -175633,7 +175703,7 @@ var snapshotProject = async ({
|
|
|
175633
175703
|
let png3d = null;
|
|
175634
175704
|
if (threeD) {
|
|
175635
175705
|
try {
|
|
175636
|
-
const glbBuffer = await
|
|
175706
|
+
const glbBuffer = await convertCircuitJsonToGltf5(circuitJson, {
|
|
175637
175707
|
format: "glb"
|
|
175638
175708
|
});
|
|
175639
175709
|
if (!(glbBuffer instanceof ArrayBuffer)) {
|
|
@@ -175646,17 +175716,17 @@ var snapshotProject = async ({
|
|
|
175646
175716
|
} catch (error) {
|
|
175647
175717
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
175648
175718
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
175649
|
-
const fileDir =
|
|
175650
|
-
const relativeDir =
|
|
175651
|
-
const snapDir2 = snapshotsDirName ?
|
|
175652
|
-
const base2 =
|
|
175653
|
-
const snap3dPath =
|
|
175654
|
-
const existing3dSnapshot =
|
|
175719
|
+
const fileDir = path56.dirname(file);
|
|
175720
|
+
const relativeDir = path56.relative(projectDir, fileDir);
|
|
175721
|
+
const snapDir2 = snapshotsDirName ? path56.join(projectDir, snapshotsDirName, relativeDir) : path56.join(fileDir, "__snapshots__");
|
|
175722
|
+
const base2 = path56.basename(file).replace(/\.tsx$/, "");
|
|
175723
|
+
const snap3dPath = path56.join(snapDir2, `${base2}-3d.snap.png`);
|
|
175724
|
+
const existing3dSnapshot = fs56.existsSync(snap3dPath);
|
|
175655
175725
|
if (existing3dSnapshot) {
|
|
175656
175726
|
onError(kleur_default.red(`
|
|
175657
175727
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
175658
175728
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
175659
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
175729
|
+
`) + kleur_default.red(` Existing snapshot: ${path56.relative(projectDir, snap3dPath)}
|
|
175660
175730
|
`));
|
|
175661
175731
|
return onExit2(1);
|
|
175662
175732
|
} else {
|
|
@@ -175672,9 +175742,9 @@ var snapshotProject = async ({
|
|
|
175672
175742
|
}
|
|
175673
175743
|
}
|
|
175674
175744
|
}
|
|
175675
|
-
const snapDir = snapshotsDirName ?
|
|
175676
|
-
|
|
175677
|
-
const base =
|
|
175745
|
+
const snapDir = snapshotsDirName ? path56.join(projectDir, snapshotsDirName, path56.relative(projectDir, path56.dirname(file))) : path56.join(path56.dirname(file), "__snapshots__");
|
|
175746
|
+
fs56.mkdirSync(snapDir, { recursive: true });
|
|
175747
|
+
const base = path56.basename(file).replace(/\.tsx$/, "");
|
|
175678
175748
|
const snapshots = [];
|
|
175679
175749
|
if (pcbOnly || !schematicOnly) {
|
|
175680
175750
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -175692,31 +175762,31 @@ var snapshotProject = async ({
|
|
|
175692
175762
|
for (const snapshot of snapshots) {
|
|
175693
175763
|
const { type } = snapshot;
|
|
175694
175764
|
const is3d = type === "3d";
|
|
175695
|
-
const snapPath =
|
|
175696
|
-
const existing =
|
|
175765
|
+
const snapPath = path56.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
175766
|
+
const existing = fs56.existsSync(snapPath);
|
|
175697
175767
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
175698
175768
|
const newContentForFile = snapshot.content;
|
|
175699
175769
|
if (!existing) {
|
|
175700
|
-
|
|
175701
|
-
console.log("✅", kleur_default.gray(
|
|
175770
|
+
fs56.writeFileSync(snapPath, newContentForFile);
|
|
175771
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175702
175772
|
didUpdate = true;
|
|
175703
175773
|
continue;
|
|
175704
175774
|
}
|
|
175705
|
-
const oldContentBuffer =
|
|
175775
|
+
const oldContentBuffer = fs56.readFileSync(snapPath);
|
|
175706
175776
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
175707
175777
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
175708
175778
|
if (update) {
|
|
175709
175779
|
if (!forceUpdate && equal2) {
|
|
175710
|
-
console.log("✅", kleur_default.gray(
|
|
175780
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175711
175781
|
} else {
|
|
175712
|
-
|
|
175713
|
-
console.log("✅", kleur_default.gray(
|
|
175782
|
+
fs56.writeFileSync(snapPath, newContentForFile);
|
|
175783
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175714
175784
|
didUpdate = true;
|
|
175715
175785
|
}
|
|
175716
175786
|
} else if (!equal2) {
|
|
175717
175787
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
175718
175788
|
} else {
|
|
175719
|
-
console.log("✅", kleur_default.gray(
|
|
175789
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175720
175790
|
}
|
|
175721
175791
|
}
|
|
175722
175792
|
}
|
|
@@ -175755,22 +175825,22 @@ var registerSnapshot = (program3) => {
|
|
|
175755
175825
|
};
|
|
175756
175826
|
|
|
175757
175827
|
// lib/shared/setup-github-actions.ts
|
|
175758
|
-
import
|
|
175759
|
-
import
|
|
175828
|
+
import fs57 from "node:fs";
|
|
175829
|
+
import path57 from "node:path";
|
|
175760
175830
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
175761
175831
|
const findGitRoot = (startDir) => {
|
|
175762
|
-
let dir =
|
|
175763
|
-
while (dir !==
|
|
175764
|
-
if (
|
|
175832
|
+
let dir = path57.resolve(startDir);
|
|
175833
|
+
while (dir !== path57.parse(dir).root) {
|
|
175834
|
+
if (fs57.existsSync(path57.join(dir, ".git"))) {
|
|
175765
175835
|
return dir;
|
|
175766
175836
|
}
|
|
175767
|
-
dir =
|
|
175837
|
+
dir = path57.dirname(dir);
|
|
175768
175838
|
}
|
|
175769
175839
|
return null;
|
|
175770
175840
|
};
|
|
175771
175841
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
175772
|
-
const workflowsDir =
|
|
175773
|
-
|
|
175842
|
+
const workflowsDir = path57.join(gitRoot, ".github", "workflows");
|
|
175843
|
+
fs57.mkdirSync(workflowsDir, { recursive: true });
|
|
175774
175844
|
const buildWorkflow = `name: tscircuit Build
|
|
175775
175845
|
|
|
175776
175846
|
on:
|
|
@@ -175809,8 +175879,8 @@ jobs:
|
|
|
175809
175879
|
- run: bun install
|
|
175810
175880
|
- run: bunx tsci snapshot
|
|
175811
175881
|
`;
|
|
175812
|
-
writeFileIfNotExists(
|
|
175813
|
-
writeFileIfNotExists(
|
|
175882
|
+
writeFileIfNotExists(path57.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
175883
|
+
writeFileIfNotExists(path57.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
175814
175884
|
};
|
|
175815
175885
|
|
|
175816
175886
|
// cli/setup/register.ts
|
|
@@ -175848,8 +175918,8 @@ function registerAuthSetupNpmrc(program3) {
|
|
|
175848
175918
|
}
|
|
175849
175919
|
|
|
175850
175920
|
// cli/convert/register.ts
|
|
175851
|
-
import
|
|
175852
|
-
import
|
|
175921
|
+
import fs58 from "node:fs/promises";
|
|
175922
|
+
import path58 from "node:path";
|
|
175853
175923
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
175854
175924
|
|
|
175855
175925
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -175970,15 +176040,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
175970
176040
|
var registerConvert = (program3) => {
|
|
175971
176041
|
program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
175972
176042
|
try {
|
|
175973
|
-
const inputPath =
|
|
175974
|
-
const modContent = await
|
|
176043
|
+
const inputPath = path58.resolve(file);
|
|
176044
|
+
const modContent = await fs58.readFile(inputPath, "utf-8");
|
|
175975
176045
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
175976
|
-
const componentName = options.name ??
|
|
176046
|
+
const componentName = options.name ?? path58.basename(inputPath, ".kicad_mod");
|
|
175977
176047
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
175978
176048
|
componentName
|
|
175979
176049
|
});
|
|
175980
|
-
const outputPath = options.output ?
|
|
175981
|
-
await
|
|
176050
|
+
const outputPath = options.output ? path58.resolve(options.output) : path58.join(path58.dirname(inputPath), `${componentName}.tsx`);
|
|
176051
|
+
await fs58.writeFile(outputPath, tsx);
|
|
175982
176052
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
175983
176053
|
} catch (error) {
|
|
175984
176054
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -176094,7 +176164,7 @@ var registerInstall = (program3) => {
|
|
|
176094
176164
|
};
|
|
176095
176165
|
|
|
176096
176166
|
// cli/transpile/register.ts
|
|
176097
|
-
import
|
|
176167
|
+
import path59 from "node:path";
|
|
176098
176168
|
var registerTranspile = (program3) => {
|
|
176099
176169
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
176100
176170
|
try {
|
|
@@ -176102,7 +176172,7 @@ var registerTranspile = (program3) => {
|
|
|
176102
176172
|
fileOrDir: file,
|
|
176103
176173
|
includeBoardFiles: false
|
|
176104
176174
|
});
|
|
176105
|
-
const distDir =
|
|
176175
|
+
const distDir = path59.join(projectDir, "dist");
|
|
176106
176176
|
validateMainInDist(projectDir, distDir);
|
|
176107
176177
|
console.log("Transpiling entry file...");
|
|
176108
176178
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -176130,8 +176200,8 @@ var registerTranspile = (program3) => {
|
|
|
176130
176200
|
};
|
|
176131
176201
|
|
|
176132
176202
|
// lib/shared/register-static-asset-loaders.ts
|
|
176133
|
-
import
|
|
176134
|
-
import
|
|
176203
|
+
import fs59 from "node:fs";
|
|
176204
|
+
import path60 from "node:path";
|
|
176135
176205
|
var STATIC_ASSET_EXTENSIONS2 = [
|
|
176136
176206
|
".glb",
|
|
176137
176207
|
".gltf",
|
|
@@ -176144,12 +176214,12 @@ var STATIC_ASSET_EXTENSIONS2 = [
|
|
|
176144
176214
|
var staticAssetFilter = new RegExp(`(${STATIC_ASSET_EXTENSIONS2.map((ext) => ext.replace(".", "\\.")).join("|")})$`, "i");
|
|
176145
176215
|
var registered = false;
|
|
176146
176216
|
var getBaseUrlFromTsConfig = () => {
|
|
176147
|
-
const tsconfigPath =
|
|
176217
|
+
const tsconfigPath = path60.join(process.cwd(), "tsconfig.json");
|
|
176148
176218
|
try {
|
|
176149
|
-
if (!
|
|
176219
|
+
if (!fs59.existsSync(tsconfigPath)) {
|
|
176150
176220
|
return null;
|
|
176151
176221
|
}
|
|
176152
|
-
const tsconfigContent =
|
|
176222
|
+
const tsconfigContent = fs59.readFileSync(tsconfigPath, "utf-8");
|
|
176153
176223
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
176154
176224
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
176155
176225
|
return tsconfig.compilerOptions.baseUrl;
|
|
@@ -176167,8 +176237,8 @@ var registerStaticAssetLoaders = () => {
|
|
|
176167
176237
|
name: "tsci-static-assets",
|
|
176168
176238
|
setup(build) {
|
|
176169
176239
|
build.onLoad({ filter: staticAssetFilter }, (args) => {
|
|
176170
|
-
const baseDir = baseUrl ?
|
|
176171
|
-
const relativePath =
|
|
176240
|
+
const baseDir = baseUrl ? path60.resolve(process.cwd(), baseUrl) : process.cwd();
|
|
176241
|
+
const relativePath = path60.relative(baseDir, args.path).split(path60.sep).join("/");
|
|
176172
176242
|
const pathStr = `./${relativePath}`;
|
|
176173
176243
|
return {
|
|
176174
176244
|
exports: {
|
|
@@ -176199,15 +176269,15 @@ var checkLoggedIn = () => {
|
|
|
176199
176269
|
|
|
176200
176270
|
// cli/doctor/checks/check-npmrc-registry.ts
|
|
176201
176271
|
import { spawnSync } from "node:child_process";
|
|
176202
|
-
import
|
|
176272
|
+
import fs60 from "node:fs";
|
|
176203
176273
|
import os9 from "node:os";
|
|
176204
|
-
import
|
|
176274
|
+
import path61 from "node:path";
|
|
176205
176275
|
var hasBunInstalled = () => {
|
|
176206
176276
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
176207
176277
|
return result.status === 0;
|
|
176208
176278
|
};
|
|
176209
176279
|
var createTempProject = (tempDir) => {
|
|
176210
|
-
const packageJsonPath =
|
|
176280
|
+
const packageJsonPath = path61.join(tempDir, "package.json");
|
|
176211
176281
|
const packageJson = {
|
|
176212
176282
|
name: "tsci-doctor-check",
|
|
176213
176283
|
version: "0.0.0",
|
|
@@ -176216,7 +176286,7 @@ var createTempProject = (tempDir) => {
|
|
|
176216
176286
|
"@tsci/does-not-exist": "0.0.0"
|
|
176217
176287
|
}
|
|
176218
176288
|
};
|
|
176219
|
-
|
|
176289
|
+
fs60.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
176220
176290
|
};
|
|
176221
176291
|
var checkGlobalNpmrcRegistry = async () => {
|
|
176222
176292
|
const name = "Global .npmrc configured for tscircuit NPM registry?";
|
|
@@ -176227,7 +176297,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
176227
176297
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
176228
176298
|
};
|
|
176229
176299
|
}
|
|
176230
|
-
const tempDir =
|
|
176300
|
+
const tempDir = fs60.mkdtempSync(path61.join(os9.tmpdir(), "tsci-doctor-"));
|
|
176231
176301
|
try {
|
|
176232
176302
|
createTempProject(tempDir);
|
|
176233
176303
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -176265,7 +176335,7 @@ ${result.stderr ?? ""}`;
|
|
|
176265
176335
|
}
|
|
176266
176336
|
return { name, success: true };
|
|
176267
176337
|
} finally {
|
|
176268
|
-
|
|
176338
|
+
fs60.rmSync(tempDir, { recursive: true, force: true });
|
|
176269
176339
|
}
|
|
176270
176340
|
};
|
|
176271
176341
|
|
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.900";
|
|
60418
60418
|
var package_default = {
|
|
60419
60419
|
name: "@tscircuit/cli",
|
|
60420
60420
|
main: "dist/cli/main.js",
|
|
@@ -67075,6 +67075,7 @@ var projectConfigSchema = z21.object({
|
|
|
67075
67075
|
kicadLibrary: z21.boolean().optional(),
|
|
67076
67076
|
kicadPcm: z21.boolean().optional(),
|
|
67077
67077
|
previewImages: z21.boolean().optional(),
|
|
67078
|
+
glbs: z21.boolean().optional(),
|
|
67078
67079
|
typescriptLibrary: z21.boolean().optional()
|
|
67079
67080
|
}).optional()
|
|
67080
67081
|
});
|
package/package.json
CHANGED
|
@@ -80,6 +80,10 @@
|
|
|
80
80
|
"type": "boolean",
|
|
81
81
|
"description": "Enable preview image outputs in build."
|
|
82
82
|
},
|
|
83
|
+
"glbs": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"description": "Enable GLB 3D model outputs for each circuit in build."
|
|
86
|
+
},
|
|
83
87
|
"typescriptLibrary": {
|
|
84
88
|
"type": "boolean",
|
|
85
89
|
"description": "Enable TypeScript library output in build."
|