inai-react-components 0.1.5 → 0.1.6
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/dist/commands/add.d.ts +3 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +74 -1
- package/dist/index.js +3 -2
- package/package.json +1 -2
package/dist/commands/add.d.ts
CHANGED
|
@@ -30,5 +30,7 @@ export declare function getTargetDir(component: RegistryComponent, aliases: {
|
|
|
30
30
|
blocks: string;
|
|
31
31
|
}): string;
|
|
32
32
|
export declare function runAdd(componentSpec: string, rootDir: string): Promise<AddResult>;
|
|
33
|
-
export declare function addCommand(componentSpec?: string
|
|
33
|
+
export declare function addCommand(componentSpec?: string, options?: {
|
|
34
|
+
all?: boolean;
|
|
35
|
+
}): Promise<void>;
|
|
34
36
|
//# sourceMappingURL=add.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;AASrB,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAQA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE;IAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAAC,SAAS,EAAE,iBAAiB,EAAE,CAAA;CAAE,EAC1G,IAAI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IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C,MAAM,CAUR;AAED,wBAAsB,MAAM,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,CAsHpB;AAuBD,wBAAsB,UAAU,CAC9B,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|
package/dist/commands/add.js
CHANGED
|
@@ -167,7 +167,12 @@ function printAddResult(result) {
|
|
|
167
167
|
console.log(chalk.cyan(` pnpm add ${result.npmDeps.join(" ")}`));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
export async function addCommand(componentSpec) {
|
|
170
|
+
export async function addCommand(componentSpec, options) {
|
|
171
|
+
// If --all flag, install everything
|
|
172
|
+
if (options?.all) {
|
|
173
|
+
await installAll();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
171
176
|
// If no component specified, show interactive picker
|
|
172
177
|
if (!componentSpec) {
|
|
173
178
|
await interactiveAdd();
|
|
@@ -290,6 +295,74 @@ async function changeTheme(rootDir, registryDir) {
|
|
|
290
295
|
console.error(chalk.red(`\nError: ${message}`));
|
|
291
296
|
}
|
|
292
297
|
}
|
|
298
|
+
async function installAll() {
|
|
299
|
+
const rootDir = process.cwd();
|
|
300
|
+
const componentsJson = readComponentsJson(rootDir);
|
|
301
|
+
if (!componentsJson) {
|
|
302
|
+
console.log(chalk.red("No components.json found. Run `inai-ui init` first to initialize your project."));
|
|
303
|
+
process.exit(1);
|
|
304
|
+
}
|
|
305
|
+
const registryDir = resolveRegistryDir(rootDir);
|
|
306
|
+
const registryPath = path.join(registryDir, "registry.json");
|
|
307
|
+
const registry = readRegistryJson(registryPath);
|
|
308
|
+
if (!registry) {
|
|
309
|
+
console.log(chalk.red("Registry not found. Ensure your project is initialized correctly."));
|
|
310
|
+
process.exit(1);
|
|
311
|
+
}
|
|
312
|
+
const allItems = [
|
|
313
|
+
...registry.components,
|
|
314
|
+
...registry.blocks,
|
|
315
|
+
...registry.templates,
|
|
316
|
+
];
|
|
317
|
+
console.log(chalk.bold(`\nInstalling all ${allItems.length} components, blocks, and templates...\n`));
|
|
318
|
+
const installed = componentsJson.installedComponents ?? [];
|
|
319
|
+
const installedNames = new Set(installed.map((c) => c.name));
|
|
320
|
+
const allNpmDeps = new Set();
|
|
321
|
+
let addedCount = 0;
|
|
322
|
+
let updatedCount = 0;
|
|
323
|
+
for (const item of allItems) {
|
|
324
|
+
const isInstalled = installedNames.has(item.name);
|
|
325
|
+
const action = isInstalled ? "Updating" : "Adding";
|
|
326
|
+
const prefix = item.type === "block" ? "block/" : item.type === "template" ? "template/" : "";
|
|
327
|
+
const spinner = ora(`${action} "${prefix}${item.name}"...`).start();
|
|
328
|
+
try {
|
|
329
|
+
const spec = prefix ? `${prefix}${item.name}` : item.name;
|
|
330
|
+
const result = await runAdd(spec, rootDir);
|
|
331
|
+
if (!result.added) {
|
|
332
|
+
spinner.fail(result.message);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (isInstalled) {
|
|
336
|
+
spinner.succeed(`Updated "${prefix}${item.name}"`);
|
|
337
|
+
updatedCount++;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
spinner.succeed(`Added "${prefix}${item.name}"`);
|
|
341
|
+
addedCount++;
|
|
342
|
+
}
|
|
343
|
+
for (const dep of result.npmDeps) {
|
|
344
|
+
allNpmDeps.add(dep);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
spinner.fail(`Failed to process "${prefix}${item.name}"`);
|
|
349
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
350
|
+
console.error(chalk.red(` Error: ${message}`));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// Summary
|
|
354
|
+
console.log(chalk.bold("\nSummary:"));
|
|
355
|
+
if (addedCount > 0) {
|
|
356
|
+
console.log(chalk.green(` ${addedCount} component${addedCount > 1 ? "s" : ""} added`));
|
|
357
|
+
}
|
|
358
|
+
if (updatedCount > 0) {
|
|
359
|
+
console.log(chalk.blue(` ${updatedCount} component${updatedCount > 1 ? "s" : ""} updated`));
|
|
360
|
+
}
|
|
361
|
+
if (allNpmDeps.size > 0) {
|
|
362
|
+
console.log(chalk.yellow("\nInstall required npm dependencies:"));
|
|
363
|
+
console.log(chalk.cyan(` pnpm add ${[...allNpmDeps].join(" ")}`));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
293
366
|
async function interactiveAdd() {
|
|
294
367
|
const rootDir = process.cwd();
|
|
295
368
|
const componentsJson = readComponentsJson(rootDir);
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const program = new Command();
|
|
|
12
12
|
program
|
|
13
13
|
.name("inai-ui")
|
|
14
14
|
.description("CLI for InAI UI component library")
|
|
15
|
-
.version("0.1.
|
|
15
|
+
.version("0.1.6");
|
|
16
16
|
program
|
|
17
17
|
.command("init [repo-url]")
|
|
18
18
|
.description("Initialize InAI UI in your project. Optionally pass a Git repo URL to fetch components remotely.")
|
|
@@ -20,7 +20,8 @@ program
|
|
|
20
20
|
program
|
|
21
21
|
.command("add [component]")
|
|
22
22
|
.description("Add a component to your project. Without arguments, opens an interactive picker to select multiple components.")
|
|
23
|
-
.
|
|
23
|
+
.option("-a, --all", "Install all available components, blocks, and templates")
|
|
24
|
+
.action((component, options) => addCommand(component, options));
|
|
24
25
|
program
|
|
25
26
|
.command("sync")
|
|
26
27
|
.description("Update the local registry cache from the remote repository")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inai-react-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "CLI for InAI UI component library — install components from a private registry into your React project",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"chalk": "^5.6.2",
|
|
36
36
|
"commander": "^14.0.3",
|
|
37
|
-
"fast-glob": "^3.3.3",
|
|
38
37
|
"ora": "^9.3.0",
|
|
39
38
|
"prompts": "^2.4.2"
|
|
40
39
|
},
|