usb.ids 2.20251213.0 → 2.20260610.1

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 ADDED
@@ -0,0 +1,74 @@
1
+ # usb.ids
2
+
3
+ USB registry data and the `usb-ids` command line tool.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g usb.ids
9
+ ```
10
+
11
+ ## CLI
12
+
13
+ ```bash
14
+ usb-ids fetch
15
+ usb-ids fetch --force
16
+ usb-ids fetch --force --interactive
17
+ usb-ids fetch --force --interactive --yes
18
+ usb-ids fetch --offline
19
+ usb-ids version
20
+ usb-ids version --json
21
+ usb-ids check
22
+ usb-ids check --json
23
+ usb-ids ui --port 3000
24
+ usb-ids help
25
+ ```
26
+
27
+ Stable exit codes:
28
+
29
+ - `0` success
30
+ - `2` usage error
31
+ - `3` data missing
32
+ - `4` network failure
33
+ - `5` parse failure
34
+ - `6` filesystem failure
35
+
36
+ `version --json` and `check --json` write machine-readable JSON to `stdout` only.
37
+
38
+ ## Data Files
39
+
40
+ The package includes the generated registry data:
41
+
42
+ - `usb.ids`
43
+ - `usb.ids.json`
44
+ - `usb.ids.version.json`
45
+ - `dist/data/usb.ids.min.json`
46
+ - `dist/data/usb.ids.compact.json`
47
+ - `dist/data/vendors.index.json`
48
+ - `dist/data/vendors/*.json`
49
+
50
+ ## SDK
51
+
52
+ Programmatic access is available as a secondary interface:
53
+
54
+ ```ts
55
+ import { getVendors, loadUsbData, searchInData } from "usb.ids";
56
+
57
+ const data = await loadUsbData();
58
+ const vendors = await getVendors();
59
+ const found = searchInData(data, "keyboard");
60
+ ```
61
+
62
+ Browser-safe subpath:
63
+
64
+ ```ts
65
+ import { filterVendors, searchInData } from "usb.ids/browser";
66
+ ```
67
+
68
+ ## Source
69
+
70
+ Repository: https://github.com/Drswith/usb.ids
71
+
72
+ ## License
73
+
74
+ MIT
package/dist/cli.js CHANGED
@@ -511,6 +511,9 @@ function resolveUpstreamMeta(rawContent, existing, strictHeader) {
511
511
  }
512
512
  //#endregion
513
513
  //#region ../sdk/src/repository/file-store.ts
514
+ function writeJsonFile(value, filePath) {
515
+ fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
516
+ }
514
517
  async function saveRawUsbIdsFile(content, filePath) {
515
518
  try {
516
519
  fs.writeFileSync(filePath, content, "utf8");
@@ -520,16 +523,14 @@ async function saveRawUsbIdsFile(content, filePath) {
520
523
  }
521
524
  async function saveUsbIdsToFile(data, filePath) {
522
525
  try {
523
- const jsonContent = JSON.stringify(data, null, 2);
524
- fs.writeFileSync(filePath, jsonContent, "utf8");
526
+ writeJsonFile(data, filePath);
525
527
  } catch (error) {
526
528
  throw new Error(`Failed to save usb.ids JSON: ${error.message}`);
527
529
  }
528
530
  }
529
531
  async function saveVersionInfo(versionInfo, filePath) {
530
532
  try {
531
- const jsonContent = JSON.stringify(versionInfo, null, 2);
532
- fs.writeFileSync(filePath, jsonContent, "utf8");
533
+ writeJsonFile(versionInfo, filePath);
533
534
  } catch (error) {
534
535
  throw new Error(`Failed to save version file: ${error.message}`);
535
536
  }