寫於 2017.05.11

1、什麼是SCION
SCION
是一個專門用於初始化專案的工具。只要你有一套模板,就能通過SCION
方便地把專案初始化出來。同時SCION
允許你新增多套模板,大大提升了工作效率。
關於SCION
的誕生,可以檢視我的這篇文章:《教你從零開始搭建一款前端腳手架工具》。
2、安裝
可以通過yarn
或者npm
全域性安裝使用:
yarn add scion-cli --global
複製程式碼
npm install scion-cli -g
複製程式碼
3、使用方式
執行scion
命令,獲取詳細使用方式及說明:
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
系統,在執行add
和delete
命令的時候,需要加上sudo
字首。
4、命令
add | a
這條命令會新增一個模板資訊到templates.json
檔案內,以便將來供SCION
使用。
$ 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的專案作為模板。

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
複製程式碼

5、明白模板是什麼
簡單來說,一個“模板”就是一個儲存在github或者gitlab專案,這個專案有著完整的目錄結構,以其為模板的專案都會在當前的目錄基礎上進行擴充套件。
6、升級資訊
-
使用cli-table優化模板的輸出。
-
使用inquirer實現命令列互動功能。
-
使用download-git-repo去下載模板,避免了通過
git clone
會把.git
資料夾也下載下來的問題。 -
修復無法跨平臺(MacOS, Windows)使用的問題。