@fumadocs/cli 0.2.1 → 1.0.1
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/build/index.d.ts +112 -91
- package/dist/build/index.js +264 -244
- package/dist/index.js +347 -784
- package/package.json +5 -5
- package/dist/chunk-DG6SFM2G.js +0 -19
package/dist/build/index.d.ts
CHANGED
|
@@ -1,128 +1,149 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import * as ts_morph from 'ts-morph';
|
|
3
|
+
import { Registry as Registry$1 } from 'shadcn/schema';
|
|
2
4
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type Output = z.infer<typeof rootSchema>;
|
|
6
|
+
type NamespaceType = (typeof namespaces)[number];
|
|
7
|
+
declare const namespaces: readonly ["components", "lib", "css", "route", "ui", "block"];
|
|
8
|
+
declare const rootSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
index: z.ZodArray<z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
title: z.ZodOptional<z.ZodString>;
|
|
13
|
+
description: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
components: z.ZodArray<z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
title: z.ZodOptional<z.ZodString>;
|
|
18
|
+
description: z.ZodOptional<z.ZodString>;
|
|
19
|
+
files: z.ZodArray<z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"components" | "lib" | "css" | "route" | "ui" | "block">;
|
|
21
|
+
path: z.ZodString;
|
|
22
|
+
target: z.ZodOptional<z.ZodString>;
|
|
23
|
+
content: z.ZodString;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
dependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
26
|
+
devDependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
27
|
+
subComponents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
|
|
31
|
+
type ComponentBuilder = ReturnType<typeof createComponentBuilder>;
|
|
32
|
+
/**
|
|
33
|
+
* @param registry registry object
|
|
34
|
+
* @param packageJson parsed package json object
|
|
35
|
+
*/
|
|
36
|
+
declare function createComponentBuilder(registry: Registry, packageJson: PackageJson | undefined): {
|
|
37
|
+
registryDir: string;
|
|
38
|
+
registry: Registry;
|
|
39
|
+
getDepFromSpecifier(specifier: string): string;
|
|
40
|
+
getDepInfo(name: string): {
|
|
41
|
+
type: "runtime" | "dev";
|
|
42
|
+
name: string;
|
|
43
|
+
version: string | null;
|
|
44
|
+
} | undefined;
|
|
45
|
+
createSourceFile(file: string): Promise<ts_morph.SourceFile>;
|
|
46
|
+
getComponentByName(name: string): Component | undefined;
|
|
47
|
+
getSubComponent(file: string): {
|
|
48
|
+
component: Component;
|
|
49
|
+
file: ComponentFile;
|
|
50
|
+
} | undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type SourceReference = {
|
|
54
|
+
type: 'file';
|
|
7
55
|
/**
|
|
8
|
-
*
|
|
56
|
+
* Absolute path
|
|
9
57
|
*/
|
|
10
|
-
|
|
58
|
+
file: string;
|
|
11
59
|
} | {
|
|
12
60
|
type: 'dependency';
|
|
13
|
-
|
|
14
|
-
|
|
61
|
+
dep: string;
|
|
62
|
+
specifier: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'sub-component';
|
|
65
|
+
resolved: {
|
|
66
|
+
type: 'local';
|
|
67
|
+
component: Component;
|
|
68
|
+
file: ComponentFile;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'remote';
|
|
71
|
+
component: Component;
|
|
72
|
+
file: ComponentFile;
|
|
73
|
+
registryName: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
type Reference = SourceReference | {
|
|
77
|
+
type: 'custom';
|
|
78
|
+
specifier: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type OnResolve = (reference: SourceReference) => Reference;
|
|
82
|
+
interface ComponentFile {
|
|
83
|
+
type: NamespaceType;
|
|
84
|
+
path: string;
|
|
85
|
+
target?: string;
|
|
86
|
+
}
|
|
15
87
|
interface Component {
|
|
16
88
|
name: string;
|
|
89
|
+
title?: string;
|
|
17
90
|
description?: string;
|
|
18
|
-
files:
|
|
19
|
-
in: string;
|
|
20
|
-
out: string;
|
|
21
|
-
})[];
|
|
91
|
+
files: ComponentFile[];
|
|
22
92
|
/**
|
|
23
93
|
* Don't list the component in registry index file
|
|
24
94
|
*/
|
|
25
95
|
unlisted?: boolean;
|
|
26
96
|
/**
|
|
27
|
-
* Map imported file paths,
|
|
97
|
+
* Map imported file paths, inherit from registry if not defined.
|
|
28
98
|
*/
|
|
29
|
-
|
|
99
|
+
onResolve?: OnResolve;
|
|
30
100
|
}
|
|
31
|
-
type NamespaceType = 'components' | 'hooks' | 'lib';
|
|
32
101
|
interface PackageJson {
|
|
33
102
|
dependencies: Record<string, string>;
|
|
34
103
|
devDependencies: Record<string, string>;
|
|
35
104
|
}
|
|
36
105
|
interface Registry {
|
|
106
|
+
name: string;
|
|
107
|
+
packageJson: string | PackageJson;
|
|
108
|
+
tsconfigPath: string;
|
|
109
|
+
components: Component[];
|
|
37
110
|
/**
|
|
38
|
-
* The directory of registry,
|
|
111
|
+
* The directory of registry, used to resolve relative paths
|
|
39
112
|
*/
|
|
40
113
|
dir: string;
|
|
41
|
-
/**
|
|
42
|
-
* Extend on existing registry
|
|
43
|
-
*/
|
|
44
|
-
on?: Record<string, {
|
|
45
|
-
type: 'remote';
|
|
46
|
-
registry: Output;
|
|
47
|
-
} | {
|
|
48
|
-
type: 'local';
|
|
49
|
-
registry: Registry;
|
|
50
|
-
}>;
|
|
51
|
-
/**
|
|
52
|
-
* The root directory project, used to resolve config paths
|
|
53
|
-
*/
|
|
54
|
-
rootDir: string;
|
|
55
|
-
namespaces?: Record<string, NamespaceType>;
|
|
56
|
-
tsconfigPath?: string;
|
|
57
|
-
packageJson?: string | PackageJson;
|
|
58
|
-
components: Component[];
|
|
59
114
|
/**
|
|
60
115
|
* Map import paths of components
|
|
61
116
|
*/
|
|
62
|
-
|
|
63
|
-
dependencies?: Record<string, {
|
|
64
|
-
type: 'runtime' | 'dev';
|
|
65
|
-
version?: string;
|
|
66
|
-
}>;
|
|
67
|
-
}
|
|
68
|
-
interface Output {
|
|
69
|
-
index: OutputIndex[];
|
|
70
|
-
components: OutputComponent[];
|
|
71
|
-
}
|
|
72
|
-
interface OutputIndex {
|
|
73
|
-
name: string;
|
|
74
|
-
description?: string;
|
|
75
|
-
}
|
|
76
|
-
interface OutputFile {
|
|
77
|
-
path: string;
|
|
78
|
-
content: string;
|
|
117
|
+
onResolve?: OnResolve;
|
|
79
118
|
/**
|
|
80
|
-
*
|
|
119
|
+
* When a referenced file is not found in component files, this function is called.
|
|
81
120
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
name: string;
|
|
86
|
-
files: OutputFile[];
|
|
87
|
-
dependencies: Record<string, string>;
|
|
88
|
-
devDependencies: Record<string, string>;
|
|
89
|
-
subComponents: string[];
|
|
121
|
+
onUnknownFile?: (absolutePath: string) => ComponentFile | undefined;
|
|
122
|
+
dependencies?: Record<string, string | null>;
|
|
123
|
+
devDependencies?: Record<string, string | null>;
|
|
90
124
|
}
|
|
91
125
|
declare function build(registry: Registry): Promise<Output>;
|
|
92
126
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
type GetComponentResult = {
|
|
98
|
-
type: 'local';
|
|
99
|
-
registryName?: string;
|
|
100
|
-
component: Component;
|
|
101
|
-
} | {
|
|
102
|
-
type: 'remote';
|
|
103
|
-
registryName: string;
|
|
104
|
-
component: OutputComponent;
|
|
105
|
-
};
|
|
106
|
-
type ComponentBuilder = ReturnType<typeof createComponentBuilder>;
|
|
107
|
-
/**
|
|
108
|
-
* @param registry registry object
|
|
109
|
-
* @param packageJson parsed package json object
|
|
110
|
-
*/
|
|
111
|
-
declare function createComponentBuilder(registry: Registry, packageJson: PackageJson | undefined): {
|
|
112
|
-
registryDir: string;
|
|
113
|
-
registry: Registry;
|
|
114
|
-
resolveDep(specifier: string): DependencyInfo & {
|
|
115
|
-
name: string;
|
|
116
|
-
};
|
|
117
|
-
createSourceFile(file: string): Promise<ts_morph.SourceFile>;
|
|
118
|
-
getComponentByName(name: string, registryName?: string): GetComponentResult | undefined;
|
|
119
|
-
resolveOutputPath(file: string, registryName?: string, namespace?: string): string;
|
|
120
|
-
getSubComponent(file: string): Component | undefined;
|
|
127
|
+
declare function toShadcnRegistry(out: Output, baseUrl: string): {
|
|
128
|
+
registry: Registry$1;
|
|
129
|
+
index: Registry$1;
|
|
121
130
|
};
|
|
122
131
|
|
|
123
|
-
declare function
|
|
132
|
+
declare function combineRegistry(...items: Output[]): Output;
|
|
133
|
+
declare function writeShadcnRegistry(out: Output, options: {
|
|
134
|
+
dir: string;
|
|
135
|
+
/**
|
|
136
|
+
* Remove previous outputs
|
|
137
|
+
*
|
|
138
|
+
* @defaultValue false
|
|
139
|
+
*/
|
|
140
|
+
cleanDir?: boolean;
|
|
141
|
+
baseUrl: string;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
declare function writeFumadocsRegistry(out: Output, options: {
|
|
144
|
+
dir: string;
|
|
124
145
|
/**
|
|
125
|
-
* Remove
|
|
146
|
+
* Remove previous outputs
|
|
126
147
|
*
|
|
127
148
|
* @defaultValue false
|
|
128
149
|
*/
|
|
@@ -130,4 +151,4 @@ declare function writeOutput(dir: string, out: Output, options?: {
|
|
|
130
151
|
log?: boolean;
|
|
131
152
|
}): Promise<void>;
|
|
132
153
|
|
|
133
|
-
export { type Component, type ComponentBuilder, type
|
|
154
|
+
export { type Component, type ComponentBuilder, type ComponentFile, type OnResolve, type PackageJson, type Registry, build, combineRegistry, createComponentBuilder, toShadcnRegistry, writeFumadocsRegistry, writeShadcnRegistry };
|