@fumadocs/cli 1.1.0 → 1.2.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 +163 -139
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +265 -405
- package/dist/build/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +592 -628
- package/dist/index.js.map +1 -0
- package/dist/schema/default.json +1 -0
- package/dist/schema/src.json +1 -0
- package/package.json +20 -20
package/dist/build/index.d.ts
CHANGED
|
@@ -1,155 +1,179 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import
|
|
3
|
-
import { Registry as Registry$1 } from 'shadcn/schema';
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Project, SourceFile } from "ts-morph";
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
//#region src/registry/schema.d.ts
|
|
6
5
|
type NamespaceType = (typeof namespaces)[number];
|
|
6
|
+
type CompiledComponent = z.input<typeof componentSchema>;
|
|
7
7
|
declare const namespaces: readonly ["components", "lib", "css", "route", "ui", "block"];
|
|
8
|
-
declare const
|
|
8
|
+
declare const componentSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
title: z.ZodOptional<z.ZodString>;
|
|
11
|
+
description: z.ZodOptional<z.ZodString>;
|
|
12
|
+
files: z.ZodArray<z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"components" | "lib" | "css" | "route" | "ui" | "block">;
|
|
14
|
+
path: z.ZodString;
|
|
15
|
+
target: z.ZodOptional<z.ZodString>;
|
|
16
|
+
content: z.ZodString;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
dependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
19
|
+
devDependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
20
|
+
subComponents: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
21
|
+
type: z.ZodLiteral<"http">;
|
|
22
|
+
baseUrl: z.ZodString;
|
|
23
|
+
component: z.ZodString;
|
|
24
|
+
}, z.core.$strip>]>>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
declare const registryInfoSchema: z.ZodObject<{
|
|
27
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
28
|
+
description: z.ZodOptional<z.ZodString>;
|
|
29
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
30
|
+
}, z.core.$strip>>>;
|
|
31
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
32
|
+
indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
9
33
|
name: z.ZodString;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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>>;
|
|
34
|
+
title: z.ZodOptional<z.ZodString>;
|
|
35
|
+
description: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>>>;
|
|
37
|
+
registries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
38
|
}, z.core.$strip>;
|
|
30
|
-
|
|
31
|
-
|
|
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';
|
|
55
|
-
/**
|
|
56
|
-
* Absolute path
|
|
57
|
-
*/
|
|
58
|
-
file: string;
|
|
59
|
-
} | {
|
|
60
|
-
type: 'dependency';
|
|
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
|
-
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/build/compiler.d.ts
|
|
81
41
|
type OnResolve = (reference: SourceReference) => Reference;
|
|
42
|
+
interface CompiledRegistry {
|
|
43
|
+
name: string;
|
|
44
|
+
components: CompiledComponent[];
|
|
45
|
+
info: z.output<typeof registryInfoSchema>;
|
|
46
|
+
}
|
|
82
47
|
interface ComponentFile {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
48
|
+
type: NamespaceType;
|
|
49
|
+
path: string;
|
|
50
|
+
target?: string;
|
|
86
51
|
}
|
|
87
52
|
interface Component {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
53
|
+
name: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
files: ComponentFile[];
|
|
57
|
+
/**
|
|
58
|
+
* Don't list the component in registry index file
|
|
59
|
+
*/
|
|
60
|
+
unlisted?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Map imported file paths, inherit from registry if not defined.
|
|
63
|
+
*/
|
|
64
|
+
onResolve?: OnResolve;
|
|
100
65
|
}
|
|
101
66
|
interface PackageJson {
|
|
102
|
-
|
|
103
|
-
|
|
67
|
+
dependencies?: Record<string, string>;
|
|
68
|
+
devDependencies?: Record<string, string>;
|
|
104
69
|
}
|
|
105
|
-
interface Registry {
|
|
70
|
+
interface Registry extends Omit<z.input<typeof registryInfoSchema>, 'indexes'> {
|
|
71
|
+
name: string;
|
|
72
|
+
packageJson: string | PackageJson;
|
|
73
|
+
tsconfigPath: string;
|
|
74
|
+
components: Component[];
|
|
75
|
+
/**
|
|
76
|
+
* The directory of registry, used to resolve relative paths
|
|
77
|
+
*/
|
|
78
|
+
dir: string;
|
|
79
|
+
/**
|
|
80
|
+
* Map import paths of components
|
|
81
|
+
*/
|
|
82
|
+
onResolve?: OnResolve;
|
|
83
|
+
/**
|
|
84
|
+
* When a referenced file is not found in component files, this function is called.
|
|
85
|
+
* @returns file, or `false` to mark as external.
|
|
86
|
+
*/
|
|
87
|
+
onUnknownFile?: (absolutePath: string) => ComponentFile | false | undefined;
|
|
88
|
+
dependencies?: Record<string, string | null>;
|
|
89
|
+
devDependencies?: Record<string, string | null>;
|
|
90
|
+
}
|
|
91
|
+
declare class RegistryCompiler {
|
|
92
|
+
readonly raw: Registry;
|
|
93
|
+
readonly project: Project;
|
|
94
|
+
resolver: RegistryResolver;
|
|
95
|
+
constructor(registry: Registry);
|
|
96
|
+
private readPackageJson;
|
|
97
|
+
createSourceFile(file: string): Promise<SourceFile>;
|
|
98
|
+
compile(): Promise<CompiledRegistry>;
|
|
99
|
+
}
|
|
100
|
+
declare class RegistryResolver {
|
|
101
|
+
private readonly compiler;
|
|
102
|
+
private readonly deps;
|
|
103
|
+
private readonly devDeps;
|
|
104
|
+
private readonly fileToComponent;
|
|
105
|
+
constructor(compiler: RegistryCompiler, packageJson?: PackageJson);
|
|
106
|
+
getDepFromSpecifier(specifier: string): string;
|
|
107
|
+
getDepInfo(name: string): {
|
|
108
|
+
type: 'runtime' | 'dev';
|
|
106
109
|
name: string;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Map import paths of components
|
|
116
|
-
*/
|
|
117
|
-
onResolve?: OnResolve;
|
|
118
|
-
/**
|
|
119
|
-
* When a referenced file is not found in component files, this function is called.
|
|
120
|
-
* @returns file, or `false` to mark as external.
|
|
121
|
-
*/
|
|
122
|
-
onUnknownFile?: (absolutePath: string) => ComponentFile | false | undefined;
|
|
123
|
-
dependencies?: Record<string, string | null>;
|
|
124
|
-
devDependencies?: Record<string, string | null>;
|
|
110
|
+
version: string | null;
|
|
111
|
+
} | undefined;
|
|
112
|
+
getComponentByName(name: string): Component | undefined;
|
|
113
|
+
getSubComponent(file: string): {
|
|
114
|
+
component: Component;
|
|
115
|
+
file: ComponentFile;
|
|
116
|
+
} | undefined;
|
|
125
117
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
type SourceReference = {
|
|
119
|
+
type: 'file';
|
|
120
|
+
/**
|
|
121
|
+
* Absolute path
|
|
122
|
+
*/
|
|
123
|
+
file: string;
|
|
124
|
+
} | {
|
|
125
|
+
type: 'dependency';
|
|
126
|
+
dep: string;
|
|
127
|
+
specifier: string;
|
|
128
|
+
} | {
|
|
129
|
+
type: 'sub-component';
|
|
130
|
+
resolved: {
|
|
131
|
+
type: 'local';
|
|
132
|
+
component: Component;
|
|
133
|
+
file: ComponentFile;
|
|
134
|
+
} | {
|
|
135
|
+
type: 'remote';
|
|
136
|
+
component: Component;
|
|
137
|
+
file: ComponentFile;
|
|
138
|
+
registryName: string;
|
|
139
|
+
};
|
|
131
140
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
141
|
+
type Reference = SourceReference | {
|
|
142
|
+
type: 'custom';
|
|
143
|
+
specifier: string;
|
|
144
|
+
};
|
|
145
|
+
declare class ComponentCompiler {
|
|
146
|
+
private readonly compiler;
|
|
147
|
+
private readonly component;
|
|
148
|
+
private readonly processedFiles;
|
|
149
|
+
private readonly registry;
|
|
150
|
+
private readonly subComponents;
|
|
151
|
+
private readonly devDependencies;
|
|
152
|
+
private readonly dependencies;
|
|
153
|
+
constructor(compiler: RegistryCompiler, component: Component);
|
|
154
|
+
private toImportPath;
|
|
155
|
+
build(): Promise<CompiledComponent>;
|
|
156
|
+
private buildFileAndDeps;
|
|
157
|
+
private resolveImport;
|
|
158
|
+
private buildFile;
|
|
159
|
+
}
|
|
160
|
+
declare function resolveFromRemote(r: Registry, component: string, selectFile: (file: ComponentFile) => boolean): Reference | undefined;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/build/index.d.ts
|
|
163
|
+
interface MonoRegistry extends CompiledRegistry {
|
|
164
|
+
registries: CompiledRegistry[];
|
|
165
|
+
}
|
|
166
|
+
declare function combineRegistry(root: CompiledRegistry, ...items: CompiledRegistry[]): MonoRegistry;
|
|
167
|
+
declare function writeFumadocsRegistry(out: CompiledRegistry | MonoRegistry, options: {
|
|
168
|
+
dir: string;
|
|
169
|
+
/**
|
|
170
|
+
* Remove previous outputs
|
|
171
|
+
*
|
|
172
|
+
* @defaultValue false
|
|
173
|
+
*/
|
|
174
|
+
cleanDir?: boolean;
|
|
175
|
+
log?: boolean;
|
|
153
176
|
}): Promise<void>;
|
|
154
|
-
|
|
155
|
-
export {
|
|
177
|
+
//#endregion
|
|
178
|
+
export { CompiledRegistry, Component, ComponentCompiler, ComponentFile, MonoRegistry, OnResolve, PackageJson, Reference, Registry, RegistryCompiler, SourceReference, combineRegistry, resolveFromRemote, writeFumadocsRegistry };
|
|
179
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/registry/schema.ts","../../src/build/compiler.ts","../../src/build/index.ts"],"sourcesContent":[],"mappings":";;;;KAEY,aAAA,WAAwB;KAExB,iBAAA,GAAoB,CAAA,CAAE,aAAa;cAMlC;cAqBA,iBAAe,CAAA,CAAA;;;;;;;;;;;;;;;;EAAA,CAAA,eAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CAAA,eAAA,CAAA;AAaf,cAAA,kBAoBX,EApB6B,CAAA,CAAA,SAoB7B,CAAA;;;;;;;;;;;;;;;KCpDU,SAAA,eAAwB,oBAAoB;ADV5C,UCYK,gBAAA,CDZmB;EAExB,IAAA,EAAA,M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