@wkgeo/cli 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +208 -0
- package/LICENSE +21 -0
- package/README.md +1042 -3
- package/SKILL.md +927 -0
- package/lib/ai/client.mjs +161 -0
- package/lib/ai/config.mjs +221 -0
- package/lib/ai/context.mjs +468 -0
- package/lib/ai/log.mjs +53 -0
- package/lib/api.mjs +339 -0
- package/lib/args.mjs +235 -0
- package/lib/cli.mjs +168 -0
- package/lib/cms.mjs +330 -0
- package/lib/commands/ai.mjs +392 -0
- package/lib/commands/apps.mjs +116 -0
- package/lib/commands/auth.mjs +1288 -0
- package/lib/commands/billing.mjs +666 -0
- package/lib/commands/cms.mjs +2533 -0
- package/lib/commands/config-auth.mjs +621 -0
- package/lib/commands/config.mjs +434 -0
- package/lib/commands/dnscred.mjs +428 -0
- package/lib/commands/domainops.mjs +546 -0
- package/lib/commands/domainorder.mjs +439 -0
- package/lib/commands/import.mjs +164 -0
- package/lib/commands/index.mjs +528 -0
- package/lib/commands/logs.mjs +141 -0
- package/lib/commands/orders.mjs +444 -0
- package/lib/commands/overview.mjs +394 -0
- package/lib/commands/plugins.mjs +678 -0
- package/lib/commands/site.mjs +435 -0
- package/lib/commands/siteops.mjs +1012 -0
- package/lib/commands/sites.mjs +905 -0
- package/lib/commands/skill.mjs +119 -0
- package/lib/config.mjs +351 -0
- package/lib/credentials.mjs +160 -0
- package/lib/device-store.mjs +132 -0
- package/lib/device.mjs +464 -0
- package/lib/errors.mjs +299 -0
- package/lib/format.mjs +339 -0
- package/lib/http.mjs +71 -0
- package/lib/index.mjs +44 -0
- package/lib/local-import.mjs +185 -0
- package/lib/login.mjs +1638 -0
- package/lib/oauth-urls.mjs +163 -0
- package/lib/page.mjs +393 -0
- package/lib/pkce.mjs +48 -0
- package/lib/proxy.mjs +454 -0
- package/lib/qr.mjs +31 -0
- package/lib/runtime.mjs +650 -0
- package/lib/site-state.mjs +137 -0
- package/package.json +53 -4
- package/wkgeo.mjs +17 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 命令注册表 + 帮助文本。
|
|
3
|
+
*
|
|
4
|
+
* 为什么注册表要同时带着 `usage`/`flags`/`args`:
|
|
5
|
+
* * 解析器用它做校验(未知参数直接报错,不静默忽略)
|
|
6
|
+
* * `--help` 用它生成文本 —— **帮助与实际行为同源**,不会出现"文档写了但命令不支持"
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { GLOBAL_FLAGS } from '../args.mjs';
|
|
10
|
+
import {
|
|
11
|
+
loginCommand,
|
|
12
|
+
logoutCommand,
|
|
13
|
+
whoamiCommand,
|
|
14
|
+
configCommand,
|
|
15
|
+
authStatusCommand,
|
|
16
|
+
authTokenCommand,
|
|
17
|
+
authRevokeCommand,
|
|
18
|
+
} from './auth.mjs';
|
|
19
|
+
import { sitesListCommand, sitesGetCommand, sitesCreateCommand, sitesDeleteCommand } from './sites.mjs';
|
|
20
|
+
import {
|
|
21
|
+
siteUseCommand,
|
|
22
|
+
categoriesListCommand,
|
|
23
|
+
categoriesGetCommand,
|
|
24
|
+
categoriesCreateCommand,
|
|
25
|
+
categoriesUpdateCommand,
|
|
26
|
+
categoriesSaveCommand,
|
|
27
|
+
categoriesDeleteCommand,
|
|
28
|
+
categoriesBindTemplateCommand,
|
|
29
|
+
contentsListCommand,
|
|
30
|
+
contentsGetCommand,
|
|
31
|
+
contentsCreateCommand,
|
|
32
|
+
contentsUpdateCommand,
|
|
33
|
+
contentsSaveCommand,
|
|
34
|
+
contentsDeleteCommand,
|
|
35
|
+
assetsListCommand,
|
|
36
|
+
assetsUploadCommand,
|
|
37
|
+
assetsSignCommand,
|
|
38
|
+
assetsRegisterCommand,
|
|
39
|
+
assetsDeleteCommand,
|
|
40
|
+
assetsRestoreCommand,
|
|
41
|
+
templatesListCommand,
|
|
42
|
+
templatesGetCommand,
|
|
43
|
+
templatesSaveCommand,
|
|
44
|
+
publishCommand,
|
|
45
|
+
publishStatusCommand,
|
|
46
|
+
publishCancelCommand,
|
|
47
|
+
/**
|
|
48
|
+
* ★ task-68 / B3:发布类 16 条动作迁入 `wkgeo-cli-fc` 自持(走 `/cli`,不再借 `/cms`)。
|
|
49
|
+
* 命令面:`publish retry` / `publish jobs[ get|cancel]` / `publish targets[ save|delete|test]` /
|
|
50
|
+
* `publish push` / `publish storage[ save|verify|delete|publish]`。
|
|
51
|
+
*/
|
|
52
|
+
publishRetryCommand,
|
|
53
|
+
publishJobsCommand,
|
|
54
|
+
publishJobGetCommand,
|
|
55
|
+
publishJobCancelCommand,
|
|
56
|
+
publishTargetsCommand,
|
|
57
|
+
publishTargetsSaveCommand,
|
|
58
|
+
publishTargetsDeleteCommand,
|
|
59
|
+
publishTargetsTestCommand,
|
|
60
|
+
publishPushCommand,
|
|
61
|
+
publishStorageCommand,
|
|
62
|
+
publishStorageSaveCommand,
|
|
63
|
+
publishStorageVerifyCommand,
|
|
64
|
+
publishStorageDeleteCommand,
|
|
65
|
+
publishStoragePublishCommand,
|
|
66
|
+
} from './cms.mjs';
|
|
67
|
+
import {
|
|
68
|
+
formsListCommand,
|
|
69
|
+
formsEntriesCommand,
|
|
70
|
+
domainInspectionCommand,
|
|
71
|
+
domainBindCommand,
|
|
72
|
+
domainStatusCommand,
|
|
73
|
+
domainRecordsCommand,
|
|
74
|
+
domainDnsCommand,
|
|
75
|
+
domainCheckCommand,
|
|
76
|
+
domainRemindCommand,
|
|
77
|
+
previewCommand,
|
|
78
|
+
importV2StartCommand,
|
|
79
|
+
importV2StatusCommand,
|
|
80
|
+
} from './siteops.mjs';
|
|
81
|
+
import { aiPingCommand, aiAskCommand, aiChatCommand, contextExportCommand } from './ai.mjs';
|
|
82
|
+
import { importCommand } from './import.mjs';
|
|
83
|
+
import { walletCommand, walletTxnsCommand, walletRechargeCommand, walletRechargeLinkCommand } from './billing.mjs';
|
|
84
|
+
import {
|
|
85
|
+
productsListCommand,
|
|
86
|
+
ordersCreateCommand,
|
|
87
|
+
ordersCheckCommand,
|
|
88
|
+
ordersPayCommand,
|
|
89
|
+
ordersGetCommand,
|
|
90
|
+
ordersListCommand,
|
|
91
|
+
} from './orders.mjs';
|
|
92
|
+
import { appsListCommand, appsRevokeCommand } from './apps.mjs';
|
|
93
|
+
import { skillCommand } from './skill.mjs';
|
|
94
|
+
/**
|
|
95
|
+
* 自持成交链(2026-10-28 老板单):域名查价 / 下单 / 订单状态 / 云解析读写 / ESA 开通 / 建站收口。
|
|
96
|
+
* 全部打 `/cli`(自持 `wkgeo-cli-fc`),**不**复用 wkgeo-domain / cms 那套。
|
|
97
|
+
*/
|
|
98
|
+
import {
|
|
99
|
+
domainSearchCommand,
|
|
100
|
+
domainBuyCommand,
|
|
101
|
+
domainOrderCommand,
|
|
102
|
+
domainZoneListCommand,
|
|
103
|
+
domainZoneAddCommand,
|
|
104
|
+
domainZoneUpdateCommand,
|
|
105
|
+
domainZoneDeleteCommand,
|
|
106
|
+
esaSiteCommand,
|
|
107
|
+
esaRecordCommand,
|
|
108
|
+
esaHostnameCommand,
|
|
109
|
+
esaKvCommand,
|
|
110
|
+
siteCreateCommand,
|
|
111
|
+
} from './domainops.mjs';
|
|
112
|
+
/**
|
|
113
|
+
* 成品链路(task-21):在平台模板下注册 → 客户模板 → 收费 → 模板认证 → 快速过户。
|
|
114
|
+
* 与上面 12 条同住 `wkgeo-cli-fc`,同样走 `/cli`;命令名带三词(`domain order create`),
|
|
115
|
+
* 依赖 `lib/args.mjs#resolveCommand` 的最长前缀匹配。
|
|
116
|
+
*/
|
|
117
|
+
import { DOMAIN_ORDER_COMMANDS } from './domainorder.mjs';
|
|
118
|
+
/**
|
|
119
|
+
* 域名级 DNS 凭据(2026-10-28 老板单):`domain dns credential detect|set|status|delete`。
|
|
120
|
+
* 四词命令(`domain dns` 已被 siteops 的"照抄表"只读命令占用),依赖 `resolveCommand` 的最长前缀匹配。
|
|
121
|
+
* 秘密只从 stdin / 无回显交互读,**不进命令行**。
|
|
122
|
+
*/
|
|
123
|
+
import { DNS_CREDENTIAL_COMMANDS } from './dnscred.mjs';
|
|
124
|
+
/**
|
|
125
|
+
* ★ task-75 / B7:配置类 auth 面 11 条迁入 `wkgeo-cli-fc` 自持(走 `/cli`,不再借 `/cms`)。
|
|
126
|
+
* 命令面:`lang list|save|set-default|delete|toggle`、`role list|save|delete`、
|
|
127
|
+
* `member list|update|remove`(`memberAdd` / `userProfileUpdate` 复核结论是**不迁**)。
|
|
128
|
+
* 读 = `site:read`、改成员/语言 = `site:write`、改角色 = `role:write`(独立 scope)。
|
|
129
|
+
*/
|
|
130
|
+
import { CONFIG_AUTH_COMMANDS } from './config-auth.mjs';
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* ★ task-90(2026-10-29):站点类自持面 —— B4 7 条(公司信息 / 域名巡检重检 /
|
|
134
|
+
* 示例内容 / 站级同步)搬进 `wkgeo-cli-fc`(`src/site-core.js`,逐字复制 CMS handler)。
|
|
135
|
+
* 命令面:`site info`、`site info save`、`site domain-recheck`、`site demo-seed`、
|
|
136
|
+
* `site demo-clear`、`site sync`;`domain inspection` 也从 `/cms` 改走 `/cli`。
|
|
137
|
+
* 读 = `site:read`、写 = `site:write`,写动作默认 dry-run。
|
|
138
|
+
* **不迁 2 条**:`cmsCreateSite`(已有原生 `site create`)、`cmsSiteDomainCheck`
|
|
139
|
+
* (已有原生 `siteDomainCheck`,`wkgeo domain check` 在用)。
|
|
140
|
+
*/
|
|
141
|
+
import { SITE_COMMANDS } from './site.mjs';
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* ★ task-91(2026-10-29):插件类自持面 —— B5 9 条(插件列表 / 访问范围 / 启停 /
|
|
145
|
+
* 配置保存 / 市场列表 / 安装 / 卸载 / 升级 / 演示链接)搬进 `wkgeo-cli-fc`
|
|
146
|
+
* (`src/plugin-core.js`,逐字复制 CMS handler)。9 条**全部可迁**。
|
|
147
|
+
* 命令面:`plugins list|access|toggle|settings|market-list|install|uninstall|upgrade|demo`。
|
|
148
|
+
* 读 = `site:read`、写 = `site:write`(写类默认 dry-run,`--confirm` 才发)。
|
|
149
|
+
* `plugins list` / `plugins toggle` 两条命令名不变 —— 只是从 `/cms` 转发改走 `/cli` 自持。
|
|
150
|
+
*/
|
|
151
|
+
import { PLUGIN_COMMANDS } from './plugins.mjs';
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* ★ task-92(2026-10-29):控制台类自持面 —— B7 **剩余 8 条**(操作日志 / 参数读取 /
|
|
155
|
+
* 参数保存 / 统计代码审核 / 站点概览 / 账号级流量账单 / 控制台首页快照 / 会员支付能力)
|
|
156
|
+
* 搬进 `wkgeo-cli-fc`(`src/console-core.js`,逐字复制 CMS handler)。8 条**全部可迁**。
|
|
157
|
+
* 命令面:`logs list`、`config get|save|review|capabilities`、
|
|
158
|
+
* `overview summary|traffic|dashboard`。
|
|
159
|
+
* 读 = `site:read`、写 = `site:write`(写类 `config save` / `config review` 默认 dry-run)。
|
|
160
|
+
* ⚠️ B7 的 **AI 7 条(aiLogList / aiLogDetail / aiLogStats / aiTaskCreate / aiTaskMessages /
|
|
161
|
+
* aiTaskModels / aiToolConfirm)本批不做** —— 后台 AI 功能还没做完,等做完再单开一单。
|
|
162
|
+
* ⚠️ `config` 这个单名命令早就被 `auth.mjs` 的本地诊断占着(`wkgeo config` 读凭据/代理),
|
|
163
|
+
* 所以这里只在它后面追加 `config get|save|…` 子命令,`wkgeo config` 本身行为一字未改。
|
|
164
|
+
*/
|
|
165
|
+
import { LOG_COMMANDS } from './logs.mjs';
|
|
166
|
+
import { CONFIG_CONSOLE_COMMANDS } from './config.mjs';
|
|
167
|
+
import { OVERVIEW_COMMANDS } from './overview.mjs';
|
|
168
|
+
|
|
169
|
+
export const COMMANDS = [
|
|
170
|
+
loginCommand,
|
|
171
|
+
whoamiCommand,
|
|
172
|
+
logoutCommand,
|
|
173
|
+
/**
|
|
174
|
+
* ★ 2026-10-28(task-12):`auth` 命令组 —— 把"令牌 / 动作面"讲清楚的只读口。
|
|
175
|
+
* 令牌模型不变(就是 `wkgeo login` 拿的 OAuth access_token,30 天),
|
|
176
|
+
* 这里**不做**令牌换领:`auth status` 调 `cliWhoami`,`auth token` 只给前 4 位,
|
|
177
|
+
* `auth revoke` = 服务端 RFC 7009 吊销 + 删本地凭据。
|
|
178
|
+
*/
|
|
179
|
+
authStatusCommand,
|
|
180
|
+
authTokenCommand,
|
|
181
|
+
authRevokeCommand,
|
|
182
|
+
sitesCreateCommand,
|
|
183
|
+
sitesListCommand,
|
|
184
|
+
sitesGetCommand,
|
|
185
|
+
sitesDeleteCommand,
|
|
186
|
+
/**
|
|
187
|
+
* ★ 2026-10-18(CMS 面):先选站,再操作内容。
|
|
188
|
+
* `site use` 排在最前面 —— 它是后面所有 CMS 命令的前置(后端只认站点成员,
|
|
189
|
+
* 而 CLI 没有 Cookie 会话,站点上下文只能来自 `--site` 或本地这条记录)。
|
|
190
|
+
*/
|
|
191
|
+
siteUseCommand,
|
|
192
|
+
categoriesListCommand,
|
|
193
|
+
categoriesGetCommand,
|
|
194
|
+
categoriesCreateCommand,
|
|
195
|
+
categoriesUpdateCommand,
|
|
196
|
+
categoriesSaveCommand,
|
|
197
|
+
categoriesDeleteCommand,
|
|
198
|
+
categoriesBindTemplateCommand,
|
|
199
|
+
contentsListCommand,
|
|
200
|
+
contentsGetCommand,
|
|
201
|
+
contentsCreateCommand,
|
|
202
|
+
contentsUpdateCommand,
|
|
203
|
+
contentsSaveCommand,
|
|
204
|
+
contentsDeleteCommand,
|
|
205
|
+
assetsListCommand,
|
|
206
|
+
assetsUploadCommand,
|
|
207
|
+
assetsSignCommand,
|
|
208
|
+
assetsRegisterCommand,
|
|
209
|
+
assetsDeleteCommand,
|
|
210
|
+
assetsRestoreCommand,
|
|
211
|
+
templatesListCommand,
|
|
212
|
+
templatesGetCommand,
|
|
213
|
+
templatesSaveCommand,
|
|
214
|
+
publishCommand,
|
|
215
|
+
publishStatusCommand,
|
|
216
|
+
publishCancelCommand,
|
|
217
|
+
/* 发布面其余动作(task-68 / B3):重发 / 推送任务 / 推送目标 / 推送 / 客户桶 */
|
|
218
|
+
publishRetryCommand,
|
|
219
|
+
publishJobsCommand,
|
|
220
|
+
publishJobGetCommand,
|
|
221
|
+
publishJobCancelCommand,
|
|
222
|
+
publishTargetsCommand,
|
|
223
|
+
publishTargetsSaveCommand,
|
|
224
|
+
publishTargetsDeleteCommand,
|
|
225
|
+
publishTargetsTestCommand,
|
|
226
|
+
publishPushCommand,
|
|
227
|
+
publishStorageCommand,
|
|
228
|
+
publishStorageSaveCommand,
|
|
229
|
+
publishStorageVerifyCommand,
|
|
230
|
+
publishStorageDeleteCommand,
|
|
231
|
+
publishStoragePublishCommand,
|
|
232
|
+
/**
|
|
233
|
+
* ★ 0.5.0 新增:站点运营面(表单 / 域名巡检 / 预览 / 导入 v2)。
|
|
234
|
+
* 共同约定:写操作默认 dry-run(`--confirm` 才真发);人产出的数据默认脱敏。
|
|
235
|
+
* ★ task-91 / B5:原来这儿的 `plugins list` / `plugins toggle` 改由 `PLUGIN_COMMANDS`
|
|
236
|
+
* 提供(走 `/cli` 自持通道,不再 `/cms` 转发),并补齐插件面另外 7 条命令。
|
|
237
|
+
*/
|
|
238
|
+
formsListCommand,
|
|
239
|
+
formsEntriesCommand,
|
|
240
|
+
domainInspectionCommand,
|
|
241
|
+
/**
|
|
242
|
+
* ★ task-9(0.5.2 未发布):域名只读命令 —— 状态 / 解析记录 / 照抄用 DNS 清单 / 可用性 / 到期提醒。
|
|
243
|
+
* 全部只读。
|
|
244
|
+
* ★ task-12(2026-10-28):补上 `domain bind` —— 走原生动作 `cliProvisionSiteDomain`
|
|
245
|
+
* (CLI 自己的函数接、代执行 domain 内部开通编排,免 OAuth 428)。
|
|
246
|
+
* `unbind` / `repair` **仍刻意没有**:`/cli` 动作面里没有等价动作
|
|
247
|
+
* (解绑只有 `releaseSiteDomain`,OAuth 下 428 短信二次验证),不造命令。
|
|
248
|
+
*/
|
|
249
|
+
domainBindCommand,
|
|
250
|
+
domainStatusCommand,
|
|
251
|
+
domainRecordsCommand,
|
|
252
|
+
domainDnsCommand,
|
|
253
|
+
domainCheckCommand,
|
|
254
|
+
domainRemindCommand,
|
|
255
|
+
previewCommand,
|
|
256
|
+
importV2StartCommand,
|
|
257
|
+
importV2StatusCommand,
|
|
258
|
+
/**
|
|
259
|
+
* ★ 2026-10-28 自持成交链:**真的**查价 / 下单 / 改云解析 / 开 ESA / 建站收口。
|
|
260
|
+
* 与上面那 5 条只读命令的区别:这些会写账号里的真实资源(所以下单默认 dry-run、
|
|
261
|
+
* 删解析强制 --yes),实现全在 `wkgeo-cli-fc` 自己的新模块里。
|
|
262
|
+
*/
|
|
263
|
+
domainSearchCommand,
|
|
264
|
+
domainBuyCommand,
|
|
265
|
+
domainOrderCommand,
|
|
266
|
+
domainZoneListCommand,
|
|
267
|
+
domainZoneAddCommand,
|
|
268
|
+
domainZoneUpdateCommand,
|
|
269
|
+
domainZoneDeleteCommand,
|
|
270
|
+
esaSiteCommand,
|
|
271
|
+
esaRecordCommand,
|
|
272
|
+
esaHostnameCommand,
|
|
273
|
+
esaKvCommand,
|
|
274
|
+
siteCreateCommand,
|
|
275
|
+
/* 成品链路(task-21):域名成交全链路 6 条 */
|
|
276
|
+
...DOMAIN_ORDER_COMMANDS,
|
|
277
|
+
/* 域名级 DNS 凭据(2026-10-28):客户自己的 DNS 托管商 AK,四词命令 */
|
|
278
|
+
...DNS_CREDENTIAL_COMMANDS,
|
|
279
|
+
/**
|
|
280
|
+
* 配置类 auth 面(task-75 / B7):语言 / 角色 / 站点成员 11 条。
|
|
281
|
+
* 排在发布面之后 —— 同属"后台配置",但权限面独立(角色写要 `role:write`)。
|
|
282
|
+
*/
|
|
283
|
+
...CONFIG_AUTH_COMMANDS,
|
|
284
|
+
/**
|
|
285
|
+
* 站点类自持面(task-90 / B4):公司信息 / 域名巡检重检 / 示例内容 / 站级同步 6 条命令。
|
|
286
|
+
* 与上面两块同属"后台运维",但对象是**站点本身**(服务端还要校验 site.owner_id)。
|
|
287
|
+
*/
|
|
288
|
+
...SITE_COMMANDS,
|
|
289
|
+
/**
|
|
290
|
+
* 插件类自持面(task-91 / B5):本站插件开关 / 配置 / 市场安装卸载升级 / 演示链接 9 条命令。
|
|
291
|
+
* 对象也是**站点内**资源(服务端同样校验 `site.owner_id`),写类同样默认 dry-run。
|
|
292
|
+
*/
|
|
293
|
+
...PLUGIN_COMMANDS,
|
|
294
|
+
/**
|
|
295
|
+
* 控制台类自持面(task-92 / B7 剩余 8 条):操作日志 / 参数读取与保存 / 统计代码审核 /
|
|
296
|
+
* 站点概览 / 账号级流量 / 控制台首页快照 / 会员支付能力。
|
|
297
|
+
* 对象是**站点及其后台配置**(服务端同样校验 `site.owner_id`),
|
|
298
|
+
* `overview traffic` 与 `overview dashboard` 的账号级两块另要求平台管理员。
|
|
299
|
+
*/
|
|
300
|
+
...LOG_COMMANDS,
|
|
301
|
+
...CONFIG_CONSOLE_COMMANDS,
|
|
302
|
+
...OVERVIEW_COMMANDS,
|
|
303
|
+
/**
|
|
304
|
+
* `import`:老站导入。**当前走本机运维脚本**(需要 service_role 权限),
|
|
305
|
+
* 带鉴权的 HTTP 入口还在后端待办 —— 这是唯一一条"不在云函数里"的命令(见命令自己的说明)。
|
|
306
|
+
*/
|
|
307
|
+
importCommand,
|
|
308
|
+
walletCommand,
|
|
309
|
+
walletTxnsCommand,
|
|
310
|
+
walletRechargeCommand,
|
|
311
|
+
/**
|
|
312
|
+
* ★ 2026-10-02(方案 A):**独立充值页**链接 —— 用户在收银台上自己选金额并支付。
|
|
313
|
+
* 与 `wallet recharge` 并列(那条是"金额定死在命令行里"的老路,行为一字未改)。
|
|
314
|
+
*/
|
|
315
|
+
walletRechargeLinkCommand,
|
|
316
|
+
productsListCommand,
|
|
317
|
+
ordersCreateCommand,
|
|
318
|
+
ordersCheckCommand,
|
|
319
|
+
ordersPayCommand,
|
|
320
|
+
ordersGetCommand,
|
|
321
|
+
ordersListCommand,
|
|
322
|
+
appsListCommand,
|
|
323
|
+
appsRevokeCommand,
|
|
324
|
+
/**
|
|
325
|
+
* ★ 0.5.0:接本地大模型。
|
|
326
|
+
* `ai ping/ask/chat` 走本机 OpenAI 兼容端点(Ollama / LM Studio),
|
|
327
|
+
* `context export` 把站点上下文导成文件(任何模型/工具都能吃)。
|
|
328
|
+
* 白名单与脱敏在 `lib/ai/context.mjs` + `lib/format.mjs#maskPii`,**不在命令里另写一套**。
|
|
329
|
+
*/
|
|
330
|
+
aiPingCommand,
|
|
331
|
+
aiAskCommand,
|
|
332
|
+
aiChatCommand,
|
|
333
|
+
contextExportCommand,
|
|
334
|
+
/**
|
|
335
|
+
* `skill`:把随包分发的 `SKILL.md` 原文打印出来(AI 端自取手册)。
|
|
336
|
+
* 放在 config 前面 —— 两者同属「(基础)」,都是"不登录也能跑"的本地命令。
|
|
337
|
+
*/
|
|
338
|
+
skillCommand,
|
|
339
|
+
configCommand,
|
|
340
|
+
];
|
|
341
|
+
|
|
342
|
+
export const COMMAND_NAMES = COMMANDS.map((c) => c.name);
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 分组规则:两词命令(`sites create`)归到第一个词下;
|
|
346
|
+
* 单词命令如果**同时是某个分组名**(`wallet` 有 `wallet txns` 子命令)也归到自己名下。
|
|
347
|
+
* 否则归「(基础)」。这样帮助里的分组跟人的直觉一致。
|
|
348
|
+
*/
|
|
349
|
+
function groupOf(command) {
|
|
350
|
+
if (command.name.includes(' ')) return command.name.split(' ')[0];
|
|
351
|
+
if (COMMANDS.some((c) => c.name.startsWith(`${command.name} `))) return command.name;
|
|
352
|
+
return '(基础)';
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** 分组帮助的一句话说明(`wkgeo <组名> --help` 的首行) */
|
|
356
|
+
const GROUP_SUMMARY = {
|
|
357
|
+
auth: '授权与令牌:登录 / 看当前令牌是谁、能干什么 / 立刻作废',
|
|
358
|
+
site: '站点:选站 / 建站 / 公司信息 / 域名巡检重检 / 示例内容 / 站级同步(写要 site:write,默认 dry-run)',
|
|
359
|
+
domain: '域名:绑自有域名 / 看开通进度 / 取解析清单 / 查可用性(购买与解析读写见 domain search / zone / esa)',
|
|
360
|
+
lang: '站点语言:列表 / 新增或修改 / 设默认 / 删除 / 启用停用(写要 site:write,默认 dry-run)',
|
|
361
|
+
role: '站点角色:列表 / 新增或修改 / 删除(写要 role:write;不许造带「系统管理」权限的角色)',
|
|
362
|
+
member: '站点成员:列表(手机号掩码)/ 改角色 / 移出本站(只能管站点内角色,不建账号)',
|
|
363
|
+
plugins: '插件:本站插件开关 / 配置 / 市场安装卸载升级 / 演示链接(写要 site:write,默认 dry-run)',
|
|
364
|
+
logs: '操作日志:谁在哪台设备上改了什么(只读,分页;走 `/cli` 自持通道)',
|
|
365
|
+
config:
|
|
366
|
+
'站点参数:读 / 存 / 审核统计代码 / 会员与支付能力(写要 site:write,默认 dry-run;`wkgeo config` 仍是本地诊断)',
|
|
367
|
+
overview: '站点总览:栏目内容素材计数 / 账号级流量账单(仅平台管理员)/ 控制台首页快照(只读)',
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 会"按时间等"的通用参数必须把**单位**写进帮助里。
|
|
372
|
+
*
|
|
373
|
+
* 踩过的坑:`--timeout` 原来按毫秒解释,`--timeout 600` 变成 600 毫秒(0.8 秒就超时),
|
|
374
|
+
* 而帮助里连单位都没写 —— 用户完全没法从 `--help` 看出自己写错了。
|
|
375
|
+
* 这里直接引用 `GLOBAL_FLAGS` 的描述(**帮助与解析同源**,不会出现"文档写了但行为不一样")。
|
|
376
|
+
*/
|
|
377
|
+
function renderTimedGlobalFlags() {
|
|
378
|
+
return [
|
|
379
|
+
` --timeout <时长> ${GLOBAL_FLAGS.timeout.desc}`,
|
|
380
|
+
` --http-timeout <毫秒> ${GLOBAL_FLAGS['http-timeout'].desc}`,
|
|
381
|
+
];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** 人类可读帮助。`wkgeo --help` / `wkgeo help` / `wkgeo sites create --help` 都走它 */
|
|
385
|
+
export function renderHelp(name = null) {
|
|
386
|
+
const line = (s = '') => s;
|
|
387
|
+
const spec = name ? COMMANDS.find((c) => c.name === name) : null;
|
|
388
|
+
|
|
389
|
+
if (spec) {
|
|
390
|
+
const out = [];
|
|
391
|
+
out.push(line(`wkgeo ${spec.name} —— ${spec.summary}`));
|
|
392
|
+
out.push('');
|
|
393
|
+
out.push(line('用法:'));
|
|
394
|
+
for (const u of String(spec.usage).split('\n')) out.push(line(` ${u}`));
|
|
395
|
+
if (spec.args && spec.args.length) {
|
|
396
|
+
out.push('');
|
|
397
|
+
out.push(line('位置参数:'));
|
|
398
|
+
for (const a of spec.args) {
|
|
399
|
+
/** variadic(如 `domain check <域名…>`):一个参数可以接多个值 */
|
|
400
|
+
const label = a.variadic ? `<${a.name}…>` : `<${a.name}>`;
|
|
401
|
+
out.push(line(` ${label}${a.required ? '(必填)' : ''} ${a.desc || ''}`));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const own = Object.entries(spec.flags || {});
|
|
405
|
+
if (own.length) {
|
|
406
|
+
out.push('');
|
|
407
|
+
out.push(line('命令参数:'));
|
|
408
|
+
for (const [k, v] of own) out.push(line(` --${k}${v.type === 'boolean' ? '' : ' <值>'}${v.required ? '(必填)' : ''} ${v.desc || ''}`));
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* 示例(2026-10-18 起每条新命令都带上)。
|
|
412
|
+
*
|
|
413
|
+
* 为什么帮助里必须有示例:AI 端拿到 `--help` 之后要能**直接照抄一条命令**跑起来;
|
|
414
|
+
* 只有参数名和一句说明时,它还得自己推参数顺序和取值形态(容易把 `--site` 填成域名)。
|
|
415
|
+
*/
|
|
416
|
+
if (spec.examples && spec.examples.length) {
|
|
417
|
+
out.push('');
|
|
418
|
+
out.push(line('示例:'));
|
|
419
|
+
for (const e of spec.examples) out.push(line(` ${e}`));
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* 命令自带的"特别说明"(可选)。目前只有 `skill` 用 ——
|
|
423
|
+
* 它**不受**"非终端自动 JSON"约定约束,必须在自己的帮助里说清楚,
|
|
424
|
+
* 否则用户按通用说明去管道里拿 JSON 会拿到 markdown(反之亦然)。
|
|
425
|
+
*/
|
|
426
|
+
if (spec.notes && spec.notes.length) {
|
|
427
|
+
out.push('');
|
|
428
|
+
out.push(line('特别说明:'));
|
|
429
|
+
for (const n of spec.notes) out.push(line(` ${n}`));
|
|
430
|
+
}
|
|
431
|
+
out.push('');
|
|
432
|
+
out.push(line('通用参数:--json / --text / --base(平台面)/ --cms-base(CMS 面)/ --client-id / --credentials / --verbose / --help'));
|
|
433
|
+
out.push(line('(默认:输出到管道/非终端时自动使用 --json)'));
|
|
434
|
+
out.push('');
|
|
435
|
+
out.push(line('带单位的通用参数(写清单位,避免"600 被当成 600 毫秒"这类误解):'));
|
|
436
|
+
for (const l of renderTimedGlobalFlags()) out.push(line(l));
|
|
437
|
+
return out.join('\n');
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* 分组帮助(2026-10-28 task-12):`wkgeo auth --help` / `wkgeo domain --help` 给
|
|
442
|
+
* **这一组的命令清单**,不再掉到全量总帮助里。
|
|
443
|
+
*
|
|
444
|
+
* 为什么要加:`auth` 是 task-12 新加的命令组(status / token / revoke),`domain` 组也刚多了
|
|
445
|
+
* `bind`;用户/AI 打组名求助时,看到 150 多条的全量帮助根本找不到这几条。
|
|
446
|
+
*/
|
|
447
|
+
if (name && !name.includes(' ')) {
|
|
448
|
+
const inGroup = COMMANDS.filter((c) => groupOf(c) === name);
|
|
449
|
+
if (inGroup.length) {
|
|
450
|
+
const g = [`wkgeo ${name} —— ${GROUP_SUMMARY[name] || `${name} 相关命令`}`, ''];
|
|
451
|
+
g.push('用法:wkgeo <命令> [参数]');
|
|
452
|
+
g.push('');
|
|
453
|
+
for (const c of inGroup) g.push(` ${c.name.padEnd(26)} ${c.summary}`);
|
|
454
|
+
g.push('');
|
|
455
|
+
g.push(`看单条用法:wkgeo <命令> --help(例:wkgeo ${inGroup[0].name} --help)`);
|
|
456
|
+
g.push('通用参数:--json / --text / --base / --cms-base / --client-id / --credentials / --verbose / --help');
|
|
457
|
+
g.push('(默认:输出到管道/非终端时自动使用 --json)');
|
|
458
|
+
g.push('');
|
|
459
|
+
g.push('退出码:0 成功 | 1 失败 | 2 用法错误 | 3 需要(重新)授权 | 4 被限流');
|
|
460
|
+
return g.join('\n');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const groups = new Map();
|
|
465
|
+
for (const c of COMMANDS) {
|
|
466
|
+
const g = groupOf(c);
|
|
467
|
+
if (!groups.has(g)) groups.set(g, []);
|
|
468
|
+
groups.get(g).push(c);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const out = [];
|
|
472
|
+
out.push('云站平台官方 CLI —— 授权登录一次,之后建站 / 下单 / 钱包支付 / 查余额都不用再登录');
|
|
473
|
+
out.push('');
|
|
474
|
+
out.push('用法:wkgeo <命令> [参数]');
|
|
475
|
+
out.push('');
|
|
476
|
+
for (const [g, list] of groups) {
|
|
477
|
+
out.push(`${g}:`);
|
|
478
|
+
/**
|
|
479
|
+
* 列宽给到 26:`categories bind-template`(24 字符)是现在最长的命令名,
|
|
480
|
+
* 还按 16 排会让它把说明文字顶到下一列去(2026-10-18 加 CMS 命令时发现)。
|
|
481
|
+
*/
|
|
482
|
+
for (const c of list) out.push(` ${c.name.padEnd(26)} ${c.summary}`);
|
|
483
|
+
out.push('');
|
|
484
|
+
}
|
|
485
|
+
out.push('常用示例:');
|
|
486
|
+
out.push(' wkgeo login # 浏览器授权一次,令牌存本地(30 天)');
|
|
487
|
+
out.push(' wkgeo whoami # 看当前登录的是谁');
|
|
488
|
+
out.push(' wkgeo sites create --name 我的站 # 建站(返回站点 id)');
|
|
489
|
+
out.push(' wkgeo products list # 能买什么');
|
|
490
|
+
out.push(' wkgeo orders create --product storage_mb --units 1 # 下单(余额够就当场付清)');
|
|
491
|
+
out.push(' wkgeo wallet # 查余额 / wallet txns 看流水');
|
|
492
|
+
out.push(' wkgeo wallet recharge --amount-cents 1000 # 充值下单(微信扫码,需人工支付)');
|
|
493
|
+
out.push(' wkgeo wallet recharge-link # 生成独立充值页链接(用户在网页上自己选金额)');
|
|
494
|
+
out.push(' wkgeo orders check <订单ID> # 查支付结果 + 最新余额');
|
|
495
|
+
out.push(' wkgeo orders list # 我的订单');
|
|
496
|
+
out.push(' wkgeo site use <站点ID或域名> # ★ 选站(栏目/内容/素材/模板命令的前置)');
|
|
497
|
+
out.push(' wkgeo categories list # 栏目树(之后 contents / assets / templates 都类似)');
|
|
498
|
+
out.push(' wkgeo contents create --category 新闻 --title 标题 --body "<p>…</p>" # 写一篇内容');
|
|
499
|
+
out.push(' wkgeo assets upload ./banner.jpg # 传图(直传 OSS,返回素材 id)');
|
|
500
|
+
out.push(' wkgeo assets sign logo.png --bytes 20480 # 只取直传票据(agent 自己 POST 文件用)');
|
|
501
|
+
out.push(' wkgeo assets delete <素材ID> # 进回收站;--purge --confirm 才是彻底删除');
|
|
502
|
+
out.push(' wkgeo templates list # 本站模板 html 清单');
|
|
503
|
+
out.push(' wkgeo publish # 发布:默认 dry-run,--confirm 才真发');
|
|
504
|
+
out.push(' wkgeo plugins list # 插件开关状态(editor 分类单选互斥)');
|
|
505
|
+
out.push(' wkgeo forms entries # 表单提交(默认脱敏)');
|
|
506
|
+
out.push(' wkgeo preview /about/ --open # 预览地址(草稿态,不开发布)');
|
|
507
|
+
out.push(' wkgeo ai ping # 本地大模型通不通(Ollama / LM Studio)');
|
|
508
|
+
out.push(' wkgeo ai ask "这站有哪些栏目?" # 本地模型 + CLI 现取的站点上下文');
|
|
509
|
+
out.push(' wkgeo context export --out ctx.md # 把站点上下文导成文件喂任意模型');
|
|
510
|
+
out.push(' wkgeo import --url=https://old-site.com # 老站导入(默认 dry-run,需运维权限)');
|
|
511
|
+
/**
|
|
512
|
+
* ⚠️ 这条示例是为了让 AI 端**能自己发现**手册入口:
|
|
513
|
+
* 手册一直随包分发(package.json 的 files 里有 SKILL.md),但在加 `skill` 命令之前
|
|
514
|
+
* 没有任何命令能把它取出来 —— AI 只能去 node_modules 里翻,等于"分发了但拿不到"。
|
|
515
|
+
*/
|
|
516
|
+
out.push(' wkgeo skill # 打印给 AI 端的操作手册(随包分发)');
|
|
517
|
+
out.push('');
|
|
518
|
+
out.push('通用参数:--json(机器可读;非终端下默认开启)/ --text(强制人类可读)');
|
|
519
|
+
out.push(' --base <url>(平台面)/ --cms-base <url>(CMS 面)/ --client-id <id> / --credentials <path>');
|
|
520
|
+
out.push(' --verbose / --help / --version');
|
|
521
|
+
out.push('CMS 命令专用:--site <站点ID>(一次性指定站点,覆盖 `wkgeo site use` 选中的)');
|
|
522
|
+
out.push('');
|
|
523
|
+
out.push('带单位的通用参数(写清单位,避免"600 被当成 600 毫秒"这类误解):');
|
|
524
|
+
for (const l of renderTimedGlobalFlags()) out.push(l);
|
|
525
|
+
out.push('');
|
|
526
|
+
out.push('退出码:0 成功 | 1 失败 | 2 用法错误 | 3 需要(重新)授权 | 4 被限流');
|
|
527
|
+
return out.join('\n');
|
|
528
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 操作日志命令(B7 / task-92):`logs list`。
|
|
3
|
+
*
|
|
4
|
+
* ## 这一层是什么
|
|
5
|
+
* task-92(2026-10-29)把 CMS `actionTable` 里剩下的 8 条"控制台类"动作搬进 CLI 自己的
|
|
6
|
+
* 云函数 `wkgeo-cli-fc`(`src/console-core.js`,逐字复制 CMS handler + 本地归属闸)。
|
|
7
|
+
* 本文件是其中**唯一一条日志读取**命令:服务端动作名 `logList`,参数名照抄 CMS 后端
|
|
8
|
+
* (`kind` / `page` / `size`)。
|
|
9
|
+
*
|
|
10
|
+
* ## 三条口径(与 B1 内容面 / B3 发布面 / B4 站点面 / B5 插件面完全一致)
|
|
11
|
+
* 1. **站点必须先定**:`--site` > `WKONGAI_SITE` > `wkgeo site use` 记住的那个;
|
|
12
|
+
* 一个都没有就当场报用法错误(`consoleCall` 统一挡,不多跑一次往返)。
|
|
13
|
+
* 2. **只读**:不加 `--confirm` 这种东西(这里没有任何写动作),也不会写审计。
|
|
14
|
+
* 3. **默认人类可读,`--json` 给原始数据**(信封由 `runtime.done()` 统一包)。
|
|
15
|
+
*
|
|
16
|
+
* ## 权限面
|
|
17
|
+
* * 读 ⇒ `site:read`
|
|
18
|
+
* * **服务端还会校验站点归属**:不是自己名下站一律 403 `not_site_owner`
|
|
19
|
+
* (站不存在 / 已删除回 404,两者不区分、不带站名与人名,不泄露额外信息)
|
|
20
|
+
*
|
|
21
|
+
* ## 别在这里做的事
|
|
22
|
+
* * ❌ 不走 `/cms` 转发面(B7 起这条改走 `/cli` 自持通道)
|
|
23
|
+
* * ❌ 不在 CLI 侧拼 `site_id`:`consoleCall` 会塞 body.siteId,服务端只用自己判定的值
|
|
24
|
+
* * ❌ 不在 CLI 侧脱敏操作人:服务端已经按"昵称 → 姓名 → 账号 → 手机号中四位掩码"
|
|
25
|
+
* 回落过一次,CLI 只负责显示,不二次加工(否则两边规则迟早不一致)
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/* ------------------------------------------------------------------ 公共小工具 */
|
|
29
|
+
|
|
30
|
+
/** 所有控制台类命令共用的 `--site`(默认取 `wkgeo site use` 选中的站点) */
|
|
31
|
+
const SITE_FLAG = {
|
|
32
|
+
site: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
desc: '站点 ID(uuid;默认用 `wkgeo site use` 选中的站点,可用 WKONGAI_SITE 覆盖)',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function siteIdOf(ctx) {
|
|
39
|
+
const site = ctx.cmsSite();
|
|
40
|
+
return (site && site.id) || '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function siteText(ctx) {
|
|
44
|
+
const site = ctx.cmsSite();
|
|
45
|
+
if (!site || !site.id) return '(未选站)';
|
|
46
|
+
return site.label ? `${site.label}(${site.id})` : String(site.id);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 服务端动作名(同时用于回执) */
|
|
50
|
+
const ACTION = {
|
|
51
|
+
logList: 'logList',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** 日志类型的中文名(服务端只认 `kind` 原文,这里只影响显示) */
|
|
55
|
+
const LOG_KIND_LABEL = {
|
|
56
|
+
操作: '操作',
|
|
57
|
+
登录: '登录',
|
|
58
|
+
系统: '系统',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const logsListCommand = {
|
|
62
|
+
name: 'logs list',
|
|
63
|
+
summary: '查本站操作日志(谁在哪台设备上改了什么;只读,分页)',
|
|
64
|
+
usage: 'wkgeo logs list [--kind <类型>] [--page <页码>] [--size <每页条数>] [--site <站点ID>] [--json]',
|
|
65
|
+
args: [],
|
|
66
|
+
flags: {
|
|
67
|
+
kind: { type: 'string', desc: '日志类型:操作 / 登录 / 系统(不写 = 全部)' },
|
|
68
|
+
page: { type: 'number', desc: '页码,从 1 开始(默认 1)' },
|
|
69
|
+
size: { type: 'number', desc: '每页条数 10–200(默认 50;服务端会把越界值夹回区间)' },
|
|
70
|
+
...SITE_FLAG,
|
|
71
|
+
},
|
|
72
|
+
examples: [
|
|
73
|
+
'wkgeo logs list',
|
|
74
|
+
'wkgeo logs list --kind 登录 --size 20',
|
|
75
|
+
'wkgeo logs list --page 3 --json',
|
|
76
|
+
],
|
|
77
|
+
notes: [
|
|
78
|
+
'需要 `site:read`(只读)。',
|
|
79
|
+
'只列**本站**的日志:服务端按站点归属过滤,不是自己名下的站一律 403 `not_site_owner`。',
|
|
80
|
+
'`operator` 是服务端算好的显示名(昵称 → 姓名 → 账号 → 手机号中四位掩码),CLI 不二次脱敏。',
|
|
81
|
+
'`--size` 超出 10–200 会被服务端夹回区间,回包里的 `page_size` 是**实际生效**的值。',
|
|
82
|
+
],
|
|
83
|
+
async run(ctx) {
|
|
84
|
+
const { out } = ctx;
|
|
85
|
+
const body = {};
|
|
86
|
+
if (ctx.flags.kind !== undefined && String(ctx.flags.kind).trim()) body.kind = String(ctx.flags.kind).trim();
|
|
87
|
+
if (Number.isFinite(ctx.flags.page) && ctx.flags.page > 0) body.page = Math.floor(ctx.flags.page);
|
|
88
|
+
if (Number.isFinite(ctx.flags.size) && ctx.flags.size > 0) body.size = Math.floor(ctx.flags.size);
|
|
89
|
+
|
|
90
|
+
const data = (await ctx.consoleCall(ACTION.logList, body)) || {};
|
|
91
|
+
const rows = Array.isArray(data.rows) ? data.rows : Array.isArray(data) ? data : [];
|
|
92
|
+
|
|
93
|
+
const payload = {
|
|
94
|
+
site_id: siteIdOf(ctx),
|
|
95
|
+
kind: body.kind || null,
|
|
96
|
+
total: Number(data.total || rows.length),
|
|
97
|
+
page: Number(data.page || body.page || 1),
|
|
98
|
+
page_size: Number(data.pageSize || body.size || rows.length),
|
|
99
|
+
rows: rows.map((one) => ({
|
|
100
|
+
id: one && one.id !== undefined && one.id !== null ? one.id : null,
|
|
101
|
+
event: String((one && one.event) || ''),
|
|
102
|
+
kind: String((one && one.logKind) || ''),
|
|
103
|
+
operator: String((one && (one.operator_name || one.userName)) || ''),
|
|
104
|
+
ip: String((one && one.IP) || ''),
|
|
105
|
+
os: String((one && one.os) || ''),
|
|
106
|
+
browser: String((one && one.browser) || ''),
|
|
107
|
+
created_at: String((one && one.createdAt) || ''),
|
|
108
|
+
})),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (!out.json) {
|
|
112
|
+
out.head(`操作日志(站点 ${siteText(ctx)}${payload.kind ? ` · ${payload.kind}` : ''})`);
|
|
113
|
+
if (!payload.rows.length) {
|
|
114
|
+
out.line(' (这一页没有日志)');
|
|
115
|
+
} else {
|
|
116
|
+
out.table(
|
|
117
|
+
[
|
|
118
|
+
{ title: '时间', key: 'created_at', width: 19 },
|
|
119
|
+
{ title: '类型', key: 'kind', width: 6 },
|
|
120
|
+
{ title: '操作人', key: 'operator', width: 14 },
|
|
121
|
+
{ title: '事件', key: 'event', width: 40 },
|
|
122
|
+
{ title: 'IP', key: 'ip', width: 15 },
|
|
123
|
+
],
|
|
124
|
+
payload.rows.map((one) => ({
|
|
125
|
+
...one,
|
|
126
|
+
kind: LOG_KIND_LABEL[one.kind] || one.kind,
|
|
127
|
+
})),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
out.line(` 第 ${payload.page} 页 · 每页 ${payload.page_size} 条 · 合计 ${payload.total} 条`);
|
|
131
|
+
if (payload.total > payload.page * payload.page_size) {
|
|
132
|
+
out.info(`看下一页:\`wkgeo logs list --page ${payload.page + 1}\``);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
ctx.done(payload);
|
|
136
|
+
return payload;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/** 注册表(顺序 = 帮助里的顺序) */
|
|
141
|
+
export const LOG_COMMANDS = [logsListCommand];
|