@tanstack/create 0.68.1 → 0.68.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tanstack/create
2
2
 
3
+ ## 0.68.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Keep the generated route tree tracked in new React and Solid apps and run route generation once during scaffold. ([#464](https://github.com/TanStack/cli/pull/464))
8
+
3
9
  ## 0.68.1
4
10
 
5
11
  ### Patch Changes
@@ -202,6 +202,28 @@ async function runCommandsAndInstallDependencies(environment, options) {
202
202
  }
203
203
  await installShadcnComponents(environment, options.targetDir, options);
204
204
  await setupIntent(environment, options.targetDir, options);
205
+ if (shouldGenerateRoutes(options)) {
206
+ s.start(`Generating route tree...`);
207
+ const command = getPackageManagerScriptCommand(options.packageManager, [
208
+ 'generate-routes',
209
+ ]);
210
+ const cmd = formatCommand(command);
211
+ environment.startStep({
212
+ id: 'generate-routes',
213
+ type: 'command',
214
+ message: cmd,
215
+ });
216
+ await environment.execute(command.command, command.args, options.targetDir, {
217
+ inherit: true,
218
+ });
219
+ environment.finishStep('generate-routes', 'Route tree generated');
220
+ s.stop(`Route tree generated`);
221
+ }
222
+ }
223
+ function shouldGenerateRoutes(options) {
224
+ return (options.install !== false &&
225
+ options.mode === 'file-router' &&
226
+ (options.framework.id === 'react' || options.framework.id === 'solid'));
205
227
  }
206
228
  async function seedEnvValues(environment, options) {
207
229
  const envVarValues = options.envVarValues || {};
@@ -6,7 +6,6 @@ dist-ssr
6
6
  .env
7
7
  .nitro
8
8
  .tanstack
9
- src/routeTree.gen.ts
10
9
  .wrangler
11
10
  .output
12
11
  .vinxi
@@ -7,6 +7,7 @@
7
7
  },
8
8
  "scripts": {
9
9
  "dev": "vite dev --port 3000",
10
+ "generate-routes": "tsr generate",
10
11
  "build": "vite build",
11
12
  "preview": "vite preview",
12
13
  "test": "vitest run"
@@ -0,0 +1,3 @@
1
+ {
2
+ "target": "react"
3
+ }
@@ -15,6 +15,9 @@
15
15
  }
16
16
  },
17
17
  "file-router": {
18
+ "devDependencies": {
19
+ "@tanstack/router-cli": "^1.132.0"
20
+ },
18
21
  "dependencies": {
19
22
  "@tanstack/router-plugin": "^1.132.0"
20
23
  }
@@ -6,7 +6,6 @@ dist-ssr
6
6
  .env
7
7
  .nitro
8
8
  .tanstack
9
- src/routeTree.gen.ts
10
9
  .wrangler
11
10
  .output
12
11
  .vinxi
@@ -4,6 +4,7 @@
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev --port 3000",
7
+ "generate-routes": "tsr generate",
7
8
  "build": "vite build",
8
9
  "start": "node .output/server/index.mjs",
9
10
  "preview": "vite preview",
@@ -0,0 +1,3 @@
1
+ {
2
+ "target": "solid"
3
+ }
@@ -11,6 +11,9 @@
11
11
  }
12
12
  },
13
13
  "file-router": {
14
+ "devDependencies": {
15
+ "@tanstack/router-cli": "^1.133.21"
16
+ },
14
17
  "dependencies": {
15
18
  "@tanstack/router-plugin": "^1.133.21"
16
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/create",
3
- "version": "0.68.1",
3
+ "version": "0.68.2",
4
4
  "description": "TanStack Application Builder Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/create-app.ts CHANGED
@@ -31,7 +31,7 @@ function stripExamplesFromOptions(options: Options): Options {
31
31
  !isDemoFilePath(route.path) &&
32
32
  !(route.url && route.url.startsWith('/demo')),
33
33
  )
34
-
34
+
35
35
  const filteredIntegrations = (addOn.integrations || []).filter(
36
36
  (integration) => !isDemoFilePath(integration.path)
37
37
  )
@@ -277,6 +277,37 @@ async function runCommandsAndInstallDependencies(
277
277
  await installShadcnComponents(environment, options.targetDir, options)
278
278
 
279
279
  await setupIntent(environment, options.targetDir, options)
280
+
281
+ if (shouldGenerateRoutes(options)) {
282
+ s.start(`Generating route tree...`)
283
+ const command = getPackageManagerScriptCommand(options.packageManager, [
284
+ 'generate-routes',
285
+ ])
286
+ const cmd = formatCommand(command)
287
+ environment.startStep({
288
+ id: 'generate-routes',
289
+ type: 'command',
290
+ message: cmd,
291
+ })
292
+ await environment.execute(
293
+ command.command,
294
+ command.args,
295
+ options.targetDir,
296
+ {
297
+ inherit: true,
298
+ },
299
+ )
300
+ environment.finishStep('generate-routes', 'Route tree generated')
301
+ s.stop(`Route tree generated`)
302
+ }
303
+ }
304
+
305
+ function shouldGenerateRoutes(options: Options) {
306
+ return (
307
+ options.install !== false &&
308
+ options.mode === 'file-router' &&
309
+ (options.framework.id === 'react' || options.framework.id === 'solid')
310
+ )
280
311
  }
281
312
 
282
313
  async function seedEnvValues(environment: Environment, options: Options) {
@@ -6,7 +6,6 @@ dist-ssr
6
6
  .env
7
7
  .nitro
8
8
  .tanstack
9
- src/routeTree.gen.ts
10
9
  .wrangler
11
10
  .output
12
11
  .vinxi
@@ -7,6 +7,7 @@
7
7
  },
8
8
  "scripts": {
9
9
  "dev": "vite dev --port 3000",
10
+ "generate-routes": "tsr generate",
10
11
  "build": "vite build",
11
12
  "preview": "vite preview",
12
13
  "test": "vitest run"
@@ -0,0 +1,3 @@
1
+ {
2
+ "target": "react"
3
+ }
@@ -15,6 +15,9 @@
15
15
  }
16
16
  },
17
17
  "file-router": {
18
+ "devDependencies": {
19
+ "@tanstack/router-cli": "^1.132.0"
20
+ },
18
21
  "dependencies": {
19
22
  "@tanstack/router-plugin": "^1.132.0"
20
23
  }
@@ -6,7 +6,6 @@ dist-ssr
6
6
  .env
7
7
  .nitro
8
8
  .tanstack
9
- src/routeTree.gen.ts
10
9
  .wrangler
11
10
  .output
12
11
  .vinxi
@@ -4,6 +4,7 @@
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev --port 3000",
7
+ "generate-routes": "tsr generate",
7
8
  "build": "vite build",
8
9
  "start": "node .output/server/index.mjs",
9
10
  "preview": "vite preview",
@@ -0,0 +1,3 @@
1
+ {
2
+ "target": "solid"
3
+ }
@@ -11,6 +11,9 @@
11
11
  }
12
12
  },
