关于类似vue-cli 脚手架
 #!/usr/bin/env node
 const download = require('download-git-repo')
 const program = require('commander')
 const exists = require('fs').existsSync
 const path = require('path')
 const ora = require('ora')
 const home = require('user-home')
 const tildify = require('tildify')
 const chalk = require('chalk')
 const inquirer = require('inquirer')
 const rm = require('rimraf').sync
 const logger = require('../lib/logger')
 const generate = require('../lib/generate')
 const checkVersion = require('../lib/check-version')
 const warnings = require('../lib/warnings')
 const localPath = require('../lib/local-path')
 const isLocalPath = localPath.isLocalPath
 const getTemplatePath = localPath.getTemplatePath
 /**
  * Usage.
  */
 program
   .usage('<template-name> [project-name]')
   .option('-c, --clone', 'use git clone')
   .option('--offline', 'use cached template')
 /**
  * Help.
  */
 program.on('--help', () => {
   console.log('  Examples:')
   console.log()
   console.log(chalk.gray('    # create a new project with an official template'))
   console.log('    $ vue init webpack my-project')
   console.log()
   console.log(chalk.gray('    # create a new project straight from a github template'))
   console.log('    $ vue init username/repo my-project')
   console.log()
 })
 /**
  * Help.
  */
 function help () {
   program.parse(process.argv)
   if (program.args.length < 1) return program.help()
 }
 help()
 /**
  * Settings.
  */
 let template = program.args[0]
 const hasSlash = template.indexOf('/') > -1
 const rawName = program.args[1]
 const inPlace = !rawName || rawName === '.'
 const name = inPlace ? path.relative('../', process.cwd()) : rawName
 const to = path.resolve(rawName || '.')
 const clone = program.clone || false
 const tmp = path.join(home, '.vue-templates', template.replace(/[\/:]/g, '-'))
 if (program.offline) {
   console.log(`> Use cached template at ${chalk.yellow(tildify(tmp))}`)
   template = tmp
 }
 /**
  * Padding.
  */
 console.log()
 process.on('exit', () => {
   console.log()
 })
 if (inPlace || exists(to)) {
   inquirer.prompt([{
     type: 'confirm',
     message: inPlace
       ? 'Generate project in current directory?'
       : 'Target directory exists. Continue?',
     name: 'ok'
   }]).then(answers => {
     if (answers.ok) {
       run()
     }
   }).catch(logger.fatal)
 } else {
   run()
 }
 /**
  * Check, download and generate the project.
  */
 function run () {
   // check if template is local
   if (isLocalPath(template)) {
     const templatePath = getTemplatePath(template)
     if (exists(templatePath)) {
       generate(name, templatePath, to, err => {
         if (err) logger.fatal(err)
         console.log()
         logger.success('Generated "%s".', name)
       })
     } else {
       logger.fatal('Local template "%s" not found.', template)
     }
   } else {
     checkVersion(() => {
       if (!hasSlash) {
         // use official templates
         const officialTemplate = 'vuejs-templates/' + template
         if (template.indexOf('#') !== -1) {
           downloadAndGenerate(officialTemplate)
         } else {
           if (template.indexOf('-2.0') !== -1) {
             warnings.v2SuffixTemplatesDeprecated(template, inPlace ? '' : name)
             return
           }
           // warnings.v2BranchIsNowDefault(template, inPlace ? '' : name)
           downloadAndGenerate(officialTemplate)
         }
       } else {
         downloadAndGenerate(template)
       }
     })
   }
 }
 /**
  * Download a generate from a template repo.
  *
  * @param {String} template
  */
 function downloadAndGenerate (template) {
   const spinner = ora('downloading template')
   spinner.start()
   // Remove if local template exists
   if (exists(tmp)) rm(tmp)
   download(template, tmp, { clone }, err => {
     spinner.stop()
     if (err) logger.fatal('Failed to download repo ' + template + ': ' + err.message.trim())
     generate(name, tmp, to, err => {
       if (err) logger.fatal(err)
       console.log()
       logger.success('Generated "%s".', name)
     })
   })
 }
https://github.com/vuejs-templates vue-cli的模板地址
https://github.com/vuejs/vue-cli vue-cli 源码
主要使用的是 bin/vue-init
用的npm 包 download-git-repo commander
主要代码
downloadAndGenerate() 里面的
template
关于类似vue-cli 脚手架的更多相关文章
- 13. Vue CLI脚手架
		
一. Vue CLI 介绍 1. 什么是Vue CLI? Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统.Vue CLI 致力于将 Vue 生态中的工具基础标准化.它确保了各种构建工 ...
 - 使用Vue CLI脚手架搭建vue项目
		
