@tanstack/cli 0.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.
@@ -0,0 +1,334 @@
1
+ import { z } from 'zod'
2
+
3
+ // Package manager options
4
+ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'deno'
5
+
6
+ // Feature categories for UI grouping
7
+ export const CategorySchema = z.enum([
8
+ 'tanstack',
9
+ 'database',
10
+ 'orm',
11
+ 'auth',
12
+ 'deploy',
13
+ 'tooling',
14
+ 'monitoring',
15
+ 'api',
16
+ 'i18n',
17
+ 'cms',
18
+ 'other',
19
+ ])
20
+ export type Category = z.infer<typeof CategorySchema>
21
+
22
+ // Integration types
23
+ export const IntegrationTypeSchema = z.enum([
24
+ 'integration',
25
+ 'example',
26
+ 'toolchain',
27
+ 'deployment',
28
+ ])
29
+ export type IntegrationType = z.infer<typeof IntegrationTypeSchema>
30
+
31
+ // Integration phases
32
+ export const IntegrationPhaseSchema = z.enum(['setup', 'integration', 'example'])
33
+ export type IntegrationPhase = z.infer<typeof IntegrationPhaseSchema>
34
+
35
+ // Router modes
36
+ export const RouterModeSchema = z.enum(['file-router', 'code-router'])
37
+ export type RouterMode = z.infer<typeof RouterModeSchema>
38
+
39
+ // Option schemas
40
+ export const SelectOptionSchema = z.object({
41
+ type: z.literal('select'),
42
+ label: z.string(),
43
+ description: z.string().optional(),
44
+ default: z.string(),
45
+ options: z.array(
46
+ z.object({
47
+ value: z.string(),
48
+ label: z.string(),
49
+ }),
50
+ ),
51
+ })
52
+
53
+ export const BooleanOptionSchema = z.object({
54
+ type: z.literal('boolean'),
55
+ label: z.string(),
56
+ description: z.string().optional(),
57
+ default: z.boolean(),
58
+ })
59
+
60
+ export const StringOptionSchema = z.object({
61
+ type: z.literal('string'),
62
+ label: z.string(),
63
+ description: z.string().optional(),
64
+ default: z.string(),
65
+ })
66
+
67
+ export const IntegrationOptionSchema = z.discriminatedUnion('type', [
68
+ SelectOptionSchema,
69
+ BooleanOptionSchema,
70
+ StringOptionSchema,
71
+ ])
72
+ export type IntegrationOption = z.infer<typeof IntegrationOptionSchema>
73
+
74
+ export const IntegrationOptionsSchema = z.record(z.string(), IntegrationOptionSchema)
75
+ export type IntegrationOptions = z.infer<typeof IntegrationOptionsSchema>
76
+
77
+ // Hook schemas (code injection points)
78
+ export const HookTypeSchema = z.enum([
79
+ 'header-user',
80
+ 'provider',
81
+ 'root-provider',
82
+ 'layout',
83
+ 'vite-plugin',
84
+ 'devtools',
85
+ 'entry-client',
86
+ ])
87
+ export type HookType = z.infer<typeof HookTypeSchema>
88
+
89
+ export const HookSchema = z.object({
90
+ type: HookTypeSchema.optional(),
91
+ path: z.string().optional(),
92
+ jsName: z.string().optional(),
93
+ import: z.string().optional(),
94
+ code: z.string().optional(),
95
+ })
96
+ export type Hook = z.infer<typeof HookSchema>
97
+
98
+ // Route schema
99
+ export interface Route {
100
+ url?: string
101
+ name?: string
102
+ icon?: string
103
+ path: string
104
+ jsName: string
105
+ children?: Array<Route>
106
+ }
107
+
108
+ export const RouteSchema: z.ZodType<Route> = z.object({
109
+ url: z.string().optional(),
110
+ name: z.string().optional(),
111
+ icon: z.string().optional(),
112
+ path: z.string(),
113
+ jsName: z.string(),
114
+ children: z.array(z.lazy(() => RouteSchema)).optional(),
115
+ })
116
+
117
+ // Environment variable schema
118
+ export const EnvVarSchema = z.object({
119
+ name: z.string(),
120
+ description: z.string(),
121
+ required: z.boolean().optional(),
122
+ example: z.string().optional(),
123
+ })
124
+ export type EnvVar = z.infer<typeof EnvVarSchema>
125
+
126
+ // Command schema
127
+ export const CommandSchema = z.object({
128
+ command: z.string(),
129
+ args: z.array(z.string()).optional(),
130
+ })
131
+ export type Command = z.infer<typeof CommandSchema>
132
+
133
+ // Integration info schema (what's in info.json)
134
+ export const IntegrationInfoSchema = z.object({
135
+ // Identity
136
+ id: z.string().optional(), // Auto-generated from directory name
137
+ name: z.string(),
138
+ description: z.string(),
139
+ author: z.string().optional(),
140
+ version: z.string().optional(),
141
+ link: z.string().optional(),
142
+ license: z.string().optional(),
143
+ warning: z.string().optional(),
144
+
145
+ // Classification
146
+ type: IntegrationTypeSchema,
147
+ phase: IntegrationPhaseSchema,
148
+ category: CategorySchema.optional(),
149
+ modes: z.array(RouterModeSchema),
150
+ priority: z.number().optional(),
151
+ default: z.boolean().optional(),
152
+
153
+ // Tailwind dependencies
154
+ // requiresTailwind: integration won't work without Tailwind (e.g., shadcn)
155
+ // demoRequiresTailwind: demo uses Tailwind, but core integration doesn't
156
+ requiresTailwind: z.boolean().optional(),
157
+ demoRequiresTailwind: z.boolean().optional(),
158
+
159
+ // Dependencies & conflicts
160
+ dependsOn: z.array(z.string()).optional(),
161
+ conflicts: z.array(z.string()).optional(),
162
+
163
+ // Partner integration
164
+ partnerId: z.string().optional(),
165
+
166
+ // Configuration
167
+ options: IntegrationOptionsSchema.optional(),
168
+
169
+ // Hooks (code injection points)
170
+ hooks: z.array(HookSchema).optional(),
171
+ routes: z.array(RouteSchema).optional(),
172
+
173
+ // Package additions
174
+ packageAdditions: z
175
+ .object({
176
+ dependencies: z.record(z.string(), z.string()).optional(),
177
+ devDependencies: z.record(z.string(), z.string()).optional(),
178
+ scripts: z.record(z.string(), z.string()).optional(),
179
+ })
180
+ .optional(),
181
+
182
+ // Shadcn components to install
183
+ shadcnComponents: z.array(z.string()).optional(),
184
+
185
+ // Gitignore patterns to add
186
+ gitignorePatterns: z.array(z.string()).optional(),
187
+
188
+ // Environment variables
189
+ envVars: z.array(EnvVarSchema).optional(),
190
+
191
+ // Commands to run
192
+ command: CommandSchema.optional(),
193
+
194
+ // Special steps
195
+ integrationSpecialSteps: z.array(z.string()).optional(),
196
+ createSpecialSteps: z.array(z.string()).optional(),
197
+ postInitSpecialSteps: z.array(z.string()).optional(),
198
+
199
+ // Visual assets
200
+ smallLogo: z.string().optional(),
201
+ logo: z.string().optional(),
202
+ readme: z.string().optional(),
203
+ })
204
+ export type IntegrationInfo = z.infer<typeof IntegrationInfoSchema>
205
+
206
+ // Compiled integration (info + files)
207
+ export const IntegrationCompiledSchema = IntegrationInfoSchema.extend({
208
+ id: z.string(), // Required after compilation
209
+ files: z.record(z.string(), z.string()),
210
+ deletedFiles: z.array(z.string()).optional(),
211
+ })
212
+ export type IntegrationCompiled = z.infer<typeof IntegrationCompiledSchema>
213
+
214
+ // Custom template schema - a curated collection of integrations with preset options
215
+ // Custom templates are just integration presets, nothing more
216
+ export const CustomTemplateInfoSchema = z.object({
217
+ // Identity
218
+ id: z.string().optional(),
219
+ name: z.string(),
220
+ description: z.string(),
221
+
222
+ // Project defaults
223
+ framework: z.string(),
224
+ mode: RouterModeSchema,
225
+ typescript: z.boolean(),
226
+ tailwind: z.boolean(),
227
+
228
+ // Core: which integrations to include (integration IDs or custom integration URLs)
229
+ integrations: z.array(z.string()),
230
+
231
+ // Preset integration options
232
+ integrationOptions: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
233
+
234
+ // Display
235
+ banner: z.string().optional(),
236
+ })
237
+ export type CustomTemplateInfo = z.infer<typeof CustomTemplateInfoSchema>
238
+
239
+ export const CustomTemplateCompiledSchema = CustomTemplateInfoSchema.extend({
240
+ id: z.string(),
241
+ })
242
+ export type CustomTemplateCompiled = z.infer<typeof CustomTemplateCompiledSchema>
243
+
244
+ // Manifest schema (lightweight index of integrations)
245
+ export const ManifestIntegrationSchema = z.object({
246
+ id: z.string(),
247
+ name: z.string(),
248
+ description: z.string(),
249
+ type: IntegrationTypeSchema,
250
+ category: CategorySchema.optional(),
251
+ modes: z.array(RouterModeSchema),
252
+ dependsOn: z.array(z.string()).optional(),
253
+ conflicts: z.array(z.string()).optional(),
254
+ partnerId: z.string().optional(),
255
+ hasOptions: z.boolean().optional(),
256
+ link: z.string().optional(),
257
+ color: z.string().optional(),
258
+ // Tailwind dependencies
259
+ requiresTailwind: z.boolean().optional(),
260
+ demoRequiresTailwind: z.boolean().optional(),
261
+ })
262
+ export type ManifestIntegration = z.infer<typeof ManifestIntegrationSchema>
263
+
264
+ export const ManifestCustomTemplateSchema = z.object({
265
+ id: z.string(),
266
+ name: z.string(),
267
+ description: z.string(),
268
+ banner: z.string().optional(),
269
+ icon: z.string().optional(),
270
+ features: z.array(z.string()).optional(),
271
+ })
272
+ export type ManifestCustomTemplate = z.infer<typeof ManifestCustomTemplateSchema>
273
+
274
+ export const ManifestSchema = z.object({
275
+ version: z.string(),
276
+ generated: z.string(),
277
+ integrations: z.array(ManifestIntegrationSchema),
278
+ customTemplates: z.array(ManifestCustomTemplateSchema).optional(),
279
+ })
280
+ export type Manifest = z.infer<typeof ManifestSchema>
281
+
282
+ // Project definition (what the user configures)
283
+ export interface ProjectDefinition {
284
+ name: string
285
+ framework: string
286
+ mode: RouterMode
287
+ typescript: boolean
288
+ tailwind: boolean
289
+ integrations: Array<string>
290
+ integrationOptions: Record<string, Record<string, unknown>>
291
+ customTemplate?: string
292
+ }
293
+
294
+ // Compile options
295
+ export interface CompileOptions {
296
+ projectName: string
297
+ framework: string
298
+ mode: RouterMode
299
+ typescript: boolean
300
+ tailwind: boolean
301
+ packageManager: PackageManager
302
+ chosenIntegrations: Array<IntegrationCompiled>
303
+ integrationOptions: Record<string, Record<string, unknown>>
304
+ customTemplate?: CustomTemplateCompiled
305
+ }
306
+
307
+ // Compile output
308
+ export interface CompileOutput {
309
+ files: Record<string, string>
310
+ packages: {
311
+ dependencies: Record<string, string>
312
+ devDependencies: Record<string, string>
313
+ scripts: Record<string, string>
314
+ }
315
+ envVars: Array<EnvVar>
316
+ warnings: Array<string>
317
+ }
318
+
319
+ // Line attribution for showing which integration contributed each line
320
+ export interface LineAttribution {
321
+ lineNumber: number
322
+ featureId: string | 'base'
323
+ featureName: string
324
+ }
325
+
326
+ export interface AttributedFile {
327
+ path: string
328
+ content: string
329
+ attributions: Array<LineAttribution>
330
+ }
331
+
332
+ export interface AttributedCompileOutput extends CompileOutput {
333
+ attributedFiles: Record<string, AttributedFile>
334
+ }
package/src/index.ts ADDED
@@ -0,0 +1,85 @@
1
+ // Engine exports
2
+ export { compile, compileWithAttribution } from './engine/compile.js'
3
+ export { processTemplateFile, relativePath } from './engine/template.js'
4
+
5
+ // Config file exports
6
+ export {
7
+ CONFIG_FILE,
8
+ writeConfigFile,
9
+ readConfigFile,
10
+ } from './engine/config-file.js'
11
+ export type { PersistedOptions } from './engine/config-file.js'
12
+
13
+ // Custom integration/template exports
14
+ export { initIntegration, compileIntegration, loadRemoteIntegration } from './engine/custom-addons/integration.js'
15
+ export { initTemplate, compileTemplate, loadTemplate } from './engine/custom-addons/template.js'
16
+
17
+ // API exports
18
+ export {
19
+ fetchManifest,
20
+ fetchIntegration,
21
+ fetchIntegrations,
22
+ fetchIntegrationInfo,
23
+ fetchIntegrationFiles,
24
+ } from './api/fetch.js'
25
+
26
+ // Type exports
27
+ export type {
28
+ // Core types
29
+ PackageManager,
30
+ Category,
31
+ IntegrationType,
32
+ IntegrationPhase,
33
+ RouterMode,
34
+
35
+ // Option types
36
+ IntegrationOption,
37
+ IntegrationOptions,
38
+
39
+ // Hook types (code injection points)
40
+ HookType,
41
+ Hook,
42
+ Route,
43
+ EnvVar,
44
+ Command,
45
+
46
+ // Integration types
47
+ IntegrationInfo,
48
+ IntegrationCompiled,
49
+ CustomTemplateInfo,
50
+ CustomTemplateCompiled,
51
+
52
+ // Manifest types
53
+ ManifestIntegration,
54
+ Manifest,
55
+
56
+ // Project types
57
+ ProjectDefinition,
58
+ CompileOptions,
59
+ CompileOutput,
60
+
61
+ // Attribution types
62
+ LineAttribution,
63
+ AttributedFile,
64
+ AttributedCompileOutput,
65
+ } from './engine/types.js'
66
+
67
+ // Schema exports (for validation)
68
+ export {
69
+ CategorySchema,
70
+ IntegrationTypeSchema,
71
+ IntegrationPhaseSchema,
72
+ RouterModeSchema,
73
+ IntegrationOptionSchema,
74
+ IntegrationOptionsSchema,
75
+ HookSchema,
76
+ RouteSchema,
77
+ EnvVarSchema,
78
+ CommandSchema,
79
+ IntegrationInfoSchema,
80
+ IntegrationCompiledSchema,
81
+ CustomTemplateInfoSchema,
82
+ CustomTemplateCompiledSchema,
83
+ ManifestIntegrationSchema,
84
+ ManifestSchema,
85
+ } from './engine/types.js'
@@ -0,0 +1,5 @@
1
+ declare module 'parse-gitignore' {
2
+ export default function parseGitignore(
3
+ content: string | Buffer,
4
+ ): { patterns: Array<string> }
5
+ }