@tdk-landscape/tdk-cli-core 1.3.94 → 1.3.95
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/cli/dist/commands/resource.js +1 -1
- package/cli/dist/frontend-frameworks/registry.js +2 -0
- package/cli/dist/frontend-frameworks/tanstack-router.js +102 -0
- package/cli/package.json +1 -1
- package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +3 -1
- package/engine/topologies/tilt/generators/vite/frontend.star +5 -0
- package/package.json +1 -1
|
@@ -312,7 +312,7 @@ export const resourceCommand = new Command("resource")
|
|
|
312
312
|
.description("Create a new resource (service) from scratch, or register an existing one")
|
|
313
313
|
.argument("[name]", "Resource name (kebab-case)")
|
|
314
314
|
.option("-t, --type <type>", "Resource type: backend, frontend, worker, mcp, bring-your-own, sdk", "backend")
|
|
315
|
-
.option("--framework <id>", "Framework: frontend react (default), vue, svelte, preact, lit, solid, qwik, vanilla; backend hono (default), express, elysia, fastify, nestjs, koa, h3")
|
|
315
|
+
.option("--framework <id>", "Framework: frontend react (default), vue, svelte, preact, lit, solid, qwik, vanilla, tanstack-router; backend hono (default), express, elysia, fastify, nestjs, koa, h3")
|
|
316
316
|
.option("--language <id>", "Backend language: bun (default), python, go, rust")
|
|
317
317
|
.option("-s, --stack <stack>", "Stack to assign resource to", "default")
|
|
318
318
|
.option("-p, --path <path>", "Custom path for resource directory")
|
|
@@ -5,6 +5,7 @@ import { qwikFrontendProvider } from "./qwik.js";
|
|
|
5
5
|
import { reactFrontendProvider } from "./react.js";
|
|
6
6
|
import { solidFrontendProvider } from "./solid.js";
|
|
7
7
|
import { svelteFrontendProvider } from "./svelte.js";
|
|
8
|
+
import { tanstackRouterFrontendProvider } from "./tanstack-router.js";
|
|
8
9
|
import { vanillaFrontendProvider } from "./vanilla.js";
|
|
9
10
|
import { vueFrontendProvider } from "./vue.js";
|
|
10
11
|
export const DEFAULT_FRONTEND_FRAMEWORK = "react";
|
|
@@ -17,6 +18,7 @@ export const FRONTEND_FRAMEWORKS = {
|
|
|
17
18
|
solid: solidFrontendProvider,
|
|
18
19
|
qwik: qwikFrontendProvider,
|
|
19
20
|
vanilla: vanillaFrontendProvider,
|
|
21
|
+
"tanstack-router": tanstackRouterFrontendProvider,
|
|
20
22
|
};
|
|
21
23
|
export function getFrontendFramework(frameworkId) {
|
|
22
24
|
const id = (frameworkId ?? DEFAULT_FRONTEND_FRAMEWORK).trim().toLowerCase();
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// A client-side Vite SPA using TanStack Router with code-based routes. It shares the React toolchain (same Vite config, JSX
|
|
2
|
+
// setting and entry file), so the generators only learn the id. TanStack Start (SSR) is a different contract: bring your own.
|
|
3
|
+
export const tanstackRouterFrontendProvider = {
|
|
4
|
+
id: "tanstack-router",
|
|
5
|
+
label: "TanStack Router + React + Vite",
|
|
6
|
+
dependencies: {
|
|
7
|
+
"@tanstack/react-router": "^1.0.0",
|
|
8
|
+
react: "^19.0.0",
|
|
9
|
+
"react-dom": "^19.0.0",
|
|
10
|
+
},
|
|
11
|
+
devDependencies: {
|
|
12
|
+
"@types/react": "^19.0.0",
|
|
13
|
+
"@types/react-dom": "^19.0.0",
|
|
14
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
15
|
+
},
|
|
16
|
+
compilerOptions: {
|
|
17
|
+
jsx: "react-jsx",
|
|
18
|
+
},
|
|
19
|
+
createFiles(name) {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
filename: "index.html",
|
|
23
|
+
content: `<!DOCTYPE html>
|
|
24
|
+
<html lang="en">
|
|
25
|
+
<head>
|
|
26
|
+
<meta charset="UTF-8" />
|
|
27
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
28
|
+
<title>${name}</title>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|
|
35
|
+
`,
|
|
36
|
+
description: "Generating HTML template",
|
|
37
|
+
emoji: "💻",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
filename: "src/main.tsx",
|
|
41
|
+
content: `import { RouterProvider } from '@tanstack/react-router';
|
|
42
|
+
import React from 'react';
|
|
43
|
+
import ReactDOM from 'react-dom/client';
|
|
44
|
+
import { router } from './router';
|
|
45
|
+
|
|
46
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
47
|
+
<React.StrictMode>
|
|
48
|
+
<RouterProvider router={router} />
|
|
49
|
+
</React.StrictMode>
|
|
50
|
+
);
|
|
51
|
+
`,
|
|
52
|
+
description: "Generating TanStack Router entry",
|
|
53
|
+
emoji: "💻",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
filename: "src/router.tsx",
|
|
57
|
+
content: `/// <reference types="vite/client" />
|
|
58
|
+
import { createRootRoute, createRoute, createRouter, Link, Outlet } from '@tanstack/react-router';
|
|
59
|
+
|
|
60
|
+
const rootRoute = createRootRoute({
|
|
61
|
+
component: () => (
|
|
62
|
+
<div style={{ padding: '2rem', fontFamily: 'system-ui' }}>
|
|
63
|
+
<nav>
|
|
64
|
+
<Link to="/">Home</Link>
|
|
65
|
+
</nav>
|
|
66
|
+
<Outlet />
|
|
67
|
+
</div>
|
|
68
|
+
),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const indexRoute = createRoute({
|
|
72
|
+
getParentRoute: () => rootRoute,
|
|
73
|
+
path: '/',
|
|
74
|
+
component: () => (
|
|
75
|
+
<>
|
|
76
|
+
<h1>${name}</h1>
|
|
77
|
+
<p>Frontend resource created with TDK</p>
|
|
78
|
+
</>
|
|
79
|
+
),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const routeTree = rootRoute.addChildren([indexRoute]);
|
|
83
|
+
|
|
84
|
+
export const router = createRouter({
|
|
85
|
+
routeTree,
|
|
86
|
+
// The app is served under /<name>/ behind Traefik, and Vite exposes that base here.
|
|
87
|
+
basepath: import.meta.env.BASE_URL,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
declare module '@tanstack/react-router' {
|
|
91
|
+
interface Register {
|
|
92
|
+
router: typeof router;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`,
|
|
96
|
+
description: "Generating TanStack Router routes",
|
|
97
|
+
emoji: "💻",
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=tanstack-router.js.map
|
package/cli/package.json
CHANGED
|
@@ -77,7 +77,7 @@ def generate_frontend_tsconfig(resource_path, write_fn, internal_deps=None, is_d
|
|
|
77
77
|
resource_path
|
|
78
78
|
))
|
|
79
79
|
print(" Docker build will resolve @{npm_scope}/* from node_modules")
|
|
80
|
-
if framework not in ['react', 'vue', 'svelte', 'preact', 'lit', 'solid', 'qwik', 'vanilla']:
|
|
80
|
+
if framework not in ['react', 'vue', 'svelte', 'preact', 'lit', 'solid', 'qwik', 'vanilla', 'tanstack-router']:
|
|
81
81
|
fail("Unknown frontend framework for TypeScript generation: " + str(framework))
|
|
82
82
|
|
|
83
83
|
compiler_options = {
|
|
@@ -99,6 +99,8 @@ def generate_frontend_tsconfig(resource_path, write_fn, internal_deps=None, is_d
|
|
|
99
99
|
}
|
|
100
100
|
if framework == 'react':
|
|
101
101
|
compiler_options['jsx'] = 'react-jsx'
|
|
102
|
+
elif framework == 'tanstack-router':
|
|
103
|
+
compiler_options['jsx'] = 'react-jsx'
|
|
102
104
|
elif framework == 'preact':
|
|
103
105
|
compiler_options['jsx'] = 'react-jsx'
|
|
104
106
|
compiler_options['jsxImportSource'] = 'preact'
|
|
@@ -68,6 +68,11 @@ _FRAMEWORK_TEMPLATES = {
|
|
|
68
68
|
'dev': VANILLA_VITE_FRONTEND,
|
|
69
69
|
'build': VANILLA_VITE_FRONTEND_BUILD,
|
|
70
70
|
},
|
|
71
|
+
# A React SPA with TanStack Router: same plugin, same config, only the app code differs.
|
|
72
|
+
'tanstack-router': {
|
|
73
|
+
'dev': REACT_VITE_FRONTEND,
|
|
74
|
+
'build': REACT_VITE_FRONTEND_BUILD,
|
|
75
|
+
},
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
def _normalize_vite_base_path(base_path):
|