@alea-design/cli 0.10.6 → 0.10.8
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 +2 -0
- package/bin/alea.mjs +32 -1
- package/package.json +2 -2
- package/registry.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ Replace `init` with `add button select`, `list` or any other command. `init` and
|
|
|
22
22
|
|
|
23
23
|
`init` installs the peers the components need, pinned to the ranges `@alea-design/ui` depends on (`react-aria-components`, `lucide-react@^0.525.0`, `@alea-design/motion`); with `--no-install` it prints the command instead. The copied components type-check with React 18 and React 19 types.
|
|
24
24
|
|
|
25
|
+
`alea search <words>` finds components by name (`alea search date pick` finds DatePicker). `alea view <component>` shows what `alea add` would copy, the files and the npm packages, without writing anything; add `--code` to print the source.
|
|
26
|
+
|
|
25
27
|
`alea audit` runs the quality audit of [`@alea-design/audit`](https://www.npmjs.com/package/@alea-design/audit) (`alea audit init`, `alea audit list`, `alea audit --shard 1/3`). The CLI does not depend on it or on Playwright: it finds the package in your project and tells you what to install when it is missing.
|
|
26
28
|
|
|
27
29
|
Docs: https://alea.alevasquez.dev/installation?utm_source=npm&utm_medium=readme&utm_campaign=alea-cli · MIT license
|
package/bin/alea.mjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// alea init [--dir src/components/ui] [--no-install]
|
|
4
4
|
// alea add <component...> | --all [--group] [--overwrite] [--update] [--no-install]
|
|
5
5
|
// alea list
|
|
6
|
+
// alea search <words...> find components by name
|
|
7
|
+
// alea view <component> [--code] what `alea add` would copy: files, npm packages, and with --code the source
|
|
6
8
|
// alea --version
|
|
7
9
|
// `alea add Button` copies Button.tsx and the files it really imports (not every file of its folders), plus the styles of
|
|
8
10
|
// those folders. A folder name copies the whole folder: alea add button --group.
|
|
@@ -143,7 +145,7 @@ const [cmd, ...rest] = argv.filter((a, i) => !a.startsWith('--') && !VALUE_FLAGS
|
|
|
143
145
|
if (flag('version') || argv.includes('-v') || cmd === 'version') {
|
|
144
146
|
say(JSON.parse(fs.readFileSync(path.resolve(here, '../package.json'), 'utf8')).version);
|
|
145
147
|
} else if (!cmd || cmd === 'help' || flag('help')) {
|
|
146
|
-
say(`Alea ${registry.version}\n\n alea init [--dir src/components/ui] [--no-install] set up alea.json, tokens and base styles\n alea add <component...> [--all] [--group] [--overwrite] [--update]\n copy a component and the files it uses; --group copies a whole folder;\n --update puts new versions next to yours\n alea add pro/media a Pro folder that shares its name with a free one (media-pro, work-pro)\n alea list what you can add (Pro needs ALEA_LICENSE_KEY)\n alea audit [init|list] [options] the quality audit (needs @alea-design/audit; alea audit --help)\n alea --version the CLI version\n`);
|
|
148
|
+
say(`Alea ${registry.version}\n\n alea init [--dir src/components/ui] [--no-install] set up alea.json, tokens and base styles\n alea add <component...> [--all] [--group] [--overwrite] [--update]\n copy a component and the files it uses; --group copies a whole folder;\n --update puts new versions next to yours\n alea add pro/media a Pro folder that shares its name with a free one (media-pro, work-pro)\n alea list what you can add (Pro needs ALEA_LICENSE_KEY)\n alea search <words...> find components by name\n alea view <component> [--code] the files and npm packages alea add would bring; --code prints the source\n alea audit [init|list] [options] the quality audit (needs @alea-design/audit; alea audit --help)\n alea --version the CLI version\n`);
|
|
147
149
|
} else if (cmd === 'init') {
|
|
148
150
|
const dir = opt('dir', 'src/components/ui');
|
|
149
151
|
const conf = { $schema: 'https://alea.alevasquez.dev/alea.schema.json', dir, version: registry.version };
|
|
@@ -197,6 +199,35 @@ if (flag('version') || argv.includes('-v') || cmd === 'version') {
|
|
|
197
199
|
if (!bin) die('alea audit needs @alea-design/audit, which is not installed here.\nInstall it with the browser tools it drives: npm i -D @alea-design/audit playwright-core axe-core\nor try it once without installing: npx @alea-design/audit init');
|
|
198
200
|
const result = spawnSync(process.execPath, [bin, ...argv.slice(argv.indexOf('audit') + 1)], { cwd, stdio: 'inherit' });
|
|
199
201
|
process.exit(result.status ?? 1);
|
|
202
|
+
} else if (cmd === 'search') {
|
|
203
|
+
// free text against component names (case and dashes ignored); every word must match, so "date pick" finds DatePicker
|
|
204
|
+
const words = rest.map(norm).filter(Boolean);
|
|
205
|
+
if (!words.length) die('say what to look for, e.g. alea search date');
|
|
206
|
+
const hits = [];
|
|
207
|
+
for (const [g, def] of Object.entries(registry.groups)) for (const e of def.exports.filter(listed)) if (words.every(w => norm(e).includes(w) || norm(g).includes(w))) hits.push(`${e.padEnd(24)} ${g}`);
|
|
208
|
+
for (const [g, exports] of Object.entries(registry.pro || {})) for (const e of exports.filter(listed)) if (words.every(w => norm(e).includes(w) || norm(g).includes(w))) hits.push(`${e.padEnd(24)} ${g} (Pro)`);
|
|
209
|
+
if (!hits.length) die(`nothing matches "${rest.join(' ')}". See: alea list`);
|
|
210
|
+
say(hits.sort().join('\n'));
|
|
211
|
+
} else if (cmd === 'view') {
|
|
212
|
+
// what `alea add <name>` would write, without writing it: the files it reaches through imports, their npm packages, and the source on request
|
|
213
|
+
if (!rest[0]) die('say which component, e.g. alea view button');
|
|
214
|
+
const hit = resolve(rest[0]) || die(`no component called "${rest[0]}". See: alea list`);
|
|
215
|
+
if (hit.pro) {
|
|
216
|
+
say(`${hit.name || hit.group} is part of Alea Pro: its source comes with a license (ALEA_LICENSE_KEY=<your key> alea add ${rest[0]}).`);
|
|
217
|
+
} else {
|
|
218
|
+
const groups = registry.groups, byPath = new Map();
|
|
219
|
+
for (const [g, def] of Object.entries(groups)) for (const f of def.files) byPath.set(f.path, { f, g });
|
|
220
|
+
const roots = groups[hit.group].files.filter(f => !f.extra && (!hit.name || (f.exports || []).includes(hit.name))).map(f => f.path);
|
|
221
|
+
const closure = new Set();
|
|
222
|
+
const visit = pth => { if (closure.has(pth)) return; closure.add(pth); for (const i of byPath.get(pth)?.f.imports || []) visit(i); };
|
|
223
|
+
roots.forEach(visit);
|
|
224
|
+
for (const g of new Set([...closure].map(pth => byPath.get(pth).g))) for (const f of groups[g].files) if (f.extra) closure.add(f.path);
|
|
225
|
+
const npm = [...new Set([...closure].flatMap(pth => byPath.get(pth).f.npm || []))].sort();
|
|
226
|
+
say(`${hit.name || hit.group} (${groups[hit.group].exports.filter(listed).join(', ')})`);
|
|
227
|
+
say(`files (${closure.size}):\n${[...closure].sort().map(pth => ` ${pth}`).join('\n')}`);
|
|
228
|
+
say(`npm: ${['react-aria-components', 'lucide-react', '@alea-design/motion', ...npm].join(', ')}`);
|
|
229
|
+
if (flag('code')) for (const pth of [...closure].sort()) say(`\n// ===== ${pth} =====\n${byPath.get(pth).f.content}`);
|
|
230
|
+
}
|
|
200
231
|
} else if (cmd === 'list') {
|
|
201
232
|
for (const [g, def] of Object.entries(registry.groups)) say(`${g.padEnd(12)} ${def.exports.filter(listed).join(', ')}`);
|
|
202
233
|
for (const [g, exports] of Object.entries(registry.pro || {})) say(`${(g + ' (Pro)').padEnd(12)} ${exports.filter(listed).join(', ')}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8",
|
|
4
4
|
"description": "Copy Alea components into your project: alea init, add, list.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "node scripts/build-registry.mjs && node --test test/*.test.mjs"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@alea-design/motion": "^0.10.
|
|
42
|
+
"@alea-design/motion": "^0.10.8",
|
|
43
43
|
"@types/react-18": "npm:@types/react@^18.3.31",
|
|
44
44
|
"@types/react-dom-18": "npm:@types/react-dom@^18.3.7",
|
|
45
45
|
"lucide-react": "^0.525.0",
|