diff --git a/README.md b/README.md index e3d14ed..0d97bfa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ I highly recommend you to try [Poi](https://github.com/egoist/poi), you can develop Vue.js app with no-config until you need it. Less boilerplate code, more happiness ❤️ - Here's the plan for [VuePack 4.0](https://github.com/egoist/vuepack/issues/136), you can support my work by [donating](https://github.com/egoist/donate) or joining the development. ## Features @@ -15,13 +14,13 @@ Here's the plan for [VuePack 4.0](https://github.com/egoist/vuepack/issues/136), - Vue 2 / Vue-router / Vuex - Hot reloading for single-file components - Split vendor code from your app -- Webpack 2 +- Webpack 2 (an update to Webpack 4 will be very soon) - [Offline Ready, perfect for progressive web app](/docs/pwa.md) - [ESLint](/docs/eslint.md) - [Babel 6](/docs/babel.md) - [PostCSS](/docs/postcss.md) - [JSX components are supported by default](/docs/jsx.md) -- [TestCafe](/docs/testcafe.md) +- [TestCafe](/docs/testcafe.md) (optional) - [Electron support](/docs/electron.md) (optional) - [CSS modules](/docs/css-modules.md) (optional) - A boilerplate which is small and focusing on client-side apps @@ -32,35 +31,26 @@ Check out [the docs](https://github.com/egoist/vuepack/tree/master/docs) for mor ## Get Started -You'd better have `node >=4` and `npm >=3` installed: +You'd better have `node >=10` and `npm >=6` installed: ## sao -This template can be used with [sao](https://github.com/egoist/sao), which also means you can use the template offline: +This template can be used with [SAO](https://github.com/egoist/sao), which also means you can use the template offline: ```bash -yarn global add sao +npm i -g sao jstransformer-handlebars # from npm sao vuepack new-project # or git repo sao egoist/vuepack new-project ``` -## vue-cli +## Vue CLI +Vue CLI (`vue-cli@2` or `@vue/cli@>=3` + `@vue/cli-init`) is still supported, but it has been deprecated by Vue officially, so it is not recommended to use Vue CLI with Vuepack. ```bash -$ npm install -g vue-cli -$ vue init egoist/vuepack new-project -$ cd new-project -$ npm install - -# edit files and start developing -$ npm run dev -# bundle all scripts and styles for production use -$ npm run build - -# lint your code -$ npm run lint +npm i -g @vue/cli @vue/cli-init +vue init egoist/vuepack ``` ### For Windows users diff --git a/package.json b/package.json index b4895b0..e4cb149 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,24 @@ { - "name": "template-vuepack", + "name": "sao-vuepack", "scripts": { "test": "echo lol" }, - "dependencies": {}, - "version": "3.3.1", + "dependencies": { + "jstransformer-handlebars": "^1.1.0" + }, + "version": "4.0.0-pre1", "repository": { - "url": "git@github.com:egoist/vuepack.git", + "url": "git+https://github.com/egoist/vuepack.git", "type": "git" }, "author": "EGOIST <0x142857@gmail.com>", - "license": "MIT" + "license": "MIT", + "description": "VuePack is a modern Vue.js starter", + "bugs": { + "url": "https://github.com/egoist/vuepack/issues" + }, + "homepage": "https://github.com/egoist/vuepack#readme", + "publishConfig": { + "registry": "https://registry.npmjs.com" + } } diff --git a/sao.js b/sao.js deleted file mode 100644 index 98da71c..0000000 --- a/sao.js +++ /dev/null @@ -1,60 +0,0 @@ -module.exports = { - template: 'handlebars', - prompts: { - name: { - required: true, - message: 'Project name', - role: 'folder:name' - }, - description: { - required: false, - message: 'Project description', - default: 'My Superb Vue Project' - }, - author: { - message: 'Author', - role: 'git:name' - }, - eslint: { - type: 'confirm', - message: 'Do you want to support ESLint?' - }, - jsx: { - type: 'confirm', - message: 'Generate components in JSX format?', - default: false - }, - electron: { - type: 'confirm', - message: 'Support Electron?', - default: false - }, - "testcafe": { - "type": "confirm", - "message": "Add testcafe to run integration tests?", - "default": false - } - }, - filters: { - 'client/components/*.vue': '!jsx', - 'client/components/**/*.{js,css}': 'jsx', - 'client/views/*.vue': '!jsx', - 'client/views/**/*.{js,css}': 'jsx', - 'app/*': 'electron', - '.eslintrc': 'eslint', - "test/e2e/*": "testcafe" - }, - post({ log, gitInit, npmInstall, chalk, isNewFolder, folderName }) { - gitInit() - npmInstall() - - log.success(`Your new Vue project has been successfully generated in ${chalk.underline(folderName)}!`) - console.log() - console.log(chalk.bold(` To get started:\n`)) - if (isNewFolder) console.log(` cd ${folderName}`) - console.log(` yarn`) - console.log(` yarn dev\n`) - console.log(chalk.bold(` To build for production:\n`)) - console.log(` yarn build\n`) - } -} diff --git a/saofile.js b/saofile.js new file mode 100644 index 0000000..dc59456 --- /dev/null +++ b/saofile.js @@ -0,0 +1,80 @@ +module.exports = { + transformer: 'handlebars', + prompts() { + return [ + { + name: 'name', + required: true, + message: 'Project name', + default: this.outFolder + }, + { + name: 'description', + required: false, + message: 'Project description', + default: 'My Superb Vue Project' + }, + { + name: 'author', + message: 'Author', + default: this.gitUser.name + }, + { + name: 'eslint', + type: 'confirm', + message: 'Do you want to support ESLint?' + }, + { + name: 'jsx', + type: 'confirm', + message: 'Generate components in JSX format?', + default: false + }, + { + name: 'electron', + type: 'confirm', + message: 'Support Electron?', + default: false + }, + { + name: 'testcafe', + type: 'confirm', + message: 'Add testcafe to run integration tests?', + default: false + } + ] + }, + actions() { + return [ + { + type: 'add', + files: '**', + filters: { + 'client/components/*.vue': '!jsx', + 'client/components/**/*.{js,css}': 'jsx', + 'client/views/*.vue': '!jsx', + 'client/views/**/*.{js,css}': 'jsx', + 'app/*': 'electron', + '.eslintrc': 'eslint', + 'test/e2e/*': 'testcafe' + }, + transformExclude: 'build/index.html' + } + ] + }, + async completed() { + const { logger, gitInit, npmInstall, chalk, outFolder } = this + + gitInit.call(this) + await npmInstall.call(this) + + logger.success(`Your new Vue project has been successfully generated in ${chalk.underline(outFolder)}!`) + console.log() + console.log(chalk.bold(` To get started:\n`)) + console.log(` cd ${outFolder}`) + console.log(` yarn`) + console.log(` yarn dev\n`) + console.log(chalk.bold(` To build for production:\n`)) + console.log(` yarn build\n`) + } +} diff --git a/template/.eslintrc b/template/.eslintrc index 80680b9..3839278 100644 --- a/template/.eslintrc +++ b/template/.eslintrc @@ -1,6 +1,6 @@ { - "extends": "vue",{{#testcafe}} - "plugins": ["testcafe"],{{/testcafe}} + "extends": "vue",{{#if testcafe}} + "plugins": ["testcafe"],{{/if}} "rules": { "import/no-unresolved": 0, "import/no-unassigned-import": 0 diff --git a/template/.gitignore b/template/.gitignore index 7d09e99..032cfa2 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -1,10 +1,10 @@ node_modules *.log .DS_Store -{{#electron}} +{{#if electron}} /app/index.html /app/assets -{{/electron}} +{{/if}} {{#unless electron}} /dist {{/unless}} diff --git a/template/README.md b/template/README.md index 3501091..bff4896 100644 --- a/template/README.md +++ b/template/README.md @@ -1,4 +1,4 @@ -# {{ name }} +# {{name}} To start: diff --git a/template/build/config.js b/template/build/config.js index c1496f7..d5e4a9a 100644 --- a/template/build/config.js +++ b/template/build/config.js @@ -1,5 +1,4 @@ 'use strict' -const pkg = require('../package') module.exports = { title: '{{name}}', diff --git a/template/client/components/App/style.css b/template/client/components/App/style.css index 1729f57..673457e 100644 --- a/template/client/components/App/style.css +++ b/template/client/components/App/style.css @@ -2,12 +2,7 @@ body { margin: 0; font-size: 2rem; - font-family: -apple-system, BlinkMacSystemFont, - 'avenir next', avenir, - helvetica, 'helvetica neue', - Ubuntu, - 'segoe ui', arial, - sans-serif; + font-family: -apple-system, BlinkMacSystemFont, 'avenir next', avenir, helvetica, 'helvetica neue',Ubuntu, 'segoe ui', arial, sans-serif; } .page { text-align: center; @@ -17,4 +12,4 @@ padding: 3px 5px; border-radius: 2px; } -} \ No newline at end of file +} diff --git a/template/package.json b/template/package.json index b1b9480..d27aa71 100644 --- a/template/package.json +++ b/template/package.json @@ -1,17 +1,17 @@ { - "name": "{{ name }}", + "name": "{{name}}", "version": "0.1.0", - "description": "{{ description }}", + "description": "<%= description %>", "main": "client/index.js", "scripts": { - "test": "{{#testcafe}}testcafe all test/e2e/index.js --app \"npm run dev\" --app-init-delay 10000{{/testcafe}}", + {{#if testcafe}}"test": "testcafe all test/e2e/index.js --app \"npm run dev\" --app-init-delay 10000",{{/if}} "build": "webpack --config build/webpack.prod.js", - "dev": "node build/server.js"{{#electron}}, - "app": "cross-env NODE_ENV=development electron app/"{{/electron}}{{#eslint}}, - "lint": "xo **/client/**/*.{vue,js}{{#electron}} **/app/**/*.js{{/electron}} !node_modules/**" - {{/eslint}} + "dev": "node build/server.js"{{#if electron}}, + "app": "cross-env NODE_ENV=development electron app/"{{/if}}{{#if eslint}}, + "lint": "xo **/client/**/*.{vue,js}{{#if electron}} **/app/**/*.js{{/if}} !node_modules/**" + {{/if}} }, - "author": "{{ author }}", + "author": "{{author}}", "license": "MIT", "xo": { "extends": "./.eslintrc", @@ -51,18 +51,18 @@ "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.23.1", "cross-env": "^2.0.0", - {{#electron}} + {{#if electron}} "electron-devtools-installer": "^2.0.1", "electron": "^1.4.2", - {{/electron}} - {{#eslint}} + {{/if}} + {{#if eslint}} "xo": "^0.18.0", "eslint-config-vue": "latest", "eslint-plugin-vue": "latest", - {{#testcafe}} + {{#if testcafe}} "eslint-plugin-testcafe": "^0.2.0", - {{/testcafe}} - {{/eslint}} + {{/if}} + {{/if}} "express": "^4.14.0", "extract-text-webpack-plugin": "^2.0.0-rc.3", "file-loader": "^0.9.0", @@ -74,9 +74,9 @@ "postcss-nested": "^1.0.0", "rimraf": "^2.6.1", "style-loader": "^0.13.1", - {{#testcafe}} + {{#if testcafe}} "testcafe": "^0.12.1", - {{/testcafe}} + {{/if}} "vue-loader": "^11.0.0", "vue-template-compiler": "^2.2.0", "webpack": "2.2.0", diff --git a/yarn.lock b/yarn.lock index fb57ccd..9ee6c98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,3 +2,61 @@ # yarn lockfile v1 +commander@~2.20.3: + version "2.20.3" + resolved "https://registry.npm.taobao.org/commander/download/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha1-/UhehMA+tIgcIHIrpIA16FMa6zM= + +handlebars@^4.0.1: + version "4.7.3" + resolved "https://registry.npm.taobao.org/handlebars/download/handlebars-4.7.3.tgz?cache=0&sync_timestamp=1580879621042&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhandlebars%2Fdownload%2Fhandlebars-4.7.3.tgz#8ece2797826886cf8082d1726ff21d2a022550ee" + integrity sha1-js4nl4Johs+AgtFyb/IdKgIlUO4= + dependencies: + neo-async "^2.6.0" + optimist "^0.6.1" + source-map "^0.6.1" + optionalDependencies: + uglify-js "^3.1.4" + +jstransformer-handlebars@^1.1.0: + version "1.1.0" + resolved "https://registry.npm.taobao.org/jstransformer-handlebars/download/jstransformer-handlebars-1.1.0.tgz#91ba56e0a28aee31bb56d4adbcbce508d8230468" + integrity sha1-kbpW4KKK7jG7VtStvLzlCNgjBGg= + dependencies: + handlebars "^4.0.1" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.npm.taobao.org/minimist/download/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= + +neo-async@^2.6.0: + version "2.6.1" + resolved "https://registry.npm.taobao.org/neo-async/download/neo-async-2.6.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fneo-async%2Fdownload%2Fneo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" + integrity sha1-rCetpmFn+ohJpq3dg39rGJrSCBw= + +optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.npm.taobao.org/optimist/download/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + integrity sha1-2j6nRob6IaGaERwybpDrFaAZZoY= + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha1-dHIq8y6WFOnCh6jQu95IteLxomM= + +uglify-js@^3.1.4: + version "3.7.7" + resolved "https://registry.npm.taobao.org/uglify-js/download/uglify-js-3.7.7.tgz?cache=0&sync_timestamp=1580771468559&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuglify-js%2Fdownload%2Fuglify-js-3.7.7.tgz#21e52c7dccda80a53bf7cde69628a7e511aec9c9" + integrity sha1-IeUsfczagKU7983mliin5RGuyck= + dependencies: + commander "~2.20.3" + source-map "~0.6.1" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.npm.taobao.org/wordwrap/download/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc=