]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
fix: don't use template files for readme, to simplify the logic
authorHaoqun Jiang <haoqunjiang@gmail.com>
Fri, 17 Sep 2021 08:08:26 +0000 (16:08 +0800)
committerHaoqun Jiang <haoqunjiang@gmail.com>
Fri, 17 Sep 2021 08:08:26 +0000 (16:08 +0800)
utils/docs/README-TEMPLATE.md [deleted file]
utils/docs/SFC-TYPE-SUPPORT.md [deleted file]
utils/generateReadme.js

diff --git a/utils/docs/README-TEMPLATE.md b/utils/docs/README-TEMPLATE.md
deleted file mode 100644 (file)
index f304a7f..0000000
+++ /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).
-
-<!-- SFC-TYPE-SUPPORT -->
-
-## Customize configuration
-
-See [Vite Configuration Reference](https://vitejs.dev/config/).
-
-## Project Setup
-
-<!-- NPM-SCRIPTS -->
diff --git a/utils/docs/SFC-TYPE-SUPPORT.md b/utils/docs/SFC-TYPE-SUPPORT.md
deleted file mode 100644 (file)
index 66a6bb8..0000000
+++ /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.
index 337b9d0f48d561a3d7e65eacac6203eaa7b22cd7..ad6e14ca2ff426b35c4f730277bfbe1f5a4d9e9b 100644 (file)
@@ -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('<!-- SFC-TYPE-SUPPORT -->\n', sfcTypeSupportDoc)
-  } else {
-    template = template.replace('<!-- SFC-TYPE-SUPPORT -->\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('<!-- NPM-SCRIPTS -->\n', npmScriptsDescriptions)
+  readme += npmScriptsDescriptions
 
-  return template
+  return readme
 }