chore: build registry
This commit is contained in:
parent
8982ec3862
commit
09cf6d56a8
|
|
@ -1102,6 +1102,13 @@ export const Index = {
|
||||||
component: () => import("../src/lib/registry/default/example/Cards/Metric.vue").then((m) => m.default),
|
component: () => import("../src/lib/registry/default/example/Cards/Metric.vue").then((m) => m.default),
|
||||||
files: ["../src/lib/registry/default/example/Cards/Metric.vue"],
|
files: ["../src/lib/registry/default/example/Cards/Metric.vue"],
|
||||||
},
|
},
|
||||||
|
"Authentication01": {
|
||||||
|
name: "Authentication01",
|
||||||
|
type: "components:block",
|
||||||
|
registryDependencies: ["button","card","input","label"],
|
||||||
|
component: () => import("../src/lib/registry/default/block/Authentication01.vue").then((m) => m.default),
|
||||||
|
files: ["../src/lib/registry/default/block/Authentication01.vue"],
|
||||||
|
},
|
||||||
}, "new-york": {
|
}, "new-york": {
|
||||||
"AccordionDemo": {
|
"AccordionDemo": {
|
||||||
name: "AccordionDemo",
|
name: "AccordionDemo",
|
||||||
|
|
@ -2202,5 +2209,12 @@ export const Index = {
|
||||||
component: () => import("../src/lib/registry/new-york/example/Cards/Metric.vue").then((m) => m.default),
|
component: () => import("../src/lib/registry/new-york/example/Cards/Metric.vue").then((m) => m.default),
|
||||||
files: ["../src/lib/registry/new-york/example/Cards/Metric.vue"],
|
files: ["../src/lib/registry/new-york/example/Cards/Metric.vue"],
|
||||||
},
|
},
|
||||||
|
"Authentication01": {
|
||||||
|
name: "Authentication01",
|
||||||
|
type: "components:block",
|
||||||
|
registryDependencies: ["button","card","input","label"],
|
||||||
|
component: () => import("../src/lib/registry/new-york/block/Authentication01.vue").then((m) => m.default),
|
||||||
|
files: ["../src/lib/registry/new-york/block/Authentication01.vue"],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,12 @@ export async function buildRegistry() {
|
||||||
const uiRegistry = await crawlUI(ui_path)
|
const uiRegistry = await crawlUI(ui_path)
|
||||||
|
|
||||||
const example_path = resolve('./src/lib/registry/default/example')
|
const example_path = resolve('./src/lib/registry/default/example')
|
||||||
const exampleRegistry = await crawlExample(example_path)
|
const exampleRegistry = await crawlDirectory(example_path, 'example')
|
||||||
|
|
||||||
return uiRegistry.concat(exampleRegistry)
|
const block_path = resolve('./src/lib/registry/default/block')
|
||||||
|
const blockRegistry = await crawlDirectory(block_path, 'block')
|
||||||
|
|
||||||
|
return uiRegistry.concat(exampleRegistry).concat(blockRegistry)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function crawlUI(rootPath: string) {
|
async function crawlUI(rootPath: string) {
|
||||||
|
|
@ -53,15 +56,15 @@ async function crawlUI(rootPath: string) {
|
||||||
return uiRegistry
|
return uiRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
async function crawlExample(rootPath: string) {
|
async function crawlDirectory(rootPath: string, typeName: 'example' | 'block') {
|
||||||
const type = 'components:example'
|
const type = `components:${typeName}` as const
|
||||||
|
|
||||||
const dir = await readdir(rootPath, {
|
const dir = await readdir(rootPath, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const exampleRegistry: Registry = []
|
const registry: Registry = []
|
||||||
|
|
||||||
for (const dirent of dir) {
|
for (const dirent of dir) {
|
||||||
if (dirent.name === 'index.ts')
|
if (dirent.name === 'index.ts')
|
||||||
|
|
@ -69,11 +72,11 @@ async function crawlExample(rootPath: string) {
|
||||||
|
|
||||||
if (dirent.isFile()) {
|
if (dirent.isFile()) {
|
||||||
const [name] = dirent.name.split('.vue')
|
const [name] = dirent.name.split('.vue')
|
||||||
const file_path = join('example', normalize(dirent.path).split('/example')[1], dirent.name)
|
const file_path = join(typeName, normalize(dirent.path).split(`/${typeName}`)[1], dirent.name)
|
||||||
const { dependencies, registryDependencies }
|
const { dependencies, registryDependencies }
|
||||||
= await getDependencies(join(dirent.path, dirent.name))
|
= await getDependencies(join(dirent.path, dirent.name))
|
||||||
|
|
||||||
exampleRegistry.push({
|
registry.push({
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
files: [file_path],
|
files: [file_path],
|
||||||
|
|
@ -87,14 +90,14 @@ async function crawlExample(rootPath: string) {
|
||||||
// if (dirent.isDirectory()) {
|
// if (dirent.isDirectory()) {
|
||||||
// const componentPath = resolve(rootPath, dirent.name);
|
// const componentPath = resolve(rootPath, dirent.name);
|
||||||
// const ui = await buildUIRegistry(componentPath, dirent.name);
|
// const ui = await buildUIRegistry(componentPath, dirent.name);
|
||||||
// exampleRegistry.push({
|
// registry.push({
|
||||||
// ...ui,
|
// ...ui,
|
||||||
// type
|
// type
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return exampleRegistry
|
return registry
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildUIRegistry(componentPath: string, componentName: string) {
|
async function buildUIRegistry(componentPath: string, componentName: string) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export const registrySchema = z.array(
|
||||||
'components:ui',
|
'components:ui',
|
||||||
'components:component',
|
'components:component',
|
||||||
'components:example',
|
'components:example',
|
||||||
|
'components:block',
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user