@tanstack/cli 0.0.7 → 0.48.2

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.
Files changed (83) hide show
  1. package/dist/bin.js +7 -0
  2. package/dist/cli.js +481 -0
  3. package/dist/command-line.js +174 -0
  4. package/dist/dev-watch.js +290 -0
  5. package/dist/file-syncer.js +148 -0
  6. package/dist/index.js +1 -0
  7. package/dist/mcp/api.js +31 -0
  8. package/dist/mcp/tools.js +250 -0
  9. package/dist/mcp/types.js +37 -0
  10. package/dist/mcp.js +121 -0
  11. package/dist/options.js +162 -0
  12. package/dist/types/bin.d.ts +2 -0
  13. package/dist/types/cli.d.ts +16 -0
  14. package/dist/types/command-line.d.ts +10 -0
  15. package/dist/types/dev-watch.d.ts +27 -0
  16. package/dist/types/file-syncer.d.ts +18 -0
  17. package/dist/types/index.d.ts +1 -0
  18. package/dist/types/mcp/api.d.ts +4 -0
  19. package/dist/types/mcp/tools.d.ts +2 -0
  20. package/dist/types/mcp/types.d.ts +217 -0
  21. package/dist/types/mcp.d.ts +6 -0
  22. package/dist/types/options.d.ts +8 -0
  23. package/dist/types/types.d.ts +25 -0
  24. package/dist/types/ui-environment.d.ts +2 -0
  25. package/dist/types/ui-prompts.d.ts +12 -0
  26. package/dist/types/utils.d.ts +8 -0
  27. package/dist/types.js +1 -0
  28. package/dist/ui-environment.js +52 -0
  29. package/dist/ui-prompts.js +244 -0
  30. package/dist/utils.js +30 -0
  31. package/package.json +46 -46
  32. package/src/bin.ts +6 -93
  33. package/src/cli.ts +692 -0
  34. package/src/command-line.ts +236 -0
  35. package/src/dev-watch.ts +430 -0
  36. package/src/file-syncer.ts +205 -0
  37. package/src/index.ts +1 -85
  38. package/src/mcp.ts +190 -0
  39. package/src/options.ts +260 -0
  40. package/src/types.ts +27 -0
  41. package/src/ui-environment.ts +74 -0
  42. package/src/ui-prompts.ts +322 -0
  43. package/src/utils.ts +38 -0
  44. package/tests/command-line.test.ts +304 -0
  45. package/tests/index.test.ts +9 -0
  46. package/tests/mcp.test.ts +225 -0
  47. package/tests/options.test.ts +304 -0
  48. package/tests/setupVitest.ts +6 -0
  49. package/tests/ui-environment.test.ts +97 -0
  50. package/tests/ui-prompts.test.ts +238 -0
  51. package/tsconfig.json +17 -0
  52. package/vitest.config.js +7 -0
  53. package/dist/bin.cjs +0 -761
  54. package/dist/bin.d.cts +0 -1
  55. package/dist/bin.d.mts +0 -1
  56. package/dist/bin.mjs +0 -760
  57. package/dist/index.cjs +0 -36
  58. package/dist/index.d.cts +0 -1172
  59. package/dist/index.d.mts +0 -1172
  60. package/dist/index.mjs +0 -3
  61. package/dist/template-CkAkdP8n.mjs +0 -2545
  62. package/dist/template-Cup47s9h.cjs +0 -2783
  63. package/src/api/fetch.test.ts +0 -114
  64. package/src/api/fetch.ts +0 -249
  65. package/src/cache/index.ts +0 -89
  66. package/src/commands/create.ts +0 -463
  67. package/src/commands/mcp.test.ts +0 -152
  68. package/src/commands/mcp.ts +0 -203
  69. package/src/engine/compile-with-addons.test.ts +0 -302
  70. package/src/engine/compile.test.ts +0 -404
  71. package/src/engine/compile.ts +0 -551
  72. package/src/engine/config-file.test.ts +0 -118
  73. package/src/engine/config-file.ts +0 -61
  74. package/src/engine/custom-addons/integration.ts +0 -323
  75. package/src/engine/custom-addons/shared.test.ts +0 -98
  76. package/src/engine/custom-addons/shared.ts +0 -281
  77. package/src/engine/custom-addons/template.test.ts +0 -288
  78. package/src/engine/custom-addons/template.ts +0 -124
  79. package/src/engine/template.test.ts +0 -256
  80. package/src/engine/template.ts +0 -269
  81. package/src/engine/types.ts +0 -336
  82. package/src/parse-gitignore.d.ts +0 -5
  83. package/src/templates/base.ts +0 -891
