@tanstack/cli 0.0.8 → 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 (87) 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 -769
  54. package/dist/bin.d.cts +0 -1
  55. package/dist/bin.d.mts +0 -1
  56. package/dist/bin.mjs +0 -768
  57. package/dist/fetch-CbFFGJEw.cjs +0 -3
  58. package/dist/fetch-DG5dLrsb.cjs +0 -522
  59. package/dist/fetch-DhlVXS6S.mjs +0 -390
  60. package/dist/fetch-I_OVg8JX.mjs +0 -3
  61. package/dist/index.cjs +0 -37
  62. package/dist/index.d.cts +0 -1172
  63. package/dist/index.d.mts +0 -1172
  64. package/dist/index.mjs +0 -4
  65. package/dist/template-Szi7-AZJ.mjs +0 -2202
  66. package/dist/template-lWrIZhCQ.cjs +0 -2314
  67. package/src/api/fetch.test.ts +0 -114
  68. package/src/api/fetch.ts +0 -278
  69. package/src/cache/index.ts +0 -89
  70. package/src/commands/create.ts +0 -470
  71. package/src/commands/mcp.test.ts +0 -152
  72. package/src/commands/mcp.ts +0 -211
  73. package/src/engine/compile-with-addons.test.ts +0 -302
  74. package/src/engine/compile.test.ts +0 -404
  75. package/src/engine/compile.ts +0 -569
  76. package/src/engine/config-file.test.ts +0 -118
  77. package/src/engine/config-file.ts +0 -61
  78. package/src/engine/custom-addons/integration.ts +0 -323
  79. package/src/engine/custom-addons/shared.test.ts +0 -98
  80. package/src/engine/custom-addons/shared.ts +0 -281
  81. package/src/engine/custom-addons/template.test.ts +0 -288
  82. package/src/engine/custom-addons/template.ts +0 -124
  83. package/src/engine/template.test.ts +0 -256
  84. package/src/engine/template.ts +0 -269
  85. package/src/engine/types.ts +0 -336
  86. package/src/parse-gitignore.d.ts +0 -5
  87. package/src/templates/base.ts +0 -883
