@tscircuit/cli 0.1.894 → 0.1.895
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/build/build-worker-entrypoint.js +3 -2
- package/dist/cli/main.js +131 -125
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -2668,7 +2668,8 @@ function getCompletePlatformConfig(userConfig) {
|
|
|
2668
2668
|
// lib/shared/register-static-asset-loaders.ts
|
|
2669
2669
|
import fs4 from "node:fs";
|
|
2670
2670
|
import path4 from "node:path";
|
|
2671
|
-
var
|
|
2671
|
+
var STATIC_ASSET_EXTENSIONS = [
|
|
2672
|
+
".glb",
|
|
2672
2673
|
".gltf",
|
|
2673
2674
|
".step",
|
|
2674
2675
|
".kicad_mod",
|
|
@@ -2676,7 +2677,7 @@ var TEXT_STATIC_ASSET_EXTENSIONS = [
|
|
|
2676
2677
|
".kicad_pro",
|
|
2677
2678
|
".kicad_sch"
|
|
2678
2679
|
];
|
|
2679
|
-
var staticAssetFilter = new RegExp(`(${
|
|
2680
|
+
var staticAssetFilter = new RegExp(`(${STATIC_ASSET_EXTENSIONS.map((ext) => ext.replace(".", "\\.")).join("|")})$`, "i");
|
|
2680
2681
|
var registered = false;
|
|
2681
2682
|
var getBaseUrlFromTsConfig = () => {
|
|
2682
2683
|
const tsconfigPath = path4.join(process.cwd(), "tsconfig.json");
|
package/dist/cli/main.js
CHANGED
|
@@ -74383,7 +74383,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74383
74383
|
import { execSync as execSync2 } from "node:child_process";
|
|
74384
74384
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74385
74385
|
// package.json
|
|
74386
|
-
var version = "0.1.
|
|
74386
|
+
var version = "0.1.894";
|
|
74387
74387
|
var package_default = {
|
|
74388
74388
|
name: "@tscircuit/cli",
|
|
74389
74389
|
main: "dist/cli/main.js",
|
|
@@ -173892,7 +173892,7 @@ var registerRemove = (program3) => {
|
|
|
173892
173892
|
};
|
|
173893
173893
|
|
|
173894
173894
|
// cli/build/register.ts
|
|
173895
|
-
import
|
|
173895
|
+
import path54 from "node:path";
|
|
173896
173896
|
import fs53 from "node:fs";
|
|
173897
173897
|
|
|
173898
173898
|
// cli/build/build-file.ts
|
|
@@ -174411,7 +174411,7 @@ ${scriptBlock} <script src="https://cdn.tailwindcss.com"></script>
|
|
|
174411
174411
|
|
|
174412
174412
|
// cli/build/build-preview-images.ts
|
|
174413
174413
|
import fs46 from "node:fs";
|
|
174414
|
-
import
|
|
174414
|
+
import path47 from "node:path";
|
|
174415
174415
|
import {
|
|
174416
174416
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
174417
174417
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg2
|
|
@@ -174420,6 +174420,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer } from "poppygl";
|
|
|
174420
174420
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf2 } from "circuit-json-to-gltf";
|
|
174421
174421
|
|
|
174422
174422
|
// cli/build/convert-model-urls-to-file-urls.ts
|
|
174423
|
+
import path46 from "node:path";
|
|
174423
174424
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
174424
174425
|
var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
174425
174426
|
const modelUrlKeys = [
|
|
@@ -174439,8 +174440,12 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
|
174439
174440
|
for (const key of modelUrlKeys) {
|
|
174440
174441
|
const value = updated[key];
|
|
174441
174442
|
if (typeof value === "string" && value.length > 0) {
|
|
174442
|
-
if (
|
|
174443
|
+
if (value.match(/^[a-zA-Z]+:\/\//))
|
|
174444
|
+
continue;
|
|
174445
|
+
if (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/)) {
|
|
174443
174446
|
updated[key] = pathToFileURL3(value).href;
|
|
174447
|
+
} else if (value.startsWith(".")) {
|
|
174448
|
+
updated[key] = pathToFileURL3(path46.resolve(process.cwd(), value)).href;
|
|
174444
174449
|
}
|
|
174445
174450
|
}
|
|
174446
174451
|
}
|
|
@@ -174487,7 +174492,7 @@ var generatePreviewAssets = async ({
|
|
|
174487
174492
|
outputDir,
|
|
174488
174493
|
distDir
|
|
174489
174494
|
}) => {
|
|
174490
|
-
const prefixRelative =
|
|
174495
|
+
const prefixRelative = path47.relative(distDir, outputDir) || ".";
|
|
174491
174496
|
const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
|
|
174492
174497
|
let circuitJson;
|
|
174493
174498
|
try {
|
|
@@ -174501,7 +174506,7 @@ var generatePreviewAssets = async ({
|
|
|
174501
174506
|
try {
|
|
174502
174507
|
console.log(`${prefix}Generating PCB SVG...`);
|
|
174503
174508
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson);
|
|
174504
|
-
fs46.writeFileSync(
|
|
174509
|
+
fs46.writeFileSync(path47.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
174505
174510
|
console.log(`${prefix}Written pcb.svg`);
|
|
174506
174511
|
} catch (error) {
|
|
174507
174512
|
console.error(`${prefix}Failed to generate PCB SVG:`, error);
|
|
@@ -174509,7 +174514,7 @@ var generatePreviewAssets = async ({
|
|
|
174509
174514
|
try {
|
|
174510
174515
|
console.log(`${prefix}Generating schematic SVG...`);
|
|
174511
174516
|
const schematicSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
|
|
174512
|
-
fs46.writeFileSync(
|
|
174517
|
+
fs46.writeFileSync(path47.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
174513
174518
|
console.log(`${prefix}Written schematic.svg`);
|
|
174514
174519
|
} catch (error) {
|
|
174515
174520
|
console.error(`${prefix}Failed to generate schematic SVG:`, error);
|
|
@@ -174526,7 +174531,7 @@ var generatePreviewAssets = async ({
|
|
|
174526
174531
|
camPos: [10, 10, 10],
|
|
174527
174532
|
lookAt: [0, 0, 0]
|
|
174528
174533
|
});
|
|
174529
|
-
fs46.writeFileSync(
|
|
174534
|
+
fs46.writeFileSync(path47.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
|
|
174530
174535
|
console.log(`${prefix}Written 3d.png`);
|
|
174531
174536
|
} catch (error) {
|
|
174532
174537
|
console.error(`${prefix}Failed to generate 3D PNG:`, error);
|
|
@@ -174541,14 +174546,14 @@ var buildPreviewImages = async ({
|
|
|
174541
174546
|
}) => {
|
|
174542
174547
|
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
174543
174548
|
const previewEntrypoint = previewComponentPath || mainEntrypoint;
|
|
174544
|
-
const resolvedPreviewEntrypoint = previewEntrypoint ?
|
|
174549
|
+
const resolvedPreviewEntrypoint = previewEntrypoint ? path47.resolve(previewEntrypoint) : undefined;
|
|
174545
174550
|
if (allImages) {
|
|
174546
174551
|
if (successfulBuilds.length === 0) {
|
|
174547
174552
|
console.warn("No successful build output available for preview image generation.");
|
|
174548
174553
|
return;
|
|
174549
174554
|
}
|
|
174550
174555
|
for (const build of successfulBuilds) {
|
|
174551
|
-
const outputDir =
|
|
174556
|
+
const outputDir = path47.dirname(build.outputPath);
|
|
174552
174557
|
await generatePreviewAssets({
|
|
174553
174558
|
build,
|
|
174554
174559
|
outputDir,
|
|
@@ -174559,7 +174564,7 @@ var buildPreviewImages = async ({
|
|
|
174559
174564
|
}
|
|
174560
174565
|
const previewBuild = (() => {
|
|
174561
174566
|
if (resolvedPreviewEntrypoint) {
|
|
174562
|
-
const match = successfulBuilds.find((built) =>
|
|
174567
|
+
const match = successfulBuilds.find((built) => path47.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
|
|
174563
174568
|
if (match)
|
|
174564
174569
|
return match;
|
|
174565
174570
|
}
|
|
@@ -174578,7 +174583,7 @@ var buildPreviewImages = async ({
|
|
|
174578
174583
|
|
|
174579
174584
|
// cli/build/build-preview-gltf.ts
|
|
174580
174585
|
import fs47 from "node:fs";
|
|
174581
|
-
import
|
|
174586
|
+
import path48 from "node:path";
|
|
174582
174587
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf3 } from "circuit-json-to-gltf";
|
|
174583
174588
|
var buildPreviewGltf = async ({
|
|
174584
174589
|
builtFiles,
|
|
@@ -174588,10 +174593,10 @@ var buildPreviewGltf = async ({
|
|
|
174588
174593
|
}) => {
|
|
174589
174594
|
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
174590
174595
|
const previewEntrypoint = previewComponentPath || mainEntrypoint;
|
|
174591
|
-
const resolvedPreviewEntrypoint = previewEntrypoint ?
|
|
174596
|
+
const resolvedPreviewEntrypoint = previewEntrypoint ? path48.resolve(previewEntrypoint) : undefined;
|
|
174592
174597
|
const previewBuild = (() => {
|
|
174593
174598
|
if (resolvedPreviewEntrypoint) {
|
|
174594
|
-
const match = successfulBuilds.find((built) =>
|
|
174599
|
+
const match = successfulBuilds.find((built) => path48.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
|
|
174595
174600
|
if (match)
|
|
174596
174601
|
return match;
|
|
174597
174602
|
}
|
|
@@ -174610,9 +174615,9 @@ var buildPreviewGltf = async ({
|
|
|
174610
174615
|
return;
|
|
174611
174616
|
}
|
|
174612
174617
|
const sourcePath = previewBuild.sourcePath;
|
|
174613
|
-
const sourceBasename =
|
|
174618
|
+
const sourceBasename = path48.basename(sourcePath);
|
|
174614
174619
|
const gltfFilename = sourceBasename.replace(/(\.(board|circuit))?\.tsx?$/, ".gltf");
|
|
174615
|
-
const outputPath =
|
|
174620
|
+
const outputPath = path48.join(distDir, gltfFilename);
|
|
174616
174621
|
try {
|
|
174617
174622
|
console.log("Converting circuit to GLTF...");
|
|
174618
174623
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
@@ -174629,7 +174634,7 @@ var buildPreviewGltf = async ({
|
|
|
174629
174634
|
|
|
174630
174635
|
// cli/build/generate-kicad-project.ts
|
|
174631
174636
|
import fs48 from "node:fs";
|
|
174632
|
-
import
|
|
174637
|
+
import path49 from "node:path";
|
|
174633
174638
|
var createKicadProContent = ({
|
|
174634
174639
|
projectName,
|
|
174635
174640
|
schematicFileName,
|
|
@@ -174670,9 +174675,9 @@ var generateKicadProject = async ({
|
|
|
174670
174675
|
});
|
|
174671
174676
|
if (writeFiles) {
|
|
174672
174677
|
fs48.mkdirSync(outputDir, { recursive: true });
|
|
174673
|
-
fs48.writeFileSync(
|
|
174674
|
-
fs48.writeFileSync(
|
|
174675
|
-
fs48.writeFileSync(
|
|
174678
|
+
fs48.writeFileSync(path49.join(outputDir, schematicFileName), schContent);
|
|
174679
|
+
fs48.writeFileSync(path49.join(outputDir, boardFileName), pcbContent);
|
|
174680
|
+
fs48.writeFileSync(path49.join(outputDir, projectFileName), proContent);
|
|
174676
174681
|
}
|
|
174677
174682
|
return {
|
|
174678
174683
|
pcbContent,
|
|
@@ -174684,7 +174689,7 @@ var generateKicadProject = async ({
|
|
|
174684
174689
|
};
|
|
174685
174690
|
|
|
174686
174691
|
// cli/build/transpile/index.ts
|
|
174687
|
-
import
|
|
174692
|
+
import path51 from "node:path";
|
|
174688
174693
|
import fs50 from "node:fs";
|
|
174689
174694
|
import { rollup } from "rollup";
|
|
174690
174695
|
import typescript from "@rollup/plugin-typescript";
|
|
@@ -174695,10 +174700,10 @@ import dts from "rollup-plugin-dts";
|
|
|
174695
174700
|
|
|
174696
174701
|
// cli/build/transpile/static-asset-plugin.ts
|
|
174697
174702
|
import fs49 from "node:fs";
|
|
174698
|
-
import
|
|
174703
|
+
import path50 from "node:path";
|
|
174699
174704
|
import { createHash } from "node:crypto";
|
|
174700
174705
|
function normalizePathSeparators(filePath) {
|
|
174701
|
-
return filePath.split(
|
|
174706
|
+
return filePath.split(path50.sep).join("/");
|
|
174702
174707
|
}
|
|
174703
174708
|
var STATIC_ASSET_EXTENSIONS = new Set([
|
|
174704
174709
|
".glb",
|
|
@@ -174729,15 +174734,15 @@ var createStaticAssetPlugin = ({
|
|
|
174729
174734
|
return {
|
|
174730
174735
|
name: "tsci-static-assets",
|
|
174731
174736
|
resolveId(source, importer) {
|
|
174732
|
-
const ext =
|
|
174737
|
+
const ext = path50.extname(source).toLowerCase();
|
|
174733
174738
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
174734
174739
|
return null;
|
|
174735
|
-
if (
|
|
174740
|
+
if (path50.isAbsolute(source)) {
|
|
174736
174741
|
return fs49.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
|
|
174737
174742
|
}
|
|
174738
174743
|
if (importer) {
|
|
174739
|
-
const importerNative = importer.split("/").join(
|
|
174740
|
-
const resolvedFromImporter =
|
|
174744
|
+
const importerNative = importer.split("/").join(path50.sep);
|
|
174745
|
+
const resolvedFromImporter = path50.resolve(path50.dirname(importerNative), source);
|
|
174741
174746
|
if (fs49.existsSync(resolvedFromImporter)) {
|
|
174742
174747
|
return {
|
|
174743
174748
|
id: normalizePathSeparators(resolvedFromImporter),
|
|
@@ -174745,7 +174750,7 @@ var createStaticAssetPlugin = ({
|
|
|
174745
174750
|
};
|
|
174746
174751
|
}
|
|
174747
174752
|
}
|
|
174748
|
-
const resolvedFromProject =
|
|
174753
|
+
const resolvedFromProject = path50.resolve(resolvedBaseUrl, source);
|
|
174749
174754
|
if (fs49.existsSync(resolvedFromProject)) {
|
|
174750
174755
|
return {
|
|
174751
174756
|
id: normalizePathSeparators(resolvedFromProject),
|
|
@@ -174759,7 +174764,7 @@ var createStaticAssetPlugin = ({
|
|
|
174759
174764
|
const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
|
|
174760
174765
|
for (const target of targets) {
|
|
174761
174766
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
174762
|
-
const resolvedTarget =
|
|
174767
|
+
const resolvedTarget = path50.resolve(resolvedBaseUrl, targetPath);
|
|
174763
174768
|
if (fs49.existsSync(resolvedTarget)) {
|
|
174764
174769
|
return {
|
|
174765
174770
|
id: normalizePathSeparators(resolvedTarget),
|
|
@@ -174786,17 +174791,17 @@ var createStaticAssetPlugin = ({
|
|
|
174786
174791
|
if (chunk.type !== "chunk")
|
|
174787
174792
|
continue;
|
|
174788
174793
|
for (const importedId of chunk.imports) {
|
|
174789
|
-
const ext =
|
|
174794
|
+
const ext = path50.extname(importedId).toLowerCase();
|
|
174790
174795
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
174791
174796
|
continue;
|
|
174792
174797
|
if (!copiedAssets.has(importedId)) {
|
|
174793
|
-
const assetDir =
|
|
174798
|
+
const assetDir = path50.join(outputDir, "assets");
|
|
174794
174799
|
fs49.mkdirSync(assetDir, { recursive: true });
|
|
174795
|
-
const nativePath = importedId.split("/").join(
|
|
174800
|
+
const nativePath = importedId.split("/").join(path50.sep);
|
|
174796
174801
|
const fileBuffer = fs49.readFileSync(nativePath);
|
|
174797
174802
|
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
174798
|
-
const fileName = `${
|
|
174799
|
-
const outputFilePath =
|
|
174803
|
+
const fileName = `${path50.basename(importedId, ext)}-${hash}${ext}`;
|
|
174804
|
+
const outputFilePath = path50.join(assetDir, fileName);
|
|
174800
174805
|
fs49.writeFileSync(outputFilePath, fileBuffer);
|
|
174801
174806
|
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
174802
174807
|
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
@@ -174819,7 +174824,7 @@ function escapeRegExp(string) {
|
|
|
174819
174824
|
|
|
174820
174825
|
// cli/build/transpile/index.ts
|
|
174821
174826
|
var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
174822
|
-
if (id.startsWith(".") || id.startsWith("/") ||
|
|
174827
|
+
if (id.startsWith(".") || id.startsWith("/") || path51.isAbsolute(id)) {
|
|
174823
174828
|
return false;
|
|
174824
174829
|
}
|
|
174825
174830
|
let baseUrl = projectDir;
|
|
@@ -174829,7 +174834,7 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
|
174829
174834
|
const tsconfigContent = fs50.readFileSync(tsconfigPath, "utf-8");
|
|
174830
174835
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
174831
174836
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
174832
|
-
baseUrl =
|
|
174837
|
+
baseUrl = path51.resolve(path51.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
174833
174838
|
}
|
|
174834
174839
|
if (tsconfig.compilerOptions?.paths) {
|
|
174835
174840
|
pathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -174843,15 +174848,15 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
|
174843
174848
|
}
|
|
174844
174849
|
}
|
|
174845
174850
|
const potentialPaths = [
|
|
174846
|
-
|
|
174847
|
-
|
|
174848
|
-
|
|
174849
|
-
|
|
174850
|
-
|
|
174851
|
-
|
|
174852
|
-
|
|
174853
|
-
|
|
174854
|
-
|
|
174851
|
+
path51.join(baseUrl, id),
|
|
174852
|
+
path51.join(baseUrl, `${id}.ts`),
|
|
174853
|
+
path51.join(baseUrl, `${id}.tsx`),
|
|
174854
|
+
path51.join(baseUrl, `${id}.js`),
|
|
174855
|
+
path51.join(baseUrl, `${id}.jsx`),
|
|
174856
|
+
path51.join(baseUrl, id, "index.ts"),
|
|
174857
|
+
path51.join(baseUrl, id, "index.tsx"),
|
|
174858
|
+
path51.join(baseUrl, id, "index.js"),
|
|
174859
|
+
path51.join(baseUrl, id, "index.jsx")
|
|
174855
174860
|
];
|
|
174856
174861
|
if (potentialPaths.some((p4) => fs50.existsSync(p4))) {
|
|
174857
174862
|
return false;
|
|
@@ -174865,7 +174870,7 @@ var transpileFile = async ({
|
|
|
174865
174870
|
}) => {
|
|
174866
174871
|
try {
|
|
174867
174872
|
fs50.mkdirSync(outputDir, { recursive: true });
|
|
174868
|
-
const tsconfigPath =
|
|
174873
|
+
const tsconfigPath = path51.join(projectDir, "tsconfig.json");
|
|
174869
174874
|
const hasTsConfig = fs50.existsSync(tsconfigPath);
|
|
174870
174875
|
let tsconfigBaseUrl = projectDir;
|
|
174871
174876
|
let tsconfigPathMappings;
|
|
@@ -174874,7 +174879,7 @@ var transpileFile = async ({
|
|
|
174874
174879
|
const tsconfigContent = fs50.readFileSync(tsconfigPath, "utf-8");
|
|
174875
174880
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
174876
174881
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
174877
|
-
tsconfigBaseUrl =
|
|
174882
|
+
tsconfigBaseUrl = path51.resolve(path51.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
174878
174883
|
}
|
|
174879
174884
|
if (tsconfig.compilerOptions?.paths) {
|
|
174880
174885
|
tsconfigPathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -174929,27 +174934,27 @@ var transpileFile = async ({
|
|
|
174929
174934
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
174930
174935
|
plugins: getPlugins()
|
|
174931
174936
|
});
|
|
174932
|
-
const esmOutputPath =
|
|
174937
|
+
const esmOutputPath = path51.join(outputDir, "index.js");
|
|
174933
174938
|
await esmBundle.write({
|
|
174934
174939
|
file: esmOutputPath,
|
|
174935
174940
|
format: "es",
|
|
174936
174941
|
sourcemap: false
|
|
174937
174942
|
});
|
|
174938
|
-
console.log(`ESM bundle written to ${
|
|
174943
|
+
console.log(`ESM bundle written to ${path51.relative(projectDir, esmOutputPath)}`);
|
|
174939
174944
|
console.log("Building CommonJS bundle...");
|
|
174940
174945
|
const cjsBundle = await rollup({
|
|
174941
174946
|
input,
|
|
174942
174947
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
174943
174948
|
plugins: getPlugins()
|
|
174944
174949
|
});
|
|
174945
|
-
const cjsOutputPath =
|
|
174950
|
+
const cjsOutputPath = path51.join(outputDir, "index.cjs");
|
|
174946
174951
|
console.log("Writing CJS bundle to:", cjsOutputPath);
|
|
174947
174952
|
await cjsBundle.write({
|
|
174948
174953
|
file: cjsOutputPath,
|
|
174949
174954
|
format: "cjs",
|
|
174950
174955
|
sourcemap: false
|
|
174951
174956
|
});
|
|
174952
|
-
console.log(`CommonJS bundle written to ${
|
|
174957
|
+
console.log(`CommonJS bundle written to ${path51.relative(projectDir, cjsOutputPath)}`);
|
|
174953
174958
|
console.log("Generating type declarations...");
|
|
174954
174959
|
const dtsBundle = await rollup({
|
|
174955
174960
|
input,
|
|
@@ -174974,9 +174979,9 @@ var transpileFile = async ({
|
|
|
174974
174979
|
dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
|
|
174975
174980
|
dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
|
|
174976
174981
|
dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
|
|
174977
|
-
const dtsOutputPath =
|
|
174982
|
+
const dtsOutputPath = path51.join(outputDir, "index.d.ts");
|
|
174978
174983
|
fs50.writeFileSync(dtsOutputPath, dtsContent);
|
|
174979
|
-
console.log(`Type declarations written to ${
|
|
174984
|
+
console.log(`Type declarations written to ${path51.relative(projectDir, dtsOutputPath)}`);
|
|
174980
174985
|
console.log(kleur_default.green("Transpilation complete!"));
|
|
174981
174986
|
return true;
|
|
174982
174987
|
} catch (err) {
|
|
@@ -174990,16 +174995,16 @@ var transpileFile = async ({
|
|
|
174990
174995
|
|
|
174991
174996
|
// cli/utils/validate-main-in-dist.ts
|
|
174992
174997
|
import fs51 from "node:fs";
|
|
174993
|
-
import
|
|
174998
|
+
import path52 from "node:path";
|
|
174994
174999
|
var validateMainInDist = (projectDir, distDir) => {
|
|
174995
|
-
const packageJsonPath =
|
|
175000
|
+
const packageJsonPath = path52.join(projectDir, "package.json");
|
|
174996
175001
|
if (!fs51.existsSync(packageJsonPath))
|
|
174997
175002
|
return;
|
|
174998
175003
|
const packageJson = JSON.parse(fs51.readFileSync(packageJsonPath, "utf-8"));
|
|
174999
175004
|
if (typeof packageJson.main !== "string")
|
|
175000
175005
|
return;
|
|
175001
|
-
const resolvedMainPath =
|
|
175002
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
175006
|
+
const resolvedMainPath = path52.resolve(projectDir, packageJson.main);
|
|
175007
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path52.sep}`);
|
|
175003
175008
|
if (!isMainInDist) {
|
|
175004
175009
|
console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
175005
175010
|
}
|
|
@@ -175021,19 +175026,19 @@ async function getLatestTscircuitCdnUrl() {
|
|
|
175021
175026
|
}
|
|
175022
175027
|
|
|
175023
175028
|
// cli/build/worker-pool.ts
|
|
175024
|
-
import
|
|
175029
|
+
import path53 from "node:path";
|
|
175025
175030
|
import fs52 from "node:fs";
|
|
175026
175031
|
import { Worker } from "node:worker_threads";
|
|
175027
175032
|
var getWorkerEntrypointPath = () => {
|
|
175028
|
-
const tsPath =
|
|
175033
|
+
const tsPath = path53.join(import.meta.dir, "build-worker-entrypoint.ts");
|
|
175029
175034
|
if (fs52.existsSync(tsPath)) {
|
|
175030
175035
|
return tsPath;
|
|
175031
175036
|
}
|
|
175032
|
-
const jsBundledPath =
|
|
175037
|
+
const jsBundledPath = path53.join(import.meta.dir, "build", "build-worker-entrypoint.js");
|
|
175033
175038
|
if (fs52.existsSync(jsBundledPath)) {
|
|
175034
175039
|
return jsBundledPath;
|
|
175035
175040
|
}
|
|
175036
|
-
return
|
|
175041
|
+
return path53.join(import.meta.dir, "build-worker-entrypoint.js");
|
|
175037
175042
|
};
|
|
175038
175043
|
|
|
175039
175044
|
class WorkerPool {
|
|
@@ -175192,25 +175197,25 @@ async function buildFilesWithWorkerPool(options) {
|
|
|
175192
175197
|
}
|
|
175193
175198
|
|
|
175194
175199
|
// cli/build/register.ts
|
|
175195
|
-
var normalizeRelativePath = (projectDir, targetPath) =>
|
|
175200
|
+
var normalizeRelativePath = (projectDir, targetPath) => path54.relative(projectDir, targetPath).split(path54.sep).join("/");
|
|
175196
175201
|
var registerBuild = (program3) => {
|
|
175197
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) => {
|
|
175198
175203
|
try {
|
|
175199
|
-
const resolvedRoot =
|
|
175204
|
+
const resolvedRoot = path54.resolve(process.cwd());
|
|
175200
175205
|
let projectDir;
|
|
175201
175206
|
if (file) {
|
|
175202
|
-
const resolved =
|
|
175207
|
+
const resolved = path54.resolve(resolvedRoot, file);
|
|
175203
175208
|
if (fs53.existsSync(resolved) && fs53.statSync(resolved).isDirectory()) {
|
|
175204
175209
|
projectDir = resolvedRoot;
|
|
175205
175210
|
} else {
|
|
175206
|
-
let currentDir =
|
|
175207
|
-
while (currentDir !==
|
|
175208
|
-
if (fs53.existsSync(
|
|
175211
|
+
let currentDir = path54.dirname(resolved);
|
|
175212
|
+
while (currentDir !== path54.dirname(currentDir)) {
|
|
175213
|
+
if (fs53.existsSync(path54.join(currentDir, "package.json"))) {
|
|
175209
175214
|
break;
|
|
175210
175215
|
}
|
|
175211
|
-
currentDir =
|
|
175216
|
+
currentDir = path54.dirname(currentDir);
|
|
175212
175217
|
}
|
|
175213
|
-
projectDir = fs53.existsSync(
|
|
175218
|
+
projectDir = fs53.existsSync(path54.join(currentDir, "package.json")) ? currentDir : resolvedRoot;
|
|
175214
175219
|
}
|
|
175215
175220
|
} else {
|
|
175216
175221
|
projectDir = resolvedRoot;
|
|
@@ -175248,7 +175253,7 @@ var registerBuild = (program3) => {
|
|
|
175248
175253
|
}
|
|
175249
175254
|
return config;
|
|
175250
175255
|
})();
|
|
175251
|
-
const distDir =
|
|
175256
|
+
const distDir = path54.join(projectDir, "dist");
|
|
175252
175257
|
fs53.mkdirSync(distDir, { recursive: true });
|
|
175253
175258
|
const concurrencyValue = Math.max(1, Number.parseInt(resolvedOptions?.concurrency || "1", 10));
|
|
175254
175259
|
if (concurrencyValue > 1) {
|
|
@@ -175268,7 +175273,7 @@ var registerBuild = (program3) => {
|
|
|
175268
175273
|
platformConfig: platformConfig2
|
|
175269
175274
|
};
|
|
175270
175275
|
const processBuildResult = async (filePath, outputPath, buildOutcome) => {
|
|
175271
|
-
const relative10 =
|
|
175276
|
+
const relative10 = path54.relative(projectDir, filePath);
|
|
175272
175277
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175273
175278
|
builtFiles.push({
|
|
175274
175279
|
sourcePath: filePath,
|
|
@@ -175282,9 +175287,9 @@ var registerBuild = (program3) => {
|
|
|
175282
175287
|
console.error(kleur_default.red(`Fatal error [${buildOutcome.isFatalError.errorType}]: ${buildOutcome.isFatalError.message}`));
|
|
175283
175288
|
}
|
|
175284
175289
|
} else if (resolvedOptions?.site) {
|
|
175285
|
-
const normalizedSourcePath = relative10.split(
|
|
175286
|
-
const relativeOutputPath =
|
|
175287
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
175290
|
+
const normalizedSourcePath = relative10.split(path54.sep).join("/");
|
|
175291
|
+
const relativeOutputPath = path54.join(outputDirName, "circuit.json");
|
|
175292
|
+
const normalizedOutputPath = relativeOutputPath.split(path54.sep).join("/");
|
|
175288
175293
|
staticFileReferences.push({
|
|
175289
175294
|
filePath: normalizedSourcePath,
|
|
175290
175295
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
@@ -175296,8 +175301,8 @@ var registerBuild = (program3) => {
|
|
|
175296
175301
|
circuitJson = JSON.parse(fs53.readFileSync(outputPath, "utf-8"));
|
|
175297
175302
|
}
|
|
175298
175303
|
if (circuitJson) {
|
|
175299
|
-
const projectOutputDir =
|
|
175300
|
-
const projectName =
|
|
175304
|
+
const projectOutputDir = path54.join(distDir, outputDirName, "kicad");
|
|
175305
|
+
const projectName = path54.basename(outputDirName);
|
|
175301
175306
|
const project = await generateKicadProject({
|
|
175302
175307
|
circuitJson,
|
|
175303
175308
|
outputDir: projectOutputDir,
|
|
@@ -175313,19 +175318,19 @@ var registerBuild = (program3) => {
|
|
|
175313
175318
|
};
|
|
175314
175319
|
const buildSequentially = async () => {
|
|
175315
175320
|
for (const filePath of circuitFiles) {
|
|
175316
|
-
const relative10 =
|
|
175321
|
+
const relative10 = path54.relative(projectDir, filePath);
|
|
175317
175322
|
console.log(`Building ${relative10}...`);
|
|
175318
175323
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175319
|
-
const outputPath =
|
|
175324
|
+
const outputPath = path54.join(distDir, outputDirName, "circuit.json");
|
|
175320
175325
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, buildOptions);
|
|
175321
175326
|
await processBuildResult(filePath, outputPath, buildOutcome);
|
|
175322
175327
|
}
|
|
175323
175328
|
};
|
|
175324
175329
|
const buildWithWorkers = async () => {
|
|
175325
175330
|
const filesToBuild = circuitFiles.map((filePath) => {
|
|
175326
|
-
const relative10 =
|
|
175331
|
+
const relative10 = path54.relative(projectDir, filePath);
|
|
175327
175332
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175328
|
-
const outputPath =
|
|
175333
|
+
const outputPath = path54.join(distDir, outputDirName, "circuit.json");
|
|
175329
175334
|
return { filePath, outputPath };
|
|
175330
175335
|
});
|
|
175331
175336
|
await buildFilesWithWorkerPool({
|
|
@@ -175339,7 +175344,7 @@ var registerBuild = (program3) => {
|
|
|
175339
175344
|
}
|
|
175340
175345
|
},
|
|
175341
175346
|
onJobComplete: async (result) => {
|
|
175342
|
-
const relative10 =
|
|
175347
|
+
const relative10 = path54.relative(projectDir, result.filePath);
|
|
175343
175348
|
if (result.ok) {
|
|
175344
175349
|
console.log(kleur_default.green(`✓ ${relative10}`));
|
|
175345
175350
|
} else {
|
|
@@ -175410,14 +175415,14 @@ var registerBuild = (program3) => {
|
|
|
175410
175415
|
if (resolvedOptions?.useCdnJavascript) {
|
|
175411
175416
|
standaloneScriptSrc = await getLatestTscircuitCdnUrl();
|
|
175412
175417
|
} else {
|
|
175413
|
-
fs53.writeFileSync(
|
|
175418
|
+
fs53.writeFileSync(path54.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
175414
175419
|
}
|
|
175415
175420
|
const indexHtml = getStaticIndexHtmlFile({
|
|
175416
175421
|
files: staticFileReferences,
|
|
175417
175422
|
standaloneScriptSrc,
|
|
175418
175423
|
defaultMainComponentPath: siteDefaultComponentPath ? normalizeRelativePath(projectDir, siteDefaultComponentPath) : undefined
|
|
175419
175424
|
});
|
|
175420
|
-
fs53.writeFileSync(
|
|
175425
|
+
fs53.writeFileSync(path54.join(distDir, "index.html"), indexHtml);
|
|
175421
175426
|
}
|
|
175422
175427
|
if (resolvedOptions?.kicadLibrary) {
|
|
175423
175428
|
console.log("Generating KiCad library...");
|
|
@@ -175437,14 +175442,14 @@ var registerBuild = (program3) => {
|
|
|
175437
175442
|
}
|
|
175438
175443
|
} else {
|
|
175439
175444
|
const libraryName = resolveKicadLibraryName({ projectDir });
|
|
175440
|
-
const kicadLibOutputDir =
|
|
175445
|
+
const kicadLibOutputDir = path54.join(distDir, "kicad-library");
|
|
175441
175446
|
try {
|
|
175442
175447
|
await convertToKicadLibrary({
|
|
175443
175448
|
filePath: entryFile,
|
|
175444
175449
|
libraryName,
|
|
175445
175450
|
outputDir: kicadLibOutputDir
|
|
175446
175451
|
});
|
|
175447
|
-
console.log(` KiCad library generated at ${kleur_default.dim(
|
|
175452
|
+
console.log(` KiCad library generated at ${kleur_default.dim(path54.relative(process.cwd(), kicadLibOutputDir))}`);
|
|
175448
175453
|
} catch (err) {
|
|
175449
175454
|
console.error(`Error generating KiCad library: ${err instanceof Error ? err.message : err}`);
|
|
175450
175455
|
if (!resolvedOptions?.ignoreErrors) {
|
|
@@ -175505,7 +175510,7 @@ var registerBuild = (program3) => {
|
|
|
175505
175510
|
if (configAppliedOpts.length > 0) {
|
|
175506
175511
|
console.log(` Config ${kleur_default.magenta(configAppliedOpts.join(", "))} ${kleur_default.dim("(from tscircuit.config.json)")}`);
|
|
175507
175512
|
}
|
|
175508
|
-
console.log(` Output ${kleur_default.dim(
|
|
175513
|
+
console.log(` Output ${kleur_default.dim(path54.relative(process.cwd(), distDir) || "dist")}`);
|
|
175509
175514
|
console.log(hasErrors ? kleur_default.yellow(`
|
|
175510
175515
|
⚠ Build completed with errors`) : kleur_default.green(`
|
|
175511
175516
|
✓ Done`));
|
|
@@ -175520,7 +175525,7 @@ var registerBuild = (program3) => {
|
|
|
175520
175525
|
|
|
175521
175526
|
// lib/shared/snapshot-project.ts
|
|
175522
175527
|
import fs55 from "node:fs";
|
|
175523
|
-
import
|
|
175528
|
+
import path55 from "node:path";
|
|
175524
175529
|
import looksSame2 from "looks-same";
|
|
175525
175530
|
import {
|
|
175526
175531
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
@@ -175572,7 +175577,7 @@ var snapshotProject = async ({
|
|
|
175572
175577
|
...DEFAULT_IGNORED_PATTERNS,
|
|
175573
175578
|
...ignored.map(normalizeIgnorePattern)
|
|
175574
175579
|
];
|
|
175575
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
175580
|
+
const resolvedPaths = filePaths.map((f2) => path55.resolve(projectDir, f2));
|
|
175576
175581
|
const boardFiles = findBoardFiles({
|
|
175577
175582
|
projectDir,
|
|
175578
175583
|
ignore,
|
|
@@ -175586,7 +175591,7 @@ var snapshotProject = async ({
|
|
|
175586
175591
|
const mismatches = [];
|
|
175587
175592
|
let didUpdate = false;
|
|
175588
175593
|
for (const file of boardFiles) {
|
|
175589
|
-
const relativeFilePath =
|
|
175594
|
+
const relativeFilePath = path55.relative(projectDir, file);
|
|
175590
175595
|
let circuitJson;
|
|
175591
175596
|
let pcbSvg;
|
|
175592
175597
|
let schSvg;
|
|
@@ -175641,17 +175646,17 @@ var snapshotProject = async ({
|
|
|
175641
175646
|
} catch (error) {
|
|
175642
175647
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
175643
175648
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
175644
|
-
const fileDir =
|
|
175645
|
-
const relativeDir =
|
|
175646
|
-
const snapDir2 = snapshotsDirName ?
|
|
175647
|
-
const base2 =
|
|
175648
|
-
const snap3dPath =
|
|
175649
|
+
const fileDir = path55.dirname(file);
|
|
175650
|
+
const relativeDir = path55.relative(projectDir, fileDir);
|
|
175651
|
+
const snapDir2 = snapshotsDirName ? path55.join(projectDir, snapshotsDirName, relativeDir) : path55.join(fileDir, "__snapshots__");
|
|
175652
|
+
const base2 = path55.basename(file).replace(/\.tsx$/, "");
|
|
175653
|
+
const snap3dPath = path55.join(snapDir2, `${base2}-3d.snap.png`);
|
|
175649
175654
|
const existing3dSnapshot = fs55.existsSync(snap3dPath);
|
|
175650
175655
|
if (existing3dSnapshot) {
|
|
175651
175656
|
onError(kleur_default.red(`
|
|
175652
175657
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
175653
175658
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
175654
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
175659
|
+
`) + kleur_default.red(` Existing snapshot: ${path55.relative(projectDir, snap3dPath)}
|
|
175655
175660
|
`));
|
|
175656
175661
|
return onExit2(1);
|
|
175657
175662
|
} else {
|
|
@@ -175667,9 +175672,9 @@ var snapshotProject = async ({
|
|
|
175667
175672
|
}
|
|
175668
175673
|
}
|
|
175669
175674
|
}
|
|
175670
|
-
const snapDir = snapshotsDirName ?
|
|
175675
|
+
const snapDir = snapshotsDirName ? path55.join(projectDir, snapshotsDirName, path55.relative(projectDir, path55.dirname(file))) : path55.join(path55.dirname(file), "__snapshots__");
|
|
175671
175676
|
fs55.mkdirSync(snapDir, { recursive: true });
|
|
175672
|
-
const base =
|
|
175677
|
+
const base = path55.basename(file).replace(/\.tsx$/, "");
|
|
175673
175678
|
const snapshots = [];
|
|
175674
175679
|
if (pcbOnly || !schematicOnly) {
|
|
175675
175680
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -175687,13 +175692,13 @@ var snapshotProject = async ({
|
|
|
175687
175692
|
for (const snapshot of snapshots) {
|
|
175688
175693
|
const { type } = snapshot;
|
|
175689
175694
|
const is3d = type === "3d";
|
|
175690
|
-
const snapPath =
|
|
175695
|
+
const snapPath = path55.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
175691
175696
|
const existing = fs55.existsSync(snapPath);
|
|
175692
175697
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
175693
175698
|
const newContentForFile = snapshot.content;
|
|
175694
175699
|
if (!existing) {
|
|
175695
175700
|
fs55.writeFileSync(snapPath, newContentForFile);
|
|
175696
|
-
console.log("✅", kleur_default.gray(
|
|
175701
|
+
console.log("✅", kleur_default.gray(path55.relative(projectDir, snapPath)));
|
|
175697
175702
|
didUpdate = true;
|
|
175698
175703
|
continue;
|
|
175699
175704
|
}
|
|
@@ -175702,16 +175707,16 @@ var snapshotProject = async ({
|
|
|
175702
175707
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
175703
175708
|
if (update) {
|
|
175704
175709
|
if (!forceUpdate && equal2) {
|
|
175705
|
-
console.log("✅", kleur_default.gray(
|
|
175710
|
+
console.log("✅", kleur_default.gray(path55.relative(projectDir, snapPath)));
|
|
175706
175711
|
} else {
|
|
175707
175712
|
fs55.writeFileSync(snapPath, newContentForFile);
|
|
175708
|
-
console.log("✅", kleur_default.gray(
|
|
175713
|
+
console.log("✅", kleur_default.gray(path55.relative(projectDir, snapPath)));
|
|
175709
175714
|
didUpdate = true;
|
|
175710
175715
|
}
|
|
175711
175716
|
} else if (!equal2) {
|
|
175712
175717
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
175713
175718
|
} else {
|
|
175714
|
-
console.log("✅", kleur_default.gray(
|
|
175719
|
+
console.log("✅", kleur_default.gray(path55.relative(projectDir, snapPath)));
|
|
175715
175720
|
}
|
|
175716
175721
|
}
|
|
175717
175722
|
}
|
|
@@ -175751,20 +175756,20 @@ var registerSnapshot = (program3) => {
|
|
|
175751
175756
|
|
|
175752
175757
|
// lib/shared/setup-github-actions.ts
|
|
175753
175758
|
import fs56 from "node:fs";
|
|
175754
|
-
import
|
|
175759
|
+
import path56 from "node:path";
|
|
175755
175760
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
175756
175761
|
const findGitRoot = (startDir) => {
|
|
175757
|
-
let dir =
|
|
175758
|
-
while (dir !==
|
|
175759
|
-
if (fs56.existsSync(
|
|
175762
|
+
let dir = path56.resolve(startDir);
|
|
175763
|
+
while (dir !== path56.parse(dir).root) {
|
|
175764
|
+
if (fs56.existsSync(path56.join(dir, ".git"))) {
|
|
175760
175765
|
return dir;
|
|
175761
175766
|
}
|
|
175762
|
-
dir =
|
|
175767
|
+
dir = path56.dirname(dir);
|
|
175763
175768
|
}
|
|
175764
175769
|
return null;
|
|
175765
175770
|
};
|
|
175766
175771
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
175767
|
-
const workflowsDir =
|
|
175772
|
+
const workflowsDir = path56.join(gitRoot, ".github", "workflows");
|
|
175768
175773
|
fs56.mkdirSync(workflowsDir, { recursive: true });
|
|
175769
175774
|
const buildWorkflow = `name: tscircuit Build
|
|
175770
175775
|
|
|
@@ -175804,8 +175809,8 @@ jobs:
|
|
|
175804
175809
|
- run: bun install
|
|
175805
175810
|
- run: bunx tsci snapshot
|
|
175806
175811
|
`;
|
|
175807
|
-
writeFileIfNotExists(
|
|
175808
|
-
writeFileIfNotExists(
|
|
175812
|
+
writeFileIfNotExists(path56.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
175813
|
+
writeFileIfNotExists(path56.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
175809
175814
|
};
|
|
175810
175815
|
|
|
175811
175816
|
// cli/setup/register.ts
|
|
@@ -175844,7 +175849,7 @@ function registerAuthSetupNpmrc(program3) {
|
|
|
175844
175849
|
|
|
175845
175850
|
// cli/convert/register.ts
|
|
175846
175851
|
import fs57 from "node:fs/promises";
|
|
175847
|
-
import
|
|
175852
|
+
import path57 from "node:path";
|
|
175848
175853
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
175849
175854
|
|
|
175850
175855
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -175965,14 +175970,14 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
175965
175970
|
var registerConvert = (program3) => {
|
|
175966
175971
|
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) => {
|
|
175967
175972
|
try {
|
|
175968
|
-
const inputPath =
|
|
175973
|
+
const inputPath = path57.resolve(file);
|
|
175969
175974
|
const modContent = await fs57.readFile(inputPath, "utf-8");
|
|
175970
175975
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
175971
|
-
const componentName = options.name ??
|
|
175976
|
+
const componentName = options.name ?? path57.basename(inputPath, ".kicad_mod");
|
|
175972
175977
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
175973
175978
|
componentName
|
|
175974
175979
|
});
|
|
175975
|
-
const outputPath = options.output ?
|
|
175980
|
+
const outputPath = options.output ? path57.resolve(options.output) : path57.join(path57.dirname(inputPath), `${componentName}.tsx`);
|
|
175976
175981
|
await fs57.writeFile(outputPath, tsx);
|
|
175977
175982
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
175978
175983
|
} catch (error) {
|
|
@@ -176089,7 +176094,7 @@ var registerInstall = (program3) => {
|
|
|
176089
176094
|
};
|
|
176090
176095
|
|
|
176091
176096
|
// cli/transpile/register.ts
|
|
176092
|
-
import
|
|
176097
|
+
import path58 from "node:path";
|
|
176093
176098
|
var registerTranspile = (program3) => {
|
|
176094
176099
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
176095
176100
|
try {
|
|
@@ -176097,7 +176102,7 @@ var registerTranspile = (program3) => {
|
|
|
176097
176102
|
fileOrDir: file,
|
|
176098
176103
|
includeBoardFiles: false
|
|
176099
176104
|
});
|
|
176100
|
-
const distDir =
|
|
176105
|
+
const distDir = path58.join(projectDir, "dist");
|
|
176101
176106
|
validateMainInDist(projectDir, distDir);
|
|
176102
176107
|
console.log("Transpiling entry file...");
|
|
176103
176108
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -176126,8 +176131,9 @@ var registerTranspile = (program3) => {
|
|
|
176126
176131
|
|
|
176127
176132
|
// lib/shared/register-static-asset-loaders.ts
|
|
176128
176133
|
import fs58 from "node:fs";
|
|
176129
|
-
import
|
|
176130
|
-
var
|
|
176134
|
+
import path59 from "node:path";
|
|
176135
|
+
var STATIC_ASSET_EXTENSIONS2 = [
|
|
176136
|
+
".glb",
|
|
176131
176137
|
".gltf",
|
|
176132
176138
|
".step",
|
|
176133
176139
|
".kicad_mod",
|
|
@@ -176135,10 +176141,10 @@ var TEXT_STATIC_ASSET_EXTENSIONS = [
|
|
|
176135
176141
|
".kicad_pro",
|
|
176136
176142
|
".kicad_sch"
|
|
176137
176143
|
];
|
|
176138
|
-
var staticAssetFilter = new RegExp(`(${
|
|
176144
|
+
var staticAssetFilter = new RegExp(`(${STATIC_ASSET_EXTENSIONS2.map((ext) => ext.replace(".", "\\.")).join("|")})$`, "i");
|
|
176139
176145
|
var registered = false;
|
|
176140
176146
|
var getBaseUrlFromTsConfig = () => {
|
|
176141
|
-
const tsconfigPath =
|
|
176147
|
+
const tsconfigPath = path59.join(process.cwd(), "tsconfig.json");
|
|
176142
176148
|
try {
|
|
176143
176149
|
if (!fs58.existsSync(tsconfigPath)) {
|
|
176144
176150
|
return null;
|
|
@@ -176161,8 +176167,8 @@ var registerStaticAssetLoaders = () => {
|
|
|
176161
176167
|
name: "tsci-static-assets",
|
|
176162
176168
|
setup(build) {
|
|
176163
176169
|
build.onLoad({ filter: staticAssetFilter }, (args) => {
|
|
176164
|
-
const baseDir = baseUrl ?
|
|
176165
|
-
const relativePath =
|
|
176170
|
+
const baseDir = baseUrl ? path59.resolve(process.cwd(), baseUrl) : process.cwd();
|
|
176171
|
+
const relativePath = path59.relative(baseDir, args.path).split(path59.sep).join("/");
|
|
176166
176172
|
const pathStr = `./${relativePath}`;
|
|
176167
176173
|
return {
|
|
176168
176174
|
exports: {
|
|
@@ -176195,13 +176201,13 @@ var checkLoggedIn = () => {
|
|
|
176195
176201
|
import { spawnSync } from "node:child_process";
|
|
176196
176202
|
import fs59 from "node:fs";
|
|
176197
176203
|
import os9 from "node:os";
|
|
176198
|
-
import
|
|
176204
|
+
import path60 from "node:path";
|
|
176199
176205
|
var hasBunInstalled = () => {
|
|
176200
176206
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
176201
176207
|
return result.status === 0;
|
|
176202
176208
|
};
|
|
176203
176209
|
var createTempProject = (tempDir) => {
|
|
176204
|
-
const packageJsonPath =
|
|
176210
|
+
const packageJsonPath = path60.join(tempDir, "package.json");
|
|
176205
176211
|
const packageJson = {
|
|
176206
176212
|
name: "tsci-doctor-check",
|
|
176207
176213
|
version: "0.0.0",
|
|
@@ -176221,7 +176227,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
176221
176227
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
176222
176228
|
};
|
|
176223
176229
|
}
|
|
176224
|
-
const tempDir = fs59.mkdtempSync(
|
|
176230
|
+
const tempDir = fs59.mkdtempSync(path60.join(os9.tmpdir(), "tsci-doctor-"));
|
|
176225
176231
|
try {
|
|
176226
176232
|
createTempProject(tempDir);
|
|
176227
176233
|
const result = spawnSync("bun", ["install"], {
|
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.894";
|
|
60418
60418
|
var package_default = {
|
|
60419
60419
|
name: "@tscircuit/cli",
|
|
60420
60420
|
main: "dist/cli/main.js",
|