@@ -1,2545 +0,0 @@
1
- import { render } from "ejs";
2
- import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
3
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
4
- import { basename, dirname, extname, join, resolve } from "node:path";
5
- import { z } from "zod";
6
- import ignore from "ignore";
7
- import parseGitignore from "parse-gitignore";
8
- import { homedir } from "node:os";
9
-
10
- //#region src/engine/template.ts
11
- /**
12
- * Convert _dot_ prefixes to actual dots (for dotfiles)
13
- */
14
- function convertDotFiles(path) {
15
- return path.split("/").map((segment) => segment.replace(/^_dot_/, ".")).join("/");
16
- }
17
- /**
18
- * Strip option prefixes from filename
19
- * e.g., __postgres__schema.prisma -> schema.prisma
20
- */
21
- function stripOptionPrefix(path) {
22
- const match = path.match(/^(.+\/)?__([^_]+)__(.+)$/);
23
- if (match) {
24
- const [, directory, , filename] = match;
25
- return (directory || "") + filename;
26
- }
27
- return path;
28
- }
29
- /**
30
- * Calculate relative path between two file paths
31
- */
32
- function relativePath(from, to, stripExtension = false) {
33
- const fromParts = from.split("/").slice(0, -1);
34
- const toParts = to.split("/");
35
- let commonLength = 0;
36
- while (commonLength < fromParts.length && commonLength < toParts.length && fromParts[commonLength] === toParts[commonLength]) commonLength++;
37
- const upCount = fromParts.length - commonLength;
38
- const ups = Array(upCount).fill("..");
39
- const remainder = toParts.slice(commonLength);
40
- let result = [...ups, ...remainder].join("/");
41
- if (!result.startsWith(".")) result = "./" + result;
42
- if (stripExtension) result = result.replace(/\.[^/.]+$/, "");
43
- return result;
44
- }
45
- /**
46
- * Error thrown when ignoreFile() is called in a template
47
- */
48
- var IgnoreFileError = class extends Error {
49
- constructor() {
50
- super("ignoreFile");
51
- this.name = "IgnoreFileError";
52
- }
53
- };
54
- /**
55
- * Create template context from compile options
56
- */
57
- function createTemplateContext(options, currentFile) {
58
- const hooks = [];
59
- for (const integration of options.chosenIntegrations) if (integration.hooks) hooks.push(...integration.hooks);
60
- const routes = [];
61
- for (const integration of options.chosenIntegrations) if (integration.routes) routes.push(...integration.routes);
62
- const integrationEnabled = {};
63
- for (const integration of options.chosenIntegrations) integrationEnabled[integration.id] = true;
64
- const localRelativePath = (to, stripExt = false) => relativePath(currentFile, to, stripExt);
65
- const hookImportContent = (hook) => hook.import || `import ${hook.jsName} from '${localRelativePath(hook.path || "")}'`;
66
- const hookImportCode = (hook) => hook.code || hook.jsName || "";
67
- return {
68
- packageManager: options.packageManager,
69
- projectName: options.projectName,
70
- typescript: options.typescript,
71
- tailwind: options.tailwind,
72
- js: options.typescript ? "ts" : "js",
73
- jsx: options.typescript ? "tsx" : "jsx",
74
- fileRouter: options.mode === "file-router",
75
- codeRouter: options.mode === "code-router",
76
- integrationEnabled,
77
- integrationOption: options.integrationOptions,
78
- integrations: options.chosenIntegrations,
79
- hooks,
80
- routes,
81
- getPackageManagerAddScript: (pkg, isDev = false) => {
82
- const pm = options.packageManager;
83
- if (pm === "npm") return `npm install ${isDev ? "-D " : ""}${pkg}`;
84
- if (pm === "yarn") return `yarn add ${isDev ? "-D " : ""}${pkg}`;
85
- if (pm === "pnpm") return `pnpm add ${isDev ? "-D " : ""}${pkg}`;
86
- if (pm === "bun") return `bun add ${isDev ? "-d " : ""}${pkg}`;
87
- if (pm === "deno") return `deno add ${pkg}`;
88
- return `npm install ${isDev ? "-D " : ""}${pkg}`;
89
- },
90
- getPackageManagerRunScript: (script, args = []) => {
91
- const pm = options.packageManager;
92
- const argsStr = args.length ? " " + args.join(" ") : "";
93
- if (pm === "npm") return `npm run ${script}${argsStr}`;
94
- if (pm === "yarn") return `yarn ${script}${argsStr}`;
95
- if (pm === "pnpm") return `pnpm ${script}${argsStr}`;
96
- if (pm === "bun") return `bun run ${script}${argsStr}`;
97
- if (pm === "deno") return `deno task ${script}${argsStr}`;
98
- return `npm run ${script}${argsStr}`;
99
- },
100
- relativePath: localRelativePath,
101
- hookImportContent,
102
- hookImportCode,
103
- ignoreFile: () => {
104
- throw new IgnoreFileError();
105
- }
106
- };
107
- }
108
- /**
109
- * Process a template file with EJS
110
- */
111
- function processTemplateFile(filePath, content, options) {
112
- const context = createTemplateContext(options, filePath);
113
- let processedContent = content;
114
- let shouldIgnore = false;
115
- if (filePath.endsWith(".ejs")) try {
116
- processedContent = render(content, context);
117
- } catch (error) {
118
- if (error instanceof IgnoreFileError) shouldIgnore = true;
119
- else throw new Error(`EJS error in file ${filePath}: ${error}`);
120
- }
121
- if (shouldIgnore) return null;
122
- let outputPath = filePath;
123
- outputPath = outputPath.replace(/\.ejs$/, "");
124
- outputPath = convertDotFiles(outputPath);
125
- outputPath = stripOptionPrefix(outputPath);
126
- let append = false;
127
- if (outputPath.endsWith(".append")) {
128
- append = true;
129
- outputPath = outputPath.replace(/\.append$/, "");
130
- }
131
- if (!options.typescript) outputPath = outputPath.replace(/\.tsx$/, ".jsx").replace(/\.ts$/, ".js");
132
- return {
133
- path: outputPath,
134
- content: processedContent,
135
- append
136
- };
137
- }
138
-
139
- //#endregion
140
- //#region src/templates/base.ts
141
- /**
142
- * Base TanStack Start template files
143
- * These provide the foundation for every project
144
- */
145
- /**
146
- * Collect all hooks from integrations, grouped by type
147
- */
148
- function collectHooks(options) {
149
- const hooks = [];
150
- for (const integration of options.chosenIntegrations) if (integration.hooks) for (const hook of integration.hooks) hooks.push({
151
- ...hook,
152
- integrationId: integration.id
153
- });
154
- return {
155
- vitePlugins: hooks.filter((i) => i.type === "vite-plugin"),
156
- rootProviders: hooks.filter((i) => i.type === "root-provider"),
157
- devtoolsPlugins: hooks.filter((i) => i.type === "devtools"),
158
- entryClientInits: hooks.filter((i) => i.type === "entry-client")
159
- };
160
- }
161
- /**
162
- * Generate vite.config.ts content with line attribution
163
- */
164
- function generateViteConfig(options, vitePlugins) {
165
- const { tailwind } = options;
166
- const lines = [];
167
- lines.push({
168
- text: `import { defineConfig } from 'vite'`,
169
- integrationId: "base"
170
- });
171
- lines.push({
172
- text: `import { tanstackStart } from '@tanstack/react-start/plugin/vite'`,
173
- integrationId: "base"
174
- });
175
- lines.push({
176
- text: `import viteReact from '@vitejs/plugin-react'`,
177
- integrationId: "base"
178
- });
179
- lines.push({
180
- text: `import viteTsConfigPaths from 'vite-tsconfig-paths'`,
181
- integrationId: "base"
182
- });
183
- if (tailwind) lines.push({
184
- text: `import tailwindcss from '@tailwindcss/vite'`,
185
- integrationId: "base"
186
- });
187
- for (const plugin of vitePlugins) if (plugin.import) lines.push({
188
- text: plugin.import,
189
- integrationId: plugin.integrationId
190
- });
191
- else {
192
- const importPath = relativePath("vite.config.ts", plugin.path || `src/integrations/${plugin.integrationId}/vite-plugin.ts`, true);
193
- lines.push({
194
- text: `import ${plugin.jsName} from '${importPath}'`,
195
- integrationId: plugin.integrationId
196
- });
197
- }
198
- lines.push({
199
- text: "",
200
- integrationId: "base"
201
- });
202
- lines.push({
203
- text: `export default defineConfig({`,
204
- integrationId: "base"
205
- });
206
- lines.push({
207
- text: ` plugins: [`,
208
- integrationId: "base"
209
- });
210
- lines.push({
211
- text: ` viteTsConfigPaths({`,
212
- integrationId: "base"
213
- });
214
- lines.push({
215
- text: ` projects: ['./tsconfig.json'],`,
216
- integrationId: "base"
217
- });
218
- lines.push({
219
- text: ` }),`,
220
- integrationId: "base"
221
- });
222
- if (tailwind) lines.push({
223
- text: ` tailwindcss(),`,
224
- integrationId: "base"
225
- });
226
- lines.push({
227
- text: ` tanstackStart(),`,
228
- integrationId: "base"
229
- });
230
- lines.push({
231
- text: ` viteReact(),`,
232
- integrationId: "base"
233
- });
234
- for (const plugin of vitePlugins) {
235
- const pluginCall = plugin.code || `${plugin.jsName}()`;
236
- lines.push({
237
- text: ` ${pluginCall},`,
238
- integrationId: plugin.integrationId
239
- });
240
- }
241
- lines.push({
242
- text: ` ],`,
243
- integrationId: "base"
244
- });
245
- lines.push({
246
- text: `})`,
247
- integrationId: "base"
248
- });
249
- return {
250
- content: lines.map((l) => l.text).join("\n"),
251
- lineAttributions: lines.map((l, i) => ({
252
- line: i + 1,
253
- integrationId: l.integrationId
254
- }))
255
- };
256
- }
257
- /**
258
- * Generate entry-client.tsx content with line attribution
259
- */
260
- function generateEntryClient(_options, entryClientInits) {
261
- const lines = [];
262
- lines.push({
263
- text: `import { hydrateRoot } from 'react-dom/client'`,
264
- integrationId: "base"
265
- });
266
- lines.push({
267
- text: `import { StartClient } from '@tanstack/react-start'`,
268
- integrationId: "base"
269
- });
270
- lines.push({
271
- text: `import { getRouter } from './router'`,
272
- integrationId: "base"
273
- });
274
- for (const init of entryClientInits) {
275
- const importPath = relativePath("src/entry-client.tsx", init.path || `src/integrations/${init.integrationId}/client.ts`, true);
276
- lines.push({
277
- text: `import { ${init.jsName} } from '${importPath}'`,
278
- integrationId: init.integrationId
279
- });
280
- }
281
- lines.push({
282
- text: "",
283
- integrationId: "base"
284
- });
285
- if (entryClientInits.length > 0) {
286
- lines.push({
287
- text: `// Initialize integrations`,
288
- integrationId: "base"
289
- });
290
- for (const init of entryClientInits) lines.push({
291
- text: `${init.jsName}()`,
292
- integrationId: init.integrationId
293
- });
294
- lines.push({
295
- text: "",
296
- integrationId: "base"
297
- });
298
- }
299
- lines.push({
300
- text: `const router = getRouter()`,
301
- integrationId: "base"
302
- });
303
- lines.push({
304
- text: "",
305
- integrationId: "base"
306
- });
307
- lines.push({
308
- text: `hydrateRoot(document.getElementById('root')!, <StartClient router={router} />)`,
309
- integrationId: "base"
310
- });
311
- return {
312
- content: lines.map((l) => l.text).join("\n"),
313
- lineAttributions: lines.map((l, i) => ({
314
- line: i + 1,
315
- integrationId: l.integrationId
316
- }))
317
- };
318
- }
319
- /**
320
- * Generate __root.tsx content with line attribution
321
- * This generates a full document route with shellComponent for proper SSR
322
- */
323
- function generateRootRoute(options, rootProviders, devtoolsPlugins) {
324
- const lines = [];
325
- const hasHeader = options.chosenIntegrations.length > 0;
326
- if (devtoolsPlugins.length > 0) lines.push({
327
- text: `import React from 'react'`,
328
- integrationId: "base"
329
- });
330
- lines.push({
331
- text: `import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'`,
332
- integrationId: "base"
333
- });
334
- lines.push({
335
- text: `import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'`,
336
- integrationId: "base"
337
- });
338
- lines.push({
339
- text: `import appCss from '../styles.css?url'`,
340
- integrationId: "base"
341
- });
342
- if (hasHeader) lines.push({
343
- text: `import { Header } from '../components/Header'`,
344
- integrationId: "base"
345
- });
346
- for (const provider of rootProviders) {
347
- const importPath = relativePath("src/routes/__root.tsx", provider.path || `src/integrations/${provider.integrationId}/provider.tsx`, true);
348
- lines.push({
349
- text: `import { ${provider.jsName} } from '${importPath}'`,
350
- integrationId: provider.integrationId
351
- });
352
- }
353
- for (const devtools of devtoolsPlugins) {
354
- const importPath = relativePath("src/routes/__root.tsx", devtools.path || `src/integrations/${devtools.integrationId}/devtools.tsx`, true);
355
- lines.push({
356
- text: `import { ${devtools.jsName} } from '${importPath}'`,
357
- integrationId: devtools.integrationId
358
- });
359
- }
360
- if (devtoolsPlugins.length > 0) {
361
- lines.push({
362
- text: "",
363
- integrationId: "base"
364
- });
365
- lines.push({
366
- text: `const devtoolsPlugins = [`,
367
- integrationId: "base"
368
- });
369
- for (const devtools of devtoolsPlugins) lines.push({
370
- text: ` ${devtools.jsName},`,
371
- integrationId: devtools.integrationId
372
- });
373
- lines.push({
374
- text: `]`,
375
- integrationId: "base"
376
- });
377
- }
378
- lines.push({
379
- text: "",
380
- integrationId: "base"
381
- });
382
- lines.push({
383
- text: `export const Route = createRootRoute({`,
384
- integrationId: "base"
385
- });
386
- lines.push({
387
- text: ` head: () => ({`,
388
- integrationId: "base"
389
- });
390
- lines.push({
391
- text: ` meta: [`,
392
- integrationId: "base"
393
- });
394
- lines.push({
395
- text: ` { charSet: 'utf-8' },`,
396
- integrationId: "base"
397
- });
398
- lines.push({
399
- text: ` { name: 'viewport', content: 'width=device-width, initial-scale=1' },`,
400
- integrationId: "base"
401
- });
402
- lines.push({
403
- text: ` { title: 'TanStack Start Starter' },`,
404
- integrationId: "base"
405
- });
406
- lines.push({
407
- text: ` ],`,
408
- integrationId: "base"
409
- });
410
- lines.push({
411
- text: ` links: [{ rel: 'stylesheet', href: appCss }],`,
412
- integrationId: "base"
413
- });
414
- lines.push({
415
- text: ` }),`,
416
- integrationId: "base"
417
- });
418
- lines.push({
419
- text: ` shellComponent: RootDocument,`,
420
- integrationId: "base"
421
- });
422
- lines.push({
423
- text: `})`,
424
- integrationId: "base"
425
- });
426
- lines.push({
427
- text: "",
428
- integrationId: "base"
429
- });
430
- lines.push({
431
- text: `function RootDocument({ children }: { children: React.ReactNode }) {`,
432
- integrationId: "base"
433
- });
434
- lines.push({
435
- text: ` return (`,
436
- integrationId: "base"
437
- });
438
- lines.push({
439
- text: ` <html lang="en">`,
440
- integrationId: "base"
441
- });
442
- lines.push({
443
- text: ` <head>`,
444
- integrationId: "base"
445
- });
446
- lines.push({
447
- text: ` <HeadContent />`,
448
- integrationId: "base"
449
- });
450
- lines.push({
451
- text: ` </head>`,
452
- integrationId: "base"
453
- });
454
- lines.push({
455
- text: ` <body>`,
456
- integrationId: "base"
457
- });
458
- let currentIndent = " ";
459
- for (const provider of rootProviders) {
460
- lines.push({
461
- text: `${currentIndent}<${provider.jsName}>`,
462
- integrationId: provider.integrationId
463
- });
464
- currentIndent += " ";
465
- }
466
- if (hasHeader) lines.push({
467
- text: `${currentIndent}<Header />`,
468
- integrationId: "base"
469
- });
470
- lines.push({
471
- text: `${currentIndent}{children}`,
472
- integrationId: "base"
473
- });
474
- lines.push({
475
- text: `${currentIndent}<TanStackRouterDevtools />`,
476
- integrationId: "base"
477
- });
478
- if (devtoolsPlugins.length > 0) {
479
- lines.push({
480
- text: `${currentIndent}{devtoolsPlugins.map((plugin, i) => (`,
481
- integrationId: "base"
482
- });
483
- lines.push({
484
- text: `${currentIndent} <React.Fragment key={i}>{plugin.render}</React.Fragment>`,
485
- integrationId: "base"
486
- });
487
- lines.push({
488
- text: `${currentIndent}))}`,
489
- integrationId: "base"
490
- });
491
- }
492
- for (const provider of [...rootProviders].reverse()) {
493
- currentIndent = currentIndent.slice(0, -2);
494
- lines.push({
495
- text: `${currentIndent}</${provider.jsName}>`,
496
- integrationId: provider.integrationId
497
- });
498
- }
499
- lines.push({
500
- text: ` <Scripts />`,
501
- integrationId: "base"
502
- });
503
- lines.push({
504
- text: ` </body>`,
505
- integrationId: "base"
506
- });
507
- lines.push({
508
- text: ` </html>`,
509
- integrationId: "base"
510
- });
511
- lines.push({
512
- text: ` )`,
513
- integrationId: "base"
514
- });
515
- lines.push({
516
- text: `}`,
517
- integrationId: "base"
518
- });
519
- return {
520
- content: lines.map((l) => l.text).join("\n"),
521
- lineAttributions: lines.map((l, i) => ({
522
- line: i + 1,
523
- integrationId: l.integrationId
524
- }))
525
- };
526
- }
527
- /**
528
- * Collect routes from integrations for navigation
529
- */
530
- function collectRoutes(options) {
531
- const routes = [];
532
- for (const integration of options.chosenIntegrations) if (integration.routes) {
533
- for (const route of integration.routes) if (route.url && route.name) routes.push({
534
- url: route.url,
535
- name: route.name,
536
- icon: route.icon || "Globe"
537
- });
538
- }
539
- return routes;
540
- }
541
- /**
542
- * Generate Header component with slide-out drawer navigation
543
- */
544
- function generateHeader(options) {
545
- const lines = [];
546
- const routes = collectRoutes(options);
547
- const icons = new Set([
548
- "Menu",
549
- "X",
550
- "Home"
551
- ]);
552
- for (const route of routes) icons.add(route.icon);
553
- lines.push({
554
- text: `import { useState } from 'react'`,
555
- integrationId: "base"
556
- });
557
- lines.push({
558
- text: `import { Link } from '@tanstack/react-router'`,
559
- integrationId: "base"
560
- });
561
- lines.push({
562
- text: `import { ${Array.from(icons).sort().join(", ")} } from 'lucide-react'`,
563
- integrationId: "base"
564
- });
565
- lines.push({
566
- text: "",
567
- integrationId: "base"
568
- });
569
- lines.push({
570
- text: `export function Header() {`,
571
- integrationId: "base"
572
- });
573
- lines.push({
574
- text: ` const [isOpen, setIsOpen] = useState(false)`,
575
- integrationId: "base"
576
- });
577
- lines.push({
578
- text: "",
579
- integrationId: "base"
580
- });
581
- lines.push({
582
- text: ` return (`,
583
- integrationId: "base"
584
- });
585
- lines.push({
586
- text: ` <>`,
587
- integrationId: "base"
588
- });
589
- lines.push({
590
- text: ` <header className="p-4 flex items-center bg-gray-800 text-white shadow-lg">`,
591
- integrationId: "base"
592
- });
593
- lines.push({
594
- text: ` <button`,
595
- integrationId: "base"
596
- });
597
- lines.push({
598
- text: ` onClick={() => setIsOpen(true)}`,
599
- integrationId: "base"
600
- });
601
- lines.push({
602
- text: ` className="p-2 hover:bg-gray-700 rounded-lg transition-colors"`,
603
- integrationId: "base"
604
- });
605
- lines.push({
606
- text: ` aria-label="Open menu"`,
607
- integrationId: "base"
608
- });
609
- lines.push({
610
- text: ` >`,
611
- integrationId: "base"
612
- });
613
- lines.push({
614
- text: ` <Menu size={24} />`,
615
- integrationId: "base"
616
- });
617
- lines.push({
618
- text: ` </button>`,
619
- integrationId: "base"
620
- });
621
- lines.push({
622
- text: ` <h1 className="ml-4 text-xl font-semibold">`,
623
- integrationId: "base"
624
- });
625
- lines.push({
626
- text: ` <Link to="/">`,
627
- integrationId: "base"
628
- });
629
- lines.push({
630
- text: ` <img`,
631
- integrationId: "base"
632
- });
633
- lines.push({
634
- text: ` src="/tanstack-logo-light.svg"`,
635
- integrationId: "base"
636
- });
637
- lines.push({
638
- text: ` alt="TanStack Logo"`,
639
- integrationId: "base"
640
- });
641
- lines.push({
642
- text: ` className="h-10"`,
643
- integrationId: "base"
644
- });
645
- lines.push({
646
- text: ` />`,
647
- integrationId: "base"
648
- });
649
- lines.push({
650
- text: ` </Link>`,
651
- integrationId: "base"
652
- });
653
- lines.push({
654
- text: ` </h1>`,
655
- integrationId: "base"
656
- });
657
- lines.push({
658
- text: ` </header>`,
659
- integrationId: "base"
660
- });
661
- lines.push({
662
- text: "",
663
- integrationId: "base"
664
- });
665
- lines.push({
666
- text: ` <aside`,
667
- integrationId: "base"
668
- });
669
- lines.push({
670
- text: ` className={\`fixed top-0 left-0 h-full w-80 bg-gray-900 text-white shadow-2xl z-50 transform transition-transform duration-300 ease-in-out flex flex-col \${`,
671
- integrationId: "base"
672
- });
673
- lines.push({
674
- text: ` isOpen ? 'translate-x-0' : '-translate-x-full'`,
675
- integrationId: "base"
676
- });
677
- lines.push({
678
- text: ` }\`}`,
679
- integrationId: "base"
680
- });
681
- lines.push({
682
- text: ` >`,
683
- integrationId: "base"
684
- });
685
- lines.push({
686
- text: ` <div className="flex items-center justify-between p-4 border-b border-gray-700">`,
687
- integrationId: "base"
688
- });
689
- lines.push({
690
- text: ` <h2 className="text-xl font-bold">Navigation</h2>`,
691
- integrationId: "base"
692
- });
693
- lines.push({
694
- text: ` <button`,
695
- integrationId: "base"
696
- });
697
- lines.push({
698
- text: ` onClick={() => setIsOpen(false)}`,
699
- integrationId: "base"
700
- });
701
- lines.push({
702
- text: ` className="p-2 hover:bg-gray-800 rounded-lg transition-colors"`,
703
- integrationId: "base"
704
- });
705
- lines.push({
706
- text: ` aria-label="Close menu"`,
707
- integrationId: "base"
708
- });
709
- lines.push({
710
- text: ` >`,
711
- integrationId: "base"
712
- });
713
- lines.push({
714
- text: ` <X size={24} />`,
715
- integrationId: "base"
716
- });
717
- lines.push({
718
- text: ` </button>`,
719
- integrationId: "base"
720
- });
721
- lines.push({
722
- text: ` </div>`,
723
- integrationId: "base"
724
- });
725
- lines.push({
726
- text: "",
727
- integrationId: "base"
728
- });
729
- lines.push({
730
- text: ` <nav className="flex-1 p-4 overflow-y-auto">`,
731
- integrationId: "base"
732
- });
733
- lines.push({
734
- text: ` <Link`,
735
- integrationId: "base"
736
- });
737
- lines.push({
738
- text: ` to="/"`,
739
- integrationId: "base"
740
- });
741
- lines.push({
742
- text: ` onClick={() => setIsOpen(false)}`,
743
- integrationId: "base"
744
- });
745
- lines.push({
746
- text: ` className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2"`,
747
- integrationId: "base"
748
- });
749
- lines.push({
750
- text: ` activeProps={{`,
751
- integrationId: "base"
752
- });
753
- lines.push({
754
- text: ` className: 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2',`,
755
- integrationId: "base"
756
- });
757
- lines.push({
758
- text: ` }}`,
759
- integrationId: "base"
760
- });
761
- lines.push({
762
- text: ` >`,
763
- integrationId: "base"
764
- });
765
- lines.push({
766
- text: ` <Home size={20} />`,
767
- integrationId: "base"
768
- });
769
- lines.push({
770
- text: ` <span className="font-medium">Home</span>`,
771
- integrationId: "base"
772
- });
773
- lines.push({
774
- text: ` </Link>`,
775
- integrationId: "base"
776
- });
777
- for (const route of routes) {
778
- const integrationId = options.chosenIntegrations.find((i) => i.routes?.some((r) => r.url === route.url))?.id || "base";
779
- lines.push({
780
- text: "",
781
- integrationId
782
- });
783
- lines.push({
784
- text: ` <Link`,
785
- integrationId
786
- });
787
- lines.push({
788
- text: ` to="${route.url}"`,
789
- integrationId
790
- });
791
- lines.push({
792
- text: ` onClick={() => setIsOpen(false)}`,
793
- integrationId
794
- });
795
- lines.push({
796
- text: ` className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2"`,
797
- integrationId
798
- });
799
- lines.push({
800
- text: ` activeProps={{`,
801
- integrationId
802
- });
803
- lines.push({
804
- text: ` className: 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2',`,
805
- integrationId
806
- });
807
- lines.push({
808
- text: ` }}`,
809
- integrationId
810
- });
811
- lines.push({
812
- text: ` >`,
813
- integrationId
814
- });
815
- lines.push({
816
- text: ` <${route.icon} size={20} />`,
817
- integrationId
818
- });
819
- lines.push({
820
- text: ` <span className="font-medium">${route.name}</span>`,
821
- integrationId
822
- });
823
- lines.push({
824
- text: ` </Link>`,
825
- integrationId
826
- });
827
- }
828
- lines.push({
829
- text: ` </nav>`,
830
- integrationId: "base"
831
- });
832
- lines.push({
833
- text: ` </aside>`,
834
- integrationId: "base"
835
- });
836
- lines.push({
837
- text: "",
838
- integrationId: "base"
839
- });
840
- lines.push({
841
- text: ` {isOpen && (`,
842
- integrationId: "base"
843
- });
844
- lines.push({
845
- text: ` <div`,
846
- integrationId: "base"
847
- });
848
- lines.push({
849
- text: ` className="fixed inset-0 bg-black/50 z-40"`,
850
- integrationId: "base"
851
- });
852
- lines.push({
853
- text: ` onClick={() => setIsOpen(false)}`,
854
- integrationId: "base"
855
- });
856
- lines.push({
857
- text: ` />`,
858
- integrationId: "base"
859
- });
860
- lines.push({
861
- text: ` )}`,
862
- integrationId: "base"
863
- });
864
- lines.push({
865
- text: ` </>`,
866
- integrationId: "base"
867
- });
868
- lines.push({
869
- text: ` )`,
870
- integrationId: "base"
871
- });
872
- lines.push({
873
- text: `}`,
874
- integrationId: "base"
875
- });
876
- return {
877
- content: lines.map((l) => l.text).join("\n"),
878
- lineAttributions: lines.map((l, i) => ({
879
- line: i + 1,
880
- integrationId: l.integrationId
881
- }))
882
- };
883
- }
884
- /**
885
- * Generate .gitignore content with line attribution
886
- */
887
- function generateGitignore(integrationPatterns) {
888
- const lines = [];
889
- lines.push({
890
- text: "# Dependencies",
891
- integrationId: "base"
892
- });
893
- lines.push({
894
- text: "node_modules/",
895
- integrationId: "base"
896
- });
897
- lines.push({
898
- text: ".pnpm-store/",
899
- integrationId: "base"
900
- });
901
- lines.push({
902
- text: "",
903
- integrationId: "base"
904
- });
905
- lines.push({
906
- text: "# Build outputs",
907
- integrationId: "base"
908
- });
909
- lines.push({
910
- text: "dist/",
911
- integrationId: "base"
912
- });
913
- lines.push({
914
- text: ".output/",
915
- integrationId: "base"
916
- });
917
- lines.push({
918
- text: ".vinxi/",
919
- integrationId: "base"
920
- });
921
- lines.push({
922
- text: ".vercel/",
923
- integrationId: "base"
924
- });
925
- lines.push({
926
- text: ".netlify/",
927
- integrationId: "base"
928
- });
929
- lines.push({
930
- text: "",
931
- integrationId: "base"
932
- });
933
- lines.push({
934
- text: "# Environment",
935
- integrationId: "base"
936
- });
937
- lines.push({
938
- text: ".env",
939
- integrationId: "base"
940
- });
941
- lines.push({
942
- text: ".env.*",
943
- integrationId: "base"
944
- });
945
- lines.push({
946
- text: "!.env.example",
947
- integrationId: "base"
948
- });
949
- lines.push({
950
- text: "",
951
- integrationId: "base"
952
- });
953
- lines.push({
954
- text: "# IDE",
955
- integrationId: "base"
956
- });
957
- lines.push({
958
- text: ".idea/",
959
- integrationId: "base"
960
- });
961
- lines.push({
962
- text: ".vscode/",
963
- integrationId: "base"
964
- });
965
- lines.push({
966
- text: "*.swp",
967
- integrationId: "base"
968
- });
969
- lines.push({
970
- text: "*.swo",
971
- integrationId: "base"
972
- });
973
- lines.push({
974
- text: "",
975
- integrationId: "base"
976
- });
977
- lines.push({
978
- text: "# OS",
979
- integrationId: "base"
980
- });
981
- lines.push({
982
- text: ".DS_Store",
983
- integrationId: "base"
984
- });
985
- lines.push({
986
- text: "Thumbs.db",
987
- integrationId: "base"
988
- });
989
- lines.push({
990
- text: "",
991
- integrationId: "base"
992
- });
993
- lines.push({
994
- text: "# Logs",
995
- integrationId: "base"
996
- });
997
- lines.push({
998
- text: "*.log",
999
- integrationId: "base"
1000
- });
1001
- lines.push({
1002
- text: "npm-debug.log*",
1003
- integrationId: "base"
1004
- });
1005
- lines.push({
1006
- text: "pnpm-debug.log*",
1007
- integrationId: "base"
1008
- });
1009
- lines.push({
1010
- text: "",
1011
- integrationId: "base"
1012
- });
1013
- lines.push({
1014
- text: "# Generated",
1015
- integrationId: "base"
1016
- });
1017
- lines.push({
1018
- text: "src/routeTree.gen.ts",
1019
- integrationId: "base"
1020
- });
1021
- if (integrationPatterns.length > 0) {
1022
- lines.push({
1023
- text: "",
1024
- integrationId: "base"
1025
- });
1026
- lines.push({
1027
- text: "# Integration-specific",
1028
- integrationId: "base"
1029
- });
1030
- for (const { pattern, integrationId } of integrationPatterns) lines.push({
1031
- text: pattern,
1032
- integrationId
1033
- });
1034
- }
1035
- return {
1036
- content: lines.map((l) => l.text).join("\n"),
1037
- lineAttributions: lines.map((l, i) => ({
1038
- line: i + 1,
1039
- integrationId: l.integrationId
1040
- }))
1041
- };
1042
- }
1043
- /**
1044
- * Get base template files (static files without hook injection)
1045
- */
1046
- function getBaseFiles(options) {
1047
- const { projectName, typescript, tailwind, packageManager } = options;
1048
- const files = {};
1049
- const { vitePlugins, rootProviders, devtoolsPlugins, entryClientInits } = collectHooks(options);
1050
- if (typescript) files["tsconfig.json"] = JSON.stringify({
1051
- compilerOptions: {
1052
- target: "ES2022",
1053
- lib: [
1054
- "ES2022",
1055
- "DOM",
1056
- "DOM.Iterable"
1057
- ],
1058
- module: "ESNext",
1059
- skipLibCheck: true,
1060
- moduleResolution: "bundler",
1061
- allowImportingTsExtensions: true,
1062
- resolveJsonModule: true,
1063
- isolatedModules: true,
1064
- moduleDetection: "force",
1065
- noEmit: true,
1066
- jsx: "react-jsx",
1067
- strict: true,
1068
- noUnusedLocals: true,
1069
- noUnusedParameters: true,
1070
- noFallthroughCasesInSwitch: true,
1071
- noUncheckedIndexedAccess: true,
1072
- paths: { "~/*": ["./src/*"] }
1073
- },
1074
- include: ["src"]
1075
- }, null, 2);
1076
- files[typescript ? "vite.config.ts" : "vite.config.js"] = generateViteConfig(options, vitePlugins).content;
1077
- if (entryClientInits.length > 0) files[`src/entry-client.${typescript ? "tsx" : "jsx"}`] = generateEntryClient(options, entryClientInits).content;
1078
- files[`src/router.${typescript ? "tsx" : "jsx"}`] = `import { createRouter as createTanStackRouter } from '@tanstack/react-router'
1079
- import { routeTree } from './routeTree.gen'
1080
-
1081
- export function getRouter() {
1082
- const router = createTanStackRouter({
1083
- routeTree,
1084
- defaultPreload: 'intent',
1085
- scrollRestoration: true,
1086
- })
1087
-
1088
- return router
1089
- }
1090
-
1091
- declare module '@tanstack/react-router' {
1092
- interface Register {
1093
- router: ReturnType<typeof getRouter>
1094
- }
1095
- }
1096
- `;
1097
- files[`src/routes/__root.${typescript ? "tsx" : "jsx"}`] = generateRootRoute(options, rootProviders, devtoolsPlugins).content;
1098
- const hasHeader = options.chosenIntegrations.length > 0;
1099
- if (hasHeader && tailwind) files[`src/components/Header.${typescript ? "tsx" : "jsx"}`] = generateHeader(options).content;
1100
- const indexRouteWithHeader = `import { createFileRoute } from '@tanstack/react-router'
1101
-
1102
- export const Route = createFileRoute('/')({
1103
- component: Home,
1104
- })
1105
-
1106
- function Home() {
1107
- return (
1108
- <div className="min-h-[calc(100vh-72px)] bg-gradient-to-br from-gray-900 to-gray-800 flex items-center justify-center">
1109
- <div className="text-center px-4">
1110
- <img
1111
- src="/tanstack-logo-dark.svg"
1112
- alt="TanStack Logo"
1113
- className="h-24 mx-auto mb-8"
1114
- />
1115
- <h1 className="text-5xl font-bold text-white mb-4">
1116
- Welcome to TanStack Start
1117
- </h1>
1118
- <p className="text-xl text-gray-300 mb-8">
1119
- Full-stack React framework powered by TanStack Router
1120
- </p>
1121
- <div className="flex gap-4 justify-center flex-wrap">
1122
- <a
1123
- href="https://tanstack.com/start"
1124
- target="_blank"
1125
- rel="noopener noreferrer"
1126
- className="px-6 py-3 bg-cyan-500 text-white rounded-lg font-medium hover:bg-cyan-600 transition-colors"
1127
- >
1128
- Documentation
1129
- </a>
1130
- <a
1131
- href="https://github.com/tanstack/router"
1132
- target="_blank"
1133
- rel="noopener noreferrer"
1134
- className="px-6 py-3 bg-gray-700 text-white rounded-lg font-medium hover:bg-gray-600 transition-colors"
1135
- >
1136
- GitHub
1137
- </a>
1138
- </div>
1139
- </div>
1140
- </div>
1141
- )
1142
- }
1143
- `;
1144
- const indexRouteNoHeader = `import { createFileRoute } from '@tanstack/react-router'
1145
-
1146
- export const Route = createFileRoute('/')({
1147
- component: Home,
1148
- })
1149
-
1150
- function Home() {
1151
- return (
1152
- <div className="min-h-screen bg-gradient-to-br from-gray-900 to-gray-800 flex items-center justify-center">
1153
- <div className="text-center px-4">
1154
- <img
1155
- src="/tanstack-logo-dark.svg"
1156
- alt="TanStack Logo"
1157
- className="h-24 mx-auto mb-8"
1158
- />
1159
- <h1 className="text-5xl font-bold text-white mb-4">
1160
- Welcome to TanStack Start
1161
- </h1>
1162
- <p className="text-xl text-gray-300 mb-8">
1163
- Full-stack React framework powered by TanStack Router
1164
- </p>
1165
- <div className="flex gap-4 justify-center flex-wrap">
1166
- <a
1167
- href="https://tanstack.com/start"
1168
- target="_blank"
1169
- rel="noopener noreferrer"
1170
- className="px-6 py-3 bg-cyan-500 text-white rounded-lg font-medium hover:bg-cyan-600 transition-colors"
1171
- >
1172
- Documentation
1173
- </a>
1174
- <a
1175
- href="https://github.com/tanstack/router"
1176
- target="_blank"
1177
- rel="noopener noreferrer"
1178
- className="px-6 py-3 bg-gray-700 text-white rounded-lg font-medium hover:bg-gray-600 transition-colors"
1179
- >
1180
- GitHub
1181
- </a>
1182
- </div>
1183
- </div>
1184
- </div>
1185
- )
1186
- }
1187
- `;
1188
- const indexRouteNoTailwind = `import { createFileRoute } from '@tanstack/react-router'
1189
-
1190
- export const Route = createFileRoute('/')({
1191
- component: Home,
1192
- })
1193
-
1194
- function Home() {
1195
- return (
1196
- <div style={styles.container}>
1197
- <div style={styles.content}>
1198
- <img
1199
- src="/tanstack-logo-dark.svg"
1200
- alt="TanStack Logo"
1201
- style={styles.logo}
1202
- />
1203
- <h1 style={styles.title}>Welcome to TanStack Start</h1>
1204
- <p style={styles.subtitle}>
1205
- Full-stack React framework powered by TanStack Router
1206
- </p>
1207
- <div style={styles.buttons}>
1208
- <a
1209
- href="https://tanstack.com/start"
1210
- target="_blank"
1211
- rel="noopener noreferrer"
1212
- style={styles.primaryButton}
1213
- >
1214
- Documentation
1215
- </a>
1216
- <a
1217
- href="https://github.com/tanstack/router"
1218
- target="_blank"
1219
- rel="noopener noreferrer"
1220
- style={styles.secondaryButton}
1221
- >
1222
- GitHub
1223
- </a>
1224
- </div>
1225
- </div>
1226
- </div>
1227
- )
1228
- }
1229
-
1230
- const styles = {
1231
- container: {
1232
- minHeight: '100vh',
1233
- background: 'linear-gradient(to bottom right, #111827, #1f2937)',
1234
- display: 'flex',
1235
- alignItems: 'center',
1236
- justifyContent: 'center',
1237
- },
1238
- content: {
1239
- textAlign: 'center' as const,
1240
- padding: '0 1rem',
1241
- },
1242
- logo: {
1243
- height: '6rem',
1244
- marginBottom: '2rem',
1245
- },
1246
- title: {
1247
- fontSize: '3rem',
1248
- fontWeight: 'bold',
1249
- color: 'white',
1250
- marginBottom: '1rem',
1251
- },
1252
- subtitle: {
1253
- fontSize: '1.25rem',
1254
- color: '#d1d5db',
1255
- marginBottom: '2rem',
1256
- },
1257
- buttons: {
1258
- display: 'flex',
1259
- gap: '1rem',
1260
- justifyContent: 'center',
1261
- flexWrap: 'wrap' as const,
1262
- },
1263
- primaryButton: {
1264
- padding: '0.75rem 1.5rem',
1265
- backgroundColor: '#06b6d4',
1266
- color: 'white',
1267
- borderRadius: '0.5rem',
1268
- fontWeight: 500,
1269
- textDecoration: 'none',
1270
- },
1271
- secondaryButton: {
1272
- padding: '0.75rem 1.5rem',
1273
- backgroundColor: '#374151',
1274
- color: 'white',
1275
- borderRadius: '0.5rem',
1276
- fontWeight: 500,
1277
- textDecoration: 'none',
1278
- },
1279
- }
1280
- `;
1281
- if (tailwind) files[`src/routes/index.${typescript ? "tsx" : "jsx"}`] = hasHeader ? indexRouteWithHeader : indexRouteNoHeader;
1282
- else files[`src/routes/index.${typescript ? "tsx" : "jsx"}`] = indexRouteNoTailwind;
1283
- if (tailwind) files["src/styles.css"] = `@import 'tailwindcss';
1284
-
1285
- body {
1286
- @apply m-0;
1287
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
1288
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
1289
- sans-serif;
1290
- -webkit-font-smoothing: antialiased;
1291
- -moz-osx-font-smoothing: grayscale;
1292
- }
1293
-
1294
- code {
1295
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1296
- monospace;
1297
- }
1298
- `;
1299
- else files["src/styles.css"] = `* {
1300
- box-sizing: border-box;
1301
- margin: 0;
1302
- padding: 0;
1303
- }
1304
-
1305
- body {
1306
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
1307
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
1308
- sans-serif;
1309
- -webkit-font-smoothing: antialiased;
1310
- -moz-osx-font-smoothing: grayscale;
1311
- line-height: 1.5;
1312
- }
1313
-
1314
- code {
1315
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1316
- monospace;
1317
- }
1318
- `;
1319
- files["public/tanstack-logo-light.svg"] = `<svg height="660" viewBox="0 0 663 660" width="663" xmlns="http://www.w3.org/2000/svg"><path d="m305.114318.62443771c8.717817-1.14462121 17.926803-.36545135 26.712694-.36545135 32.548987 0 64.505987 5.05339923 95.64868 14.63098274 39.74418 12.2236582 76.762804 31.7666864 109.435876 57.477568 40.046637 31.5132839 73.228974 72.8472109 94.520714 119.2362609 39.836383 86.790386 39.544267 191.973146-1.268422 278.398081-26.388695 55.880442-68.724007 102.650458-119.964986 136.75724-41.808813 27.828603-90.706831 44.862601-140.45707 50.89341-63.325458 7.677926-131.784923-3.541603-188.712259-32.729444-106.868873-54.795293-179.52309291-165.076271-180.9604082-285.932068-.27660564-23.300971.08616998-46.74071 4.69884909-69.814998 7.51316071-37.57857 20.61272131-73.903917 40.28618971-106.877282 21.2814003-35.670293 48.7704861-67.1473767 81.6882804-92.5255597 38.602429-29.7610135 83.467691-51.1674988 130.978372-62.05777669 11.473831-2.62966514 22.9946-4.0869914 34.57273-5.4964306l3.658171-.44480576c3.050084-.37153079 6.104217-.74794222 9.162589-1.14972654zm-110.555861 549.44131429c-14.716752 1.577863-30.238964 4.25635-42.869928 12.522173 2.84343.683658 6.102369.004954 9.068638 0 7.124652-.011559 14.317732-.279903 21.434964.032202 17.817402.781913 36.381729 3.63214 53.58741 8.350042 22.029372 6.040631 41.432961 17.928687 62.656049 25.945156 22.389644 8.456554 44.67706 11.084675 68.427 11.084675 11.96813 0 23.845573-.035504 35.450133-3.302696-6.056202-3.225083-14.72582-2.619864-21.434964-3.963236-14.556814-2.915455-28.868774-6.474936-42.869928-11.470264-10.304996-3.676672-20.230803-8.214291-30.11097-12.848661l-6.348531-2.985046c-9.1705-4.309263-18.363277-8.560752-27.845391-12.142608-24.932161-9.418465-52.560181-14.071964-79.144482-11.221737zm22.259385-62.614168c-29.163917 0-58.660076 5.137344-84.915434 18.369597-6.361238 3.206092-12.407546 7.02566-18.137277 11.258891-1.746125 1.290529-4.841829 2.948483-5.487351 5.191839-.654591 2.275558 1.685942 4.182039 3.014086 5.637703 6.562396-3.497556 12.797498-7.199878 19.78612-9.855246 45.19892-17.169893 99.992458-13.570779 145.098218 2.172348 22.494346 7.851335 43.219483 19.592421 65.129314 28.800338 24.503461 10.297807 49.53043 16.975034 75.846795 20.399104 31.04195 4.037546 66.433549.7654 94.808495-13.242161 9.970556-4.921843 23.814245-12.422267 28.030337-23.320339-5.207047.454947-9.892236 2.685918-14.83959 4.224149-7.866632 2.445646-15.827248 4.51974-23.908229 6.138887-27.388113 5.486604-56.512458 6.619429-84.091013 1.639788-25.991939-4.693152-50.142596-14.119246-74.179513-24.03502l-3.068058-1.268177c-2.045137-.846788-4.089983-1.695816-6.135603-2.544467l-3.069142-1.272366c-12.279956-5.085721-24.606928-10.110797-37.210937-14.51024-24.485325-8.546552-50.726667-13.784628-76.671218-13.784628zm51.114145-447.9909432c-34.959602 7.7225298-66.276908 22.7605319-96.457338 41.7180089-17.521434 11.0054099-34.281927 22.2799893-49.465301 36.4444283-22.5792616 21.065423-39.8360564 46.668751-54.8866988 73.411509-15.507372 27.55357-25.4498976 59.665686-30.2554517 90.824149-4.7140432 30.568106-5.4906485 62.70747-.0906864 93.301172 6.7503648 38.248526 19.5989769 74.140579 39.8896436 107.337631 6.8187918-3.184625 11.659796-10.445603 17.3128555-15.336896 11.4149428-9.875888 23.3995608-19.029311 36.2745548-26.928535 4.765981-2.923712 9.662222-5.194315 14.83959-7.275014 1.953055-.785216 5.14604-1.502727 6.06527-3.647828 1.460876-3.406732-1.240754-9.335897-1.704904-12.865654-1.324845-10.095517-2.124534-20.362774-1.874735-30.549941.725492-29.668947 6.269727-59.751557 16.825623-87.521453 7.954845-20.924233 20.10682-39.922168 34.502872-56.971512 4.884699-5.785498 10.077731-11.170545 15.437296-16.512656 3.167428-3.157378 7.098271-5.858983 9.068639-9.908915-10.336599.006606-20.674847 2.987289-30.503603 6.013385-21.174447 6.519522-41.801477 16.19312-59.358362 29.841512-8.008432 6.226409-13.873368 14.387371-21.44733 20.939921-2.32322 2.010516-6.484901 4.704691-9.695199 3.187928-4.8500728-2.29042-4.1014979-11.835213-4.6571581-16.222019-2.1369011-16.873476 4.2548401-38.216325 12.3778671-52.843142 13.039878-23.479694 37.150915-43.528712 65.467327-42.82854 12.228647.302197 22.934587 4.551115 34.625711 7.324555-2.964621-4.211764-6.939158-7.28162-10.717482-10.733763-9.257431-8.459031-19.382979-16.184864-30.503603-22.028985-4.474136-2.350694-9.291232-3.77911-14.015169-5.506421-2.375159-.867783-5.36616-2.062533-6.259834-4.702213-1.654614-4.888817 7.148561-9.416813 10.381943-11.478522 12.499882-7.969406 27.826705-14.525258 42.869928-14.894334 23.509209-.577147 46.479246 12.467678 56.162903 34.665926 3.404469 7.803171 4.411273 16.054969 5.079109 24.382907l.121749 1.56229.174325 2.345587c.01913.260708.038244.521433.057403.782164l.11601 1.56437.120128 1.563971c7.38352-6.019164 12.576553-14.876995 19.78612-21.323859 16.861073-15.07846 39.936636-21.7722 61.831627-14.984333 19.786945 6.133107 36.984382 19.788105 47.105807 37.959541 2.648042 4.754231 10.035685 16.373942 4.698379 21.109183-4.177345 3.707277-9.475079.818243-13.880788-.719162-3.33605-1.16376-6.782939-1.90214-10.241828-2.585698l-1.887262-.369639c-.629089-.122886-1.257979-.246187-1.886079-.372129-11.980496-2.401886-25.91652-2.152533-37.923398-.041284-7.762754 1.364839-15.349083 4.127545-23.083807 5.271929v1.651348c21.149714.175043 41.608563 12.240618 52.043268 30.549941 4.323267 7.585468 6.482428 16.267431 8.138691 24.770223 2.047864 10.50918.608423 21.958802-2.263037 32.201289-.962925 3.433979-2.710699 9.255807-6.817143 10.046802-2.902789.558982-5.36781-2.330878-7.024898-4.279468-4.343878-5.10762-8.475879-9.96341-13.573278-14.374161-12.895604-11.157333-26.530715-21.449361-40.396663-31.373138-7.362086-5.269452-15.425755-12.12007-23.908229-15.340199 2.385052 5.745041 4.721463 11.086326 5.532694 17.339156 2.385876 18.392716-5.314223 35.704625-16.87179 49.540445-3.526876 4.222498-7.29943 8.475545-11.744712 11.755948-1.843407 1.360711-4.156734 3.137561-6.595373 2.752797-7.645687-1.207961-8.555849-12.73272-9.728176-18.637115-3.970415-19.998652-2.375984-39.861068 3.132802-59.448534-4.901187 2.485279-8.443727 7.923994-11.521293 12.385111-6.770975 9.816439-12.645804 20.199291-16.858599 31.375615-16.777806 44.519521-16.616219 96.664142 5.118834 139.523233 2.427098 4.786433 6.110614 4.144058 10.894733 4.144058.720854 0 1.44257-.004515 2.164851-.010924l2.168232-.022283c4.338648-.045438 8.686803-.064635 12.979772.508795 2.227588.297243 5.320818.032202 7.084256 1.673642 2.111344 1.966755.986008 5.338808.4996 7.758859-1.358647 6.765574-1.812904 12.914369-1.812904 19.816178 9.02412-1.398692 11.525415-15.866153 14.724172-23.118874 3.624982-8.216283 7.313444-16.440823 10.667192-24.770223 1.648843-4.093692 3.854171-8.671229 3.275427-13.210785-.649644-5.10184-4.335633-10.510831-6.904531-14.862134-4.86244-8.234447-10.389363-16.70834-13.969002-25.595896-2.861567-7.104926-.197036-15.983399 7.871579-18.521521 4.450228-1.400344 9.198073 1.345848 12.094266 4.562675 6.07269 6.74328 9.992815 16.777697 14.401823 24.692609l34.394873 61.925556c2.920926 5.243856 5.848447 10.481933 8.836976 15.687808 1.165732 2.031158 2.352075 5.167068 4.740424 6.0332 2.127008.77118 5.033095-.325315 7.148561-.748886 5.492297-1.099798 10.97635-2.287117 16.488434-3.28288 6.605266-1.193099 16.673928-.969342 21.434964-6.129805-6.963066-2.205375-15.011895-2.074919-22.259386-1.577863-4.352947.298894-9.178287 1.856116-13.178381-.686135-5.953149-3.783239-9.910373-12.522173-13.552668-18.377854-8.980425-14.439388-17.441465-29.095929-26.041008-43.760726l-1.376261-2.335014-2.765943-4.665258c-1.380597-2.334387-2.750786-4.67476-4.079753-7.036188-1.02723-1.826391-2.549937-4.233231-1.078344-6.24705 1.545791-2.114476 4.91472-2.239146 7.956473-2.243117l.603351.000261c1.195428.001526 2.315572.002427 3.222811-.11692 12.27399-1.615019 24.718635-2.952611 37.098976-2.952611-.963749-3.352237-3.719791-7.141255-2.838484-10.73046 1.972017-8.030506 13.526287-10.543033 18.899867-4.780653 3.60767 3.868283 5.704174 9.192229 8.051303 13.859765 3.097352 6.162006 6.624228 12.118418 9.940876 18.16483 5.805578 10.585967 12.146205 20.881297 18.116667 31.375615.49237.865561.999687 1.726685 1.512269 2.587098l.771613 1.290552c2.577138 4.303168 5.164895 8.635123 6.553094 13.461506-20.735854-.9487-36.30176-25.018751-45.343193-41.283704-.721369 2.604176.450959 4.928448 1.388326 7.431066 1.948109 5.197619 4.276275 10.147535 7.20627 14.862134 4.184765 6.732546 8.982075 13.665732 15.313633 18.553722 11.236043 8.673707 26.05255 8.721596 39.572241 7.794364 8.669619-.595311 19.50252-4.542034 28.030338-1.864372 8.513803 2.673532 11.940924 12.063098 6.884745 19.276187-3.787393 5.403211-8.842747 7.443452-15.128962 8.257566 4.445282 9.53571 10.268996 18.385285 14.490036 28.072919 1.758491 4.035895 3.59118 10.22102 7.8048 12.350433 2.805507 1.416857 6.824562.09743 9.85761.034678-3.043765-8.053625-8.742992-14.887729-11.541904-23.118874 8.533589.390544 16.786875 4.843404 24.732651 7.685374 15.630376 5.590144 31.063836 11.701854 46.475333 17.86913l7.112077 2.848685c6.338978 2.538947 12.71588 5.052299 18.961699 7.812528 2.285297 1.009799 5.449427 3.370401 7.975455 1.917215 2.061054-1.186494 3.394144-4.015253 4.665403-5.931643 3.55573-5.361927 6.775921-10.928622 9.965609-16.513481 12.774414-22.36586 22.143967-46.872692 28.402976-71.833646 20.645168-82.323009 2.934117-173.156241-46.677107-241.922507-19.061454-26.420745-43.033164-49.262193-69.46165-68.1783861-66.13923-47.336721-152.911262-66.294198-232.486917-48.7172481zm135.205158 410.5292842c-17.532977 4.570931-35.601827 8.714164-53.58741 11.040088 2.365265 8.052799 8.145286 15.885969 12.376218 23.118874 1.635653 2.796558 3.3859 6.541816 6.618457 7.755557 3.651364 1.370619 8.063669-.853747 11.508927-1.975838-1.595256-4.364513-4.279573-8.292245-6.476657-12.385112-.905215-1.687677-2.305907-3.685809-1.559805-5.68972 1.410585-3.786541 7.266452-3.563609 10.509727-4.221671 8.54678-1.733916 17.004522-3.898008 25.557073-5.611281 3.150939-.631641 7.538512-2.342438 10.705115-1.285575 2.371037.791232 3.800147 2.744743 5.152304 4.781948l.606196.918752c.80912 1.222827 1.637246 2.41754 2.671212 3.351165 3.457625 3.121874 8.628398 3.60159 13.017619 4.453686-2.678546-6.027421-7.130424-11.301001-9.984571-17.339156-1.659561-3.511592-3.023155-8.677834-6.656381-10.707341-5.005064-2.795733-15.341663 2.461334-20.458024 3.795624zm-110.472507-40.151706c-.825246 10.467897-4.036369 18.984725-9.068639 28.072919 5.76683.729896 11.649079.989984 17.312856 2.39363 4.244947 1.051908 8.156828 3.058296 12.366325 4.211763-2.250671-6.157877-6.426367-11.651913-9.661398-17.339156-3.266358-5.740912-6.189758-12.717032-10.949144-17.339156z" fill="#fff" transform="translate(.9778)"/></svg>`;
1320
- files["public/tanstack-logo-dark.svg"] = `<svg height="660" viewBox="0 0 663 660" width="663" xmlns="http://www.w3.org/2000/svg"><path d="m305.114318.62443771c8.717817-1.14462121 17.926803-.36545135 26.712694-.36545135 32.548987 0 64.505987 5.05339923 95.64868 14.63098274 39.74418 12.2236582 76.762804 31.7666864 109.435876 57.477568 40.046637 31.5132839 73.228974 72.8472109 94.520714 119.2362609 39.836383 86.790386 39.544267 191.973146-1.268422 278.398081-26.388695 55.880442-68.724007 102.650458-119.964986 136.75724-41.808813 27.828603-90.706831 44.862601-140.45707 50.89341-63.325458 7.677926-131.784923-3.541603-188.712259-32.729444-106.868873-54.795293-179.52309291-165.076271-180.9604082-285.932068-.27660564-23.300971.08616998-46.74071 4.69884909-69.814998 7.51316071-37.57857 20.61272131-73.903917 40.28618971-106.877282 21.2814003-35.670293 48.7704861-67.1473767 81.6882804-92.5255597 38.602429-29.7610135 83.467691-51.1674988 130.978372-62.05777669 11.473831-2.62966514 22.9946-4.0869914 34.57273-5.4964306l3.658171-.44480576c3.050084-.37153079 6.104217-.74794222 9.162589-1.14972654zm-110.555861 549.44131429c-14.716752 1.577863-30.238964 4.25635-42.869928 12.522173 2.84343.683658 6.102369.004954 9.068638 0 7.124652-.011559 14.317732-.279903 21.434964.032202 17.817402.781913 36.381729 3.63214 53.58741 8.350042 22.029372 6.040631 41.432961 17.928687 62.656049 25.945156 22.389644 8.456554 44.67706 11.084675 68.427 11.084675 11.96813 0 23.845573-.035504 35.450133-3.302696-6.056202-3.225083-14.72582-2.619864-21.434964-3.963236-14.556814-2.915455-28.868774-6.474936-42.869928-11.470264-10.304996-3.676672-20.230803-8.214291-30.11097-12.848661l-6.348531-2.985046c-9.1705-4.309263-18.363277-8.560752-27.845391-12.142608-24.932161-9.418465-52.560181-14.071964-79.144482-11.221737zm22.259385-62.614168c-29.163917 0-58.660076 5.137344-84.915434 18.369597-6.361238 3.206092-12.407546 7.02566-18.137277 11.258891-1.746125 1.290529-4.841829 2.948483-5.487351 5.191839-.654591 2.275558 1.685942 4.182039 3.014086 5.637703 6.562396-3.497556 12.797498-7.199878 19.78612-9.855246 45.19892-17.169893 99.992458-13.570779 145.098218 2.172348 22.494346 7.851335 43.219483 19.592421 65.129314 28.800338 24.503461 10.297807 49.53043 16.975034 75.846795 20.399104 31.04195 4.037546 66.433549.7654 94.808495-13.242161 9.970556-4.921843 23.814245-12.422267 28.030337-23.320339-5.207047.454947-9.892236 2.685918-14.83959 4.224149-7.866632 2.445646-15.827248 4.51974-23.908229 6.138887-27.388113 5.486604-56.512458 6.619429-84.091013 1.639788-25.991939-4.693152-50.142596-14.119246-74.179513-24.03502l-3.068058-1.268177c-2.045137-.846788-4.089983-1.695816-6.135603-2.544467l-3.069142-1.272366c-12.279956-5.085721-24.606928-10.110797-37.210937-14.51024-24.485325-8.546552-50.726667-13.784628-76.671218-13.784628zm51.114145-447.9909432c-34.959602 7.7225298-66.276908 22.7605319-96.457338 41.7180089-17.521434 11.0054099-34.281927 22.2799893-49.465301 36.4444283-22.5792616 21.065423-39.8360564 46.668751-54.8866988 73.411509-15.507372 27.55357-25.4498976 59.665686-30.2554517 90.824149-4.7140432 30.568106-5.4906485 62.70747-.0906864 93.301172 6.7503648 38.248526 19.5989769 74.140579 39.8896436 107.337631 6.8187918-3.184625 11.659796-10.445603 17.3128555-15.336896 11.4149428-9.875888 23.3995608-19.029311 36.2745548-26.928535 4.765981-2.923712 9.662222-5.194315 14.83959-7.275014 1.953055-.785216 5.14604-1.502727 6.06527-3.647828 1.460876-3.406732-1.240754-9.335897-1.704904-12.865654-1.324845-10.095517-2.124534-20.362774-1.874735-30.549941.725492-29.668947 6.269727-59.751557 16.825623-87.521453 7.954845-20.924233 20.10682-39.922168 34.502872-56.971512 4.884699-5.785498 10.077731-11.170545 15.437296-16.512656 3.167428-3.157378 7.098271-5.858983 9.068639-9.908915-10.336599.006606-20.674847 2.987289-30.503603 6.013385-21.174447 6.519522-41.801477 16.19312-59.358362 29.841512-8.008432 6.226409-13.873368 14.387371-21.44733 20.939921-2.32322 2.010516-6.484901 4.704691-9.695199 3.187928-4.8500728-2.29042-4.1014979-11.835213-4.6571581-16.222019-2.1369011-16.873476 4.2548401-38.216325 12.3778671-52.843142 13.039878-23.479694 37.150915-43.528712 65.467327-42.82854 12.228647.302197 22.934587 4.551115 34.625711 7.324555-2.964621-4.211764-6.939158-7.28162-10.717482-10.733763-9.257431-8.459031-19.382979-16.184864-30.503603-22.028985-4.474136-2.350694-9.291232-3.77911-14.015169-5.506421-2.375159-.867783-5.36616-2.062533-6.259834-4.702213-1.654614-4.888817 7.148561-9.416813 10.381943-11.478522 12.499882-7.969406 27.826705-14.525258 42.869928-14.894334 23.509209-.577147 46.479246 12.467678 56.162903 34.665926 3.404469 7.803171 4.411273 16.054969 5.079109 24.382907l.121749 1.56229.174325 2.345587c.01913.260708.038244.521433.057403.782164l.11601 1.56437.120128 1.563971c7.38352-6.019164 12.576553-14.876995 19.78612-21.323859 16.861073-15.07846 39.936636-21.7722 61.831627-14.984333 19.786945 6.133107 36.984382 19.788105 47.105807 37.959541 2.648042 4.754231 10.035685 16.373942 4.698379 21.109183-4.177345 3.707277-9.475079.818243-13.880788-.719162-3.33605-1.16376-6.782939-1.90214-10.241828-2.585698l-1.887262-.369639c-.629089-.122886-1.257979-.246187-1.886079-.372129-11.980496-2.401886-25.91652-2.152533-37.923398-.041284-7.762754 1.364839-15.349083 4.127545-23.083807 5.271929v1.651348c21.149714.175043 41.608563 12.240618 52.043268 30.549941 4.323267 7.585468 6.482428 16.267431 8.138691 24.770223 2.047864 10.50918.608423 21.958802-2.263037 32.201289-.962925 3.433979-2.710699 9.255807-6.817143 10.046802-2.902789.558982-5.36781-2.330878-7.024898-4.279468-4.343878-5.10762-8.475879-9.96341-13.573278-14.374161-12.895604-11.157333-26.530715-21.449361-40.396663-31.373138-7.362086-5.269452-15.425755-12.12007-23.908229-15.340199 2.385052 5.745041 4.721463 11.086326 5.532694 17.339156 2.385876 18.392716-5.314223 35.704625-16.87179 49.540445-3.526876 4.222498-7.29943 8.475545-11.744712 11.755948-1.843407 1.360711-4.156734 3.137561-6.595373 2.752797-7.645687-1.207961-8.555849-12.73272-9.728176-18.637115-3.970415-19.998652-2.375984-39.861068 3.132802-59.448534-4.901187 2.485279-8.443727 7.923994-11.521293 12.385111-6.770975 9.816439-12.645804 20.199291-16.858599 31.375615-16.777806 44.519521-16.616219 96.664142 5.118834 139.523233 2.427098 4.786433 6.110614 4.144058 10.894733 4.144058.720854 0 1.44257-.004515 2.164851-.010924l2.168232-.022283c4.338648-.045438 8.686803-.064635 12.979772.508795 2.227588.297243 5.320818.032202 7.084256 1.673642 2.111344 1.966755.986008 5.338808.4996 7.758859-1.358647 6.765574-1.812904 12.914369-1.812904 19.816178 9.02412-1.398692 11.525415-15.866153 14.724172-23.118874 3.624982-8.216283 7.313444-16.440823 10.667192-24.770223 1.648843-4.093692 3.854171-8.671229 3.275427-13.210785-.649644-5.10184-4.335633-10.510831-6.904531-14.862134-4.86244-8.234447-10.389363-16.70834-13.969002-25.595896-2.861567-7.104926-.197036-15.983399 7.871579-18.521521 4.450228-1.400344 9.198073 1.345848 12.094266 4.562675 6.07269 6.74328 9.992815 16.777697 14.401823 24.692609l34.394873 61.925556c2.920926 5.243856 5.848447 10.481933 8.836976 15.687808 1.165732 2.031158 2.352075 5.167068 4.740424 6.0332 2.127008.77118 5.033095-.325315 7.148561-.748886 5.492297-1.099798 10.97635-2.287117 16.488434-3.28288 6.605266-1.193099 16.673928-.969342 21.434964-6.129805-6.963066-2.205375-15.011895-2.074919-22.259386-1.577863-4.352947.298894-9.178287 1.856116-13.178381-.686135-5.953149-3.783239-9.910373-12.522173-13.552668-18.377854-8.980425-14.439388-17.441465-29.095929-26.041008-43.760726l-1.376261-2.335014-2.765943-4.665258c-1.380597-2.334387-2.750786-4.67476-4.079753-7.036188-1.02723-1.826391-2.549937-4.233231-1.078344-6.24705 1.545791-2.114476 4.91472-2.239146 7.956473-2.243117l.603351.000261c1.195428.001526 2.315572.002427 3.222811-.11692 12.27399-1.615019 24.718635-2.952611 37.098976-2.952611-.963749-3.352237-3.719791-7.141255-2.838484-10.73046 1.972017-8.030506 13.526287-10.543033 18.899867-4.780653 3.60767 3.868283 5.704174 9.192229 8.051303 13.859765 3.097352 6.162006 6.624228 12.118418 9.940876 18.16483 5.805578 10.585967 12.146205 20.881297 18.116667 31.375615.49237.865561.999687 1.726685 1.512269 2.587098l.771613 1.290552c2.577138 4.303168 5.164895 8.635123 6.553094 13.461506-20.735854-.9487-36.30176-25.018751-45.343193-41.283704-.721369 2.604176.450959 4.928448 1.388326 7.431066 1.948109 5.197619 4.276275 10.147535 7.20627 14.862134 4.184765 6.732546 8.982075 13.665732 15.313633 18.553722 11.236043 8.673707 26.05255 8.721596 39.572241 7.794364 8.669619-.595311 19.50252-4.542034 28.030338-1.864372 8.513803 2.673532 11.940924 12.063098 6.884745 19.276187-3.787393 5.403211-8.842747 7.443452-15.128962 8.257566 4.445282 9.53571 10.268996 18.385285 14.490036 28.072919 1.758491 4.035895 3.59118 10.22102 7.8048 12.350433 2.805507 1.416857 6.824562.09743 9.85761.034678-3.043765-8.053625-8.742992-14.887729-11.541904-23.118874 8.533589.390544 16.786875 4.843404 24.732651 7.685374 15.630376 5.590144 31.063836 11.701854 46.475333 17.86913l7.112077 2.848685c6.338978 2.538947 12.71588 5.052299 18.961699 7.812528 2.285297 1.009799 5.449427 3.370401 7.975455 1.917215 2.061054-1.186494 3.394144-4.015253 4.665403-5.931643 3.55573-5.361927 6.775921-10.928622 9.965609-16.513481 12.774414-22.36586 22.143967-46.872692 28.402976-71.833646 20.645168-82.323009 2.934117-173.156241-46.677107-241.922507-19.061454-26.420745-43.033164-49.262193-69.46165-68.1783861-66.13923-47.336721-152.911262-66.294198-232.486917-48.7172481zm135.205158 410.5292842c-17.532977 4.570931-35.601827 8.714164-53.58741 11.040088 2.365265 8.052799 8.145286 15.885969 12.376218 23.118874 1.635653 2.796558 3.3859 6.541816 6.618457 7.755557 3.651364 1.370619 8.063669-.853747 11.508927-1.975838-1.595256-4.364513-4.279573-8.292245-6.476657-12.385112-.905215-1.687677-2.305907-3.685809-1.559805-5.68972 1.410585-3.786541 7.266452-3.563609 10.509727-4.221671 8.54678-1.733916 17.004522-3.898008 25.557073-5.611281 3.150939-.631641 7.538512-2.342438 10.705115-1.285575 2.371037.791232 3.800147 2.744743 5.152304 4.781948l.606196.918752c.80912 1.222827 1.637246 2.41754 2.671212 3.351165 3.457625 3.121874 8.628398 3.60159 13.017619 4.453686-2.678546-6.027421-7.130424-11.301001-9.984571-17.339156-1.659561-3.511592-3.023155-8.677834-6.656381-10.707341-5.005064-2.795733-15.341663 2.461334-20.458024 3.795624zm-110.472507-40.151706c-.825246 10.467897-4.036369 18.984725-9.068639 28.072919 5.76683.729896 11.649079.989984 17.312856 2.39363 4.244947 1.051908 8.156828 3.058296 12.366325 4.211763-2.250671-6.157877-6.426367-11.651913-9.661398-17.339156-3.266358-5.740912-6.189758-12.717032-10.949144-17.339156z" fill="#1f2937" transform="translate(.9778)"/></svg>`;
1321
- const gitignorePatterns = [];
1322
- for (const integration of options.chosenIntegrations) if (integration.gitignorePatterns) for (const pattern of integration.gitignorePatterns) gitignorePatterns.push({
1323
- pattern,
1324
- integrationId: integration.id
1325
- });
1326
- files[".gitignore"] = generateGitignore(gitignorePatterns).content;
1327
- files[".env.example"] = `# Add your environment variables here
1328
- # Copy this file to .env.local and fill in your values
1329
-
1330
- # Example:
1331
- # DATABASE_URL=postgresql://user:password@localhost:5432/db
1332
- `;
1333
- files["README.md"] = `# ${projectName}
1334
-
1335
- A full-stack React application built with [TanStack Start](https://tanstack.com/start).
1336
-
1337
- ## Getting Started
1338
-
1339
- \`\`\`bash
1340
- # Install dependencies
1341
- ${packageManager} install
1342
-
1343
- # Start development server
1344
- ${packageManager}${packageManager === "npm" ? " run" : ""} dev
1345
- \`\`\`
1346
-
1347
- ## Scripts
1348
-
1349
- - \`dev\` - Start development server
1350
- - \`build\` - Build for production
1351
- - \`start\` - Start production server
1352
-
1353
- ## Learn More
1354
-
1355
- - [TanStack Start Documentation](https://tanstack.com/start)
1356
- - [TanStack Router Documentation](https://tanstack.com/router)
1357
- `;
1358
- files[".nvmrc"] = "22.12.0";
1359
- return files;
1360
- }
1361
- /**
1362
- * Get base files WITH line-by-line attribution for files that have hooks
1363
- */
1364
- function getBaseFilesWithAttribution(options) {
1365
- const { typescript } = options;
1366
- const files = getBaseFiles(options);
1367
- const attributions = {};
1368
- const { vitePlugins, rootProviders, devtoolsPlugins, entryClientInits } = collectHooks(options);
1369
- attributions[typescript ? "vite.config.ts" : "vite.config.js"] = generateViteConfig(options, vitePlugins).lineAttributions;
1370
- if (entryClientInits.length > 0) attributions[`src/entry-client.${typescript ? "tsx" : "jsx"}`] = generateEntryClient(options, entryClientInits).lineAttributions;
1371
- attributions[`src/routes/__root.${typescript ? "tsx" : "jsx"}`] = generateRootRoute(options, rootProviders, devtoolsPlugins).lineAttributions;
1372
- const gitignorePatterns = [];
1373
- for (const integration of options.chosenIntegrations) if (integration.gitignorePatterns) for (const pattern of integration.gitignorePatterns) gitignorePatterns.push({
1374
- pattern,
1375
- integrationId: integration.id
1376
- });
1377
- attributions[".gitignore"] = generateGitignore(gitignorePatterns).lineAttributions;
1378
- return {
1379
- files,
1380
- attributions
1381
- };
1382
- }
1383
-
1384
- //#endregion
1385
- //#region src/engine/compile.ts
1386
- /**
1387
- * Merge package contributions from integrations
1388
- */
1389
- function mergePackages(target, source) {
1390
- if (!source) return;
1391
- if (source.dependencies) target.dependencies = {
1392
- ...target.dependencies,
1393
- ...source.dependencies
1394
- };
1395
- if (source.devDependencies) target.devDependencies = {
1396
- ...target.devDependencies,
1397
- ...source.devDependencies
1398
- };
1399
- if (source.scripts) target.scripts = {
1400
- ...target.scripts,
1401
- ...source.scripts
1402
- };
1403
- }
1404
- function mergePackagesWithAttribution(target, source, integrationId, attribution) {
1405
- if (!source) return;
1406
- if (source.dependencies) {
1407
- for (const pkg of Object.keys(source.dependencies)) attribution.dependencies.set(pkg, integrationId);
1408
- target.dependencies = {
1409
- ...target.dependencies,
1410
- ...source.dependencies
1411
- };
1412
- }
1413
- if (source.devDependencies) {
1414
- for (const pkg of Object.keys(source.devDependencies)) attribution.devDependencies.set(pkg, integrationId);
1415
- target.devDependencies = {
1416
- ...target.devDependencies,
1417
- ...source.devDependencies
1418
- };
1419
- }
1420
- if (source.scripts) {
1421
- for (const script of Object.keys(source.scripts)) attribution.scripts.set(script, integrationId);
1422
- target.scripts = {
1423
- ...target.scripts,
1424
- ...source.scripts
1425
- };
1426
- }
1427
- }
1428
- /**
1429
- * Process all files from an integration
1430
- */
1431
- function processIntegrationFiles(integration, options, files, appendFiles) {
1432
- for (const [filePath, content] of Object.entries(integration.files)) {
1433
- const processed = processTemplateFile(filePath, content, options);
1434
- if (!processed) continue;
1435
- if (processed.append) {
1436
- if (!appendFiles.has(processed.path)) appendFiles.set(processed.path, []);
1437
- appendFiles.get(processed.path).push({
1438
- content: processed.content,
1439
- integrationId: integration.id
1440
- });
1441
- } else files.set(processed.path, {
1442
- content: processed.content,
1443
- integrationId: integration.id
1444
- });
1445
- }
1446
- }
1447
- /**
1448
- * Build the package.json content
1449
- */
1450
- function buildPackageJson(options, packages) {
1451
- const hasHeader = options.chosenIntegrations.length > 0 && options.tailwind;
1452
- const pkg = {
1453
- name: options.projectName,
1454
- private: true,
1455
- type: "module",
1456
- scripts: {
1457
- dev: "vite dev --port 3000",
1458
- build: "vite build",
1459
- start: "node .output/server/index.mjs",
1460
- ...packages.scripts
1461
- },
1462
- dependencies: {
1463
- "@tanstack/react-router": "^1.132.0",
1464
- "@tanstack/react-router-devtools": "^1.132.0",
1465
- "@tanstack/react-start": "^1.132.0",
1466
- react: "^19.2.0",
1467
- "react-dom": "^19.2.0",
1468
- "vite-tsconfig-paths": "^5.1.4",
1469
- ...hasHeader ? { "lucide-react": "^0.468.0" } : {},
1470
- ...packages.dependencies
1471
- },
1472
- devDependencies: {
1473
- "@vitejs/plugin-react": "^4.4.1",
1474
- vite: "^7.0.0",
1475
- ...options.typescript ? {
1476
- "@types/react": "^19.2.0",
1477
- "@types/react-dom": "^19.2.0",
1478
- typescript: "^5.7.0"
1479
- } : {},
1480
- ...options.tailwind ? {
1481
- "@tailwindcss/vite": "^4.0.0",
1482
- tailwindcss: "^4.0.0"
1483
- } : {},
1484
- ...packages.devDependencies
1485
- }
1486
- };
1487
- return JSON.stringify(pkg, null, 2);
1488
- }
1489
- /**
1490
- * Compile a project from options
1491
- */
1492
- function compile(options) {
1493
- const files = /* @__PURE__ */ new Map();
1494
- const appendFiles = /* @__PURE__ */ new Map();
1495
- const packages = {
1496
- dependencies: {},
1497
- devDependencies: {},
1498
- scripts: {}
1499
- };
1500
- const envVars = [];
1501
- const warnings = [];
1502
- const baseFiles = getBaseFiles(options);
1503
- for (const [path, content] of Object.entries(baseFiles)) files.set(path, {
1504
- content,
1505
- integrationId: "base"
1506
- });
1507
- const sortedIntegrations = [...options.chosenIntegrations].sort((a, b) => {
1508
- const phaseOrder = {
1509
- setup: 0,
1510
- integration: 1,
1511
- example: 2
1512
- };
1513
- const phaseA = phaseOrder[a.phase];
1514
- const phaseB = phaseOrder[b.phase];
1515
- if (phaseA !== phaseB) return phaseA - phaseB;
1516
- return (a.priority ?? 100) - (b.priority ?? 100);
1517
- });
1518
- for (const integration of sortedIntegrations) {
1519
- processIntegrationFiles(integration, options, files, appendFiles);
1520
- mergePackages(packages, integration.packageAdditions);
1521
- if (integration.envVars) envVars.push(...integration.envVars);
1522
- if (integration.warning) warnings.push(`${integration.name}: ${integration.warning}`);
1523
- }
1524
- for (const [path, appends] of appendFiles) {
1525
- const existing = files.get(path);
1526
- if (existing) {
1527
- const appendContent = appends.map((a) => a.content).join("\n");
1528
- existing.content = existing.content + "\n" + appendContent;
1529
- } else files.set(path, {
1530
- content: appends.map((a) => a.content).join("\n"),
1531
- integrationId: appends[0]?.integrationId ?? "base"
1532
- });
1533
- }
1534
- const outputFiles = {};
1535
- for (const [path, { content }] of files) outputFiles[path] = content;
1536
- outputFiles["package.json"] = buildPackageJson(options, packages);
1537
- const seenEnvVars = /* @__PURE__ */ new Set();
1538
- return {
1539
- files: outputFiles,
1540
- packages,
1541
- envVars: envVars.filter((v) => {
1542
- if (seenEnvVars.has(v.name)) return false;
1543
- seenEnvVars.add(v.name);
1544
- return true;
1545
- }),
1546
- warnings
1547
- };
1548
- }
1549
- /**
1550
- * Compile with line-by-line attribution tracking
1551
- */
1552
- function compileWithAttribution(options) {
1553
- const files = /* @__PURE__ */ new Map();
1554
- const appendFiles = /* @__PURE__ */ new Map();
1555
- const packages = {
1556
- dependencies: {},
1557
- devDependencies: {},
1558
- scripts: {}
1559
- };
1560
- const packageAttribution = {
1561
- dependencies: /* @__PURE__ */ new Map(),
1562
- devDependencies: /* @__PURE__ */ new Map(),
1563
- scripts: /* @__PURE__ */ new Map()
1564
- };
1565
- const envVars = [];
1566
- const warnings = [];
1567
- const fileOwnership = /* @__PURE__ */ new Map();
1568
- const { files: baseFiles, attributions: baseAttributions } = getBaseFilesWithAttribution(options);
1569
- for (const [path, content] of Object.entries(baseFiles)) {
1570
- files.set(path, {
1571
- content,
1572
- integrationId: "base"
1573
- });
1574
- fileOwnership.set(path, "base");
1575
- }
1576
- const hookAttributions = /* @__PURE__ */ new Map();
1577
- for (const [path, attrs] of Object.entries(baseAttributions)) hookAttributions.set(path, attrs);
1578
- const sortedIntegrations = [...options.chosenIntegrations].sort((a, b) => {
1579
- const phaseOrder = {
1580
- setup: 0,
1581
- integration: 1,
1582
- example: 2
1583
- };
1584
- const phaseA = phaseOrder[a.phase];
1585
- const phaseB = phaseOrder[b.phase];
1586
- if (phaseA !== phaseB) return phaseA - phaseB;
1587
- return (a.priority ?? 100) - (b.priority ?? 100);
1588
- });
1589
- const integrationNames = /* @__PURE__ */ new Map();
1590
- integrationNames.set("base", "Base Template");
1591
- if (options.customTemplate) integrationNames.set(options.customTemplate.id, options.customTemplate.name);
1592
- for (const integration of sortedIntegrations) integrationNames.set(integration.id, integration.name);
1593
- for (const integration of sortedIntegrations) {
1594
- for (const [filePath, content] of Object.entries(integration.files)) {
1595
- const processed = processTemplateFile(filePath, content, options);
1596
- if (!processed) continue;
1597
- if (processed.append) {
1598
- if (!appendFiles.has(processed.path)) appendFiles.set(processed.path, []);
1599
- appendFiles.get(processed.path).push({
1600
- content: processed.content,
1601
- integrationId: integration.id
1602
- });
1603
- } else {
1604
- files.set(processed.path, {
1605
- content: processed.content,
1606
- integrationId: integration.id
1607
- });
1608
- fileOwnership.set(processed.path, integration.id);
1609
- }
1610
- }
1611
- mergePackagesWithAttribution(packages, integration.packageAdditions, integration.id, packageAttribution);
1612
- if (integration.envVars) for (const envVar of integration.envVars) envVars.push({
1613
- ...envVar,
1614
- integrationId: integration.id
1615
- });
1616
- if (integration.warning) warnings.push(`${integration.name}: ${integration.warning}`);
1617
- }
1618
- const appendOwnership = /* @__PURE__ */ new Map();
1619
- for (const [path, appends] of appendFiles) {
1620
- const existing = files.get(path);
1621
- if (existing) {
1622
- const existingLines = existing.content.split("\n").length;
1623
- const lineMap = /* @__PURE__ */ new Map();
1624
- let currentLine = existingLines + 1;
1625
- for (const append of appends) {
1626
- const appendLines = append.content.split("\n").length;
1627
- for (let i = 0; i < appendLines; i++) lineMap.set(currentLine + i, append.integrationId);
1628
- currentLine += appendLines + 1;
1629
- }
1630
- appendOwnership.set(path, lineMap);
1631
- const appendContent = appends.map((a) => a.content).join("\n");
1632
- existing.content = existing.content + "\n" + appendContent;
1633
- } else {
1634
- files.set(path, {
1635
- content: appends.map((a) => a.content).join("\n"),
1636
- integrationId: appends[0]?.integrationId ?? "base"
1637
- });
1638
- fileOwnership.set(path, appends[0]?.integrationId ?? "base");
1639
- }
1640
- }
1641
- const outputFiles = {};
1642
- const attributedFiles = {};
1643
- for (const [path, { content, integrationId }] of files) {
1644
- outputFiles[path] = content;
1645
- const lines = content.split("\n");
1646
- const attributions = [];
1647
- const appendLineMap = appendOwnership.get(path);
1648
- const hookAttrMap = hookAttributions.get(path);
1649
- for (let i = 0; i < lines.length; i++) {
1650
- const lineNumber = i + 1;
1651
- let owningIntegrationId = integrationId;
1652
- const appendIntegrationId = appendLineMap?.get(lineNumber);
1653
- const hookAttr = hookAttrMap?.find((a) => a.line === lineNumber);
1654
- if (appendIntegrationId) owningIntegrationId = appendIntegrationId;
1655
- else if (hookAttr) owningIntegrationId = hookAttr.integrationId;
1656
- attributions.push({
1657
- lineNumber,
1658
- featureId: owningIntegrationId,
1659
- featureName: integrationNames.get(owningIntegrationId) || owningIntegrationId
1660
- });
1661
- }
1662
- attributedFiles[path] = {
1663
- path,
1664
- content,
1665
- attributions
1666
- };
1667
- }
1668
- outputFiles["package.json"] = buildPackageJson(options, packages);
1669
- const pkgJsonLines = outputFiles["package.json"].split("\n");
1670
- const pkgJsonAttributions = [];
1671
- for (let i = 0; i < pkgJsonLines.length; i++) {
1672
- const line = pkgJsonLines[i];
1673
- const lineNumber = i + 1;
1674
- let integrationId = "base";
1675
- const match = line.match(/^\s*"([^"]+)":\s*"[^"]+"/);
1676
- if (match) {
1677
- const pkgName = match[1];
1678
- const depIntegration = packageAttribution.dependencies.get(pkgName);
1679
- const devDepIntegration = packageAttribution.devDependencies.get(pkgName);
1680
- const scriptIntegration = packageAttribution.scripts.get(pkgName);
1681
- if (depIntegration) integrationId = depIntegration;
1682
- else if (devDepIntegration) integrationId = devDepIntegration;
1683
- else if (scriptIntegration) integrationId = scriptIntegration;
1684
- }
1685
- pkgJsonAttributions.push({
1686
- lineNumber,
1687
- featureId: integrationId,
1688
- featureName: integrationNames.get(integrationId) || integrationId
1689
- });
1690
- }
1691
- attributedFiles["package.json"] = {
1692
- path: "package.json",
1693
- content: outputFiles["package.json"],
1694
- attributions: pkgJsonAttributions
1695
- };
1696
- const seenEnvVars = /* @__PURE__ */ new Set();
1697
- const uniqueEnvVars = envVars.filter((v) => {
1698
- if (seenEnvVars.has(v.name)) return false;
1699
- seenEnvVars.add(v.name);
1700
- return true;
1701
- });
1702
- if (uniqueEnvVars.length > 0) {
1703
- const envLines = [];
1704
- envLines.push({
1705
- text: "# Environment Variables",
1706
- integrationId: "base"
1707
- });
1708
- envLines.push({
1709
- text: "# Copy this file to .env.local and fill in your values",
1710
- integrationId: "base"
1711
- });
1712
- envLines.push({
1713
- text: "",
1714
- integrationId: "base"
1715
- });
1716
- const envByIntegration = /* @__PURE__ */ new Map();
1717
- for (const envVar of uniqueEnvVars) {
1718
- const id = envVar.integrationId;
1719
- if (!envByIntegration.has(id)) envByIntegration.set(id, []);
1720
- envByIntegration.get(id).push(envVar);
1721
- }
1722
- for (const [integrationId, vars] of envByIntegration) {
1723
- const integrationName = integrationNames.get(integrationId) || integrationId;
1724
- envLines.push({
1725
- text: `# ${integrationName}`,
1726
- integrationId
1727
- });
1728
- for (const v of vars) {
1729
- envLines.push({
1730
- text: `# ${v.description}${v.required ? " (required)" : ""}`,
1731
- integrationId
1732
- });
1733
- envLines.push({
1734
- text: `${v.name}=${v.example || ""}`,
1735
- integrationId
1736
- });
1737
- }
1738
- envLines.push({
1739
- text: "",
1740
- integrationId: "base"
1741
- });
1742
- }
1743
- const envContent = envLines.map((l) => l.text).join("\n");
1744
- outputFiles[".env.example"] = envContent;
1745
- attributedFiles[".env.example"] = {
1746
- path: ".env.example",
1747
- content: envContent,
1748
- attributions: envLines.map((l, i) => ({
1749
- lineNumber: i + 1,
1750
- featureId: l.integrationId,
1751
- featureName: integrationNames.get(l.integrationId) || l.integrationId
1752
- }))
1753
- };
1754
- }
1755
- return {
1756
- files: outputFiles,
1757
- packages,
1758
- envVars: uniqueEnvVars.map(({ integrationId, ...rest }) => rest),
1759
- warnings,
1760
- attributedFiles
1761
- };
1762
- }
1763
-
1764
- //#endregion
1765
- //#region src/engine/config-file.ts
1766
- const CONFIG_FILE = ".tanstack.json";
1767
- function createPersistedOptions(options) {
1768
- return {
1769
- version: 1,
1770
- projectName: options.projectName,
1771
- framework: options.framework,
1772
- mode: options.mode,
1773
- typescript: options.typescript,
1774
- tailwind: options.tailwind,
1775
- packageManager: options.packageManager,
1776
- chosenIntegrations: options.chosenIntegrations.map((integration) => integration.id),
1777
- customTemplate: options.customTemplate?.id
1778
- };
1779
- }
1780
- async function writeConfigFile(targetDir, options) {
1781
- await writeFile(resolve(targetDir, CONFIG_FILE), JSON.stringify(createPersistedOptions(options), null, 2));
1782
- }
1783
- async function readConfigFile(targetDir) {
1784
- const configPath = resolve(targetDir, CONFIG_FILE);
1785
- if (!existsSync(configPath)) return null;
1786
- try {
1787
- const content = await readFile(configPath, "utf-8");
1788
- return JSON.parse(content);
1789
- } catch {
1790
- return null;
1791
- }
1792
- }
1793
-
1794
- //#endregion
1795
- //#region src/engine/types.ts
1796
- const CategorySchema = z.enum([
1797
- "tanstack",
1798
- "database",
1799
- "orm",
1800
- "auth",
1801
- "deploy",
1802
- "tooling",
1803
- "monitoring",
1804
- "api",
1805
- "i18n",
1806
- "cms",
1807
- "other"
1808
- ]);
1809
- const IntegrationTypeSchema = z.enum([
1810
- "integration",
1811
- "example",
1812
- "toolchain",
1813
- "deployment"
1814
- ]);
1815
- const IntegrationPhaseSchema = z.enum([
1816
- "setup",
1817
- "integration",
1818
- "example"
1819
- ]);
1820
- const RouterModeSchema = z.enum(["file-router", "code-router"]);
1821
- const SelectOptionSchema = z.object({
1822
- type: z.literal("select"),
1823
- label: z.string(),
1824
- description: z.string().optional(),
1825
- default: z.string(),
1826
- options: z.array(z.object({
1827
- value: z.string(),
1828
- label: z.string()
1829
- }))
1830
- });
1831
- const BooleanOptionSchema = z.object({
1832
- type: z.literal("boolean"),
1833
- label: z.string(),
1834
- description: z.string().optional(),
1835
- default: z.boolean()
1836
- });
1837
- const StringOptionSchema = z.object({
1838
- type: z.literal("string"),
1839
- label: z.string(),
1840
- description: z.string().optional(),
1841
- default: z.string()
1842
- });
1843
- const IntegrationOptionSchema = z.discriminatedUnion("type", [
1844
- SelectOptionSchema,
1845
- BooleanOptionSchema,
1846
- StringOptionSchema
1847
- ]);
1848
- const IntegrationOptionsSchema = z.record(z.string(), IntegrationOptionSchema);
1849
- const HookTypeSchema = z.enum([
1850
- "header-user",
1851
- "provider",
1852
- "root-provider",
1853
- "layout",
1854
- "vite-plugin",
1855
- "devtools",
1856
- "entry-client"
1857
- ]);
1858
- const HookSchema = z.object({
1859
- type: HookTypeSchema.optional(),
1860
- path: z.string().optional(),
1861
- jsName: z.string().optional(),
1862
- import: z.string().optional(),
1863
- code: z.string().optional()
1864
- });
1865
- const RouteSchema = z.object({
1866
- url: z.string().optional(),
1867
- name: z.string().optional(),
1868
- icon: z.string().optional(),
1869
- path: z.string(),
1870
- jsName: z.string(),
1871
- children: z.array(z.lazy(() => RouteSchema)).optional()
1872
- });
1873
- const EnvVarSchema = z.object({
1874
- name: z.string(),
1875
- description: z.string(),
1876
- required: z.boolean().optional(),
1877
- example: z.string().optional()
1878
- });
1879
- const CommandSchema = z.object({
1880
- command: z.string(),
1881
- args: z.array(z.string()).optional()
1882
- });
1883
- const IntegrationInfoSchema = z.object({
1884
- id: z.string().optional(),
1885
- name: z.string(),
1886
- description: z.string(),
1887
- author: z.string().optional(),
1888
- version: z.string().optional(),
1889
- link: z.string().optional(),
1890
- license: z.string().optional(),
1891
- warning: z.string().optional(),
1892
- type: IntegrationTypeSchema,
1893
- phase: IntegrationPhaseSchema,
1894
- category: CategorySchema.optional(),
1895
- modes: z.array(RouterModeSchema),
1896
- priority: z.number().optional(),
1897
- default: z.boolean().optional(),
1898
- requiresTailwind: z.boolean().optional(),
1899
- demoRequiresTailwind: z.boolean().optional(),
1900
- dependsOn: z.array(z.string()).optional(),
1901
- exclusive: z.array(z.string()).optional(),
1902
- partnerId: z.string().optional(),
1903
- options: IntegrationOptionsSchema.optional(),
1904
- hooks: z.array(HookSchema).optional(),
1905
- routes: z.array(RouteSchema).optional(),
1906
- packageAdditions: z.object({
1907
- dependencies: z.record(z.string(), z.string()).optional(),
1908
- devDependencies: z.record(z.string(), z.string()).optional(),
1909
- scripts: z.record(z.string(), z.string()).optional()
1910
- }).optional(),
1911
- shadcnComponents: z.array(z.string()).optional(),
1912
- gitignorePatterns: z.array(z.string()).optional(),
1913
- envVars: z.array(EnvVarSchema).optional(),
1914
- command: CommandSchema.optional(),
1915
- integrationSpecialSteps: z.array(z.string()).optional(),
1916
- createSpecialSteps: z.array(z.string()).optional(),
1917
- postInitSpecialSteps: z.array(z.string()).optional(),
1918
- smallLogo: z.string().optional(),
1919
- logo: z.string().optional(),
1920
- readme: z.string().optional()
1921
- });
1922
- const IntegrationCompiledSchema = IntegrationInfoSchema.extend({
1923
- id: z.string(),
1924
- files: z.record(z.string(), z.string()),
1925
- deletedFiles: z.array(z.string()).optional()
1926
- });
1927
- const CustomTemplateInfoSchema = z.object({
1928
- id: z.string().optional(),
1929
- name: z.string(),
1930
- description: z.string(),
1931
- framework: z.string(),
1932
- mode: RouterModeSchema,
1933
- typescript: z.boolean(),
1934
- tailwind: z.boolean(),
1935
- integrations: z.array(z.string()),
1936
- integrationOptions: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
1937
- banner: z.string().optional()
1938
- });
1939
- const CustomTemplateCompiledSchema = CustomTemplateInfoSchema.extend({ id: z.string() });
1940
- const ManifestIntegrationSchema = z.object({
1941
- id: z.string(),
1942
- name: z.string(),
1943
- description: z.string(),
1944
- type: IntegrationTypeSchema,
1945
- category: CategorySchema.optional(),
1946
- modes: z.array(RouterModeSchema),
1947
- dependsOn: z.array(z.string()).optional(),
1948
- exclusive: z.array(z.string()).optional(),
1949
- partnerId: z.string().optional(),
1950
- hasOptions: z.boolean().optional(),
1951
- link: z.string().optional(),
1952
- color: z.string().optional(),
1953
- requiresTailwind: z.boolean().optional(),
1954
- demoRequiresTailwind: z.boolean().optional()
1955
- });
1956
- const ManifestCustomTemplateSchema = z.object({
1957
- id: z.string(),
1958
- name: z.string(),
1959
- description: z.string(),
1960
- banner: z.string().optional(),
1961
- icon: z.string().optional(),
1962
- features: z.array(z.string()).optional()
1963
- });
1964
- const ManifestSchema = z.object({
1965
- version: z.string(),
1966
- generated: z.string(),
1967
- integrations: z.array(ManifestIntegrationSchema),
1968
- customTemplates: z.array(ManifestCustomTemplateSchema).optional()
1969
- });
1970
-
1971
- //#endregion
1972
- //#region src/cache/index.ts
1973
- const CACHE_DIR = join(homedir(), ".tanstack", "cache");
1974
- const DEFAULT_TTL_MS = 1440 * 60 * 1e3;
1975
- function ensureCacheDir() {
1976
- if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
1977
- }
1978
- function getCachePath(key) {
1979
- return join(CACHE_DIR, `${key.replace(/[^a-zA-Z0-9-_]/g, "_")}.json`);
1980
- }
1981
- function getCached(key) {
1982
- const cachePath = getCachePath(key);
1983
- if (!existsSync(cachePath)) return null;
1984
- try {
1985
- const raw = readFileSync(cachePath, "utf-8");
1986
- const entry = JSON.parse(raw);
1987
- if (Date.now() - entry.timestamp > entry.ttl) return null;
1988
- return entry.data;
1989
- } catch {
1990
- return null;
1991
- }
1992
- }
1993
- function setCache(key, data, ttlMs = DEFAULT_TTL_MS) {
1994
- ensureCacheDir();
1995
- const cachePath = getCachePath(key);
1996
- const entry = {
1997
- data,
1998
- timestamp: Date.now(),
1999
- ttl: ttlMs
2000
- };
2001
- writeFileSync(cachePath, JSON.stringify(entry, null, 2), "utf-8");
2002
- }
2003
- async function fetchWithCache(key, fetcher, ttlMs = DEFAULT_TTL_MS) {
2004
- const cached = getCached(key);
2005
- if (cached !== null) return cached;
2006
- const data = await fetcher();
2007
- setCache(key, data, ttlMs);
2008
- return data;
2009
- }
2010
-
2011
- //#endregion
2012
- //#region src/api/fetch.ts
2013
- const GITHUB_RAW_BASE = "https://raw.githubusercontent.com/TanStack/cli/main/integrations";
2014
- const CACHE_TTL_MS = 3600 * 1e3;
2015
- /**
2016
- * Check if a path is a local directory
2017
- */
2018
- function isLocalPath(path) {
2019
- return path.startsWith("/") || path.startsWith("./") || path.startsWith("..");
2020
- }
2021
- /**
2022
- * Fetch the integration manifest from GitHub or local path (with caching for remote)
2023
- */
2024
- async function fetchManifest(baseUrl = GITHUB_RAW_BASE) {
2025
- if (isLocalPath(baseUrl)) {
2026
- const manifestPath = join(baseUrl, "manifest.json");
2027
- if (!existsSync(manifestPath)) throw new Error(`Manifest not found at ${manifestPath}`);
2028
- const data = JSON.parse(readFileSync(manifestPath, "utf-8"));
2029
- return ManifestSchema.parse(data);
2030
- }
2031
- return fetchWithCache(`manifest_${baseUrl.replace(/[^a-zA-Z0-9]/g, "_")}`, async () => {
2032
- const url = `${baseUrl}/manifest.json`;
2033
- const response = await fetch(url);
2034
- if (!response.ok) throw new Error(`Failed to fetch manifest: ${response.statusText}`);
2035
- const data = await response.json();
2036
- return ManifestSchema.parse(data);
2037
- }, CACHE_TTL_MS);
2038
- }
2039
- /**
2040
- * Fetch integration info.json from GitHub or local path (with caching for remote)
2041
- */
2042
- async function fetchIntegrationInfo(integrationId, baseUrl = GITHUB_RAW_BASE) {
2043
- if (isLocalPath(baseUrl)) {
2044
- const infoPath = join(baseUrl, integrationId, "info.json");
2045
- if (!existsSync(infoPath)) throw new Error(`Integration info not found at ${infoPath}`);
2046
- const data = JSON.parse(readFileSync(infoPath, "utf-8"));
2047
- return IntegrationInfoSchema.parse(data);
2048
- }
2049
- return fetchWithCache(`integration_info_${integrationId}_${baseUrl.replace(/[^a-zA-Z0-9]/g, "_")}`, async () => {
2050
- const url = `${baseUrl}/${integrationId}/info.json`;
2051
- const response = await fetch(url);
2052
- if (!response.ok) throw new Error(`Failed to fetch integration ${integrationId}: ${response.statusText}`);
2053
- const data = await response.json();
2054
- return IntegrationInfoSchema.parse(data);
2055
- }, CACHE_TTL_MS);
2056
- }
2057
- /**
2058
- * Recursively read all files from a directory
2059
- */
2060
- function readDirRecursive(dir, basePath = "") {
2061
- const files = {};
2062
- if (!existsSync(dir)) return files;
2063
- for (const entry of readdirSync(dir)) {
2064
- const fullPath = join(dir, entry);
2065
- const relativePath$1 = basePath ? `${basePath}/${entry}` : entry;
2066
- if (statSync(fullPath).isDirectory()) Object.assign(files, readDirRecursive(fullPath, relativePath$1));
2067
- else files[relativePath$1] = readFileSync(fullPath, "utf-8");
2068
- }
2069
- return files;
2070
- }
2071
- /**
2072
- * Fetch all files for an integration from GitHub or local path (with caching for remote)
2073
- */
2074
- async function fetchIntegrationFiles(integrationId, baseUrl = GITHUB_RAW_BASE) {
2075
- if (isLocalPath(baseUrl)) return readDirRecursive(join(baseUrl, integrationId, "assets"));
2076
- return fetchWithCache(`integration_files_${integrationId}_${baseUrl.replace(/[^a-zA-Z0-9]/g, "_")}`, async () => {
2077
- const filesUrl = `${baseUrl}/${integrationId}/files.json`;
2078
- const response = await fetch(filesUrl);
2079
- if (!response.ok) return {};
2080
- const fileList = await response.json();
2081
- const files = {};
2082
- await Promise.all(fileList.map(async (filePath) => {
2083
- const fileUrl = `${baseUrl}/${integrationId}/assets/${filePath}`;
2084
- const fileResponse = await fetch(fileUrl);
2085
- if (fileResponse.ok) files[filePath] = await fileResponse.text();
2086
- }));
2087
- return files;
2088
- }, CACHE_TTL_MS);
2089
- }
2090
- /**
2091
- * Fetch integration package.json if it exists
2092
- */
2093
- async function fetchIntegrationPackageJson(integrationId, baseUrl) {
2094
- if (isLocalPath(baseUrl)) {
2095
- const pkgPath = join(baseUrl, integrationId, "package.json");
2096
- if (existsSync(pkgPath)) return JSON.parse(readFileSync(pkgPath, "utf-8"));
2097
- return null;
2098
- }
2099
- const url = `${baseUrl}/${integrationId}/package.json`;
2100
- const response = await fetch(url);
2101
- if (!response.ok) return null;
2102
- return response.json();
2103
- }
2104
- /**
2105
- * Fetch a complete compiled integration from GitHub
2106
- */
2107
- async function fetchIntegration(integrationId, baseUrl = GITHUB_RAW_BASE) {
2108
- const [info, files, pkgJson] = await Promise.all([
2109
- fetchIntegrationInfo(integrationId, baseUrl),
2110
- fetchIntegrationFiles(integrationId, baseUrl),
2111
- fetchIntegrationPackageJson(integrationId, baseUrl)
2112
- ]);
2113
- const packageAdditions = info.packageAdditions ?? {};
2114
- if (pkgJson) {
2115
- if (pkgJson.dependencies) packageAdditions.dependencies = {
2116
- ...packageAdditions.dependencies,
2117
- ...pkgJson.dependencies
2118
- };
2119
- if (pkgJson.devDependencies) packageAdditions.devDependencies = {
2120
- ...packageAdditions.devDependencies,
2121
- ...pkgJson.devDependencies
2122
- };
2123
- if (pkgJson.scripts) packageAdditions.scripts = {
2124
- ...packageAdditions.scripts,
2125
- ...pkgJson.scripts
2126
- };
2127
- }
2128
- return IntegrationCompiledSchema.parse({
2129
- ...info,
2130
- id: integrationId,
2131
- files,
2132
- packageAdditions: Object.keys(packageAdditions).length > 0 ? packageAdditions : void 0,
2133
- deletedFiles: []
2134
- });
2135
- }
2136
- /**
2137
- * Fetch multiple integrations in parallel
2138
- */
2139
- async function fetchIntegrations(integrationIds, baseUrl = GITHUB_RAW_BASE) {
2140
- return Promise.all(integrationIds.map((id) => fetchIntegration(id, baseUrl)));
2141
- }
2142
-
2143
- //#endregion
2144
- //#region src/engine/custom-addons/shared.ts
2145
- /**
2146
- * Shared utilities for custom integration/template creation
2147
- * Based on Jack's implementation in create-tsrouter-app
2148
- */
2149
- const IGNORE_FILES = [
2150
- ".template",
2151
- ".integration",
2152
- ".tanstack.json",
2153
- ".git",
2154
- "integration-info.json",
2155
- "integration.json",
2156
- "build",
2157
- "bun.lock",
2158
- "bun.lockb",
2159
- "deno.lock",
2160
- "dist",
2161
- "node_modules",
2162
- "package-lock.json",
2163
- "pnpm-lock.yaml",
2164
- "template.json",
2165
- "template-info.json",
2166
- "yarn.lock"
2167
- ];
2168
- const PROJECT_FILES = ["package.json"];
2169
- const BINARY_EXTENSIONS = [
2170
- ".png",
2171
- ".jpg",
2172
- ".jpeg",
2173
- ".gif",
2174
- ".svg",
2175
- ".ico"
2176
- ];
2177
- /**
2178
- * Check if a file is binary based on extension
2179
- */
2180
- function isBinaryFile(path) {
2181
- return BINARY_EXTENSIONS.includes(extname(path));
2182
- }
2183
- /**
2184
- * Read file contents, handling binary files with base64 encoding
2185
- */
2186
- function readFileHelper(path) {
2187
- if (isBinaryFile(path)) return `base64::${readFileSync(path).toString("base64")}`;
2188
- return readFileSync(path, "utf-8");
2189
- }
2190
- /**
2191
- * Create an ignore function that respects .gitignore and standard ignore patterns
2192
- * Ported from Jack's createIgnore in file-helpers.ts
2193
- */
2194
- function createIgnore(path, includeProjectFiles = true) {
2195
- const gitignorePath = resolve(path, ".gitignore");
2196
- const ignoreList = existsSync(gitignorePath) ? parseGitignore(readFileSync(gitignorePath)).patterns : [];
2197
- const ig = ignore().add(ignoreList);
2198
- return (filePath) => {
2199
- const fileName = basename(filePath);
2200
- if (IGNORE_FILES.includes(fileName) || includeProjectFiles && PROJECT_FILES.includes(fileName)) return true;
2201
- const nameWithoutDotSlash = fileName.replace(/^\.\//, "");
2202
- return ig.ignores(nameWithoutDotSlash);
2203
- };
2204
- }
2205
- /**
2206
- * Create package.json additions by comparing original and current
2207
- * Ported from Jack's createPackageAdditions
2208
- */
2209
- function createPackageAdditions(originalPackageJson, currentPackageJson) {
2210
- const packageAdditions = {};
2211
- const origScripts = originalPackageJson.scripts || {};
2212
- const currScripts = currentPackageJson.scripts || {};
2213
- const scripts = {};
2214
- for (const script of Object.keys(currScripts)) {
2215
- const currValue = currScripts[script];
2216
- if (currValue && origScripts[script] !== currValue) scripts[script] = currValue;
2217
- }
2218
- if (Object.keys(scripts).length) packageAdditions.scripts = scripts;
2219
- const origDeps = originalPackageJson.dependencies || {};
2220
- const currDeps = currentPackageJson.dependencies || {};
2221
- const dependencies = {};
2222
- for (const dep of Object.keys(currDeps)) {
2223
- const currValue = currDeps[dep];
2224
- if (currValue && origDeps[dep] !== currValue) dependencies[dep] = currValue;
2225
- }
2226
- if (Object.keys(dependencies).length) packageAdditions.dependencies = dependencies;
2227
- const origDevDeps = originalPackageJson.devDependencies || {};
2228
- const currDevDeps = currentPackageJson.devDependencies || {};
2229
- const devDependencies = {};
2230
- for (const dep of Object.keys(currDevDeps)) {
2231
- const currValue = currDevDeps[dep];
2232
- if (currValue && origDevDeps[dep] !== currValue) devDependencies[dep] = currValue;
2233
- }
2234
- if (Object.keys(devDependencies).length) packageAdditions.devDependencies = devDependencies;
2235
- return packageAdditions;
2236
- }
2237
- async function createCompileOptionsFromPersisted(persisted, integrationsPath) {
2238
- let chosenIntegrations = [];
2239
- if (persisted.chosenIntegrations.length > 0) chosenIntegrations = await fetchIntegrations(persisted.chosenIntegrations, integrationsPath);
2240
- return {
2241
- projectName: persisted.projectName,
2242
- framework: persisted.framework,
2243
- mode: persisted.mode,
2244
- typescript: persisted.typescript,
2245
- tailwind: persisted.tailwind,
2246
- packageManager: persisted.packageManager,
2247
- chosenIntegrations,
2248
- integrationOptions: {},
2249
- customTemplate: void 0
2250
- };
2251
- }
2252
- function runCompile(options) {
2253
- return compile(options);
2254
- }
2255
- /**
2256
- * Compare files recursively between current project and original output
2257
- * Ported from Jack's compareFilesRecursively
2258
- */
2259
- async function compareFilesRecursively(basePath, ignoreFn, original, changedFiles) {
2260
- await compareFilesRecursivelyHelper(basePath, ".", ignoreFn, original, changedFiles);
2261
- }
2262
- async function compareFilesRecursivelyHelper(basePath, relativePath$1, ignoreFn, original, changedFiles) {
2263
- const entries = await readdir(resolve(basePath, relativePath$1), { withFileTypes: true });
2264
- for (const entry of entries) {
2265
- const entryRelativePath = relativePath$1 === "." ? entry.name : `${relativePath$1}/${entry.name}`;
2266
- const entryFullPath = resolve(basePath, entryRelativePath);
2267
- if (ignoreFn(entry.name)) continue;
2268
- if (entry.isDirectory()) await compareFilesRecursivelyHelper(basePath, entryRelativePath, ignoreFn, original, changedFiles);
2269
- else {
2270
- const contents = readFileHelper(entryFullPath);
2271
- const originalKey = entryRelativePath;
2272
- if (!original[originalKey] || original[originalKey] !== contents) changedFiles[entryRelativePath] = contents;
2273
- }
2274
- }
2275
- }
2276
- async function readCurrentProjectOptions(targetDir) {
2277
- const persisted = await readConfigFile(targetDir);
2278
- if (!persisted) throw new Error(`No .tanstack.json file found in ${targetDir}.\nThis project may have been created with an older version of the CLI, or was not created with the TanStack CLI.`);
2279
- return persisted;
2280
- }
2281
- /**
2282
- * Recursively gather files from a directory
2283
- * Ported from Jack's recursivelyGatherFiles
2284
- */
2285
- async function recursivelyGatherFiles(path, includeProjectFiles = true) {
2286
- const ignoreFn = createIgnore(path, includeProjectFiles);
2287
- const files = {};
2288
- if (!existsSync(path)) return files;
2289
- await gatherFilesHelper(path, ".", files, ignoreFn);
2290
- return files;
2291
- }
2292
- async function gatherFilesHelper(basePath, relativePath$1, files, ignoreFn) {
2293
- const entries = await readdir(resolve(basePath, relativePath$1), { withFileTypes: true });
2294
- for (const entry of entries) {
2295
- if (ignoreFn(entry.name)) continue;
2296
- const entryRelativePath = relativePath$1 === "." ? entry.name : `${relativePath$1}/${entry.name}`;
2297
- const entryFullPath = resolve(basePath, entryRelativePath);
2298
- if (entry.isDirectory()) await gatherFilesHelper(basePath, entryRelativePath, files, ignoreFn);
2299
- else files[entryRelativePath] = readFileHelper(entryFullPath);
2300
- }
2301
- }
2302
-
2303
- //#endregion
2304
- //#region src/engine/custom-addons/integration.ts
2305
- const INTEGRATION_DIR = ".integration";
2306
- const INFO_FILE$1 = ".integration/info.json";
2307
- const COMPILED_FILE$1 = "integration.json";
2308
- const ASSETS_DIR = "assets";
2309
- const INTEGRATION_IGNORE_FILES = [
2310
- "main.jsx",
2311
- "App.jsx",
2312
- "main.tsx",
2313
- "App.tsx",
2314
- "routeTree.gen.ts"
2315
- ];
2316
- function camelCase(str) {
2317
- return str.split(/(\.|-|\/)/).filter((part) => /^[a-zA-Z]+$/.test(part)).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
2318
- }
2319
- function templatize(routeCode, routeFile) {
2320
- let code = routeCode;
2321
- code = code.replace(/import { createFileRoute } from ['"]@tanstack\/react-router['"]/g, `import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/react-router'`);
2322
- const routeMatch = code.match(/export\s+const\s+Route\s*=\s*createFileRoute\(['"]([^'"]+)['"]\)\s*\(\{([^}]+)\}\)/);
2323
- let path = "";
2324
- if (routeMatch) {
2325
- const fullMatch = routeMatch[0];
2326
- path = routeMatch[1];
2327
- const routeDefinition = routeMatch[2];
2328
- code = code.replace(fullMatch, `<% if (codeRouter) { %>
2329
- import type { RootRoute } from '@tanstack/react-router'
2330
- <% } else { %>
2331
- export const Route = createFileRoute('${path}')({${routeDefinition}})
2332
- <% } %>`);
2333
- code += `
2334
- <% if (codeRouter) { %>
2335
- export default (parentRoute: RootRoute) => createRoute({
2336
- path: '${path}',
2337
- ${routeDefinition}
2338
- getParentRoute: () => parentRoute,
2339
- })
2340
- <% } %>
2341
- `;
2342
- } else console.warn(`No route found in the file: ${routeFile}`);
2343
- const name = basename(path).replace(".tsx", "").replace(/^demo/, "").replace(".", " ").trim();
2344
- const jsName = camelCase(basename(path));
2345
- return {
2346
- url: path,
2347
- code,
2348
- name,
2349
- jsName
2350
- };
2351
- }
2352
- async function validateIntegrationSetup(targetDir) {
2353
- const options = await readCurrentProjectOptions(targetDir);
2354
- if (options.mode === "code-router") throw new Error("This project is using code-router mode.\nTo create an integration, the project must use file-router mode.");
2355
- if (!options.tailwind) throw new Error("This project is not using Tailwind CSS.\nTo create an integration, the project must be created with Tailwind CSS.");
2356
- if (!options.typescript) throw new Error("This project is not using TypeScript.\nTo create an integration, the project must be created with TypeScript.");
2357
- }
2358
- async function readOrGenerateIntegrationInfo(options, targetDir) {
2359
- const infoPath = resolve(targetDir, INFO_FILE$1);
2360
- if (existsSync(infoPath)) {
2361
- const content = await readFile(infoPath, "utf-8");
2362
- return JSON.parse(content);
2363
- }
2364
- return {
2365
- id: `${options.projectName}-integration`,
2366
- name: `${options.projectName} Integration`,
2367
- description: "Custom integration",
2368
- author: "Author <author@example.com>",
2369
- version: "0.0.1",
2370
- license: "MIT",
2371
- link: `https://github.com/example/${options.projectName}-integration`,
2372
- type: "integration",
2373
- phase: "integration",
2374
- modes: [options.mode],
2375
- requiresTailwind: options.tailwind || void 0,
2376
- dependsOn: options.chosenIntegrations.length > 0 ? options.chosenIntegrations : void 0,
2377
- routes: [],
2378
- packageAdditions: {
2379
- scripts: {},
2380
- dependencies: {},
2381
- devDependencies: {}
2382
- }
2383
- };
2384
- }
2385
- async function generateBaseProject(persistedOptions, targetDir, integrationsPath) {
2386
- return {
2387
- info: await readOrGenerateIntegrationInfo(persistedOptions, targetDir),
2388
- output: runCompile(await createCompileOptionsFromPersisted(persistedOptions, integrationsPath))
2389
- };
2390
- }
2391
- async function buildAssetsDirectory(targetDir, output, info) {
2392
- const assetsDir = resolve(targetDir, INTEGRATION_DIR, ASSETS_DIR);
2393
- if (existsSync(assetsDir)) return;
2394
- const ignoreFn = createIgnore(targetDir);
2395
- const changedFiles = {};
2396
- await compareFilesRecursively(targetDir, ignoreFn, output.files, changedFiles);
2397
- for (const file of Object.keys(changedFiles)) {
2398
- if (INTEGRATION_IGNORE_FILES.includes(basename(file))) continue;
2399
- const targetPath = resolve(assetsDir, file);
2400
- mkdirSync(dirname(targetPath), { recursive: true });
2401
- const fileContent = changedFiles[file];
2402
- if (file.includes("/routes/")) {
2403
- const { url, code, name, jsName } = templatize(fileContent, file);
2404
- info.routes ||= [];
2405
- if (!info.routes.find((r) => r.url === url)) info.routes.push({
2406
- url,
2407
- name,
2408
- jsName,
2409
- path: file
2410
- });
2411
- writeFileSync(`${targetPath}.ejs`, code);
2412
- } else writeFileSync(targetPath, fileContent);
2413
- }
2414
- }
2415
- async function updateIntegrationInfo(targetDir, integrationsPath) {
2416
- const { info, output } = await generateBaseProject(await readCurrentProjectOptions(targetDir), targetDir, integrationsPath);
2417
- info.packageAdditions = createPackageAdditions(JSON.parse(output.files["package.json"]), JSON.parse(await readFile(resolve(targetDir, "package.json"), "utf-8")));
2418
- await buildAssetsDirectory(targetDir, output, info);
2419
- await mkdir(resolve(targetDir, dirname(INFO_FILE$1)), { recursive: true });
2420
- await writeFile(resolve(targetDir, INFO_FILE$1), JSON.stringify(info, null, 2));
2421
- }
2422
- async function compileIntegration(targetDir, _integrationsPath) {
2423
- const persistedOptions = await readCurrentProjectOptions(targetDir);
2424
- const info = await readOrGenerateIntegrationInfo(persistedOptions, targetDir);
2425
- const assetsDir = resolve(targetDir, INTEGRATION_DIR, ASSETS_DIR);
2426
- const compiledInfo = {
2427
- ...info,
2428
- id: info.id || `${persistedOptions.projectName}-integration`,
2429
- files: await recursivelyGatherFiles(assetsDir),
2430
- deletedFiles: []
2431
- };
2432
- await writeFile(resolve(targetDir, COMPILED_FILE$1), JSON.stringify(compiledInfo, null, 2));
2433
- console.log(`Compiled integration written to ${COMPILED_FILE$1}`);
2434
- }
2435
- async function initIntegration(targetDir, integrationsPath) {
2436
- await validateIntegrationSetup(targetDir);
2437
- await updateIntegrationInfo(targetDir, integrationsPath);
2438
- await compileIntegration(targetDir, integrationsPath);
2439
- console.log(`
2440
- Integration initialized successfully!
2441
-
2442
- Files created:
2443
- ${INFO_FILE$1} - Integration metadata (edit this to customize)
2444
- ${INTEGRATION_DIR}/${ASSETS_DIR}/ - Integration asset files
2445
- ${COMPILED_FILE$1} - Compiled integration (distribute this)
2446
-
2447
- Next steps:
2448
- 1. Edit ${INFO_FILE$1} to customize your integration metadata
2449
- 2. Run 'tanstack integration compile' to rebuild after changes
2450
- 3. Share ${COMPILED_FILE$1} or host it publicly
2451
- `);
2452
- }
2453
- /**
2454
- * Load a remote integration from a URL
2455
- */
2456
- async function loadRemoteIntegration(url) {
2457
- const response = await fetch(url);
2458
- if (!response.ok) throw new Error(`Failed to fetch integration from ${url}: ${response.statusText}`);
2459
- const jsonContent = await response.json();
2460
- const result = IntegrationCompiledSchema.safeParse(jsonContent);
2461
- if (!result.success) throw new Error(`Invalid integration at ${url}: ${result.error.message}`);
2462
- const integration = result.data;
2463
- if (!integration.id) integration.id = url;
2464
- return integration;
2465
- }
2466
-
2467
- //#endregion
2468
- //#region src/engine/custom-addons/template.ts
2469
- const INFO_FILE = "template-info.json";
2470
- const COMPILED_FILE = "template.json";
2471
- /**
2472
- * Generate default template info from project options
2473
- * Custom templates are just integration presets - they capture which integrations are selected
2474
- */
2475
- async function readOrGenerateTemplateInfo(options, targetDir) {
2476
- const infoPath = resolve(targetDir, INFO_FILE);
2477
- if (existsSync(infoPath)) {
2478
- const content = await readFile(infoPath, "utf-8");
2479
- return JSON.parse(content);
2480
- }
2481
- return {
2482
- id: `${options.projectName}-template`,
2483
- name: `${options.projectName} Template`,
2484
- description: "A curated project template",
2485
- framework: options.framework,
2486
- mode: options.mode,
2487
- typescript: options.typescript,
2488
- tailwind: options.tailwind,
2489
- integrations: options.chosenIntegrations
2490
- };
2491
- }
2492
- /**
2493
- * Compile a custom template from the current project
2494
- * Custom templates are just integration presets - they specify project defaults and which integrations to include
2495
- */
2496
- async function compileTemplate(targetDir) {
2497
- const persistedOptions = await readCurrentProjectOptions(targetDir);
2498
- const info = await readOrGenerateTemplateInfo(persistedOptions, targetDir);
2499
- const compiledInfo = {
2500
- ...info,
2501
- id: info.id || `${persistedOptions.projectName}-template`
2502
- };
2503
- await writeFile(resolve(targetDir, COMPILED_FILE), JSON.stringify(compiledInfo, null, 2));
2504
- console.log(`Compiled template written to ${COMPILED_FILE}`);
2505
- console.log(`\nIncluded integrations: ${compiledInfo.integrations.length > 0 ? compiledInfo.integrations.join(", ") : "(none)"}`);
2506
- }
2507
- async function initTemplate(targetDir) {
2508
- const info = await readOrGenerateTemplateInfo(await readCurrentProjectOptions(targetDir), targetDir);
2509
- await writeFile(resolve(targetDir, INFO_FILE), JSON.stringify(info, null, 2));
2510
- await compileTemplate(targetDir);
2511
- console.log(`
2512
- Custom template initialized successfully!
2513
-
2514
- Files created:
2515
- ${INFO_FILE} - Template metadata (edit this to customize)
2516
- ${COMPILED_FILE} - Compiled template (distribute this)
2517
-
2518
- Custom templates are integration presets. They capture:
2519
- - Project defaults (framework, mode, typescript, tailwind)
2520
- - Which integrations to include
2521
- - Preset integration options (if any)
2522
-
2523
- Next steps:
2524
- 1. Edit ${INFO_FILE} to customize name, description, and integrations
2525
- 2. Run 'tanstack template compile' to rebuild after changes
2526
- 3. Share ${COMPILED_FILE} or host it publicly
2527
- 4. Users can use: tanstack create --template <url-to-template.json>
2528
- `);
2529
- }
2530
- /**
2531
- * Load a remote custom template from a URL
2532
- */
2533
- async function loadTemplate(url) {
2534
- const response = await fetch(url);
2535
- if (!response.ok) throw new Error(`Failed to fetch template from ${url}: ${response.statusText}`);
2536
- const jsonContent = await response.json();
2537
- const result = CustomTemplateCompiledSchema.safeParse(jsonContent);
2538
- if (!result.success) throw new Error(`Invalid template at ${url}: ${result.error.message}`);
2539
- const template = result.data;
2540
- if (!template.id) template.id = url;
2541
- return template;
2542
- }
2543
-
2544
- //#endregion
2545
- export { writeConfigFile as A, IntegrationTypeSchema as C, RouterModeSchema as D, RouteSchema as E, compileWithAttribution as M, processTemplateFile as N, CONFIG_FILE as O, relativePath as P, IntegrationPhaseSchema as S, ManifestSchema as T, HookSchema as _, initIntegration as a, IntegrationOptionSchema as b, fetchIntegrationFiles as c, fetchManifest as d, CategorySchema as f, EnvVarSchema as g, CustomTemplateInfoSchema as h, compileIntegration as i, compile as j, readConfigFile as k, fetchIntegrationInfo as l, CustomTemplateCompiledSchema as m, initTemplate as n, loadRemoteIntegration as o, CommandSchema as p, loadTemplate as r, fetchIntegration as s, compileTemplate as t, fetchIntegrations as u, IntegrationCompiledSchema as v, ManifestIntegrationSchema as w, IntegrationOptionsSchema as x, IntegrationInfoSchema as y };