search-solar 0.1.0
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 +77 -0
- package/dist/cli.js +168 -0
- package/dist/data/icons.json +17820 -0
- package/dist/scripts/parse-icons.js +38 -0
- package/package.json +25 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
3
|
+
/**
|
|
4
|
+
* Strips the `Icon` property from a JS object array in a text file.
|
|
5
|
+
*
|
|
6
|
+
* The file contains JS object literals (not valid JSON), e.g.:
|
|
7
|
+
* {name:"chat-round-money", ..., Icon:ZQ.ChatRoundMoney}
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node dist/parse-icons.js <input.txt>
|
|
11
|
+
*/
|
|
12
|
+
const inputPath = process.argv[2];
|
|
13
|
+
const outputPath = "data/icons.json";
|
|
14
|
+
if (!inputPath) {
|
|
15
|
+
console.error("Usage: node dist/parse-icons.js <input.txt>");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
// ── Read input ────────────────────────────────────────────────────────────────
|
|
19
|
+
const raw = readFileSync(inputPath, "utf-8");
|
|
20
|
+
// ── Step 1: strip the Icon property ──────────────────────────────────────────
|
|
21
|
+
const withoutIcon = raw.replace(/,?\s*Icon\s*:\s*[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*/g, "");
|
|
22
|
+
// ── Step 2: JS object literal → valid JSON ────────────────────────────────────
|
|
23
|
+
const quotedKeys = withoutIcon.replace(/([{,]\s*)([A-Za-z_$][A-Za-z0-9_$]*)(\s*:)/g, '$1"$2"$3');
|
|
24
|
+
const doubleQuoted = quotedKeys.replace(/'([^'\\]*(\\.[^'\\]*)*)'/g, '"$1"');
|
|
25
|
+
const cleaned = doubleQuoted.replace(/,(\s*[}\]])/g, "$1");
|
|
26
|
+
// ── Step 3: parse ─────────────────────────────────────────────────────────────
|
|
27
|
+
let parsed;
|
|
28
|
+
try {
|
|
29
|
+
const json = JSON.parse(cleaned);
|
|
30
|
+
parsed = Array.isArray(json) ? json : [json];
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
throw new Error(`JSON parse failed: ${err.message}`);
|
|
34
|
+
}
|
|
35
|
+
// ── Step 4: write output ──────────────────────────────────────────────────────
|
|
36
|
+
const result = JSON.stringify(parsed);
|
|
37
|
+
writeFileSync(outputPath, result);
|
|
38
|
+
console.log(`✓ Written ${parsed.length} objects to ${outputPath}`);
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "search-solar",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A dead simple CLI to search Solar icons. Built for agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"search-solar": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": ["dist"],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc scripts/parse-icons.ts cli.ts --outDir dist --esModuleInterop --module NodeNext --moduleResolution NodeNext --target ES2020 --declaration false && node -e \"const fs=require('fs');fs.mkdirSync('dist/data',{recursive:true});fs.copyFileSync('data/icons.json','dist/data/icons.json')\"",
|
|
12
|
+
"parse": "npm run build && node dist/parse-icons.js",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": ["solar", "icons", "cli", "search", "agents"],
|
|
16
|
+
"author": "bittere",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^25.5.0",
|
|
20
|
+
"typescript": "^5.9.3"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"commander": "^14.0.3"
|
|
24
|
+
}
|
|
25
|
+
}
|