inai-react-components 2.0.6 → 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/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +11 -29
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +37 -0
- package/dist/commands/status.d.ts +12 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +23 -22
- package/dist/components/ui/button.d.ts +2 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +1 -0
- package/dist/index.js +0 -0
- package/dist/schemas/init-config.schema.json +5 -0
- package/dist/utils/paths.d.ts +23 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +37 -0
- package/package.json +12 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AA2BrB,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,C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,OAAO,CAAC,SAAS,CAAC,CA0NpB;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
|
@@ -10,7 +10,7 @@ import { saveSnapshot, sha256, } from "../utils/snapshot.js";
|
|
|
10
10
|
import { fuzzySearchNames } from "../utils/fuzzy-search.js";
|
|
11
11
|
import { normalizeThemeCss, getLocalTailwindCssTemplate, getLegacyTailwindCssTemplate, } from "./init.js";
|
|
12
12
|
import { autoInstallDeps } from "../utils/auto-install.js";
|
|
13
|
-
import { resolveLocalDir, getSourceRoot, rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, } from "../utils/paths.js";
|
|
13
|
+
import { resolveLocalDir, getSourceRoot, rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, computeDestRel, } from "../utils/paths.js";
|
|
14
14
|
/**
|
|
15
15
|
* Parse a component spec into its registry namespace, type prefix and name.
|
|
16
16
|
*
|
|
@@ -121,19 +121,6 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
121
121
|
const baseTargetDir = getTargetDir(component, componentsJson);
|
|
122
122
|
const isMultiFile = component.type === "block" || component.type === "template";
|
|
123
123
|
const targetDir = isMultiFile ? path.join(baseTargetDir, name) : baseTargetDir;
|
|
124
|
-
// Prefixes used by source files. Stripping them preserves each
|
|
125
|
-
// component/block's internal subdirectory structure.
|
|
126
|
-
//
|
|
127
|
-
// Components: `packages/ui/src/<name>.tsx` and
|
|
128
|
-
// `packages/ui/src/<name>/sub.tsx` → strip `packages/ui/src/`
|
|
129
|
-
// so compound subdirs (`data-table/`) land as-is under
|
|
130
|
-
// `<componentDir>/`.
|
|
131
|
-
//
|
|
132
|
-
// Blocks/templates: `apps/docs/src/registry/blocks/<name>/**` → strip
|
|
133
|
-
// `apps/docs/src/registry/blocks/<name>/` so nested `parts/`
|
|
134
|
-
// subfolders are preserved under `<blocksDir>/<name>/`.
|
|
135
|
-
const UI_PREFIX = "packages/ui/src/";
|
|
136
|
-
const BLOCK_PREFIX = `apps/docs/src/registry/blocks/${name}/`;
|
|
137
124
|
const copiedFiles = [];
|
|
138
125
|
const skippedFiles = [];
|
|
139
126
|
// Track captured content for the snapshot (only for files that were
|
|
@@ -141,21 +128,11 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
141
128
|
const capturedFiles = {};
|
|
142
129
|
for (const filePath of component.files) {
|
|
143
130
|
const registryFilePath = path.join(registryDir, filePath);
|
|
144
|
-
// Destination path relative to `targetDir`.
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
if (isMultiFile && filePath.startsWith(BLOCK_PREFIX)) {
|
|
150
|
-
destRel = filePath.slice(BLOCK_PREFIX.length);
|
|
151
|
-
}
|
|
152
|
-
else if (!isMultiFile && filePath.startsWith(UI_PREFIX)) {
|
|
153
|
-
destRel = filePath.slice(UI_PREFIX.length);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
// Fallback for legacy registry entries without the expected prefix.
|
|
157
|
-
destRel = path.basename(filePath);
|
|
158
|
-
}
|
|
131
|
+
// Destination path relative to `targetDir`. Prefix stripping preserves
|
|
132
|
+
// intra-component directory structure (compound subdirs, blocks'
|
|
133
|
+
// `parts/` folders, etc.). `computeDestRel` throws on registry drift
|
|
134
|
+
// instead of silently flattening to basename.
|
|
135
|
+
const destRel = computeDestRel(filePath, name, isMultiFile);
|
|
159
136
|
const localFilePath = path.join(rootDir, targetDir, destRel);
|
|
160
137
|
const displayName = isMultiFile ? `${name}/${destRel}` : destRel;
|
|
161
138
|
if (!fs.existsSync(registryFilePath)) {
|
|
@@ -326,6 +303,10 @@ async function installOne(component, registry, componentsJson, registryDir, root
|
|
|
326
303
|
name,
|
|
327
304
|
version: registryVersion,
|
|
328
305
|
installedAt: new Date().toISOString().split("T")[0],
|
|
306
|
+
// `targetDir` is already relative to rootDir (returned by getTargetDir
|
|
307
|
+
// → resolveLocalDir which never emits absolute paths). Persist it so
|
|
308
|
+
// `update` can re-target the same dir even if aliases later change.
|
|
309
|
+
installDir: targetDir,
|
|
329
310
|
};
|
|
330
311
|
if (existingIdx >= 0) {
|
|
331
312
|
installed[existingIdx] = entry;
|
|
@@ -425,6 +406,7 @@ async function installTheme(theme, componentsJson, registryDir, rootDir, options
|
|
|
425
406
|
name: `theme/${name}`,
|
|
426
407
|
version: "2.0.0",
|
|
427
408
|
installedAt: new Date().toISOString().split("T")[0],
|
|
409
|
+
installDir: themesDir,
|
|
428
410
|
};
|
|
429
411
|
if (existingIdx >= 0) {
|
|
430
412
|
installed[existingIdx] = entry;
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -218,6 +218,7 @@ type FontPreset = (typeof FONT_PRESETS)[number]["name"];
|
|
|
218
218
|
export interface InitConfig {
|
|
219
219
|
componentPath: string;
|
|
220
220
|
blockPath: string;
|
|
221
|
+
templatePath: string;
|
|
221
222
|
theme: Theme;
|
|
222
223
|
fontBody: FontPreset;
|
|
223
224
|
fontHeading: FontPreset;
|
|
@@ -244,6 +245,7 @@ export interface ComponentsJson {
|
|
|
244
245
|
aliases: {
|
|
245
246
|
components: string;
|
|
246
247
|
blocks: string;
|
|
248
|
+
templates: string;
|
|
247
249
|
utils: string;
|
|
248
250
|
lib?: string;
|
|
249
251
|
};
|
|
@@ -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;AAIrC,KAAK,KAAK,GAAG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AC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,WAAW,CAC/B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA8Hf"}
|
package/dist/commands/init.js
CHANGED
|
@@ -136,6 +136,9 @@ export function loadInitConfigFromFile(configPath, framework, layout) {
|
|
|
136
136
|
const blockPath = typeof raw.blockPath === "string"
|
|
137
137
|
? assertSafeRelativePath(raw.blockPath, "blockPath")
|
|
138
138
|
: `${sourceRoot}/components/blocks`;
|
|
139
|
+
const templatePath = typeof raw.templatePath === "string"
|
|
140
|
+
? assertSafeRelativePath(raw.templatePath, "templatePath")
|
|
141
|
+
: `${sourceRoot}/templates`;
|
|
139
142
|
const theme = typeof raw.theme === "string" ? raw.theme : AVAILABLE_THEMES[0] ?? "inai";
|
|
140
143
|
if (!AVAILABLE_THEMES.includes(theme)) {
|
|
141
144
|
throw new Error(`Unknown theme "${theme}". Allowed: ${AVAILABLE_THEMES.join(", ")}`);
|
|
@@ -161,6 +164,7 @@ export function loadInitConfigFromFile(configPath, framework, layout) {
|
|
|
161
164
|
return {
|
|
162
165
|
componentPath,
|
|
163
166
|
blockPath,
|
|
167
|
+
templatePath,
|
|
164
168
|
theme,
|
|
165
169
|
fontBody,
|
|
166
170
|
fontHeading,
|
|
@@ -180,18 +184,50 @@ export async function promptInitConfig(registryDir, framework, layout) {
|
|
|
180
184
|
const defaultCssEntry = framework
|
|
181
185
|
? getCssEntryPoint(framework, sourceRoot)
|
|
182
186
|
: `${sourceRoot}/index.css`;
|
|
187
|
+
// Warn (non-blocking) when the user types a path that doesn't start with
|
|
188
|
+
// `${sourceRoot}/` but `${sourceRoot}` exists on disk. This catches the
|
|
189
|
+
// classic "I dropped the `src/` prefix and now files end up at the repo
|
|
190
|
+
// root" mistake without forcing the layout for non-standard projects.
|
|
191
|
+
const validateProjectPath = (value) => {
|
|
192
|
+
if (typeof value !== "string")
|
|
193
|
+
return "Path must be a string";
|
|
194
|
+
const trimmed = value.trim();
|
|
195
|
+
if (!trimmed)
|
|
196
|
+
return "Path must not be empty";
|
|
197
|
+
if (path.isAbsolute(trimmed))
|
|
198
|
+
return "Path must be relative to the project root";
|
|
199
|
+
if (trimmed.split(/[\\/]/).includes(".."))
|
|
200
|
+
return "Path must not contain '..' segments";
|
|
201
|
+
const expectsSourceRoot = fs.existsSync(path.join(process.cwd(), sourceRoot));
|
|
202
|
+
if (expectsSourceRoot &&
|
|
203
|
+
sourceRoot !== "." &&
|
|
204
|
+
!trimmed.startsWith(`${sourceRoot}/`) &&
|
|
205
|
+
trimmed !== sourceRoot) {
|
|
206
|
+
return `Project uses '${sourceRoot}/' as the source root — did you mean '${sourceRoot}/${trimmed}'?`;
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
};
|
|
183
210
|
const response = await prompts([
|
|
184
211
|
{
|
|
185
212
|
type: "text",
|
|
186
213
|
name: "componentPath",
|
|
187
214
|
message: "Where would you like to install components?",
|
|
188
215
|
initial: `${sourceRoot}/components/ui`,
|
|
216
|
+
validate: validateProjectPath,
|
|
189
217
|
},
|
|
190
218
|
{
|
|
191
219
|
type: "text",
|
|
192
220
|
name: "blockPath",
|
|
193
221
|
message: "Where would you like to install blocks?",
|
|
194
222
|
initial: `${sourceRoot}/components/blocks`,
|
|
223
|
+
validate: validateProjectPath,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
type: "text",
|
|
227
|
+
name: "templatePath",
|
|
228
|
+
message: "Where would you like to install templates?",
|
|
229
|
+
initial: `${sourceRoot}/templates`,
|
|
230
|
+
validate: validateProjectPath,
|
|
195
231
|
},
|
|
196
232
|
{
|
|
197
233
|
type: "select",
|
|
@@ -282,6 +318,7 @@ export function buildComponentsJson(config, repoUrl) {
|
|
|
282
318
|
aliases: {
|
|
283
319
|
components: config.componentPath,
|
|
284
320
|
blocks: config.blockPath,
|
|
321
|
+
templates: config.templatePath,
|
|
285
322
|
utils: utilsAlias,
|
|
286
323
|
lib: libAlias,
|
|
287
324
|
},
|
|
@@ -47,6 +47,18 @@ export interface InstalledComponent {
|
|
|
47
47
|
name: string;
|
|
48
48
|
version: string;
|
|
49
49
|
installedAt: string;
|
|
50
|
+
/**
|
|
51
|
+
* Directory (relative to the project root) where this component's files
|
|
52
|
+
* were copied during `add`. Used by `update` to keep writing to the same
|
|
53
|
+
* location even if the user later edits `aliases.components` / `blocks` /
|
|
54
|
+
* `templates` in `components.json` — that change would otherwise produce
|
|
55
|
+
* silent duplicates (old files in the old dir, new ones in the new dir).
|
|
56
|
+
*
|
|
57
|
+
* Optional for back-compat: components installed by a pre-2.2 CLI won't
|
|
58
|
+
* have this field, and `update` falls back to re-resolving via
|
|
59
|
+
* `getTargetDir` in that case.
|
|
60
|
+
*/
|
|
61
|
+
installDir?: string;
|
|
50
62
|
}
|
|
51
63
|
export interface RegistryJson {
|
|
52
64
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd;;;;;;;;;W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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,YAAY,CA4Cd;AAED,wBAAsB,SAAS,CAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,UAAQ,GAClB,OAAO,CAAC,YAAY,CAAC,CAwSvB;AAED,wBAAsB,aAAa,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiDf"}
|
package/dist/commands/update.js
CHANGED
|
@@ -8,7 +8,7 @@ import { readComponentsJson, readRegistryJson, } from "./status.js";
|
|
|
8
8
|
import { findComponentInRegistry, computeDiff } from "./diff.js";
|
|
9
9
|
import { getTargetDir } from "./add.js";
|
|
10
10
|
import { resolveRegistryDir } from "../utils/registry-resolver.js";
|
|
11
|
-
import { rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, resolveLocalDir, getSourceRoot, } from "../utils/paths.js";
|
|
11
|
+
import { rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, resolveLocalDir, getSourceRoot, computeDestRel, } from "../utils/paths.js";
|
|
12
12
|
import { loadSnapshot, saveSnapshot, sha256, } from "../utils/snapshot.js";
|
|
13
13
|
/**
|
|
14
14
|
* Run a 3-way line merge between base (snapshot), mine (local) and theirs
|
|
@@ -81,18 +81,25 @@ export async function runUpdate(componentName, rootDir, skipPrompts = false) {
|
|
|
81
81
|
// Mirror add.ts targetDir resolution so blocks/templates land in their own
|
|
82
82
|
// subdirectories and components in `aliases.components` directly. Without
|
|
83
83
|
// this, `update` for a block would write its files into the components dir.
|
|
84
|
+
//
|
|
85
|
+
// Drift guard: if `add` recorded an `installDir` for this component, use
|
|
86
|
+
// that path verbatim instead of re-resolving from current aliases. This
|
|
87
|
+
// keeps update writing to the same directory where the files actually
|
|
88
|
+
// live even when the user has since edited `components.json` aliases —
|
|
89
|
+
// otherwise update would create silent duplicates in the new location
|
|
90
|
+
// while leaving the originals untouched.
|
|
84
91
|
const isMultiFile = registryComponent.type === "block" || registryComponent.type === "template";
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
const installedEntry = (componentsJson.installedComponents ?? []).find((c) => c.name === componentName);
|
|
93
|
+
let targetDir;
|
|
94
|
+
if (installedEntry?.installDir) {
|
|
95
|
+
targetDir = installedEntry.installDir;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const baseTargetDir = getTargetDir(registryComponent, componentsJson);
|
|
99
|
+
targetDir = isMultiFile
|
|
100
|
+
? path.join(baseTargetDir, componentName)
|
|
101
|
+
: baseTargetDir;
|
|
102
|
+
}
|
|
96
103
|
const updatedFiles = [];
|
|
97
104
|
const cleanMerges = [];
|
|
98
105
|
const conflictedFiles = [];
|
|
@@ -102,16 +109,10 @@ export async function runUpdate(componentName, rootDir, skipPrompts = false) {
|
|
|
102
109
|
for (const filePath of registryComponent.files) {
|
|
103
110
|
const registryFilePath = path.join(registryDir, filePath);
|
|
104
111
|
// Compute destination path that preserves subdirectory structure.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
else if (!isMultiFile && filePath.startsWith(UI_PREFIX)) {
|
|
110
|
-
destRel = filePath.slice(UI_PREFIX.length);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
destRel = path.basename(filePath);
|
|
114
|
-
}
|
|
112
|
+
// Shared with add.ts via `computeDestRel` so a future divergence
|
|
113
|
+
// can't reintroduce the v2.0.4 bug where compound paths collapsed
|
|
114
|
+
// to basename and overwrote sibling files.
|
|
115
|
+
const destRel = computeDestRel(filePath, componentName, isMultiFile);
|
|
115
116
|
const fileName = destRel;
|
|
116
117
|
const localFilePath = path.join(rootDir, targetDir, destRel);
|
|
117
118
|
if (!fs.existsSync(registryFilePath)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/button.tsx"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,SAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function Button() { return null; /* v2 */ }
|
package/dist/index.js
CHANGED
|
File without changes
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"description": "Where to install blocks. Defaults to `<sourceRoot>/components/blocks`.",
|
|
17
17
|
"default": "src/components/blocks"
|
|
18
18
|
},
|
|
19
|
+
"templatePath": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Where to install templates. Defaults to `<sourceRoot>/templates`.",
|
|
22
|
+
"default": "src/templates"
|
|
23
|
+
},
|
|
19
24
|
"theme": {
|
|
20
25
|
"type": "string",
|
|
21
26
|
"description": "Base theme. Must be one of the values returned by `inai-ui list themes`.",
|
package/dist/utils/paths.d.ts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import type { ComponentsJsonFile } from "../commands/status.js";
|
|
2
|
+
/**
|
|
3
|
+
* Source layout prefix for component files in the registry. Every component
|
|
4
|
+
* path emitted by `scripts/generate-registry.mjs` lives under this prefix.
|
|
5
|
+
* Stripping it preserves intra-component subdirectory structure (e.g.
|
|
6
|
+
* `data-table/data-table-body.tsx`) when copying to the consumer project.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UI_PREFIX = "packages/ui/src/";
|
|
9
|
+
/**
|
|
10
|
+
* Source layout prefix for a block/template's files. Each block/template
|
|
11
|
+
* owns a directory under `apps/docs/src/registry/blocks/`, and the prefix
|
|
12
|
+
* is parameterised by the block/template name.
|
|
13
|
+
*/
|
|
14
|
+
export declare function blockPrefix(name: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Compute the destination path of a registry file relative to its target
|
|
17
|
+
* component/block directory. The prefix stripping preserves nested folder
|
|
18
|
+
* structure (compound component subdirs, block `parts/` folders, etc.).
|
|
19
|
+
*
|
|
20
|
+
* Throws if `filePath` doesn't match either prefix — this catches
|
|
21
|
+
* registry drift early instead of silently flattening compound paths to
|
|
22
|
+
* their basename (which used to overwrite sibling files; see v2.0.4 fix).
|
|
23
|
+
*/
|
|
24
|
+
export declare function computeDestRel(filePath: string, componentName: string, isMultiFile: boolean): string;
|
|
2
25
|
/**
|
|
3
26
|
* Resolve an alias stored in `components.json` (e.g. "@/components/ui" or
|
|
4
27
|
* "app/components/ui") to an actual directory relative to the project root.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC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AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,GACjD,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,GACjD,MAAM,CAER;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAC,GAC7D,MAAM,CAYR;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAC,GAC7D,MAAM,CAiBR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAC,GAC7D,MAAM,CAqBR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAYhE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAC,GAC7D,MAAM,CAaR"}
|
package/dist/utils/paths.js
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
const KNOWN_PREFIXES = ["@/", "~/", "$/"];
|
|
2
|
+
/**
|
|
3
|
+
* Source layout prefix for component files in the registry. Every component
|
|
4
|
+
* path emitted by `scripts/generate-registry.mjs` lives under this prefix.
|
|
5
|
+
* Stripping it preserves intra-component subdirectory structure (e.g.
|
|
6
|
+
* `data-table/data-table-body.tsx`) when copying to the consumer project.
|
|
7
|
+
*/
|
|
8
|
+
export const UI_PREFIX = "packages/ui/src/";
|
|
9
|
+
/**
|
|
10
|
+
* Source layout prefix for a block/template's files. Each block/template
|
|
11
|
+
* owns a directory under `apps/docs/src/registry/blocks/`, and the prefix
|
|
12
|
+
* is parameterised by the block/template name.
|
|
13
|
+
*/
|
|
14
|
+
export function blockPrefix(name) {
|
|
15
|
+
return `apps/docs/src/registry/blocks/${name}/`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Compute the destination path of a registry file relative to its target
|
|
19
|
+
* component/block directory. The prefix stripping preserves nested folder
|
|
20
|
+
* structure (compound component subdirs, block `parts/` folders, etc.).
|
|
21
|
+
*
|
|
22
|
+
* Throws if `filePath` doesn't match either prefix — this catches
|
|
23
|
+
* registry drift early instead of silently flattening compound paths to
|
|
24
|
+
* their basename (which used to overwrite sibling files; see v2.0.4 fix).
|
|
25
|
+
*/
|
|
26
|
+
export function computeDestRel(filePath, componentName, isMultiFile) {
|
|
27
|
+
if (isMultiFile) {
|
|
28
|
+
const prefix = blockPrefix(componentName);
|
|
29
|
+
if (filePath.startsWith(prefix))
|
|
30
|
+
return filePath.slice(prefix.length);
|
|
31
|
+
}
|
|
32
|
+
else if (filePath.startsWith(UI_PREFIX)) {
|
|
33
|
+
return filePath.slice(UI_PREFIX.length);
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Registry path "${filePath}" does not match the expected prefix for "${componentName}" (` +
|
|
36
|
+
`${isMultiFile ? blockPrefix(componentName) : UI_PREFIX}). ` +
|
|
37
|
+
"This usually means registry.json is out of sync — run `pnpm sync-registry` from the registry repo and commit the result.");
|
|
38
|
+
}
|
|
2
39
|
/**
|
|
3
40
|
* Resolve an alias stored in `components.json` (e.g. "@/components/ui" or
|
|
4
41
|
* "app/components/ui") to an actual directory relative to the project root.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inai-react-components",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
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",
|
|
@@ -28,6 +28,14 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc && pnpm run copy-schemas",
|
|
33
|
+
"copy-schemas": "node -e \"require('fs').cpSync('src/schemas', 'dist/schemas', {recursive: true})\"",
|
|
34
|
+
"dev": "tsc --watch",
|
|
35
|
+
"check-types": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"prepublishOnly": "pnpm run build && pnpm run test"
|
|
38
|
+
},
|
|
31
39
|
"dependencies": {
|
|
32
40
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
33
41
|
"chalk": "^5.6.2",
|
|
@@ -38,17 +46,10 @@
|
|
|
38
46
|
"prompts": "^2.4.2"
|
|
39
47
|
},
|
|
40
48
|
"devDependencies": {
|
|
49
|
+
"@repo/typescript-config": "workspace:*",
|
|
41
50
|
"@types/diff": "^8.0.0",
|
|
42
51
|
"@types/node": "^22.15.3",
|
|
43
52
|
"typescript": "5.9.2",
|
|
44
|
-
"vitest": "^4.1.0"
|
|
45
|
-
"@repo/typescript-config": "0.0.0"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"build": "tsc && pnpm run copy-schemas",
|
|
49
|
-
"copy-schemas": "node -e \"require('fs').cpSync('src/schemas', 'dist/schemas', {recursive: true})\"",
|
|
50
|
-
"dev": "tsc --watch",
|
|
51
|
-
"check-types": "tsc --noEmit",
|
|
52
|
-
"test": "vitest run"
|
|
53
|
+
"vitest": "^4.1.0"
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|