├── .gitignore ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 36氪前端 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kr-vue-startkit 2 | 36Kr鲸准前端项目脚手架,集成了Vue+Vuex+ElementUI+axios+less,并提供了简单的封装。可以快速搭建基于Vue的SPA应用。 3 | 4 | ## 使用 5 | 6 | 安装: 7 | ```sh 8 | npm install -g kr-vue-startkit 9 | ``` 10 | 11 | 构建项目: 12 | ```sh 13 | kr-vue-startkit init <项目名称> 14 | ``` 15 | 16 | 按提示输入信息: 17 | ```sh 18 | description:<项目描述> 19 | author: <作者> 20 | downloading。。。。。。 21 | npm run serve 22 | ``` 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const fs = require('fs'); 4 | const program = require('commander'); 5 | const download = require('download-git-repo'); 6 | const handlebars = require('handlebars'); 7 | const inquirer = require('inquirer'); 8 | const execa = require('execa'); 9 | const ora = require('ora'); 10 | const chalk = require('chalk'); 11 | const symbols = require('log-symbols'); 12 | const path = require('path'); 13 | program.version('1.3.0', '-v, --version') 14 | .command('init ') 15 | .action((name) => { 16 | const root = path.join(process.cwd(), name); 17 | if (!fs.existsSync(root)) { 18 | inquirer.prompt([{ 19 | name: 'description', 20 | message: 'Description:' 21 | }, 22 | { 23 | name: 'author', 24 | message: 'Author:' 25 | } 26 | ]).then((answers) => { 27 | const spinner = ora('downloading...'); 28 | const npminstall = ora('npminstalling...'); 29 | const runserve = ora('runserve...'); 30 | spinner.start(); 31 | download('36KrFE/kr-vue-base', root, (err) => { 32 | if (err) { 33 | spinner.fail(); 34 | console.log(symbols.error, chalk.red(err)); 35 | } else { 36 | spinner.succeed(); 37 | const fileName = `${root}/package.json`; 38 | const meta = { 39 | name, 40 | description: answers.description, 41 | author: answers.author 42 | } 43 | if (fs.existsSync(fileName)) { 44 | const content = fs.readFileSync(fileName).toString(); 45 | const result = handlebars.compile(content)(meta); 46 | fs.writeFileSync(fileName, result); 47 | } 48 | console.log(symbols.success, chalk.green('Created success!')); 49 | npminstall.start(); 50 | execa.shell(`cd ${root};npm i`).then(r => { 51 | npminstall.info(r.stdout); 52 | }).catch(error => { 53 | npminstall.fail(); 54 | console.log(error); 55 | }); 56 | } 57 | }) 58 | }) 59 | } else { 60 | // 错误提示项目已存在,避免覆盖原有项目 61 | console.log(symbols.error, chalk.red('Project already exists!')); 62 | } 63 | }) 64 | program.parse(process.argv); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kr-vue-startkit", 3 | "version": "1.3.1", 4 | "description": "vue构建脚手架", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "bugs": { 10 | "url": "https://github.com/36KrFE/kr-vue-startkit/issues" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/36KrFE/kr-vue-startkit.git" 15 | }, 16 | "bin": { 17 | "kr-vue-startkit": "./index.js" 18 | }, 19 | "keywords": [ 20 | "startkit", 21 | "vue", 22 | "cli", 23 | "vuex" 24 | ], 25 | "files": [ 26 | "index.js", 27 | "package.json", 28 | "LICENSE", 29 | "README.md" 30 | ], 31 | "author": "沈凤蛟 <674735426@qq.com>", 32 | "license": "MIT", 33 | "maintainers": [ 34 | { 35 | "email": "674735426@qq.com", 36 | "name": "沈凤蛟" 37 | }, 38 | { 39 | "email": "46517115@qq.com", 40 | "name": "Ryouaki" 41 | } 42 | ], 43 | "dependencies": { 44 | "chalk": "^2.4.1", 45 | "commander": "^2.15.1", 46 | "download-git-repo": "^1.0.2", 47 | "execa": "^0.10.0", 48 | "handlebars": "^4.0.11", 49 | "inquirer": "^6.0.0", 50 | "log-symbols": "^2.2.0", 51 | "ora": "^2.1.0" 52 | } 53 | } 54 | --------------------------------------------------------------------------------