1.1.2 • Published 1 year ago

xwzs v1.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

切换 git 仓库源

功能模仿参考 nrm xmzs

安装命令

npm i xwzs -g (建议全局安装 -g)

安装后,请使用命令 xw

命令支持

  • xw use 使用 name 源
  • xw use 选择源
  • xw list/ls 列出所有的仓库源
  • xw current 展示当前仓库源

  • xw add 添加自定义源
  • xw rename/rn 重命名自定义源
  • xw del/delete/rm 删除自定义源

  • xw ping 查看源响应时间

内置仓库源

实现过程

  1. index.js 添加注释 ,bin 2.commander +process.argv 读取并解析命令行参数
  2. child_process exec 执行命令设置 git 仓库源
  3. inquirer 获取用户选择的仓库源进行设置

用到的库:commander inquirer child_process node-http-ping chalk ora

总结:

  • 配置 bin 命令:js 首行加注释 !#/usr/env/bin node ; 当运行自定义 bin 命令 xw 时,系统隐式运行 node
  • commander 配合 process.argv 去解析出命令行参数,定义指令 use、ls、add、current 等
  • inquirer 带来命令行交互,选择源
  • child_process 从代码里运行 npm 命令:npm get registry/npm config set registry <npm 源地址>
  • node-http-ping 查看源的响应时间
  • chalk 命令行文字颜色
  • ora 添加 loading 加载
1.1.1

1 year ago

1.1.0

1 year ago

1.1.2

1 year ago

1.0.0

1 year ago