13
13
  "file-router": {
14
+ "devDependencies": {
15
+ "@tanstack/router-cli": "^1.133.21"
16
+ },
14
17
  "dependencies": {
15
18
  "@tanstack/router-plugin": "^1.133.21"
16
19
  }
@@ -4,8 +4,7 @@ import { resolve } from 'node:path'
4
4
  import { createApp } from '../src/create-app.js'
5
5
 
6
6
  import { createMemoryEnvironment } from '../src/environment.js'
7
- import { FILE_ROUTER } from '../src/constants.js'
8
- import { AddOn, Options } from '../src/types.js'
7
+ import type { AddOn, Options } from '../src/types.js'
9
8
 
10
9
  const simpleOptions = {
11
10
  projectName: 'test',
@@ -43,7 +42,7 @@ const simpleOptions = {
43
42
  packageManager: 'pnpm',
44
43
  typescript: true,
45
44
  tailwind: true,
46
- mode: FILE_ROUTER,
45
+ mode: 'file-router',
47
46
  variableValues: {},
48
47
  } as unknown as Options
49
48
 
@@ -88,6 +87,43 @@ describe('createApp', () => {
88
87
  expect(output.commands.some(({ command }) => command === 'echo')).toBe(true)
89
88
  })
90
89
 
90
+ it.each(['react', 'solid'])(
91
+ 'generates routes for %s file-router apps after install',
92
+ async (frameworkId) => {
93
+ const { environment, output } = createMemoryEnvironment()
94
+ await createApp(environment, {
95
+ ...simpleOptions,
96
+ framework: {
97
+ ...simpleOptions.framework,
98
+ id: frameworkId,
99
+ },
100
+ install: true,
101
+ } as Options)
102
+
103
+ expect(output.commands).toContainEqual({
104
+ command: 'pnpm',
105
+ args: ['generate-routes'],
106
+ })
107
+ },
108
+ )
109
+
110
+ it('skips route generation when dependency install is skipped', async () => {
111
+ const { environment, output } = createMemoryEnvironment()
112
+ await createApp(environment, {
113
+ ...simpleOptions,
114
+ framework: {
115
+ ...simpleOptions.framework,
116
+ id: 'react',
117
+ },
118
+ install: false,
119
+ })
120
+
121
+ expect(output.commands).not.toContainEqual({
122
+ command: 'pnpm',
123
+ args: ['generate-routes'],
124
+ })
125
+ })
126
+
91
127
  it('should create an app - with a add-on', async () => {
92
128
  const { environment, output } = createMemoryEnvironment()
93
129
  await createApp(environment, {
@@ -7,9 +7,28 @@ describe('framework templates', () => {
7
7
  it.each([
8
8
  ['React', createReactFrameworkDefinition],
9
9
  ['Solid', createSolidFrameworkDefinition],
10
- ])('%s gitignore excludes the generated route tree', (_, createDefinition) => {
10
+ ])(
11
+ '%s gitignore does not exclude the generated route tree',
12
+ (_, createDefinition) => {
13
+ const framework = createDefinition()
14
+
15
+ expect(framework.base._dot_gitignore).not.toContain(
16
+ 'src/routeTree.gen.ts',
17
+ )
18
+ },
19
+ )
20
+
21
+ it.each([
22
+ ['React', createReactFrameworkDefinition],
23
+ ['Solid', createSolidFrameworkDefinition],
24
+ ])('%s includes route generation tooling', (_, createDefinition) => {
11
25
  const framework = createDefinition()
12
26
 
13
- expect(framework.base._dot_gitignore).toContain('src/routeTree.gen.ts')
27
+ expect(framework.base['package.json']).toContain(
28
+ '"generate-routes": "tsr generate"',
29
+ )
30
+ expect(
31
+ framework.optionalPackages['file-router'].devDependencies,
32
+ ).toHaveProperty('@tanstack/router-cli')
14
33
  })
15
34
  })