好用的项目初始化工具 SCION 升级啦!

写于 2017.05.11前端

一、什么是SCION

SCION是一个专门用于初始化项目的工具。只要你有一套模板,就能经过SCION方便地把项目初始化出来。同时SCION容许你添加多套模板,大大提高了工做效率。git

关于SCION的诞生,能够查看个人这篇文章:《教你从零开始搭建一款前端脚手架工具》github

项目地址:github.com/jrainlau/sc…npm

二、安装

能够经过yarn或者npm全局安装使用:json

yarn add scion-cli --global
复制代码
npm install scion-cli -g
复制代码

三、使用方式

执行scion命令,获取详细使用方式及说明:bash

Usage: scion <command>


  Commands:

    add|a      Add a new template
    list|l     List all the templates
    init|i     Generate a new project
    delete|d   Delete a template

  Options:

    -h, --help     output usage information
    -V, --version  output the version number
复制代码

注意,若是你正在使用MacOS或者Linux系统,在执行adddelete命令的时候,须要加上sudo前缀。工具

四、命令

add | a

这条命令会添加一个模板信息到templates.json文件内,以便未来供SCION使用。gitlab

$ scion add

? Set the custom name of the template: my-first-template
? Owner/name of the template: jrainlau/scion
? Branch of the template: new
┌───────────────────┬────────────────┬────────┐
│ Template Name     │ Owner/Name     │ Branch │
├───────────────────┼────────────────┼────────┤
│ my-first-template │ jrainlau/scion │ new    │
└───────────────────┴────────────────┴────────┘
✔ New template has been added successfully!
复制代码

Scion 使用了 download-git-repo 去下载位于github的项目做为模板。post

list | l

列出全部已保存的模板。优化

$ scion list

┌────────────────────┬────────────────┬────────┐
│ Template Name      │ Owner/Name     │ Branch │
├────────────────────┼────────────────┼────────┤
│ my-first-template  │ jrainlau/scion │ new    │
├────────────────────┼────────────────┼────────┤
│ my-second-template │ jrainlau/motto │ master │
└────────────────────┴────────────────┴────────┘
复制代码

init | i

在添加了模板之后,经过这条命令初始化你的项目。

$ scion init

? Template name: my-first-template
? Project name: my-project
? Where to init the project? ../
⠹ Downloading template...

New project has been initialized successfully!
复制代码

是否是很简单呢?

delete | d

用于删除一个模板。

$ scion delete

? Which template you want to delete? my-second-template
┌───────────────────┬────────────────┬────────┐
│ Template Name     │ Owner/Name     │ Branch │
├───────────────────┼────────────────┼────────┤
│ my-first-template │ jrainlau/scion │ new    │
└───────────────────┴────────────────┴────────┘
✔ Template has been deleted successfully
复制代码

五、明白模板是什么

简单来讲,一个“模板”就是一个保存在github或者gitlab项目,这个项目有着完整的目录结构,以其为模板的项目都会在当前的目录基础上进行扩展。

六、升级信息

  • 使用cli-table优化模板的输出。

  • 使用inquirer实现命令行交互功能。

  • 使用download-git-repo去下载模板,避免了经过git clone会把.git文件夹也下载下来的问题。

  • 修复没法跨平台(MacOS, Windows)使用的问题。

相关文章
相关标签/搜索