From 7cf43d2cd5cb96001507ca5b67edc3e2792774b5 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 17 Sep 2021 16:08:26 +0800 Subject: [PATCH] fix: don't use template files for readme, to simplify the logic --- utils/docs/README-TEMPLATE.md | 17 --------------- utils/docs/SFC-TYPE-SUPPORT.md | 5 ----- utils/generateReadme.js | 38 ++++++++++++++++++++-------------- 3 files changed, 22 insertions(+), 38 deletions(-) delete mode 100644 utils/docs/README-TEMPLATE.md delete mode 100644 utils/docs/SFC-TYPE-SUPPORT.md diff --git a/utils/docs/README-TEMPLATE.md b/utils/docs/README-TEMPLATE.md deleted file mode 100644 index f304a7f7..00000000 --- a/utils/docs/README-TEMPLATE.md +++ /dev/null @@ -1,17 +0,0 @@ -# {{projectName}} - -This template should help get you started developing with Vue 3 in Vite. - -## Recommended IDE Setup - -[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur). - - - -## Customize configuration - -See [Vite Configuration Reference](https://vitejs.dev/config/). - -## Project Setup - - diff --git a/utils/docs/SFC-TYPE-SUPPORT.md b/utils/docs/SFC-TYPE-SUPPORT.md deleted file mode 100644 index 66a6bb8f..00000000 --- a/utils/docs/SFC-TYPE-SUPPORT.md +++ /dev/null @@ -1,5 +0,0 @@ -## Type Support for `.vue` Imports in TS - -Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. - -However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can run `Volar: Switch TS Plugin on/off` from VSCode command palette. diff --git a/utils/generateReadme.js b/utils/generateReadme.js index 337b9d0f..ad6e14ca 100644 --- a/utils/generateReadme.js +++ b/utils/generateReadme.js @@ -2,10 +2,13 @@ import fs from 'fs' import getCommand from './getCommand.js' -const sfcTypeSupportDoc = fs.readFileSync( - new URL('./docs/SFC-TYPE-SUPPORT.md', import.meta.url).pathname, - 'utf8' -) +const sfcTypeSupportDoc = + '\n' + + '## Type Support for `.vue` Imports in TS\n' + + '\n' + + "Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates.\n" + + '\n' + + 'However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can run `Volar: Switch TS Plugin on/off` from VSCode command palette.\n' export default function generateReadme({ projectName, @@ -13,18 +16,21 @@ export default function generateReadme({ needsTypeScript, needsTests }) { - let template = fs.readFileSync( - new URL('./docs/README-TEMPLATE.md', import.meta.url).pathname, - 'utf8' - ) + let readme = `# ${projectName} - template = template.replace('{{projectName}}', projectName) +This template should help get you started developing with Vue 3 in Vite. - if (needsTypeScript) { - template = template.replace('\n', sfcTypeSupportDoc) - } else { - template = template.replace('\n\n', '') - } +## Recommended IDE Setup + +[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur). +${needsTypeScript ? sfcTypeSupportDoc : ''} +## Customize configuration + +See [Vite Configuration Reference](https://vitejs.dev/config/). + +## Project Setup + +` let npmScriptsDescriptions = `\`\`\`sh ${getCommand(packageManager, 'install')} @@ -65,7 +71,7 @@ ${getCommand(packageManager, 'test:e2e')} # or \`${getCommand( ` } - template = template.replace('\n', npmScriptsDescriptions) + readme += npmScriptsDescriptions - return template + return readme } -- 2.39.5