@tanstack/cta-engine 0.14.3 → 0.15.0
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/dist/add-ons.js +5 -91
- package/dist/add-to-app.js +171 -0
- package/dist/config-file.js +34 -11
- package/dist/constants.js +0 -2
- package/dist/create-app.js +142 -451
- package/dist/custom-add-ons/add-on.js +175 -0
- package/dist/custom-add-ons/shared.js +116 -0
- package/dist/custom-add-ons/starter.js +84 -0
- package/dist/environment.js +67 -44
- package/dist/file-helpers.js +165 -0
- package/dist/frameworks.js +92 -0
- package/dist/index.js +18 -1
- package/dist/integrations/git.js +4 -0
- package/dist/integrations/shadcn.js +33 -0
- package/dist/options.js +9 -333
- package/dist/package-json.js +48 -0
- package/dist/package-manager.js +51 -6
- package/dist/registry.js +56 -0
- package/dist/special-steps/index.js +24 -0
- package/dist/special-steps/rimraf-node-modules.js +16 -0
- package/dist/template-file.js +112 -0
- package/dist/types/add-ons.d.ts +3 -8
- package/dist/types/add-to-app.d.ts +17 -0
- package/dist/types/config-file.d.ts +7 -4
- package/dist/types/constants.d.ts +0 -3
- package/dist/types/create-app.d.ts +1 -7
- package/dist/types/custom-add-ons/add-on.d.ts +69 -0
- package/dist/types/custom-add-ons/shared.d.ts +15 -0
- package/dist/types/custom-add-ons/starter.d.ts +7 -0
- package/dist/types/environment.d.ts +2 -1
- package/dist/types/file-helpers.d.ts +15 -0
- package/dist/types/frameworks.d.ts +7 -0
- package/dist/types/index.d.ts +21 -1
- package/dist/types/integrations/git.d.ts +2 -0
- package/dist/types/integrations/shadcn.d.ts +2 -0
- package/dist/types/options.d.ts +2 -6
- package/dist/types/package-json.d.ts +7 -0
- package/dist/types/package-manager.d.ts +18 -1
- package/dist/types/registry.d.ts +25 -0
- package/dist/types/special-steps/index.d.ts +2 -0
- package/dist/types/special-steps/rimraf-node-modules.d.ts +2 -0
- package/dist/types/template-file.d.ts +2 -0
- package/dist/types/types.d.ts +788 -85
- package/dist/types/utils.d.ts +5 -0
- package/dist/types.js +65 -1
- package/dist/utils.js +9 -0
- package/package.json +9 -12
- package/src/add-ons.ts +7 -123
- package/src/add-to-app.ts +276 -0
- package/src/config-file.ts +51 -20
- package/src/constants.ts +0 -5
- package/src/create-app.ts +180 -730
- package/src/custom-add-ons/add-on.ts +261 -0
- package/src/custom-add-ons/shared.ts +160 -0
- package/src/custom-add-ons/starter.ts +126 -0
- package/src/environment.ts +80 -45
- package/src/file-helpers.ts +235 -0
- package/src/frameworks.ts +134 -0
- package/src/index.ts +85 -1
- package/src/integrations/git.ts +7 -0
- package/src/integrations/shadcn.ts +54 -0
- package/src/options.ts +8 -409
- package/src/package-json.ts +69 -0
- package/src/package-manager.ts +80 -9
- package/src/registry.ts +92 -0
- package/src/special-steps/index.ts +36 -0
- package/src/special-steps/rimraf-node-modules.ts +25 -0
- package/src/template-file.ts +150 -0
- package/src/types.ts +175 -87
- package/src/utils.ts +17 -0
- package/tests/add-ons.test.ts +67 -0
- package/tests/add-to-app.test.ts +358 -0
- package/tests/config-file.test.ts +105 -0
- package/tests/create-app.test.ts +120 -0
- package/tests/custom-add-ons/add-on.test.ts +12 -0
- package/tests/custom-add-ons/shared.test.ts +253 -0
- package/tests/custom-add-ons/starter.test.ts +58 -0
- package/tests/environment.test.ts +115 -0
- package/tests/file-helper.test.ts +90 -0
- package/tests/frameworks.test.ts +95 -0
- package/tests/index.test.ts +9 -0
- package/tests/integrations/git.test.ts +20 -0
- package/tests/integrations/shadcn.test.ts +91 -0
- package/tests/options.test.ts +42 -0
- package/tests/package-json.test.ts +63 -0
- package/tests/package-manager.test.ts +154 -0
- package/tests/setupVitest.ts +6 -0
- package/tests/template-file.test.ts +178 -0
- package/tests/utils.test.ts +23 -0
- package/vitest.config.ts +21 -0
- package/dist/add.js +0 -125
- package/dist/cli.js +0 -132
- package/dist/custom-add-on.js +0 -254
- package/dist/file-helper.js +0 -18
- package/dist/mcp.js +0 -229
- package/dist/templates.js +0 -6
- package/dist/toolchain.js +0 -6
- package/dist/types/add.d.ts +0 -3
- package/dist/types/cli.d.ts +0 -7
- package/dist/types/custom-add-on.d.ts +0 -3
- package/dist/types/file-helper.d.ts +0 -2
- package/dist/types/mcp.d.ts +0 -7
- package/dist/types/templates.d.ts +0 -1
- package/dist/types/toolchain.d.ts +0 -3
- package/src/add.ts +0 -186
- package/src/cli.ts +0 -210
- package/src/custom-add-on.ts +0 -325
- package/src/file-helper.ts +0 -20
- package/src/mcp.ts +0 -302
- package/src/templates.ts +0 -7
- package/src/toolchain.ts +0 -7
- package/templates/react/add-on/clerk/README.md +0 -3
- package/templates/react/add-on/clerk/assets/_dot_env.local.append +0 -2
- package/templates/react/add-on/clerk/assets/src/integrations/clerk/header-user.tsx +0 -19
- package/templates/react/add-on/clerk/assets/src/integrations/clerk/provider.tsx +0 -18
- package/templates/react/add-on/clerk/assets/src/routes/demo.clerk.tsx +0 -20
- package/templates/react/add-on/clerk/info.json +0 -13
- package/templates/react/add-on/clerk/package.json +0 -5
- package/templates/react/add-on/convex/README.md +0 -4
- package/templates/react/add-on/convex/assets/_dot_cursorrules.append +0 -93
- package/templates/react/add-on/convex/assets/_dot_env.local.append +0 -3
- package/templates/react/add-on/convex/assets/convex/products.ts +0 -8
- package/templates/react/add-on/convex/assets/convex/schema.ts +0 -10
- package/templates/react/add-on/convex/assets/src/integrations/convex/provider.tsx +0 -20
- package/templates/react/add-on/convex/assets/src/routes/demo.convex.tsx +0 -33
- package/templates/react/add-on/convex/info.json +0 -13
- package/templates/react/add-on/convex/package.json +0 -6
- package/templates/react/add-on/form/assets/src/components/demo.FormComponents.tsx.ejs +0 -300
- package/templates/react/add-on/form/assets/src/hooks/demo.form-context.ts +0 -4
- package/templates/react/add-on/form/assets/src/hooks/demo.form.ts +0 -22
- package/templates/react/add-on/form/assets/src/routes/demo.form.address.tsx.ejs +0 -213
- package/templates/react/add-on/form/assets/src/routes/demo.form.simple.tsx.ejs +0 -77
- package/templates/react/add-on/form/info.json +0 -26
- package/templates/react/add-on/form/package.json +0 -6
- package/templates/react/add-on/module-federation/assets/module-federation.config.js.ejs +0 -31
- package/templates/react/add-on/module-federation/assets/src/demo-mf-component.tsx +0 -3
- package/templates/react/add-on/module-federation/assets/src/demo-mf-self-contained.tsx +0 -11
- package/templates/react/add-on/module-federation/info.json +0 -7
- package/templates/react/add-on/module-federation/package.json +0 -5
- package/templates/react/add-on/netlify/README.md +0 -11
- package/templates/react/add-on/netlify/info.json +0 -7
- package/templates/react/add-on/sentry/assets/_dot_cursorrules.append +0 -22
- package/templates/react/add-on/sentry/assets/_dot_env.local.append +0 -11
- package/templates/react/add-on/sentry/assets/src/app/global-middleware.ts +0 -11
- package/templates/react/add-on/sentry/assets/src/routes/demo.sentry.testing.tsx +0 -489
- package/templates/react/add-on/sentry/info.json +0 -14
- package/templates/react/add-on/sentry/package.json +0 -5
- package/templates/react/add-on/shadcn/README.md +0 -7
- package/templates/react/add-on/shadcn/assets/_dot_cursorrules.append +0 -7
- package/templates/react/add-on/shadcn/assets/components.json +0 -21
- package/templates/react/add-on/shadcn/assets/src/lib/utils.ts +0 -6
- package/templates/react/add-on/shadcn/assets/src/styles.css +0 -138
- package/templates/react/add-on/shadcn/info.json +0 -7
- package/templates/react/add-on/shadcn/package.json +0 -9
- package/templates/react/add-on/start/assets/_dot_gitignore.append +0 -2
- package/templates/react/add-on/start/assets/app.config.ts.ejs +0 -32
- package/templates/react/add-on/start/assets/src/api.ts +0 -6
- package/templates/react/add-on/start/assets/src/client.tsx.ejs +0 -33
- package/templates/react/add-on/start/assets/src/router.tsx.ejs +0 -48
- package/templates/react/add-on/start/assets/src/routes/api.demo-names.ts +0 -11
- package/templates/react/add-on/start/assets/src/routes/demo.start.api-request.tsx.ejs +0 -33
- package/templates/react/add-on/start/assets/src/routes/demo.start.server-funcs.tsx +0 -50
- package/templates/react/add-on/start/assets/src/ssr.tsx.ejs +0 -30
- package/templates/react/add-on/start/info.json +0 -18
- package/templates/react/add-on/start/package.json +0 -13
- package/templates/react/add-on/store/assets/src/lib/demo-store.ts +0 -13
- package/templates/react/add-on/store/assets/src/routes/demo.store.tsx.ejs +0 -75
- package/templates/react/add-on/store/info.json +0 -13
- package/templates/react/add-on/store/package.json +0 -6
- package/templates/react/add-on/t3env/README.md +0 -16
- package/templates/react/add-on/t3env/assets/src/env.ts +0 -39
- package/templates/react/add-on/t3env/info.json +0 -10
- package/templates/react/add-on/t3env/package.json +0 -6
- package/templates/react/add-on/tRPC/assets/src/integrations/trpc/init.ts +0 -9
- package/templates/react/add-on/tRPC/assets/src/integrations/trpc/react.ts +0 -4
- package/templates/react/add-on/tRPC/assets/src/integrations/trpc/router.ts +0 -18
- package/templates/react/add-on/tRPC/assets/src/routes/api.trpc.$.tsx +0 -16
- package/templates/react/add-on/tRPC/info.json +0 -9
- package/templates/react/add-on/tRPC/package.json +0 -9
- package/templates/react/add-on/table/assets/src/data/demo-table-data.ts +0 -50
- package/templates/react/add-on/table/assets/src/routes/demo.table.tsx.ejs +0 -373
- package/templates/react/add-on/table/info.json +0 -13
- package/templates/react/add-on/table/package.json +0 -7
- package/templates/react/add-on/tanstack-query/assets/src/integrations/tanstack-query/layout.tsx +0 -5
- package/templates/react/add-on/tanstack-query/assets/src/integrations/tanstack-query/root-provider.tsx.ejs +0 -70
- package/templates/react/add-on/tanstack-query/assets/src/routes/demo.tanstack-query.tsx.ejs +0 -53
- package/templates/react/add-on/tanstack-query/info.json +0 -13
- package/templates/react/add-on/tanstack-query/package.json +0 -6
- package/templates/react/base/README.md.ejs +0 -558
- package/templates/react/base/_dot_gitignore +0 -5
- package/templates/react/base/_dot_vscode/settings.biome.json +0 -38
- package/templates/react/base/_dot_vscode/settings.json +0 -11
- package/templates/react/base/index.html.ejs +0 -20
- package/templates/react/base/package.biome.json +0 -10
- package/templates/react/base/package.eslintprettier.json +0 -11
- package/templates/react/base/package.json +0 -30
- package/templates/react/base/package.ts.json +0 -7
- package/templates/react/base/package.tw.json +0 -6
- package/templates/react/base/public/favicon.ico +0 -0
- package/templates/react/base/public/logo192.png +0 -0
- package/templates/react/base/public/logo512.png +0 -0
- package/templates/react/base/public/manifest.json +0 -25
- package/templates/react/base/public/robots.txt +0 -3
- package/templates/react/base/src/App.css +0 -38
- package/templates/react/base/src/App.test.tsx.ejs +0 -10
- package/templates/react/base/src/App.tsx.ejs +0 -74
- package/templates/react/base/src/components/Header.tsx.ejs +0 -27
- package/templates/react/base/src/logo.svg +0 -44
- package/templates/react/base/src/reportWebVitals.ts.ejs +0 -28
- package/templates/react/base/src/styles.css.ejs +0 -15
- package/templates/react/base/toolchain/.prettierignore +0 -3
- package/templates/react/base/toolchain/biome.json +0 -31
- package/templates/react/base/toolchain/eslint.config.js +0 -5
- package/templates/react/base/toolchain/prettier.config.js +0 -10
- package/templates/react/base/tsconfig.json.ejs +0 -29
- package/templates/react/base/vite.config.js.ejs +0 -23
- package/templates/react/code-router/src/main.tsx.ejs +0 -92
- package/templates/react/example/tanchat/README.md +0 -37
- package/templates/react/example/tanchat/assets/_dot_env.local.append +0 -2
- package/templates/react/example/tanchat/assets/public/example-guitar-flowers.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-motherboard.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-racing.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-steamer-trunk.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-superhero.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-traveling.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-video-games.jpg +0 -0
- package/templates/react/example/tanchat/assets/src/components/example-AIAssistant.tsx +0 -173
- package/templates/react/example/tanchat/assets/src/components/example-GuitarRecommendation.tsx +0 -47
- package/templates/react/example/tanchat/assets/src/data/example-guitars.ts +0 -83
- package/templates/react/example/tanchat/assets/src/demo.index.css +0 -220
- package/templates/react/example/tanchat/assets/src/integrations/tanchat/header-user.tsx +0 -5
- package/templates/react/example/tanchat/assets/src/routes/api.messages.ts +0 -24
- package/templates/react/example/tanchat/assets/src/routes/api.sse.ts +0 -23
- package/templates/react/example/tanchat/assets/src/routes/example.chat.tsx +0 -159
- package/templates/react/example/tanchat/assets/src/routes/example.guitars/$guitarId.tsx +0 -50
- package/templates/react/example/tanchat/assets/src/routes/example.guitars/index.tsx +0 -54
- package/templates/react/example/tanchat/assets/src/store/example-assistant.ts +0 -3
- package/templates/react/example/tanchat/assets/src/utils/demo.ai.ts +0 -62
- package/templates/react/example/tanchat/assets/src/utils/demo.sse.ts +0 -31
- package/templates/react/example/tanchat/assets/src/utils/demo.tools.ts +0 -47
- package/templates/react/example/tanchat/info.json +0 -19
- package/templates/react/example/tanchat/package.json +0 -16
- package/templates/react/file-router/package.fr.json +0 -5
- package/templates/react/file-router/src/main.tsx.ejs +0 -55
- package/templates/react/file-router/src/routes/__root.tsx.ejs +0 -82
- package/templates/solid/add-on/form/assets/src/routes/demo.form.tsx.ejs +0 -352
- package/templates/solid/add-on/form/info.json +0 -13
- package/templates/solid/add-on/form/package.json +0 -5
- package/templates/solid/add-on/module-federation/assets/module-federation.config.js.ejs +0 -27
- package/templates/solid/add-on/module-federation/assets/src/demo-mf-component.tsx +0 -3
- package/templates/solid/add-on/module-federation/assets/src/demo-mf-self-contained.tsx +0 -9
- package/templates/solid/add-on/module-federation/info.json +0 -7
- package/templates/solid/add-on/module-federation/package.json +0 -5
- package/templates/solid/add-on/sentry/assets/_dot_cursorrules.append +0 -22
- package/templates/solid/add-on/sentry/assets/_dot_env.local.append +0 -2
- package/templates/solid/add-on/sentry/assets/src/routes/demo.sentry.bad-event-handler.tsx +0 -20
- package/templates/solid/add-on/sentry/info.json +0 -13
- package/templates/solid/add-on/sentry/package.json +0 -5
- package/templates/solid/add-on/solid-ui/README.md +0 -9
- package/templates/solid/add-on/solid-ui/assets/src/lib/utils.ts +0 -6
- package/templates/solid/add-on/solid-ui/assets/src/styles.css +0 -138
- package/templates/solid/add-on/solid-ui/assets/ui.config.json +0 -13
- package/templates/solid/add-on/solid-ui/info.json +0 -11
- package/templates/solid/add-on/solid-ui/package.json +0 -9
- package/templates/solid/add-on/start/assets/app.config.ts +0 -16
- package/templates/solid/add-on/start/assets/src/api.ts +0 -6
- package/templates/solid/add-on/start/assets/src/client.tsx +0 -7
- package/templates/solid/add-on/start/assets/src/router.tsx.ejs +0 -24
- package/templates/solid/add-on/start/assets/src/routes/demo.start.server-funcs.tsx +0 -49
- package/templates/solid/add-on/start/assets/src/ssr.tsx +0 -12
- package/templates/solid/add-on/start/info.json +0 -14
- package/templates/solid/add-on/start/package.json +0 -12
- package/templates/solid/add-on/store/assets/src/lib/demo-store.ts +0 -13
- package/templates/solid/add-on/store/assets/src/routes/demo.store.tsx.ejs +0 -77
- package/templates/solid/add-on/store/info.json +0 -13
- package/templates/solid/add-on/store/package.json +0 -6
- package/templates/solid/add-on/t3env/README.md +0 -16
- package/templates/solid/add-on/t3env/assets/src/env.ts +0 -39
- package/templates/solid/add-on/t3env/info.json +0 -10
- package/templates/solid/add-on/t3env/package.json +0 -6
- package/templates/solid/add-on/tanstack-query/assets/src/integrations/tanstack-query/header-user.tsx +0 -5
- package/templates/solid/add-on/tanstack-query/assets/src/integrations/tanstack-query/provider.tsx +0 -15
- package/templates/solid/add-on/tanstack-query/assets/src/routes/demo.tanstack-query.tsx +0 -30
- package/templates/solid/add-on/tanstack-query/info.json +0 -13
- package/templates/solid/add-on/tanstack-query/package.json +0 -6
- package/templates/solid/base/README.md.ejs +0 -215
- package/templates/solid/base/_dot_cursorrules.append +0 -35
- package/templates/solid/base/_dot_gitignore +0 -5
- package/templates/solid/base/_dot_vscode/settings.biome.json +0 -38
- package/templates/solid/base/_dot_vscode/settings.json +0 -11
- package/templates/solid/base/index.html.ejs +0 -20
- package/templates/solid/base/package.biome.json +0 -10
- package/templates/solid/base/package.eslintprettier.json +0 -11
- package/templates/solid/base/package.json +0 -23
- package/templates/solid/base/package.ts.json +0 -5
- package/templates/solid/base/package.tw.json +0 -6
- package/templates/solid/base/public/favicon.ico +0 -0
- package/templates/solid/base/public/logo192.png +0 -0
- package/templates/solid/base/public/logo512.png +0 -0
- package/templates/solid/base/public/manifest.json +0 -25
- package/templates/solid/base/public/robots.txt +0 -3
- package/templates/solid/base/src/App.css +0 -0
- package/templates/solid/base/src/App.tsx.ejs +0 -47
- package/templates/solid/base/src/components/Header.tsx.ejs +0 -26
- package/templates/solid/base/src/logo.svg +0 -120
- package/templates/solid/base/src/styles.css.ejs +0 -15
- package/templates/solid/base/toolchain/.prettierignore +0 -3
- package/templates/solid/base/toolchain/biome.json +0 -31
- package/templates/solid/base/toolchain/eslint.config.js +0 -5
- package/templates/solid/base/toolchain/prettier.config.js +0 -10
- package/templates/solid/base/tsconfig.json.ejs +0 -31
- package/templates/solid/base/vite.config.js.ejs +0 -22
- package/templates/solid/code-router/src/main.tsx.ejs +0 -71
- package/templates/solid/example/tanchat/README.md +0 -52
- package/templates/solid/example/tanchat/assets/ai-streaming-server/README.md +0 -110
- package/templates/solid/example/tanchat/assets/ai-streaming-server/_dot_env.example +0 -1
- package/templates/solid/example/tanchat/assets/ai-streaming-server/package.json +0 -26
- package/templates/solid/example/tanchat/assets/ai-streaming-server/src/index.ts +0 -102
- package/templates/solid/example/tanchat/assets/ai-streaming-server/tsconfig.json +0 -15
- package/templates/solid/example/tanchat/assets/src/components/demo.SettingsDialog.tsx +0 -149
- package/templates/solid/example/tanchat/assets/src/demo.index.css +0 -227
- package/templates/solid/example/tanchat/assets/src/lib/demo-store.ts +0 -13
- package/templates/solid/example/tanchat/assets/src/routes/example.chat.tsx +0 -435
- package/templates/solid/example/tanchat/assets/src/store/demo.hooks.ts +0 -17
- package/templates/solid/example/tanchat/assets/src/store/demo.store.ts +0 -133
- package/templates/solid/example/tanchat/info.json +0 -14
- package/templates/solid/example/tanchat/package.json +0 -7
- package/templates/solid/file-router/package.fr.json +0 -5
- package/templates/solid/file-router/src/main.tsx.ejs +0 -47
- package/templates/solid/file-router/src/routes/__root.tsx.ejs +0 -41
- package/templates/solid/file-router/src/routes/index.tsx +0 -43
- package/tests/cra.test.ts +0 -293
- package/tests/snapshots/cra/cr-js-npm.json +0 -33
- package/tests/snapshots/cra/cr-ts-npm.json +0 -34
- package/tests/snapshots/cra/cr-ts-start-npm.json +0 -38
- package/tests/snapshots/cra/fr-ts-npm.json +0 -34
- package/tests/snapshots/cra/fr-ts-tw-npm.json +0 -33
- package/tests/snapshots/cra/solid-cr-js-npm.json +0 -31
- package/tests/snapshots/cra/solid-cr-ts-npm.json +0 -32
- package/tests/snapshots/cra/solid-cr-ts-start-npm.json +0 -36
- package/tests/snapshots/cra/solid-fr-ts-npm.json +0 -33
- package/tests/snapshots/cra/solid-fr-ts-tw-npm.json +0 -32
- package/tests/test-utilities.ts +0 -87
package/src/custom-add-on.ts
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import { readFile, readdir } from 'node:fs/promises'
|
|
2
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
3
|
-
import { basename, dirname, resolve } from 'node:path'
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
|
|
6
|
-
import { createMemoryEnvironment } from './environment.js'
|
|
7
|
-
import { createApp } from './create-app.js'
|
|
8
|
-
import { readConfigFile } from './config-file.js'
|
|
9
|
-
import { finalizeAddOns } from './add-ons.js'
|
|
10
|
-
import { readFileHelper } from './file-helper.js'
|
|
11
|
-
|
|
12
|
-
import type { Framework, Options } from './types.js'
|
|
13
|
-
import type { PersistedOptions } from './config-file.js'
|
|
14
|
-
|
|
15
|
-
type AddOnMode = 'add-on' | 'overlay'
|
|
16
|
-
|
|
17
|
-
const INFO_FILE: Record<AddOnMode, string> = {
|
|
18
|
-
'add-on': '.add-on/info.json',
|
|
19
|
-
overlay: 'overlay-info.json',
|
|
20
|
-
}
|
|
21
|
-
const COMPILED_FILE: Record<AddOnMode, string> = {
|
|
22
|
-
'add-on': 'add-on.json',
|
|
23
|
-
overlay: 'overlay.json',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const ADD_ON_DIR = '.add-on'
|
|
27
|
-
const ASSETS_DIR = 'assets'
|
|
28
|
-
|
|
29
|
-
const IGNORE_FILES = [
|
|
30
|
-
ADD_ON_DIR,
|
|
31
|
-
'node_modules',
|
|
32
|
-
'dist',
|
|
33
|
-
'build',
|
|
34
|
-
'.git',
|
|
35
|
-
'pnpm-lock.yaml',
|
|
36
|
-
'package-lock.json',
|
|
37
|
-
'yarn.lock',
|
|
38
|
-
'bun.lockb',
|
|
39
|
-
'bun.lock',
|
|
40
|
-
'deno.lock',
|
|
41
|
-
'add-on.json',
|
|
42
|
-
'add-on-info.json',
|
|
43
|
-
'package.json',
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
const ADD_ON_IGNORE_FILES: Array<string> = [
|
|
47
|
-
'main.jsx',
|
|
48
|
-
'App.jsx',
|
|
49
|
-
'main.tsx',
|
|
50
|
-
'App.tsx',
|
|
51
|
-
'routeTree.gen.ts',
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
function templatize(routeCode: string, routeFile: string) {
|
|
55
|
-
let code = routeCode
|
|
56
|
-
|
|
57
|
-
// Replace the import
|
|
58
|
-
code = code.replace(
|
|
59
|
-
/import { createFileRoute } from '@tanstack\/react-router'/g,
|
|
60
|
-
`import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/react-router'`,
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
// Extract route path and definition, then transform the route declaration
|
|
64
|
-
const routeMatch = code.match(
|
|
65
|
-
/export\s+const\s+Route\s*=\s*createFileRoute\(['"]([^'"]+)['"]\)\s*\(\{([^}]+)\}\)/,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
let path = ''
|
|
69
|
-
|
|
70
|
-
if (routeMatch) {
|
|
71
|
-
const fullMatch = routeMatch[0]
|
|
72
|
-
path = routeMatch[1]
|
|
73
|
-
const routeDefinition = routeMatch[2]
|
|
74
|
-
code = code.replace(
|
|
75
|
-
fullMatch,
|
|
76
|
-
`<% if (codeRouter) { %>
|
|
77
|
-
import type { RootRoute } from '@tanstack/react-router'
|
|
78
|
-
<% } else { %>
|
|
79
|
-
export const Route = createFileRoute('${path}')({${routeDefinition}})
|
|
80
|
-
<% } %>`,
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
code += `
|
|
84
|
-
<% if (codeRouter) { %>
|
|
85
|
-
export default (parentRoute: RootRoute) => createRoute({
|
|
86
|
-
path: '${path}',
|
|
87
|
-
${routeDefinition}
|
|
88
|
-
getParentRoute: () => parentRoute,
|
|
89
|
-
})
|
|
90
|
-
<% } %>
|
|
91
|
-
`
|
|
92
|
-
} else {
|
|
93
|
-
console.error(`No route found in the file: ${routeFile}`)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const name = basename(path)
|
|
97
|
-
.replace('.tsx', '')
|
|
98
|
-
.replace(/^demo/, '')
|
|
99
|
-
.replace('.', ' ')
|
|
100
|
-
.trim()
|
|
101
|
-
|
|
102
|
-
return { url: path, code, name }
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function createOptions(
|
|
106
|
-
json: PersistedOptions,
|
|
107
|
-
): Promise<Required<Options>> {
|
|
108
|
-
return {
|
|
109
|
-
...json,
|
|
110
|
-
chosenAddOns: await finalizeAddOns(
|
|
111
|
-
json.framework as Framework,
|
|
112
|
-
json.mode as string,
|
|
113
|
-
[...json.existingAddOns],
|
|
114
|
-
),
|
|
115
|
-
} as Required<Options>
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function runCreateApp(options: Required<Options>) {
|
|
119
|
-
const { environment, output } = createMemoryEnvironment()
|
|
120
|
-
await createApp(options, {
|
|
121
|
-
silent: true,
|
|
122
|
-
environment,
|
|
123
|
-
cwd: process.cwd(),
|
|
124
|
-
name: 'create-tsrouter-app',
|
|
125
|
-
})
|
|
126
|
-
return output
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function recursivelyGatherFiles(
|
|
130
|
-
path: string,
|
|
131
|
-
files: Record<string, string>,
|
|
132
|
-
) {
|
|
133
|
-
const dirFiles = await readdir(path, { withFileTypes: true })
|
|
134
|
-
for (const file of dirFiles) {
|
|
135
|
-
if (file.isDirectory()) {
|
|
136
|
-
await recursivelyGatherFiles(resolve(path, file.name), files)
|
|
137
|
-
} else {
|
|
138
|
-
files[resolve(path, file.name)] = readFileHelper(resolve(path, file.name))
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function compareFiles(
|
|
144
|
-
path: string,
|
|
145
|
-
ignore: Array<string>,
|
|
146
|
-
original: Record<string, string>,
|
|
147
|
-
changedFiles: Record<string, string>,
|
|
148
|
-
) {
|
|
149
|
-
const files = await readdir(path, { withFileTypes: true })
|
|
150
|
-
for (const file of files) {
|
|
151
|
-
const filePath = `${path}/${file.name}`
|
|
152
|
-
if (!ignore.includes(file.name)) {
|
|
153
|
-
if (file.isDirectory()) {
|
|
154
|
-
await compareFiles(filePath, ignore, original, changedFiles)
|
|
155
|
-
} else {
|
|
156
|
-
const contents = (await readFile(filePath)).toString()
|
|
157
|
-
const absolutePath = resolve(process.cwd(), filePath)
|
|
158
|
-
if (!original[absolutePath] || original[absolutePath] !== contents) {
|
|
159
|
-
changedFiles[filePath] = contents
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export async function initAddOn(mode: AddOnMode) {
|
|
167
|
-
const persistedOptions = await readConfigFile(process.cwd())
|
|
168
|
-
if (!persistedOptions) {
|
|
169
|
-
console.error(`${chalk.red('There is no .cta.json file in your project.')}
|
|
170
|
-
|
|
171
|
-
This is probably because this was created with an older version of create-tsrouter-app.`)
|
|
172
|
-
return
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (mode === 'add-on') {
|
|
176
|
-
if (persistedOptions.mode !== 'file-router') {
|
|
177
|
-
console.error(`${chalk.red('This project is not using file-router mode.')}
|
|
178
|
-
|
|
179
|
-
To create an add-on, the project must be created with the file-router mode.`)
|
|
180
|
-
return
|
|
181
|
-
}
|
|
182
|
-
if (!persistedOptions.tailwind) {
|
|
183
|
-
console.error(`${chalk.red('This project is not using Tailwind CSS.')}
|
|
184
|
-
|
|
185
|
-
To create an add-on, the project must be created with Tailwind CSS.`)
|
|
186
|
-
return
|
|
187
|
-
}
|
|
188
|
-
if (!persistedOptions.typescript) {
|
|
189
|
-
console.error(`${chalk.red('This project is not using TypeScript.')}
|
|
190
|
-
|
|
191
|
-
To create an add-on, the project must be created with TypeScript.`)
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const info = existsSync(INFO_FILE[mode])
|
|
197
|
-
? JSON.parse((await readFile(INFO_FILE[mode])).toString())
|
|
198
|
-
: {
|
|
199
|
-
name: `${persistedOptions.projectName}-${mode}`,
|
|
200
|
-
version: '0.0.1',
|
|
201
|
-
description: mode === 'add-on' ? 'Add-on' : 'Project overlay',
|
|
202
|
-
author: 'Jane Smith <jane.smith@example.com>',
|
|
203
|
-
license: 'MIT',
|
|
204
|
-
link: `https://github.com/jane-smith/${persistedOptions.projectName}-${mode}`,
|
|
205
|
-
command: {},
|
|
206
|
-
shadcnComponents: [],
|
|
207
|
-
templates: [persistedOptions.mode],
|
|
208
|
-
routes: [],
|
|
209
|
-
warning: '',
|
|
210
|
-
variables: {},
|
|
211
|
-
phase: 'add-on',
|
|
212
|
-
type: mode,
|
|
213
|
-
packageAdditions: {
|
|
214
|
-
scripts: {},
|
|
215
|
-
dependencies: {},
|
|
216
|
-
devDependencies: {},
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const compiledInfo = JSON.parse(JSON.stringify(info))
|
|
221
|
-
|
|
222
|
-
const originalOutput = await runCreateApp(
|
|
223
|
-
await createOptions(persistedOptions),
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
const originalPackageJson = JSON.parse(
|
|
227
|
-
originalOutput.files[resolve(process.cwd(), 'package.json')],
|
|
228
|
-
)
|
|
229
|
-
const currentPackageJson = JSON.parse(
|
|
230
|
-
(await readFile('package.json')).toString(),
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
for (const script of Object.keys(currentPackageJson.scripts)) {
|
|
234
|
-
if (
|
|
235
|
-
originalPackageJson.scripts[script] !== currentPackageJson.scripts[script]
|
|
236
|
-
) {
|
|
237
|
-
info.packageAdditions.scripts[script] = currentPackageJson.scripts[script]
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const dependencies: Record<string, string> = {}
|
|
242
|
-
for (const dependency of Object.keys(currentPackageJson.dependencies)) {
|
|
243
|
-
if (
|
|
244
|
-
originalPackageJson.dependencies[dependency] !==
|
|
245
|
-
currentPackageJson.dependencies[dependency]
|
|
246
|
-
) {
|
|
247
|
-
dependencies[dependency] = currentPackageJson.dependencies[dependency]
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
info.packageAdditions.dependencies = dependencies
|
|
251
|
-
|
|
252
|
-
const devDependencies: Record<string, string> = {}
|
|
253
|
-
for (const dependency of Object.keys(currentPackageJson.devDependencies)) {
|
|
254
|
-
if (
|
|
255
|
-
originalPackageJson.devDependencies[dependency] !==
|
|
256
|
-
currentPackageJson.devDependencies[dependency]
|
|
257
|
-
) {
|
|
258
|
-
devDependencies[dependency] =
|
|
259
|
-
currentPackageJson.devDependencies[dependency]
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
info.packageAdditions.devDependencies = devDependencies
|
|
263
|
-
|
|
264
|
-
// Find altered files
|
|
265
|
-
const changedFiles: Record<string, string> = {}
|
|
266
|
-
await compareFiles('.', IGNORE_FILES, originalOutput.files, changedFiles)
|
|
267
|
-
if (mode === 'overlay') {
|
|
268
|
-
compiledInfo.files = changedFiles
|
|
269
|
-
} else {
|
|
270
|
-
const assetsDir = resolve(ADD_ON_DIR, ASSETS_DIR)
|
|
271
|
-
if (!existsSync(assetsDir)) {
|
|
272
|
-
await compareFiles('.', IGNORE_FILES, originalOutput.files, changedFiles)
|
|
273
|
-
for (const file of Object.keys(changedFiles).filter(
|
|
274
|
-
(file) => !ADD_ON_IGNORE_FILES.includes(basename(file)),
|
|
275
|
-
)) {
|
|
276
|
-
mkdirSync(dirname(resolve(assetsDir, file)), {
|
|
277
|
-
recursive: true,
|
|
278
|
-
})
|
|
279
|
-
if (file.includes('/routes/')) {
|
|
280
|
-
const { url, code, name } = templatize(changedFiles[file], file)
|
|
281
|
-
info.routes.push({
|
|
282
|
-
url,
|
|
283
|
-
name,
|
|
284
|
-
})
|
|
285
|
-
writeFileSync(resolve(assetsDir, `${file}.ejs`), code)
|
|
286
|
-
} else {
|
|
287
|
-
writeFileSync(resolve(assetsDir, file), changedFiles[file])
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
const addOnFiles: Record<string, string> = {}
|
|
292
|
-
await recursivelyGatherFiles(assetsDir, addOnFiles)
|
|
293
|
-
compiledInfo.files = Object.keys(addOnFiles).reduce(
|
|
294
|
-
(acc, file) => {
|
|
295
|
-
acc[file.replace(assetsDir, '.')] = addOnFiles[file]
|
|
296
|
-
return acc
|
|
297
|
-
},
|
|
298
|
-
{} as Record<string, string>,
|
|
299
|
-
)
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
compiledInfo.routes = info.routes
|
|
303
|
-
compiledInfo.framework = persistedOptions.framework
|
|
304
|
-
compiledInfo.addDependencies = persistedOptions.existingAddOns
|
|
305
|
-
|
|
306
|
-
if (mode === 'overlay') {
|
|
307
|
-
compiledInfo.mode = persistedOptions.mode
|
|
308
|
-
compiledInfo.typescript = persistedOptions.typescript
|
|
309
|
-
compiledInfo.tailwind = persistedOptions.tailwind
|
|
310
|
-
|
|
311
|
-
compiledInfo.deletedFiles = []
|
|
312
|
-
for (const file of Object.keys(originalOutput.files)) {
|
|
313
|
-
if (!existsSync(file)) {
|
|
314
|
-
compiledInfo.deletedFiles.push(file.replace(process.cwd(), '.'))
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (!existsSync(resolve(INFO_FILE[mode]))) {
|
|
320
|
-
mkdirSync(resolve(dirname(INFO_FILE[mode])), { recursive: true })
|
|
321
|
-
writeFileSync(INFO_FILE[mode], JSON.stringify(info, null, 2))
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
writeFileSync(COMPILED_FILE[mode], JSON.stringify(compiledInfo, null, 2))
|
|
325
|
-
}
|
package/src/file-helper.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs'
|
|
2
|
-
import { extname } from 'node:path'
|
|
3
|
-
|
|
4
|
-
const BINARY_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico']
|
|
5
|
-
|
|
6
|
-
export function readFileHelper(path: string): string {
|
|
7
|
-
if (BINARY_EXTENSIONS.includes(extname(path))) {
|
|
8
|
-
return `base64::${readFileSync(path).toString('base64')}`
|
|
9
|
-
} else {
|
|
10
|
-
return readFileSync(path, 'utf-8').toString()
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getBinaryFile(content: string): string | null {
|
|
15
|
-
if (content.startsWith('base64::')) {
|
|
16
|
-
const binaryContent = Buffer.from(content.replace('base64::', ''), 'base64')
|
|
17
|
-
return binaryContent as unknown as string
|
|
18
|
-
}
|
|
19
|
-
return null
|
|
20
|
-
}
|
package/src/mcp.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
-
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
4
|
-
import express from 'express'
|
|
5
|
-
import { z } from 'zod'
|
|
6
|
-
|
|
7
|
-
import { createApp } from './create-app.js'
|
|
8
|
-
import { finalizeAddOns } from './add-ons.js'
|
|
9
|
-
import { createDefaultEnvironment } from './environment.js'
|
|
10
|
-
|
|
11
|
-
import type { TemplateOptions } from './types.js'
|
|
12
|
-
|
|
13
|
-
const tanStackReactAddOns = [
|
|
14
|
-
{
|
|
15
|
-
id: 'clerk',
|
|
16
|
-
description: 'Enable authentication with Clerk',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: 'convex',
|
|
20
|
-
description: 'Enable a database using Convex',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: 'form',
|
|
24
|
-
description: 'Form handling library',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 'netlify',
|
|
28
|
-
description: 'Enable deployments to Netlify',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: 'sentry',
|
|
32
|
-
description: 'Enable Sentry error tracking',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 'shadcn',
|
|
36
|
-
description: 'Enable integration of the Shadcn UI component library',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'start',
|
|
40
|
-
description:
|
|
41
|
-
'Set this if you want a TanStack Start application that supports server functions or APIs',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: 'tanstack-query',
|
|
45
|
-
description: 'Enable TanStack Query for data fetching',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: 'store',
|
|
49
|
-
description: 'Enable the TanStack Store state management library',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: 'tanchat',
|
|
53
|
-
description: 'Add an AI chatbot example to the application',
|
|
54
|
-
},
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
const tanStackSolidAddOns = [
|
|
58
|
-
{
|
|
59
|
-
id: 'solid-ui',
|
|
60
|
-
description: 'Enable integration of the Solid UI component library',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: 'form',
|
|
64
|
-
description: 'Form handling library',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: 'sentry',
|
|
68
|
-
description: 'Enable Sentry error tracking',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
id: 'store',
|
|
72
|
-
description: 'Enable the TanStack Store state management library',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
id: 'start',
|
|
76
|
-
description:
|
|
77
|
-
'Set this if you want a TanStack Start application that supports server functions or APIs',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: 'tanstack-query',
|
|
81
|
-
description: 'Enable TanStack Query for data fetching',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: 'tanchat',
|
|
85
|
-
description: 'Add an AI chatbot example to the application',
|
|
86
|
-
},
|
|
87
|
-
]
|
|
88
|
-
|
|
89
|
-
function createServer({
|
|
90
|
-
appName,
|
|
91
|
-
forcedAddOns = [],
|
|
92
|
-
name,
|
|
93
|
-
}: {
|
|
94
|
-
appName?: string
|
|
95
|
-
forcedAddOns?: Array<string>
|
|
96
|
-
name?: string
|
|
97
|
-
}) {
|
|
98
|
-
const server = new McpServer({
|
|
99
|
-
name: `${appName} Application Builder`,
|
|
100
|
-
version: '1.0.0',
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
server.tool('listTanStackReactAddOns', {}, () => {
|
|
104
|
-
return {
|
|
105
|
-
content: [{ type: 'text', text: JSON.stringify(tanStackReactAddOns) }],
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
server.tool(
|
|
110
|
-
'createTanStackReactApplication',
|
|
111
|
-
{
|
|
112
|
-
projectName: z
|
|
113
|
-
.string()
|
|
114
|
-
.describe(
|
|
115
|
-
'The package.json module name of the application (will also be the directory name)',
|
|
116
|
-
),
|
|
117
|
-
cwd: z.string().describe('The directory to create the application in'),
|
|
118
|
-
addOns: z
|
|
119
|
-
.array(
|
|
120
|
-
z.enum([
|
|
121
|
-
'clerk',
|
|
122
|
-
'convex',
|
|
123
|
-
'form',
|
|
124
|
-
'netlify',
|
|
125
|
-
'sentry',
|
|
126
|
-
'shadcn',
|
|
127
|
-
'start',
|
|
128
|
-
'store',
|
|
129
|
-
'tanstack-query',
|
|
130
|
-
'tanchat',
|
|
131
|
-
]),
|
|
132
|
-
)
|
|
133
|
-
.describe('The IDs of the add-ons to install'),
|
|
134
|
-
targetDir: z
|
|
135
|
-
.string()
|
|
136
|
-
.describe(
|
|
137
|
-
'The directory to create the application in. Use the absolute path of the directory you want the application to be created in',
|
|
138
|
-
),
|
|
139
|
-
},
|
|
140
|
-
async ({ projectName, addOns, cwd, targetDir }) => {
|
|
141
|
-
try {
|
|
142
|
-
process.chdir(cwd)
|
|
143
|
-
const chosenAddOns = await finalizeAddOns(
|
|
144
|
-
'react',
|
|
145
|
-
'file-router',
|
|
146
|
-
Array.from(
|
|
147
|
-
new Set([...(addOns as unknown as Array<string>), ...forcedAddOns]),
|
|
148
|
-
),
|
|
149
|
-
)
|
|
150
|
-
await createApp(
|
|
151
|
-
{
|
|
152
|
-
projectName: projectName.replace(/^\//, './'),
|
|
153
|
-
framework: 'react',
|
|
154
|
-
typescript: true,
|
|
155
|
-
tailwind: true,
|
|
156
|
-
packageManager: 'pnpm',
|
|
157
|
-
toolchain: 'none',
|
|
158
|
-
mode: 'file-router',
|
|
159
|
-
addOns: true,
|
|
160
|
-
chosenAddOns,
|
|
161
|
-
git: true,
|
|
162
|
-
variableValues: {},
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
silent: true,
|
|
166
|
-
environment: createDefaultEnvironment(),
|
|
167
|
-
name,
|
|
168
|
-
cwd: targetDir,
|
|
169
|
-
},
|
|
170
|
-
)
|
|
171
|
-
return {
|
|
172
|
-
content: [{ type: 'text', text: 'Application created successfully' }],
|
|
173
|
-
}
|
|
174
|
-
} catch (error) {
|
|
175
|
-
return {
|
|
176
|
-
content: [
|
|
177
|
-
{ type: 'text', text: `Error creating application: ${error}` },
|
|
178
|
-
],
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
server.tool('listTanStackSolidAddOns', {}, () => {
|
|
185
|
-
return {
|
|
186
|
-
content: [{ type: 'text', text: JSON.stringify(tanStackSolidAddOns) }],
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
server.tool(
|
|
191
|
-
'createTanStackSolidApplication',
|
|
192
|
-
{
|
|
193
|
-
projectName: z
|
|
194
|
-
.string()
|
|
195
|
-
.describe(
|
|
196
|
-
'The package.json module name of the application (will also be the directory name)',
|
|
197
|
-
),
|
|
198
|
-
cwd: z.string().describe('The directory to create the application in'),
|
|
199
|
-
addOns: z
|
|
200
|
-
.array(
|
|
201
|
-
z.enum([
|
|
202
|
-
'solid-ui',
|
|
203
|
-
'form',
|
|
204
|
-
'sentry',
|
|
205
|
-
'store',
|
|
206
|
-
'tanstack-query',
|
|
207
|
-
'tanchat',
|
|
208
|
-
]),
|
|
209
|
-
)
|
|
210
|
-
.describe('The IDs of the add-ons to install'),
|
|
211
|
-
targetDir: z
|
|
212
|
-
.string()
|
|
213
|
-
.describe(
|
|
214
|
-
'The directory to create the application in. Use the absolute path of the directory you want the application to be created in',
|
|
215
|
-
),
|
|
216
|
-
},
|
|
217
|
-
async ({ projectName, addOns, cwd, targetDir }) => {
|
|
218
|
-
try {
|
|
219
|
-
process.chdir(cwd)
|
|
220
|
-
const chosenAddOns = await finalizeAddOns(
|
|
221
|
-
'solid',
|
|
222
|
-
'file-router',
|
|
223
|
-
Array.from(
|
|
224
|
-
new Set([...(addOns as unknown as Array<string>), ...forcedAddOns]),
|
|
225
|
-
),
|
|
226
|
-
)
|
|
227
|
-
await createApp(
|
|
228
|
-
{
|
|
229
|
-
projectName: projectName.replace(/^\//, './'),
|
|
230
|
-
framework: 'solid',
|
|
231
|
-
typescript: true,
|
|
232
|
-
tailwind: true,
|
|
233
|
-
packageManager: 'pnpm',
|
|
234
|
-
toolchain: 'none',
|
|
235
|
-
mode: 'file-router',
|
|
236
|
-
addOns: true,
|
|
237
|
-
chosenAddOns,
|
|
238
|
-
git: true,
|
|
239
|
-
variableValues: {},
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
silent: true,
|
|
243
|
-
environment: createDefaultEnvironment(),
|
|
244
|
-
name,
|
|
245
|
-
cwd: targetDir,
|
|
246
|
-
},
|
|
247
|
-
)
|
|
248
|
-
return {
|
|
249
|
-
content: [{ type: 'text', text: 'Application created successfully' }],
|
|
250
|
-
}
|
|
251
|
-
} catch (error) {
|
|
252
|
-
return {
|
|
253
|
-
content: [
|
|
254
|
-
{ type: 'text', text: `Error creating application: ${error}` },
|
|
255
|
-
],
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
return server
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export default async function runServer(
|
|
265
|
-
sse: boolean,
|
|
266
|
-
{
|
|
267
|
-
forcedAddOns,
|
|
268
|
-
appName,
|
|
269
|
-
name,
|
|
270
|
-
}: {
|
|
271
|
-
forcedMode?: TemplateOptions
|
|
272
|
-
forcedAddOns?: Array<string>
|
|
273
|
-
appName?: string
|
|
274
|
-
name?: string
|
|
275
|
-
},
|
|
276
|
-
) {
|
|
277
|
-
let transport: SSEServerTransport | null = null
|
|
278
|
-
|
|
279
|
-
const server = createServer({ appName, forcedAddOns, name })
|
|
280
|
-
if (sse) {
|
|
281
|
-
const app = express()
|
|
282
|
-
|
|
283
|
-
app.get('/sse', (req, res) => {
|
|
284
|
-
transport = new SSEServerTransport('/messages', res)
|
|
285
|
-
server.connect(transport)
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
app.post('/messages', (req, res) => {
|
|
289
|
-
if (transport) {
|
|
290
|
-
transport.handlePostMessage(req, res)
|
|
291
|
-
}
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
const port = process.env.PORT || 8080
|
|
295
|
-
app.listen(port, () => {
|
|
296
|
-
console.log(`Server is running on port http://localhost:${port}/sse`)
|
|
297
|
-
})
|
|
298
|
-
} else {
|
|
299
|
-
const transport = new StdioServerTransport()
|
|
300
|
-
await server.connect(transport)
|
|
301
|
-
}
|
|
302
|
-
}
|
package/src/templates.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { dirname, join } from 'node:path'
|
|
2
|
-
import { fileURLToPath } from 'node:url'
|
|
3
|
-
|
|
4
|
-
export function getTemplatesRoot() {
|
|
5
|
-
// Get the parent directory because the compiled code is in the dist folder
|
|
6
|
-
return join(dirname(dirname(fileURLToPath(import.meta.url))), 'templates')
|
|
7
|
-
}
|
package/src/toolchain.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SignedIn,
|
|
3
|
-
SignInButton,
|
|
4
|
-
SignedOut,
|
|
5
|
-
UserButton,
|
|
6
|
-
} from '@clerk/clerk-react'
|
|
7
|
-
|
|
8
|
-
export default function HeaderUser() {
|
|
9
|
-
return (
|
|
10
|
-
<>
|
|
11
|
-
<SignedIn>
|
|
12
|
-
<UserButton />
|
|
13
|
-
</SignedIn>
|
|
14
|
-
<SignedOut>
|
|
15
|
-
<SignInButton />
|
|
16
|
-
</SignedOut>
|
|
17
|
-
</>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ClerkProvider } from '@clerk/clerk-react'
|
|
2
|
-
|
|
3
|
-
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY
|
|
4
|
-
if (!PUBLISHABLE_KEY) {
|
|
5
|
-
throw new Error('Add your Clerk Publishable Key to the .env.local file')
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function AppClerkProvider({
|
|
9
|
-
children,
|
|
10
|
-
}: {
|
|
11
|
-
children: React.ReactNode
|
|
12
|
-
}) {
|
|
13
|
-
return (
|
|
14
|
-
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
|
|
15
|
-
{children}
|
|
16
|
-
</ClerkProvider>
|
|
17
|
-
)
|
|
18
|
-
}
|