import getCommand from './getCommand' const sfcTypeSupportDoc = [ '', '## Type Support for `.vue` Imports in TS', '', 'TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.', '', ].join('\n') export default function generateReadme({ projectName, packageManager, needsTypeScript, needsCypress, needsNightwatch, needsCypressCT, needsNightwatchCT, needsPlaywright, needsVitest, needsEslint, }) { const commandFor = (scriptName: string, args?: string) => getCommand(packageManager, scriptName, args) let readme = `# ${projectName} This template should help get you started developing with Vue 3 in Vite. ## Recommended IDE Setup [VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur). ## Recommended Browser Setup - Chromium-based browsers (Chrome, Edge, Brave, etc.): - [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd) - [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters) - Firefox: - [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/) - [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/) ${needsTypeScript ? sfcTypeSupportDoc : ''} ## Customize configuration See [Vite Configuration Reference](https://vite.dev/config/). ## Project Setup ` let installCommand = commandFor('install') if (packageManager === 'pnpm' && needsNightwatch) { // TODO: remove the "for pnpm 10+" note when pnpm 10 is widely adopted installCommand += `\npnpm approve-builds # for pnpm 10+` } let npmScriptsDescriptions = `\`\`\`sh ${installCommand} \`\`\` ### Compile and Hot-Reload for Development \`\`\`sh ${commandFor('dev')} \`\`\` ### ${needsTypeScript ? 'Type-Check, ' : ''}Compile and Minify for Production \`\`\`sh ${commandFor('build')} \`\`\` ` if (needsVitest) { npmScriptsDescriptions += ` ### Run Unit Tests with [Vitest](https://vitest.dev/) \`\`\`sh ${commandFor('test:unit')} \`\`\` ` } if (needsCypressCT) { npmScriptsDescriptions += ` ### Run Headed Component Tests with [Cypress Component Testing](https://on.cypress.io/component) \`\`\`sh ${commandFor('test:unit:dev')} # or \`${commandFor('test:unit')}\` for headless testing \`\`\` ` } if (needsCypress) { npmScriptsDescriptions += ` ### Run End-to-End Tests with [Cypress](https://www.cypress.io/) \`\`\`sh ${commandFor('test:e2e:dev')} \`\`\` This runs the end-to-end tests against the Vite development server. It is much faster than the production build. But it's still recommended to test the production build with \`test:e2e\` before deploying (e.g. in CI environments): \`\`\`sh ${commandFor('build')} ${commandFor('test:e2e')} \`\`\` ` } if (needsNightwatch) { npmScriptsDescriptions += ` ### Run End-to-End Tests with [Nightwatch](https://nightwatchjs.org/) \`\`\`sh # When using CI, the project must be built first. ${commandFor('build')} # Runs the end-to-end tests ${commandFor('test:e2e')} # Runs the tests only on Chrome ${commandFor('test:e2e', '--env chrome')} # Runs the tests of a specific file ${commandFor('test:e2e', `tests/e2e/example.${needsTypeScript ? 'ts' : 'js'}`)} # Runs the tests in debug mode ${commandFor('test:e2e', '--debug')} \`\`\` ` } if (needsNightwatchCT) { npmScriptsDescriptions += ` ### Run Headed Component Tests with [Nightwatch Component Testing](https://nightwatchjs.org/guide/component-testing/introduction.html) \`\`\`sh ${commandFor('test:unit')} ${commandFor('test:unit -- --headless # for headless testing')} \`\`\` ` } if (needsPlaywright) { npmScriptsDescriptions += ` ### Run End-to-End Tests with [Playwright](https://playwright.dev) \`\`\`sh # Install browsers for the first run npx playwright install # When testing on CI, must build the project first ${commandFor('build')} # Runs the end-to-end tests ${commandFor('test:e2e')} # Runs the tests only on Chromium ${commandFor('test:e2e', '--project=chromium')} # Runs the tests of a specific file ${commandFor('test:e2e', 'tests/example.spec.ts')} # Runs the tests in debug mode ${commandFor('test:e2e', '--debug')} \`\`\` ` } if (needsEslint) { npmScriptsDescriptions += ` ### Lint with [ESLint](https://eslint.org/) \`\`\`sh ${commandFor('lint')} \`\`\` ` } readme += npmScriptsDescriptions return readme }