@tanstack/create 0.61.3 → 0.61.5
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 +33 -0
- package/dist/create-app.js +64 -3
- package/dist/custom-add-ons/add-on.js +59 -1
- package/dist/custom-add-ons/starter.js +5 -1
- package/dist/frameworks/react/add-ons/clerk/info.json +9 -0
- package/dist/frameworks/react/add-ons/convex/info.json +16 -0
- package/dist/frameworks/react/project/base/_dot_gitignore +0 -1
- package/dist/frameworks/react/project/base/index.html.ejs +13 -0
- package/dist/frameworks/react/project/base/src/main.tsx.ejs +24 -0
- package/dist/frameworks/react/project/base/src/routes/__root.tsx.ejs +31 -0
- package/dist/frameworks/react/project/base/vite.config.ts.ejs +6 -2
- package/dist/frameworks/solid/project/base/_dot_gitignore +0 -1
- package/dist/frameworks/solid/project/base/index.html.ejs +13 -0
- package/dist/frameworks/solid/project/base/src/main.tsx.ejs +23 -0
- package/dist/frameworks/solid/project/base/src/routes/__root.tsx.ejs +20 -0
- package/dist/frameworks/solid/project/base/vite.config.ts.ejs +6 -2
- package/dist/frameworks.js +1 -0
- package/dist/index.js +1 -1
- package/dist/package-json.js +20 -0
- package/dist/template-file.js +1 -0
- package/dist/types/custom-add-ons/add-on.d.ts +9 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +193 -0
- package/dist/types.js +10 -0
- package/package.json +1 -1
- package/src/create-app.ts +77 -3
- package/src/custom-add-ons/add-on.ts +72 -1
- package/src/custom-add-ons/starter.ts +7 -1
- package/src/frameworks/react/add-ons/clerk/info.json +9 -0
- package/src/frameworks/react/add-ons/convex/info.json +16 -0
- package/src/frameworks/react/project/base/_dot_gitignore +0 -1
- package/src/frameworks/react/project/base/index.html.ejs +13 -0
- package/src/frameworks/react/project/base/src/main.tsx.ejs +24 -0
- package/src/frameworks/react/project/base/src/routes/__root.tsx.ejs +31 -0
- package/src/frameworks/react/project/base/vite.config.ts.ejs +6 -2
- package/src/frameworks/solid/project/base/_dot_gitignore +0 -1
- package/src/frameworks/solid/project/base/index.html.ejs +13 -0
- package/src/frameworks/solid/project/base/src/main.tsx.ejs +23 -0
- package/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs +20 -0
- package/src/frameworks/solid/project/base/vite.config.ts.ejs +6 -2
- package/src/frameworks.ts +1 -0
- package/src/index.ts +1 -1
- package/src/package-json.ts +24 -0
- package/src/template-file.ts +1 -0
- package/src/types.ts +15 -0
- package/tests/custom-add-ons/starter.test.ts +29 -0
|
@@ -4,7 +4,11 @@ import tsconfigPaths from 'vite-tsconfig-paths'
|
|
|
4
4
|
<% if (addOnEnabled.paraglide) { -%>
|
|
5
5
|
import { paraglideVitePlugin } from "@inlang/paraglide-js"
|
|
6
6
|
<% } -%>
|
|
7
|
+
<% if (routerOnly) { %>
|
|
8
|
+
import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
|
9
|
+
<% } else { %>
|
|
7
10
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
11
|
+
<% } %>
|
|
8
12
|
import viteReact from '@vitejs/plugin-react'
|
|
9
13
|
import tailwindcss from "@tailwindcss/vite"
|
|
10
14
|
<% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %><%- integrationImportContent(integration) %>
|
|
@@ -14,11 +18,11 @@ const config = defineConfig({
|
|
|
14
18
|
plugins: [devtools(), <% if (addOnEnabled.paraglide) { %>paraglideVitePlugin({
|
|
15
19
|
project: './project.inlang',
|
|
16
20
|
outdir: './src/paraglide',
|
|
17
|
-
strategy: ['url'],
|
|
21
|
+
strategy: ['url', "baseLocale"],
|
|
18
22
|
}), <% } %><% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %><%- integrationImportCode(integration) %>,<% } %>
|
|
19
23
|
tsconfigPaths({ projects: ['./tsconfig.json'] }),
|
|
20
24
|
tailwindcss(),
|
|
21
|
-
tanstackStart()
|
|
25
|
+
<% if (routerOnly) { %>tanstackRouter({ target: 'react', autoCodeSplitting: true }),<% } else { %>tanstackStart(),<% } %>
|
|
22
26
|
viteReact(<% if (addOnEnabled.compiler) { %>{
|
|
23
27
|
babel: {
|
|
24
28
|
plugins: ["babel-plugin-react-compiler"],
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% if (!routerOnly) { ignoreFile() } %>
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title><%= projectName %></title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<% if (!routerOnly) { ignoreFile() } %>
|
|
2
|
+
import { render } from 'solid-js/web'
|
|
3
|
+
import { RouterProvider, createRouter } from '@tanstack/solid-router'
|
|
4
|
+
import { routeTree } from './routeTree.gen'
|
|
5
|
+
|
|
6
|
+
const router = createRouter({
|
|
7
|
+
routeTree,
|
|
8
|
+
defaultPreload: 'intent',
|
|
9
|
+
defaultPreloadStaleTime: 0,
|
|
10
|
+
scrollRestoration: true,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
declare module '@tanstack/solid-router' {
|
|
14
|
+
interface Register {
|
|
15
|
+
router: typeof router
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const rootElement = document.getElementById('app')!
|
|
20
|
+
|
|
21
|
+
if (!rootElement.innerHTML) {
|
|
22
|
+
render(() => <RouterProvider router={router} />, rootElement)
|
|
23
|
+
}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
<% if (routerOnly) { %>
|
|
2
|
+
import { Outlet, createRootRoute } from '@tanstack/solid-router'
|
|
3
|
+
import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
|
|
4
|
+
|
|
5
|
+
import '../styles.css'
|
|
6
|
+
|
|
7
|
+
export const Route = createRootRoute({
|
|
8
|
+
component: RootComponent,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
function RootComponent() {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<Outlet />
|
|
15
|
+
<TanStackRouterDevtools position="bottom-right" />
|
|
16
|
+
</>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
<% } else { %>
|
|
1
20
|
import { HeadContent, Outlet, Scripts, createRootRouteWithContext } from '@tanstack/solid-router'
|
|
2
21
|
import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
|
|
3
22
|
|
|
@@ -47,3 +66,4 @@ function RootComponent() {
|
|
|
47
66
|
</html>
|
|
48
67
|
);
|
|
49
68
|
}
|
|
69
|
+
<% } %>
|
|
@@ -2,7 +2,11 @@ import { defineConfig } from "vite";
|
|
|
2
2
|
import { devtools } from '@tanstack/devtools-vite'
|
|
3
3
|
import viteTsConfigPaths from 'vite-tsconfig-paths'
|
|
4
4
|
import tailwindcss from "@tailwindcss/vite"
|
|
5
|
+
<% if (routerOnly) { %>
|
|
6
|
+
import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
|
7
|
+
<% } else { %>
|
|
5
8
|
import { tanstackStart } from "@tanstack/solid-start/plugin/vite";
|
|
9
|
+
<% } %>
|
|
6
10
|
import solidPlugin from 'vite-plugin-solid';
|
|
7
11
|
<% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %><%- integrationImportContent(integration) %>
|
|
8
12
|
<% } %>
|
|
@@ -15,7 +19,7 @@ export default defineConfig({
|
|
|
15
19
|
projects: ['./tsconfig.json'],
|
|
16
20
|
}),
|
|
17
21
|
tailwindcss(),
|
|
18
|
-
tanstackStart()
|
|
19
|
-
solidPlugin({ ssr: true }),
|
|
22
|
+
<% if (routerOnly) { %>tanstackRouter({ target: 'solid', autoCodeSplitting: true }),<% } else { %>tanstackStart(),<% } %>
|
|
23
|
+
solidPlugin(<% if (!routerOnly) { %>{ ssr: true }<% } %>),
|
|
20
24
|
],
|
|
21
25
|
})
|
package/src/frameworks.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -61,7 +61,7 @@ export {
|
|
|
61
61
|
export { formatCommand, handleSpecialURL } from './utils.js'
|
|
62
62
|
|
|
63
63
|
export { initStarter, compileStarter } from './custom-add-ons/starter.js'
|
|
64
|
-
export { initAddOn, compileAddOn } from './custom-add-ons/add-on.js'
|
|
64
|
+
export { initAddOn, compileAddOn, devAddOn } from './custom-add-ons/add-on.js'
|
|
65
65
|
export {
|
|
66
66
|
createAppOptionsFromPersisted,
|
|
67
67
|
createSerializedOptionsFromPersisted,
|
package/src/package-json.ts
CHANGED
|
@@ -63,6 +63,7 @@ export function createPackageJSON(options: Options) {
|
|
|
63
63
|
jsx: 'tsx',
|
|
64
64
|
fileRouter: options.mode === 'file-router',
|
|
65
65
|
codeRouter: options.mode === 'code-router',
|
|
66
|
+
routerOnly: options.routerOnly === true,
|
|
66
67
|
addOnEnabled: options.chosenAddOns.reduce<Record<string, boolean>>(
|
|
67
68
|
(acc, addon) => {
|
|
68
69
|
acc[addon.id] = true
|
|
@@ -97,6 +98,29 @@ export function createPackageJSON(options: Options) {
|
|
|
97
98
|
)
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
if (options.routerOnly) {
|
|
102
|
+
if (options.framework.id === 'react-cra') {
|
|
103
|
+
delete packageJSON.dependencies?.['@tanstack/react-start']
|
|
104
|
+
delete packageJSON.dependencies?.['@tanstack/react-router-ssr-query']
|
|
105
|
+
packageJSON.devDependencies = {
|
|
106
|
+
...(packageJSON.devDependencies ?? {}),
|
|
107
|
+
'@tanstack/router-plugin':
|
|
108
|
+
packageJSON.devDependencies?.['@tanstack/router-plugin'] ?? '^1.132.0',
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (options.framework.id === 'solid') {
|
|
113
|
+
delete packageJSON.dependencies?.['@tanstack/solid-start']
|
|
114
|
+
delete packageJSON.dependencies?.['@tanstack/solid-router-ssr-query']
|
|
115
|
+
delete packageJSON.scripts?.start
|
|
116
|
+
packageJSON.devDependencies = {
|
|
117
|
+
...(packageJSON.devDependencies ?? {}),
|
|
118
|
+
'@tanstack/router-plugin':
|
|
119
|
+
packageJSON.devDependencies?.['@tanstack/router-plugin'] ?? '^1.133.20',
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
100
124
|
packageJSON.dependencies = sortObject(
|
|
101
125
|
(packageJSON.dependencies ?? {}) as Record<string, string>,
|
|
102
126
|
)
|
package/src/template-file.ts
CHANGED
|
@@ -136,6 +136,7 @@ export function createTemplateFile(environment: Environment, options: Options) {
|
|
|
136
136
|
jsx: 'tsx',
|
|
137
137
|
fileRouter: options.mode === 'file-router',
|
|
138
138
|
codeRouter: options.mode === 'code-router',
|
|
139
|
+
routerOnly: options.routerOnly === true,
|
|
139
140
|
addOnEnabled,
|
|
140
141
|
addOnOption: options.addOnOptions,
|
|
141
142
|
addOns: options.chosenAddOns,
|
package/src/types.ts
CHANGED
|
@@ -92,6 +92,18 @@ export const AddOnBaseSchema = z.object({
|
|
|
92
92
|
createSpecialSteps: z.array(z.string()).optional(),
|
|
93
93
|
postInitSpecialSteps: z.array(z.string()).optional(),
|
|
94
94
|
options: AddOnOptionsSchema.optional(),
|
|
95
|
+
envVars: z
|
|
96
|
+
.array(
|
|
97
|
+
z.object({
|
|
98
|
+
name: z.string(),
|
|
99
|
+
description: z.string().optional(),
|
|
100
|
+
required: z.boolean().optional(),
|
|
101
|
+
default: z.string().optional(),
|
|
102
|
+
secret: z.boolean().optional(),
|
|
103
|
+
file: z.enum(['.env', '.env.local']).optional(),
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
106
|
+
.optional(),
|
|
95
107
|
default: z.boolean().optional(),
|
|
96
108
|
})
|
|
97
109
|
|
|
@@ -206,6 +218,9 @@ export interface Options {
|
|
|
206
218
|
chosenAddOns: Array<AddOn>
|
|
207
219
|
addOnOptions: Record<string, Record<string, any>>
|
|
208
220
|
starter?: Starter | undefined
|
|
221
|
+
routerOnly?: boolean
|
|
222
|
+
includeExamples?: boolean
|
|
223
|
+
envVarValues?: Record<string, string>
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
export type SerializedOptions = Omit<
|
|
@@ -55,4 +55,33 @@ describe('readOrGenerateStarterInfo', () => {
|
|
|
55
55
|
})
|
|
56
56
|
expect(starterInfo.name).toEqual('test-starter')
|
|
57
57
|
})
|
|
58
|
+
|
|
59
|
+
it('should backfill version when missing', async () => {
|
|
60
|
+
fs.mkdirSync(process.cwd(), { recursive: true })
|
|
61
|
+
fs.writeFileSync(
|
|
62
|
+
'starter-info.json',
|
|
63
|
+
JSON.stringify({
|
|
64
|
+
framework: 'test',
|
|
65
|
+
chosenAddOns: [],
|
|
66
|
+
starter: undefined,
|
|
67
|
+
name: 'test-starter',
|
|
68
|
+
mode: 'code-router',
|
|
69
|
+
typescript: true,
|
|
70
|
+
tailwind: true,
|
|
71
|
+
git: true,
|
|
72
|
+
}),
|
|
73
|
+
)
|
|
74
|
+
const starterInfo = await readOrGenerateStarterInfo({
|
|
75
|
+
framework: 'test',
|
|
76
|
+
version: 1,
|
|
77
|
+
chosenAddOns: [],
|
|
78
|
+
starter: undefined,
|
|
79
|
+
projectName: 'test',
|
|
80
|
+
mode: 'code-router',
|
|
81
|
+
typescript: true,
|
|
82
|
+
tailwind: true,
|
|
83
|
+
git: true,
|
|
84
|
+
})
|
|
85
|
+
expect(starterInfo.version).toEqual('0.0.1')
|
|
86
|
+
})
|
|
58
87
|
})
|