generateReadme.js 917 B

12345678910111213141516171819202122232425262728293031323334
  1. const descriptions = {
  2. build: 'Compiles and minifies for production',
  3. serve: 'Compiles and hot-reloads for development',
  4. lint: 'Lints and fixes files',
  5. 'test:e2e': 'Run your end-to-end tests',
  6. 'test:unit': 'Run your unit tests'
  7. }
  8. function printScripts (pkg, packageManager) {
  9. return Object.keys(pkg.scripts || {}).map(key => {
  10. if (!descriptions[key]) return ''
  11. return [
  12. `\n### ${descriptions[key]}`,
  13. '```',
  14. `${packageManager} ${packageManager !== 'yarn' ? 'run ' : ''}${key}`,
  15. '```',
  16. ''
  17. ].join('\n')
  18. }).join('')
  19. }
  20. module.exports = function generateReadme (pkg, packageManager) {
  21. return [
  22. `# ${pkg.name}\n`,
  23. '## Project setup',
  24. '```',
  25. `${packageManager} install`,
  26. '```',
  27. printScripts(pkg, packageManager),
  28. '### Customize configuration',
  29. 'See [Configuration Reference](https://cli.vuejs.org/config/).',
  30. ''
  31. ].join('\n')
  32. }