@tscircuit/cli 0.1.1564 → 0.1.1565
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 +175 -151
- package/dist/lib/index.js +276 -252
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -93628,7 +93628,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
93628
93628
|
// lib/getVersion.ts
|
|
93629
93629
|
import { createRequire as createRequire2 } from "node:module";
|
|
93630
93630
|
// package.json
|
|
93631
|
-
var version = "0.1.
|
|
93631
|
+
var version = "0.1.1564";
|
|
93632
93632
|
var package_default = {
|
|
93633
93633
|
name: "@tscircuit/cli",
|
|
93634
93634
|
version,
|
|
@@ -259182,7 +259182,7 @@ var registerConvert = (program2) => {
|
|
|
259182
259182
|
// cli/dev/register.ts
|
|
259183
259183
|
import * as fs53 from "node:fs";
|
|
259184
259184
|
import * as net from "node:net";
|
|
259185
|
-
import * as
|
|
259185
|
+
import * as path58 from "node:path";
|
|
259186
259186
|
|
|
259187
259187
|
// cli/dev/resolve-dev-target.ts
|
|
259188
259188
|
import * as fs47 from "node:fs";
|
|
@@ -259241,7 +259241,7 @@ var resolveDevTarget = async (file) => {
|
|
|
259241
259241
|
|
|
259242
259242
|
// lib/dev/DevServer.ts
|
|
259243
259243
|
import fs52 from "node:fs";
|
|
259244
|
-
import
|
|
259244
|
+
import path57 from "node:path";
|
|
259245
259245
|
|
|
259246
259246
|
// node_modules/chokidar/esm/index.js
|
|
259247
259247
|
import { stat as statcb } from "fs";
|
|
@@ -261262,6 +261262,8 @@ class EventsWatcher extends EventEmitter2 {
|
|
|
261262
261262
|
// lib/server/createHttpServer.ts
|
|
261263
261263
|
import * as fs50 from "node:fs";
|
|
261264
261264
|
import * as http from "node:http";
|
|
261265
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
261266
|
+
import * as path53 from "node:path";
|
|
261265
261267
|
|
|
261266
261268
|
// node_modules/winterspec/dist/edge/transform-to-node.js
|
|
261267
261269
|
var import_node_utils = __toESM2(require_dist5(), 1);
|
|
@@ -263023,6 +263025,17 @@ Rebuilding KiCad PCM assets...`));
|
|
|
263023
263025
|
};
|
|
263024
263026
|
|
|
263025
263027
|
// lib/server/createHttpServer.ts
|
|
263028
|
+
var resolveLocalTscircuitStandalonePath = (projectDir) => {
|
|
263029
|
+
if (!projectDir)
|
|
263030
|
+
return;
|
|
263031
|
+
try {
|
|
263032
|
+
const projectRequire = createRequire4(path53.join(projectDir, "package.json"));
|
|
263033
|
+
const browserBundlePath = path53.join(path53.dirname(projectRequire.resolve("tscircuit/package.json")), "dist", "browser.min.js");
|
|
263034
|
+
if (fs50.existsSync(browserBundlePath))
|
|
263035
|
+
return browserBundlePath;
|
|
263036
|
+
} catch {}
|
|
263037
|
+
return;
|
|
263038
|
+
};
|
|
263026
263039
|
var createHttpServer = async ({
|
|
263027
263040
|
port = 3020,
|
|
263028
263041
|
defaultMainComponentPath,
|
|
@@ -263082,8 +263095,19 @@ var createHttpServer = async ({
|
|
|
263082
263095
|
}
|
|
263083
263096
|
}
|
|
263084
263097
|
if (url2.pathname === "/standalone.min.js") {
|
|
263085
|
-
const
|
|
263086
|
-
if (!
|
|
263098
|
+
const explicitStandalonePath = process.env.RUNFRAME_STANDALONE_FILE_PATH;
|
|
263099
|
+
if (!explicitStandalonePath) {
|
|
263100
|
+
const localStandalonePath = resolveLocalTscircuitStandalonePath(projectDir);
|
|
263101
|
+
if (localStandalonePath) {
|
|
263102
|
+
try {
|
|
263103
|
+
const content = fs50.readFileSync(localStandalonePath, "utf8");
|
|
263104
|
+
res2.writeHead(200, {
|
|
263105
|
+
"Content-Type": "application/javascript; charset=utf-8"
|
|
263106
|
+
});
|
|
263107
|
+
res2.end(content);
|
|
263108
|
+
return;
|
|
263109
|
+
} catch {}
|
|
263110
|
+
}
|
|
263087
263111
|
res2.writeHead(200, {
|
|
263088
263112
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
263089
263113
|
});
|
|
@@ -263091,7 +263115,7 @@ var createHttpServer = async ({
|
|
|
263091
263115
|
return;
|
|
263092
263116
|
}
|
|
263093
263117
|
try {
|
|
263094
|
-
const content = fs50.readFileSync(
|
|
263118
|
+
const content = fs50.readFileSync(explicitStandalonePath, "utf8");
|
|
263095
263119
|
res2.writeHead(200, {
|
|
263096
263120
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
263097
263121
|
});
|
|
@@ -263135,7 +263159,7 @@ var createHttpServer = async ({
|
|
|
263135
263159
|
// lib/shared/push-snippet.ts
|
|
263136
263160
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
263137
263161
|
import * as fs51 from "node:fs";
|
|
263138
|
-
import * as
|
|
263162
|
+
import * as path56 from "node:path";
|
|
263139
263163
|
import Debug2 from "debug";
|
|
263140
263164
|
|
|
263141
263165
|
// lib/utils/validate-package-name.ts
|
|
@@ -263153,7 +263177,7 @@ var validatePackageName = (name) => {
|
|
|
263153
263177
|
};
|
|
263154
263178
|
|
|
263155
263179
|
// lib/dev/get-package-file-paths.ts
|
|
263156
|
-
import * as
|
|
263180
|
+
import * as path54 from "node:path";
|
|
263157
263181
|
var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
263158
263182
|
const ignorePatterns = [
|
|
263159
263183
|
...DEFAULT_IGNORED_PATTERNS,
|
|
@@ -263164,7 +263188,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
|
263164
263188
|
ignore: ignorePatterns
|
|
263165
263189
|
});
|
|
263166
263190
|
fileNames.sort();
|
|
263167
|
-
return fileNames.map((fileName) =>
|
|
263191
|
+
return fileNames.map((fileName) => path54.join(projectDir, fileName));
|
|
263168
263192
|
};
|
|
263169
263193
|
|
|
263170
263194
|
// lib/utils/check-org-access.ts
|
|
@@ -263180,7 +263204,7 @@ var checkOrgAccess = async (ky4, orgTscircuitHandle) => {
|
|
|
263180
263204
|
};
|
|
263181
263205
|
|
|
263182
263206
|
// lib/shared/is-binary-file.ts
|
|
263183
|
-
import * as
|
|
263207
|
+
import * as path55 from "node:path";
|
|
263184
263208
|
var BINARY_FILE_EXTENSIONS = new Set([
|
|
263185
263209
|
".glb",
|
|
263186
263210
|
".gltf",
|
|
@@ -263196,7 +263220,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
|
|
|
263196
263220
|
".tar"
|
|
263197
263221
|
]);
|
|
263198
263222
|
var isBinaryFile = (filePath) => {
|
|
263199
|
-
const ext =
|
|
263223
|
+
const ext = path55.extname(filePath).toLowerCase();
|
|
263200
263224
|
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
263201
263225
|
};
|
|
263202
263226
|
|
|
@@ -263233,14 +263257,14 @@ var findPushProject = async ({
|
|
|
263233
263257
|
return null;
|
|
263234
263258
|
}
|
|
263235
263259
|
const packageJsonPath2 = [
|
|
263236
|
-
|
|
263237
|
-
|
|
263260
|
+
path56.resolve(path56.join(path56.dirname(snippetFilePath2), "package.json")),
|
|
263261
|
+
path56.resolve(path56.join(process.cwd(), "package.json"))
|
|
263238
263262
|
].find((candidatePath) => fs51.existsSync(candidatePath));
|
|
263239
|
-
const projectDir2 = packageJsonPath2 ?
|
|
263263
|
+
const projectDir2 = packageJsonPath2 ? path56.dirname(packageJsonPath2) : path56.dirname(snippetFilePath2);
|
|
263240
263264
|
return { snippetFilePath: snippetFilePath2, packageJsonPath: packageJsonPath2, projectDir: projectDir2 };
|
|
263241
263265
|
}
|
|
263242
263266
|
const projectDir = process.cwd();
|
|
263243
|
-
const packageJsonPath =
|
|
263267
|
+
const packageJsonPath = path56.resolve(path56.join(projectDir, "package.json"));
|
|
263244
263268
|
if (!fs51.existsSync(packageJsonPath)) {
|
|
263245
263269
|
return { projectDir };
|
|
263246
263270
|
}
|
|
@@ -263254,7 +263278,7 @@ var findPushProject = async ({
|
|
|
263254
263278
|
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
263255
263279
|
const zip = new import_jszip4.default;
|
|
263256
263280
|
for (const fullFilePath of filePaths) {
|
|
263257
|
-
const relativeFilePath =
|
|
263281
|
+
const relativeFilePath = path56.relative(projectDir, fullFilePath);
|
|
263258
263282
|
zip.file(relativeFilePath, fs51.readFileSync(fullFilePath));
|
|
263259
263283
|
}
|
|
263260
263284
|
const archive = await zip.generateAsync({
|
|
@@ -263485,7 +263509,7 @@ var pushSnippet = async ({
|
|
|
263485
263509
|
json: archivePayload
|
|
263486
263510
|
});
|
|
263487
263511
|
for (const fullFilePath of filePaths) {
|
|
263488
|
-
const relativeFilePath =
|
|
263512
|
+
const relativeFilePath = path56.relative(projectDir, fullFilePath);
|
|
263489
263513
|
uploadResults.succeeded.push(relativeFilePath);
|
|
263490
263514
|
}
|
|
263491
263515
|
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
@@ -263495,7 +263519,7 @@ var pushSnippet = async ({
|
|
|
263495
263519
|
}
|
|
263496
263520
|
if (uploadResults.succeeded.length === 0) {
|
|
263497
263521
|
for (const fullFilePath of filePaths) {
|
|
263498
|
-
const relativeFilePath =
|
|
263522
|
+
const relativeFilePath = path56.relative(projectDir, fullFilePath);
|
|
263499
263523
|
const fileBuffer = fs51.readFileSync(fullFilePath);
|
|
263500
263524
|
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
263501
263525
|
const payload = {
|
|
@@ -263586,7 +263610,7 @@ class DevServer {
|
|
|
263586
263610
|
}) {
|
|
263587
263611
|
this.port = port;
|
|
263588
263612
|
this.componentFilePath = componentFilePath;
|
|
263589
|
-
this.projectDir = projectDir ??
|
|
263613
|
+
this.projectDir = projectDir ?? path57.dirname(componentFilePath);
|
|
263590
263614
|
this.kicadPcm = kicadPcm ?? false;
|
|
263591
263615
|
const projectConfig2 = loadProjectConfig(this.projectDir);
|
|
263592
263616
|
this.ignoredFiles = projectConfig2?.ignoredFiles ?? [];
|
|
@@ -263597,7 +263621,7 @@ class DevServer {
|
|
|
263597
263621
|
async start() {
|
|
263598
263622
|
const { server } = await createHttpServer({
|
|
263599
263623
|
port: this.port,
|
|
263600
|
-
defaultMainComponentPath:
|
|
263624
|
+
defaultMainComponentPath: path57.relative(this.projectDir, this.componentFilePath),
|
|
263601
263625
|
kicadPcm: this.kicadPcm,
|
|
263602
263626
|
projectDir: this.projectDir,
|
|
263603
263627
|
entryFile: this.componentFilePath
|
|
@@ -263613,7 +263637,7 @@ class DevServer {
|
|
|
263613
263637
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
263614
263638
|
persistent: true,
|
|
263615
263639
|
ignoreInitial: true,
|
|
263616
|
-
ignored: (p3) => shouldIgnorePath(
|
|
263640
|
+
ignored: (p3) => shouldIgnorePath(path57.relative(this.projectDir, p3), this.ignoredFiles)
|
|
263617
263641
|
});
|
|
263618
263642
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
263619
263643
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -263628,8 +263652,8 @@ class DevServer {
|
|
|
263628
263652
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
263629
263653
|
searchParams: { file_path: ev2.file_path }
|
|
263630
263654
|
}).json();
|
|
263631
|
-
const fullPath =
|
|
263632
|
-
const dirPath =
|
|
263655
|
+
const fullPath = path57.join(this.projectDir, ev2.file_path);
|
|
263656
|
+
const dirPath = path57.dirname(fullPath);
|
|
263633
263657
|
if (!fs52.existsSync(dirPath)) {
|
|
263634
263658
|
fs52.mkdirSync(dirPath, { recursive: true });
|
|
263635
263659
|
}
|
|
@@ -263641,14 +263665,14 @@ class DevServer {
|
|
|
263641
263665
|
}
|
|
263642
263666
|
}
|
|
263643
263667
|
async handleFileDeletedEventFromServer(ev2) {
|
|
263644
|
-
const fullPath =
|
|
263668
|
+
const fullPath = path57.join(this.projectDir, ev2.file_path);
|
|
263645
263669
|
if (fs52.existsSync(fullPath)) {
|
|
263646
263670
|
debug13(`Deleting file ${ev2.file_path} from filesystem`);
|
|
263647
263671
|
fs52.unlinkSync(fullPath);
|
|
263648
263672
|
}
|
|
263649
263673
|
}
|
|
263650
263674
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
263651
|
-
const relativeFilePath =
|
|
263675
|
+
const relativeFilePath = path57.relative(this.projectDir, absoluteFilePath);
|
|
263652
263676
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
263653
263677
|
return;
|
|
263654
263678
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -263663,14 +263687,14 @@ class DevServer {
|
|
|
263663
263687
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
263664
263688
|
}
|
|
263665
263689
|
async checkAndUploadNewNodeModules(filePath) {
|
|
263666
|
-
const ext =
|
|
263690
|
+
const ext = path57.extname(filePath).toLowerCase();
|
|
263667
263691
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
263668
263692
|
if (!isSourceFile)
|
|
263669
263693
|
return;
|
|
263670
263694
|
try {
|
|
263671
263695
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
263672
263696
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
263673
|
-
const relativePath =
|
|
263697
|
+
const relativePath = path57.relative(this.projectDir, file);
|
|
263674
263698
|
return !this.uploadedNodeModules.has(relativePath);
|
|
263675
263699
|
});
|
|
263676
263700
|
if (newFiles.length === 0)
|
|
@@ -263683,7 +263707,7 @@ class DevServer {
|
|
|
263683
263707
|
}
|
|
263684
263708
|
}
|
|
263685
263709
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
263686
|
-
const relativeFilePath =
|
|
263710
|
+
const relativeFilePath = path57.relative(this.projectDir, absoluteFilePath);
|
|
263687
263711
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
263688
263712
|
return;
|
|
263689
263713
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -263721,8 +263745,8 @@ class DevServer {
|
|
|
263721
263745
|
debug13(`Successfully deleted file ${relativeFilePath} from server`);
|
|
263722
263746
|
}
|
|
263723
263747
|
async handleFileRename(oldPath, newPath) {
|
|
263724
|
-
const oldRelativePath =
|
|
263725
|
-
const newRelativePath =
|
|
263748
|
+
const oldRelativePath = path57.relative(this.projectDir, oldPath);
|
|
263749
|
+
const newRelativePath = path57.relative(this.projectDir, newPath);
|
|
263726
263750
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
263727
263751
|
return;
|
|
263728
263752
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -263740,7 +263764,7 @@ class DevServer {
|
|
|
263740
263764
|
});
|
|
263741
263765
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
263742
263766
|
for (const filePath of filePaths) {
|
|
263743
|
-
const relativeFilePath =
|
|
263767
|
+
const relativeFilePath = path57.relative(this.projectDir, filePath);
|
|
263744
263768
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
263745
263769
|
await this.postFileUpsert({
|
|
263746
263770
|
filePath: relativeFilePath,
|
|
@@ -263772,7 +263796,7 @@ class DevServer {
|
|
|
263772
263796
|
}
|
|
263773
263797
|
async uploadNodeModuleFiles(files) {
|
|
263774
263798
|
for (const nodeModuleFile of files) {
|
|
263775
|
-
const relativeFilePath =
|
|
263799
|
+
const relativeFilePath = path57.relative(this.projectDir, nodeModuleFile);
|
|
263776
263800
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
263777
263801
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
263778
263802
|
await this.postFileUpsert({
|
|
@@ -263811,7 +263835,7 @@ class DevServer {
|
|
|
263811
263835
|
getInitialNodeModuleDependencyEntryFiles() {
|
|
263812
263836
|
const entryFiles = [this.componentFilePath];
|
|
263813
263837
|
for (const configFileName of CONFIG_MODULE_FILENAMES2) {
|
|
263814
|
-
const configPath =
|
|
263838
|
+
const configPath = path57.join(this.projectDir, configFileName);
|
|
263815
263839
|
if (fs52.existsSync(configPath)) {
|
|
263816
263840
|
entryFiles.push(configPath);
|
|
263817
263841
|
}
|
|
@@ -263827,7 +263851,7 @@ class DevServer {
|
|
|
263827
263851
|
formData.set("file_path", filePath);
|
|
263828
263852
|
formData.set("initiator", initiator);
|
|
263829
263853
|
const binaryBytes = Uint8Array.from(binaryContent);
|
|
263830
|
-
formData.set("binary_file", new Blob([binaryBytes]),
|
|
263854
|
+
formData.set("binary_file", new Blob([binaryBytes]), path57.basename(filePath));
|
|
263831
263855
|
const response = await fetch(`http://localhost:${this.port}/api/files/upsert-multipart`, {
|
|
263832
263856
|
method: "POST",
|
|
263833
263857
|
body: formData
|
|
@@ -263867,7 +263891,7 @@ class DevServer {
|
|
|
263867
263891
|
await this.filesystemWatcher?.close();
|
|
263868
263892
|
}
|
|
263869
263893
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
263870
|
-
const ext =
|
|
263894
|
+
const ext = path57.extname(relativeFilePath).toLowerCase();
|
|
263871
263895
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
263872
263896
|
const fileBuffer = fs52.readFileSync(absoluteFilePath);
|
|
263873
263897
|
return { binary_content: fileBuffer };
|
|
@@ -263913,7 +263937,7 @@ var isPortAvailable = (port) => {
|
|
|
263913
263937
|
});
|
|
263914
263938
|
};
|
|
263915
263939
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
263916
|
-
const tsconfigPath =
|
|
263940
|
+
const tsconfigPath = path58.join(projectDir, "tsconfig.json");
|
|
263917
263941
|
if (!fs53.existsSync(tsconfigPath)) {
|
|
263918
263942
|
return;
|
|
263919
263943
|
}
|
|
@@ -263950,7 +263974,7 @@ var registerDev = (program2) => {
|
|
|
263950
263974
|
|
|
263951
263975
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
263952
263976
|
console.log(`
|
|
263953
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
263977
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path58.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
263954
263978
|
|
|
263955
263979
|
`);
|
|
263956
263980
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -263980,13 +264004,13 @@ var checkLoggedIn = () => {
|
|
|
263980
264004
|
import { spawnSync } from "node:child_process";
|
|
263981
264005
|
import fs54 from "node:fs";
|
|
263982
264006
|
import os7 from "node:os";
|
|
263983
|
-
import
|
|
264007
|
+
import path59 from "node:path";
|
|
263984
264008
|
var hasBunInstalled = () => {
|
|
263985
264009
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
263986
264010
|
return result.status === 0;
|
|
263987
264011
|
};
|
|
263988
264012
|
var createTempProject = (tempDir) => {
|
|
263989
|
-
const packageJsonPath =
|
|
264013
|
+
const packageJsonPath = path59.join(tempDir, "package.json");
|
|
263990
264014
|
const packageJson = {
|
|
263991
264015
|
name: "tsci-doctor-check",
|
|
263992
264016
|
version: "0.0.0",
|
|
@@ -264006,7 +264030,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
264006
264030
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
264007
264031
|
};
|
|
264008
264032
|
}
|
|
264009
|
-
const tempDir = fs54.mkdtempSync(
|
|
264033
|
+
const tempDir = fs54.mkdtempSync(path59.join(os7.tmpdir(), "tsci-doctor-"));
|
|
264010
264034
|
try {
|
|
264011
264035
|
createTempProject(tempDir);
|
|
264012
264036
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -264078,7 +264102,7 @@ var registerDoctor = (program2) => {
|
|
|
264078
264102
|
|
|
264079
264103
|
// lib/shared/export-snippet.ts
|
|
264080
264104
|
import fs55 from "node:fs";
|
|
264081
|
-
import
|
|
264105
|
+
import path60 from "node:path";
|
|
264082
264106
|
import { promisify as promisify3 } from "node:util";
|
|
264083
264107
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
264084
264108
|
import {
|
|
@@ -265211,9 +265235,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
265211
265235
|
const stringifyCoordinates = (coordinates) => {
|
|
265212
265236
|
return coordinates.join(" ");
|
|
265213
265237
|
};
|
|
265214
|
-
const stringifyPath = (
|
|
265238
|
+
const stringifyPath = (path60, level) => {
|
|
265215
265239
|
const padding = indent.repeat(level);
|
|
265216
|
-
return `${padding}(path ${
|
|
265240
|
+
return `${padding}(path ${path60.layer} ${path60.width} ${stringifyCoordinates(path60.coordinates)})`;
|
|
265217
265241
|
};
|
|
265218
265242
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
265219
265243
|
`;
|
|
@@ -266892,11 +266916,11 @@ var convertSoupToGerberCommands = (soup, opts = {}) => {
|
|
|
266892
266916
|
continue;
|
|
266893
266917
|
}
|
|
266894
266918
|
const letterPaths = lineAlphabet2[char] || [];
|
|
266895
|
-
for (const
|
|
266896
|
-
const x12 = anchoredX +
|
|
266897
|
-
const y12 = anchoredY +
|
|
266898
|
-
const x22 = anchoredX +
|
|
266899
|
-
const y22 = anchoredY +
|
|
266919
|
+
for (const path60 of letterPaths) {
|
|
266920
|
+
const x12 = anchoredX + path60.x1 * fontSize;
|
|
266921
|
+
const y12 = anchoredY + path60.y1 * fontSize;
|
|
266922
|
+
const x22 = anchoredX + path60.x2 * fontSize;
|
|
266923
|
+
const y22 = anchoredY + path60.y2 * fontSize;
|
|
266900
266924
|
const p12 = applyTransform({ x: x12, y: y12 });
|
|
266901
266925
|
const p23 = applyTransform({ x: x22, y: y22 });
|
|
266902
266926
|
gerber.add("move_operation", { x: p12.x, y: mfy(p12.y) });
|
|
@@ -267670,10 +267694,10 @@ var exportSnippet = async ({
|
|
|
267670
267694
|
onError(`Invalid format: ${format}`);
|
|
267671
267695
|
return onExit(1);
|
|
267672
267696
|
}
|
|
267673
|
-
const projectDir =
|
|
267674
|
-
const outputBaseName =
|
|
267697
|
+
const projectDir = path60.dirname(filePath);
|
|
267698
|
+
const outputBaseName = path60.basename(filePath).replace(/\.[^.]+$/, "");
|
|
267675
267699
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
267676
|
-
const outputDestination =
|
|
267700
|
+
const outputDestination = path60.join(projectDir, outputPath ?? outputFileName);
|
|
267677
267701
|
if (format === "kicad-library") {
|
|
267678
267702
|
try {
|
|
267679
267703
|
const result = await convertToKicadLibrary({
|
|
@@ -267785,7 +267809,7 @@ var exportSnippet = async ({
|
|
|
267785
267809
|
model3dSourcePaths: pcbConverter.getModel3dSourcePaths(),
|
|
267786
267810
|
projectName: outputBaseName,
|
|
267787
267811
|
fetch: platformConfig2?.platformFetch ?? globalThis.fetch,
|
|
267788
|
-
readFile: (modelPath) => fs55.promises.readFile(
|
|
267812
|
+
readFile: (modelPath) => fs55.promises.readFile(path60.resolve(projectDir, modelPath)),
|
|
267789
267813
|
onModelFile: ({ outputPath: outputPath2, content }) => {
|
|
267790
267814
|
zip.file(outputPath2, content);
|
|
267791
267815
|
},
|
|
@@ -267966,13 +267990,13 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
267966
267990
|
};
|
|
267967
267991
|
|
|
267968
267992
|
// lib/eecircuit-engine/run-simulation.ts
|
|
267969
|
-
import { promises as fs56, existsSync as
|
|
267970
|
-
import
|
|
267993
|
+
import { promises as fs56, existsSync as existsSync15 } from "node:fs";
|
|
267994
|
+
import path61 from "node:path";
|
|
267971
267995
|
import os8 from "node:os";
|
|
267972
267996
|
var sim = null;
|
|
267973
267997
|
var fetchSimulation = async () => {
|
|
267974
|
-
const tempFilePath =
|
|
267975
|
-
if (!
|
|
267998
|
+
const tempFilePath = path61.join(os8.tmpdir(), `tscircuit-eecircuit-engine-1.7.4.mjs`);
|
|
267999
|
+
if (!existsSync15(tempFilePath)) {
|
|
267976
268000
|
const url2 = `https://jscdn.tscircuit.com/@tscircuit/eecircuit-engine/1.7.4/dist/eecircuit-engine.mjs`;
|
|
267977
268001
|
const response = await fetch(url2);
|
|
267978
268002
|
if (!response.ok) {
|
|
@@ -268068,7 +268092,7 @@ var resultToCsv = (result) => {
|
|
|
268068
268092
|
};
|
|
268069
268093
|
|
|
268070
268094
|
// cli/export/register.ts
|
|
268071
|
-
import
|
|
268095
|
+
import path62 from "node:path";
|
|
268072
268096
|
import { promises as fs57 } from "node:fs";
|
|
268073
268097
|
var registerExport = (program2) => {
|
|
268074
268098
|
program2.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`).option("-o, --output <path>", "Output file path").option("--disable-parts-engine", "Disable the parts engine").option("--show-courtyards", "Show courtyard outlines in PCB SVG output").action(async (file, options) => {
|
|
@@ -268083,7 +268107,7 @@ var registerExport = (program2) => {
|
|
|
268083
268107
|
});
|
|
268084
268108
|
if (circuitJson) {
|
|
268085
268109
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
268086
|
-
const outputSpicePath = options.output ??
|
|
268110
|
+
const outputSpicePath = options.output ?? path62.join(path62.dirname(file), `${path62.basename(file, path62.extname(file))}.spice.cir`);
|
|
268087
268111
|
await fs57.writeFile(outputSpicePath, spiceString);
|
|
268088
268112
|
const { result } = await runSimulation(spiceString);
|
|
268089
268113
|
const csvContent = resultToCsv(result);
|
|
@@ -268810,8 +268834,8 @@ function getErrorMap2() {
|
|
|
268810
268834
|
return overrideErrorMap2;
|
|
268811
268835
|
}
|
|
268812
268836
|
var makeIssue2 = (params2) => {
|
|
268813
|
-
const { data, path:
|
|
268814
|
-
const fullPath = [...
|
|
268837
|
+
const { data, path: path63, errorMaps, issueData } = params2;
|
|
268838
|
+
const fullPath = [...path63, ...issueData.path || []];
|
|
268815
268839
|
const fullIssue = {
|
|
268816
268840
|
...issueData,
|
|
268817
268841
|
path: fullPath
|
|
@@ -268919,11 +268943,11 @@ var errorUtil2;
|
|
|
268919
268943
|
errorUtil22.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
268920
268944
|
})(errorUtil2 || (errorUtil2 = {}));
|
|
268921
268945
|
var ParseInputLazyPath2 = class {
|
|
268922
|
-
constructor(parent, value,
|
|
268946
|
+
constructor(parent, value, path63, key) {
|
|
268923
268947
|
this._cachedPath = [];
|
|
268924
268948
|
this.parent = parent;
|
|
268925
268949
|
this.data = value;
|
|
268926
|
-
this._path =
|
|
268950
|
+
this._path = path63;
|
|
268927
268951
|
this._key = key;
|
|
268928
268952
|
}
|
|
268929
268953
|
get path() {
|
|
@@ -276592,15 +276616,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
276592
276616
|
}
|
|
276593
276617
|
}
|
|
276594
276618
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
276595
|
-
const
|
|
276619
|
+
const path63 = [];
|
|
276596
276620
|
for (let i3 = 0;i3 <= numPoints; i3++) {
|
|
276597
276621
|
const t50 = i3 / numPoints;
|
|
276598
276622
|
const angle2 = startAngle + t50 * (endAngle - startAngle);
|
|
276599
276623
|
const x4 = centerX + radius * Math.cos(angle2);
|
|
276600
276624
|
const y4 = centerY + radius * Math.sin(angle2);
|
|
276601
|
-
|
|
276625
|
+
path63.push({ x: x4, y: y4 });
|
|
276602
276626
|
}
|
|
276603
|
-
return
|
|
276627
|
+
return path63;
|
|
276604
276628
|
}
|
|
276605
276629
|
var mil10ToMm = (value) => value * 10 * 0.0254;
|
|
276606
276630
|
var getBoundsCenter = (bounds) => ({
|
|
@@ -277771,7 +277795,7 @@ var parsePin = (pinString) => {
|
|
|
277771
277795
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
277772
277796
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
277773
277797
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
277774
|
-
const
|
|
277798
|
+
const path63 = pathMatch ? pathMatch[1] : "";
|
|
277775
277799
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
277776
277800
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
277777
277801
|
const r4 = Number.parseFloat(rotation23);
|
|
@@ -277785,7 +277809,7 @@ var parsePin = (pinString) => {
|
|
|
277785
277809
|
rotation: Number.isNaN(r4) ? 0 : r4,
|
|
277786
277810
|
label,
|
|
277787
277811
|
labelColor,
|
|
277788
|
-
path:
|
|
277812
|
+
path: path63,
|
|
277789
277813
|
arrow
|
|
277790
277814
|
};
|
|
277791
277815
|
};
|
|
@@ -283375,15 +283399,15 @@ function generateArcFromSweep2(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
283375
283399
|
}
|
|
283376
283400
|
}
|
|
283377
283401
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
283378
|
-
const
|
|
283402
|
+
const path63 = [];
|
|
283379
283403
|
for (let i3 = 0;i3 <= numPoints; i3++) {
|
|
283380
283404
|
const t50 = i3 / numPoints;
|
|
283381
283405
|
const angle2 = startAngle + t50 * (endAngle - startAngle);
|
|
283382
283406
|
const x4 = centerX + radius * Math.cos(angle2);
|
|
283383
283407
|
const y4 = centerY + radius * Math.sin(angle2);
|
|
283384
|
-
|
|
283408
|
+
path63.push({ x: x4, y: y4 });
|
|
283385
283409
|
}
|
|
283386
|
-
return
|
|
283410
|
+
return path63;
|
|
283387
283411
|
}
|
|
283388
283412
|
var mil10ToMm2 = (value) => value * 10 * 0.0254;
|
|
283389
283413
|
var getBoundsCenter2 = (bounds) => ({
|
|
@@ -284540,7 +284564,7 @@ var parsePin2 = (pinString) => {
|
|
|
284540
284564
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
284541
284565
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
284542
284566
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
284543
|
-
const
|
|
284567
|
+
const path63 = pathMatch ? pathMatch[1] : "";
|
|
284544
284568
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
284545
284569
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
284546
284570
|
const r4 = Number.parseFloat(rotation23);
|
|
@@ -284554,7 +284578,7 @@ var parsePin2 = (pinString) => {
|
|
|
284554
284578
|
rotation: Number.isNaN(r4) ? 0 : r4,
|
|
284555
284579
|
label,
|
|
284556
284580
|
labelColor,
|
|
284557
|
-
path:
|
|
284581
|
+
path: path63,
|
|
284558
284582
|
arrow
|
|
284559
284583
|
};
|
|
284560
284584
|
};
|
|
@@ -284877,14 +284901,14 @@ function normalizeManufacturerPartNumber2(partNumber) {
|
|
|
284877
284901
|
|
|
284878
284902
|
// lib/import/import-component-from-jlcpcb.ts
|
|
284879
284903
|
import fs58 from "node:fs/promises";
|
|
284880
|
-
import
|
|
284904
|
+
import path63 from "node:path";
|
|
284881
284905
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd(), options = {}) => {
|
|
284882
284906
|
const rawEasy = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
284883
284907
|
const betterEasy = EasyEdaJsonSchema2.parse(rawEasy);
|
|
284884
284908
|
const rawPn = betterEasy.dataStr.head.c_para["Manufacturer Part"];
|
|
284885
284909
|
const componentName = rawPn ? normalizeManufacturerPartNumber2(rawPn) : jlcpcbPartNumber;
|
|
284886
284910
|
let tsx = await convertRawEasyToTsx({ rawEasy });
|
|
284887
|
-
const componentDir = options.download ?
|
|
284911
|
+
const componentDir = options.download ? path63.join(projectDir, "imports", componentName) : path63.join(projectDir, "imports");
|
|
284888
284912
|
await fs58.mkdir(componentDir, { recursive: true });
|
|
284889
284913
|
if (options.download) {
|
|
284890
284914
|
const platformConfig2 = getPlatformConfigWithCliDefaults();
|
|
@@ -284896,7 +284920,7 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
284896
284920
|
if (cadComponent?.model_step_url) {
|
|
284897
284921
|
const stepFileName = `${componentName}.step`;
|
|
284898
284922
|
const stepResp = await platformFetch2(cadComponent.model_step_url);
|
|
284899
|
-
await fs58.writeFile(
|
|
284923
|
+
await fs58.writeFile(path63.join(componentDir, stepFileName), Buffer.from(await stepResp.arrayBuffer()));
|
|
284900
284924
|
tsx = `import stepPath from "./${stepFileName}"
|
|
284901
284925
|
` + tsx;
|
|
284902
284926
|
tsx = tsx.replace(`"${cadComponent.model_step_url}"`, "stepPath");
|
|
@@ -284904,13 +284928,13 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
284904
284928
|
if (cadComponent?.model_obj_url) {
|
|
284905
284929
|
const objFileName = `${componentName}.obj`;
|
|
284906
284930
|
const objResp = await platformFetch2(cadComponent.model_obj_url);
|
|
284907
|
-
await fs58.writeFile(
|
|
284931
|
+
await fs58.writeFile(path63.join(componentDir, objFileName), Buffer.from(await objResp.arrayBuffer()));
|
|
284908
284932
|
tsx = `import objPath from "./${objFileName}"
|
|
284909
284933
|
` + tsx;
|
|
284910
284934
|
tsx = tsx.replace(`"${cadComponent.model_obj_url}"`, "objPath");
|
|
284911
284935
|
}
|
|
284912
284936
|
}
|
|
284913
|
-
const filePath =
|
|
284937
|
+
const filePath = path63.join(componentDir, `${componentName}.tsx`);
|
|
284914
284938
|
await fs58.writeFile(filePath, tsx);
|
|
284915
284939
|
return { filePath };
|
|
284916
284940
|
};
|
|
@@ -286353,12 +286377,12 @@ var registerImport = (program2) => {
|
|
|
286353
286377
|
|
|
286354
286378
|
// cli/init/register.ts
|
|
286355
286379
|
import * as fs60 from "node:fs";
|
|
286356
|
-
import * as
|
|
286380
|
+
import * as path66 from "node:path";
|
|
286357
286381
|
|
|
286358
286382
|
// lib/shared/generate-gitignore-file.ts
|
|
286359
|
-
import
|
|
286383
|
+
import path64 from "node:path";
|
|
286360
286384
|
var generateGitIgnoreFile = (dir) => {
|
|
286361
|
-
const gitignorePath =
|
|
286385
|
+
const gitignorePath = path64.join(dir, ".gitignore");
|
|
286362
286386
|
const gitignoreContent = `# Dependencies
|
|
286363
286387
|
node_modules/
|
|
286364
286388
|
|
|
@@ -286394,7 +286418,7 @@ yarn-error.log*
|
|
|
286394
286418
|
|
|
286395
286419
|
// lib/shared/setup-tscircuit-skill.ts
|
|
286396
286420
|
import * as fs59 from "node:fs";
|
|
286397
|
-
import * as
|
|
286421
|
+
import * as path65 from "node:path";
|
|
286398
286422
|
var SKILL_REPO_API_URL = "https://api.github.com/repos/tscircuit/skill/contents";
|
|
286399
286423
|
var SKILL_INSTALL_PATHS = [
|
|
286400
286424
|
".claude/skills/tscircuit",
|
|
@@ -286417,7 +286441,7 @@ async function fetchFileContent(downloadUrl) {
|
|
|
286417
286441
|
async function downloadDirectory(apiUrl, targetDir) {
|
|
286418
286442
|
const contents = await fetchGitHubContents(apiUrl);
|
|
286419
286443
|
for (const item of contents) {
|
|
286420
|
-
const targetPath =
|
|
286444
|
+
const targetPath = path65.join(targetDir, item.name);
|
|
286421
286445
|
if (item.type === "dir") {
|
|
286422
286446
|
fs59.mkdirSync(targetPath, { recursive: true });
|
|
286423
286447
|
await downloadDirectory(`${apiUrl}/${item.name}`, targetPath);
|
|
@@ -286434,7 +286458,7 @@ async function downloadSkillRepo(targetDir) {
|
|
|
286434
286458
|
if (item.name === ".git" || item.name === ".github") {
|
|
286435
286459
|
continue;
|
|
286436
286460
|
}
|
|
286437
|
-
const targetPath =
|
|
286461
|
+
const targetPath = path65.join(targetDir, item.name);
|
|
286438
286462
|
if (item.type === "dir") {
|
|
286439
286463
|
fs59.mkdirSync(targetPath, { recursive: true });
|
|
286440
286464
|
await downloadDirectory(`${SKILL_REPO_API_URL}/${item.name}`, targetPath);
|
|
@@ -286445,7 +286469,7 @@ async function downloadSkillRepo(targetDir) {
|
|
|
286445
286469
|
}
|
|
286446
286470
|
}
|
|
286447
286471
|
async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
286448
|
-
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !fs59.existsSync(
|
|
286472
|
+
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !fs59.existsSync(path65.join(projectDir, skillPath, "SKILL.md")));
|
|
286449
286473
|
if (missingSkillPaths.length === 0) {
|
|
286450
286474
|
console.log("TSCircuit AI skills already exist, skipping...");
|
|
286451
286475
|
return true;
|
|
@@ -286465,7 +286489,7 @@ async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
|
286465
286489
|
console.info("Setting up tscircuit AI skills...");
|
|
286466
286490
|
try {
|
|
286467
286491
|
for (const skillPath of missingSkillPaths) {
|
|
286468
|
-
const targetDir =
|
|
286492
|
+
const targetDir = path65.join(projectDir, skillPath);
|
|
286469
286493
|
await downloadSkillRepo(targetDir);
|
|
286470
286494
|
console.info(`tscircuit skill installed at ${skillPath}`);
|
|
286471
286495
|
}
|
|
@@ -286550,7 +286574,7 @@ var POSTHOG_HOST = "https://us.i.posthog.com";
|
|
|
286550
286574
|
var TSCI_POSTHOG_PROJECT_API_KEY = "phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo";
|
|
286551
286575
|
var POSTHOG_CAPTURE_PATH = "/capture";
|
|
286552
286576
|
var isTruthy4 = (value) => value ? ["1", "true", "yes", "on"].includes(value.toLowerCase()) : false;
|
|
286553
|
-
var joinUrl = (host,
|
|
286577
|
+
var joinUrl = (host, path66) => `${host.replace(/\/$/, "")}${path66}`;
|
|
286554
286578
|
var getTelemetryConfigFromEnv = (env3 = process.env) => {
|
|
286555
286579
|
if (isTruthy4(env3.TSCI_TELEMETRY_DISABLED)) {
|
|
286556
286580
|
return { enabled: false };
|
|
@@ -286618,7 +286642,7 @@ var registerInit = (program3) => {
|
|
|
286618
286642
|
}
|
|
286619
286643
|
}
|
|
286620
286644
|
}
|
|
286621
|
-
const projectDir = directory ?
|
|
286645
|
+
const projectDir = directory ? path66.resolve(process.cwd(), directory) : process.cwd();
|
|
286622
286646
|
let tsciHandle = null;
|
|
286623
286647
|
const token = getSessionToken();
|
|
286624
286648
|
if (token) {
|
|
@@ -286629,7 +286653,7 @@ var registerInit = (program3) => {
|
|
|
286629
286653
|
}
|
|
286630
286654
|
} catch {}
|
|
286631
286655
|
}
|
|
286632
|
-
const dirName =
|
|
286656
|
+
const dirName = path66.basename(projectDir);
|
|
286633
286657
|
let defaultPackageName = dirName;
|
|
286634
286658
|
if (tsciHandle) {
|
|
286635
286659
|
defaultPackageName = `@tsci/${tsciHandle}.${dirName}`;
|
|
@@ -286648,7 +286672,7 @@ var registerInit = (program3) => {
|
|
|
286648
286672
|
}
|
|
286649
286673
|
}
|
|
286650
286674
|
fs60.mkdirSync(projectDir, { recursive: true });
|
|
286651
|
-
writeFileIfNotExists(
|
|
286675
|
+
writeFileIfNotExists(path66.join(projectDir, "index.circuit.tsx"), `
|
|
286652
286676
|
export default () => (
|
|
286653
286677
|
<board>
|
|
286654
286678
|
<resistor resistance="1k" footprint="0402" name="R1" />
|
|
@@ -286660,7 +286684,7 @@ export default () => (
|
|
|
286660
286684
|
if (saveProjectConfig(null, projectDir)) {
|
|
286661
286685
|
console.log("Created tscircuit.config.json with schema");
|
|
286662
286686
|
}
|
|
286663
|
-
writeFileIfNotExists(
|
|
286687
|
+
writeFileIfNotExists(path66.join(projectDir, ".npmrc"), `
|
|
286664
286688
|
@tsci:registry=https://npm.tscircuit.com
|
|
286665
286689
|
`);
|
|
286666
286690
|
console.log("Generating package.json");
|
|
@@ -286799,9 +286823,9 @@ var registerRegistryPackagesCreate = (program3) => {
|
|
|
286799
286823
|
|
|
286800
286824
|
// cli/registry/packages/update/register.ts
|
|
286801
286825
|
import fs61 from "node:fs";
|
|
286802
|
-
import
|
|
286826
|
+
import path67 from "node:path";
|
|
286803
286827
|
var getCurrentDirectoryPackageName = () => {
|
|
286804
|
-
const packageJsonPath =
|
|
286828
|
+
const packageJsonPath = path67.join(process.cwd(), "package.json");
|
|
286805
286829
|
if (!fs61.existsSync(packageJsonPath))
|
|
286806
286830
|
return;
|
|
286807
286831
|
try {
|
|
@@ -286942,14 +286966,14 @@ var KeyStore = class {
|
|
|
286942
286966
|
}
|
|
286943
286967
|
};
|
|
286944
286968
|
function createKey(key) {
|
|
286945
|
-
let
|
|
286969
|
+
let path68 = null;
|
|
286946
286970
|
let id2 = null;
|
|
286947
286971
|
let src = null;
|
|
286948
286972
|
let weight = 1;
|
|
286949
286973
|
let getFn = null;
|
|
286950
286974
|
if (isString2(key) || isArray(key)) {
|
|
286951
286975
|
src = key;
|
|
286952
|
-
|
|
286976
|
+
path68 = createKeyPath(key);
|
|
286953
286977
|
id2 = createKeyId(key);
|
|
286954
286978
|
} else {
|
|
286955
286979
|
if (!hasOwn.call(key, "name"))
|
|
@@ -286961,12 +286985,12 @@ function createKey(key) {
|
|
|
286961
286985
|
if (weight <= 0)
|
|
286962
286986
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(createKeyId(name)));
|
|
286963
286987
|
}
|
|
286964
|
-
|
|
286988
|
+
path68 = createKeyPath(name);
|
|
286965
286989
|
id2 = createKeyId(name);
|
|
286966
286990
|
getFn = key.getFn ?? null;
|
|
286967
286991
|
}
|
|
286968
286992
|
return {
|
|
286969
|
-
path:
|
|
286993
|
+
path: path68,
|
|
286970
286994
|
id: id2,
|
|
286971
286995
|
weight,
|
|
286972
286996
|
src,
|
|
@@ -286979,22 +287003,22 @@ function createKeyPath(key) {
|
|
|
286979
287003
|
function createKeyId(key) {
|
|
286980
287004
|
return isArray(key) ? key.join(".") : key;
|
|
286981
287005
|
}
|
|
286982
|
-
function get(obj,
|
|
287006
|
+
function get(obj, path68) {
|
|
286983
287007
|
const list = [];
|
|
286984
287008
|
let arr = false;
|
|
286985
|
-
const deepGet = (obj2,
|
|
287009
|
+
const deepGet = (obj2, path69, index, arrayIndex) => {
|
|
286986
287010
|
if (!isDefined(obj2))
|
|
286987
287011
|
return;
|
|
286988
|
-
if (!
|
|
287012
|
+
if (!path69[index])
|
|
286989
287013
|
list.push(arrayIndex !== undefined ? {
|
|
286990
287014
|
v: obj2,
|
|
286991
287015
|
i: arrayIndex
|
|
286992
287016
|
} : obj2);
|
|
286993
287017
|
else {
|
|
286994
|
-
const value = obj2[
|
|
287018
|
+
const value = obj2[path69[index]];
|
|
286995
287019
|
if (!isDefined(value))
|
|
286996
287020
|
return;
|
|
286997
|
-
if (index ===
|
|
287021
|
+
if (index === path69.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value) || typeof value === "bigint"))
|
|
286998
287022
|
list.push(arrayIndex !== undefined ? {
|
|
286999
287023
|
v: toString2(value),
|
|
287000
287024
|
i: arrayIndex
|
|
@@ -287002,12 +287026,12 @@ function get(obj, path67) {
|
|
|
287002
287026
|
else if (isArray(value)) {
|
|
287003
287027
|
arr = true;
|
|
287004
287028
|
for (let i3 = 0, len = value.length;i3 < len; i3 += 1)
|
|
287005
|
-
deepGet(value[i3],
|
|
287006
|
-
} else if (
|
|
287007
|
-
deepGet(value,
|
|
287029
|
+
deepGet(value[i3], path69, index + 1, i3);
|
|
287030
|
+
} else if (path69.length)
|
|
287031
|
+
deepGet(value, path69, index + 1, arrayIndex);
|
|
287008
287032
|
}
|
|
287009
287033
|
};
|
|
287010
|
-
deepGet(obj, isString2(
|
|
287034
|
+
deepGet(obj, isString2(path68) ? path68.split(".") : path68, 0);
|
|
287011
287035
|
return arr ? list : list[0];
|
|
287012
287036
|
}
|
|
287013
287037
|
var MatchOptions = {
|
|
@@ -288683,8 +288707,8 @@ function createBridgeHeaders(partnerToken, accept) {
|
|
|
288683
288707
|
}
|
|
288684
288708
|
return headers;
|
|
288685
288709
|
}
|
|
288686
|
-
function buildRequestUrl(baseUrl,
|
|
288687
|
-
return `${normalizeBaseUrl(baseUrl)}${
|
|
288710
|
+
function buildRequestUrl(baseUrl, path68) {
|
|
288711
|
+
return `${normalizeBaseUrl(baseUrl)}${path68}`;
|
|
288688
288712
|
}
|
|
288689
288713
|
function logRequest(logger, url2) {
|
|
288690
288714
|
if (!logger)
|
|
@@ -288718,8 +288742,8 @@ function createBridgeHeaders2(partnerToken, accept) {
|
|
|
288718
288742
|
}
|
|
288719
288743
|
return headers;
|
|
288720
288744
|
}
|
|
288721
|
-
function buildRequestUrl2(baseUrl,
|
|
288722
|
-
return `${normalizeBaseUrl(baseUrl)}${
|
|
288745
|
+
function buildRequestUrl2(baseUrl, path68) {
|
|
288746
|
+
return `${normalizeBaseUrl(baseUrl)}${path68}`;
|
|
288723
288747
|
}
|
|
288724
288748
|
function logRequest2(logger, url2) {
|
|
288725
288749
|
if (!logger)
|
|
@@ -288767,11 +288791,11 @@ function createUltraLibrarianBridgeClient(options = {}) {
|
|
|
288767
288791
|
return {
|
|
288768
288792
|
baseUrl,
|
|
288769
288793
|
async searchParts(request) {
|
|
288770
|
-
const
|
|
288794
|
+
const path68 = buildSearchPath(request);
|
|
288771
288795
|
const rawPayload = await requestJson({
|
|
288772
288796
|
fetchImpl,
|
|
288773
288797
|
baseUrl,
|
|
288774
|
-
path:
|
|
288798
|
+
path: path68,
|
|
288775
288799
|
partnerToken,
|
|
288776
288800
|
logger
|
|
288777
288801
|
});
|
|
@@ -288781,11 +288805,11 @@ function createUltraLibrarianBridgeClient(options = {}) {
|
|
|
288781
288805
|
};
|
|
288782
288806
|
},
|
|
288783
288807
|
async downloadKicadArchive(request) {
|
|
288784
|
-
const
|
|
288808
|
+
const path68 = buildKicadExportPath(request);
|
|
288785
288809
|
return await requestArchive({
|
|
288786
288810
|
fetchImpl,
|
|
288787
288811
|
baseUrl,
|
|
288788
|
-
path:
|
|
288812
|
+
path: path68,
|
|
288789
288813
|
partnerToken,
|
|
288790
288814
|
logger
|
|
288791
288815
|
});
|
|
@@ -288896,9 +288920,9 @@ var registerSearch = (program3) => {
|
|
|
288896
288920
|
}
|
|
288897
288921
|
if (opts.json) {
|
|
288898
288922
|
const unifiedResults = [
|
|
288899
|
-
...kicadResults.map((
|
|
288923
|
+
...kicadResults.map((path68) => ({
|
|
288900
288924
|
source: "kicad",
|
|
288901
|
-
path:
|
|
288925
|
+
path: path68
|
|
288902
288926
|
})),
|
|
288903
288927
|
...results.packages.map((pkg) => ({
|
|
288904
288928
|
source: "tscircuit",
|
|
@@ -288931,8 +288955,8 @@ var registerSearch = (program3) => {
|
|
|
288931
288955
|
}
|
|
288932
288956
|
if (kicadResults.length) {
|
|
288933
288957
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
288934
|
-
kicadResults.forEach((
|
|
288935
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
288958
|
+
kicadResults.forEach((path68, idx) => {
|
|
288959
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path68.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
288936
288960
|
});
|
|
288937
288961
|
}
|
|
288938
288962
|
if (results.packages.length) {
|
|
@@ -288970,20 +288994,20 @@ var registerSearch = (program3) => {
|
|
|
288970
288994
|
|
|
288971
288995
|
// lib/shared/setup-github-actions.ts
|
|
288972
288996
|
import fs62 from "node:fs";
|
|
288973
|
-
import
|
|
288997
|
+
import path68 from "node:path";
|
|
288974
288998
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
288975
288999
|
const findGitRoot = (startDir) => {
|
|
288976
|
-
let dir =
|
|
288977
|
-
while (dir !==
|
|
288978
|
-
if (fs62.existsSync(
|
|
289000
|
+
let dir = path68.resolve(startDir);
|
|
289001
|
+
while (dir !== path68.parse(dir).root) {
|
|
289002
|
+
if (fs62.existsSync(path68.join(dir, ".git"))) {
|
|
288979
289003
|
return dir;
|
|
288980
289004
|
}
|
|
288981
|
-
dir =
|
|
289005
|
+
dir = path68.dirname(dir);
|
|
288982
289006
|
}
|
|
288983
289007
|
return null;
|
|
288984
289008
|
};
|
|
288985
289009
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
288986
|
-
const workflowsDir =
|
|
289010
|
+
const workflowsDir = path68.join(gitRoot, ".github", "workflows");
|
|
288987
289011
|
fs62.mkdirSync(workflowsDir, { recursive: true });
|
|
288988
289012
|
const buildWorkflow = `name: tscircuit Build
|
|
288989
289013
|
|
|
@@ -289023,8 +289047,8 @@ jobs:
|
|
|
289023
289047
|
- run: bun install
|
|
289024
289048
|
- run: bunx tsci snapshot
|
|
289025
289049
|
`;
|
|
289026
|
-
writeFileIfNotExists(
|
|
289027
|
-
writeFileIfNotExists(
|
|
289050
|
+
writeFileIfNotExists(path68.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
289051
|
+
writeFileIfNotExists(path68.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
289028
289052
|
};
|
|
289029
289053
|
|
|
289030
289054
|
// cli/setup/register.ts
|
|
@@ -289139,21 +289163,21 @@ var registerSimulate = (program3) => {
|
|
|
289139
289163
|
|
|
289140
289164
|
// lib/shared/snapshot-project.ts
|
|
289141
289165
|
import fs66 from "node:fs";
|
|
289142
|
-
import
|
|
289166
|
+
import path71 from "node:path";
|
|
289143
289167
|
|
|
289144
289168
|
// cli/snapshot/worker-pool.ts
|
|
289145
289169
|
import fs63 from "node:fs";
|
|
289146
|
-
import
|
|
289170
|
+
import path69 from "node:path";
|
|
289147
289171
|
var getWorkerEntrypointPath2 = () => {
|
|
289148
|
-
const tsPath =
|
|
289172
|
+
const tsPath = path69.join(import.meta.dir, "snapshot.worker.ts");
|
|
289149
289173
|
if (fs63.existsSync(tsPath)) {
|
|
289150
289174
|
return tsPath;
|
|
289151
289175
|
}
|
|
289152
|
-
const jsBundledPath =
|
|
289176
|
+
const jsBundledPath = path69.join(import.meta.dir, "snapshot", "snapshot.worker.js");
|
|
289153
289177
|
if (fs63.existsSync(jsBundledPath)) {
|
|
289154
289178
|
return jsBundledPath;
|
|
289155
289179
|
}
|
|
289156
|
-
return
|
|
289180
|
+
return path69.join(import.meta.dir, "snapshot.worker.js");
|
|
289157
289181
|
};
|
|
289158
289182
|
var snapshotFilesWithWorkerPool = async (options) => {
|
|
289159
289183
|
const cancellationError = new Error("Snapshot cancelled due to file failure");
|
|
@@ -289224,7 +289248,7 @@ var snapshotFilesWithWorkerPool = async (options) => {
|
|
|
289224
289248
|
|
|
289225
289249
|
// lib/shared/process-snapshot-file.ts
|
|
289226
289250
|
import fs65 from "node:fs";
|
|
289227
|
-
import
|
|
289251
|
+
import path70 from "node:path";
|
|
289228
289252
|
import {
|
|
289229
289253
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg5,
|
|
289230
289254
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg5
|
|
@@ -289273,7 +289297,7 @@ var processSnapshotFile = async ({
|
|
|
289273
289297
|
cameraPreset,
|
|
289274
289298
|
pcbLayer
|
|
289275
289299
|
}) => {
|
|
289276
|
-
const relativeFilePath =
|
|
289300
|
+
const relativeFilePath = path70.relative(projectDir, file);
|
|
289277
289301
|
const successPaths = [];
|
|
289278
289302
|
const warningMessages = [];
|
|
289279
289303
|
const mismatches = [];
|
|
@@ -289368,11 +289392,11 @@ var processSnapshotFile = async ({
|
|
|
289368
289392
|
} catch (error2) {
|
|
289369
289393
|
const errorMessage = error2 instanceof Error ? error2.message : String(error2);
|
|
289370
289394
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
289371
|
-
const fileDir =
|
|
289372
|
-
const relativeDir =
|
|
289373
|
-
const snapDir2 = snapshotsDirName ?
|
|
289374
|
-
const base2 =
|
|
289375
|
-
const snap3dPath =
|
|
289395
|
+
const fileDir = path70.dirname(file);
|
|
289396
|
+
const relativeDir = path70.relative(projectDir, fileDir);
|
|
289397
|
+
const snapDir2 = snapshotsDirName ? path70.join(projectDir, snapshotsDirName, relativeDir) : path70.join(fileDir, "__snapshots__");
|
|
289398
|
+
const base2 = path70.basename(file).replace(/\.[^.]+$/, "");
|
|
289399
|
+
const snap3dPath = path70.join(snapDir2, `${base2}-3d.snap.png`);
|
|
289376
289400
|
const existing3dSnapshot = fs65.existsSync(snap3dPath);
|
|
289377
289401
|
if (existing3dSnapshot) {
|
|
289378
289402
|
return {
|
|
@@ -289384,7 +289408,7 @@ var processSnapshotFile = async ({
|
|
|
289384
289408
|
errorMessage: kleur_default.red(`
|
|
289385
289409
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
289386
289410
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
289387
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
289411
|
+
`) + kleur_default.red(` Existing snapshot: ${path70.relative(projectDir, snap3dPath)}
|
|
289388
289412
|
`)
|
|
289389
289413
|
};
|
|
289390
289414
|
}
|
|
@@ -289405,9 +289429,9 @@ var processSnapshotFile = async ({
|
|
|
289405
289429
|
}
|
|
289406
289430
|
}
|
|
289407
289431
|
}
|
|
289408
|
-
const snapDir = snapshotsDirName ?
|
|
289432
|
+
const snapDir = snapshotsDirName ? path70.join(projectDir, snapshotsDirName, path70.relative(projectDir, path70.dirname(file))) : path70.join(path70.dirname(file), "__snapshots__");
|
|
289409
289433
|
fs65.mkdirSync(snapDir, { recursive: true });
|
|
289410
|
-
const base =
|
|
289434
|
+
const base = path70.basename(file).replace(/\.[^.]+$/, "");
|
|
289411
289435
|
const snapshots = [];
|
|
289412
289436
|
if (!simulationOnly && (pcbOnly || !schematicOnly)) {
|
|
289413
289437
|
let pcbSnapshotType = "pcb";
|
|
@@ -289441,13 +289465,13 @@ var processSnapshotFile = async ({
|
|
|
289441
289465
|
for (const snapshot of snapshots) {
|
|
289442
289466
|
const { type } = snapshot;
|
|
289443
289467
|
const is3d = type === "3d";
|
|
289444
|
-
const snapPath =
|
|
289468
|
+
const snapPath = path70.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
289445
289469
|
const existing = fs65.existsSync(snapPath);
|
|
289446
289470
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
289447
289471
|
const newContentForFile = snapshot.content;
|
|
289448
289472
|
if (!existing) {
|
|
289449
289473
|
fs65.writeFileSync(snapPath, newContentForFile);
|
|
289450
|
-
successPaths.push(
|
|
289474
|
+
successPaths.push(path70.relative(projectDir, snapPath));
|
|
289451
289475
|
didUpdate = true;
|
|
289452
289476
|
continue;
|
|
289453
289477
|
}
|
|
@@ -289463,16 +289487,16 @@ var processSnapshotFile = async ({
|
|
|
289463
289487
|
}
|
|
289464
289488
|
if (update) {
|
|
289465
289489
|
if (!forceUpdate && equal2) {
|
|
289466
|
-
successPaths.push(
|
|
289490
|
+
successPaths.push(path70.relative(projectDir, snapPath));
|
|
289467
289491
|
} else {
|
|
289468
289492
|
fs65.writeFileSync(snapPath, newContentForFile);
|
|
289469
|
-
successPaths.push(
|
|
289493
|
+
successPaths.push(path70.relative(projectDir, snapPath));
|
|
289470
289494
|
didUpdate = true;
|
|
289471
289495
|
}
|
|
289472
289496
|
} else if (!equal2) {
|
|
289473
289497
|
mismatches.push(diffPath ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
289474
289498
|
} else {
|
|
289475
|
-
successPaths.push(
|
|
289499
|
+
successPaths.push(path70.relative(projectDir, snapPath));
|
|
289476
289500
|
}
|
|
289477
289501
|
}
|
|
289478
289502
|
return {
|
|
@@ -289517,7 +289541,7 @@ var snapshotProject = async ({
|
|
|
289517
289541
|
...DEFAULT_IGNORED_PATTERNS,
|
|
289518
289542
|
...ignored.map(normalizeIgnorePattern)
|
|
289519
289543
|
];
|
|
289520
|
-
const resolvedPaths = filePaths.map((f3) =>
|
|
289544
|
+
const resolvedPaths = filePaths.map((f3) => path71.resolve(projectDir, f3));
|
|
289521
289545
|
const explicitDirectoryTarget = resolvedPaths.find((resolvedPath) => {
|
|
289522
289546
|
if (!fs66.existsSync(resolvedPath)) {
|
|
289523
289547
|
return false;
|
|
@@ -289531,7 +289555,7 @@ var snapshotProject = async ({
|
|
|
289531
289555
|
});
|
|
289532
289556
|
if (boardFiles.length === 0) {
|
|
289533
289557
|
if (explicitDirectoryTarget) {
|
|
289534
|
-
const relativeDirectory =
|
|
289558
|
+
const relativeDirectory = path71.relative(projectDir, explicitDirectoryTarget) || ".";
|
|
289535
289559
|
const runtimeIncludeBoardFilePatterns = projectConfig2?.includeBoardFiles?.filter((pattern) => pattern.trim()) ?? [];
|
|
289536
289560
|
const includeBoardFilePatterns = runtimeIncludeBoardFilePatterns.length > 0 ? runtimeIncludeBoardFilePatterns : getBoardFilePatterns(projectDir);
|
|
289537
289561
|
const patternSourceMessage = hasConfiguredIncludeBoardFiles(projectConfig2) ? "Searched using tscircuit.config.json includeBoardFiles" : "Searched using default includeBoardFiles";
|
|
@@ -289695,7 +289719,7 @@ var registerSnapshot = (program3) => {
|
|
|
289695
289719
|
};
|
|
289696
289720
|
|
|
289697
289721
|
// cli/transpile/register.ts
|
|
289698
|
-
import
|
|
289722
|
+
import path72 from "node:path";
|
|
289699
289723
|
var registerTranspile = (program3) => {
|
|
289700
289724
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
289701
289725
|
try {
|
|
@@ -289703,7 +289727,7 @@ var registerTranspile = (program3) => {
|
|
|
289703
289727
|
fileOrDir: file,
|
|
289704
289728
|
includeBoardFiles: false
|
|
289705
289729
|
});
|
|
289706
|
-
const distDir =
|
|
289730
|
+
const distDir = path72.join(projectDir, "dist");
|
|
289707
289731
|
validateMainInDist(projectDir, distDir);
|
|
289708
289732
|
console.log("Transpiling entry file...");
|
|
289709
289733
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -289741,12 +289765,12 @@ function registerUpgradeCommand(program3) {
|
|
|
289741
289765
|
}
|
|
289742
289766
|
|
|
289743
289767
|
// lib/shared/update-package.ts
|
|
289744
|
-
import * as
|
|
289768
|
+
import * as path73 from "node:path";
|
|
289745
289769
|
import * as fs67 from "node:fs";
|
|
289746
289770
|
async function updatePackage(packageSpec, projectDir = process.cwd()) {
|
|
289747
289771
|
const packageManager = getPackageManager();
|
|
289748
289772
|
if (!packageSpec) {
|
|
289749
|
-
const pkgJsonPath =
|
|
289773
|
+
const pkgJsonPath = path73.join(projectDir, "package.json");
|
|
289750
289774
|
if (!fs67.existsSync(pkgJsonPath)) {
|
|
289751
289775
|
console.log(kleur_default.yellow("No package.json found. Cannot update all packages."));
|
|
289752
289776
|
return;
|