@solar-icons/cli 2.2.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/LICENSE +11 -0
- package/LICENSE-THIRD-PARTY +14 -0
- package/README.md +24 -0
- package/dist/catalog.d.mts +74 -0
- package/dist/catalog.mjs +3 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +4 -0
- package/dist/commands/get.d.mts +10 -0
- package/dist/commands/get.mjs +1 -0
- package/dist/commands/info.d.mts +7 -0
- package/dist/commands/info.mjs +1 -0
- package/dist/commands/list.d.mts +10 -0
- package/dist/commands/list.mjs +1 -0
- package/dist/commands/search.d.mts +11 -0
- package/dist/commands/search.mjs +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +1 -0
- package/dist/search.d.mts +15 -0
- package/dist/search.mjs +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Hakim Saoudi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
The Software may include icons that are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). Commercial use is allowed, but attribution is required for the use of these icons. See LICENSE-THIRD-PARTY for more details.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
THIRD-PARTY LICENSES
|
|
2
|
+
|
|
3
|
+
This project includes icons that are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
|
|
4
|
+
|
|
5
|
+
Attribution Requirement:
|
|
6
|
+
You are allowed to use these icons for commercial and non-commercial purposes, but you must give appropriate credit as required by the CC BY 4.0 license.
|
|
7
|
+
|
|
8
|
+
For more details, please visit: https://creativecommons.org/licenses/by/4.0/
|
|
9
|
+
|
|
10
|
+
List of Third-Party Elements:
|
|
11
|
+
- **Solar Icons Set** By [480 Design](https://www.figma.com/community/file/1166831539721848736)
|
|
12
|
+
|
|
13
|
+
Attribution Instructions:
|
|
14
|
+
When using the icons, please attribute the original authors in a visible way according to the terms of the CC BY 4.0 license.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @solar-icons/cli
|
|
2
|
+
|
|
3
|
+
CLI for Solar Icons — 1,268 icons × 6 styles. Search, get and list icons locally (offline) via `@solar-icons/static`. Designed as the single source of truth for `skills` and the future MCP server.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add -D @solar-icons/cli
|
|
7
|
+
# or without install
|
|
8
|
+
npx @solar-icons/cli search "home" --limit 10 --json
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
solar-icons search <query> [--limit 20] [--style linear] [--category ui] [--framework react] [--json]
|
|
15
|
+
solar-icons get <name> [--style linear] [--framework react] [--out file.svg] [--json]
|
|
16
|
+
solar-icons list [--category ui] [--style linear] [--json] [--limit 50]
|
|
17
|
+
solar-icons info <name> [--json]
|
|
18
|
+
solar-icons categories [--json]
|
|
19
|
+
solar-icons styles [--json]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
All `--json` outputs are machine-readable (for agents / MCP).
|
|
23
|
+
|
|
24
|
+
Framework snippet examples: `react` → `import { HomeBoldIcon } from "@solar-icons/react/bold/home"`, `vue`, `svelte`, `solid`, `angular` (`SolarHomeBold`), `react-native`, `nuxt`, `static`, `js`.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/catalog.d.ts
|
|
2
|
+
type IconDescription = {
|
|
3
|
+
name: string;
|
|
4
|
+
category: string;
|
|
5
|
+
categoryTags: string[];
|
|
6
|
+
tags: string[];
|
|
7
|
+
};
|
|
8
|
+
declare const STYLES: readonly ['bold', 'bold-duotone', 'broken', 'linear', 'line-duotone', 'outline'];
|
|
9
|
+
type Style = (typeof STYLES)[number];
|
|
10
|
+
declare const FRAMEWORKS: readonly ['react', 'vue', 'svelte', 'solid', 'angular', 'react-native', 'nuxt', 'static', 'js'];
|
|
11
|
+
type Framework = (typeof FRAMEWORKS)[number];
|
|
12
|
+
declare function styleToPascal(style: Style): string;
|
|
13
|
+
declare function toPascalKebab(kebab: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generic per-file component name (style in path, no suffix).
|
|
16
|
+
* e.g. home + linear → HomeIcon
|
|
17
|
+
*/
|
|
18
|
+
declare function perFileComponentName(kebabName: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Root/top-level component name (style in name, path is package root).
|
|
21
|
+
* e.g. home + bold → HomeBoldIcon
|
|
22
|
+
*/
|
|
23
|
+
declare function rootComponentName(kebabName: string, style: Style, framework: Framework): string;
|
|
24
|
+
declare function componentName(kebabName: string, style: Style, framework: Framework): string;
|
|
25
|
+
/**
|
|
26
|
+
* Per-file import snippet (recommended, tree-shakable).
|
|
27
|
+
* Style is in the path, component name is generic (no style suffix).
|
|
28
|
+
* Verified against docs: apps/docs/content/docs/v2/packages/{react,vue,svelte,solid}.mdx
|
|
29
|
+
* react: import { HeartIcon } from '@solar-icons/react/bold/heart'
|
|
30
|
+
* vue: import { HeartIcon } from '@solar-icons/vue/bold/heart'
|
|
31
|
+
* svelte: import HeartIcon from '@solar-icons/svelte/bold/heart' (default)
|
|
32
|
+
* solid: import { HeartIcon } from '@solar-icons/solid/bold/heart'
|
|
33
|
+
* angular:import { SolarHeartBold } from '@solar-icons/angular' (style in name, root)
|
|
34
|
+
*/
|
|
35
|
+
declare function importSnippet(name: string, style: Style, framework: Framework): string;
|
|
36
|
+
declare function rootImportSnippet(name: string, style: Style, framework: Framework): string;
|
|
37
|
+
declare function loadDescriptions(): IconDescription[];
|
|
38
|
+
declare function listCategories(): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Totale counts for generation / --json usage.
|
|
41
|
+
*/
|
|
42
|
+
declare function catalogStats(): {
|
|
43
|
+
icons: number;
|
|
44
|
+
categories: number;
|
|
45
|
+
styles: number;
|
|
46
|
+
variations: number;
|
|
47
|
+
};
|
|
48
|
+
declare function resolveSvgPath(name: string, style: Style): string | null;
|
|
49
|
+
declare function cdnSvgUrl(name: string, style: Style, version?: string): string;
|
|
50
|
+
declare const FIGMA_URL = "https://www.figma.com/community/plugin/1664759238792120976/solar-icons";
|
|
51
|
+
declare const DOCS_URL = "https://solar-icons.vercel.app/";
|
|
52
|
+
declare const ICONS_URL = "https://solar-icons.vercel.app/icons";
|
|
53
|
+
type PackageInfo = {
|
|
54
|
+
name: string;
|
|
55
|
+
version: string;
|
|
56
|
+
description: string;
|
|
57
|
+
directory: string;
|
|
58
|
+
};
|
|
59
|
+
type Overview = {
|
|
60
|
+
catalog: {
|
|
61
|
+
icons: number;
|
|
62
|
+
categories: number;
|
|
63
|
+
styles: number;
|
|
64
|
+
variations: number;
|
|
65
|
+
};
|
|
66
|
+
packages: PackageInfo[];
|
|
67
|
+
cliVersion: string;
|
|
68
|
+
figma: string;
|
|
69
|
+
docs: string;
|
|
70
|
+
iconsExplorer: string;
|
|
71
|
+
};
|
|
72
|
+
declare function getOverview(): Overview;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { DOCS_URL, FIGMA_URL, FRAMEWORKS, Framework, ICONS_URL, IconDescription, Overview, PackageInfo, STYLES, Style, catalogStats, cdnSvgUrl, componentName, getOverview, importSnippet, listCategories, loadDescriptions, perFileComponentName, resolveSvgPath, rootComponentName, rootImportSnippet, styleToPascal, toPascalKebab };
|
package/dist/catalog.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{existsSync as t,readFileSync as n,readdirSync as r}from"node:fs";import{dirname as i,join as a,resolve as o}from"node:path";import{fileURLToPath as s}from"node:url";const c=[`bold`,`bold-duotone`,`broken`,`linear`,`line-duotone`,`outline`],l=[`react`,`vue`,`svelte`,`solid`,`angular`,`react-native`,`nuxt`,`static`,`js`],u={bold:`Bold`,"bold-duotone":`BoldDuotone`,broken:`Broken`,linear:`Linear`,"line-duotone":`LineDuotone`,outline:`Outline`};function d(e){return u[e]}function f(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function p(e){return`${f(e)}Icon`}function m(e,t,n){let r=f(e),i=d(t);return n===`angular`?`Solar${r}${i}`:`${r}${i}Icon`}function h(e,t,n){return m(e,t,n)}function g(e,t,n){let r=e,i=p(e),a=m(e,t,n);switch(n){case`react`:return`import { ${i} } from "@solar-icons/react/${t}/${r}";`;case`vue`:return`import { ${i} } from "@solar-icons/vue/${t}/${r}";`;case`svelte`:return`import ${i} from "@solar-icons/svelte/${t}/${r}";`;case`solid`:return`import { ${i} } from "@solar-icons/solid/${t}/${r}";`;case`angular`:return`import { ${a} } from "@solar-icons/angular"; // usage: <svg ${a.charAt(0).toLowerCase()+a.slice(1)}></svg> (directive)`;case`react-native`:return`import { ${i} } from "@solar-icons/react-native/${t}/${r}";`;case`nuxt`:return`// nuxt.config: modules: ["@solar-icons/nuxt"] → auto-import <${a} />`;case`static`:return`import url from "@solar-icons/static/${t}/${r}.svg"; // <img src={url} alt="${r}" />`;case`js`:return`import { createIcons, icons } from "@solar-icons/js"; // icons["${r}-${t}"]`;default:return`import { ${i} } from "@solar-icons/${n}/${t}/${r}";`}}function _(e,t,n){let r=m(e,t,n);switch(n){case`svelte`:return`import { ${r} } from "@solar-icons/svelte";`;case`angular`:return`import { ${r} } from "@solar-icons/angular";`;case`static`:case`js`:case`nuxt`:return g(e,t,n);default:return`import { ${r} } from "@solar-icons/${n}";`}}function v(e){if(!t(e))return null;try{return JSON.parse(n(e,`utf8`))}catch{return null}}let y=null,b=null;function x(){if(y)return y;let t=[];try{let n=e(import.meta.url).resolve(`@solar-icons/static/package.json`),r=i(n);t.push(a(r,`dist`,`metadata-descriptions.json`)),t.push(a(r,`metadata-descriptions.json`))}catch{}try{let e=i(s(import.meta.url));t.push(o(e,`../../static/dist/metadata-descriptions.json`)),t.push(o(e,`../../../packages/static/dist/metadata-descriptions.json`)),t.push(o(e,`../../core/src/metadata-descriptions.json`)),t.push(o(e,`../../../packages/core/src/metadata-descriptions.json`))}catch{}for(let e of t){let t=v(e);if(Array.isArray(t)&&t.length>0)return y=t,y}throw Error(`Could not locate Solar Icons metadata. Ensure @solar-icons/static is installed or run inside the solar-icons monorepo. Tried:
|
|
2
|
+
`+t.join(`
|
|
3
|
+
`))}function S(){if(b)return b;let e=x(),t=new Set;for(let n of e)t.add(n.category);return b=[...t].sort(),b}function C(){let e=x(),t=new Set(e.map(e=>e.category));return{icons:e.length,categories:t.size,styles:c.length,variations:e.length*c.length}}function w(n,r){let c=[];try{let t=e(import.meta.url).resolve(`@solar-icons/static/package.json`),o=i(t);c.push(a(o,`dist`,`icons`,r,`${n}.svg`))}catch{}try{let e=i(s(import.meta.url));c.push(o(e,`../../static/dist/icons`,r,`${n}.svg`)),c.push(o(e,`../../../packages/static/dist/icons`,r,`${n}.svg`))}catch{}for(let e of c)if(t(e))return e;return null}function T(e,t,n=`latest`){return`https://cdn.jsdelivr.net/npm/@solar-icons/static@${n}/dist/icons/${t}/${e}.svg`}const E=`https://www.figma.com/community/plugin/1664759238792120976/solar-icons`,D=`https://solar-icons.vercel.app/`,O=`https://solar-icons.vercel.app/icons`;function k(){let t=[];try{let n=e(import.meta.url).resolve(`@solar-icons/cli/package.json`),r=v(n);if(r?.version)return r.version;t.push(n)}catch{}try{let e=i(s(import.meta.url));t.push(o(e,`../../package.json`)),t.push(o(e,`../../../packages/cli/package.json`)),t.push(o(e,`../package.json`))}catch{}for(let e of t){let t=v(e);if(t?.version)return t.version}return`unknown`}function A(){let e=[];try{let t=i(s(import.meta.url));e.push(o(t,`../../..`,`packages`)),e.push(o(t,`../../../packages`)),e.push(o(t,`../../packages`)),e.push(o(t,`..`,`..`,`packages`)),e.push(o(t,`../packages`))}catch{}try{e.push(o(process.cwd(),`packages`))}catch{}for(let n of e)if(t(n))try{let e=r(n,{withFileTypes:!0}),i=[];for(let r of e){if(!r.isDirectory())continue;let e=a(n,r.name,`package.json`);if(!t(e))continue;let o=v(e);o?.name?.startsWith(`@solar-icons/`)&&(o.private||i.push({name:o.name,version:o.version??`unknown`,description:o.description??``,directory:`packages/${r.name}`}))}if(i.length>0)return i.sort((e,t)=>e.name.localeCompare(t.name)),i}catch{}return[]}function j(){return{catalog:C(),packages:A(),cliVersion:k(),figma:E,docs:D,iconsExplorer:O}}export{D as DOCS_URL,E as FIGMA_URL,l as FRAMEWORKS,O as ICONS_URL,c as STYLES,C as catalogStats,T as cdnSvgUrl,h as componentName,j as getOverview,g as importSnippet,S as listCategories,x as loadDescriptions,p as perFileComponentName,w as resolveSvgPath,m as rootComponentName,_ as rootImportSnippet,d as styleToPascal,f as toPascalKebab};
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{STYLES as e,getOverview as t,listCategories as n}from"./catalog.mjs";import{runSearch as r}from"./commands/search.mjs";import{runGet as i}from"./commands/get.mjs";import{runList as a}from"./commands/list.mjs";import{runInfo as o}from"./commands/info.mjs";import{realpathSync as s}from"node:fs";import{pathToFileURL as c}from"node:url";import l from"picocolors";import{Command as u}from"commander";const d=new u().name(`solar-icons`).description(`Solar Icons CLI — search, get and list 1,268 icons × 6 styles.`).version(`2.1.0`,`-v, --version`).showHelpAfterError().showSuggestionAfterError().configureHelp({sortSubcommands:!0,styleTitle:e=>l.bold(l.cyan(e)),styleCommandText:e=>l.cyan(e),styleCommandDescription:e=>l.dim(e),styleOptionText:e=>l.green(e),styleArgumentText:e=>l.yellow(e),styleDescriptionText:e=>l.dim(e),styleOptionTerm:e=>l.green(e)});d.addHelpText(`after`,`\n${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons`)} ${l.green(`search`)} ${l.yellow(`"home"`)} ${l.dim(`--limit 10 --framework react`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons`)} ${l.green(`get`)} ${l.yellow(`arrow-up`)} ${l.dim(`--style linear --framework vue`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons`)} ${l.green(`overview`)} ${l.dim(`--json`)} ${l.dim(`# for agents / CI`)}\n`),d.command(`search`).argument(`<query>`,`search query, e.g. "home" or "shopping cart"`).option(`-l, --limit <n>`,`max results (1..200, default 20)`,`20`).option(`--style <style>`,`restrict import hint to one style: ${e.join(`|`)}`).option(`--category <category>`,`restrict to category (see: solar-icons categories)`).option(`--framework <framework>`,`emit import snippet for framework (react|vue|svelte|solid|angular|react-native|nuxt|static|js)`).option(`--json`,`machine-readable JSON output (for agents/MCP)`).description(`Search icons by name/tags/category`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons search`)} ${l.yellow(`"shopping cart"`)} ${l.dim(`--framework react`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons search`)} ${l.yellow(`arrow`)} ${l.dim(`--category arrows --json`)}\n `).action((e,t)=>{try{r(e,t)}catch(e){console.error(l.red(`error: ${e.message}`)),process.exit(2)}}),d.command(`get`).argument(`<name>`,`kebab icon name, e.g. home`).option(`--style <style>`,`style`,`linear`).option(`--framework <framework>`,`framework for snippet`,`react`).option(`--out <file>`,`copy SVG to file`).option(`--json`,`JSON output`).description(`Get import snippet and SVG for an icon`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons get`)} ${l.yellow(`home`)} ${l.dim(`--style bold --framework svelte`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons get`)} ${l.yellow(`arrow-up`)} ${l.dim(`--out ./arrow.svg`)}\n `).action((e,t)=>{try{i(e,t)}catch(e){console.error(l.red(`error: ${e.message}`)),process.exit(2)}}),d.command(`list`).option(`--category <category>`,`filter by category`).option(`--style <style>`,`hint style: ${e.join(`|`)}`).option(`-l, --limit <n>`,`max results (1..2000, default 50)`,`50`).option(`--json`,`JSON output`).description(`List icons`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons list`)} ${l.dim(`--category home --limit 20`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons list`)} ${l.dim(`--json | jq .[].name`)}\n `).action(e=>{try{a(e)}catch(e){console.error(l.red(`error: ${e.message}`)),process.exit(2)}}),d.command(`info`).argument(`<name>`,`icon name`).option(`--json`,`JSON output`).description(`Show metadata and all import paths for an icon`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons info`)} ${l.yellow(`arrow-up`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons info`)} ${l.yellow(`heart`)} ${l.dim(`--json`)}\n `).action((e,t)=>{try{o(e,t)}catch(e){console.error(l.red(`error: ${e.message}`)),process.exit(2)}}),d.command(`categories`).option(`--json`,`JSON output`).description(`List all categories`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons categories`)} ${l.dim(`--json`)}\n `).action(e=>{let t=n();if(e.json)console.log(JSON.stringify(t,null,2));else for(let e of t)console.log(e)}),d.command(`styles`).option(`--json`,`JSON output`).description(`List all styles and provider tokens`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons styles`)}\n `).action(t=>{if(t.json)console.log(JSON.stringify(e,null,2));else{for(let t of e)console.log(t);console.log(l.dim(`
|
|
3
|
+
Provider tokens: --solar-color, --solar-size, --solar-stroke-width, --solar-secondary-color, --solar-secondary-opacity`))}}),d.command(`overview`).option(`--json`,`JSON output`).description(`Show global overview — catalog, packages, Figma plugin and docs`).addHelpText(`after`,` ${l.bold(`Examples:`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons overview`)}\n ${l.dim(`$`)} ${l.cyan(`solar-icons overview`)} ${l.dim(`--json`)}\n `).action(e=>{let n=t();if(e.json){console.log(JSON.stringify(n,null,2));return}if(console.log(`${l.bgCyan(l.black(` Solar Icons `))} ${l.dim(`v${n.cliVersion}`)}`),console.log(``),console.log(`${l.bold(l.cyan(String(n.catalog.icons)))} ${l.dim(`icons`)} ${l.dim(`×`)} ${l.bold(String(n.catalog.styles))} ${l.dim(`styles`)} ${l.dim(`=`)} ${l.bold(l.cyan(String(n.catalog.variations)))} ${l.dim(`variations`)} ${l.dim(`—`)} ${l.bold(String(n.catalog.categories))} ${l.dim(`categories`)}`),console.log(l.dim(`─`.repeat(56))),n.packages.length>0){console.log(l.bold(`\nPackages (${n.packages.length})`));let e=Math.max(...n.packages.map(e=>e.name.length));for(let t of n.packages){let n=l.cyan(t.name.padEnd(e)),r=l.dim(`v${t.version}`.padEnd(8)),i=l.dim(t.description.length>58?`${t.description.slice(0,55)}…`:t.description);console.log(` ${l.dim(`›`)} ${n} ${r} ${i}`)}}else console.log(l.dim(`
|
|
4
|
+
Packages: (run inside monorepo to list versions)`));console.log(``),console.log(`${l.bold(`Figma`)} ${l.underline(l.cyan(n.figma))}`),console.log(`${l.bold(`Docs `)} ${l.underline(l.cyan(n.docs))}`),console.log(`${l.bold(`Icons`)} ${l.underline(l.cyan(n.iconsExplorer))}`)});async function f(){await d.parseAsync(process.argv)}const p=process.argv[1]?s(process.argv[1]):void 0;p&&import.meta.url===c(p).href&&f();export{};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/commands/get.d.ts
|
|
2
|
+
type GetCliOptions = {
|
|
3
|
+
style?: string;
|
|
4
|
+
framework?: string;
|
|
5
|
+
out?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function runGet(name: string | undefined, opts: GetCliOptions): void;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GetCliOptions, runGet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FRAMEWORKS as e,STYLES as t,cdnSvgUrl as n,importSnippet as r,loadDescriptions as i,resolveSvgPath as a}from"../catalog.mjs";import{copyFileSync as o,existsSync as s,mkdirSync as c,readFileSync as l}from"node:fs";import{dirname as u}from"node:path";import d from"picocolors";function f(e){let n=e??`linear`;if(t.includes(n))return n;throw Error(`--style must be one of: ${t.join(`, `)}. Received: '${e}'`)}function p(t){let n=t??`react`;if(e.includes(n))return n;throw Error(`--framework must be one of: ${e.join(`, `)}. Received: '${t}'`)}function m(e,t){e||(console.error(d.red(`error: get requires <name>. Example: solar-icons get home --style bold`)),process.exit(2));let m=f(t.style),h=p(t.framework),g=i().find(t=>t.name===e);g||(console.error(d.red(`error: icon '${e}' not found.`)),console.error(d.dim(`Try: solar-icons search "${e}" --limit 10`)),process.exit(2));let _=a(e,m),v=n(e,m),y=r(e,m,h);if(t.json){let t={name:e,style:m,framework:h,category:g.category,tags:g.tags,import:y,cdn:v,svgPath:_??null};if(_&&s(_))try{t.svg=l(_,`utf8`)}catch{}console.log(JSON.stringify(t,null,2));return}if(t.out){let e=t.out;_&&s(_)?(c(u(e),{recursive:!0}),o(_,e),console.log(d.green(e))):(console.error(d.yellow(`Local SVG not found (expected ${_??`unknown`}). CDN fallback: ${v}. Use --json to get CDN URL.`)),process.exit(2)),console.log(d.dim(y));return}if(console.log(d.green(y)),console.log(`${d.bold(`Category`)} ${d.cyan(g.category)}`),console.log(`${d.bold(`CDN`)} ${d.underline(d.cyan(v))}`),_&&s(_)){let e=l(_,`utf8`);console.log(`\n${d.dim(`Preview`)} ${d.dim(`(${e.length} bytes)`)}`),console.log(d.dim(e.slice(0,400)+(e.length>400?d.dim(` …`):``)))}}export{m as runGet};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FRAMEWORKS as e,STYLES as t,cdnSvgUrl as n,importSnippet as r,loadDescriptions as i,resolveSvgPath as a,rootImportSnippet as o}from"../catalog.mjs";import s from"picocolors";function c(c,l){c||(console.error(s.red(`error: info requires <name>. Example: solar-icons info home`)),process.exit(2));let u=i().find(e=>e.name===c);u||(console.error(s.red(`error: icon '${c}' not found.`)),process.exit(2));let d=[...t],f=[...e];if(l.json){let e={name:u.name,category:u.category,categoryTags:u.categoryTags,tags:u.tags,styles:d,imports:Object.fromEntries(f.map(e=>[e,r(u.name,`linear`,e)])),rootImports:Object.fromEntries(d.map(e=>[e,o(u.name,e,`react`)])),styleImports:Object.fromEntries(d.map(e=>[e,o(u.name,e,`react`)])),svg:Object.fromEntries(d.map(e=>[e,a(u.name,e)??n(u.name,e)]))};console.log(JSON.stringify(e,null,2));return}console.log(`${s.bgCyan(s.black(` ${u.name} `))} ${s.dim(u.category)}`),console.log(`${s.bold(`Tags`)} ${u.tags.join(`, `)}`),console.log(`${s.bold(`CategoryTags`)} ${s.dim(u.categoryTags.join(`, `))}`),console.log(`\n${s.bold(`Available styles`)} ${d.map(e=>s.cyan(e)).join(s.dim(` · `))}`),console.log(`\n${s.bold(s.underline(`Imports — linear example (per-file, tree-shakable)`))}`);for(let e of f){let t=s.dim(e.padEnd(14));console.log(` ${t} ${s.green(r(u.name,`linear`,e))}`)}console.log(`\n${s.bold(s.underline(`All styles — per-file (generic name)`))} ${s.dim(`import { ArrowUpIcon } from "@solar-icons/react/<style>/arrow-up"`)}`);for(let e of d)console.log(` ${s.dim(e.padEnd(14))} ${s.green(r(u.name,e,`react`))}`);console.log(`\n${s.bold(s.underline(`All styles — root (style in name)`))} ${s.dim(`import { ArrowUpBoldIcon } from "@solar-icons/react"`)}`);for(let e of d)console.log(` ${s.dim(e.padEnd(14))} ${s.green(o(u.name,e,`react`))}`)}export{c as runInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{STYLES as e,loadDescriptions as t}from"../catalog.mjs";import n from"picocolors";function r(r){let i=r.category,a=r.style;a&&!e.includes(a)&&(console.error(n.red(`error: --style must be one of: ${e.join(`, `)}. Received: '${a}'`)),process.exit(2));let o=r.limit?Number(r.limit):50;r.limit&&(!Number.isInteger(o)||o<=0||o>2e3)&&(console.error(n.red(`error: --limit must be 1..2000. Received: '${r.limit}'`)),process.exit(2));let s=t(),c=i?s.filter(e=>e.category===i):s;i&&c.length===0&&(console.error(n.yellow(`No icons in category '${i}'. Try: solar-icons categories`)),process.exit(2));let l=c.slice(0,o);if(r.json){console.log(JSON.stringify(l.map(e=>({name:e.name,category:e.category,tags:e.tags,...a?{style:a,import:`@solar-icons/{react,…}/${a}/${e.name}`}:{}})),null,2));return}let u=Math.max(...l.map(e=>e.name.length),12);for(let e of l){let t=n.cyan(n.bold(e.name.padEnd(u))),r=n.dim(e.category.padEnd(16));console.log(a?` ${t} ${r} ${n.dim(`${a}/${e.name}`)}`:` ${t} ${r}`)}c.length>l.length?console.log(n.dim(`\n … ${c.length-l.length} more — use --limit ${c.length} or --json`)):console.log(n.dim(`\n ${l.length} shown`))}export{r as runList};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/commands/search.d.ts
|
|
2
|
+
type SearchCliOptions = {
|
|
3
|
+
limit?: string;
|
|
4
|
+
style?: string;
|
|
5
|
+
category?: string;
|
|
6
|
+
framework?: string;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare function runSearch(query: string | undefined, opts: SearchCliOptions): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SearchCliOptions, runSearch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FRAMEWORKS as e,STYLES as t,importSnippet as n,loadDescriptions as r}from"../catalog.mjs";import{searchCatalog as i}from"../search.mjs";import a from"picocolors";function o(e){if(!e)return 20;let t=Number(e);if(!Number.isInteger(t)||t<=0||t>200)throw Error(`--limit must be 1..200. Received: '${e}'`);return t}function s(e){if(e){if(t.includes(e))return e;throw Error(`--style must be one of: ${t.join(`, `)}. Received: '${e}'`)}}function c(t){if(t){if(e.includes(t))return t;throw Error(`--framework must be one of: ${e.join(`, `)}. Received: '${t}'`)}}function l(e,t){e||(console.error(a.red(`error: search query is required. Example: solar-icons search "home"`)),process.exit(2));let l=o(t.limit),u=s(t.style),d=c(t.framework),f=r(),p=i(f,{query:e,limit:l,style:u,category:t.category});if(t.json){let e=p.map(e=>({name:e.name,category:e.category,tags:e.tags,categoryTags:e.categoryTags,score:e.score,...d?{import:n(e.name,u??`linear`,d)}:{},...u?{styleHint:u}:{}}));console.log(JSON.stringify(e,null,2));return}p.length===0&&(console.error(a.yellow(`No match for "${e}". Try broader terms or: solar-icons categories`)),process.exit(2));let m=Math.max(...p.map(e=>e.name.length),12);for(let e of p){let t=` ${a.cyan(a.bold(e.name.padEnd(m)))} ${a.dim(e.category.padEnd(16))} ${a.dim(e.tags.slice(0,4).join(`, `))}`;if(d){let r=n(e.name,u??`linear`,d);console.log(`${t}\n ${a.dim(`→`)} ${a.green(r)}`)}else console.log(t)}console.log(a.dim(`\n ${p.length} result${p.length>1?`s`:``} — try --framework react or --json`))}export{l as runSearch};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DOCS_URL, FIGMA_URL, FRAMEWORKS, Framework, ICONS_URL, IconDescription, Overview, PackageInfo, STYLES, Style, catalogStats, cdnSvgUrl, componentName, getOverview, importSnippet, listCategories, loadDescriptions, perFileComponentName, resolveSvgPath, rootComponentName, rootImportSnippet, styleToPascal, toPascalKebab } from "./catalog.mjs";
|
|
2
|
+
import { SearchOptions, SearchResult, searchCatalog } from "./search.mjs";
|
|
3
|
+
import { runSearch } from "./commands/search.mjs";
|
|
4
|
+
import { runGet } from "./commands/get.mjs";
|
|
5
|
+
import { runList } from "./commands/list.mjs";
|
|
6
|
+
import { runInfo } from "./commands/info.mjs";
|
|
7
|
+
export { DOCS_URL, FIGMA_URL, FRAMEWORKS, Framework, ICONS_URL, IconDescription, Overview, PackageInfo, STYLES, SearchOptions, SearchResult, Style, catalogStats, cdnSvgUrl, componentName, getOverview, importSnippet, listCategories, loadDescriptions, perFileComponentName, resolveSvgPath, rootComponentName, rootImportSnippet, runGet, runInfo, runList, runSearch, searchCatalog, styleToPascal, toPascalKebab };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DOCS_URL as e,FIGMA_URL as t,FRAMEWORKS as n,ICONS_URL as r,STYLES as i,catalogStats as a,cdnSvgUrl as o,componentName as s,getOverview as c,importSnippet as l,listCategories as u,loadDescriptions as d,perFileComponentName as f,resolveSvgPath as p,rootComponentName as m,rootImportSnippet as h,styleToPascal as g,toPascalKebab as _}from"./catalog.mjs";import{searchCatalog as v}from"./search.mjs";import{runSearch as y}from"./commands/search.mjs";import{runGet as b}from"./commands/get.mjs";import{runList as x}from"./commands/list.mjs";import{runInfo as S}from"./commands/info.mjs";export{e as DOCS_URL,t as FIGMA_URL,n as FRAMEWORKS,r as ICONS_URL,i as STYLES,a as catalogStats,o as cdnSvgUrl,s as componentName,c as getOverview,l as importSnippet,u as listCategories,d as loadDescriptions,f as perFileComponentName,p as resolveSvgPath,m as rootComponentName,h as rootImportSnippet,b as runGet,S as runInfo,x as runList,y as runSearch,v as searchCatalog,g as styleToPascal,_ as toPascalKebab};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconDescription, Style } from "./catalog.mjs";
|
|
2
|
+
//#region src/search.d.ts
|
|
3
|
+
type SearchOptions = {
|
|
4
|
+
query: string;
|
|
5
|
+
limit?: number;
|
|
6
|
+
style?: Style;
|
|
7
|
+
category?: string;
|
|
8
|
+
};
|
|
9
|
+
type SearchResult = IconDescription & {
|
|
10
|
+
score: number;
|
|
11
|
+
styleHint: Style;
|
|
12
|
+
};
|
|
13
|
+
declare function searchCatalog(descriptions: IconDescription[], opts: SearchOptions): SearchResult[];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SearchOptions, SearchResult, searchCatalog };
|
package/dist/search.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e.toLowerCase()}function t(t,n){let r=n.query.trim().toLowerCase();if(!r)return[];let i=n.limit??20,a=n.style??`linear`,o=r.split(/\s+/).filter(Boolean),s=n.category?t.filter(t=>e(t.category)===e(n.category)):t,c=[];for(let t of s){let i=e(t.name),s=(t.tags??[]).map(e).join(` `),l=(t.categoryTags??[]).map(e).join(` `),u=0;if(i===r)u=100;else if(i.includes(r))u=50;else if(o.every(e=>i.includes(e)))u=40;else if(s.includes(r))u=30;else if(l.includes(r))u=18;else if(o.every(e=>(s+` `+l).includes(e)))u=15;else if(o.some(e=>i.includes(e)||s.includes(e)||l.includes(e)))u=8;else continue;n.category&&(u+=2),c.push({...t,score:u,styleHint:a})}return c.sort((e,t)=>t.score-e.score||e.name.localeCompare(t.name)),c.slice(0,i)}export{t as searchCatalog};
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@solar-icons/cli",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "CLI for Solar Icons — search, get and list 1,268 icons × 6 styles. Base for skills and MCP.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"cli",
|
|
8
|
+
"icons",
|
|
9
|
+
"search",
|
|
10
|
+
"solar",
|
|
11
|
+
"svg"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Saoudi Hakim",
|
|
16
|
+
"email": "saoudihakim@gmail.com",
|
|
17
|
+
"url": "https://hakimsaoudi.dev"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/saoudi-h/solar-icons.git",
|
|
22
|
+
"directory": "packages/cli"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"solar-icons": "./dist/cli.mjs"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"LICENSE-THIRD-PARTY"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.mts",
|
|
38
|
+
"import": "./dist/index.mjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"commander": "^15.0.0",
|
|
46
|
+
"picocolors": "^1.1.1",
|
|
47
|
+
"@solar-icons/static": "2.1.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@tala-tools/tsconfig": "0.0.2",
|
|
51
|
+
"@types/node": "^26.1.2",
|
|
52
|
+
"rimraf": "^6.1.3",
|
|
53
|
+
"tsdown": "^0.22.14",
|
|
54
|
+
"tsx": "^4.23.8",
|
|
55
|
+
"typescript": "7.0.2",
|
|
56
|
+
"vitest": "^4.1.10"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "pnpm copy:licenses && tsdown -l error",
|
|
63
|
+
"copy:licenses": "cp ../../LICENSE ./LICENSE && cp ../../LICENSE-THIRD-PARTY ./LICENSE-THIRD-PARTY",
|
|
64
|
+
"lint": "oxlint --deny-warnings .",
|
|
65
|
+
"lint:fix": "oxlint --fix .",
|
|
66
|
+
"format": "oxfmt --check .",
|
|
67
|
+
"format:fix": "oxfmt --write .",
|
|
68
|
+
"clean": "rimraf dist LICENSE LICENSE-THIRD-PARTY",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
|
+
"pre-commit": "lint-staged"
|
|
72
|
+
}
|
|
73
|
+
}
|