From 43262a41fdeefc58456878086ec067057f785c0b Mon Sep 17 00:00:00 2001 From: Alex Scott Date: Sat, 6 Jan 2018 19:25:47 +0000 Subject: [PATCH 1/3] Issue #1226: Add easy-deploy option when installing the template using Vue CLI --- meta.js | 16 +++++++++++++++- template/config/index.js | 5 ++++- template/package.json | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/meta.js b/meta.js index 0dc63e651b..5cc3dd3285 100644 --- a/meta.js +++ b/meta.js @@ -23,7 +23,6 @@ module.exports = { return templateVersion }, }, - prompts: { name: { type: 'string', @@ -61,6 +60,21 @@ module.exports = { type: 'confirm', message: 'Install vue-router?', }, + deploy: { + type: 'confirm', + message: 'Setup a deploy command for GitHub pages?', + }, + branch: { + when: 'deploy', + default: 'gh-pages', + type: 'string', + message: 'What branch should the built site be deployed to?', + }, + baseUrl: { + when: 'deploy', + type: 'string', + message: 'What is the GitHub project? (Leave blank for User & Organization pages)', + }, lint: { type: 'confirm', message: 'Use ESLint to lint your code?', diff --git a/template/config/index.js b/template/config/index.js index d1ec13d12a..9493f9cb16 100644 --- a/template/config/index.js +++ b/template/config/index.js @@ -51,8 +51,11 @@ module.exports = { // Paths assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', + {{#deploy}} + assetsPublicPath: '/{{ baseUrl }}/', + {{else}} assetsPublicPath: '/', - + {{/deploy}} /** * Source Maps */ diff --git a/template/package.json b/template/package.json index db5f9564d2..3b48547d13 100644 --- a/template/package.json +++ b/template/package.json @@ -22,6 +22,9 @@ {{#lint}} "lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}", {{/lint}} + {{#deploy}} + "deploy": "npm run build;push-dir --dir=dist --branch={{ branch }} --cleanup", + {{/deploy}} "build": "node build/build.js" }, "dependencies": { @@ -103,6 +106,9 @@ "postcss-import": "^11.0.0", "postcss-loader": "^2.0.8", "postcss-url": "^7.2.1", + {{#deploy}} + "push-dir": "^0.4.1", + {{/deploy}} "semver": "^5.3.0", "shelljs": "^0.7.6", "optimize-css-assets-webpack-plugin": "^3.2.0", From 643697645a18c825107aa28879d6322377bd4061 Mon Sep 17 00:00:00 2001 From: Alex Scott Date: Sun, 7 Jan 2018 15:06:26 +0000 Subject: [PATCH 2/3] Issue #1226: Add easy-deploy option when installing the template using Vue CLI * Add `deployBuild` prompt in `meta.js` * Add `if` conditional around `npm run build;` in templates `package.json` --- meta.js | 4 ++++ template/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/meta.js b/meta.js index 5cc3dd3285..81aaabd9c8 100644 --- a/meta.js +++ b/meta.js @@ -64,6 +64,10 @@ module.exports = { type: 'confirm', message: 'Setup a deploy command for GitHub pages?', }, + deployBuild: { + type: 'confirm', + message: 'Build project when deploying?', + }, branch: { when: 'deploy', default: 'gh-pages', diff --git a/template/package.json b/template/package.json index 3b48547d13..4f5900a3bd 100644 --- a/template/package.json +++ b/template/package.json @@ -23,7 +23,7 @@ "lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}", {{/lint}} {{#deploy}} - "deploy": "npm run build;push-dir --dir=dist --branch={{ branch }} --cleanup", + "deploy": "{{#deployBuild}}npm run build;{{/deployBuild}}push-dir --dir=dist --branch={{ branch }} --cleanup", {{/deploy}} "build": "node build/build.js" }, From 040cee856ee77b38e058508502510b037eb6d20d Mon Sep 17 00:00:00 2001 From: Alex Scott Date: Sun, 7 Jan 2018 15:38:01 +0000 Subject: [PATCH 3/3] Issue #1226: Add easy-deploy option when installing the template using Vue CLI * Add 'when' conditional to `deployBuild` prompt in `meta.js` --- meta.js | 1 + 1 file changed, 1 insertion(+) diff --git a/meta.js b/meta.js index 81aaabd9c8..13bd7bd54e 100644 --- a/meta.js +++ b/meta.js @@ -65,6 +65,7 @@ module.exports = { message: 'Setup a deploy command for GitHub pages?', }, deployBuild: { + when: 'deploy', type: 'confirm', message: 'Build project when deploying?', },