inai-react-components 1.4.0 → 1.5.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/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +109 -29
- package/dist/commands/init.d.ts +5 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +18 -13
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AAoBrB,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kDAAkD;IAClD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,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;IACvB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kEAAkE;IAClE,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IA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AAM,EAAE,CAAC;IACnB,kEAAkE;IAClE,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAChD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAsCA;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,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,iBAAiB,GAAG,IAAI,CAc1B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,iBAAiB,EAC5B,cAAc,EAAE,kBAAkB,GACjC,MAAM,CAiBR;AA2OD,wBAAsB,MAAM,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,SAAS,CAAC,CAmMpB;AAqCD,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,UAAU,CAC9B,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAqIf"}
|
package/dist/commands/add.js
CHANGED
|
@@ -107,6 +107,10 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
107
107
|
const baseTargetDir = getTargetDir(component, componentsJson);
|
|
108
108
|
const isMultiFile = component.type === "block" || component.type === "template";
|
|
109
109
|
const targetDir = isMultiFile ? path.join(baseTargetDir, name) : baseTargetDir;
|
|
110
|
+
// Prefix used by component source files. Stripping it preserves the
|
|
111
|
+
// component's internal subdirectory structure (e.g. `data-table/context.tsx`
|
|
112
|
+
// stays inside a `data-table/` subfolder in the user's project).
|
|
113
|
+
const UI_PREFIX = "packages/ui/src/";
|
|
110
114
|
const copiedFiles = [];
|
|
111
115
|
const skippedFiles = [];
|
|
112
116
|
// Track captured content for the snapshot (only for files that were
|
|
@@ -114,15 +118,30 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
114
118
|
const capturedFiles = {};
|
|
115
119
|
for (const filePath of component.files) {
|
|
116
120
|
const registryFilePath = path.join(registryDir, filePath);
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
// Destination path relative to `targetDir`:
|
|
122
|
+
// - Blocks/templates (multi-file) already nest under `<targetDir>/<name>/`,
|
|
123
|
+
// so we take the basename of each file (flat within the block dir).
|
|
124
|
+
// - Components strip the `packages/ui/src/` prefix so compound components
|
|
125
|
+
// like `data-table` keep their internal `data-table/` subfolder.
|
|
126
|
+
let destRel;
|
|
127
|
+
if (isMultiFile) {
|
|
128
|
+
destRel = path.basename(filePath);
|
|
129
|
+
}
|
|
130
|
+
else if (filePath.startsWith(UI_PREFIX)) {
|
|
131
|
+
destRel = filePath.slice(UI_PREFIX.length);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
destRel = path.basename(filePath);
|
|
135
|
+
}
|
|
136
|
+
const localFilePath = path.join(rootDir, targetDir, destRel);
|
|
137
|
+
const displayName = isMultiFile ? `${name}/${destRel}` : destRel;
|
|
119
138
|
if (!fs.existsSync(registryFilePath)) {
|
|
120
139
|
continue;
|
|
121
140
|
}
|
|
122
141
|
const exists = fs.existsSync(localFilePath);
|
|
123
142
|
if (exists && !options.force) {
|
|
124
143
|
if (options.skipExisting) {
|
|
125
|
-
skippedFiles.push(
|
|
144
|
+
skippedFiles.push(displayName);
|
|
126
145
|
continue;
|
|
127
146
|
}
|
|
128
147
|
if (options.dryRun) {
|
|
@@ -136,7 +155,7 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
136
155
|
initial: false,
|
|
137
156
|
});
|
|
138
157
|
if (!res.overwrite) {
|
|
139
|
-
skippedFiles.push(
|
|
158
|
+
skippedFiles.push(displayName);
|
|
140
159
|
continue;
|
|
141
160
|
}
|
|
142
161
|
}
|
|
@@ -158,19 +177,38 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
158
177
|
content,
|
|
159
178
|
};
|
|
160
179
|
}
|
|
161
|
-
copiedFiles.push(
|
|
162
|
-
}
|
|
163
|
-
// Internal deps (lib/cn, lib/animations, ...)
|
|
164
|
-
//
|
|
165
|
-
|
|
180
|
+
copiedFiles.push(displayName);
|
|
181
|
+
}
|
|
182
|
+
// Internal deps (lib/cn, lib/animations, lib/i18n-context, ...).
|
|
183
|
+
//
|
|
184
|
+
// Placement matters: source components import via `./lib/<name>.js`
|
|
185
|
+
// (sibling), so lib files MUST land in `<componentDir>/lib/` — NOT in
|
|
186
|
+
// `<sourceRoot>/lib/`. Otherwise the relative imports break at runtime.
|
|
187
|
+
//
|
|
188
|
+
// Extensions: most lib files are `.ts` but `i18n-context.tsx` contains
|
|
189
|
+
// JSX and must be copied as `.tsx`. We probe both in order.
|
|
190
|
+
const componentsDir = resolveLocalDir(componentsJson.aliases.components, componentsJson);
|
|
166
191
|
const copiedInternalDeps = [];
|
|
167
192
|
for (const dep of component.internalDeps) {
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
193
|
+
const depBase = dep.split("/").pop();
|
|
194
|
+
const tsSource = path.join(registryDir, "packages", "ui", "src", dep + ".ts");
|
|
195
|
+
const tsxSource = path.join(registryDir, "packages", "ui", "src", dep + ".tsx");
|
|
196
|
+
let depSourcePath;
|
|
197
|
+
let depFileName;
|
|
198
|
+
if (fs.existsSync(tsSource)) {
|
|
199
|
+
depSourcePath = tsSource;
|
|
200
|
+
depFileName = `${depBase}.ts`;
|
|
201
|
+
}
|
|
202
|
+
else if (fs.existsSync(tsxSource)) {
|
|
203
|
+
depSourcePath = tsxSource;
|
|
204
|
+
depFileName = `${depBase}.tsx`;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
172
207
|
continue;
|
|
173
208
|
}
|
|
209
|
+
// e.g. componentsDir = "app/components/ui" → target:
|
|
210
|
+
// "app/components/ui/lib/i18n-context.tsx"
|
|
211
|
+
const depTargetPath = path.join(rootDir, componentsDir, "lib", depFileName);
|
|
174
212
|
const content = fs.readFileSync(depSourcePath, "utf-8");
|
|
175
213
|
if (options.dryRun) {
|
|
176
214
|
console.log(chalk.dim(` [dry-run] would write ${path.relative(rootDir, depTargetPath)}`));
|
|
@@ -181,6 +219,29 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
181
219
|
}
|
|
182
220
|
copiedInternalDeps.push(dep);
|
|
183
221
|
}
|
|
222
|
+
// Block/template lib: blocks import via `../../lib/animations` and
|
|
223
|
+
// `../../lib/styles` relative to `<blocksDir>/<blockName>/page.tsx`,
|
|
224
|
+
// which resolves two levels up to `path.dirname(blocksDir)/lib/`.
|
|
225
|
+
// Copy the global block lib from `apps/docs/src/registry/lib/` there.
|
|
226
|
+
if (isMultiFile) {
|
|
227
|
+
const blocksDir = resolveLocalDir(componentsJson.aliases.blocks, componentsJson);
|
|
228
|
+
const blockLibDest = path.join(rootDir, path.dirname(blocksDir), "lib");
|
|
229
|
+
for (const libFile of ["animations.ts", "styles.ts"]) {
|
|
230
|
+
const src = path.join(registryDir, "apps", "docs", "src", "registry", "lib", libFile);
|
|
231
|
+
if (!fs.existsSync(src))
|
|
232
|
+
continue;
|
|
233
|
+
const dest = path.join(blockLibDest, libFile);
|
|
234
|
+
if (fs.existsSync(dest) && !options.force)
|
|
235
|
+
continue;
|
|
236
|
+
if (options.dryRun) {
|
|
237
|
+
console.log(chalk.dim(` [dry-run] would write ${path.relative(rootDir, dest)}`));
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
fs.mkdirSync(blockLibDest, { recursive: true });
|
|
241
|
+
fs.copyFileSync(src, dest);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
184
245
|
// Update components.json (skipped in dry-run).
|
|
185
246
|
if (!options.dryRun) {
|
|
186
247
|
const registryVersion = registry.version;
|
|
@@ -650,34 +711,53 @@ async function installAll(options) {
|
|
|
650
711
|
...registry.templates,
|
|
651
712
|
];
|
|
652
713
|
console.log(chalk.bold(`\nInstalling all ${allItems.length} components, blocks, and templates...\n`));
|
|
653
|
-
|
|
654
|
-
|
|
714
|
+
// Track what's been installed across the loop. Because `runAdd` resolves
|
|
715
|
+
// transitive dependencies (e.g. `alert` pulls in `button`), a component
|
|
716
|
+
// scheduled later in the iteration may already be on disk by the time we
|
|
717
|
+
// reach it. We refresh this set from `components.json` after every
|
|
718
|
+
// `runAdd` call so `isInstalled` stays accurate across the bulk install.
|
|
719
|
+
const installedNames = new Set((componentsJson.installedComponents ?? []).map((c) => c.name));
|
|
655
720
|
const allNpmDeps = new Set();
|
|
656
721
|
let addedCount = 0;
|
|
657
|
-
let
|
|
722
|
+
let skippedCount = 0;
|
|
658
723
|
for (const item of allItems) {
|
|
659
|
-
|
|
660
|
-
|
|
724
|
+
// Skip components that were already installed by a previous iteration
|
|
725
|
+
// as a transitive dep — avoids redundant file writes and prevents the
|
|
726
|
+
// overwrite prompt from hanging the bulk install.
|
|
727
|
+
if (installedNames.has(item.name)) {
|
|
728
|
+
skippedCount++;
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
661
731
|
const prefix = item.type === "block" ? "block/" : item.type === "template" ? "template/" : "";
|
|
662
|
-
const spinner = ora(
|
|
732
|
+
const spinner = ora(`Adding "${prefix}${item.name}"...`).start();
|
|
663
733
|
try {
|
|
664
734
|
const spec = prefix ? `${prefix}${item.name}` : item.name;
|
|
735
|
+
// Pause the spinner defensively — any stray `prompts()` call inside
|
|
736
|
+
// `runAdd` would otherwise deadlock because ora holds stdout while
|
|
737
|
+
// the prompt reads stdin.
|
|
738
|
+
spinner.stop();
|
|
665
739
|
const result = await runAdd(spec, rootDir, {
|
|
740
|
+
// During a bulk install, default to skipping files that already
|
|
741
|
+
// exist (from transitive deps or user edits) instead of prompting
|
|
742
|
+
// for overwrite. `--force` still overrides this if the user wants
|
|
743
|
+
// to refresh everything.
|
|
666
744
|
force: options?.force,
|
|
667
745
|
dryRun: options?.dryRun,
|
|
668
|
-
skipExisting: options?.skipExisting,
|
|
746
|
+
skipExisting: options?.skipExisting ?? !options?.force,
|
|
669
747
|
});
|
|
670
748
|
if (!result.added) {
|
|
671
749
|
spinner.fail(result.message);
|
|
672
750
|
continue;
|
|
673
751
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
752
|
+
spinner.succeed(`Added "${prefix}${item.name}"`);
|
|
753
|
+
addedCount++;
|
|
754
|
+
// Refresh the installed-names cache so the next iteration sees any
|
|
755
|
+
// transitive deps just installed by `runAdd`.
|
|
756
|
+
const freshJson = readComponentsJson(rootDir);
|
|
757
|
+
if (freshJson?.installedComponents) {
|
|
758
|
+
for (const entry of freshJson.installedComponents) {
|
|
759
|
+
installedNames.add(entry.name);
|
|
760
|
+
}
|
|
681
761
|
}
|
|
682
762
|
for (const dep of result.npmDeps) {
|
|
683
763
|
allNpmDeps.add(dep);
|
|
@@ -694,8 +774,8 @@ async function installAll(options) {
|
|
|
694
774
|
if (addedCount > 0) {
|
|
695
775
|
console.log(chalk.green(` ${addedCount} component${addedCount > 1 ? "s" : ""} added`));
|
|
696
776
|
}
|
|
697
|
-
if (
|
|
698
|
-
console.log(chalk.
|
|
777
|
+
if (skippedCount > 0) {
|
|
778
|
+
console.log(chalk.dim(` ${skippedCount} component${skippedCount > 1 ? "s" : ""} skipped (already installed as dependency)`));
|
|
699
779
|
}
|
|
700
780
|
if (allNpmDeps.size > 0) {
|
|
701
781
|
console.log(chalk.yellow("\nInstall required npm dependencies:"));
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -273,11 +273,12 @@ export declare function getLegacyTailwindCssTemplate(theme: Theme, fontBody: Fon
|
|
|
273
273
|
export declare function normalizeThemeCss(css: string, theme: string): string;
|
|
274
274
|
/**
|
|
275
275
|
* Copies the i18n base files (context, types, defaults) from the registry
|
|
276
|
-
* to
|
|
277
|
-
* `useUIMessages` from `./lib/i18n-context.js` —
|
|
278
|
-
*
|
|
276
|
+
* to `<componentPath>/lib/`. Required because ~75 components import
|
|
277
|
+
* `useUIMessages` from `./lib/i18n-context.js` — the lib directory must
|
|
278
|
+
* live as a SIBLING of the component `.tsx` files so relative imports
|
|
279
|
+
* resolve correctly.
|
|
279
280
|
*/
|
|
280
|
-
export declare function copyI18nFiles(registryDir: string | undefined, targetDir: string,
|
|
281
|
+
export declare function copyI18nFiles(registryDir: string | undefined, targetDir: string, componentPath: string): string[];
|
|
281
282
|
export declare function runInit(config: InitConfig, targetDir: string, repoUrl?: string): Promise<{
|
|
282
283
|
success: boolean;
|
|
283
284
|
filesCreated: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAGrC,KAAK,KAAK,GAAG,MAAM,CAAC;AAEpB,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
347
347
|
}
|
|
348
348
|
/**
|
|
349
349
|
* Copies the i18n base files (context, types, defaults) from the registry
|
|
350
|
-
* to
|
|
351
|
-
* `useUIMessages` from `./lib/i18n-context.js` —
|
|
352
|
-
*
|
|
350
|
+
* to `<componentPath>/lib/`. Required because ~75 components import
|
|
351
|
+
* `useUIMessages` from `./lib/i18n-context.js` — the lib directory must
|
|
352
|
+
* live as a SIBLING of the component `.tsx` files so relative imports
|
|
353
|
+
* resolve correctly.
|
|
353
354
|
*/
|
|
354
|
-
export function copyI18nFiles(registryDir, targetDir,
|
|
355
|
+
export function copyI18nFiles(registryDir, targetDir, componentPath) {
|
|
355
356
|
if (!registryDir)
|
|
356
357
|
return [];
|
|
357
358
|
const files = ["i18n-context.tsx", "i18n-types.ts", "i18n-defaults.ts"];
|
|
358
359
|
const srcBase = path.join(registryDir, "packages", "ui", "src", "lib");
|
|
359
|
-
const destBase = path.join(targetDir,
|
|
360
|
+
const destBase = path.join(targetDir, componentPath, "lib");
|
|
360
361
|
fs.mkdirSync(destBase, { recursive: true });
|
|
361
362
|
const copied = [];
|
|
362
363
|
for (const file of files) {
|
|
@@ -364,7 +365,7 @@ export function copyI18nFiles(registryDir, targetDir, sourceRoot) {
|
|
|
364
365
|
if (!fs.existsSync(src))
|
|
365
366
|
continue;
|
|
366
367
|
fs.copyFileSync(src, path.join(destBase, file));
|
|
367
|
-
copied.push(`${
|
|
368
|
+
copied.push(`${componentPath}/lib/${file}`);
|
|
368
369
|
}
|
|
369
370
|
return copied;
|
|
370
371
|
}
|
|
@@ -381,12 +382,15 @@ export async function runInit(config, targetDir, repoUrl) {
|
|
|
381
382
|
fs.mkdirSync(componentDir, { recursive: true });
|
|
382
383
|
const blockDir = path.join(targetDir, config.blockPath);
|
|
383
384
|
fs.mkdirSync(blockDir, { recursive: true });
|
|
384
|
-
// 3. Create cn.ts utility
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
385
|
+
// 3. Create cn.ts utility as a sibling of the components directory.
|
|
386
|
+
// Components import via `./lib/cn.js`, so lib/ MUST live directly
|
|
387
|
+
// next to the installed component files — `<componentPath>/lib/`,
|
|
388
|
+
// not `<sourceRoot>/lib/`.
|
|
389
|
+
const libDir = path.join(targetDir, config.componentPath, "lib");
|
|
390
|
+
fs.mkdirSync(libDir, { recursive: true });
|
|
391
|
+
const cnPath = path.join(libDir, "cn.ts");
|
|
388
392
|
fs.writeFileSync(cnPath, getCnTemplate());
|
|
389
|
-
filesCreated.push(`${
|
|
393
|
+
filesCreated.push(`${config.componentPath}/lib/cn.ts`);
|
|
390
394
|
// 4. Copy tokens and create CSS
|
|
391
395
|
const cssRelPath = config.cssEntryPoint ?? `${sourceRoot}/index.css`;
|
|
392
396
|
const cssPath = path.join(targetDir, cssRelPath);
|
|
@@ -396,8 +400,9 @@ export async function runInit(config, targetDir, repoUrl) {
|
|
|
396
400
|
const registryDir = getCacheDir();
|
|
397
401
|
const tokenFiles = copyTokensToProject(registryDir, targetDir, config.theme, sourceRoot);
|
|
398
402
|
filesCreated.push(...tokenFiles);
|
|
399
|
-
// Copy i18n base files
|
|
400
|
-
|
|
403
|
+
// Copy i18n base files next to the components so their
|
|
404
|
+
// `./lib/i18n-context.js` imports resolve.
|
|
405
|
+
const i18nFiles = copyI18nFiles(registryDir, targetDir, config.componentPath);
|
|
401
406
|
filesCreated.push(...i18nFiles);
|
|
402
407
|
fs.writeFileSync(cssPath, getLocalTailwindCssTemplate(config.theme, config.fontBody, config.fontHeading, config.radius));
|
|
403
408
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const program = new Command();
|
|
|
17
17
|
program
|
|
18
18
|
.name("inai-ui")
|
|
19
19
|
.description("CLI for InAI UI component library")
|
|
20
|
-
.version("1.
|
|
20
|
+
.version("1.5.0");
|
|
21
21
|
program
|
|
22
22
|
.command("init [repo-url]")
|
|
23
23
|
.description("Initialize InAI UI in your project. Optionally pass a Git repo URL to fetch components remotely.")
|
package/package.json
CHANGED