Skip to content

Commit 9b3f5a6

Browse files
author
MRBadri
committed
feat(core): enhance icon configuration and caching system; add new CLI commands for cache management and update Figma integration
1 parent 4205c83 commit 9b3f5a6

32 files changed

+757
-194
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"30788:66895-B6R9BOyrbu0h3dVMhh1kkT": {
3+
"nodeHash": "f554d37c20885422",
4+
"filePath": "icons/element-category-heading.svg",
5+
"downloadedAt": "2025-09-09T21:56:34.096Z",
6+
"nodeId": "30788:66895",
7+
"nodeName": "Element / Category Heading",
8+
"fileId": "B6R9BOyrbu0h3dVMhh1kkT"
9+
},
10+
"30789:32174-B6R9BOyrbu0h3dVMhh1kkT": {
11+
"nodeHash": "59629728c0e48240",
12+
"filePath": "icons/arrow-chevron_right_duo.svg",
13+
"downloadedAt": "2025-09-09T21:56:34.622Z",
14+
"nodeId": "30789:32174",
15+
"nodeName": "Arrow / Chevron_Right_Duo",
16+
"fileId": "B6R9BOyrbu0h3dVMhh1kkT"
17+
},
18+
"30789:32168-B6R9BOyrbu0h3dVMhh1kkT": {
19+
"nodeHash": "b63f5e2bb9d436ba",
20+
"filePath": "icons/arrow-unfold_more.svg",
21+
"downloadedAt": "2025-09-09T21:56:34.635Z",
22+
"nodeId": "30789:32168",
23+
"nodeName": "Arrow / Unfold_More",
24+
"fileId": "B6R9BOyrbu0h3dVMhh1kkT"
25+
},
26+
"30789:32124-B6R9BOyrbu0h3dVMhh1kkT": {
27+
"nodeHash": "77ba224d5f1cea3d",
28+
"filePath": "icons/arrow-arrow_down_up.svg",
29+
"downloadedAt": "2025-09-09T21:56:34.783Z",
30+
"nodeId": "30789:32124",
31+
"nodeName": "Arrow / Arrow_Down_Up",
32+
"fileId": "B6R9BOyrbu0h3dVMhh1kkT"
33+
}
34+
}

apps/docs/icon.config.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
import { defineConfig, parseFigmaUrl } from "@figmicon/core";
1+
/// <reference types="node" />
2+
import { iconConfig } from "@figmicon/core";
23

34
// https://www.figma.com/design/iH0P8rAVJjqln9jiuNqY7R/VergeCloud?node-id=10806-24901&m=dev
45

56
// TODO: check this URL
67
// https://www.figma.com/design/B6R9BOyrbu0h3dVMhh1kkT/coolicons-%7C-Free-Iconset--Community-?node-id=30789-32015&m=dev
8+
// https://www.figma.com/design/B6R9BOyrbu0h3dVMhh1kkT/coolicons-%7C-Free-Iconset--Community-?node-id=30788-66894&t=AXIVkr6jFRczopB2-4
79

