好用的項目初始化工具 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)使用的問題。

相關文章
相關標籤/搜索