From c0df900cd93e7b3e9279e0119ccc7d26822f9273 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 10 Aug 2021 17:07:28 +0800 Subject: [PATCH] feat!: rename `--spa` option to `--router` --- index.js | 34 ++++++++++-------- .../cypress/integration/example.spec.js | 0 template/code/router/package.json | 5 +++ template/code/{spa => router}/src/App.vue | 0 .../code/{spa => router}/src/assets/logo.png | Bin .../src/components/HelloWorld.vue | 0 .../components/__tests__/HelloWorld.spec.js | 0 template/code/{spa => router}/src/main.js | 3 -- .../code/{spa => router}/src/router/index.js | 0 .../code/{spa => router}/src/views/About.vue | 0 .../code/{spa => router}/src/views/Home.vue | 0 template/code/spa/package.json | 6 ---- template/code/spa/src/store/index.js | 8 ----- .../cypress/integration/example.spec.ts | 0 template/code/typescript-router/package.json | 5 +++ .../src/App.vue | 0 .../src/assets/logo.png | Bin .../src/components/HelloWorld.vue | 0 .../components/__tests__/HelloWorld.spec.ts | 0 .../src/main.ts | 3 -- .../src/router/index.ts | 0 .../src/views/About.vue | 0 .../src/views/Home.vue | 0 template/code/typescript-spa/package.json | 6 ---- .../code/typescript-spa/src/shims-vue.d.ts | 6 ---- .../code/typescript-spa/src/store/index.ts | 8 ----- .../code/typescript-spa/src/vite-env.d.ts | 1 - 27 files changed, 29 insertions(+), 56 deletions(-) rename template/code/{spa => router}/cypress/integration/example.spec.js (100%) create mode 100644 template/code/router/package.json rename template/code/{spa => router}/src/App.vue (100%) rename template/code/{spa => router}/src/assets/logo.png (100%) rename template/code/{spa => router}/src/components/HelloWorld.vue (100%) rename template/code/{spa => router}/src/components/__tests__/HelloWorld.spec.js (100%) rename template/code/{spa => router}/src/main.js (77%) rename template/code/{spa => router}/src/router/index.js (100%) rename template/code/{spa => router}/src/views/About.vue (100%) rename template/code/{spa => router}/src/views/Home.vue (100%) delete mode 100644 template/code/spa/package.json delete mode 100644 template/code/spa/src/store/index.js rename template/code/{typescript-spa => typescript-router}/cypress/integration/example.spec.ts (100%) create mode 100644 template/code/typescript-router/package.json rename template/code/{typescript-spa => typescript-router}/src/App.vue (100%) rename template/code/{typescript-spa => typescript-router}/src/assets/logo.png (100%) rename template/code/{typescript-spa => typescript-router}/src/components/HelloWorld.vue (100%) rename template/code/{typescript-spa => typescript-router}/src/components/__tests__/HelloWorld.spec.ts (100%) rename template/code/{typescript-spa => typescript-router}/src/main.ts (77%) rename template/code/{typescript-spa => typescript-router}/src/router/index.ts (100%) rename template/code/{typescript-spa => typescript-router}/src/views/About.vue (100%) rename template/code/{typescript-spa => typescript-router}/src/views/Home.vue (100%) delete mode 100644 template/code/typescript-spa/package.json delete mode 100644 template/code/typescript-spa/src/shims-vue.d.ts delete mode 100644 template/code/typescript-spa/src/store/index.ts delete mode 100644 template/code/typescript-spa/src/vite-env.d.ts diff --git a/index.js b/index.js index eeb01506..11dd5702 100755 --- 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/spa/cypress/integration/example.spec.js b/template/code/router/cypress/integration/example.spec.js similarity index 100% rename from template/code/spa/cypress/integration/example.spec.js rename to template/code/router/cypress/integration/example.spec.js diff --git a/template/code/router/package.json b/template/code/router/package.json new file mode 100644 index 00000000..8888f592 --- /dev/null +++ b/template/code/router/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "vue-router": "^4.0.10" + } +} diff --git a/template/code/spa/src/App.vue b/template/code/router/src/App.vue similarity index 100% rename from template/code/spa/src/App.vue rename to template/code/router/src/App.vue diff --git a/template/code/spa/src/assets/logo.png b/template/code/router/src/assets/logo.png similarity index 100% rename from template/code/spa/src/assets/logo.png rename to template/code/router/src/assets/logo.png diff --git a/template/code/spa/src/components/HelloWorld.vue b/template/code/router/src/components/HelloWorld.vue similarity index 100% rename from template/code/spa/src/components/HelloWorld.vue rename to template/code/router/src/components/HelloWorld.vue diff --git a/template/code/spa/src/components/__tests__/HelloWorld.spec.js b/template/code/router/src/components/__tests__/HelloWorld.spec.js similarity index 100% rename from template/code/spa/src/components/__tests__/HelloWorld.spec.js rename to template/code/router/src/components/__tests__/HelloWorld.spec.js diff --git a/template/code/spa/src/main.js b/template/code/router/src/main.js similarity index 77% rename from template/code/spa/src/main.js rename to template/code/router/src/main.js index ab55e6d5..c8e37b03 100644 --- a/template/code/spa/src/main.js +++ b/template/code/router/src/main.js @@ -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/src/router/index.js b/template/code/router/src/router/index.js similarity index 100% rename from template/code/spa/src/router/index.js rename to template/code/router/src/router/index.js diff --git a/template/code/spa/src/views/About.vue b/template/code/router/src/views/About.vue similarity index 100% rename from template/code/spa/src/views/About.vue rename to template/code/router/src/views/About.vue diff --git a/template/code/spa/src/views/Home.vue b/template/code/router/src/views/Home.vue similarity index 100% rename from template/code/spa/src/views/Home.vue rename to template/code/router/src/views/Home.vue diff --git a/template/code/spa/package.json b/template/code/spa/package.json deleted file mode 100644 index 364bb2bf..00000000 --- a/template/code/spa/package.json +++ /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 index 2b9da8fe..00000000 --- a/template/code/spa/src/store/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import { createStore } from 'vuex' - -export default createStore({ - state: {}, - mutations: {}, - actions: {}, - modules: {} -}) diff --git a/template/code/typescript-spa/cypress/integration/example.spec.ts b/template/code/typescript-router/cypress/integration/example.spec.ts similarity index 100% rename from template/code/typescript-spa/cypress/integration/example.spec.ts rename to template/code/typescript-router/cypress/integration/example.spec.ts diff --git a/template/code/typescript-router/package.json b/template/code/typescript-router/package.json new file mode 100644 index 00000000..8888f592 --- /dev/null +++ b/template/code/typescript-router/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "vue-router": "^4.0.10" + } +} diff --git a/template/code/typescript-spa/src/App.vue b/template/code/typescript-router/src/App.vue similarity index 100% rename from template/code/typescript-spa/src/App.vue rename to template/code/typescript-router/src/App.vue diff --git a/template/code/typescript-spa/src/assets/logo.png b/template/code/typescript-router/src/assets/logo.png similarity index 100% rename from template/code/typescript-spa/src/assets/logo.png rename to template/code/typescript-router/src/assets/logo.png diff --git a/template/code/typescript-spa/src/components/HelloWorld.vue b/template/code/typescript-router/src/components/HelloWorld.vue similarity index 100% rename from template/code/typescript-spa/src/components/HelloWorld.vue rename to template/code/typescript-router/src/components/HelloWorld.vue diff --git a/template/code/typescript-spa/src/components/__tests__/HelloWorld.spec.ts b/template/code/typescript-router/src/components/__tests__/HelloWorld.spec.ts similarity index 100% rename from template/code/typescript-spa/src/components/__tests__/HelloWorld.spec.ts rename to template/code/typescript-router/src/components/__tests__/HelloWorld.spec.ts diff --git a/template/code/typescript-spa/src/main.ts b/template/code/typescript-router/src/main.ts similarity index 77% rename from template/code/typescript-spa/src/main.ts rename to template/code/typescript-router/src/main.ts index ab55e6d5..c8e37b03 100644 --- a/template/code/typescript-spa/src/main.ts +++ b/template/code/typescript-router/src/main.ts @@ -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/src/router/index.ts b/template/code/typescript-router/src/router/index.ts similarity index 100% rename from template/code/typescript-spa/src/router/index.ts rename to template/code/typescript-router/src/router/index.ts diff --git a/template/code/typescript-spa/src/views/About.vue b/template/code/typescript-router/src/views/About.vue similarity index 100% rename from template/code/typescript-spa/src/views/About.vue rename to template/code/typescript-router/src/views/About.vue diff --git a/template/code/typescript-spa/src/views/Home.vue b/template/code/typescript-router/src/views/Home.vue similarity index 100% rename from template/code/typescript-spa/src/views/Home.vue rename to template/code/typescript-router/src/views/Home.vue diff --git a/template/code/typescript-spa/package.json b/template/code/typescript-spa/package.json deleted file mode 100644 index 364bb2bf..00000000 --- a/template/code/typescript-spa/package.json +++ /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 index ec4f1b2e..00000000 --- a/template/code/typescript-spa/src/shims-vue.d.ts +++ /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 index 2b9da8fe..00000000 --- a/template/code/typescript-spa/src/store/index.ts +++ /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 index 11f02fe2..00000000 --- a/template/code/typescript-spa/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// -- 2.39.5