refacor: 重构目录架构

This commit is contained in:
2026-09-16 22:43:21 +08:00
parent b37cdb0d54
commit 2754ed1e45
2762 changed files with 0 additions and 1529 deletions
+393
View File
@@ -0,0 +1,393 @@
# ecom-license CLI
Ecom-DMB License 运营管理命令行工具,用于登录 License Server、管理客户与签发/吊销许可证。
**前置条件**:License Server 已启动(默认 `http://localhost:3100`)。首次登录默认账号 `admin` / `admin123`。
---
## 安装与运行
```bash
cd ecom-license/cli
pnpm install
pnpm build # 可选,生产模式需要
```
| 方式 | 命令 | 说明 |
|------|------|------|
| 开发模式 | `pnpm dev <子命令>` | 使用 `tsx` 直接运行源码 |
| 构建产物 | `pnpm start <子命令>` | 运行 `dist/index.js` |
| 全局安装 | `pnpm link --global` 后 `ecom-license` | 需先 `pnpm build` |
| 快捷脚本 | `pnpm login` / `pnpm whoami` / `pnpm stats` | 等价于 `pnpm dev <命令>` |
无子命令时显示常用命令引导;完整帮助:
```bash
pnpm dev -- --help
pnpm dev customer --help
pnpm dev license --help
```
---
## 配置
登录成功后写入本地配置文件:
| 项 | 值 |
|----|-----|
| 默认路径 | `~/.config/ecom-license/config.json` |
| 自定义路径 | 环境变量 `ECOM_LICENSE_CONFIG` |
```json
{
"apiUrl": "http://localhost:3100",
"token": "eyJ...",
"username": "admin",
"expiresAt": "2026-06-01T00:00:00.000Z"
}
```
`logout` 会清除 token,保留 `apiUrl`。
---
## 环境变量
| 变量 | 作用 |
|------|------|
| `ECOM_LICENSE_API_URL` | API 根地址(优先级低于 `--url`) |
| `ECOM_LICENSE_TOKEN` | Bearer Token(优先级低于 `--token`) |
| `ECOM_LICENSE_USERNAME` | 非交互 `login` 用户名 |
| `ECOM_LICENSE_PASSWORD` | 非交互 `login` 密码 |
| `ECOM_LICENSE_CONFIG` | 配置文件路径 |
| `CI` | 存在时禁用交互向导 |
| `NO_COLOR` / `FORCE_COLOR` | 控制终端颜色 |
---
## 全局选项
所有命令均支持(写在子命令前或后均可,由 Commander 解析):
| 选项 | 说明 |
|------|------|
| `--url <base>` | API 根地址,如 `http://localhost:3100` |
| `--token <jwt>` | 临时指定 Token,不写配置文件 |
| `--json` | 纯 JSON 输出,适合脚本 |
| `--quiet` | 仅输出关键值(如 ID、licenseKey、文件路径) |
| `--yes` | 跳过确认(删除客户、吊销许可证) |
| `--verbose` | 显示详细错误堆栈 |
| `-V, --version` | 版本号 |
| `-h, --help` | 帮助 |
### 输出模式
| 模式 | 条件 | 行为 |
|------|------|------|
| 交互(默认) | TTY 且非 `CI`,无 `--json`/`--quiet` | 缺参时向导提问;列表用表格;请求有 spinner |
| `--json` | 显式指定 | 结构化 JSON,无颜色 |
| `--quiet` | 显式指定 | 单行关键值,便于管道 |
| 管道/重定向 | stdout 非 TTY | 同 `--json` 语义,不展示 banner/boxen |
---
## 命令总览
```
ecom-license [--url] [--token] [--json] [--quiet] [--yes] [--verbose]
login [--username] [--password]
logout
whoami
stats
customer list [--page] [--size]
customer create [--code] [--name] [--contact-name] [--contact-phone] [--contact-email]
customer show <id>
customer delete <id>
license list [--page] [--size] [--customer-id] [--status]
license show <id>
license generate [--customer-id] [--company] [--fingerprint] [--edition] [--expires] [--features]
license revoke <id>
license download <id> [-o|--output <file>]
```
---
## 认证与会话
### `login`
登录 License 平台,保存 Token 到配置文件。
| 选项 | 说明 |
|------|------|
| `--username <name>` | 用户名(非交互必填其一) |
| `--password <pwd>` | 密码 |
**交互模式**:依次询问 API 地址(默认当前配置或 `http://localhost:3100`)、用户名、密码。
```bash
pnpm dev login
pnpm dev login --username admin --password admin123
ECOM_LICENSE_USERNAME=admin ECOM_LICENSE_PASSWORD=admin123 pnpm dev login
pnpm dev login --url http://192.168.1.10:3100
```
### `logout`
清除本地 Token,不删除 API 地址配置。
```bash
pnpm dev logout
```
### `whoami`
查看当前登录状态(API 地址、用户名、Token 过期时间)。
```bash
pnpm dev whoami
pnpm dev whoami --json
pnpm dev whoami --quiet # 仅输出用户名
```
未登录时退出码 `1`,并提示运行 `login`。
### `stats`
获取平台统计:客户数、有效许可证、即将过期、许可证总数。
```bash
pnpm dev stats
pnpm dev stats --json
pnpm dev stats --quiet # 仅输出有效许可证数量
```
---
## 客户管理 `customer`
### `customer list`
分页列出客户。
| 选项 | 默认 | 说明 |
|------|------|------|
| `--page <n>` | `1` | 页码 |
| `--size <n>` | `20` | 每页条数 |
```bash
pnpm dev customer list
pnpm dev customer list --page 2 --size 10
pnpm dev customer list --json
```
### `customer create`
创建客户。交互模式下会逐步询问公司名、联系人、电话、邮箱、客户编码(编码可留空自动生成)。
| 选项 | 说明 |
|------|------|
| `--name <name>` | 公司名称(**必填**,非交互) |
| `--code <code>` | 客户编码,省略则服务端自动生成 |
| `--contact-name <n>` | 联系人 |
| `--contact-phone <p>` | 联系电话 |
| `--contact-email <e>` | 联系邮箱 |
```bash
pnpm dev customer create
pnpm dev customer create --name "某某科技有限公司" --contact-name 张三 --contact-phone 13800138000
pnpm dev customer create --name "示例公司" --code CUST-001 --json
pnpm dev customer create --name "示例公司" --quiet # 仅输出新客户 ID
```
### `customer show <id>`
查看单个客户详情(JSON 格式)。
```bash
pnpm dev customer show 1
pnpm dev customer show 1 --json
```
### `customer delete <id>`
删除客户。交互模式下需二次确认;`--yes` 跳过确认。
```bash
pnpm dev customer delete 1
pnpm dev customer delete 1 --yes
```
---
## 许可证管理 `license`
### `license list`
分页列出许可证,可按客户、状态筛选。
| 选项 | 默认 | 说明 |
|------|------|------|
| `--page <n>` | `1` | 页码 |
| `--size <n>` | `20` | 每页条数 |
| `--customer-id <id>` | — | 按客户 ID 过滤 |
| `--status <s>` | — | 按状态过滤(如 `active`、`revoked`) |
```bash
pnpm dev license list
pnpm dev license list --customer-id 1 --status active
pnpm dev license list --json
```
### `license show <id>`
查看单个许可证详情。
```bash
pnpm dev license show 1
pnpm dev license show 1 --json
```
### `license generate`
签发新许可证。交互模式为分步向导:选择客户 → 公司名 → 机器指纹 → 版本 → 有效期 → 功能 → 确认摘要。
| 选项 | 默认 | 说明 |
|------|------|------|
| `--customer-id <id>` | — | 客户 ID |
| `--company <name>` | — | 授权公司名 |
| `--fingerprint <fp>` | — | 机器指纹,`FP-xxx` 或 `*`(SaaS 不限) |
| `--edition <e>` | `enterprise` | 版本:`trial` / `enterprise` / `unlimited` |
| `--expires <date>` | — | 过期日 `YYYY-MM-DD` |
| `--features <list>` | `order-import` | 逗号分隔功能列表 |
**非交互模式**必须同时提供:`--customer-id`、`--company`、`--fingerprint`、`--expires`。
```bash
# 交互向导(推荐)
pnpm dev license generate
# 脚本签发
pnpm dev license generate \
--customer-id 1 \
--company "某某科技有限公司" \
--fingerprint "FP-abc123" \
--edition enterprise \
--expires 2027-05-28 \
--features order-import
# SaaS 不限指纹
pnpm dev license generate \
--customer-id 1 \
--company "SaaS 客户" \
--fingerprint "*" \
--expires 2027-05-28
# 仅输出 licenseKey(便于复制到主应用激活)
pnpm dev license generate ... --quiet
pnpm dev license generate ... --json
```
签发成功后交互模式以绿色面板展示 ID、JTI、过期日与完整 `licenseKey`。
### `license revoke <id>`
吊销许可证。交互模式下展示 JTI、指纹并二次确认;`--yes` 跳过。
```bash
pnpm dev license revoke 1
pnpm dev license revoke 1 --yes
pnpm dev license revoke 1 --json
```
### `license download <id>`
下载许可证文件到本地。
| 选项 | 默认 | 说明 |
|------|------|------|
| `-o, --output <file>` | `license-<id>.key` | 保存路径 |
```bash
pnpm dev license download 1
pnpm dev license download 1 -o ./my-license.key
pnpm dev license download 1 --quiet # 仅输出文件路径
```
---
## 典型工作流
### 1. 首次使用
```bash
# 1. 确保 License Server 已启动(ecom-license/server)
cd ../server && pnpm start:dev
# 2. 登录
cd ../cli && pnpm dev login
# 3. 查看平台概况
pnpm dev stats
```
### 2. 为客户签发 License
```bash
pnpm dev customer create --name "某某科技有限公司"
pnpm dev customer list --quiet # 记下客户 ID,或直接用交互 generate
pnpm dev license generate # 交互向导
# 或
pnpm dev license generate \
--customer-id 1 \
--company "某某科技有限公司" \
--fingerprint "FP-xxxxxxxx" \
--expires 2027-12-31 \
--quiet > license.key
```
### 3. CI / 脚本集成
```bash
export ECOM_LICENSE_API_URL=http://license.internal:3100
export ECOM_LICENSE_TOKEN="$(pnpm dev login --username admin --password "$SECRET" --json | jq -r .token)"
pnpm dev customer list --json | jq '.items | length'
pnpm dev stats --json
```
---
## 错误与提示
| 情况 | 行为 |
|------|------|
| 未登录调用需鉴权 API | 提示运行 `ecom-license login`,非裸 401 |
| 网络/服务端错误 | spinner 停止后显示可读错误;加 `--verbose` 看堆栈 |
| Ctrl+C 中断向导 | 优雅退出,不打印 Node 堆栈 |
| 空列表 | 提示下一步建议(如「运行 customer create」) |
---
## 当前未实现的子命令
以下能力在 License Server API 中可能存在,CLI 尚未接入:
- `customer update` — 更新客户信息
- `customer licenses <id>` — 查看某客户下全部许可证
如需使用,可直接调用 Server REST API,或后续在 CLI 中补充。
---
## 相关文档
- 整体设计:`../DESIGN.md`
- CLI 交互规格:`../DESIGN.reference.md` §E
- Server 启动:`../server/README.md`(若有)或 `../README.md`
+25
View File
@@ -0,0 +1,25 @@
{
"name": "ecom-license-tui",
"version": "0.2.0",
"private": true,
"packageManager": "pnpm@10.32.0",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx src/index.ts",
"start": "node dist/index.js"
},
"dependencies": {
"@inquirer/prompts": "^7.2.0",
"boxen": "^8.0.1",
"chalk": "^5.4.1",
"cli-table3": "^0.6.5",
"gradient-string": "^3.0.0",
"ora": "^8.1.1"
},
"devDependencies": {
"@types/node": "^22.10.2",
"tsx": "^4.19.2",
"typescript": "^5.7.2"
}
}
+950
View File
@@ -0,0 +1,950 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@inquirer/prompts':
specifier: ^7.2.0
version: 7.10.1(@types/node@22.19.20)
boxen:
specifier: ^8.0.1
version: 8.0.1
chalk:
specifier: ^5.4.1
version: 5.6.2
cli-table3:
specifier: ^0.6.5
version: 0.6.5
gradient-string:
specifier: ^3.0.0
version: 3.0.0
ora:
specifier: ^8.1.1
version: 8.2.0
devDependencies:
'@types/node':
specifier: ^22.10.2
version: 22.19.20
tsx:
specifier: ^4.19.2
version: 4.22.4
typescript:
specifier: ^5.7.2
version: 5.9.3
packages:
'@colors/colors@1.5.0':
resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==}
engines: {node: '>=0.1.90'}
'@esbuild/aix-ppc64@0.28.0':
resolution: {integrity: sha512-lhRUCeuOyJQURhTxl4WkpFTjIsbDayJHih5kZC1giwE+MhIzAb7mEsQMqMf18rHLsrb5qI1tafG20mLxEWcWlA==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
'@esbuild/android-arm64@0.28.0':
resolution: {integrity: sha512-+WzIXQOSaGs33tLEgYPYe/yQHf0WTU0X42Jca3y8NWMbUVhp7rUnw+vAsRC/QiDrdD31IszMrZy+qwPOPjd+rw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [android]
'@esbuild/android-arm@0.28.0':
resolution: {integrity: sha512-wqh0ByljabXLKHeWXYLqoJ5jKC4XBaw6Hk08OfMrCRd2nP2ZQ5eleDZC41XHyCNgktBGYMbqnrJKq/K/lzPMSQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [android]
'@esbuild/android-x64@0.28.0':
resolution: {integrity: sha512-+VJggoaKhk2VNNqVL7f6S189UzShHC/mR9EE8rDdSkdpN0KflSwWY/gWjDrNxxisg8Fp1ZCD9jLMo4m0OUfeUA==}
engines: {node: '>=18'}
cpu: [x64]
os: [android]
'@esbuild/darwin-arm64@0.28.0':
resolution: {integrity: sha512-0T+A9WZm+bZ84nZBtk1ckYsOvyA3x7e2Acj1KdVfV4/2tdG4fzUp91YHx+GArWLtwqp77pBXVCPn2We7Letr0Q==}
engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
'@esbuild/darwin-x64@0.28.0':
resolution: {integrity: sha512-fyzLm/DLDl/84OCfp2f/XQ4flmORsjU7VKt8HLjvIXChJoFFOIL6pLJPH4Yhd1n1gGFF9mPwtlN5Wf82DZs+LQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
'@esbuild/freebsd-arm64@0.28.0':
resolution: {integrity: sha512-l9GeW5UZBT9k9brBYI+0WDffcRxgHQD8ShN2Ur4xWq/NFzUKm3k5lsH4PdaRgb2w7mI9u61nr2gI2mLI27Nh3Q==}
engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
'@esbuild/freebsd-x64@0.28.0':
resolution: {integrity: sha512-BXoQai/A0wPO6Es3yFJ7APCiKGc1tdAEOgeTNy3SsB491S3aHn4S4r3e976eUnPdU+NbdtmBuLncYir2tMU9Nw==}
engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
'@esbuild/linux-arm64@0.28.0':
resolution: {integrity: sha512-RVyzfb3FWsGA55n6WY0MEIEPURL1FcbhFE6BffZEMEekfCzCIMtB5yyDcFnVbTnwk+CLAgTujmV/Lgvih56W+A==}
engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
'@esbuild/linux-arm@0.28.0':
resolution: {integrity: sha512-CjaaREJagqJp7iTaNQjjidaNbCKYcd4IDkzbwwxtSvjI7NZm79qiHc8HqciMddQ6CKvJT6aBd8lO9kN/ZudLlw==}
engines: {node: '>=18'}
cpu: [arm]
os: [linux]
'@esbuild/linux-ia32@0.28.0':
resolution: {integrity: sha512-KBnSTt1kxl9x70q+ydterVdl+Cn0H18ngRMRCEQfrbqdUuntQQ0LoMZv47uB97NljZFzY6HcfqEZ2SAyIUTQBQ==}
engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
'@esbuild/linux-loong64@0.28.0':
resolution: {integrity: sha512-zpSlUce1mnxzgBADvxKXX5sl8aYQHo2ezvMNI8I0lbblJtp8V4odlm3Yzlj7gPyt3T8ReksE6bK+pT3WD+aJRg==}
engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
'@esbuild/linux-mips64el@0.28.0':
resolution: {integrity: sha512-2jIfP6mmjkdmeTlsX/9vmdmhBmKADrWqN7zcdtHIeNSCH1SqIoNI63cYsjQR8J+wGa4Y5izRcSHSm8K3QWmk3w==}
engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
'@esbuild/linux-ppc64@0.28.0':
resolution: {integrity: sha512-bc0FE9wWeC0WBm49IQMPSPILRocGTQt3j5KPCA8os6VprfuJ7KD+5PzESSrJ6GmPIPJK965ZJHTUlSA6GNYEhg==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
'@esbuild/linux-riscv64@0.28.0':
resolution: {integrity: sha512-SQPZOwoTTT/HXFXQJG/vBX8sOFagGqvZyXcgLA3NhIqcBv1BJU1d46c0rGcrij2B56Z2rNiSLaZOYW5cUk7yLQ==}
engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
'@esbuild/linux-s390x@0.28.0':
resolution: {integrity: sha512-SCfR0HN8CEEjnYnySJTd2cw0k9OHB/YFzt5zgJEwa+wL/T/raGWYMBqwDNAC6dqFKmJYZoQBRfHjgwLHGSrn3Q==}
engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
'@esbuild/linux-x64@0.28.0':
resolution: {integrity: sha512-us0dSb9iFxIi8srnpl931Nvs65it/Jd2a2K3qs7fz2WfGPHqzfzZTfec7oxZJRNPXPnNYZtanmRc4AL/JwVzHQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [linux]
'@esbuild/netbsd-arm64@0.28.0':
resolution: {integrity: sha512-CR/RYotgtCKwtftMwJlUU7xCVNg3lMYZ0RzTmAHSfLCXw3NtZtNpswLEj/Kkf6kEL3Gw+BpOekRX0BYCtklhUw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [netbsd]
'@esbuild/netbsd-x64@0.28.0':
resolution: {integrity: sha512-nU1yhmYutL+fQ71Kxnhg8uEOdC0pwEW9entHykTgEbna2pw2dkbFSMeqjjyHZoCmt8SBkOSvV+yNmm94aUrrqw==}
engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
'@esbuild/openbsd-arm64@0.28.0':
resolution: {integrity: sha512-cXb5vApOsRsxsEl4mcZ1XY3D4DzcoMxR/nnc4IyqYs0rTI8ZKmW6kyyg+11Z8yvgMfAEldKzP7AdP64HnSC/6g==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openbsd]
'@esbuild/openbsd-x64@0.28.0':
resolution: {integrity: sha512-8wZM2qqtv9UP3mzy7HiGYNH/zjTA355mpeuA+859TyR+e+Tc08IHYpLJuMsfpDJwoLo1ikIJI8jC3GFjnRClzA==}
engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
'@esbuild/openharmony-arm64@0.28.0':
resolution: {integrity: sha512-FLGfyizszcef5C3YtoyQDACyg95+dndv79i2EekILBofh5wpCa1KuBqOWKrEHZg3zrL3t5ouE5jgr94vA+Wb2w==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openharmony]
'@esbuild/sunos-x64@0.28.0':
resolution: {integrity: sha512-1ZgjUoEdHZZl/YlV76TSCz9Hqj9h9YmMGAgAPYd+q4SicWNX3G5GCyx9uhQWSLcbvPW8Ni7lj4gDa1T40akdlw==}
engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
'@esbuild/win32-arm64@0.28.0':
resolution: {integrity: sha512-Q9StnDmQ/enxnpxCCLSg0oo4+34B9TdXpuyPeTedN/6+iXBJ4J+zwfQI28u/Jl40nOYAxGoNi7mFP40RUtkmUA==}
engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
'@esbuild/win32-ia32@0.28.0':
resolution: {integrity: sha512-zF3ag/gfiCe6U2iczcRzSYJKH1DCI+ByzSENHlM2FcDbEeo5Zd2C86Aq0tKUYAJJ1obRP84ymxIAksZUcdztHA==}
engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
'@esbuild/win32-x64@0.28.0':
resolution: {integrity: sha512-pEl1bO9mfAmIC+tW5btTmrKaujg3zGtUmWNdCw/xs70FBjwAL3o9OEKNHvNmnyylD6ubxUERiEhdsL0xBQ9efw==}
engines: {node: '>=18'}
cpu: [x64]
os: [win32]
'@inquirer/ansi@1.0.2':
resolution: {integrity: sha512-S8qNSZiYzFd0wAcyG5AXCvUHC5Sr7xpZ9wZ2py9XR88jUz8wooStVx5M6dRzczbBWjic9NP7+rY0Xi7qqK/aMQ==}
engines: {node: '>=18'}
'@inquirer/checkbox@4.3.2':
resolution: {integrity: sha512-VXukHf0RR1doGe6Sm4F0Em7SWYLTHSsbGfJdS9Ja2bX5/D5uwVOEjr07cncLROdBvmnvCATYEWlHqYmXv2IlQA==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/confirm@5.1.21':
resolution: {integrity: sha512-KR8edRkIsUayMXV+o3Gv+q4jlhENF9nMYUZs9PA2HzrXeHI8M5uDag70U7RJn9yyiMZSbtF5/UexBtAVtZGSbQ==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/core@10.3.2':
resolution: {integrity: sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/editor@4.2.23':
resolution: {integrity: sha512-aLSROkEwirotxZ1pBaP8tugXRFCxW94gwrQLxXfrZsKkfjOYC1aRvAZuhpJOb5cu4IBTJdsCigUlf2iCOu4ZDQ==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/expand@4.0.23':
resolution: {integrity: sha512-nRzdOyFYnpeYTTR2qFwEVmIWypzdAx/sIkCMeTNTcflFOovfqUk+HcFhQQVBftAh9gmGrpFj6QcGEqrDMDOiew==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/external-editor@1.0.3':
resolution: {integrity: sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/figures@1.0.15':
resolution: {integrity: sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g==}
engines: {node: '>=18'}
'@inquirer/input@4.3.1':
resolution: {integrity: sha512-kN0pAM4yPrLjJ1XJBjDxyfDduXOuQHrBB8aLDMueuwUGn+vNpF7Gq7TvyVxx8u4SHlFFj4trmj+a2cbpG4Jn1g==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/number@3.0.23':
resolution: {integrity: sha512-5Smv0OK7K0KUzUfYUXDXQc9jrf8OHo4ktlEayFlelCjwMXz0299Y8OrI+lj7i4gCBY15UObk76q0QtxjzFcFcg==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/password@4.0.23':
resolution: {integrity: sha512-zREJHjhT5vJBMZX/IUbyI9zVtVfOLiTO66MrF/3GFZYZ7T4YILW5MSkEYHceSii/KtRk+4i3RE7E1CUXA2jHcA==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/prompts@7.10.1':
resolution: {integrity: sha512-Dx/y9bCQcXLI5ooQ5KyvA4FTgeo2jYj/7plWfV5Ak5wDPKQZgudKez2ixyfz7tKXzcJciTxqLeK7R9HItwiByg==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/rawlist@4.1.11':
resolution: {integrity: sha512-+LLQB8XGr3I5LZN/GuAHo+GpDJegQwuPARLChlMICNdwW7OwV2izlCSCxN6cqpL0sMXmbKbFcItJgdQq5EBXTw==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/search@3.2.2':
resolution: {integrity: sha512-p2bvRfENXCZdWF/U2BXvnSI9h+tuA8iNqtUKb9UWbmLYCRQxd8WkvwWvYn+3NgYaNwdUkHytJMGG4MMLucI1kA==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/select@4.4.2':
resolution: {integrity: sha512-l4xMuJo55MAe+N7Qr4rX90vypFwCajSakx59qe/tMaC1aEHWLyw68wF4o0A4SLAY4E0nd+Vt+EyskeDIqu1M6w==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@inquirer/type@3.0.10':
resolution: {integrity: sha512-BvziSRxfz5Ov8ch0z/n3oijRSEcEsHnhggm4xFZe93DHcUCTlutlq9Ox4SVENAfcRD22UQq7T/atg9Wr3k09eA==}
engines: {node: '>=18'}
peerDependencies:
'@types/node': '>=18'
peerDependenciesMeta:
'@types/node':
optional: true
'@types/node@22.19.20':
resolution: {integrity: sha512-6tELRwSDYWW9EdZhbeZmYGZ1/7Djkt+Ah3/ScEYT9cDord7UJzasR/4D3VONg9tQI5CDp+/CZC1AXj2pCFOvpw==}
'@types/tinycolor2@1.4.6':
resolution: {integrity: sha512-iEN8J0BoMnsWBqjVbWH/c0G0Hh7O21lpR2/+PrvAVgWdzL7eexIFm4JN/Wn10PTcmNdtS6U67r499mlWMXOxNw==}
ansi-align@3.0.1:
resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==}
ansi-regex@5.0.1:
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
engines: {node: '>=8'}
ansi-regex@6.2.2:
resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==}
engines: {node: '>=12'}
ansi-styles@4.3.0:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
ansi-styles@6.2.3:
resolution: {integrity: sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==}
engines: {node: '>=12'}
boxen@8.0.1:
resolution: {integrity: sha512-F3PH5k5juxom4xktynS7MoFY+NUWH5LC4CnH11YB8NPew+HLpmBLCybSAEyb2F+4pRXhuhWqFesoQd6DAyc2hw==}
engines: {node: '>=18'}
camelcase@8.0.0:
resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==}
engines: {node: '>=16'}
chalk@5.6.2:
resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
chardet@2.1.1:
resolution: {integrity: sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==}
cli-boxes@3.0.0:
resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==}
engines: {node: '>=10'}
cli-cursor@5.0.0:
resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==}
engines: {node: '>=18'}
cli-spinners@2.9.2:
resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==}
engines: {node: '>=6'}
cli-table3@0.6.5:
resolution: {integrity: sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==}
engines: {node: 10.* || >= 12.*}
cli-width@4.1.0:
resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==}
engines: {node: '>= 12'}
color-convert@2.0.1:
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
engines: {node: '>=7.0.0'}
color-name@1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
emoji-regex@10.6.0:
resolution: {integrity: sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==}
emoji-regex@8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
esbuild@0.28.0:
resolution: {integrity: sha512-sNR9MHpXSUV/XB4zmsFKN+QgVG82Cc7+/aaxJ8Adi8hyOac+EXptIp45QBPaVyX3N70664wRbTcLTOemCAnyqw==}
engines: {node: '>=18'}
hasBin: true
fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
get-east-asian-width@1.6.0:
resolution: {integrity: sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA==}
engines: {node: '>=18'}
gradient-string@3.0.0:
resolution: {integrity: sha512-frdKI4Qi8Ihp4C6wZNB565de/THpIaw3DjP5ku87M+N9rNSGmPTjfkq61SdRXB7eCaL8O1hkKDvf6CDMtOzIAg==}
engines: {node: '>=14'}
iconv-lite@0.7.2:
resolution: {integrity: sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==}
engines: {node: '>=0.10.0'}
is-fullwidth-code-point@3.0.0:
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
is-interactive@2.0.0:
resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==}
engines: {node: '>=12'}
is-unicode-supported@1.3.0:
resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==}
engines: {node: '>=12'}
is-unicode-supported@2.1.0:
resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==}
engines: {node: '>=18'}
log-symbols@6.0.0:
resolution: {integrity: sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==}
engines: {node: '>=18'}
mimic-function@5.0.1:
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
engines: {node: '>=18'}
mute-stream@2.0.0:
resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==}
engines: {node: ^18.17.0 || >=20.5.0}
onetime@7.0.0:
resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==}
engines: {node: '>=18'}
ora@8.2.0:
resolution: {integrity: sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==}
engines: {node: '>=18'}
restore-cursor@5.1.0:
resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==}
engines: {node: '>=18'}
safer-buffer@2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
signal-exit@4.1.0:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
stdin-discarder@0.2.2:
resolution: {integrity: sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==}
engines: {node: '>=18'}
string-width@4.2.3:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
string-width@7.2.0:
resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==}
engines: {node: '>=18'}
strip-ansi@6.0.1:
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
engines: {node: '>=8'}
strip-ansi@7.2.0:
resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==}
engines: {node: '>=12'}
tinycolor2@1.6.0:
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
tinygradient@1.1.5:
resolution: {integrity: sha512-8nIfc2vgQ4TeLnk2lFj4tRLvvJwEfQuabdsmvDdQPT0xlk9TaNtpGd6nNRxXoK6vQhN6RSzj+Cnp5tTQmpxmbw==}
tsx@4.22.4:
resolution: {integrity: sha512-X8EX+XV4QR5xCsrgxaED954zTDfY8KqlDtskKEL0cHhyS/P8b4IFOvGDQpsC9Q1XnLq915wEfwwY/zzskCtmhg==}
engines: {node: '>=18.0.0'}
hasBin: true
type-fest@4.41.0:
resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==}
engines: {node: '>=16'}
typescript@5.9.3:
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
engines: {node: '>=14.17'}
hasBin: true
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
widest-line@5.0.0:
resolution: {integrity: sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==}
engines: {node: '>=18'}
wrap-ansi@6.2.0:
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
engines: {node: '>=8'}
wrap-ansi@9.0.2:
resolution: {integrity: sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==}
engines: {node: '>=18'}
yoctocolors-cjs@2.1.3:
resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==}
engines: {node: '>=18'}
snapshots:
'@colors/colors@1.5.0':
optional: true
'@esbuild/aix-ppc64@0.28.0':
optional: true
'@esbuild/android-arm64@0.28.0':
optional: true
'@esbuild/android-arm@0.28.0':
optional: true
'@esbuild/android-x64@0.28.0':
optional: true
'@esbuild/darwin-arm64@0.28.0':
optional: true
'@esbuild/darwin-x64@0.28.0':
optional: true
'@esbuild/freebsd-arm64@0.28.0':
optional: true
'@esbuild/freebsd-x64@0.28.0':
optional: true
'@esbuild/linux-arm64@0.28.0':
optional: true
'@esbuild/linux-arm@0.28.0':
optional: true
'@esbuild/linux-ia32@0.28.0':
optional: true
'@esbuild/linux-loong64@0.28.0':
optional: true
'@esbuild/linux-mips64el@0.28.0':
optional: true
'@esbuild/linux-ppc64@0.28.0':
optional: true
'@esbuild/linux-riscv64@0.28.0':
optional: true
'@esbuild/linux-s390x@0.28.0':
optional: true
'@esbuild/linux-x64@0.28.0':
optional: true
'@esbuild/netbsd-arm64@0.28.0':
optional: true
'@esbuild/netbsd-x64@0.28.0':
optional: true
'@esbuild/openbsd-arm64@0.28.0':
optional: true
'@esbuild/openbsd-x64@0.28.0':
optional: true
'@esbuild/openharmony-arm64@0.28.0':
optional: true
'@esbuild/sunos-x64@0.28.0':
optional: true
'@esbuild/win32-arm64@0.28.0':
optional: true
'@esbuild/win32-ia32@0.28.0':
optional: true
'@esbuild/win32-x64@0.28.0':
optional: true
'@inquirer/ansi@1.0.2': {}
'@inquirer/checkbox@4.3.2(@types/node@22.19.20)':
dependencies:
'@inquirer/ansi': 1.0.2
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/figures': 1.0.15
'@inquirer/type': 3.0.10(@types/node@22.19.20)
yoctocolors-cjs: 2.1.3
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/confirm@5.1.21(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/core@10.3.2(@types/node@22.19.20)':
dependencies:
'@inquirer/ansi': 1.0.2
'@inquirer/figures': 1.0.15
'@inquirer/type': 3.0.10(@types/node@22.19.20)
cli-width: 4.1.0
mute-stream: 2.0.0
signal-exit: 4.1.0
wrap-ansi: 6.2.0
yoctocolors-cjs: 2.1.3
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/editor@4.2.23(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/external-editor': 1.0.3(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/expand@4.0.23(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
yoctocolors-cjs: 2.1.3
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/external-editor@1.0.3(@types/node@22.19.20)':
dependencies:
chardet: 2.1.1
iconv-lite: 0.7.2
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/figures@1.0.15': {}
'@inquirer/input@4.3.1(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/number@3.0.23(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/password@4.0.23(@types/node@22.19.20)':
dependencies:
'@inquirer/ansi': 1.0.2
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/prompts@7.10.1(@types/node@22.19.20)':
dependencies:
'@inquirer/checkbox': 4.3.2(@types/node@22.19.20)
'@inquirer/confirm': 5.1.21(@types/node@22.19.20)
'@inquirer/editor': 4.2.23(@types/node@22.19.20)
'@inquirer/expand': 4.0.23(@types/node@22.19.20)
'@inquirer/input': 4.3.1(@types/node@22.19.20)
'@inquirer/number': 3.0.23(@types/node@22.19.20)
'@inquirer/password': 4.0.23(@types/node@22.19.20)
'@inquirer/rawlist': 4.1.11(@types/node@22.19.20)
'@inquirer/search': 3.2.2(@types/node@22.19.20)
'@inquirer/select': 4.4.2(@types/node@22.19.20)
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/rawlist@4.1.11(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/type': 3.0.10(@types/node@22.19.20)
yoctocolors-cjs: 2.1.3
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/search@3.2.2(@types/node@22.19.20)':
dependencies:
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/figures': 1.0.15
'@inquirer/type': 3.0.10(@types/node@22.19.20)
yoctocolors-cjs: 2.1.3
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/select@4.4.2(@types/node@22.19.20)':
dependencies:
'@inquirer/ansi': 1.0.2
'@inquirer/core': 10.3.2(@types/node@22.19.20)
'@inquirer/figures': 1.0.15
'@inquirer/type': 3.0.10(@types/node@22.19.20)
yoctocolors-cjs: 2.1.3
optionalDependencies:
'@types/node': 22.19.20
'@inquirer/type@3.0.10(@types/node@22.19.20)':
optionalDependencies:
'@types/node': 22.19.20
'@types/node@22.19.20':
dependencies:
undici-types: 6.21.0
'@types/tinycolor2@1.4.6': {}
ansi-align@3.0.1:
dependencies:
string-width: 4.2.3
ansi-regex@5.0.1: {}
ansi-regex@6.2.2: {}
ansi-styles@4.3.0:
dependencies:
color-convert: 2.0.1
ansi-styles@6.2.3: {}
boxen@8.0.1:
dependencies:
ansi-align: 3.0.1
camelcase: 8.0.0
chalk: 5.6.2
cli-boxes: 3.0.0
string-width: 7.2.0
type-fest: 4.41.0
widest-line: 5.0.0
wrap-ansi: 9.0.2
camelcase@8.0.0: {}
chalk@5.6.2: {}
chardet@2.1.1: {}
cli-boxes@3.0.0: {}
cli-cursor@5.0.0:
dependencies:
restore-cursor: 5.1.0
cli-spinners@2.9.2: {}
cli-table3@0.6.5:
dependencies:
string-width: 4.2.3
optionalDependencies:
'@colors/colors': 1.5.0
cli-width@4.1.0: {}
color-convert@2.0.1:
dependencies:
color-name: 1.1.4
color-name@1.1.4: {}
emoji-regex@10.6.0: {}
emoji-regex@8.0.0: {}
esbuild@0.28.0:
optionalDependencies:
'@esbuild/aix-ppc64': 0.28.0
'@esbuild/android-arm': 0.28.0
'@esbuild/android-arm64': 0.28.0
'@esbuild/android-x64': 0.28.0
'@esbuild/darwin-arm64': 0.28.0
'@esbuild/darwin-x64': 0.28.0
'@esbuild/freebsd-arm64': 0.28.0
'@esbuild/freebsd-x64': 0.28.0
'@esbuild/linux-arm': 0.28.0
'@esbuild/linux-arm64': 0.28.0
'@esbuild/linux-ia32': 0.28.0
'@esbuild/linux-loong64': 0.28.0
'@esbuild/linux-mips64el': 0.28.0
'@esbuild/linux-ppc64': 0.28.0
'@esbuild/linux-riscv64': 0.28.0
'@esbuild/linux-s390x': 0.28.0
'@esbuild/linux-x64': 0.28.0
'@esbuild/netbsd-arm64': 0.28.0
'@esbuild/netbsd-x64': 0.28.0
'@esbuild/openbsd-arm64': 0.28.0
'@esbuild/openbsd-x64': 0.28.0
'@esbuild/openharmony-arm64': 0.28.0
'@esbuild/sunos-x64': 0.28.0
'@esbuild/win32-arm64': 0.28.0
'@esbuild/win32-ia32': 0.28.0
'@esbuild/win32-x64': 0.28.0
fsevents@2.3.3:
optional: true
get-east-asian-width@1.6.0: {}
gradient-string@3.0.0:
dependencies:
chalk: 5.6.2
tinygradient: 1.1.5
iconv-lite@0.7.2:
dependencies:
safer-buffer: 2.1.2
is-fullwidth-code-point@3.0.0: {}
is-interactive@2.0.0: {}
is-unicode-supported@1.3.0: {}
is-unicode-supported@2.1.0: {}
log-symbols@6.0.0:
dependencies:
chalk: 5.6.2
is-unicode-supported: 1.3.0
mimic-function@5.0.1: {}
mute-stream@2.0.0: {}
onetime@7.0.0:
dependencies:
mimic-function: 5.0.1
ora@8.2.0:
dependencies:
chalk: 5.6.2
cli-cursor: 5.0.0
cli-spinners: 2.9.2
is-interactive: 2.0.0
is-unicode-supported: 2.1.0
log-symbols: 6.0.0
stdin-discarder: 0.2.2
string-width: 7.2.0
strip-ansi: 7.2.0
restore-cursor@5.1.0:
dependencies:
onetime: 7.0.0
signal-exit: 4.1.0
safer-buffer@2.1.2: {}
signal-exit@4.1.0: {}
stdin-discarder@0.2.2: {}
string-width@4.2.3:
dependencies:
emoji-regex: 8.0.0
is-fullwidth-code-point: 3.0.0
strip-ansi: 6.0.1
string-width@7.2.0:
dependencies:
emoji-regex: 10.6.0
get-east-asian-width: 1.6.0
strip-ansi: 7.2.0
strip-ansi@6.0.1:
dependencies:
ansi-regex: 5.0.1
strip-ansi@7.2.0:
dependencies:
ansi-regex: 6.2.2
tinycolor2@1.6.0: {}
tinygradient@1.1.5:
dependencies:
'@types/tinycolor2': 1.4.6
tinycolor2: 1.6.0
tsx@4.22.4:
dependencies:
esbuild: 0.28.0
optionalDependencies:
fsevents: 2.3.3
type-fest@4.41.0: {}
typescript@5.9.3: {}
undici-types@6.21.0: {}
widest-line@5.0.0:
dependencies:
string-width: 7.2.0
wrap-ansi@6.2.0:
dependencies:
ansi-styles: 4.3.0
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi@9.0.2:
dependencies:
ansi-styles: 6.2.3
string-width: 7.2.0
strip-ansi: 7.2.0
yoctocolors-cjs@2.1.3: {}
+79
View File
@@ -0,0 +1,79 @@
import { loadConfig, resolveApiUrl, resolveToken } from '../config.js';
import { runSpinner } from '../ui/render.js';
export class ApiError extends Error {
constructor(
message: string,
public status?: number,
) {
super(message);
}
}
async function parseError(res: Response): Promise<string> {
try {
const body = await res.json();
if (typeof body?.message === 'string') return body.message;
if (Array.isArray(body?.message)) return body.message.join(', ');
return JSON.stringify(body);
} catch {
return res.statusText || `HTTP ${res.status}`;
}
}
export async function apiRequest<T>(
method: string,
path: string,
body?: unknown,
auth = true,
): Promise<T> {
const config = await loadConfig();
const baseUrl = resolveApiUrl(undefined, config);
const token = resolveToken(undefined, config);
const headers: Record<string, string> = {
'Content-Type': 'application/json',
Accept: 'application/json',
};
if (auth && token) {
headers.Authorization = `Bearer ${token}`;
}
const doFetch = async () => {
const res = await fetch(`${baseUrl}/api${path}`, {
method,
headers,
body: body !== undefined ? JSON.stringify(body) : undefined,
});
if (!res.ok) {
throw new ApiError(await parseError(res), res.status);
}
if (res.status === 204) return undefined as T;
const contentType = res.headers.get('content-type') || '';
if (contentType.includes('application/json')) {
return (await res.json()) as T;
}
return (await res.text()) as T;
};
return runSpinner(doFetch, '请求中...');
}
export async function apiDownload(path: string, outfile: string): Promise<string> {
const config = await loadConfig();
const baseUrl = resolveApiUrl(undefined, config);
const token = resolveToken(undefined, config);
const doFetch = async () => {
const res = await fetch(`${baseUrl}/api${path}`, {
headers: token ? { Authorization: `Bearer ${token}` } : {},
});
if (!res.ok) throw new ApiError(await parseError(res), res.status);
const { writeFile } = await import('fs/promises');
const text = await res.text();
await writeFile(outfile, text, 'utf8');
return outfile;
};
return runSpinner(doFetch, '正在下载...');
}
@@ -0,0 +1,124 @@
import { confirm, input, select } from '@inquirer/prompts';
import { apiRequest } from '../api/client.js';
import { printEmptyHint, printSuccess, printTable } from '../ui/render.js';
async function pause() {
await input({ message: '按 Enter 返回' });
}
interface Customer {
id: number;
code: string;
name: string;
status: number;
contactName?: string;
contactPhone?: string;
}
interface PageResult<T> {
items: T[];
total: number;
page: number;
size: number;
}
async function customerList() {
const data = await apiRequest<PageResult<Customer>>('GET', '/customers?page=1&size=20');
if (!data.items.length) {
printEmptyHint('创建客户');
return;
}
printTable(
['ID', 'CODE', 'NAME', 'STATUS'],
data.items.map((c) => [
String(c.id),
c.code,
c.name,
c.status === 1 ? '启用' : '禁用',
]),
);
const totalPages = Math.ceil(data.total / data.size) || 1;
console.log(`共 ${data.total} 条 · 第 ${data.page}/${totalPages} 页`);
}
async function customerCreate() {
const name = await input({ message: '公司名称', validate: (v) => !!v || '必填' });
const contactName = await input({ message: '联系人', default: '' });
const contactPhone = await input({ message: '联系电话', default: '' });
const contactEmail = await input({ message: '联系邮箱', default: '' });
let code = await input({ message: '客户编码(留空自动生成)', default: '' });
if (!code) code = undefined as any;
const created = await apiRequest<Customer>('POST', '/customers', {
name,
contactName,
contactPhone,
contactEmail,
code,
});
printSuccess(`客户已创建: ${created.code} · ${created.name}`);
}
async function customerShow() {
const id = await input({ message: '客户 ID', validate: (v) => /^\d+$/.test(v) || '请输入数字' });
const customer = await apiRequest<Customer>('GET', `/customers/${Number(id)}`);
printTable(
['ID', 'CODE', 'NAME', 'STATUS', '联系人', '电话'],
[[
String(customer.id),
customer.code,
customer.name,
customer.status === 1 ? '启用' : '禁用',
customer.contactName || '-',
customer.contactPhone || '-',
]],
);
}
async function customerDelete() {
const id = await input({ message: '客户 ID', validate: (v) => /^\d+$/.test(v) || '请输入数字' });
const ok = await confirm({ message: `确认删除客户 #${id}?`, default: false });
if (!ok) return;
await apiRequest('DELETE', `/customers/${Number(id)}`);
printSuccess(`客户 #${id} 已删除`);
}
export async function customerMenu() {
console.clear();
const action = await select({
message: '客户管理',
choices: [
{ name: '列表', value: 'list' },
{ name: '创建', value: 'create' },
{ name: '查看', value: 'show' },
{ name: '删除', value: 'delete' },
{ name: '返回主菜单', value: 'back' },
],
});
switch (action) {
case 'list':
console.clear();
await customerList();
await pause();
break;
case 'create':
console.clear();
await customerCreate();
await pause();
break;
case 'show':
console.clear();
await customerShow();
await pause();
break;
case 'delete':
console.clear();
await customerDelete();
await pause();
break;
}
}
@@ -0,0 +1,261 @@
import { checkbox, confirm, input, search, select } from '@inquirer/prompts';
import { apiRequest, apiDownload } from '../api/client.js';
import { printBox, printEmptyHint, printSuccess, printTable } from '../ui/render.js';
async function pause() {
await input({ message: '按 Enter 返回' });
}
interface Customer {
id: number;
code: string;
name: string;
}
interface License {
id: number;
jti: string;
edition: string;
machineFingerprint: string;
status: string;
expiresAt: string;
licenseKey?: string;
customer?: Customer;
}
interface PageResult<T> {
items: T[];
total: number;
page: number;
size: number;
}
interface GenerateResult {
id: number;
licenseKey: string;
jti: string;
edition: string;
machineFingerprint: string;
maxCompanies: number | null;
expiresAt: string;
status: string;
}
async function licenseList() {
const data = await apiRequest<PageResult<License>>('GET', '/licenses?page=1&size=20');
if (!data.items.length) {
printEmptyHint('签发许可证');
return;
}
printTable(
['ID', 'JTI', 'EDITION', 'FINGERPRINT', 'STATUS', 'EXPIRES'],
data.items.map((l) => [
String(l.id),
l.jti.slice(0, 8) + '...',
l.edition,
l.machineFingerprint.slice(0, 16) + (l.machineFingerprint.length > 16 ? '...' : ''),
l.status,
l.expiresAt?.slice(0, 10) || '-',
]),
);
console.log(`共 ${data.total} 条`);
}
async function licenseShow() {
const id = await input({ message: '许可证 ID', validate: (v) => /^\d+$/.test(v) || '请输入数字' });
const license = await apiRequest<License>('GET', `/licenses/${Number(id)}`);
printBox(
`许可证 #${license.id}`,
[
`JTI: ${license.jti}`,
`版本: ${license.edition}`,
`指纹: ${license.machineFingerprint}`,
`状态: ${license.status}`,
`过期: ${license.expiresAt?.slice(0, 10) || '-'}`,
license.licenseKey ? `\n${license.licenseKey}` : '',
].join('\n'),
);
}
async function licenseGenerate() {
const customers = await apiRequest<PageResult<Customer>>('GET', '/customers?page=1&size=100');
if (!customers.items.length) {
console.error('暂无客户,请先创建客户');
return;
}
const customerId = await search({
message: '选择客户',
source: async (term) => {
const q = (term || '').toLowerCase();
return customers.items
.filter((c) => !q || c.name.toLowerCase().includes(q) || c.code.toLowerCase().includes(q))
.map((c) => ({ name: `${c.code} · ${c.name}`, value: c.id }));
},
});
const picked = customers.items.find((c) => c.id === customerId)!;
const company = await input({ message: '授权公司名', default: picked.name });
const fpMode = await select({
message: '机器指纹',
choices: [
{ name: '私有部署(输入 FP-xxx)', value: 'custom' },
{ name: 'SaaS 不限指纹 (*)', value: '*' },
],
});
const fingerprint =
fpMode === '*'
? '*'
: await input({
message: '机器指纹',
validate: (v) => v.startsWith('FP-') || v === '*' || '格式应为 FP-...',
});
const defaultMaxCompanies = fingerprint === '*' ? 100 : 2;
const maxCompaniesInput = await input({
message: `最大公司数量(默认 ${defaultMaxCompanies})`,
default: String(defaultMaxCompanies),
validate: (v) => /^\d+$/.test(v) || '请输入正整数',
});
const maxCompanies = Number(maxCompaniesInput);
const edition = await select({
message: '版本类型',
choices: [
{ name: 'trial · 试用', value: 'trial' },
{ name: 'enterprise · 企业', value: 'enterprise' },
{ name: 'unlimited · 无限', value: 'unlimited' },
],
});
const expireChoice = await select({
message: '有效期',
choices: [
{ name: '+30 天', value: '30d' },
{ name: '+1 年', value: '1y' },
{ name: '自定义日期', value: 'custom' },
],
});
let expiresAt: string;
if (expireChoice === 'custom') {
expiresAt = await input({
message: '过期日期 (YYYY-MM-DD)',
validate: (v) => /^\d{4}-\d{2}-\d{2}$/.test(v) || '格式 YYYY-MM-DD',
});
} else {
const d = new Date();
if (expireChoice === '30d') d.setDate(d.getDate() + 30);
else d.setFullYear(d.getFullYear() + 1);
expiresAt = d.toISOString().slice(0, 10);
}
const features = await checkbox({
message: '授权功能',
choices: [
{ name: 'order-import · 订单导入', value: 'order-import', checked: true },
{ name: 'order-create · 创建订单', value: 'order-create', checked: true },
],
});
const summary = [
`客户 ID: ${customerId}`,
`公司: ${company}`,
`指纹: ${fingerprint}`,
`最大公司数: ${maxCompanies}`,
`版本: ${edition}`,
`过期: ${expiresAt}`,
`功能: ${features.join(', ')}`,
].join('\n');
const ok = await confirm({ message: `确认签发?\n${summary}`, default: true });
if (!ok) return;
const result = await apiRequest<GenerateResult>('POST', '/licenses/generate', {
customerId,
company,
machineFingerprint: fingerprint,
edition,
expiresAt: new Date(expiresAt).toISOString(),
features,
maxCompanies,
});
printBox(
'签发成功',
[
`ID: ${result.id}`,
`JTI: ${result.jti}`,
`最大公司数: ${result.maxCompanies ?? (fingerprint === '*' ? 100 : 2)}`,
`过期: ${result.expiresAt?.slice(0, 10)}`,
'',
result.licenseKey,
].join('\n'),
'green',
);
}
async function licenseRevoke() {
const id = await input({ message: '许可证 ID', validate: (v) => /^\d+$/.test(v) || '请输入数字' });
const license = await apiRequest<License>('GET', `/licenses/${Number(id)}`);
const ok = await confirm({
message: `确认吊销?\nJTI: ${license.jti}\n指纹: ${license.machineFingerprint}`,
default: false,
});
if (!ok) return;
await apiRequest('POST', `/licenses/${id}/revoke`);
printSuccess(`许可证 #${id} 已吊销`);
}
async function licenseDownload() {
const id = await input({ message: '许可证 ID', validate: (v) => /^\d+$/.test(v) || '请输入数字' });
const outfile = `license-${id}.key`;
const path = await apiDownload(`/licenses/${id}/download`, outfile);
printSuccess(`已保存到 ${path}`);
}
export async function licenseMenu() {
console.clear();
const action = await select({
message: '许可证管理',
choices: [
{ name: '列表', value: 'list' },
{ name: '查看', value: 'show' },
{ name: '签发', value: 'generate' },
{ name: '吊销', value: 'revoke' },
{ name: '下载', value: 'download' },
{ name: '返回主菜单', value: 'back' },
],
});
switch (action) {
case 'list':
console.clear();
await licenseList();
await pause();
break;
case 'show':
console.clear();
await licenseShow();
await pause();
break;
case 'generate':
console.clear();
await licenseGenerate();
await pause();
break;
case 'revoke':
console.clear();
await licenseRevoke();
await pause();
break;
case 'download':
console.clear();
await licenseDownload();
await pause();
break;
}
}
@@ -0,0 +1,52 @@
import { input, password } from '@inquirer/prompts';
import { apiRequest } from '../api/client.js';
import { loadConfig, resolveApiUrl, saveConfig } from '../config.js';
import { printError, printSuccess } from '../ui/render.js';
interface LoginResult {
token: string;
username: string;
expiresAt: string | null;
}
export async function loginCommand(opts: { url?: string; username?: string; password?: string }) {
const config = await loadConfig();
const apiUrl = resolveApiUrl(opts.url, config);
let username = opts.username || process.env.ECOM_LICENSE_USERNAME;
let pass = opts.password || process.env.ECOM_LICENSE_PASSWORD;
if (!username) {
username = await input({ message: '用户名', default: username || 'admin' });
}
if (!pass) {
pass = await password({ message: '密码', mask: '*' });
}
if (!username || !pass) {
printError('请提供用户名和密码');
return;
}
try {
const result = await apiRequest<LoginResult>(
'POST',
'/auth/login',
{ username, password: pass },
false,
);
await saveConfig({
apiUrl,
token: result.token,
username: result.username,
expiresAt: result.expiresAt || undefined,
});
printSuccess(
`登录成功 · ${result.username}` +
(result.expiresAt ? ` · Token 有效期至 ${result.expiresAt.slice(0, 10)}` : ''),
);
} catch (e: any) {
printError(e?.message || '登录失败');
}
}
@@ -0,0 +1,7 @@
import { clearConfig } from '../config.js';
import { printSuccess } from '../ui/render.js';
export async function logoutCommand() {
await clearConfig();
printSuccess('已退出登录');
}
@@ -0,0 +1,24 @@
import { apiRequest } from '../api/client.js';
import { printBox } from '../ui/render.js';
interface Stats {
customerCount: number;
activeLicenseCount: number;
expiringSoonCount: number;
totalLicenses: number;
}
export async function statsCommand() {
const stats = await apiRequest<Stats>('GET', '/dashboard/stats');
printBox(
'平台概览',
[
`客户数: ${stats.customerCount}`,
`有效许可证: ${stats.activeLicenseCount}`,
`即将过期: ${stats.expiringSoonCount}`,
`许可证总数: ${stats.totalLicenses}`,
].join('\n'),
'green',
);
}
@@ -0,0 +1,21 @@
import { loadConfig, resolveApiUrl } from '../config.js';
import { printBox, printError } from '../ui/render.js';
export async function whoamiCommand() {
const config = await loadConfig();
const apiUrl = resolveApiUrl(undefined, config);
if (!config?.token) {
printError('未登录,请先登录');
return;
}
printBox(
'当前会话',
[
`API: ${apiUrl}`,
`用户: ${config?.username || '(未知)'}`,
`过期: ${config?.expiresAt || '-'}`,
].join('\n'),
);
}
+53
View File
@@ -0,0 +1,53 @@
import { mkdir, readFile, writeFile } from 'fs/promises';
import { homedir } from 'os';
import { dirname, join } from 'path';
export interface CliConfig {
apiUrl: string;
token?: string;
username?: string;
expiresAt?: string;
}
const DEFAULT_CONFIG_PATH = join(
homedir(),
'.config',
'ecom-license',
'config.json',
);
export function getConfigPath(): string {
return process.env.ECOM_LICENSE_CONFIG || DEFAULT_CONFIG_PATH;
}
export async function loadConfig(): Promise<CliConfig | null> {
try {
const raw = await readFile(getConfigPath(), 'utf8');
return JSON.parse(raw) as CliConfig;
} catch {
return null;
}
}
export async function saveConfig(config: CliConfig): Promise<void> {
const path = getConfigPath();
await mkdir(dirname(path), { recursive: true });
await writeFile(path, JSON.stringify(config, null, 2), 'utf8');
}
export async function clearConfig(): Promise<void> {
await saveConfig({ apiUrl: (await loadConfig())?.apiUrl || 'http://localhost:3100' });
}
export function resolveApiUrl(flagUrl?: string, config?: CliConfig | null): string {
return (
flagUrl ||
process.env.ECOM_LICENSE_API_URL ||
config?.apiUrl ||
'http://localhost:3100'
).replace(/\/$/, '');
}
export function resolveToken(flagToken?: string, config?: CliConfig | null): string | undefined {
return flagToken || process.env.ECOM_LICENSE_TOKEN || config?.token;
}
+3
View File
@@ -0,0 +1,3 @@
export function isInteractive(): boolean {
return Boolean(process.stdout.isTTY) && !process.env.CI;
}
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env node
import { input, select } from '@inquirer/prompts';
import { customerMenu } from './commands/customer.js';
import { licenseMenu } from './commands/license.js';
import { loginCommand } from './commands/login.js';
import { logoutCommand } from './commands/logout.js';
import { statsCommand } from './commands/stats.js';
import { whoamiCommand } from './commands/whoami.js';
import { loadConfig } from './config.js';
import { printBanner } from './ui/render.js';
async function mainMenu() {
console.clear();
printBanner();
const config = await loadConfig();
const isLoggedIn = Boolean(config?.token);
const choices: { name: string; value: string }[] = [];
if (!isLoggedIn) {
choices.push({ name: '登录', value: 'login' });
} else {
choices.push(
{ name: '当前会话', value: 'whoami' },
{ name: '客户管理', value: 'customer' },
{ name: '许可证管理', value: 'license' },
{ name: '平台统计', value: 'stats' },
{ name: '退出登录', value: 'logout' },
);
}
choices.push({ name: '退出', value: 'exit' });
const action = await select({
message: '主菜单',
choices,
pageSize: 10,
});
switch (action) {
case 'login':
console.clear();
await loginCommand({});
await input({ message: '按 Enter 返回' });
break;
case 'whoami':
console.clear();
await whoamiCommand();
await input({ message: '按 Enter 返回' });
break;
case 'customer':
await customerMenu();
break;
case 'license':
await licenseMenu();
break;
case 'stats':
console.clear();
await statsCommand();
await input({ message: '按 Enter 返回' });
break;
case 'logout':
console.clear();
await logoutCommand();
await input({ message: '按 Enter 返回' });
break;
case 'exit':
process.exit(0);
}
}
async function main() {
while (true) {
try {
await mainMenu();
} catch (e: any) {
if (e?.name === 'ExitPromptError') process.exit(0);
console.error(e?.message || e);
}
}
}
main();
+72
View File
@@ -0,0 +1,72 @@
import boxen from 'boxen';
import chalk from 'chalk';
import Table from 'cli-table3';
import gradient from 'gradient-string';
import ora, { type Ora } from 'ora';
export function printBanner() {
const title = gradient.pastel('Ecom License TUI');
console.log(
boxen(`${title}\n${chalk.gray('授权管理平台 · 运营端')}`, {
padding: 1,
borderColor: 'cyan',
borderStyle: 'round',
}),
);
}
export function printSuccess(msg: string) {
console.log(chalk.green('✔'), msg);
}
export function printError(msg: string) {
console.error(chalk.red('✖'), msg);
}
export function printInfo(msg: string) {
console.log(chalk.blue('ℹ'), msg);
}
export function printBox(title: string, content: string, borderColor: 'green' | 'cyan' | 'yellow' = 'cyan') {
console.log(
boxen(content, {
title: chalk.bold(title),
padding: 1,
borderColor,
}),
);
}
export function printTable(headers: string[], rows: string[][]) {
const table = new Table({ head: headers.map((h) => chalk.cyan(h)) });
rows.forEach((r) => table.push(r));
console.log(table.toString());
}
export function printEmptyHint(hint: string) {
console.log(chalk.yellow('暂无数据。'), chalk.gray(hint));
}
let activeSpinner: Ora | null = null;
export async function runSpinner<T>(fn: () => Promise<T>, text: string): Promise<T> {
const spinner = ora(text).start();
activeSpinner = spinner;
try {
const result = await fn();
spinner.succeed();
return result;
} catch (e) {
spinner.fail();
throw e;
} finally {
activeSpinner = null;
}
}
export function failSpinner(msg: string) {
if (activeSpinner) {
activeSpinner.fail(msg);
activeSpinner = null;
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": false
},
"include": ["src/**/*"]
}