@tscircuit/cli 0.1.2086 → 0.1.2087
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/README.md +18 -0
- package/dist/cli/main.js +39 -4
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -182,6 +182,24 @@ the solver can be reproduced independently. Values that JSON cannot represent
|
|
|
182
182
|
directly, such as `undefined`, `NaN`, maps, sets, or circular references, use
|
|
183
183
|
explicit `value_type` records instead of being silently discarded.
|
|
184
184
|
|
|
185
|
+
## Searching DigiKey and Mouser parts
|
|
186
|
+
|
|
187
|
+
Use `--digikey` or `--mouser` for distributor stock and supplier part numbers:
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
tsci search --digikey LM358
|
|
191
|
+
tsci search --mouser --json "buck converter"
|
|
192
|
+
tsci search --digikey --mouser LM358
|
|
193
|
+
tsci search --ti --digikey --mouser --json TPS62160
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Results come from [DigiKey Search](https://digikeysearch.tscircuit.com) and
|
|
197
|
+
[Mouser Search](https://mousersearch.tscircuit.com), without requiring distributor
|
|
198
|
+
API credentials. Text output includes supplier part numbers; JSON preserves
|
|
199
|
+
returned part metadata with `source: "digikey"` or `source: "mouser"`.
|
|
200
|
+
Stock and pricing reflect the services' cached responses. These flags provide
|
|
201
|
+
part discovery, not direct TSX import from distributors.
|
|
202
|
+
|
|
185
203
|
## Searching Texas Instruments parts
|
|
186
204
|
|
|
187
205
|
Use `--ti` to search the TI catalog indexed by [tisearch](https://tisearch.tscircuit.com):
|
package/dist/cli/main.js
CHANGED
|
@@ -153438,7 +153438,7 @@ var import_perfect_cli = __toESM3(require_dist3(), 1);
|
|
|
153438
153438
|
// lib/getVersion.ts
|
|
153439
153439
|
import { createRequire as createRequire2 } from "node:module";
|
|
153440
153440
|
// package.json
|
|
153441
|
-
var version = "0.1.
|
|
153441
|
+
var version = "0.1.2086";
|
|
153442
153442
|
var package_default = {
|
|
153443
153443
|
name: "@tscircuit/cli",
|
|
153444
153444
|
version,
|
|
@@ -366857,15 +366857,20 @@ var entry_default = Fuse2;
|
|
|
366857
366857
|
|
|
366858
366858
|
// cli/search/register.ts
|
|
366859
366859
|
var registerSearch = (program) => {
|
|
366860
|
-
program.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query...>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--ti", "Search Texas Instruments components").option("--tscircuit", "Search tscircuit registry packages").option("--json", "Output search results as JSON").action(async (queryParts, opts) => {
|
|
366860
|
+
program.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query...>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--ti", "Search Texas Instruments components").option("--digikey", "Search DigiKey components").option("--mouser", "Search Mouser components").option("--tscircuit", "Search tscircuit registry packages").option("--json", "Output search results as JSON").action(async (queryParts, opts) => {
|
|
366861
366861
|
const query = getQueryFromParts(queryParts);
|
|
366862
|
-
const hasFilters = opts.kicad || opts.jlcpcb || opts.lcsc || opts.ti || opts.tscircuit;
|
|
366862
|
+
const hasFilters = opts.kicad || opts.jlcpcb || opts.lcsc || opts.ti || opts.digikey || opts.mouser || opts.tscircuit;
|
|
366863
366863
|
const searchKicad = opts.kicad;
|
|
366864
366864
|
const searchJlc = opts.jlcpcb || opts.lcsc || !hasFilters;
|
|
366865
366865
|
const searchTscircuit = opts.tscircuit;
|
|
366866
366866
|
let results = { packages: [] };
|
|
366867
366867
|
let jlcResults = [];
|
|
366868
366868
|
let tiResults = [];
|
|
366869
|
+
const distributors = [
|
|
366870
|
+
{ source: "digikey", label: "DigiKey", enabled: opts.digikey },
|
|
366871
|
+
{ source: "mouser", label: "Mouser", enabled: opts.mouser }
|
|
366872
|
+
];
|
|
366873
|
+
const distributorResults = [];
|
|
366869
366874
|
let kicadResults = [];
|
|
366870
366875
|
try {
|
|
366871
366876
|
if (searchTscircuit) {
|
|
@@ -366889,6 +366894,23 @@ var registerSearch = (program) => {
|
|
|
366889
366894
|
throw new Error("TI search returned an invalid response");
|
|
366890
366895
|
tiResults = data.components;
|
|
366891
366896
|
}
|
|
366897
|
+
for (const distributor of distributors) {
|
|
366898
|
+
if (!distributor.enabled)
|
|
366899
|
+
continue;
|
|
366900
|
+
const url = `https://${distributor.source}search.tscircuit.com/api/search?limit=10&q=${encodeURIComponent(query)}`;
|
|
366901
|
+
const response = await fetch(url, {
|
|
366902
|
+
headers: { accept: "application/json" }
|
|
366903
|
+
});
|
|
366904
|
+
if (!response.ok)
|
|
366905
|
+
throw new Error(`${distributor.label} search failed (HTTP ${response.status})`);
|
|
366906
|
+
const data = await response.json();
|
|
366907
|
+
if (!Array.isArray(data?.components))
|
|
366908
|
+
throw new Error(`${distributor.label} search returned an invalid response`);
|
|
366909
|
+
distributorResults.push({
|
|
366910
|
+
...distributor,
|
|
366911
|
+
components: data.components
|
|
366912
|
+
});
|
|
366913
|
+
}
|
|
366892
366914
|
if (searchKicad) {
|
|
366893
366915
|
const kicadFiles = await fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then((r) => r.json());
|
|
366894
366916
|
const fuse = new entry_default(kicadFiles);
|
|
@@ -366912,6 +366934,7 @@ var registerSearch = (program) => {
|
|
|
366912
366934
|
...comp,
|
|
366913
366935
|
source: "ti"
|
|
366914
366936
|
})),
|
|
366937
|
+
...distributorResults.flatMap(({ source, components }) => components.map((comp) => ({ ...comp, source }))),
|
|
366915
366938
|
...jlcResults.map((comp) => ({
|
|
366916
366939
|
source: "jlcpcb",
|
|
366917
366940
|
...comp
|
|
@@ -366923,11 +366946,12 @@ var registerSearch = (program) => {
|
|
|
366923
366946
|
}, null, 2));
|
|
366924
366947
|
return;
|
|
366925
366948
|
}
|
|
366926
|
-
if (!kicadResults.length && !results.packages.length && !jlcResults.length && !tiResults.length) {
|
|
366949
|
+
if (!kicadResults.length && !results.packages.length && !jlcResults.length && !tiResults.length && !distributorResults.some(({ components }) => components.length)) {
|
|
366927
366950
|
const sources = [
|
|
366928
366951
|
searchTscircuit && "tscircuit registry",
|
|
366929
366952
|
searchJlc && "JLCPCB",
|
|
366930
366953
|
opts.ti && "Texas Instruments",
|
|
366954
|
+
...distributors.filter((d) => d.enabled).map((d) => d.label),
|
|
366931
366955
|
searchKicad && "KiCad"
|
|
366932
366956
|
].filter(Boolean);
|
|
366933
366957
|
console.log(kleur_default.yellow(`No results found for "${query}" in ${sources.join(", ")}.`));
|
|
@@ -366961,6 +366985,17 @@ var registerSearch = (program) => {
|
|
|
366961
366985
|
console.log(`${idx + 1}. ${comp.mfr} - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
|
|
366962
366986
|
});
|
|
366963
366987
|
}
|
|
366988
|
+
for (const { source, label, components } of distributorResults) {
|
|
366989
|
+
if (!components.length)
|
|
366990
|
+
continue;
|
|
366991
|
+
console.log();
|
|
366992
|
+
console.log(kleur_default.bold().underline(`Found ${components.length} component(s) in ${label} search:`));
|
|
366993
|
+
components.forEach((comp, idx) => {
|
|
366994
|
+
const supplierNumber = comp.supplier_part_number || comp[`${source}_product_number`];
|
|
366995
|
+
const identity = supplierNumber ? `${comp.mfr} (${supplierNumber})` : comp.mfr;
|
|
366996
|
+
console.log(`${idx + 1}. ${identity} - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
|
|
366997
|
+
});
|
|
366998
|
+
}
|
|
366964
366999
|
console.log(`
|
|
366965
367000
|
`);
|
|
366966
367001
|
});
|
package/dist/lib/index.js
CHANGED
|
@@ -69109,7 +69109,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
69109
69109
|
}));
|
|
69110
69110
|
};
|
|
69111
69111
|
// package.json
|
|
69112
|
-
var version = "0.1.
|
|
69112
|
+
var version = "0.1.2086";
|
|
69113
69113
|
var package_default = {
|
|
69114
69114
|
name: "@tscircuit/cli",
|
|
69115
69115
|
version,
|