官方与参考链接
「企业型 CLI」无单一全球官网:各公司通常自研或基于内部制品库分发。下文 列全所有子命令与常用参数,便于只读本站完成配置与运维;外部链接仅作工具链参考。
概述
企业型 CLI(opencli enterprise)用于在受管控网络中安装、配置与审计 OpenCLI
各子模块。适合需要统一身份、留痕与离线包分发的团队。
前置要求
| 工具 | 最低版本 | 用途 |
|---|
| Node.js | 20 LTS 及以上 | 运行 CLI 与部分插件 |
| npm 或 pnpm | npm 10+ / pnpm 9+ | 全局安装与锁文件解析 |
| Git | 2.40+ | 从企业镜像拉取配置模板(可选) |
| 企业 CA 证书 | — | 内网 HTTPS / 私有 npm 源 |
说明: 若仅使用预编译二进制分发,可不安装 Node.js,改用安装包内的 opencli 可执行文件。
安装
方式一:npm 全局安装(推荐开发机)
npm install -g @opencli/cli@latest
npm install -g:将包安装到全局,终端任意目录可执行 opencli。
@opencli/cli@latest:固定使用最新稳定版;生产环境建议锁具体版本号,例如 @opencli/cli@1.4.2。
安装完成后校验:
opencli --version
方式二:内网离线包
tar -xzf opencli-enterprise-linux-x64.tar.gz
sudo mv opencli /usr/local/bin/
opencli --version
tar -xzf:解压发布包。
sudo mv ... /usr/local/bin/:将二进制放到 PATH 常见目录(按贵司规范可改为 /opt/opencli/bin)。
初次配置
登录企业 SSO
opencli enterprise login --tenant your-corp --sso oidc
| 参数 | 含义 |
|---|
login | 发起浏览器或设备码流程,换取刷新令牌 |
--tenant | 企业在身份提供商中的租户标识 |
--sso | 协议类型:oidc 或 saml |
指定私有 registry(可选)
opencli enterprise config set npm.registry https://npm.corp.example.com
将后续 opencli enterprise plugins install 等操作的包解析指向内网镜像。
命令参考(全量)
以下假定主程序为 opencli,企业模块为 opencli enterprise。<...> 表示占位符,[...] 表示可选。
顶层帮助
opencli --help
opencli enterprise --help
身份与自检
| 命令 | 说明 |
|---|
opencli enterprise login [--tenant <id>] [--sso oidc 或 saml] [--no-browser] | SSO 登录;--no-browser 使用设备码流 |
opencli enterprise logout | 清除本地令牌与会话 |
opencli enterprise whoami | 打印当前租户、用户名、令牌过期时间 |
opencli enterprise doctor | 检查 Node、证书、registry、SSO、磁盘权限 |
opencli enterprise doctor --verbose / -v | 输出诊断详情 |
opencli enterprise status | 与 doctor 类似,偏「一行摘要」运维视图 |
opencli enterprise doctor
opencli enterprise doctor -v
opencli enterprise whoami
配置 config
| 命令 | 说明 |
|---|
opencli enterprise config get <key> | 读取单项配置(如 npm.registry) |
opencli enterprise config set <key> <value> | 写入字符串配置 |
opencli enterprise config unset <key> | 删除键 |
opencli enterprise config list | 列出全部(默认掩码敏感项) |
opencli enterprise config list --show-secrets | 列出含敏感字段(慎用、勿重定向到共享终端) |
opencli enterprise config set npm.registry https://npm.corp.example.com
opencli enterprise config get npm.registry
opencli enterprise config list
审计 audit
| 命令 | 说明 |
|---|
opencli enterprise audit export [--since 7d/30d/90d] [--out <path>] | 导出 JSONL 审计 |
opencli enterprise audit tail [--follow] [--lines N] | 查看近期审计流(需日志后端支持) |
opencli enterprise audit export --since 30d --out ./audit.jsonl
opencli enterprise audit tail --lines 100
离线包 bundle
| 命令 | 说明 |
|---|
opencli enterprise bundle pack [--output <path>] [--include-plugins] | 打离线包;默认含已启用插件 |
opencli enterprise bundle verify <path> | 校验包签名与清单 |
opencli enterprise bundle pack --output ./opencli-offline-bundle.tgz
opencli enterprise bundle verify ./opencli-offline-bundle.tgz
插件 plugins
| 命令 | 说明 |
|---|
opencli enterprise plugins list | 已安装插件与版本 |
opencli enterprise plugins list --outdated | 标出可升级项 |
opencli enterprise plugins install <spec> | spec 为 npm 包名、版本或 tarball 路径 |
opencli enterprise plugins uninstall <name> | 卸载 |
opencli enterprise plugins update | 升级全部 |
opencli enterprise plugins update <name> | 升级指定插件 |
opencli enterprise plugins list
opencli enterprise plugins install @opencli/plugin-example@1.2.0
opencli enterprise plugins uninstall @opencli/plugin-example
缓存与其它
| 命令 | 说明 |
|---|
opencli enterprise cache clear | 清除本地 HTTP/registry 缓存 |
opencli enterprise version | 打印 enterprise 模块版本(若与全局 opencli --version 分开展示) |
opencli --version
opencli enterprise version
opencli enterprise cache clear
故障排查
UNABLE_TO_VERIFY_LEAF_SIGNATURE:将企业根证书导入系统信任库,或设置 NODE_EXTRA_CA_CERTS=/path/to/corp-ca.pem。
E401 on login:确认时钟同步(NTP),并检查 --tenant 是否与 IdP 配置一致。