@icoolaw/cli
v0.1.1
Published
CLI tool for icoolaw projects
Readme
iCoolaw CLI 使用指南
iCoolaw CLI 是一个强大的命令行工具,用于简化开发流程和项目管理。
安装
npm install -g @icoolaw/cli基本用法
icoolaw <command> [options]Config 配置管理
Config 命令用于管理 CLI 工具的配置项,支持查看、设置、删除和重置配置。
基本语法
icoolaw config <sub-command> [options]子命令
1. 查看配置 (list)
显示当前所有配置项及其值:
icoolaw config list输出示例:
===================== 配置项详情 ======================
当前配置:
registry https://registry.npmjs.org/ (默认) # NPM 包注册表地址
gitlabUrl http://172.16.8.35:9980 (默认) # GitLab 服务器地址
gitlabToken null (默认) # GitLab 访问令牌
packageManager yarn (自定义) # 包管理工具 (npm, yarn, pnpm)
配置文件位置: /Users/username/.icoolawrc2. 设置配置 (set)
设置指定配置项的值:
icoolaw config set <key> [value]参数说明:
key: 配置项名称value: 配置项值(可选,如果不提供将进入交互式输入)
示例:
# 设置 NPM 注册表地址
icoolaw config set registry https://registry.npm.taobao.org/
# 设置 GitLab 服务器地址
icoolaw config set gitlabUrl https://gitlab.example.com
# 设置包管理工具
icoolaw config set packageManager pnpm
# 交互式设置(不提供 value 参数)
icoolaw config set gitlabToken3. 删除配置 (unset)
删除指定的配置项,恢复为默认值:
icoolaw config unset <key>示例:
# 删除自定义的注册表配置,恢复默认值
icoolaw config unset registry
# 删除 GitLab Token
icoolaw config unset gitlabToken4. 重置配置 (reset)
重置所有配置项为默认值:
icoolaw config reset注意: 此操作会删除所有自定义配置,请谨慎使用。
可用的配置项
| 配置项 | 描述 | 默认值 | 示例值 |
|--------|------|--------|--------|
| registry | NPM 包注册表地址 | https://registry.npmjs.org/ | https://registry.npm.taobao.org/ |
| gitlabUrl | GitLab 服务器地址 | http://172.16.8.35:9980 | https://gitlab.example.com |
| gitlabToken | GitLab 访问令牌 | null | glpat-xxxxxxxxxxxxxxxxxxxx |
| packageManager | 包管理工具 | npm | npm, yarn, pnpm |
配置文件
配置信息存储在用户主目录下的 .icoolawrc 文件中:
- macOS/Linux:
~/.icoolawrc - Windows:
%USERPROFILE%\.icoolawrc
配置文件采用 JSON 格式:
{
"registry": "https://registry.npm.taobao.org/",
"packageManager": "yarn",
"gitlabUrl": "https://gitlab.example.com",
"gitlabToken": "glpat-xxxxxxxxxxxxxxxxxxxx"
}敏感信息处理
为了安全考虑,敏感配置项(如 gitlabToken)在显示时会进行脱敏处理:
gitlabToken ***xxxx (自定义) # GitLab 访问令牌交互式配置
当使用 icoolaw config set <key> 而不提供 value 参数时,CLI 会进入交互式模式:
$ icoolaw config set gitlabToken
? 请输入 GitLab 访问令牌: [hidden]
✓ 配置项 gitlabToken 已设置配置验证
CLI 会对配置值进行验证:
- registry: 必须是有效的 URL
- gitlabUrl: 必须是有效的 URL
- packageManager: 必须是
npm、yarn或pnpm之一 - gitlabToken: 必须是非空字符串
常见用法示例
# 查看当前配置
icoolaw config list
# 设置淘宝镜像
icoolaw config set registry https://registry.npm.taobao.org/
# 设置使用 pnpm 作为包管理工具
icoolaw config set packageManager pnpm
# 交互式设置 GitLab Token
icoolaw config set gitlabToken
# 重置所有配置
icoolaw config reset获取帮助
使用以下命令获取帮助信息:
# 查看所有可用命令
icoolaw --help
# 查看 config 命令帮助
icoolaw config更多功能和命令正在开发中,敬请期待!
