CLI: support init with JSON schema

This commit is contained in:
Fuma Nama
2025-12-18 22:28:23 +08:00
parent 3aa43738b4
commit 730718fe49
4 changed files with 14 additions and 16 deletions
+1 -2
View File
@@ -16,8 +16,7 @@
"./build": {
"import": "./dist/build/index.js",
"types": "./dist/build/index.d.ts"
},
"./schema/*": "./dist/schema/*"
}
},
"main": "./dist/index.js",
"bin": {
-13
View File
@@ -1,13 +0,0 @@
## Fumadocs Registry
A Fumadocs registry is similar to Shadcn registry, but included more hints for accurate replication of original file structure.
Different from Shadcn CLI (currently), Fumadocs CLI has better support for using another base URL for registry.
For example, `index.json` was only supported for Shadcn UI itself but not custom registries.
## Definition
index file: `{base_url}/_registry.json`, type: `OutputIndex[]`.
component file: `{base_url}/{name}.json`, type: `OutputComponent`.
We have a smarter build system that can accurately detect references to deps, local files, and sub component.
+8
View File
@@ -12,6 +12,14 @@ export function createConfigSchema(isSrc: boolean) {
};
return z.object({
$schema: z
.string()
.default(
isSrc
? 'node_modules/@fumadocs/cli/dist/schema/src.json'
: 'node_modules/@fumadocs/cli/dist/schema/default.json',
)
.optional(),
aliases: z
.object({
uiDir: z.string().default(defaultAliases.uiDir),
+5 -1
View File
@@ -17,7 +17,7 @@ export function toImportSpecifier(
const extname = path.extname(referenceFile);
const removeExt = typescriptExtensions.includes(extname);
const importPath = path
let importPath = path
.relative(
path.dirname(sourceFile),
removeExt
@@ -26,5 +26,9 @@ export function toImportSpecifier(
)
.replaceAll(path.sep, '/');
if (removeExt && importPath.endsWith('/index')) {
importPath = importPath.slice(0, -'/index'.length);
}
return importPath.startsWith('../') ? importPath : `./${importPath}`;
}