本次是使用@vue/cli 3.11.0版本搭建的vue项目 1. 首先确保自己的电脑上的Node.js的版本是8.9版本或者以上 2. 全局安装vue/cli npm install @vue/cl ...
 - vue.cli脚手架初次使用图文教程
		
vue-cli作用 vue-cli作为vue的脚手架,可以帮助我们在实际开发中自动生成vue.js的模板工程. vue-cli使用 !!前提:需要vue和webpack 安装全局vue-cli npm ...
 - vue cli脚手架使用
		
1.安装nodejs,npm https://www.cnblogs.com/xidianzxm/p/12036880.html 2.安装vue cli sudo npm install -g @vu ...
 - node.js和vue cli脚手架下载安装配置方法
		
一.node.js安装以及环境配置 1.下载vue.js 下载地址: https://nodejs.org/en/ 2.安装node.js 下载完成后,双击安装包开始安装.安装地址最好换成自己指定的地 ...
 - vue cli 脚手架上多页面开发 支持webpack2.x
		
A yuri demo for webpack2 vue multiple page.我看到有一些项目多页面项目是基于webapck1.0的,我这个是在webpack2.x上布置修改. 项目地址: ...
 - 用 vue cli 脚手架搭建单页面 Vue 应用(进阶2)
		
1.配置 Node 环境. 自行百度吧. 安装好了之后,打开 cmd .运行 node -v .显示版本号,就是安装成功了. 注:不要安装8.0.0以上的版本,和 vue-cli 不兼容. 我使用的 ...
 - vue.js---利用vue cli脚手架工具+webpack创建项目遇到的坑
		
1.Eslint js代码规范报错 WARNING Compiled with 2 warnings 10:43:26 ✘ http://eslint.org/docs/rules/quotes St ...
 - vue cli脚手架项目利用webpack给生产环境和发布环境配置不同的接口地址或者不同的变量值。
		
废话不多说,直接进入正题,此文以配置不同的接口域名地址为例子 项目根目录下有一个config文件夹,基础项目的话里面至少包括三个文件, 1.dev.env.js 2.index.js 3.prod.e ...
 - 关于Vue.cli 脚手架环境中引入Bootstrap时,table表格样式缺失的解决办法
		
Vue+bootstrap不能正常使用table的样式 环境:下载官网的本地bootstrap包,然后在vue 的index.html引入bootstrap的css和js环境 问题描述:1. vue里 ...
 
随机推荐
- [USACO06JAN]牛的舞会The Cow Prom Tarjan
			
题目描述 The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their ...
 - [BZOJ1096][ZJOI2007]仓库建设(斜率优化DP)
			
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1096 分析: 假设1~10,如果在3 6 10建立仓库,那么当前建立仓库决策下的最优值 ...
 - 源码分析-react1-根节点渲染
 - Windows下React Native开发01  -- Android开发环境搭建
			
1.安装jdk 推荐将JDK的bin目录加入系统PATH环境变量(自己百度下怎么配置). 2.安装SDK 直接安装 Android Studio 推荐从AndroidDevTools下载.(也可以直 ...
 - 项目中应用到的框架和技术之三——echarts
			
echarts是效果丰富的图表库,当时考虑怎么炫怎么来就引入了这个库来做图表展示,官网:http://echarts.baidu.com 项目里用的比较浅,估且一看吧 代码: this.toChart ...
 - 条款50: 提高对C++的认识
			
class Base { public: virtual void f(int x); }; class Derived: public Base { public: virtual void f(d ...
 - 自然语言处理中的Attention Model:是什么及为什么
			
/* 版权声明:能够随意转载.转载时请标明文章原始出处和作者信息 .*/ author: 张俊林 要是关注深度学习在自然语言处理方面的研究进展,我相信你一定听说过Attention Model(后文有 ...
 - Eclipse导入外部项目问题总结
			
 此次在项目开发过程中导入从oksvn下载的共享项目时出现几个项目在不同的IDE导入导出时的问题,为免忘记做例如以下笔记: 1 类路径问题 在Java开发中大多数的开发人员使用的IDE是MyEcl ...
 - 数学之路-python计算实战(17)-机器视觉-滤波去噪(中值滤波)
			
Blurs an image using the median filter. C++: void medianBlur(InputArray src, OutputArray dst, int ks ...
 - Git新建本地分支与远程分支关联问题:git branch --set-upstream【转】
			
本文转载自:http://blog.csdn.net/netwalk/article/details/21088405 Git新建本地分支与远程分支关联问题:git branch --set-upst ...