@@ -1,2314 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
- const require_fetch = require('./fetch-DG5dLrsb.cjs');
29
- let ejs = require("ejs");
30
- let node_fs_promises = require("node:fs/promises");
31
- let node_fs = require("node:fs");
32
- let node_path = require("node:path");
33
- let ignore = require("ignore");
34
- ignore = __toESM(ignore);
35
- let parse_gitignore = require("parse-gitignore");
36
- parse_gitignore = __toESM(parse_gitignore);
37
-
38
- //#region src/engine/template.ts
39
- /**
40
- * Convert _dot_ prefixes to actual dots (for dotfiles)
41
- */
42
- function convertDotFiles(path) {
43
- return path.split("/").map((segment) => segment.replace(/^_dot_/, ".")).join("/");
44
- }
45
- /**
46
- * Strip option prefixes from filename
47
- * e.g., __postgres__schema.prisma -> schema.prisma
48
- */
49
- function stripOptionPrefix(path) {
50
- const match = path.match(/^(.+\/)?__([^_]+)__(.+)$/);
51
- if (match) {
52
- const [, directory, , filename] = match;
53
- return (directory || "") + filename;
54
- }
55
- return path;
56
- }
57
- /**
58
- * Calculate relative path between two file paths
59
- */
60
- function relativePath(from, to, stripExtension = false) {
61
- const fromParts = from.split("/").slice(0, -1);
62
- const toParts = to.split("/");
63
- let commonLength = 0;
64
- while (commonLength < fromParts.length && commonLength < toParts.length && fromParts[commonLength] === toParts[commonLength]) commonLength++;
65
- const upCount = fromParts.length - commonLength;
66
- const ups = Array(upCount).fill("..");
67
- const remainder = toParts.slice(commonLength);
68
- let result = [...ups, ...remainder].join("/");
69
- if (!result.startsWith(".")) result = "./" + result;
70
- if (stripExtension) result = result.replace(/\.[^/.]+$/, "");
71
- return result;
72
- }
73
- /**
74
- * Error thrown when ignoreFile() is called in a template
75
- */
76
- var IgnoreFileError = class extends Error {
77
- constructor() {
78
- super("ignoreFile");
79
- this.name = "IgnoreFileError";
80
- }
81
- };
82
- /**
83
- * Create template context from compile options
84
- */
85
- function createTemplateContext(options, currentFile) {
86
- const hooks = [];
87
- for (const integration of options.chosenIntegrations) if (integration.hooks) hooks.push(...integration.hooks);
88
- const routes = [];
89
- for (const integration of options.chosenIntegrations) if (integration.routes) routes.push(...integration.routes);
90
- const integrationEnabled = {};
91
- for (const integration of options.chosenIntegrations) integrationEnabled[integration.id] = true;
92
- const localRelativePath = (to, stripExt = false) => relativePath(currentFile, to, stripExt);
93
- const hookImportContent = (hook) => hook.import || `import ${hook.jsName} from '${localRelativePath(hook.path || "")}'`;
94
- const hookImportCode = (hook) => hook.code || hook.jsName || "";
95
- return {
96
- packageManager: options.packageManager,
97
- projectName: options.projectName,
98
- typescript: options.typescript,
99
- tailwind: options.tailwind,
100
- js: options.typescript ? "ts" : "js",
101
- jsx: options.typescript ? "tsx" : "jsx",
102
- fileRouter: options.mode === "file-router",
103
- codeRouter: options.mode === "code-router",
104
- integrationEnabled,
105
- integrationOption: options.integrationOptions,
106
- integrations: options.chosenIntegrations,
107
- hooks,
108
- routes,
109
- getPackageManagerAddScript: (pkg, isDev = false) => {
110
- const pm = options.packageManager;
111
- if (pm === "npm") return `npm install ${isDev ? "-D " : ""}${pkg}`;
112
- if (pm === "yarn") return `yarn add ${isDev ? "-D " : ""}${pkg}`;
113
- if (pm === "pnpm") return `pnpm add ${isDev ? "-D " : ""}${pkg}`;
114
- if (pm === "bun") return `bun add ${isDev ? "-d " : ""}${pkg}`;
115
- if (pm === "deno") return `deno add ${pkg}`;
116
- return `npm install ${isDev ? "-D " : ""}${pkg}`;
117
- },
118
- getPackageManagerRunScript: (script, args = []) => {
119
- const pm = options.packageManager;
120
- const argsStr = args.length ? " " + args.join(" ") : "";
121
- if (pm === "npm") return `npm run ${script}${argsStr}`;
122
- if (pm === "yarn") return `yarn ${script}${argsStr}`;
123
- if (pm === "pnpm") return `pnpm ${script}${argsStr}`;
124
- if (pm === "bun") return `bun run ${script}${argsStr}`;
125
- if (pm === "deno") return `deno task ${script}${argsStr}`;
126
- return `npm run ${script}${argsStr}`;
127
- },
128
- relativePath: localRelativePath,
129
- hookImportContent,
130
- hookImportCode,
131
- ignoreFile: () => {
132
- throw new IgnoreFileError();
133
- }
134
- };
135
- }
136
- /**
137
- * Process a template file with EJS
138
- */
139
- function processTemplateFile(filePath, content, options) {
140
- const context = createTemplateContext(options, filePath);
141
- let processedContent = content;
142
- let shouldIgnore = false;
143
- if (filePath.endsWith(".ejs")) try {
144
- processedContent = (0, ejs.render)(content, context);
145
- } catch (error) {
146
- if (error instanceof IgnoreFileError) shouldIgnore = true;
147
- else throw new Error(`EJS error in file ${filePath}: ${error}`);
148
- }
149
- if (shouldIgnore) return null;
150
- let outputPath = filePath;
151
- outputPath = outputPath.replace(/\.ejs$/, "");
152
- outputPath = convertDotFiles(outputPath);
153
- outputPath = stripOptionPrefix(outputPath);
154
- let append = false;
155
- if (outputPath.endsWith(".append")) {
156
- append = true;
157
- outputPath = outputPath.replace(/\.append$/, "");
158
- }
159
- if (!options.typescript) outputPath = outputPath.replace(/\.tsx$/, ".jsx").replace(/\.ts$/, ".js");
160
- return {
161
- path: outputPath,
162
- content: processedContent,
163
- append
164
- };
165
- }
166
-
167
- //#endregion
168
- //#region src/templates/base.ts
169
- /**
170
- * Base TanStack Start template files
171
- * These provide the foundation for every project
172
- */
173
- /**
174
- * Collect all hooks from integrations, grouped by type
175
- */
176
- function collectHooks(options) {
177
- const hooks = [];
178
- for (const integration of options.chosenIntegrations) if (integration.hooks) for (const hook of integration.hooks) hooks.push({
179
- ...hook,
180
- integrationId: integration.id
181
- });
182
- return {
183
- vitePlugins: hooks.filter((i) => i.type === "vite-plugin"),
184
- rootProviders: hooks.filter((i) => i.type === "root-provider"),
185
- devtoolsPlugins: hooks.filter((i) => i.type === "devtools"),
186
- entryClientInits: hooks.filter((i) => i.type === "entry-client")
187
- };
188
- }
189
- /**
190
- * Generate vite.config.ts content with line attribution
191
- */
192
- function generateViteConfig(options, vitePlugins) {
193
- const { tailwind } = options;
194
- const lines = [];
195
- lines.push({
196
- text: `import { defineConfig } from 'vite'`,
197
- integrationId: "base"
198
- });
199
- lines.push({
200
- text: `import { tanstackStart } from '@tanstack/react-start/plugin/vite'`,
201
- integrationId: "base"
202
- });
203
- lines.push({
204
- text: `import viteReact from '@vitejs/plugin-react'`,
205
- integrationId: "base"
206
- });
207
- lines.push({
208
- text: `import viteTsConfigPaths from 'vite-tsconfig-paths'`,
209
- integrationId: "base"
210
- });
211
- if (tailwind) lines.push({
212
- text: `import tailwindcss from '@tailwindcss/vite'`,
213
- integrationId: "base"
214
- });
215
- for (const plugin of vitePlugins) if (plugin.import) lines.push({
216
- text: plugin.import,
217
- integrationId: plugin.integrationId
218
- });
219
- else {
220
- const importPath = relativePath("vite.config.ts", plugin.path || `src/integrations/${plugin.integrationId}/vite-plugin.ts`, true);
221
- lines.push({
222
- text: `import ${plugin.jsName} from '${importPath}'`,
223
- integrationId: plugin.integrationId
224
- });
225
- }
226
- lines.push({
227
- text: "",
228
- integrationId: "base"
229
- });
230
- lines.push({
231
- text: `export default defineConfig({`,
232
- integrationId: "base"
233
- });
234
- lines.push({
235
- text: ` plugins: [`,
236
- integrationId: "base"
237
- });
238
- lines.push({
239
- text: ` viteTsConfigPaths({`,
240
- integrationId: "base"
241
- });
242
- lines.push({
243
- text: ` projects: ['./tsconfig.json'],`,
244
- integrationId: "base"
245
- });
246
- lines.push({
247
- text: ` }),`,
248
- integrationId: "base"
249
- });
250
- if (tailwind) lines.push({
251
- text: ` tailwindcss(),`,
252
- integrationId: "base"
253
- });
254
- lines.push({
255
- text: ` tanstackStart(),`,
256
- integrationId: "base"
257
- });
258
- lines.push({
259
- text: ` viteReact(),`,
260
- integrationId: "base"
261
- });
262
- for (const plugin of vitePlugins) {
263
- const pluginCall = plugin.code || `${plugin.jsName}()`;
264
- lines.push({
265
- text: ` ${pluginCall},`,
266
- integrationId: plugin.integrationId
267
- });
268
- }
269
- lines.push({
270
- text: ` ],`,
271
- integrationId: "base"
272
- });
273
- lines.push({
274
- text: `})`,
275
- integrationId: "base"
276
- });
277
- return {
278
- content: lines.map((l) => l.text).join("\n"),
279
- lineAttributions: lines.map((l, i) => ({
280
- line: i + 1,
281
- integrationId: l.integrationId
282
- }))
283
- };
284
- }
285
- /**
286
- * Generate entry-client.tsx content with line attribution
287
- */
288
- function generateEntryClient(_options, entryClientInits) {
289
- const lines = [];
290
- lines.push({
291
- text: `import { hydrateRoot } from 'react-dom/client'`,
292
- integrationId: "base"
293
- });
294
- lines.push({
295
- text: `import { StartClient } from '@tanstack/react-start'`,
296
- integrationId: "base"
297
- });
298
- lines.push({
299
- text: `import { getRouter } from './router'`,
300
- integrationId: "base"
301
- });
302
- for (const init of entryClientInits) {
303
- const importPath = relativePath("src/entry-client.tsx", init.path || `src/integrations/${init.integrationId}/client.ts`, true);
304
- lines.push({
305
- text: `import { ${init.jsName} } from '${importPath}'`,
306
- integrationId: init.integrationId
307
- });
308
- }
309
- lines.push({
310
- text: "",
311
- integrationId: "base"
312
- });
313
- if (entryClientInits.length > 0) {
314
- lines.push({
315
- text: `// Initialize integrations`,
316
- integrationId: "base"
317
- });
318
- for (const init of entryClientInits) lines.push({
319
- text: `${init.jsName}()`,
320
- integrationId: init.integrationId
321
- });
322
- lines.push({
323
- text: "",
324
- integrationId: "base"
325
- });
326
- }
327
- lines.push({
328
- text: `const router = getRouter()`,
329
- integrationId: "base"
330
- });
331
- lines.push({
332
- text: "",
333
- integrationId: "base"
334
- });
335
- lines.push({
336
- text: `hydrateRoot(document.getElementById('root')!, <StartClient router={router} />)`,
337
- integrationId: "base"
338
- });
339
- return {
340
- content: lines.map((l) => l.text).join("\n"),
341
- lineAttributions: lines.map((l, i) => ({
342
- line: i + 1,
343
- integrationId: l.integrationId
344
- }))
345
- };
346
- }
347
- /**
348
- * Generate __root.tsx content with line attribution
349
- * This generates a full document route with shellComponent for proper SSR
350
- */
351
- function generateRootRoute(options, rootProviders, devtoolsPlugins) {
352
- const lines = [];
353
- const hasHeader = options.chosenIntegrations.length > 0;
354
- lines.push({
355
- text: `import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'`,
356
- integrationId: "base"
357
- });
358
- lines.push({
359
- text: `import { TanStackDevtools } from '@tanstack/react-devtools'`,
360
- integrationId: "base"
361
- });
362
- lines.push({
363
- text: `import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'`,
364
- integrationId: "base"
365
- });
366
- lines.push({
367
- text: `import appCss from '../styles.css?url'`,
368
- integrationId: "base"
369
- });
370
- if (hasHeader) lines.push({
371
- text: `import { Header } from '../components/Header'`,
372
- integrationId: "base"
373
- });
374
- for (const provider of rootProviders) {
375
- const importPath = relativePath("src/routes/__root.tsx", provider.path || `src/integrations/${provider.integrationId}/provider.tsx`, true);
376
- lines.push({
377
- text: `import { ${provider.jsName} } from '${importPath}'`,
378
- integrationId: provider.integrationId
379
- });
380
- }
381
- for (const devtools of devtoolsPlugins) {
382
- const importPath = relativePath("src/routes/__root.tsx", devtools.path || `src/integrations/${devtools.integrationId}/devtools.tsx`, true);
383
- lines.push({
384
- text: `import { ${devtools.jsName} } from '${importPath}'`,
385
- integrationId: devtools.integrationId
386
- });
387
- }
388
- lines.push({
389
- text: "",
390
- integrationId: "base"
391
- });
392
- lines.push({
393
- text: `export const Route = createRootRoute({`,
394
- integrationId: "base"
395
- });
396
- lines.push({
397
- text: ` head: () => ({`,
398
- integrationId: "base"
399
- });
400
- lines.push({
401
- text: ` meta: [`,
402
- integrationId: "base"
403
- });
404
- lines.push({
405
- text: ` { charSet: 'utf-8' },`,
406
- integrationId: "base"
407
- });
408
- lines.push({
409
- text: ` { name: 'viewport', content: 'width=device-width, initial-scale=1' },`,
410
- integrationId: "base"
411
- });
412
- lines.push({
413
- text: ` { title: 'TanStack Start Starter' },`,
414
- integrationId: "base"
415
- });
416
- lines.push({
417
- text: ` ],`,
418
- integrationId: "base"
419
- });
420
- lines.push({
421
- text: ` links: [{ rel: 'stylesheet', href: appCss }],`,
422
- integrationId: "base"
423
- });
424
- lines.push({
425
- text: ` }),`,
426
- integrationId: "base"
427
- });
428
- lines.push({
429
- text: ` shellComponent: RootDocument,`,
430
- integrationId: "base"
431
- });
432
- lines.push({
433
- text: `})`,
434
- integrationId: "base"
435
- });
436
- lines.push({
437
- text: "",
438
- integrationId: "base"
439
- });
440
- lines.push({
441
- text: `function RootDocument({ children }: { children: React.ReactNode }) {`,
442
- integrationId: "base"
443
- });
444
- lines.push({
445
- text: ` return (`,
446
- integrationId: "base"
447
- });
448
- lines.push({
449
- text: ` <html lang="en">`,
450
- integrationId: "base"
451
- });
452
- lines.push({
453
- text: ` <head>`,
454
- integrationId: "base"
455
- });
456
- lines.push({
457
- text: ` <HeadContent />`,
458
- integrationId: "base"
459
- });
460
- lines.push({
461
- text: ` </head>`,
462
- integrationId: "base"
463
- });
464
- lines.push({
465
- text: ` <body>`,
466
- integrationId: "base"
467
- });
468
- let currentIndent = " ";
469
- for (const provider of rootProviders) {
470
- lines.push({
471
- text: `${currentIndent}<${provider.jsName}>`,
472
- integrationId: provider.integrationId
473
- });
474
- currentIndent += " ";
475
- }
476
- if (hasHeader) lines.push({
477
- text: `${currentIndent}<Header />`,
478
- integrationId: "base"
479
- });
480
- lines.push({
481
- text: `${currentIndent}{children}`,
482
- integrationId: "base"
483
- });
484
- lines.push({
485
- text: `${currentIndent}<TanStackDevtools`,
486
- integrationId: "base"
487
- });
488
- lines.push({
489
- text: `${currentIndent} config={{ position: 'bottom-right' }}`,
490
- integrationId: "base"
491
- });
492
- lines.push({
493
- text: `${currentIndent} plugins={[`,
494
- integrationId: "base"
495
- });
496
- lines.push({
497
- text: `${currentIndent} { name: 'TanStack Router', render: <TanStackRouterDevtoolsPanel /> },`,
498
- integrationId: "base"
499
- });
500
- for (const devtools of devtoolsPlugins) lines.push({
501
- text: `${currentIndent} ${devtools.jsName},`,
502
- integrationId: devtools.integrationId
503
- });
504
- lines.push({
505
- text: `${currentIndent} ]}`,
506
- integrationId: "base"
507
- });
508
- lines.push({
509
- text: `${currentIndent}/>`,
510
- integrationId: "base"
511
- });
512
- for (const provider of [...rootProviders].reverse()) {
513
- currentIndent = currentIndent.slice(0, -2);
514
- lines.push({
515
- text: `${currentIndent}</${provider.jsName}>`,
516
- integrationId: provider.integrationId
517
- });
518
- }
519
- lines.push({
520
- text: ` <Scripts />`,
521
- integrationId: "base"
522
- });
523
- lines.push({
524
- text: ` </body>`,
525
- integrationId: "base"
526
- });
527
- lines.push({
528
- text: ` </html>`,
529
- integrationId: "base"
530
- });
531
- lines.push({
532
- text: ` )`,
533
- integrationId: "base"
534
- });
535
- lines.push({
536
- text: `}`,
537
- integrationId: "base"
538
- });
539
- return {
540
- content: lines.map((l) => l.text).join("\n"),
541
- lineAttributions: lines.map((l, i) => ({
542
- line: i + 1,
543
- integrationId: l.integrationId
544
- }))
545
- };
546
- }
547
- /**
548
- * Collect routes from integrations for navigation
549
- */
550
- function collectRoutes(options) {
551
- const routes = [];
552
- for (const integration of options.chosenIntegrations) if (integration.routes) {
553
- for (const route of integration.routes) if (route.url && route.name) routes.push({
554
- url: route.url,
555
- name: route.name,
556
- icon: route.icon || "Globe"
557
- });
558
- }
559
- return routes;
560
- }
561
- /**
562
- * Generate Header component with slide-out drawer navigation
563
- */
564
- function generateHeader(options) {
565
- const lines = [];
566
- const routes = collectRoutes(options);
567
- const icons = new Set([
568
- "Menu",
569
- "X",
570
- "Home"
571
- ]);
572
- for (const route of routes) icons.add(route.icon);
573
- lines.push({
574
- text: `import { useState } from 'react'`,
575
- integrationId: "base"
576
- });
577
- lines.push({
578
- text: `import { Link } from '@tanstack/react-router'`,
579
- integrationId: "base"
580
- });
581
- lines.push({
582
- text: `import { ${Array.from(icons).sort().join(", ")} } from 'lucide-react'`,
583
- integrationId: "base"
584
- });
585
- lines.push({
586
- text: "",
587
- integrationId: "base"
588
- });
589
- lines.push({
590
- text: `export function Header() {`,
591
- integrationId: "base"
592
- });
593
- lines.push({
594
- text: ` const [isOpen, setIsOpen] = useState(false)`,
595
- integrationId: "base"
596
- });
597
- lines.push({
598
- text: "",
599
- integrationId: "base"
600
- });
601
- lines.push({
602
- text: ` return (`,
603
- integrationId: "base"
604
- });
605
- lines.push({
606
- text: ` <>`,
607
- integrationId: "base"
608
- });
609
- lines.push({
610
- text: ` <header className="p-4 flex items-center bg-gray-800 text-white shadow-lg">`,
611
- integrationId: "base"
612
- });
613
- lines.push({
614
- text: ` <button`,
615
- integrationId: "base"
616
- });
617
- lines.push({
618
- text: ` onClick={() => setIsOpen(true)}`,
619
- integrationId: "base"
620
- });
621
- lines.push({
622
- text: ` className="p-2 hover:bg-gray-700 rounded-lg transition-colors"`,
623
- integrationId: "base"
624
- });
625
- lines.push({
626
- text: ` aria-label="Open menu"`,
627
- integrationId: "base"
628
- });
629
- lines.push({
630
- text: ` >`,
631
- integrationId: "base"
632
- });
633
- lines.push({
634
- text: ` <Menu size={24} />`,
635
- integrationId: "base"
636
- });
637
- lines.push({
638
- text: ` </button>`,
639
- integrationId: "base"
640
- });
641
- lines.push({
642
- text: ` <h1 className="ml-4 text-xl font-semibold">`,
643
- integrationId: "base"
644
- });
645
- lines.push({
646
- text: ` <Link to="/">`,
647
- integrationId: "base"
648
- });
649
- lines.push({
650
- text: ` <img`,
651
- integrationId: "base"
652
- });
653
- lines.push({
654
- text: ` src="/tanstack-logo-light.svg"`,
655
- integrationId: "base"
656
- });
657
- lines.push({
658
- text: ` alt="TanStack Logo"`,
659
- integrationId: "base"
660
- });
661
- lines.push({
662
- text: ` className="h-10"`,
663
- integrationId: "base"
664
- });
665
- lines.push({
666
- text: ` />`,
667
- integrationId: "base"
668
- });
669
- lines.push({
670
- text: ` </Link>`,
671
- integrationId: "base"
672
- });
673
- lines.push({
674
- text: ` </h1>`,
675
- integrationId: "base"
676
- });
677
- lines.push({
678
- text: ` </header>`,
679
- integrationId: "base"
680
- });
681
- lines.push({
682
- text: "",
683
- integrationId: "base"
684
- });
685
- lines.push({
686
- text: ` <aside`,
687
- integrationId: "base"
688
- });
689
- lines.push({
690
- 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 \${`,
691
- integrationId: "base"
692
- });
693
- lines.push({
694
- text: ` isOpen ? 'translate-x-0' : '-translate-x-full'`,
695
- integrationId: "base"
696
- });
697
- lines.push({
698
- text: ` }\`}`,
699
- integrationId: "base"
700
- });
701
- lines.push({
702
- text: ` >`,
703
- integrationId: "base"
704
- });
705
- lines.push({
706
- text: ` <div className="flex items-center justify-between p-4 border-b border-gray-700">`,
707
- integrationId: "base"
708
- });
709
- lines.push({
710
- text: ` <h2 className="text-xl font-bold">Navigation</h2>`,
711
- integrationId: "base"
712
- });
713
- lines.push({
714
- text: ` <button`,
715
- integrationId: "base"
716
- });
717
- lines.push({
718
- text: ` onClick={() => setIsOpen(false)}`,
719
- integrationId: "base"
720
- });
721
- lines.push({
722
- text: ` className="p-2 hover:bg-gray-800 rounded-lg transition-colors"`,
723
- integrationId: "base"
724
- });
725
- lines.push({
726
- text: ` aria-label="Close menu"`,
727
- integrationId: "base"
728
- });
729
- lines.push({
730
- text: ` >`,
731
- integrationId: "base"
732
- });
733
- lines.push({
734
- text: ` <X size={24} />`,
735
- integrationId: "base"
736
- });
737
- lines.push({
738
- text: ` </button>`,
739
- integrationId: "base"
740
- });
741
- lines.push({
742
- text: ` </div>`,
743
- integrationId: "base"
744
- });
745
- lines.push({
746
- text: "",
747
- integrationId: "base"
748
- });
749
- lines.push({
750
- text: ` <nav className="flex-1 p-4 overflow-y-auto">`,
751
- integrationId: "base"
752
- });
753
- lines.push({
754
- text: ` <Link`,
755
- integrationId: "base"
756
- });
757
- lines.push({
758
- text: ` to="/"`,
759
- integrationId: "base"
760
- });
761
- lines.push({
762
- text: ` onClick={() => setIsOpen(false)}`,
763
- integrationId: "base"
764
- });
765
- lines.push({
766
- text: ` className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2"`,
767
- integrationId: "base"
768
- });
769
- lines.push({
770
- text: ` activeProps={{`,
771
- integrationId: "base"
772
- });
773
- lines.push({
774
- text: ` className: 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2',`,
775
- integrationId: "base"
776
- });
777
- lines.push({
778
- text: ` }}`,
779
- integrationId: "base"
780
- });
781
- lines.push({
782
- text: ` >`,
783
- integrationId: "base"
784
- });
785
- lines.push({
786
- text: ` <Home size={20} />`,
787
- integrationId: "base"
788
- });
789
- lines.push({
790
- text: ` <span className="font-medium">Home</span>`,
791
- integrationId: "base"
792
- });
793
- lines.push({
794
- text: ` </Link>`,
795
- integrationId: "base"
796
- });
797
- for (const route of routes) {
798
- const integrationId = options.chosenIntegrations.find((i) => i.routes?.some((r) => r.url === route.url))?.id || "base";
799
- lines.push({
800
- text: "",
801
- integrationId
802
- });
803
- lines.push({
804
- text: ` <Link`,
805
- integrationId
806
- });
807
- lines.push({
808
- text: ` to="${route.url}"`,
809
- integrationId
810
- });
811
- lines.push({
812
- text: ` onClick={() => setIsOpen(false)}`,
813
- integrationId
814
- });
815
- lines.push({
816
- text: ` className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2"`,
817
- integrationId
818
- });
819
- lines.push({
820
- text: ` activeProps={{`,
821
- integrationId
822
- });
823
- lines.push({
824
- text: ` className: 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2',`,
825
- integrationId
826
- });
827
- lines.push({
828
- text: ` }}`,
829
- integrationId
830
- });
831
- lines.push({
832
- text: ` >`,
833
- integrationId
834
- });
835
- lines.push({
836
- text: ` <${route.icon} size={20} />`,
837
- integrationId
838
- });
839
- lines.push({
840
- text: ` <span className="font-medium">${route.name}</span>`,
841
- integrationId
842
- });
843
- lines.push({
844
- text: ` </Link>`,
845
- integrationId
846
- });
847
- }
848
- lines.push({
849
- text: ` </nav>`,
850
- integrationId: "base"
851
- });
852
- lines.push({
853
- text: ` </aside>`,
854
- integrationId: "base"
855
- });
856
- lines.push({
857
- text: "",
858
- integrationId: "base"
859
- });
860
- lines.push({
861
- text: ` {isOpen && (`,
862
- integrationId: "base"
863
- });
864
- lines.push({
865
- text: ` <div`,
866
- integrationId: "base"
867
- });
868
- lines.push({
869
- text: ` className="fixed inset-0 bg-black/50 z-40"`,
870
- integrationId: "base"
871
- });
872
- lines.push({
873
- text: ` onClick={() => setIsOpen(false)}`,
874
- integrationId: "base"
875
- });
876
- lines.push({
877
- text: ` />`,
878
- integrationId: "base"
879
- });
880
- lines.push({
881
- text: ` )}`,
882
- integrationId: "base"
883
- });
884
- lines.push({
885
- text: ` </>`,
886
- integrationId: "base"
887
- });
888
- lines.push({
889
- text: ` )`,
890
- integrationId: "base"
891
- });
892
- lines.push({
893
- text: `}`,
894
- integrationId: "base"
895
- });
896
- return {
897
- content: lines.map((l) => l.text).join("\n"),
898
- lineAttributions: lines.map((l, i) => ({
899
- line: i + 1,
900
- integrationId: l.integrationId
901
- }))
902
- };
903
- }
904
- /**
905
- * Generate .gitignore content with line attribution
906
- */
907
- function generateGitignore(integrationPatterns) {
908
- const lines = [];
909
- lines.push({
910
- text: "# Dependencies",
911
- integrationId: "base"
912
- });
913
- lines.push({
914
- text: "node_modules/",
915
- integrationId: "base"
916
- });
917
- lines.push({
918
- text: ".pnpm-store/",
919
- integrationId: "base"
920
- });
921
- lines.push({
922
- text: "",
923
- integrationId: "base"
924
- });
925
- lines.push({
926
- text: "# Build outputs",
927
- integrationId: "base"
928
- });
929
- lines.push({
930
- text: "dist/",
931
- integrationId: "base"
932
- });
933
- lines.push({
934
- text: ".output/",
935
- integrationId: "base"
936
- });
937
- lines.push({
938
- text: ".vinxi/",
939
- integrationId: "base"
940
- });
941
- lines.push({
942
- text: ".vercel/",
943
- integrationId: "base"
944
- });
945
- lines.push({
946
- text: ".netlify/",
947
- integrationId: "base"
948
- });
949
- lines.push({
950
- text: "",
951
- integrationId: "base"
952
- });
953
- lines.push({
954
- text: "# Environment",
955
- integrationId: "base"
956
- });
957
- lines.push({
958
- text: ".env",
959
- integrationId: "base"
960
- });
961
- lines.push({
962
- text: ".env.*",
963
- integrationId: "base"
964
- });
965
- lines.push({
966
- text: "!.env.example",
967
- integrationId: "base"
968
- });
969
- lines.push({
970
- text: "",
971
- integrationId: "base"
972
- });
973
- lines.push({
974
- text: "# IDE",
975
- integrationId: "base"
976
- });
977
- lines.push({
978
- text: ".idea/",
979
- integrationId: "base"
980
- });
981
- lines.push({
982
- text: ".vscode/",
983
- integrationId: "base"
984
- });
985
- lines.push({
986
- text: "*.swp",
987
- integrationId: "base"
988
- });
989
- lines.push({
990
- text: "*.swo",
991
- integrationId: "base"
992
- });
993
- lines.push({
994
- text: "",
995
- integrationId: "base"
996
- });
997
- lines.push({
998
- text: "# OS",
999
- integrationId: "base"
1000
- });
1001
- lines.push({
1002
- text: ".DS_Store",
1003
- integrationId: "base"
1004
- });
1005
- lines.push({
1006
- text: "Thumbs.db",
1007
- integrationId: "base"
1008
- });
1009
- lines.push({
1010
- text: "",
1011
- integrationId: "base"
1012
- });
1013
- lines.push({
1014
- text: "# Logs",
1015
- integrationId: "base"
1016
- });
1017
- lines.push({
1018
- text: "*.log",
1019
- integrationId: "base"
1020
- });
1021
- lines.push({
1022
- text: "npm-debug.log*",
1023
- integrationId: "base"
1024
- });
1025
- lines.push({
1026
- text: "pnpm-debug.log*",
1027
- integrationId: "base"
1028
- });
1029
- lines.push({
1030
- text: "",
1031
- integrationId: "base"
1032
- });
1033
- lines.push({
1034
- text: "# Generated",
1035
- integrationId: "base"
1036
- });
1037
- lines.push({
1038
- text: "src/routeTree.gen.ts",
1039
- integrationId: "base"
1040
- });
1041
- if (integrationPatterns.length > 0) {
1042
- lines.push({
1043
- text: "",
1044
- integrationId: "base"
1045
- });
1046
- lines.push({
1047
- text: "# Integration-specific",
1048
- integrationId: "base"
1049
- });
1050
- for (const { pattern, integrationId } of integrationPatterns) lines.push({
1051
- text: pattern,
1052
- integrationId
1053
- });
1054
- }
1055
- return {
1056
- content: lines.map((l) => l.text).join("\n"),
1057
- lineAttributions: lines.map((l, i) => ({
1058
- line: i + 1,
1059
- integrationId: l.integrationId
1060
- }))
1061
- };
1062
- }
1063
- /**
1064
- * Get base template files (static files without hook injection)
1065
- */
1066
- function getBaseFiles(options) {
1067
- const { projectName, typescript, tailwind, packageManager } = options;
1068
- const files = {};
1069
- const { vitePlugins, rootProviders, devtoolsPlugins, entryClientInits } = collectHooks(options);
1070
- if (typescript) files["tsconfig.json"] = JSON.stringify({
1071
- compilerOptions: {
1072
- target: "ES2022",
1073
- lib: [
1074
- "ES2022",
1075
- "DOM",
1076
- "DOM.Iterable"
1077
- ],
1078
- module: "ESNext",
1079
- skipLibCheck: true,
1080
- moduleResolution: "bundler",
1081
- allowImportingTsExtensions: true,
1082
- resolveJsonModule: true,
1083
- isolatedModules: true,
1084
- moduleDetection: "force",
1085
- noEmit: true,
1086
- jsx: "react-jsx",
1087
- strict: true,
1088
- noUnusedLocals: true,
1089
- noUnusedParameters: true,
1090
- noFallthroughCasesInSwitch: true,
1091
- noUncheckedIndexedAccess: true,
1092
- paths: { "~/*": ["./src/*"] }
1093
- },
1094
- include: ["src"]
1095
- }, null, 2);
1096
- files[typescript ? "vite.config.ts" : "vite.config.js"] = generateViteConfig(options, vitePlugins).content;
1097
- if (entryClientInits.length > 0) files[`src/entry-client.${typescript ? "tsx" : "jsx"}`] = generateEntryClient(options, entryClientInits).content;
1098
- files[`src/router.${typescript ? "tsx" : "jsx"}`] = `import { createRouter as createTanStackRouter } from '@tanstack/react-router'
1099
- import { routeTree } from './routeTree.gen'
1100
-
1101
- export function getRouter() {
1102
- const router = createTanStackRouter({
1103
- routeTree,
1104
- defaultPreload: 'intent',
1105
- scrollRestoration: true,
1106
- })
1107
-
1108
- return router
1109
- }
1110
-
1111
- declare module '@tanstack/react-router' {
1112
- interface Register {
1113
- router: ReturnType<typeof getRouter>
1114
- }
1115
- }
1116
- `;
1117
- files[`src/routes/__root.${typescript ? "tsx" : "jsx"}`] = generateRootRoute(options, rootProviders, devtoolsPlugins).content;
1118
- const hasHeader = options.chosenIntegrations.length > 0;
1119
- if (hasHeader && tailwind) files[`src/components/Header.${typescript ? "tsx" : "jsx"}`] = generateHeader(options).content;
1120
- const indexRouteWithHeader = `import { createFileRoute } from '@tanstack/react-router'
1121
-
1122
- export const Route = createFileRoute('/')({
1123
- component: Home,
1124
- })
1125
-
1126
- function Home() {
1127
- return (
1128
- <div className="min-h-[calc(100vh-72px)] bg-gradient-to-br from-gray-900 to-gray-800 flex items-center justify-center">
1129
- <div className="text-center px-4">
1130
- <img
1131
- src="/tanstack-logo-dark.svg"
1132
- alt="TanStack Logo"
1133
- className="h-24 mx-auto mb-8"
1134
- />
1135
- <h1 className="text-5xl font-bold text-white mb-4">
1136
- Welcome to TanStack Start
1137
- </h1>
1138
- <p className="text-xl text-gray-300 mb-8">
1139
- Full-stack React framework powered by TanStack Router
1140
- </p>
1141
- <div className="flex gap-4 justify-center flex-wrap">
1142
- <a
1143
- href="https://tanstack.com/start"
1144
- target="_blank"
1145
- rel="noopener noreferrer"
1146
- className="px-6 py-3 bg-cyan-500 text-white rounded-lg font-medium hover:bg-cyan-600 transition-colors"
1147
- >
1148
- Documentation
1149
- </a>
1150
- <a
1151
- href="https://github.com/tanstack/router"
1152
- target="_blank"
1153
- rel="noopener noreferrer"
1154
- className="px-6 py-3 bg-gray-700 text-white rounded-lg font-medium hover:bg-gray-600 transition-colors"
1155
- >
1156
- GitHub
1157
- </a>
1158
- </div>
1159
- </div>
1160
- </div>
1161
- )
1162
- }
1163
- `;
1164
- const indexRouteNoHeader = `import { createFileRoute } from '@tanstack/react-router'
1165
-
1166
- export const Route = createFileRoute('/')({
1167
- component: Home,
1168
- })
1169
-
1170
- function Home() {
1171
- return (
1172
- <div className="min-h-screen bg-gradient-to-br from-gray-900 to-gray-800 flex items-center justify-center">
1173
- <div className="text-center px-4">
1174
- <img
1175
- src="/tanstack-logo-dark.svg"
1176
- alt="TanStack Logo"
1177
- className="h-24 mx-auto mb-8"
1178
- />
1179
- <h1 className="text-5xl font-bold text-white mb-4">
1180
- Welcome to TanStack Start
1181
- </h1>
1182
- <p className="text-xl text-gray-300 mb-8">
1183
- Full-stack React framework powered by TanStack Router
1184
- </p>
1185
- <div className="flex gap-4 justify-center flex-wrap">
1186
- <a
1187
- href="https://tanstack.com/start"
1188
- target="_blank"
1189
- rel="noopener noreferrer"
1190
- className="px-6 py-3 bg-cyan-500 text-white rounded-lg font-medium hover:bg-cyan-600 transition-colors"
1191
- >
1192
- Documentation
1193
- </a>
1194
- <a
1195
- href="https://github.com/tanstack/router"
1196
- target="_blank"
1197
- rel="noopener noreferrer"
1198
- className="px-6 py-3 bg-gray-700 text-white rounded-lg font-medium hover:bg-gray-600 transition-colors"
1199
- >
1200
- GitHub
1201
- </a>
1202
- </div>
1203
- </div>
1204
- </div>
1205
- )
1206
- }
1207
- `;
1208
- const indexRouteNoTailwind = `import { createFileRoute } from '@tanstack/react-router'
1209
-
1210
- export const Route = createFileRoute('/')({
1211
- component: Home,
1212
- })
1213
-
1214
- function Home() {
1215
- return (
1216
- <div style={styles.container}>
1217
- <div style={styles.content}>
1218
- <img
1219
- src="/tanstack-logo-dark.svg"
1220
- alt="TanStack Logo"
1221
- style={styles.logo}
1222
- />
1223
- <h1 style={styles.title}>Welcome to TanStack Start</h1>
1224
- <p style={styles.subtitle}>
1225
- Full-stack React framework powered by TanStack Router
1226
- </p>
1227
- <div style={styles.buttons}>
1228
- <a
1229
- href="https://tanstack.com/start"
1230
- target="_blank"
1231
- rel="noopener noreferrer"
1232
- style={styles.primaryButton}
1233
- >
1234
- Documentation
1235
- </a>
1236
- <a
1237
- href="https://github.com/tanstack/router"
1238
- target="_blank"
1239
- rel="noopener noreferrer"
1240
- style={styles.secondaryButton}
1241
- >
1242
- GitHub
1243
- </a>
1244
- </div>
1245
- </div>
1246
- </div>
1247
- )
1248
- }
1249
-
1250
- const styles = {
1251
- container: {
1252
- minHeight: '100vh',
1253
- background: 'linear-gradient(to bottom right, #111827, #1f2937)',
1254
- display: 'flex',
1255
- alignItems: 'center',
1256
- justifyContent: 'center',
1257
- },
1258
- content: {
1259
- textAlign: 'center' as const,
1260
- padding: '0 1rem',
1261
- },
1262
- logo: {
1263
- height: '6rem',
1264
- marginBottom: '2rem',
1265
- },
1266
- title: {
1267
- fontSize: '3rem',
1268
- fontWeight: 'bold',
1269
- color: 'white',
1270
- marginBottom: '1rem',
1271
- },
1272
- subtitle: {
1273
- fontSize: '1.25rem',
1274
- color: '#d1d5db',
1275
- marginBottom: '2rem',
1276
- },
1277
- buttons: {
1278
- display: 'flex',
1279
- gap: '1rem',
1280
- justifyContent: 'center',
1281
- flexWrap: 'wrap' as const,
1282
- },
1283
- primaryButton: {
1284
- padding: '0.75rem 1.5rem',
1285
- backgroundColor: '#06b6d4',
1286
- color: 'white',
1287
- borderRadius: '0.5rem',
1288
- fontWeight: 500,
1289
- textDecoration: 'none',
1290
- },
1291
- secondaryButton: {
1292
- padding: '0.75rem 1.5rem',
1293
- backgroundColor: '#374151',
1294
- color: 'white',
1295
- borderRadius: '0.5rem',
1296
- fontWeight: 500,
1297
- textDecoration: 'none',
1298
- },
1299
- }
1300
- `;
1301
- if (tailwind) files[`src/routes/index.${typescript ? "tsx" : "jsx"}`] = hasHeader ? indexRouteWithHeader : indexRouteNoHeader;
1302
- else files[`src/routes/index.${typescript ? "tsx" : "jsx"}`] = indexRouteNoTailwind;
1303
- if (tailwind) files["src/styles.css"] = `@import 'tailwindcss';
1304
-
1305
- body {
1306
- @apply m-0;
1307
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
1308
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
1309
- sans-serif;
1310
- -webkit-font-smoothing: antialiased;
1311
- -moz-osx-font-smoothing: grayscale;
1312
- }
1313
-
1314
- code {
1315
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1316
- monospace;
1317
- }
1318
- `;
1319
- else files["src/styles.css"] = `* {
1320
- box-sizing: border-box;
1321
- margin: 0;
1322
- padding: 0;
1323
- }
1324
-
1325
- body {
1326
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
1327
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
1328
- sans-serif;
1329
- -webkit-font-smoothing: antialiased;
1330
- -moz-osx-font-smoothing: grayscale;
1331
- line-height: 1.5;
1332
- }
1333
-
1334
- code {
1335
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1336
- monospace;
1337
- }
1338
- `;
1339
- 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>`;
1340
- 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>`;
1341
- const gitignorePatterns = [];
1342
- for (const integration of options.chosenIntegrations) if (integration.gitignorePatterns) for (const pattern of integration.gitignorePatterns) gitignorePatterns.push({
1343
- pattern,
1344
- integrationId: integration.id
1345
- });
1346
- files[".gitignore"] = generateGitignore(gitignorePatterns).content;
1347
- files[".env.example"] = `# Add your environment variables here
1348
- # Copy this file to .env.local and fill in your values
1349
-
1350
- # Example:
1351
- # DATABASE_URL=postgresql://user:password@localhost:5432/db
1352
- `;
1353
- files["README.md"] = `# ${projectName}
1354
-
1355
- A full-stack React application built with [TanStack Start](https://tanstack.com/start).
1356
-
1357
- ## Getting Started
1358
-
1359
- \`\`\`bash
1360
- # Install dependencies
1361
- ${packageManager} install
1362
-
1363
- # Start development server
1364
- ${packageManager}${packageManager === "npm" ? " run" : ""} dev
1365
- \`\`\`
1366
-
1367
- ## Scripts
1368
-
1369
- - \`dev\` - Start development server
1370
- - \`build\` - Build for production
1371
- - \`start\` - Start production server
1372
-
1373
- ## Learn More
1374
-
1375
- - [TanStack Start Documentation](https://tanstack.com/start)
1376
- - [TanStack Router Documentation](https://tanstack.com/router)
1377
- `;
1378
- files[".nvmrc"] = "22.12.0";
1379
- return files;
1380
- }
1381
- /**
1382
- * Get base files WITH line-by-line attribution for files that have hooks
1383
- */
1384
- function getBaseFilesWithAttribution(options) {
1385
- const { typescript } = options;
1386
- const files = getBaseFiles(options);
1387
- const attributions = {};
1388
- const { vitePlugins, rootProviders, devtoolsPlugins, entryClientInits } = collectHooks(options);
1389
- attributions[typescript ? "vite.config.ts" : "vite.config.js"] = generateViteConfig(options, vitePlugins).lineAttributions;
1390
- if (entryClientInits.length > 0) attributions[`src/entry-client.${typescript ? "tsx" : "jsx"}`] = generateEntryClient(options, entryClientInits).lineAttributions;
1391
- attributions[`src/routes/__root.${typescript ? "tsx" : "jsx"}`] = generateRootRoute(options, rootProviders, devtoolsPlugins).lineAttributions;
1392
- const gitignorePatterns = [];
1393
- for (const integration of options.chosenIntegrations) if (integration.gitignorePatterns) for (const pattern of integration.gitignorePatterns) gitignorePatterns.push({
1394
- pattern,
1395
- integrationId: integration.id
1396
- });
1397
- attributions[".gitignore"] = generateGitignore(gitignorePatterns).lineAttributions;
1398
- return {
1399
- files,
1400
- attributions
1401
- };
1402
- }
1403
-
1404
- //#endregion
1405
- //#region src/engine/compile.ts
1406
- /**
1407
- * Merge package contributions from integrations
1408
- */
1409
- function mergePackages(target, source) {
1410
- if (!source) return;
1411
- if (source.dependencies) target.dependencies = {
1412
- ...target.dependencies,
1413
- ...source.dependencies
1414
- };
1415
- if (source.devDependencies) target.devDependencies = {
1416
- ...target.devDependencies,
1417
- ...source.devDependencies
1418
- };
1419
- if (source.scripts) target.scripts = {
1420
- ...target.scripts,
1421
- ...source.scripts
1422
- };
1423
- }
1424
- function mergePackagesWithAttribution(target, source, integrationId, attribution) {
1425
- if (!source) return;
1426
- if (source.dependencies) {
1427
- for (const pkg of Object.keys(source.dependencies)) attribution.dependencies.set(pkg, integrationId);
1428
- target.dependencies = {
1429
- ...target.dependencies,
1430
- ...source.dependencies
1431
- };
1432
- }
1433
- if (source.devDependencies) {
1434
- for (const pkg of Object.keys(source.devDependencies)) attribution.devDependencies.set(pkg, integrationId);
1435
- target.devDependencies = {
1436
- ...target.devDependencies,
1437
- ...source.devDependencies
1438
- };
1439
- }
1440
- if (source.scripts) {
1441
- for (const script of Object.keys(source.scripts)) attribution.scripts.set(script, integrationId);
1442
- target.scripts = {
1443
- ...target.scripts,
1444
- ...source.scripts
1445
- };
1446
- }
1447
- }
1448
- /**
1449
- * Process all files from an integration
1450
- */
1451
- function processIntegrationFiles(integration, options, files, appendFiles) {
1452
- for (const [filePath, content] of Object.entries(integration.files)) {
1453
- const processed = processTemplateFile(filePath, content, options);
1454
- if (!processed) continue;
1455
- if (processed.append) {
1456
- if (!appendFiles.has(processed.path)) appendFiles.set(processed.path, []);
1457
- appendFiles.get(processed.path).push({
1458
- content: processed.content,
1459
- integrationId: integration.id
1460
- });
1461
- } else files.set(processed.path, {
1462
- content: processed.content,
1463
- integrationId: integration.id
1464
- });
1465
- }
1466
- }
1467
- /**
1468
- * Build the package.json content
1469
- */
1470
- function buildPackageJson(options, packages) {
1471
- const hasHeader = options.chosenIntegrations.length > 0 && options.tailwind;
1472
- const pkg = {
1473
- name: options.projectName,
1474
- private: true,
1475
- type: "module",
1476
- scripts: {
1477
- dev: "vite dev --port 3000",
1478
- build: "vite build",
1479
- start: "node .output/server/index.mjs",
1480
- ...packages.scripts
1481
- },
1482
- dependencies: {
1483
- "@tanstack/react-router": "^1.132.0",
1484
- "@tanstack/react-router-devtools": "^1.132.0",
1485
- "@tanstack/react-devtools": "^0.9.2",
1486
- "@tanstack/react-start": "^1.132.0",
1487
- react: "^19.2.0",
1488
- "react-dom": "^19.2.0",
1489
- "vite-tsconfig-paths": "^5.1.4",
1490
- ...hasHeader ? { "lucide-react": "^0.468.0" } : {},
1491
- ...packages.dependencies
1492
- },
1493
- devDependencies: {
1494
- "@vitejs/plugin-react": "^4.4.1",
1495
- vite: "^7.0.0",
1496
- ...options.typescript ? {
1497
- "@types/react": "^19.2.0",
1498
- "@types/react-dom": "^19.2.0",
1499
- typescript: "^5.7.0"
1500
- } : {},
1501
- ...options.tailwind ? {
1502
- "@tailwindcss/vite": "^4.0.0",
1503
- tailwindcss: "^4.0.0"
1504
- } : {},
1505
- ...packages.devDependencies
1506
- }
1507
- };
1508
- return JSON.stringify(pkg, null, 2);
1509
- }
1510
- /**
1511
- * Compile a project from options
1512
- */
1513
- function compile(options) {
1514
- const files = /* @__PURE__ */ new Map();
1515
- const appendFiles = /* @__PURE__ */ new Map();
1516
- const packages = {
1517
- dependencies: {},
1518
- devDependencies: {},
1519
- scripts: {}
1520
- };
1521
- const envVars = [];
1522
- const warnings = [];
1523
- const baseFiles = getBaseFiles(options);
1524
- for (const [path, content] of Object.entries(baseFiles)) files.set(path, {
1525
- content,
1526
- integrationId: "base"
1527
- });
1528
- const sortedIntegrations = [...options.chosenIntegrations].sort((a, b) => {
1529
- const phaseOrder = {
1530
- setup: 0,
1531
- integration: 1,
1532
- example: 2
1533
- };
1534
- const phaseA = phaseOrder[a.phase];
1535
- const phaseB = phaseOrder[b.phase];
1536
- if (phaseA !== phaseB) return phaseA - phaseB;
1537
- return (a.priority ?? 100) - (b.priority ?? 100);
1538
- });
1539
- for (const integration of sortedIntegrations) {
1540
- processIntegrationFiles(integration, options, files, appendFiles);
1541
- mergePackages(packages, integration.packageAdditions);
1542
- if (integration.envVars) envVars.push(...integration.envVars);
1543
- if (integration.warning) warnings.push(`${integration.name}: ${integration.warning}`);
1544
- }
1545
- for (const [path, appends] of appendFiles) {
1546
- const existing = files.get(path);
1547
- if (existing) {
1548
- const appendContent = appends.map((a) => a.content).join("\n");
1549
- existing.content = existing.content + "\n" + appendContent;
1550
- } else files.set(path, {
1551
- content: appends.map((a) => a.content).join("\n"),
1552
- integrationId: appends[0]?.integrationId ?? "base"
1553
- });
1554
- }
1555
- const outputFiles = {};
1556
- for (const [path, { content }] of files) outputFiles[path] = content;
1557
- outputFiles["package.json"] = buildPackageJson(options, packages);
1558
- const seenEnvVars = /* @__PURE__ */ new Set();
1559
- const uniqueEnvVars = envVars.filter((v) => {
1560
- if (seenEnvVars.has(v.name)) return false;
1561
- seenEnvVars.add(v.name);
1562
- return true;
1563
- });
1564
- if (uniqueEnvVars.length > 0) {
1565
- const envLines = [
1566
- "# Environment Variables",
1567
- "# Copy this file to .env.local and fill in your values",
1568
- ""
1569
- ];
1570
- for (const v of uniqueEnvVars) {
1571
- envLines.push(`# ${v.description}${v.required ? " (required)" : ""}`);
1572
- envLines.push(`${v.name}=${v.example || ""}`);
1573
- envLines.push("");
1574
- }
1575
- outputFiles[".env.example"] = envLines.join("\n");
1576
- }
1577
- return {
1578
- files: outputFiles,
1579
- packages,
1580
- envVars: uniqueEnvVars,
1581
- warnings
1582
- };
1583
- }
1584
- /**
1585
- * Compile with line-by-line attribution tracking
1586
- */
1587
- function compileWithAttribution(options) {
1588
- const files = /* @__PURE__ */ new Map();
1589
- const appendFiles = /* @__PURE__ */ new Map();
1590
- const packages = {
1591
- dependencies: {},
1592
- devDependencies: {},
1593
- scripts: {}
1594
- };
1595
- const packageAttribution = {
1596
- dependencies: /* @__PURE__ */ new Map(),
1597
- devDependencies: /* @__PURE__ */ new Map(),
1598
- scripts: /* @__PURE__ */ new Map()
1599
- };
1600
- const envVars = [];
1601
- const warnings = [];
1602
- const fileOwnership = /* @__PURE__ */ new Map();
1603
- const { files: baseFiles, attributions: baseAttributions } = getBaseFilesWithAttribution(options);
1604
- for (const [path, content] of Object.entries(baseFiles)) {
1605
- files.set(path, {
1606
- content,
1607
- integrationId: "base"
1608
- });
1609
- fileOwnership.set(path, "base");
1610
- }
1611
- const hookAttributions = /* @__PURE__ */ new Map();
1612
- for (const [path, attrs] of Object.entries(baseAttributions)) hookAttributions.set(path, attrs);
1613
- const sortedIntegrations = [...options.chosenIntegrations].sort((a, b) => {
1614
- const phaseOrder = {
1615
- setup: 0,
1616
- integration: 1,
1617
- example: 2
1618
- };
1619
- const phaseA = phaseOrder[a.phase];
1620
- const phaseB = phaseOrder[b.phase];
1621
- if (phaseA !== phaseB) return phaseA - phaseB;
1622
- return (a.priority ?? 100) - (b.priority ?? 100);
1623
- });
1624
- const integrationNames = /* @__PURE__ */ new Map();
1625
- integrationNames.set("base", "Base Template");
1626
- if (options.customTemplate) integrationNames.set(options.customTemplate.id, options.customTemplate.name);
1627
- for (const integration of sortedIntegrations) integrationNames.set(integration.id, integration.name);
1628
- for (const integration of sortedIntegrations) {
1629
- for (const [filePath, content] of Object.entries(integration.files)) {
1630
- const processed = processTemplateFile(filePath, content, options);
1631
- if (!processed) continue;
1632
- if (processed.append) {
1633
- if (!appendFiles.has(processed.path)) appendFiles.set(processed.path, []);
1634
- appendFiles.get(processed.path).push({
1635
- content: processed.content,
1636
- integrationId: integration.id
1637
- });
1638
- } else {
1639
- files.set(processed.path, {
1640
- content: processed.content,
1641
- integrationId: integration.id
1642
- });
1643
- fileOwnership.set(processed.path, integration.id);
1644
- }
1645
- }
1646
- mergePackagesWithAttribution(packages, integration.packageAdditions, integration.id, packageAttribution);
1647
- if (integration.envVars) for (const envVar of integration.envVars) envVars.push({
1648
- ...envVar,
1649
- integrationId: integration.id
1650
- });
1651
- if (integration.warning) warnings.push(`${integration.name}: ${integration.warning}`);
1652
- }
1653
- const appendOwnership = /* @__PURE__ */ new Map();
1654
- for (const [path, appends] of appendFiles) {
1655
- const existing = files.get(path);
1656
- if (existing) {
1657
- const existingLines = existing.content.split("\n").length;
1658
- const lineMap = /* @__PURE__ */ new Map();
1659
- let currentLine = existingLines + 1;
1660
- for (const append of appends) {
1661
- const appendLines = append.content.split("\n").length;
1662
- for (let i = 0; i < appendLines; i++) lineMap.set(currentLine + i, append.integrationId);
1663
- currentLine += appendLines + 1;
1664
- }
1665
- appendOwnership.set(path, lineMap);
1666
- const appendContent = appends.map((a) => a.content).join("\n");
1667
- existing.content = existing.content + "\n" + appendContent;
1668
- } else {
1669
- files.set(path, {
1670
- content: appends.map((a) => a.content).join("\n"),
1671
- integrationId: appends[0]?.integrationId ?? "base"
1672
- });
1673
- fileOwnership.set(path, appends[0]?.integrationId ?? "base");
1674
- }
1675
- }
1676
- const outputFiles = {};
1677
- const attributedFiles = {};
1678
- for (const [path, { content, integrationId }] of files) {
1679
- outputFiles[path] = content;
1680
- const lines = content.split("\n");
1681
- const attributions = [];
1682
- const appendLineMap = appendOwnership.get(path);
1683
- const hookAttrMap = hookAttributions.get(path);
1684
- for (let i = 0; i < lines.length; i++) {
1685
- const lineNumber = i + 1;
1686
- let owningIntegrationId = integrationId;
1687
- const appendIntegrationId = appendLineMap?.get(lineNumber);
1688
- const hookAttr = hookAttrMap?.find((a) => a.line === lineNumber);
1689
- if (appendIntegrationId) owningIntegrationId = appendIntegrationId;
1690
- else if (hookAttr) owningIntegrationId = hookAttr.integrationId;
1691
- attributions.push({
1692
- lineNumber,
1693
- featureId: owningIntegrationId,
1694
- featureName: integrationNames.get(owningIntegrationId) || owningIntegrationId
1695
- });
1696
- }
1697
- attributedFiles[path] = {
1698
- path,
1699
- content,
1700
- attributions
1701
- };
1702
- }
1703
- outputFiles["package.json"] = buildPackageJson(options, packages);
1704
- const pkgJsonLines = outputFiles["package.json"].split("\n");
1705
- const pkgJsonAttributions = [];
1706
- for (let i = 0; i < pkgJsonLines.length; i++) {
1707
- const line = pkgJsonLines[i];
1708
- const lineNumber = i + 1;
1709
- let integrationId = "base";
1710
- const match = line.match(/^\s*"([^"]+)":\s*"[^"]+"/);
1711
- if (match) {
1712
- const pkgName = match[1];
1713
- const depIntegration = packageAttribution.dependencies.get(pkgName);
1714
- const devDepIntegration = packageAttribution.devDependencies.get(pkgName);
1715
- const scriptIntegration = packageAttribution.scripts.get(pkgName);
1716
- if (depIntegration) integrationId = depIntegration;
1717
- else if (devDepIntegration) integrationId = devDepIntegration;
1718
- else if (scriptIntegration) integrationId = scriptIntegration;
1719
- }
1720
- pkgJsonAttributions.push({
1721
- lineNumber,
1722
- featureId: integrationId,
1723
- featureName: integrationNames.get(integrationId) || integrationId
1724
- });
1725
- }
1726
- attributedFiles["package.json"] = {
1727
- path: "package.json",
1728
- content: outputFiles["package.json"],
1729
- attributions: pkgJsonAttributions
1730
- };
1731
- const seenEnvVars = /* @__PURE__ */ new Set();
1732
- const uniqueEnvVars = envVars.filter((v) => {
1733
- if (seenEnvVars.has(v.name)) return false;
1734
- seenEnvVars.add(v.name);
1735
- return true;
1736
- });
1737
- if (uniqueEnvVars.length > 0) {
1738
- const envLines = [];
1739
- envLines.push({
1740
- text: "# Environment Variables",
1741
- integrationId: "base"
1742
- });
1743
- envLines.push({
1744
- text: "# Copy this file to .env.local and fill in your values",
1745
- integrationId: "base"
1746
- });
1747
- envLines.push({
1748
- text: "",
1749
- integrationId: "base"
1750
- });
1751
- const envByIntegration = /* @__PURE__ */ new Map();
1752
- for (const envVar of uniqueEnvVars) {
1753
- const id = envVar.integrationId;
1754
- if (!envByIntegration.has(id)) envByIntegration.set(id, []);
1755
- envByIntegration.get(id).push(envVar);
1756
- }
1757
- for (const [integrationId, vars] of envByIntegration) {
1758
- const integrationName = integrationNames.get(integrationId) || integrationId;
1759
- envLines.push({
1760
- text: `# ${integrationName}`,
1761
- integrationId
1762
- });
1763
- for (const v of vars) {
1764
- envLines.push({
1765
- text: `# ${v.description}${v.required ? " (required)" : ""}`,
1766
- integrationId
1767
- });
1768
- envLines.push({
1769
- text: `${v.name}=${v.example || ""}`,
1770
- integrationId
1771
- });
1772
- }
1773
- envLines.push({
1774
- text: "",
1775
- integrationId: "base"
1776
- });
1777
- }
1778
- const envContent = envLines.map((l) => l.text).join("\n");
1779
- outputFiles[".env.example"] = envContent;
1780
- attributedFiles[".env.example"] = {
1781
- path: ".env.example",
1782
- content: envContent,
1783
- attributions: envLines.map((l, i) => ({
1784
- lineNumber: i + 1,
1785
- featureId: l.integrationId,
1786
- featureName: integrationNames.get(l.integrationId) || l.integrationId
1787
- }))
1788
- };
1789
- }
1790
- return {
1791
- files: outputFiles,
1792
- packages,
1793
- envVars: uniqueEnvVars.map(({ integrationId, ...rest }) => rest),
1794
- warnings,
1795
- attributedFiles
1796
- };
1797
- }
1798
-
1799
- //#endregion
1800
- //#region src/engine/config-file.ts
1801
- const CONFIG_FILE = ".tanstack.json";
1802
- function createPersistedOptions(options) {
1803
- return {
1804
- version: 1,
1805
- projectName: options.projectName,
1806
- framework: options.framework,
1807
- mode: options.mode,
1808
- typescript: options.typescript,
1809
- tailwind: options.tailwind,
1810
- packageManager: options.packageManager,
1811
- chosenIntegrations: options.chosenIntegrations.map((integration) => integration.id),
1812
- customTemplate: options.customTemplate?.id
1813
- };
1814
- }
1815
- async function writeConfigFile(targetDir, options) {
1816
- await (0, node_fs_promises.writeFile)((0, node_path.resolve)(targetDir, CONFIG_FILE), JSON.stringify(createPersistedOptions(options), null, 2));
1817
- }
1818
- async function readConfigFile(targetDir) {
1819
- const configPath = (0, node_path.resolve)(targetDir, CONFIG_FILE);
1820
- if (!(0, node_fs.existsSync)(configPath)) return null;
1821
- try {
1822
- const content = await (0, node_fs_promises.readFile)(configPath, "utf-8");
1823
- return JSON.parse(content);
1824
- } catch {
1825
- return null;
1826
- }
1827
- }
1828
-
1829
- //#endregion
1830
- //#region src/engine/custom-addons/shared.ts
1831
- /**
1832
- * Shared utilities for custom integration/template creation
1833
- * Based on Jack's implementation in create-tsrouter-app
1834
- */
1835
- const IGNORE_FILES = [
1836
- ".template",
1837
- ".integration",
1838
- ".tanstack.json",
1839
- ".git",
1840
- "integration-info.json",
1841
- "integration.json",
1842
- "build",
1843
- "bun.lock",
1844
- "bun.lockb",
1845
- "deno.lock",
1846
- "dist",
1847
- "node_modules",
1848
- "package-lock.json",
1849
- "pnpm-lock.yaml",
1850
- "template.json",
1851
- "template-info.json",
1852
- "yarn.lock"
1853
- ];
1854
- const PROJECT_FILES = ["package.json"];
1855
- const BINARY_EXTENSIONS = [
1856
- ".png",
1857
- ".jpg",
1858
- ".jpeg",
1859
- ".gif",
1860
- ".svg",
1861
- ".ico"
1862
- ];
1863
- /**
1864
- * Check if a file is binary based on extension
1865
- */
1866
- function isBinaryFile(path) {
1867
- return BINARY_EXTENSIONS.includes((0, node_path.extname)(path));
1868
- }
1869
- /**
1870
- * Read file contents, handling binary files with base64 encoding
1871
- */
1872
- function readFileHelper(path) {
1873
- if (isBinaryFile(path)) return `base64::${(0, node_fs.readFileSync)(path).toString("base64")}`;
1874
- return (0, node_fs.readFileSync)(path, "utf-8");
1875
- }
1876
- /**
1877
- * Create an ignore function that respects .gitignore and standard ignore patterns
1878
- * Ported from Jack's createIgnore in file-helpers.ts
1879
- */
1880
- function createIgnore(path, includeProjectFiles = true) {
1881
- const gitignorePath = (0, node_path.resolve)(path, ".gitignore");
1882
- const ignoreList = (0, node_fs.existsSync)(gitignorePath) ? (0, parse_gitignore.default)((0, node_fs.readFileSync)(gitignorePath)).patterns : [];
1883
- const ig = (0, ignore.default)().add(ignoreList);
1884
- return (filePath) => {
1885
- const fileName = (0, node_path.basename)(filePath);
1886
- if (IGNORE_FILES.includes(fileName) || includeProjectFiles && PROJECT_FILES.includes(fileName)) return true;
1887
- const nameWithoutDotSlash = fileName.replace(/^\.\//, "");
1888
- return ig.ignores(nameWithoutDotSlash);
1889
- };
1890
- }
1891
- /**
1892
- * Create package.json additions by comparing original and current
1893
- * Ported from Jack's createPackageAdditions
1894
- */
1895
- function createPackageAdditions(originalPackageJson, currentPackageJson) {
1896
- const packageAdditions = {};
1897
- const origScripts = originalPackageJson.scripts || {};
1898
- const currScripts = currentPackageJson.scripts || {};
1899
- const scripts = {};
1900
- for (const script of Object.keys(currScripts)) {
1901
- const currValue = currScripts[script];
1902
- if (currValue && origScripts[script] !== currValue) scripts[script] = currValue;
1903
- }
1904
- if (Object.keys(scripts).length) packageAdditions.scripts = scripts;
1905
- const origDeps = originalPackageJson.dependencies || {};
1906
- const currDeps = currentPackageJson.dependencies || {};
1907
- const dependencies = {};
1908
- for (const dep of Object.keys(currDeps)) {
1909
- const currValue = currDeps[dep];
1910
- if (currValue && origDeps[dep] !== currValue) dependencies[dep] = currValue;
1911
- }
1912
- if (Object.keys(dependencies).length) packageAdditions.dependencies = dependencies;
1913
- const origDevDeps = originalPackageJson.devDependencies || {};
1914
- const currDevDeps = currentPackageJson.devDependencies || {};
1915
- const devDependencies = {};
1916
- for (const dep of Object.keys(currDevDeps)) {
1917
- const currValue = currDevDeps[dep];
1918
- if (currValue && origDevDeps[dep] !== currValue) devDependencies[dep] = currValue;
1919
- }
1920
- if (Object.keys(devDependencies).length) packageAdditions.devDependencies = devDependencies;
1921
- return packageAdditions;
1922
- }
1923
- async function createCompileOptionsFromPersisted(persisted, integrationsPath) {
1924
- let chosenIntegrations = [];
1925
- if (persisted.chosenIntegrations.length > 0) chosenIntegrations = await require_fetch.fetchIntegrations(persisted.chosenIntegrations, integrationsPath);
1926
- return {
1927
- projectName: persisted.projectName,
1928
- framework: persisted.framework,
1929
- mode: persisted.mode,
1930
- typescript: persisted.typescript,
1931
- tailwind: persisted.tailwind,
1932
- packageManager: persisted.packageManager,
1933
- chosenIntegrations,
1934
- integrationOptions: {},
1935
- customTemplate: void 0
1936
- };
1937
- }
1938
- function runCompile(options) {
1939
- return compile(options);
1940
- }
1941
- /**
1942
- * Compare files recursively between current project and original output
1943
- * Ported from Jack's compareFilesRecursively
1944
- */
1945
- async function compareFilesRecursively(basePath, ignoreFn, original, changedFiles) {
1946
- await compareFilesRecursivelyHelper(basePath, ".", ignoreFn, original, changedFiles);
1947
- }
1948
- async function compareFilesRecursivelyHelper(basePath, relativePath$1, ignoreFn, original, changedFiles) {
1949
- const entries = await (0, node_fs_promises.readdir)((0, node_path.resolve)(basePath, relativePath$1), { withFileTypes: true });
1950
- for (const entry of entries) {
1951
- const entryRelativePath = relativePath$1 === "." ? entry.name : `${relativePath$1}/${entry.name}`;
1952
- const entryFullPath = (0, node_path.resolve)(basePath, entryRelativePath);
1953
- if (ignoreFn(entry.name)) continue;
1954
- if (entry.isDirectory()) await compareFilesRecursivelyHelper(basePath, entryRelativePath, ignoreFn, original, changedFiles);
1955
- else {
1956
- const contents = readFileHelper(entryFullPath);
1957
- const originalKey = entryRelativePath;
1958
- if (!original[originalKey] || original[originalKey] !== contents) changedFiles[entryRelativePath] = contents;
1959
- }
1960
- }
1961
- }
1962
- async function readCurrentProjectOptions(targetDir) {
1963
- const persisted = await readConfigFile(targetDir);
1964
- 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.`);
1965
- return persisted;
1966
- }
1967
- /**
1968
- * Recursively gather files from a directory
1969
- * Ported from Jack's recursivelyGatherFiles
1970
- */
1971
- async function recursivelyGatherFiles(path, includeProjectFiles = true) {
1972
- const ignoreFn = createIgnore(path, includeProjectFiles);
1973
- const files = {};
1974
- if (!(0, node_fs.existsSync)(path)) return files;
1975
- await gatherFilesHelper(path, ".", files, ignoreFn);
1976
- return files;
1977
- }
1978
- async function gatherFilesHelper(basePath, relativePath$1, files, ignoreFn) {
1979
- const entries = await (0, node_fs_promises.readdir)((0, node_path.resolve)(basePath, relativePath$1), { withFileTypes: true });
1980
- for (const entry of entries) {
1981
- if (ignoreFn(entry.name)) continue;
1982
- const entryRelativePath = relativePath$1 === "." ? entry.name : `${relativePath$1}/${entry.name}`;
1983
- const entryFullPath = (0, node_path.resolve)(basePath, entryRelativePath);
1984
- if (entry.isDirectory()) await gatherFilesHelper(basePath, entryRelativePath, files, ignoreFn);
1985
- else files[entryRelativePath] = readFileHelper(entryFullPath);
1986
- }
1987
- }
1988
-
1989
- //#endregion
1990
- //#region src/engine/custom-addons/integration.ts
1991
- const INTEGRATION_DIR = ".integration";
1992
- const INFO_FILE$1 = ".integration/info.json";
1993
- const COMPILED_FILE$1 = "integration.json";
1994
- const ASSETS_DIR = "assets";
1995
- const INTEGRATION_IGNORE_FILES = [
1996
- "main.jsx",
1997
- "App.jsx",
1998
- "main.tsx",
1999
- "App.tsx",
2000
- "routeTree.gen.ts"
2001
- ];
2002
- function camelCase(str) {
2003
- return str.split(/(\.|-|\/)/).filter((part) => /^[a-zA-Z]+$/.test(part)).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
2004
- }
2005
- function templatize(routeCode, routeFile) {
2006
- let code = routeCode;
2007
- code = code.replace(/import { createFileRoute } from ['"]@tanstack\/react-router['"]/g, `import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/react-router'`);
2008
- const routeMatch = code.match(/export\s+const\s+Route\s*=\s*createFileRoute\(['"]([^'"]+)['"]\)\s*\(\{([^}]+)\}\)/);
2009
- let path = "";
2010
- if (routeMatch) {
2011
- const fullMatch = routeMatch[0];
2012
- path = routeMatch[1];
2013
- const routeDefinition = routeMatch[2];
2014
- code = code.replace(fullMatch, `<% if (codeRouter) { %>
2015
- import type { RootRoute } from '@tanstack/react-router'
2016
- <% } else { %>
2017
- export const Route = createFileRoute('${path}')({${routeDefinition}})
2018
- <% } %>`);
2019
- code += `
2020
- <% if (codeRouter) { %>
2021
- export default (parentRoute: RootRoute) => createRoute({
2022
- path: '${path}',
2023
- ${routeDefinition}
2024
- getParentRoute: () => parentRoute,
2025
- })
2026
- <% } %>
2027
- `;
2028
- } else console.warn(`No route found in the file: ${routeFile}`);
2029
- const name = (0, node_path.basename)(path).replace(".tsx", "").replace(/^demo/, "").replace(".", " ").trim();
2030
- const jsName = camelCase((0, node_path.basename)(path));
2031
- return {
2032
- url: path,
2033
- code,
2034
- name,
2035
- jsName
2036
- };
2037
- }
2038
- async function validateIntegrationSetup(targetDir) {
2039
- const options = await readCurrentProjectOptions(targetDir);
2040
- 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.");
2041
- 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.");
2042
- if (!options.typescript) throw new Error("This project is not using TypeScript.\nTo create an integration, the project must be created with TypeScript.");
2043
- }
2044
- async function readOrGenerateIntegrationInfo(options, targetDir) {
2045
- const infoPath = (0, node_path.resolve)(targetDir, INFO_FILE$1);
2046
- if ((0, node_fs.existsSync)(infoPath)) {
2047
- const content = await (0, node_fs_promises.readFile)(infoPath, "utf-8");
2048
- return JSON.parse(content);
2049
- }
2050
- return {
2051
- id: `${options.projectName}-integration`,
2052
- name: `${options.projectName} Integration`,
2053
- description: "Custom integration",
2054
- author: "Author <author@example.com>",
2055
- version: "0.0.1",
2056
- license: "MIT",
2057
- link: `https://github.com/example/${options.projectName}-integration`,
2058
- type: "integration",
2059
- phase: "integration",
2060
- modes: [options.mode],
2061
- requiresTailwind: options.tailwind || void 0,
2062
- dependsOn: options.chosenIntegrations.length > 0 ? options.chosenIntegrations : void 0,
2063
- routes: [],
2064
- packageAdditions: {
2065
- scripts: {},
2066
- dependencies: {},
2067
- devDependencies: {}
2068
- }
2069
- };
2070
- }
2071
- async function generateBaseProject(persistedOptions, targetDir, integrationsPath) {
2072
- return {
2073
- info: await readOrGenerateIntegrationInfo(persistedOptions, targetDir),
2074
- output: runCompile(await createCompileOptionsFromPersisted(persistedOptions, integrationsPath))
2075
- };
2076
- }
2077
- async function buildAssetsDirectory(targetDir, output, info) {
2078
- const assetsDir = (0, node_path.resolve)(targetDir, INTEGRATION_DIR, ASSETS_DIR);
2079
- if ((0, node_fs.existsSync)(assetsDir)) return;
2080
- const ignoreFn = createIgnore(targetDir);
2081
- const changedFiles = {};
2082
- await compareFilesRecursively(targetDir, ignoreFn, output.files, changedFiles);
2083
- for (const file of Object.keys(changedFiles)) {
2084
- if (INTEGRATION_IGNORE_FILES.includes((0, node_path.basename)(file))) continue;
2085
- const targetPath = (0, node_path.resolve)(assetsDir, file);
2086
- (0, node_fs.mkdirSync)((0, node_path.dirname)(targetPath), { recursive: true });
2087
- const fileContent = changedFiles[file];
2088
- if (file.includes("/routes/")) {
2089
- const { url, code, name, jsName } = templatize(fileContent, file);
2090
- info.routes ||= [];
2091
- if (!info.routes.find((r) => r.url === url)) info.routes.push({
2092
- url,
2093
- name,
2094
- jsName,
2095
- path: file
2096
- });
2097
- (0, node_fs.writeFileSync)(`${targetPath}.ejs`, code);
2098
- } else (0, node_fs.writeFileSync)(targetPath, fileContent);
2099
- }
2100
- }
2101
- async function updateIntegrationInfo(targetDir, integrationsPath) {
2102
- const { info, output } = await generateBaseProject(await readCurrentProjectOptions(targetDir), targetDir, integrationsPath);
2103
- info.packageAdditions = createPackageAdditions(JSON.parse(output.files["package.json"]), JSON.parse(await (0, node_fs_promises.readFile)((0, node_path.resolve)(targetDir, "package.json"), "utf-8")));
2104
- await buildAssetsDirectory(targetDir, output, info);
2105
- await (0, node_fs_promises.mkdir)((0, node_path.resolve)(targetDir, (0, node_path.dirname)(INFO_FILE$1)), { recursive: true });
2106
- await (0, node_fs_promises.writeFile)((0, node_path.resolve)(targetDir, INFO_FILE$1), JSON.stringify(info, null, 2));
2107
- }
2108
- async function compileIntegration(targetDir, _integrationsPath) {
2109
- const persistedOptions = await readCurrentProjectOptions(targetDir);
2110
- const info = await readOrGenerateIntegrationInfo(persistedOptions, targetDir);
2111
- const assetsDir = (0, node_path.resolve)(targetDir, INTEGRATION_DIR, ASSETS_DIR);
2112
- const compiledInfo = {
2113
- ...info,
2114
- id: info.id || `${persistedOptions.projectName}-integration`,
2115
- files: await recursivelyGatherFiles(assetsDir),
2116
- deletedFiles: []
2117
- };
2118
- await (0, node_fs_promises.writeFile)((0, node_path.resolve)(targetDir, COMPILED_FILE$1), JSON.stringify(compiledInfo, null, 2));
2119
- console.log(`Compiled integration written to ${COMPILED_FILE$1}`);
2120
- }
2121
- async function initIntegration(targetDir, integrationsPath) {
2122
- await validateIntegrationSetup(targetDir);
2123
- await updateIntegrationInfo(targetDir, integrationsPath);
2124
- await compileIntegration(targetDir, integrationsPath);
2125
- console.log(`
2126
- Integration initialized successfully!
2127
-
2128
- Files created:
2129
- ${INFO_FILE$1} - Integration metadata (edit this to customize)
2130
- ${INTEGRATION_DIR}/${ASSETS_DIR}/ - Integration asset files
2131
- ${COMPILED_FILE$1} - Compiled integration (distribute this)
2132
-
2133
- Next steps:
2134
- 1. Edit ${INFO_FILE$1} to customize your integration metadata
2135
- 2. Run 'tanstack integration compile' to rebuild after changes
2136
- 3. Share ${COMPILED_FILE$1} or host it publicly
2137
- `);
2138
- }
2139
- /**
2140
- * Load a remote integration from a URL
2141
- */
2142
- async function loadRemoteIntegration(url) {
2143
- const response = await fetch(url);
2144
- if (!response.ok) throw new Error(`Failed to fetch integration from ${url}: ${response.statusText}`);
2145
- const jsonContent = await response.json();
2146
- const result = require_fetch.IntegrationCompiledSchema.safeParse(jsonContent);
2147
- if (!result.success) throw new Error(`Invalid integration at ${url}: ${result.error.message}`);
2148
- const integration = result.data;
2149
- if (!integration.id) integration.id = url;
2150
- return integration;
2151
- }
2152
-
2153
- //#endregion
2154
- //#region src/engine/custom-addons/template.ts
2155
- const INFO_FILE = "template-info.json";
2156
- const COMPILED_FILE = "template.json";
2157
- /**
2158
- * Generate default template info from project options
2159
- * Custom templates are just integration presets - they capture which integrations are selected
2160
- */
2161
- async function readOrGenerateTemplateInfo(options, targetDir) {
2162
- const infoPath = (0, node_path.resolve)(targetDir, INFO_FILE);
2163
- if ((0, node_fs.existsSync)(infoPath)) {
2164
- const content = await (0, node_fs_promises.readFile)(infoPath, "utf-8");
2165
- return JSON.parse(content);
2166
- }
2167
- return {
2168
- id: `${options.projectName}-template`,
2169
- name: `${options.projectName} Template`,
2170
- description: "A curated project template",
2171
- framework: options.framework,
2172
- mode: options.mode,
2173
- typescript: options.typescript,
2174
- tailwind: options.tailwind,
2175
- integrations: options.chosenIntegrations
2176
- };
2177
- }
2178
- /**
2179
- * Compile a custom template from the current project
2180
- * Custom templates are just integration presets - they specify project defaults and which integrations to include
2181
- */
2182
- async function compileTemplate(targetDir) {
2183
- const persistedOptions = await readCurrentProjectOptions(targetDir);
2184
- const info = await readOrGenerateTemplateInfo(persistedOptions, targetDir);
2185
- const compiledInfo = {
2186
- ...info,
2187
- id: info.id || `${persistedOptions.projectName}-template`
2188
- };
2189
- await (0, node_fs_promises.writeFile)((0, node_path.resolve)(targetDir, COMPILED_FILE), JSON.stringify(compiledInfo, null, 2));
2190
- console.log(`Compiled template written to ${COMPILED_FILE}`);
2191
- console.log(`\nIncluded integrations: ${compiledInfo.integrations.length > 0 ? compiledInfo.integrations.join(", ") : "(none)"}`);
2192
- }
2193
- async function initTemplate(targetDir) {
2194
- const info = await readOrGenerateTemplateInfo(await readCurrentProjectOptions(targetDir), targetDir);
2195
- await (0, node_fs_promises.writeFile)((0, node_path.resolve)(targetDir, INFO_FILE), JSON.stringify(info, null, 2));
2196
- await compileTemplate(targetDir);
2197
- console.log(`
2198
- Custom template initialized successfully!
2199
-
2200
- Files created:
2201
- ${INFO_FILE} - Template metadata (edit this to customize)
2202
- ${COMPILED_FILE} - Compiled template (distribute this)
2203
-
2204
- Custom templates are integration presets. They capture:
2205
- - Project defaults (framework, mode, typescript, tailwind)
2206
- - Which integrations to include
2207
- - Preset integration options (if any)
2208
-
2209
- Next steps:
2210
- 1. Edit ${INFO_FILE} to customize name, description, and integrations
2211
- 2. Run 'tanstack template compile' to rebuild after changes
2212
- 3. Share ${COMPILED_FILE} or host it publicly
2213
- 4. Users can use: tanstack create --template <url-to-template.json>
2214
- `);
2215
- }
2216
- /**
2217
- * Load a remote custom template from a URL
2218
- */
2219
- async function loadTemplate(url) {
2220
- const response = await fetch(url);
2221
- if (!response.ok) throw new Error(`Failed to fetch template from ${url}: ${response.statusText}`);
2222
- const jsonContent = await response.json();
2223
- const result = require_fetch.CustomTemplateCompiledSchema.safeParse(jsonContent);
2224
- if (!result.success) throw new Error(`Invalid template at ${url}: ${result.error.message}`);
2225
- const template = result.data;
2226
- if (!template.id) template.id = url;
2227
- return template;
2228
- }
2229
-
2230
- //#endregion
2231
- Object.defineProperty(exports, 'CONFIG_FILE', {
2232
- enumerable: true,
2233
- get: function () {
2234
- return CONFIG_FILE;
2235
- }
2236
- });
2237
- Object.defineProperty(exports, '__toESM', {
2238
- enumerable: true,
2239
- get: function () {
2240
- return __toESM;
2241
- }
2242
- });
2243
- Object.defineProperty(exports, 'compile', {
2244
- enumerable: true,
2245
- get: function () {
2246
- return compile;
2247
- }
2248
- });
2249
- Object.defineProperty(exports, 'compileIntegration', {
2250
- enumerable: true,
2251
- get: function () {
2252
- return compileIntegration;
2253
- }
2254
- });
2255
- Object.defineProperty(exports, 'compileTemplate', {
2256
- enumerable: true,
2257
- get: function () {
2258
- return compileTemplate;
2259
- }
2260
- });
2261
- Object.defineProperty(exports, 'compileWithAttribution', {
2262
- enumerable: true,
2263
- get: function () {
2264
- return compileWithAttribution;
2265
- }
2266
- });
2267
- Object.defineProperty(exports, 'initIntegration', {
2268
- enumerable: true,
2269
- get: function () {
2270
- return initIntegration;
2271
- }
2272
- });
2273
- Object.defineProperty(exports, 'initTemplate', {
2274
- enumerable: true,
2275
- get: function () {
2276
- return initTemplate;
2277
- }
2278
- });
2279
- Object.defineProperty(exports, 'loadRemoteIntegration', {
2280
- enumerable: true,
2281
- get: function () {
2282
- return loadRemoteIntegration;
2283
- }
2284
- });
2285
- Object.defineProperty(exports, 'loadTemplate', {
2286
- enumerable: true,
2287
- get: function () {
2288
- return loadTemplate;
2289
- }
2290
- });
2291
- Object.defineProperty(exports, 'processTemplateFile', {
2292
- enumerable: true,
2293
- get: function () {
2294
- return processTemplateFile;
2295
- }
2296
- });
2297
- Object.defineProperty(exports, 'readConfigFile', {
2298
- enumerable: true,
2299
- get: function () {
2300
- return readConfigFile;
2301
- }
2302
- });
2303
- Object.defineProperty(exports, 'relativePath', {
2304
- enumerable: true,
2305
- get: function () {
2306
- return relativePath;
2307
- }
2308
- });
2309
- Object.defineProperty(exports, 'writeConfigFile', {
2310
- enumerable: true,
2311
- get: function () {
2312
- return writeConfigFile;
2313
- }
2314
- });