]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
feat!: rename `--spa` option to `--router`
authorHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 10 Aug 2021 09:07:28 +0000 (17:07 +0800)
committerHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 10 Aug 2021 09:07:28 +0000 (17:07 +0800)
27 files changed:
index.js
template/code/router/cypress/integration/example.spec.js [moved from template/code/spa/cypress/integration/example.spec.js with 100% similarity]
template/code/router/package.json [new file with mode: 0644]
template/code/router/src/App.vue [moved from template/code/spa/src/App.vue with 100% similarity]
template/code/router/src/assets/logo.png [moved from template/code/spa/src/assets/logo.png with 100% similarity]
template/code/router/src/components/HelloWorld.vue [moved from template/code/spa/src/components/HelloWorld.vue with 100% similarity]
template/code/router/src/components/__tests__/HelloWorld.spec.js [moved from template/code/spa/src/components/__tests__/HelloWorld.spec.js with 100% similarity]
template/code/router/src/main.js [moved from template/code/spa/src/main.js with 77% similarity]
template/code/router/src/router/index.js [moved from template/code/spa/src/router/index.js with 100% similarity]
template/code/router/src/views/About.vue [moved from template/code/spa/src/views/About.vue with 100% similarity]
template/code/router/src/views/Home.vue [moved from template/code/spa/src/views/Home.vue with 100% similarity]
template/code/spa/package.json [deleted file]
template/code/spa/src/store/index.js [deleted file]
template/code/typescript-router/cypress/integration/example.spec.ts [moved from template/code/typescript-spa/cypress/integration/example.spec.ts with 100% similarity]
template/code/typescript-router/package.json [new file with mode: 0644]
template/code/typescript-router/src/App.vue [moved from template/code/typescript-spa/src/App.vue with 100% similarity]
template/code/typescript-router/src/assets/logo.png [moved from template/code/typescript-spa/src/assets/logo.png with 100% similarity]
template/code/typescript-router/src/components/HelloWorld.vue [moved from template/code/typescript-spa/src/components/HelloWorld.vue with 100% similarity]
template/code/typescript-router/src/components/__tests__/HelloWorld.spec.ts [moved from template/code/typescript-spa/src/components/__tests__/HelloWorld.spec.ts with 100% similarity]
template/code/typescript-router/src/main.ts [moved from template/code/typescript-spa/src/main.ts with 77% similarity]
template/code/typescript-router/src/router/index.ts [moved from template/code/typescript-spa/src/router/index.ts with 100% similarity]
template/code/typescript-router/src/views/About.vue [moved from template/code/typescript-spa/src/views/About.vue with 100% similarity]
template/code/typescript-router/src/views/Home.vue [moved from template/code/typescript-spa/src/views/Home.vue with 100% similarity]
template/code/typescript-spa/package.json [deleted file]
template/code/typescript-spa/src/shims-vue.d.ts [deleted file]
template/code/typescript-spa/src/store/index.ts [deleted file]
template/code/typescript-spa/src/vite-env.d.ts [deleted file]

