@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
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { fs, vol } from 'memfs'
|
|
3
|
+
|
|
4
|
+
import { createMemoryEnvironment } from '../src/environment.js'
|
|
5
|
+
import {
|
|
6
|
+
addToApp,
|
|
7
|
+
getCurrentConfiguration,
|
|
8
|
+
hasPendingGitChanges,
|
|
9
|
+
runNewCommands,
|
|
10
|
+
writeFiles,
|
|
11
|
+
} from '../src/add-to-app.js'
|
|
12
|
+
import {
|
|
13
|
+
__testClearFrameworks,
|
|
14
|
+
__testRegisterFramework,
|
|
15
|
+
} from '../src/frameworks.js'
|
|
16
|
+
|
|
17
|
+
import type { PersistedOptions } from '../src/config-file.js'
|
|
18
|
+
|
|
19
|
+
vi.mock('node:fs', () => fs)
|
|
20
|
+
vi.mock('node:fs/promises', () => fs.promises)
|
|
21
|
+
|
|
22
|
+
const fakeCTAJSON: PersistedOptions = {
|
|
23
|
+
projectName: 'test',
|
|
24
|
+
targetDir: '/foo',
|
|
25
|
+
framework: 'test',
|
|
26
|
+
mode: 'code-router',
|
|
27
|
+
chosenAddOns: [],
|
|
28
|
+
version: 1,
|
|
29
|
+
typescript: true,
|
|
30
|
+
tailwind: true,
|
|
31
|
+
packageManager: 'npm',
|
|
32
|
+
git: true,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
const fakeFiles = {
|
|
37
|
+
'./package.json': JSON.stringify({
|
|
38
|
+
name: 'test',
|
|
39
|
+
version: '1.0.0',
|
|
40
|
+
dependencies: {},
|
|
41
|
+
}),
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
vol.reset()
|
|
45
|
+
__testClearFrameworks()
|
|
46
|
+
__testRegisterFramework({
|
|
47
|
+
id: 'test',
|
|
48
|
+
name: 'Test',
|
|
49
|
+
description: 'Test',
|
|
50
|
+
version: '1.0.0',
|
|
51
|
+
baseDirectory: '/foo',
|
|
52
|
+
addOnsDirectories: [],
|
|
53
|
+
examplesDirectory: '',
|
|
54
|
+
basePackageJSON: {},
|
|
55
|
+
optionalPackages: {},
|
|
56
|
+
getAddOns: () => [
|
|
57
|
+
{
|
|
58
|
+
id: 'test',
|
|
59
|
+
name: 'Test',
|
|
60
|
+
description: 'Test',
|
|
61
|
+
version: '1.0.0',
|
|
62
|
+
type: 'add-on',
|
|
63
|
+
phase: 'add-on',
|
|
64
|
+
modes: ['code-router', 'file-router'],
|
|
65
|
+
command: {
|
|
66
|
+
command: 'echo',
|
|
67
|
+
args: ['baz'],
|
|
68
|
+
},
|
|
69
|
+
packageAdditions: {
|
|
70
|
+
dependencies: {
|
|
71
|
+
'test-package': '1.0.0',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
dependsOn: [],
|
|
75
|
+
getFiles: () => Promise.resolve(['./jack.txt']),
|
|
76
|
+
getFileContents: () => Promise.resolve('foo'),
|
|
77
|
+
getDeletedFiles: () => Promise.resolve([]),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
getFiles: () => Promise.resolve(Object.keys(fakeFiles)),
|
|
81
|
+
getFileContents: (path) => Promise.resolve(fakeFiles[path]),
|
|
82
|
+
getDeletedFiles: () => Promise.resolve([]),
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const configFile: PersistedOptions = {
|
|
87
|
+
projectName: 'test',
|
|
88
|
+
targetDir: '/foo',
|
|
89
|
+
framework: 'test',
|
|
90
|
+
mode: 'code-router',
|
|
91
|
+
chosenAddOns: [],
|
|
92
|
+
version: 1,
|
|
93
|
+
typescript: true,
|
|
94
|
+
tailwind: true,
|
|
95
|
+
packageManager: 'npm',
|
|
96
|
+
git: true,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
describe('getCurrentConfiguration', () => {
|
|
100
|
+
it('should check for the config file', async () => {
|
|
101
|
+
const { environment } = createMemoryEnvironment()
|
|
102
|
+
const out = await getCurrentConfiguration(environment, '/foo')
|
|
103
|
+
expect(out).toBeUndefined()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('should read the config file', async () => {
|
|
107
|
+
const { environment } = createMemoryEnvironment()
|
|
108
|
+
|
|
109
|
+
environment.writeFile('/foo/.cta.json', JSON.stringify(configFile, null, 2))
|
|
110
|
+
|
|
111
|
+
const out = await getCurrentConfiguration(environment, '/foo')
|
|
112
|
+
expect(out).toEqual(configFile)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
describe('hasPendingGitChanges', () => {
|
|
117
|
+
it('should check for pending git changes', async () => {
|
|
118
|
+
const { environment } = createMemoryEnvironment()
|
|
119
|
+
environment.execute = () => Promise.resolve({ stdout: '' })
|
|
120
|
+
const out = await hasPendingGitChanges(environment, '/foo')
|
|
121
|
+
expect(out).toBe(false)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('should check for pending git changes', async () => {
|
|
125
|
+
const { environment } = createMemoryEnvironment()
|
|
126
|
+
environment.execute = () => Promise.resolve({ stdout: 'M foo' })
|
|
127
|
+
const out = await hasPendingGitChanges(environment, '/foo')
|
|
128
|
+
expect(out).toBe(true)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
describe('writeFiles', () => {
|
|
133
|
+
it('should prompt for confirmation when not forced', async () => {
|
|
134
|
+
const { environment } = createMemoryEnvironment('/foo')
|
|
135
|
+
environment.writeFile('/foo/bloop.txt', 'bloop')
|
|
136
|
+
environment.writeFile(
|
|
137
|
+
'/foo/package.json',
|
|
138
|
+
JSON.stringify(
|
|
139
|
+
{
|
|
140
|
+
name: 'test',
|
|
141
|
+
version: '1.0.0',
|
|
142
|
+
dependencies: {},
|
|
143
|
+
},
|
|
144
|
+
null,
|
|
145
|
+
2,
|
|
146
|
+
),
|
|
147
|
+
)
|
|
148
|
+
environment.writeFile('/foo/bar.txt', 'bar')
|
|
149
|
+
environment.confirm = () => Promise.resolve(false)
|
|
150
|
+
let thrown = false
|
|
151
|
+
writeFiles(
|
|
152
|
+
environment,
|
|
153
|
+
'/foo',
|
|
154
|
+
{
|
|
155
|
+
files: {
|
|
156
|
+
'./bar.txt': 'baz',
|
|
157
|
+
'./blarg.txt': 'blarg',
|
|
158
|
+
},
|
|
159
|
+
deletedFiles: [],
|
|
160
|
+
},
|
|
161
|
+
false,
|
|
162
|
+
)
|
|
163
|
+
.catch((e) => {
|
|
164
|
+
thrown = true
|
|
165
|
+
})
|
|
166
|
+
.finally(() => {
|
|
167
|
+
expect(thrown).toBe(true)
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it('should not prompt for confirmation when forced', async () => {
|
|
172
|
+
const { environment, output } = createMemoryEnvironment('/foo')
|
|
173
|
+
environment.startRun()
|
|
174
|
+
environment.writeFile('/foo/.cta.json', JSON.stringify(configFile, null, 2))
|
|
175
|
+
environment.writeFile('/foo/blooop.txt', 'blooop')
|
|
176
|
+
await writeFiles(
|
|
177
|
+
environment,
|
|
178
|
+
'/foo',
|
|
179
|
+
{
|
|
180
|
+
files: {
|
|
181
|
+
'./bar.txt': 'baz',
|
|
182
|
+
'./blarg.txt': 'blarg',
|
|
183
|
+
},
|
|
184
|
+
deletedFiles: [],
|
|
185
|
+
},
|
|
186
|
+
true,
|
|
187
|
+
)
|
|
188
|
+
environment.finishRun()
|
|
189
|
+
expect(output.files).toEqual({
|
|
190
|
+
'./blooop.txt': 'blooop',
|
|
191
|
+
'./bar.txt': 'baz',
|
|
192
|
+
'./blarg.txt': 'blarg',
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('should handle binary files', async () => {
|
|
197
|
+
const { environment, output } = createMemoryEnvironment('/foo')
|
|
198
|
+
environment.startRun()
|
|
199
|
+
environment.writeFile('/foo/.cta.json', JSON.stringify(configFile, null, 2))
|
|
200
|
+
environment.writeFile('/foo/unchanged.jpg', 'base64::foobaz')
|
|
201
|
+
environment.writeFile('/foo/changing.jpg', 'base64::foobaz')
|
|
202
|
+
await writeFiles(
|
|
203
|
+
environment,
|
|
204
|
+
'/foo',
|
|
205
|
+
{
|
|
206
|
+
files: {
|
|
207
|
+
'./unchanged.jpg': 'base64::foobaz',
|
|
208
|
+
'./changing.jpg': 'base64::aGVsbG8=',
|
|
209
|
+
'./new.jpg': 'base64::aGVsbG8=',
|
|
210
|
+
},
|
|
211
|
+
deletedFiles: [],
|
|
212
|
+
},
|
|
213
|
+
true,
|
|
214
|
+
)
|
|
215
|
+
environment.finishRun()
|
|
216
|
+
// It's ok for unchanged.jpg not to be written, because it matches the existing file
|
|
217
|
+
expect(output.files).toEqual({
|
|
218
|
+
'./unchanged.jpg': 'base64::foobaz',
|
|
219
|
+
'./changing.jpg': 'base64::aGVsbG8=',
|
|
220
|
+
'./new.jpg': 'base64::aGVsbG8=',
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('should handle package.json', async () => {
|
|
225
|
+
const { environment, output } = createMemoryEnvironment('/foo')
|
|
226
|
+
environment.startRun()
|
|
227
|
+
environment.writeFile(
|
|
228
|
+
'/foo/package.json',
|
|
229
|
+
JSON.stringify(
|
|
230
|
+
{
|
|
231
|
+
name: 'test',
|
|
232
|
+
version: '1.0.0',
|
|
233
|
+
scripts: {
|
|
234
|
+
dev: 'echo "test"',
|
|
235
|
+
},
|
|
236
|
+
dependencies: {
|
|
237
|
+
'test-package-2': '1.0.0',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
null,
|
|
241
|
+
2,
|
|
242
|
+
),
|
|
243
|
+
)
|
|
244
|
+
await writeFiles(
|
|
245
|
+
environment,
|
|
246
|
+
'/foo',
|
|
247
|
+
{
|
|
248
|
+
files: {
|
|
249
|
+
'./package.json': JSON.stringify(
|
|
250
|
+
{
|
|
251
|
+
scripts: {
|
|
252
|
+
test: 'echo "test"',
|
|
253
|
+
},
|
|
254
|
+
dependencies: {
|
|
255
|
+
'test-package': '1.0.0',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
null,
|
|
259
|
+
2,
|
|
260
|
+
),
|
|
261
|
+
},
|
|
262
|
+
deletedFiles: [],
|
|
263
|
+
},
|
|
264
|
+
true,
|
|
265
|
+
)
|
|
266
|
+
environment.finishRun()
|
|
267
|
+
expect(output.files).toEqual({
|
|
268
|
+
'./package.json': JSON.stringify(
|
|
269
|
+
{
|
|
270
|
+
name: 'test',
|
|
271
|
+
version: '1.0.0',
|
|
272
|
+
scripts: {
|
|
273
|
+
dev: 'echo "test"',
|
|
274
|
+
test: 'echo "test"',
|
|
275
|
+
},
|
|
276
|
+
dependencies: {
|
|
277
|
+
'test-package-2': '1.0.0',
|
|
278
|
+
'test-package': '1.0.0',
|
|
279
|
+
},
|
|
280
|
+
devDependencies: {},
|
|
281
|
+
},
|
|
282
|
+
null,
|
|
283
|
+
2,
|
|
284
|
+
),
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it('should delete files', async () => {
|
|
289
|
+
const { environment, output } = createMemoryEnvironment('/foo')
|
|
290
|
+
environment.startRun()
|
|
291
|
+
environment.writeFile('/foo/bloop.txt', 'bloop')
|
|
292
|
+
await writeFiles(
|
|
293
|
+
environment,
|
|
294
|
+
'/foo',
|
|
295
|
+
{ files: {}, deletedFiles: ['./bloop.txt'] },
|
|
296
|
+
true,
|
|
297
|
+
)
|
|
298
|
+
environment.finishRun()
|
|
299
|
+
expect(output.deletedFiles).toEqual(['./bloop.txt'])
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
describe('runNewCommands', () => {
|
|
304
|
+
it('should run new commands', async () => {
|
|
305
|
+
const { environment, output } = createMemoryEnvironment('/foo')
|
|
306
|
+
environment.startRun()
|
|
307
|
+
await runNewCommands(environment, fakeCTAJSON, '/foo', {
|
|
308
|
+
commands: [{ command: 'echo', args: ['bloop'] }],
|
|
309
|
+
})
|
|
310
|
+
environment.finishRun()
|
|
311
|
+
expect(output.commands).toEqual([{ command: 'echo', args: ['bloop'] }])
|
|
312
|
+
})
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
describe('addToApp', () => {
|
|
316
|
+
it('should add an add-on', async () => {
|
|
317
|
+
const { environment, output } = createMemoryEnvironment('/foo')
|
|
318
|
+
environment.startRun()
|
|
319
|
+
environment.writeFile(
|
|
320
|
+
'/foo/.cta.json',
|
|
321
|
+
JSON.stringify(fakeCTAJSON, null, 2),
|
|
322
|
+
)
|
|
323
|
+
environment.writeFile(
|
|
324
|
+
'/foo/package.json',
|
|
325
|
+
JSON.stringify(
|
|
326
|
+
{
|
|
327
|
+
name: 'test',
|
|
328
|
+
version: '1.0.0',
|
|
329
|
+
scripts: {},
|
|
330
|
+
dependencies: {},
|
|
331
|
+
devDependencies: {},
|
|
332
|
+
},
|
|
333
|
+
null,
|
|
334
|
+
2,
|
|
335
|
+
),
|
|
336
|
+
)
|
|
337
|
+
await addToApp(environment, ['test'], '/foo', {
|
|
338
|
+
forced: true,
|
|
339
|
+
})
|
|
340
|
+
environment.finishRun()
|
|
341
|
+
expect(output.files).toEqual({
|
|
342
|
+
'./jack.txt': 'foo',
|
|
343
|
+
'./package.json': JSON.stringify(
|
|
344
|
+
{
|
|
345
|
+
name: 'test',
|
|
346
|
+
version: '1.0.0',
|
|
347
|
+
scripts: {},
|
|
348
|
+
dependencies: {
|
|
349
|
+
'test-package': '1.0.0',
|
|
350
|
+
},
|
|
351
|
+
devDependencies: {},
|
|
352
|
+
},
|
|
353
|
+
null,
|
|
354
|
+
2,
|
|
355
|
+
),
|
|
356
|
+
})
|
|
357
|
+
})
|
|
358
|
+
})
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { fs, vol } from 'memfs'
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
readConfigFileFromEnvironment,
|
|
7
|
+
writeConfigFileToEnvironment,
|
|
8
|
+
} from '../src/config-file.js'
|
|
9
|
+
import { CONFIG_FILE } from '../src/constants.js'
|
|
10
|
+
import { createMemoryEnvironment } from '../src/environment.js'
|
|
11
|
+
import type { AddOn, Environment, Framework, Options } from '../src/types.js'
|
|
12
|
+
|
|
13
|
+
vi.mock('node:fs', () => fs)
|
|
14
|
+
vi.mock('node:fs/promises', () => fs.promises)
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
vol.reset()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('writeConfigFile', () => {
|
|
21
|
+
it('should write the config file', async () => {
|
|
22
|
+
const targetDir = 'test-dir'
|
|
23
|
+
const options = {
|
|
24
|
+
framework: {
|
|
25
|
+
id: 'react-cra',
|
|
26
|
+
getAddOns: () => [],
|
|
27
|
+
} as unknown as Framework,
|
|
28
|
+
chosenAddOns: [
|
|
29
|
+
{
|
|
30
|
+
id: 'add-on-1',
|
|
31
|
+
description: 'Add-on 1',
|
|
32
|
+
modes: ['file-router'],
|
|
33
|
+
} as AddOn,
|
|
34
|
+
],
|
|
35
|
+
targetDir,
|
|
36
|
+
} as unknown as Options
|
|
37
|
+
const persistedOptions = {
|
|
38
|
+
version: 1,
|
|
39
|
+
framework: options.framework.id,
|
|
40
|
+
chosenAddOns: options.chosenAddOns.map((addOn) => addOn.id),
|
|
41
|
+
}
|
|
42
|
+
const env = {
|
|
43
|
+
writeFile: (path, optionsString) => {
|
|
44
|
+
expect(path).toEqual(resolve(targetDir, CONFIG_FILE))
|
|
45
|
+
expect(optionsString).toEqual(JSON.stringify(persistedOptions, null, 2))
|
|
46
|
+
},
|
|
47
|
+
} as Environment
|
|
48
|
+
await writeConfigFileToEnvironment(env, options)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('readConfigFileFromEnvironment', () => {
|
|
53
|
+
it('should read the config file', async () => {
|
|
54
|
+
const targetDir = 'test-dir'
|
|
55
|
+
const persistedOptions = {
|
|
56
|
+
version: 1,
|
|
57
|
+
framework: 'react-cra',
|
|
58
|
+
chosenAddOns: ['add-on-1'],
|
|
59
|
+
}
|
|
60
|
+
const { environment } = createMemoryEnvironment()
|
|
61
|
+
environment.writeFile(
|
|
62
|
+
resolve(targetDir, CONFIG_FILE),
|
|
63
|
+
JSON.stringify(persistedOptions, null, 2),
|
|
64
|
+
)
|
|
65
|
+
const config = await readConfigFileFromEnvironment(environment, targetDir)
|
|
66
|
+
expect(config).toEqual(persistedOptions)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('should upgrade old config files', async () => {
|
|
70
|
+
const targetDir = 'test-dir'
|
|
71
|
+
const persistedOptions = {
|
|
72
|
+
framework: 'react',
|
|
73
|
+
projectName: 'foo',
|
|
74
|
+
typescript: false,
|
|
75
|
+
tailwind: false,
|
|
76
|
+
packageManager: 'pnpm',
|
|
77
|
+
toolchain: 'none',
|
|
78
|
+
mode: 'code-router',
|
|
79
|
+
git: true,
|
|
80
|
+
variableValues: {},
|
|
81
|
+
version: 1,
|
|
82
|
+
existingAddOns: [],
|
|
83
|
+
}
|
|
84
|
+
const { output, environment } = createMemoryEnvironment()
|
|
85
|
+
environment.writeFile(
|
|
86
|
+
resolve(targetDir, CONFIG_FILE),
|
|
87
|
+
JSON.stringify(persistedOptions, null, 2),
|
|
88
|
+
)
|
|
89
|
+
const config = await readConfigFileFromEnvironment(environment, targetDir)
|
|
90
|
+
|
|
91
|
+
environment.finishRun()
|
|
92
|
+
|
|
93
|
+
expect(config).toEqual({
|
|
94
|
+
framework: 'react-cra',
|
|
95
|
+
projectName: 'foo',
|
|
96
|
+
typescript: false,
|
|
97
|
+
tailwind: false,
|
|
98
|
+
packageManager: 'pnpm',
|
|
99
|
+
chosenAddOns: [],
|
|
100
|
+
git: true,
|
|
101
|
+
mode: 'code-router',
|
|
102
|
+
version: 1,
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { createApp } from '../src/create-app.js'
|
|
5
|
+
|
|
6
|
+
import { createMemoryEnvironment } from '../src/environment.js'
|
|
7
|
+
import { FILE_ROUTER } from '../src/constants.js'
|
|
8
|
+
import { AddOn, Options } from '../src/types.js'
|
|
9
|
+
|
|
10
|
+
const simpleOptions = {
|
|
11
|
+
projectName: 'test',
|
|
12
|
+
targetDir: '/',
|
|
13
|
+
framework: {
|
|
14
|
+
id: 'test',
|
|
15
|
+
name: 'Test',
|
|
16
|
+
basePackageJSON: {
|
|
17
|
+
scripts: {
|
|
18
|
+
dev: 'react-scripts start',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
optionalPackages: {
|
|
22
|
+
typescript: {
|
|
23
|
+
devDependencies: {
|
|
24
|
+
typescript: '^5.0.0',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
tailwindcss: {
|
|
28
|
+
dependencies: {
|
|
29
|
+
tailwindcss: '^3.0.0',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
'file-router': {
|
|
33
|
+
dependencies: {
|
|
34
|
+
'file-router': '^1.0.0',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
getFiles: () => ['./src/test.txt'],
|
|
39
|
+
getFileContents: () => 'Hello',
|
|
40
|
+
getDeletedFiles: () => [],
|
|
41
|
+
},
|
|
42
|
+
chosenAddOns: [],
|
|
43
|
+
packageManager: 'pnpm',
|
|
44
|
+
typescript: true,
|
|
45
|
+
tailwind: true,
|
|
46
|
+
mode: FILE_ROUTER,
|
|
47
|
+
variableValues: {},
|
|
48
|
+
} as unknown as Options
|
|
49
|
+
|
|
50
|
+
describe('createApp', () => {
|
|
51
|
+
it('should create an app', async () => {
|
|
52
|
+
const { environment, output } = createMemoryEnvironment()
|
|
53
|
+
await createApp(environment, simpleOptions)
|
|
54
|
+
|
|
55
|
+
expect(output.files['/src/test.txt']).toEqual('Hello')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should create an app - not silent', async () => {
|
|
59
|
+
const { environment, output } = createMemoryEnvironment()
|
|
60
|
+
await createApp(environment, {
|
|
61
|
+
...simpleOptions,
|
|
62
|
+
targetDir: '/foo/bar/baz',
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const cwd = process.cwd()
|
|
66
|
+
|
|
67
|
+
expect(output.files[resolve(cwd, '/foo/bar/baz/src/test.txt')]).toEqual(
|
|
68
|
+
'Hello',
|
|
69
|
+
)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should create an app - with a starter', async () => {
|
|
73
|
+
const { environment, output } = createMemoryEnvironment()
|
|
74
|
+
await createApp(environment, {
|
|
75
|
+
...simpleOptions,
|
|
76
|
+
starter: {
|
|
77
|
+
command: {
|
|
78
|
+
command: 'echo',
|
|
79
|
+
args: ['Hello'],
|
|
80
|
+
},
|
|
81
|
+
getFiles: () => ['./src/test2.txt'],
|
|
82
|
+
getFileContents: () => 'Hello-2',
|
|
83
|
+
getDeletedFiles: () => [],
|
|
84
|
+
} as unknown as AddOn,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
expect(output.files['/src/test2.txt']).toEqual('Hello-2')
|
|
88
|
+
expect(output.commands.some(({ command }) => command === 'echo')).toBe(true)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should create an app - with a add-on', async () => {
|
|
92
|
+
const { environment, output } = createMemoryEnvironment()
|
|
93
|
+
await createApp(environment, {
|
|
94
|
+
...simpleOptions,
|
|
95
|
+
git: true,
|
|
96
|
+
chosenAddOns: [
|
|
97
|
+
{
|
|
98
|
+
type: 'add-on',
|
|
99
|
+
phase: 'add-on',
|
|
100
|
+
warning: 'This is a warning',
|
|
101
|
+
command: {
|
|
102
|
+
command: 'echo',
|
|
103
|
+
args: ['Hello'],
|
|
104
|
+
},
|
|
105
|
+
packageAdditions: {
|
|
106
|
+
dependencies: {},
|
|
107
|
+
devDependencies: {},
|
|
108
|
+
},
|
|
109
|
+
getFiles: () => ['./src/test2.txt', './public/foo.jpg'],
|
|
110
|
+
getFileContents: () => 'base64::aGVsbG8=',
|
|
111
|
+
getDeletedFiles: () => [],
|
|
112
|
+
} as unknown as AddOn,
|
|
113
|
+
],
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// This is ok, we convert to binary right at the end of the process
|
|
117
|
+
expect(output.files['/src/test2.txt']).toEqual('base64::aGVsbG8=')
|
|
118
|
+
expect(output.commands.some(({ command }) => command === 'echo')).toBe(true)
|
|
119
|
+
})
|
|
120
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { camelCase } from '../../src/custom-add-ons/add-on.js'
|
|
4
|
+
|
|
5
|
+
describe('camelCase', () => {
|
|
6
|
+
it('should convert a string to camel case', () => {
|
|
7
|
+
expect(camelCase('test-case')).toBe('TestCase')
|
|
8
|
+
expect(camelCase('demo.test-case')).toBe('DemoTestCase')
|
|
9
|
+
expect(camelCase('demo/test-case')).toBe('DemoTestCase')
|
|
10
|
+
expect(camelCase('demo/test/case')).toBe('DemoTestCase')
|
|
11
|
+
})
|
|
12
|
+
})
|