SCION
是一個專門用於初始化項目的工具。只要你有一套模板,就能經過SCION
方便地把項目初始化出來。同時SCION
容許你添加多套模板,大大提高了工做效率。前端
關於SCION
的誕生,能夠查看個人這篇文章:《教你從零開始搭建一款前端腳手架工具》。git
項目地址:https://github.com/jrainlau/s...github
能夠經過yarn
或者npm
全局安裝使用:npm
yarn add scion-cli --global
npm install scion-cli -g
執行scion
命令,獲取詳細使用方式及說明:json
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
前綴。segmentfault
這條命令會添加一個模板信息到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的項目做爲模板。gitlab
列出全部已保存的模板。優化
$ scion list ┌────────────────────┬────────────────┬────────┐ │ Template Name │ Owner/Name │ Branch │ ├────────────────────┼────────────────┼────────┤ │ my-first-template │ jrainlau/scion │ new │ ├────────────────────┼────────────────┼────────┤ │ my-second-template │ jrainlau/motto │ master │ └────────────────────┴────────────────┴────────┘
在添加了模板之後,經過這條命令初始化你的項目。ui
$ scion init ? Template name: my-first-template ? Project name: my-project ? Where to init the project? ../ ⠹ Downloading template... New project has been initialized successfully!
是否是很簡單呢?
用於刪除一個模板。
$ 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)使用的問題。