@fumadocs/cli 1.1.0 → 1.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.
@@ -1,84 +1,47 @@
1
1
  import { z } from 'zod';
2
- import * as ts_morph from 'ts-morph';
3
- import { Registry as Registry$1 } from 'shadcn/schema';
2
+ import { Project, SourceFile } from 'ts-morph';
4
3
 
5
- type Output = z.infer<typeof rootSchema>;
6
4
  type NamespaceType = (typeof namespaces)[number];
5
+ type CompiledComponent = z.input<typeof componentSchema>;
7
6
  declare const namespaces: readonly ["components", "lib", "css", "route", "ui", "block"];
8
- declare const rootSchema: z.ZodObject<{
7
+ declare const componentSchema: z.ZodObject<{
9
8
  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>;
9
+ title: z.ZodOptional<z.ZodString>;
10
+ description: z.ZodOptional<z.ZodString>;
11
+ files: z.ZodArray<z.ZodObject<{
12
+ type: z.ZodLiteral<"components" | "lib" | "css" | "route" | "ui" | "block">;
13
+ path: z.ZodString;
14
+ target: z.ZodOptional<z.ZodString>;
15
+ content: z.ZodString;
14
16
  }, z.core.$strip>>;
15
- components: z.ZodArray<z.ZodObject<{
17
+ dependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
18
+ devDependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
19
+ subComponents: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
20
+ type: z.ZodLiteral<"http">;
21
+ baseUrl: z.ZodString;
22
+ component: z.ZodString;
23
+ }, z.core.$strip>]>>>;
24
+ }, z.core.$strip>;
25
+ declare const registryInfoSchema: z.ZodObject<{
26
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
27
+ description: z.ZodOptional<z.ZodString>;
28
+ default: z.ZodOptional<z.ZodUnknown>;
29
+ }, z.core.$strip>>>;
30
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
31
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
16
32
  name: z.ZodString;
17
33
  title: z.ZodOptional<z.ZodString>;
18
34
  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>>;
35
+ }, z.core.$strip>>>;
36
+ registries: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
37
  }, z.core.$strip>;
30
38
 
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';
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
-
81
39
  type OnResolve = (reference: SourceReference) => Reference;
40
+ interface CompiledRegistry {
41
+ name: string;
42
+ components: CompiledComponent[];
43
+ info: z.output<typeof registryInfoSchema>;
44
+ }
82
45
  interface ComponentFile {
83
46
  type: NamespaceType;
84
47
  path: string;
@@ -99,10 +62,10 @@ interface Component {
99
62
  onResolve?: OnResolve;
100
63
  }
101
64
  interface PackageJson {
102
- dependencies: Record<string, string>;
103
- devDependencies: Record<string, string>;
65
+ dependencies?: Record<string, string>;
66
+ devDependencies?: Record<string, string>;
104
67
  }
105
- interface Registry {
68
+ interface Registry extends Omit<z.input<typeof registryInfoSchema>, 'indexes'> {
106
69
  name: string;
107
70
  packageJson: string | PackageJson;
108
71
  tsconfigPath: string;
@@ -123,25 +86,82 @@ interface Registry {
123
86
  dependencies?: Record<string, string | null>;
124
87
  devDependencies?: Record<string, string | null>;
125
88
  }
126
- declare function build(registry: Registry): Promise<Output>;
127
-
128
- declare function toShadcnRegistry(out: Output, baseUrl: string): {
129
- registry: Registry$1;
130
- index: Registry$1;
131
- };
132
-
133
- declare function combineRegistry(...items: Output[]): Output;
134
- declare function writeShadcnRegistry(out: Output, options: {
135
- dir: string;
89
+ declare class RegistryCompiler {
90
+ readonly raw: Registry;
91
+ readonly project: Project;
92
+ resolver: RegistryResolver;
93
+ constructor(registry: Registry);
94
+ private readPackageJson;
95
+ createSourceFile(file: string): Promise<SourceFile>;
96
+ compile(): Promise<CompiledRegistry>;
97
+ }
98
+ declare class RegistryResolver {
99
+ private readonly compiler;
100
+ private readonly deps;
101
+ private readonly devDeps;
102
+ private readonly fileToComponent;
103
+ constructor(compiler: RegistryCompiler, packageJson?: PackageJson);
104
+ getDepFromSpecifier(specifier: string): string;
105
+ getDepInfo(name: string): {
106
+ type: 'runtime' | 'dev';
107
+ name: string;
108
+ version: string | null;
109
+ } | undefined;
110
+ getComponentByName(name: string): Component | undefined;
111
+ getSubComponent(file: string): {
112
+ component: Component;
113
+ file: ComponentFile;
114
+ } | undefined;
115
+ }
116
+ type SourceReference = {
117
+ type: 'file';
136
118
  /**
137
- * Remove previous outputs
138
- *
139
- * @defaultValue false
119
+ * Absolute path
140
120
  */
141
- cleanDir?: boolean;
142
- baseUrl: string;
143
- }): Promise<void>;
144
- declare function writeFumadocsRegistry(out: Output, options: {
121
+ file: string;
122
+ } | {
123
+ type: 'dependency';
124
+ dep: string;
125
+ specifier: string;
126
+ } | {
127
+ type: 'sub-component';
128
+ resolved: {
129
+ type: 'local';
130
+ component: Component;
131
+ file: ComponentFile;
132
+ } | {
133
+ type: 'remote';
134
+ component: Component;
135
+ file: ComponentFile;
136
+ registryName: string;
137
+ };
138
+ };
139
+ type Reference = SourceReference | {
140
+ type: 'custom';
141
+ specifier: string;
142
+ };
143
+ declare class ComponentCompiler {
144
+ private readonly compiler;
145
+ private readonly component;
146
+ private readonly processedFiles;
147
+ private readonly registry;
148
+ private readonly subComponents;
149
+ private readonly devDependencies;
150
+ private readonly dependencies;
151
+ constructor(compiler: RegistryCompiler, component: Component);
152
+ private toImportPath;
153
+ build(): Promise<CompiledComponent>;
154
+ private buildFileAndDeps;
155
+ private resolveImport;
156
+ private buildFile;
157
+ }
158
+ declare function resolveFromRemote(r: Registry, component: string, selectFile: (file: ComponentFile) => boolean): Reference | undefined;
159
+
160
+ interface MonoRegistry extends CompiledRegistry {
161
+ registries: CompiledRegistry[];
162
+ }
163
+ declare function combineRegistry(root: CompiledRegistry, ...items: CompiledRegistry[]): MonoRegistry;
164
+ declare function writeFumadocsRegistry(out: CompiledRegistry | MonoRegistry, options: {
145
165
  dir: string;
146
166
  /**
147
167
  * Remove previous outputs
@@ -152,4 +172,4 @@ declare function writeFumadocsRegistry(out: Output, options: {
152
172
  log?: boolean;
153
173
  }): Promise<void>;
154
174
 
155
- export { type Component, type ComponentBuilder, type ComponentFile, type OnResolve, type PackageJson, type Registry, build, combineRegistry, createComponentBuilder, toShadcnRegistry, writeFumadocsRegistry, writeShadcnRegistry };
175
+ export { type CompiledRegistry, type Component, ComponentCompiler, type ComponentFile, type MonoRegistry, type OnResolve, type PackageJson, type Reference, type Registry, RegistryCompiler, type SourceReference, combineRegistry, resolveFromRemote, writeFumadocsRegistry };