8-
export default defineConfig({
10+
export default iconConfig({
911
figma: {
1012
token: process.env.FIGMA_TOKEN!,
13+
url: "https://www.figma.com/design/B6R9BOyrbu0h3dVMhh1kkT/coolicons-%7C-Free-Iconset--Community-?node-id=30788-66894&t=AXIVkr6jFRczopB2-4",
1114
// fileId: "iH0P8rAVJjqln9jiuNqY7R",
1215
// nodeId: "10806-24901",
1316
// INFO: you can use parseFigmaUrl to parse the url alternative to fileId and nodeId
14-
...parseFigmaUrl(
15-
"https://www.figma.com/design/B6R9BOyrbu0h3dVMhh1kkT/coolicons-%7C-Free-Iconset--Community-?node-id=30789-32168&m=dev"
16-
),
17-
},
18-
fetch: {
19-
// nodeTypes: ["COMPONENT", "COMPONENT_SET"],
20-
generateFileName: (node, parentNode) => node.name + "--" + parentNode.name,
21-
outDir: "icons/badri",
22-
sanitizeName: true,
17+
// ...parseFigmaUrl(
18+
// "https://www.figma.com/design/B6R9BOyrbu0h3dVMhh1kkT/coolicons-%7C-Free-Iconset--Community-?node-id=30788-66894&t=AXIVkr6jFRczopB2-4"
19+
// ),
2320
},
21+
// fetch: {
22+
// // nodeTypes: ["COMPONENT", "COMPONENT_SET"],
23+
// generateFileName: (node, parentNode) => node.name + "--" + parentNode.name,
24+
// // outDir: "icons/badri",
25+
// sanitizeName: true,
26+
// },
2427
});
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Loading

apps/docs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"dev": "next dev -p 3002",
99
"lint": "next lint",
1010
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
11-
"icon": "figmicon fetch --out tmp/icons"
11+
"icon:fetch": "figmicon fetch --out tmp/icons",
12+
"icon:cache:stats": "figmicon cache:stats",
13+
"icon:cache:clear": "figmicon cache:clear"
1214
},
1315
"dependencies": {
1416
"@acme/utils": "workspace:*",

packages/core/STRUTURE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```
2+
packages/core/
3+
├── src/
4+
│ ├── features/ # 🎯 Feature-based organization
5+
│ │ ├── config/ # Configuration management
6+
│ │ │ ├── index.ts # Main exports
7+
│ │ │ ├── loader.ts # Config loading logic
8+
│ │ │ ├── schema.ts # Zod schemas & validation
9+
│ │ │ └── types.ts # Config-specific types
10+
│ │ ├── figma/ # Figma API integration
11+
│ │ │ ├── index.ts # Main exports
12+
│ │ │ ├── client.ts # Figma API client
13+
│ │ │ ├── parser.ts # URL parsing & utilities
14+
│ │ │ └── types.ts # Figma-specific types
15+
│ │ ├── cache/ # Caching system
16+
│ │ │ ├── index.ts # Main exports
17+
│ │ │ ├── node-cache.ts # Node.js cache implementation
18+
│ │ │ └── types.ts # Cache-specific types
19+
│ │ ├── fetch/ # Icon fetching
20+
│ │ │ ├── index.ts # Main exports
21+
│ │ │ ├── download.ts # Download logic
22+
│ │ │ ├── document.ts # Document fetching
23+
│ │ │ └── types.ts # Fetch-specific types
24+
│ │ └── generate/ # Code generation
25+
│ │ ├── index.ts # Main exports
26+
│ │ ├── react.ts # React component generation
27+
│ │ ├── sprite.ts # SVG sprite generation
28+
│ │ └── types.ts # Generation types
29+
│ ├── cli/ # 🖥️ CLI commands
30+
│ │ ├── index.ts # CLI setup & routing
31+
│ │ ├── fetch.ts # Fetch command
32+
│ │ ├── cache.ts # Cache management commands
33+
│ │ └── utils.ts # CLI utilities
34+
│ └──
35+
└──
36+
```

packages/core/TODO.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# TODO
2+
3+
- [ ] Handle caching
4+
- [ ] Handle rate limiting
5+
- [ ] Generate icons with SVGR
6+
- [ ] Generate sprite sheets
7+
- [ ] Generate React components
8+
- [ ] Add example apps
9+
- [ ] Create documentation app
10+
- [ ] Rename packages
11+
- [ ] Handle init command for initial config

packages/core/src/cli/cache.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { loadConfig } from "../features/config";
2+
import { NodeCache } from "@/features/cache";
3+
import { green, cyan, yellow } from "kolorist";
4+
import { cacheLogger } from "@/features/cache";
5+
6+
export const cacheStatsCommand = async () => {
7+
const { source } = await loadConfig();
8+
9+
if (!source) {
10+
console.error(cacheLogger(), "❌", "Could not find config file path");
11+
return;
12+
}
13+
14+
const nodeCache = new NodeCache(source);
15+
const stats = await nodeCache.getCacheStats();
16+
17+
console.log(cacheLogger(), "📊", "Cache Statistics:");
18+
console.log(` Total entries: ${cyan(stats.totalEntries.toString())}`);
19+
console.log(` Cache size: ${cyan(stats.cacheSize)}`);
20+
21+
if (stats.oldestEntry) {
22+
console.log(
23+
` Oldest entry: ${yellow(new Date(stats.oldestEntry).toLocaleString())}`
24+
);
25+
}
26+
27+
if (stats.newestEntry) {
28+
console.log(
29+
` Newest entry: ${yellow(new Date(stats.newestEntry).toLocaleString())}`
30+
);
31+
}
32+
33+
if (stats.totalEntries === 0) {
34+
console.log(yellow(" No cache entries found"));
35+
}
36+
};
37+
38+
export const cacheClearCommand = async () => {
39+
const { source } = await loadConfig();
40+
41+
if (!source) {
42+
console.error(cacheLogger(), "❌", "Could not find config file path");
43+
return;
44+
}
45+
46+
const nodeCache = new NodeCache(source);
47+
await nodeCache.clearCache();
48+
console.log(cacheLogger(), green("✔"), "Cache cleared successfully");
49+
};

0 commit comments

Comments
 (0)