index eeb015065c963c503a857aa741d2144c52bce693..11dd5702d66dc38044a2cd659aacd45d6dd50e1e 100755 (executable)
--- a/index.js
+++ b/index.js
@@ -45,14 +45,16 @@ function emptyDir(dir) {
 async function init() {
   const cwd = process.cwd()
   // possible options:
-  // --jsx
-  // --spa (todo: split into vuex & vue-router)
   // --typescript / --ts
+  // --jsx
+  // --router / --vue-router
+  // --vuex (todo)
   // --with-tests / --tests / --cypress
   const argv = minimist(process.argv.slice(2), {
     alias: {
       'typescript': ['ts'],
-      'with-tests': ['tests', 'cypress']
+      'with-tests': ['tests', 'cypress'],
+      'router': ['vue-router']
     },
     // all arguments are treated as booleans
     boolean: true
@@ -69,7 +71,9 @@ async function init() {
     //   - whether to overwrite the existing directory or not?
     //   - enter a valid package name for package.json
     // - Project language: JavaScript / TypeScript
-    // - Install Vue Router & Vuex for SPA development?
+    // - Add JSX Support?
+    // - Install Vue Router for SPA development?
+    // - Install Vuex for state management? (TODO)
     // - Add Cypress for testing?
     result = await prompts(
       [
@@ -111,26 +115,26 @@ async function init() {
             isValidPackageName(dir) || 'Invalid package.json name'
         },
         {
-          name: 'needsJSX',
-          type: () => (argv.jsx ? null : 'toggle'),
-          message: 'Add JSX Support?',
+          name: 'needsTypeScript',
+          type: () => (argv.typescript ? null : 'toggle'),
+          message: 'Add TypeScript?',
           initial: false,
           active: 'Yes',
           inactive: 'No'
         },
         {
-          name: 'needsTypeScript',
-          type: () => (argv.typescript ? null : 'toggle'),
-          message: 'Add TypeScript?',
+          name: 'needsJSX',
+          type: () => (argv.jsx ? null : 'toggle'),
+          message: 'Add JSX Support?',
           initial: false,
           active: 'Yes',
           inactive: 'No'
         },
         {
-          name: 'isSPA',
-          type: () => (argv.spa ? null : 'toggle'),
+          name: 'needsRouter',
+          type: () => (argv.router ? null : 'toggle'),
           message:
-            'Add Vue Router & Vuex for Single Page Application development?',
+            'Add Vue Router for Single Page Application development?',
           initial: false,
           active: 'Yes',
           inactive: 'No'
@@ -162,7 +166,7 @@ async function init() {
     shouldOverwrite,
     needsJSX = argv.jsx,
     needsTypeScript = argv.typescript,
-    isSPA = argv.spa,
+    needsRouter = argv.router,
     needsTests = argv.tests
   } = result
   const root = path.join(cwd, targetDir)
@@ -220,7 +224,7 @@ async function init() {
   // prettier-ignore
   const codeTemplate =
     (needsTypeScript ? 'typescript-' : '') +
-    (isSPA ? 'spa' : 'default')
+    (needsRouter ? 'router' : 'default')
   render(`code/${codeTemplate}`)
 
   // TODO:
diff --git a/template/code/router/package.json b/template/code/router/package.json
new file mode 100644 (file)
index 0000000..8888f59
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "dependencies": {
+    "vue-router": "^4.0.10"
+  }
+}
similarity index 77%
rename from template/code/spa/src/main.js
rename to template/code/router/src/main.js
index ab55e6d5fd2ac2e46c22dc557dc27791f66f825a..c8e37b03b9c2289ea08f80feeca1880e2abc3a86 100644 (file)
@@ -1,12 +1,9 @@
 import { createApp } from 'vue'
 import App from './App.vue'
-
 import router from './router'
-import store from './store'
 
 const app = createApp(App)
 
 app.use(router)
-app.use(store)
 
 app.mount('#app')
diff --git a/template/code/spa/package.json b/template/code/spa/package.json
deleted file mode 100644 (file)
index 364bb2b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-  "dependencies": {
-    "vue-router": "^4.0.10",
-    "vuex": "^4.0.2"
-  }
-}
diff --git a/template/code/spa/src/store/index.js b/template/code/spa/src/store/index.js
deleted file mode 100644 (file)
index 2b9da8f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStore } from 'vuex'
-
-export default createStore({
-  state: {},
-  mutations: {},
-  actions: {},
-  modules: {}
-})
diff --git a/template/code/typescript-router/package.json b/template/code/typescript-router/package.json
new file mode 100644 (file)
index 0000000..8888f59
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "dependencies": {
+    "vue-router": "^4.0.10"
+  }
+}
similarity index 77%
rename from template/code/typescript-spa/src/main.ts
rename to template/code/typescript-router/src/main.ts
index ab55e6d5fd2ac2e46c22dc557dc27791f66f825a..c8e37b03b9c2289ea08f80feeca1880e2abc3a86 100644 (file)
@@ -1,12 +1,9 @@
 import { createApp } from 'vue'
 import App from './App.vue'
-
 import router from './router'
-import store from './store'
 
 const app = createApp(App)
 
 app.use(router)
-app.use(store)
 
 app.mount('#app')
diff --git a/template/code/typescript-spa/package.json b/template/code/typescript-spa/package.json
deleted file mode 100644 (file)
index 364bb2b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-  "dependencies": {
-    "vue-router": "^4.0.10",
-    "vuex": "^4.0.2"
-  }
-}
diff --git a/template/code/typescript-spa/src/shims-vue.d.ts b/template/code/typescript-spa/src/shims-vue.d.ts
deleted file mode 100644 (file)
index ec4f1b2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.vue' {
-  import { DefineComponent } from 'vue'
-  // eslint-disable-next-line
-  const component: DefineComponent<{}, {}, any>
-  export default component
-}
diff --git a/template/code/typescript-spa/src/store/index.ts b/template/code/typescript-spa/src/store/index.ts
deleted file mode 100644 (file)
index 2b9da8f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStore } from 'vuex'
-
-export default createStore({
-  state: {},
-  mutations: {},
-  actions: {},
-  modules: {}
-})
diff --git a/template/code/typescript-spa/src/vite-env.d.ts b/template/code/typescript-spa/src/vite-env.d.ts
deleted file mode 100644 (file)
index 11f02fe..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/// <reference types="vite/client" />