@wkgeo/cli 1.1.3 → 1.1.5
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 +35 -0
- package/README.md +64 -3
- package/SKILL.md +35 -2
- package/lib/api.mjs +28 -1
- package/lib/commands/cms.mjs +2 -2
- package/lib/commands/data.mjs +694 -0
- package/lib/commands/domainops.mjs +11 -11
- package/lib/commands/index.mjs +13 -1
- package/lib/commands/member.mjs +104 -49
- package/lib/commands/orders.mjs +27 -1
- package/lib/commands/siteops.mjs +1 -1
- package/lib/commands/sites.mjs +0 -1
- package/lib/commands/template.mjs +10 -0
- package/lib/errors.mjs +31 -0
- package/lib/manifest-apply.mjs +103 -2
- package/lib/manifest-schema.json +4 -0
- package/lib/manifest.mjs +23 -0
- package/lib/site-create.mjs +1 -2
- package/lib/template-publish.mjs +5 -1
- package/lib/templates-sync.mjs +51 -23
- package/package.json +1 -1
|
@@ -241,10 +241,10 @@ export const domainOrderCommand = {
|
|
|
241
241
|
/* ============================== 云解析(真写) ============================== */
|
|
242
242
|
|
|
243
243
|
const DNS_FLAGS = {
|
|
244
|
-
domain: { type: 'string', desc: '完整域名(服务端按最长后缀找 zone,如
|
|
244
|
+
domain: { type: 'string', desc: '完整域名(服务端按最长后缀找 zone,如 demo.example.com ⇒ zone example.com)' },
|
|
245
245
|
type: { type: 'string', desc: '记录类型:A / AAAA / CNAME / TXT / MX / SRV / CAA' },
|
|
246
246
|
value: { type: 'string', desc: '记录值(CNAME 填目标域名,TXT 填文本)' },
|
|
247
|
-
rr: { type: 'string', desc: '主机记录(不填就从域名里推:
|
|
247
|
+
rr: { type: 'string', desc: '主机记录(不填就从域名里推:demo.example.com ⇒ demo)' },
|
|
248
248
|
ttl: { type: 'string', desc: 'TTL 秒(600–86400,默认 600)' },
|
|
249
249
|
'record-id': { type: 'string', desc: '记录 ID(update / delete 必填,来自 domain zone list)' },
|
|
250
250
|
yes: { type: 'boolean', desc: '删除必须显式确认' },
|
|
@@ -255,7 +255,7 @@ export const domainZoneListCommand = {
|
|
|
255
255
|
summary: '列账号里某个域名的真实解析记录(自持 alidns,不是"照抄表")',
|
|
256
256
|
usage: 'wkgeo domain zone list --domain <域名> [--type <类型>] [--rr <主机记录>] [--json]',
|
|
257
257
|
flags: { domain: DNS_FLAGS.domain, type: DNS_FLAGS.type, rr: DNS_FLAGS.rr },
|
|
258
|
-
examples: ['wkgeo domain zone list --domain
|
|
258
|
+
examples: ['wkgeo domain zone list --domain example.com', 'wkgeo domain zone list --domain demo.example.com --type CNAME'],
|
|
259
259
|
notes: ['只想看"我还该加哪几条解析"?用 `wkgeo domain dns`(那张是给客户照抄的表)。'],
|
|
260
260
|
async run(ctx) {
|
|
261
261
|
const { out, flags } = ctx;
|
|
@@ -290,8 +290,8 @@ export const domainZoneAddCommand = {
|
|
|
290
290
|
usage: 'wkgeo domain zone add --domain <域名> --type <类型> --value <值> [--rr <主机>] [--ttl <秒>] [--json]',
|
|
291
291
|
flags: { domain: DNS_FLAGS.domain, type: DNS_FLAGS.type, value: DNS_FLAGS.value, rr: DNS_FLAGS.rr, ttl: DNS_FLAGS.ttl },
|
|
292
292
|
examples: [
|
|
293
|
-
'wkgeo domain zone add --domain
|
|
294
|
-
'wkgeo domain zone add --domain _verify.
|
|
293
|
+
'wkgeo domain zone add --domain demo.example.com --type CNAME --value c-demo.intl.wkgeo.com.cn',
|
|
294
|
+
'wkgeo domain zone add --domain _verify.example.com --type TXT --value "verify=abc"',
|
|
295
295
|
],
|
|
296
296
|
notes: [
|
|
297
297
|
'写完立刻回读:**回读值不符会报 502**(这时记录可能已经写进去了,先去 `domain zone list` 看一眼,别急着重加)。',
|
|
@@ -358,7 +358,7 @@ export const domainZoneDeleteCommand = {
|
|
|
358
358
|
summary: '删一条解析(必须 --yes;重复删是幂等的)',
|
|
359
359
|
usage: 'wkgeo domain zone delete --domain <域名> --record-id <记录ID> --yes',
|
|
360
360
|
flags: { domain: DNS_FLAGS.domain, 'record-id': DNS_FLAGS['record-id'], yes: DNS_FLAGS.yes },
|
|
361
|
-
examples: ['wkgeo domain zone delete --domain
|
|
361
|
+
examples: ['wkgeo domain zone delete --domain demo.example.com --record-id 8123456 --yes'],
|
|
362
362
|
notes: ['删错一条解析 = 线上事故,所以这里强制 `--yes`。'],
|
|
363
363
|
async run(ctx) {
|
|
364
364
|
const { out, flags } = ctx;
|
|
@@ -382,7 +382,7 @@ export const domainZoneDeleteCommand = {
|
|
|
382
382
|
const ESA_FLAGS = {
|
|
383
383
|
pool: { type: 'string', desc: '池位:id / set_code / 站点名(如 intl-1、intl.wkgeo.com.cn)' },
|
|
384
384
|
site: { type: 'string', desc: '站点 id(与 --pool 二选一)' },
|
|
385
|
-
host: { type: 'string', desc: '要接的完整域名(如
|
|
385
|
+
host: { type: 'string', desc: '要接的完整域名(如 demo.example.com)' },
|
|
386
386
|
endpoint: { type: 'string', desc: '回源桶端点(默认复用池行 origin 记录)' },
|
|
387
387
|
'record-id': { type: 'string', desc: 'ESA 回源记录 id(不填按记录名自动查)' },
|
|
388
388
|
'no-cert': { type: 'boolean', desc: '不申请免费证书(只接域名)' },
|
|
@@ -419,7 +419,7 @@ export const esaRecordCommand = {
|
|
|
419
419
|
summary: '建/改 ESA 的 S3 回源记录(同值幂等;记录名必须是单标签子域)',
|
|
420
420
|
usage: 'wkgeo esa record --pool <池位> --host <域名> [--endpoint <桶端点>]',
|
|
421
421
|
flags: { pool: ESA_FLAGS.pool, site: ESA_FLAGS.site, host: ESA_FLAGS.host, endpoint: ESA_FLAGS.endpoint },
|
|
422
|
-
examples: ['wkgeo esa record --pool intl-1 --host
|
|
422
|
+
examples: ['wkgeo esa record --pool intl-1 --host demo.example.com'],
|
|
423
423
|
notes: [
|
|
424
424
|
'记录名 = `c-<slug>.<池域>`(单标签,ESA 的硬要求);HostPolicy 必须是 follow_origin_domain。',
|
|
425
425
|
'写后回读:源站类型 / Data / HostPolicy 任何一项不符都会报错。',
|
|
@@ -450,7 +450,7 @@ export const esaHostnameCommand = {
|
|
|
450
450
|
summary: '接 CustomHostname + 申请免费证书(幂等;100 次/小时限流,别重试)',
|
|
451
451
|
usage: 'wkgeo esa hostname --pool <池位> --host <域名> [--record-id <id>] [--no-cert]',
|
|
452
452
|
flags: { pool: ESA_FLAGS.pool, site: ESA_FLAGS.site, host: ESA_FLAGS.host, 'record-id': ESA_FLAGS['record-id'], 'no-cert': ESA_FLAGS['no-cert'] },
|
|
453
|
-
examples: ['wkgeo esa hostname --pool intl-1 --host
|
|
453
|
+
examples: ['wkgeo esa hostname --pool intl-1 --host demo.example.com'],
|
|
454
454
|
notes: [
|
|
455
455
|
'**先有回源记录再接域名**:没回源记录也没给 --record-id 会直接 400(避免接出个黑洞)。',
|
|
456
456
|
'证书是免费 DV,DNS 必须先解析到 ESA 才能签下来;签不下来不会假装成功。',
|
|
@@ -484,7 +484,7 @@ export const esaKvCommand = {
|
|
|
484
484
|
summary: '把域名写进边缘路由 KV(`host:<域名>` → 站点目录,写后 GetKv 回读)',
|
|
485
485
|
usage: 'wkgeo esa kv --host <域名> --site-id <站点id>',
|
|
486
486
|
flags: { host: ESA_FLAGS.host, 'site-id': { type: 'string', desc: '站点 id(KV 的值就是它,边缘据此改写路径)' } },
|
|
487
|
-
examples: ['wkgeo esa kv --host
|
|
487
|
+
examples: ['wkgeo esa kv --host demo.example.com --site-id 8f0c…'],
|
|
488
488
|
notes: [
|
|
489
489
|
'KV 值是**站点 id**(= 桶里的顶层目录),边缘路由器命中后把 `/<path>` 改写成 `/<siteId>/<path>`。',
|
|
490
490
|
'BatchPutKv 回 200 只代表"收到",不代表生效 —— 所以这里强制 GetKv 回读,读不到就是失败。',
|
|
@@ -535,7 +535,7 @@ export const siteCreateCommand = {
|
|
|
535
535
|
const c = data.closeout || {};
|
|
536
536
|
out.head(`建站完成:${data.name || flags.name}`);
|
|
537
537
|
out.line(` 站点 id:${data.site_id || data.id || '—'}`);
|
|
538
|
-
out.line(`
|
|
538
|
+
out.line(` 短域:${c.prefix_host || '—'}`);
|
|
539
539
|
out.line(` host KV:${c.kv ? (c.kv.verified ? `已验证(${c.kv.via})` : '未验证') : '—'}`);
|
|
540
540
|
if (c.ok) out.ok(`短域可直接访问:${c.prefix_url || `https://${c.prefix_host}`}`);
|
|
541
541
|
else out.warn(`收口未完成:${c.code || ''} ${c.message || ''}`.trim());
|
package/lib/commands/index.mjs
CHANGED
|
@@ -202,6 +202,14 @@ import {
|
|
|
202
202
|
import { contentCheckCommand, contentFillCommand } from './content.mjs';
|
|
203
203
|
/* `content apply` 本体在 `cli/lib/manifest-apply.mjs`(只管建站内容契约;模板契约那条已拆成 `content fill`) */
|
|
204
204
|
import { contentApplyCommand } from '../manifest-apply.mjs';
|
|
205
|
+
/**
|
|
206
|
+
* ★ 2026-11-10(老板单「数据交换」):`data` 组 = 三类运营数据的**只读**导出。
|
|
207
|
+
* chat AI 客服会话 / 单会话消息(`/aikefu` → MaxKB 只读库;正文默认脱敏、IP 只给掩码);
|
|
208
|
+
* stats 访问统计按日 PV / UV / IP 唯一数 + Top 页面 / 来源(`/analytics` → `statRange`);
|
|
209
|
+
* usage 大模型消耗按日 / 模型 / 站点(`/admin` → `llmCostSummary`,需 scope `llm:cost_read`)。
|
|
210
|
+
* 统一参数:`--site <ID|域名>` / `--from` / `--to` / `--page` `/`--limit` / `--json|--text` / `--out <csv|json>`。
|
|
211
|
+
*/
|
|
212
|
+
import { DATA_COMMANDS } from './data.mjs';
|
|
205
213
|
/**
|
|
206
214
|
* ★ 2026-10-30(task-4):\`seo\` 组 = **本地站点产物**的 SEO 工具,四条纯本地命令(不联网、不写库)。
|
|
207
215
|
* audit 13 项加权评分 + issues[](报告命令,恒 exit 0);
|
|
@@ -238,6 +246,8 @@ export const COMMANDS = [
|
|
|
238
246
|
contentApplyCommand,
|
|
239
247
|
contentFillCommand,
|
|
240
248
|
contentCheckCommand,
|
|
249
|
+
/* ★ 2026-11-10:数据交换三件套(chat / stats / usage,全部只读) */
|
|
250
|
+
...DATA_COMMANDS,
|
|
241
251
|
/* ★ task-4:本地站点产物的 SEO 工具(audit / llms / schema / files),不联网、不写库 */
|
|
242
252
|
...seoCommands,
|
|
243
253
|
/* ★ task-5:本地站点产物的 GEO 工具(audit / llms / robots / brands / report),不联网、不写库 */
|
|
@@ -451,7 +461,7 @@ const GROUP_SUMMARY = {
|
|
|
451
461
|
coupons: '优惠券:我的券(可按状态筛)/ `--usable` 看某笔订单能用的券与抵扣预览(只读,不含核销)',
|
|
452
462
|
notify: '我的消息:列表(未读数置顶)/ 标已读(写,默认 dry-run,`--confirm` 才真发)',
|
|
453
463
|
invoices: '我的开票:可开票订单 + 我的开票申请(只读;开票动作留在会员端)',
|
|
454
|
-
plans: '套餐目录:订阅套餐 /
|
|
464
|
+
plans: '套餐目录:订阅套餐 / 加量包套餐 / 我已买的加量包(只读,三块小表)',
|
|
455
465
|
site: '站点:选站 / 建站 / 公司信息 / 域名巡检重检 / 示例内容 / 站级同步(写要 site:write,默认 dry-run)',
|
|
456
466
|
domain: '域名:绑自有域名 / 看开通进度 / 取解析清单 / 查可用性(购买与解析读写见 domain search / zone / esa)',
|
|
457
467
|
lang: '站点语言:列表 / 新增或修改 / 设默认 / 删除 / 启用停用(写要 site:write,默认 dry-run)',
|
|
@@ -464,6 +474,8 @@ const GROUP_SUMMARY = {
|
|
|
464
474
|
overview: '站点总览:栏目内容素材计数 / 账号级流量账单(仅平台管理员)/ 控制台首页快照(只读)',
|
|
465
475
|
content:
|
|
466
476
|
'内容原语:apply = 建站清单(site-manifest.json)落站 · fill = 模板内容契约(sections[]/pages[])填库 · check 契约↔库↔前台自检 + 9 维评分(两条写命令默认 dry-run、逐栏目 upsert、幂等、未知字段拒绝)',
|
|
477
|
+
data:
|
|
478
|
+
'数据交换(只读):chat = AI 客服会话/单会话消息(正文默认脱敏、IP 只给掩码)· stats = 按日 PV/UV/IP 唯一数 + Top 页面/来源 · usage = 按日/模型/站点的大模型请求数/token/费用(需 scope llm:cost_read);`--out` 落 CSV/JSON',
|
|
467
479
|
template:
|
|
468
480
|
'模板工具链:init 取基础库 / validate 契约九关 / capture 载图 / verify 像素自比 / score 评分 / anim 动画 / pack 打包 / publish 发布 / preview 预览',
|
|
469
481
|
templates:
|
package/lib/commands/member.mjs
CHANGED
|
@@ -523,7 +523,7 @@ export const sitesRecycleCommand = {
|
|
|
523
523
|
[
|
|
524
524
|
{ title: '站点', key: 'name', width: 24 },
|
|
525
525
|
{ title: '域名', key: 'domains', width: 30, format: (v, row) => domainsText(row) },
|
|
526
|
-
{ title: '删除时间', key: '
|
|
526
|
+
{ title: '删除时间', key: 'offline_at', width: 20, format: TIME },
|
|
527
527
|
{ title: '到期时间', key: 'expires_at', width: 20, format: TIME },
|
|
528
528
|
{ title: '站点 ID', key: 'id', width: 36 },
|
|
529
529
|
],
|
|
@@ -573,12 +573,9 @@ export const sitesRecycleRestoreCommand = {
|
|
|
573
573
|
const data = {
|
|
574
574
|
id: src.id || id,
|
|
575
575
|
restored: src.restored !== false,
|
|
576
|
-
pool: src.pool || null,
|
|
577
576
|
};
|
|
578
577
|
if (!out.json) {
|
|
579
578
|
out.ok(`站点已还原:${data.id}`);
|
|
580
|
-
const pool = data.pool && typeof data.pool === 'object' ? data.pool : null;
|
|
581
|
-
if (pool && (pool.pool_id || pool.id)) out.line(` 资源池:${pool.pool_id || pool.id}`);
|
|
582
579
|
}
|
|
583
580
|
ctx.done(data);
|
|
584
581
|
return data;
|
|
@@ -674,40 +671,80 @@ export const invoicesListCommand = {
|
|
|
674
671
|
|
|
675
672
|
/* ════════════════════════════ ⑦ plans list ════════════════════════════ */
|
|
676
673
|
|
|
677
|
-
/**
|
|
674
|
+
/** 像「时长」的档位标签(`1 年` / `7 天` / `2 年(24 个月)`);不像就**不**拿它当时长用 */
|
|
675
|
+
const DURATION_LABEL_RE = /^\d+\s*(?:天|日|个月|月|年)/;
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* ★ 2026-11-16 task-528:时长文案统一入口。
|
|
679
|
+
*
|
|
680
|
+
* 为什么不能一律写「N 个月」:`bundle_price.months` 是**时长档里的数量**,单位在
|
|
681
|
+
* `unit`(`day` / `month` / `year`)—— `basic` 的三档是 **1 / 2 / 3 年**,按「个月」读
|
|
682
|
+
* 会说成「1 / 2 / 3 个月」,客户看到的档位就是错的。
|
|
683
|
+
* 取值顺序:① 服务端下发的 `duration_text`(「7 天」「1 年」,与下单计价同一份实现
|
|
684
|
+
* `_shared/bundle-term-policy.js`)→ ② 档位标签 `label`(管理员填的展示文案,且必须**长得像时长**)
|
|
685
|
+
* → ③ 按 `unit + months` 拼 → ④ 最后才按 `month` 降级。纯展示,不参与任何计价。
|
|
686
|
+
*/
|
|
687
|
+
function termTextOf(t) {
|
|
688
|
+
const row = t && typeof t === 'object' ? t : {};
|
|
689
|
+
const text = String(row.duration_text === null || row.duration_text === undefined ? '' : row.duration_text).trim();
|
|
690
|
+
if (text) return text;
|
|
691
|
+
const label = String(row.label === null || row.label === undefined ? '' : row.label).trim();
|
|
692
|
+
if (DURATION_LABEL_RE.test(label)) return label;
|
|
693
|
+
const months = Number(row.months);
|
|
694
|
+
if (!Number.isFinite(months) || months <= 0) return dash(row.months);
|
|
695
|
+
const unit = String(row.unit === null || row.unit === undefined ? '' : row.unit).trim().toLowerCase();
|
|
696
|
+
if (unit === 'year') return `${months} 年`;
|
|
697
|
+
if (unit === 'day') return `${months} 天`;
|
|
698
|
+
return `${months} 个月`;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* 档价文案:**生效价**(`price_cents`,后端按 `bundle_price` 算出)优先,
|
|
703
|
+
* 其次老的 `price_cents_month`,两者都没有才是「面议」。
|
|
704
|
+
*
|
|
705
|
+
* 为什么不再固定读 `price_cents_month`:那列是**每等价月的价**,按年 / 按天卖的档位
|
|
706
|
+
* 上恒为 NULL ⇒ 以前一律读它,`basic`(年档)全档显示成「面议」。
|
|
707
|
+
*/
|
|
708
|
+
function termPriceTextOf(t) {
|
|
709
|
+
const row = t && typeof t === 'object' ? t : {};
|
|
710
|
+
const cents = Number(row.price_cents);
|
|
711
|
+
if (Number.isFinite(cents) && cents > 0) return formatMoney(cents);
|
|
712
|
+
const monthCents = Number(row.price_cents_month);
|
|
713
|
+
if (Number.isFinite(monthCents) && monthCents > 0) return formatMoney(monthCents);
|
|
714
|
+
return '面议';
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/** 各周期价格数组 → 一行文本:`1 年 ¥368.00 / 2 年 ¥577.00` */
|
|
678
718
|
function priceListText(prices) {
|
|
679
719
|
const list = Array.isArray(prices) ? prices : [];
|
|
680
720
|
if (!list.length) return '-';
|
|
681
|
-
return list
|
|
682
|
-
.map((p) => `${dash(p.months)} 个月 ${formatMoney(p.price_cents)}`)
|
|
683
|
-
.join(' / ');
|
|
721
|
+
return list.map((p) => `${termTextOf(p)} ${termPriceTextOf(p)}`).join(' / ');
|
|
684
722
|
}
|
|
685
723
|
|
|
686
724
|
/**
|
|
687
|
-
*
|
|
725
|
+
* 套餐目录(三块一起看,**默认全取**):
|
|
688
726
|
* ① `listPlans` —— 订阅套餐 + 各周期价格(active)
|
|
689
|
-
* ② `
|
|
690
|
-
* ③ `
|
|
691
|
-
* ④ `listBundles` —— 我已买的加量包(旧 plan 模型,含下架件)
|
|
727
|
+
* ② `listBundlePlans` —— 加量包套餐(含/加量项 + 各周期单价)
|
|
728
|
+
* ③ `listBundles` —— 我已买的加量包(旧 plan 模型,含下架件)
|
|
692
729
|
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
* 硬合成一张宽表只会满屏 `-`。`--no-bundles`
|
|
730
|
+
* 为什么三块都用**独立小表**:`plan` / `bundle` / `bundle_plan` 是三张表、
|
|
731
|
+
* 三套字段(价格字段名都不一样:`price_cents` / `base_price_cents` / `price_cents_month`),
|
|
732
|
+
* 硬合成一张宽表只会满屏 `-`。`--no-bundles` 可以只取第一块。
|
|
696
733
|
*/
|
|
697
734
|
export const plansListCommand = {
|
|
698
735
|
name: 'plans list',
|
|
699
|
-
summary: '套餐目录:订阅套餐 /
|
|
736
|
+
summary: '套餐目录:订阅套餐 / 加量包套餐 / 我已买的加量包',
|
|
700
737
|
usage: 'wkgeo plans list [--no-bundles]',
|
|
701
738
|
args: [],
|
|
702
739
|
flags: {
|
|
703
740
|
bundles: {
|
|
704
741
|
type: 'boolean',
|
|
705
|
-
desc: '取加量包那两块(默认取;`--no-bundles`
|
|
742
|
+
desc: '取加量包那两块(默认取;`--no-bundles` 只取套餐)',
|
|
706
743
|
},
|
|
707
744
|
},
|
|
708
745
|
examples: ['wkgeo plans list', 'wkgeo plans list --no-bundles', 'wkgeo plans list --json'],
|
|
709
746
|
notes: [
|
|
710
|
-
'只读(`billing:self` / `site:read
|
|
747
|
+
'只读(`billing:self` / `site:read`),三块分别是三次查询;`--no-bundles` 省掉后两次。',
|
|
711
748
|
'只列**在售**(`status=active`):下架的套餐 / 加量包不会出现。`listBundles` 例外 —— 管理员能看到自己名下的下架件。',
|
|
712
749
|
'下单不在这条命令里:订阅 `wkgeo orders create`、加量包走报价单接口(CLI 暂未开放)。',
|
|
713
750
|
],
|
|
@@ -716,18 +753,15 @@ export const plansListCommand = {
|
|
|
716
753
|
const withBundles = flags.bundles !== false;
|
|
717
754
|
|
|
718
755
|
const plans = await ctx.callData('listPlans', {});
|
|
719
|
-
const sitePrices = await ctx.callData('listSitePrices', {});
|
|
720
756
|
const bundlePlans = withBundles ? await ctx.callData('listBundlePlans', {}) : null;
|
|
721
757
|
const bundles = withBundles ? await ctx.callData('listBundles', {}) : null;
|
|
722
758
|
|
|
723
759
|
const planRows = plans && Array.isArray(plans.rows) ? plans.rows : [];
|
|
724
|
-
const priceRows = sitePrices && Array.isArray(sitePrices.rows) ? sitePrices.rows : [];
|
|
725
760
|
const bundlePlanRows = bundlePlans && Array.isArray(bundlePlans.rows) ? bundlePlans.rows : [];
|
|
726
761
|
const bundleRows = bundles && Array.isArray(bundles.rows) ? bundles.rows : [];
|
|
727
762
|
|
|
728
763
|
const data = {
|
|
729
764
|
plans: plans && typeof plans === 'object' ? plans : {},
|
|
730
|
-
site_prices: sitePrices && typeof sitePrices === 'object' ? sitePrices : {},
|
|
731
765
|
};
|
|
732
766
|
if (withBundles) {
|
|
733
767
|
data.bundle_plans = bundlePlans && typeof bundlePlans === 'object' ? bundlePlans : {};
|
|
@@ -762,29 +796,21 @@ export const plansListCommand = {
|
|
|
762
796
|
planRows,
|
|
763
797
|
);
|
|
764
798
|
|
|
765
|
-
out.head(`站点续费价格 · ${priceRows.length} 档`);
|
|
766
|
-
out.table(
|
|
767
|
-
[
|
|
768
|
-
{ title: '周期', key: 'months', width: 8, format: (v) => `${dash(v)} 个月` },
|
|
769
|
-
{ title: '价格', key: 'price_cents', width: 12, format: (v) => formatMoney(v) },
|
|
770
|
-
{ title: '原价', key: 'original_cents', width: 12, format: (v) => (v ? formatMoney(v) : '-') },
|
|
771
|
-
{ title: '标签', key: 'label', width: 16 },
|
|
772
|
-
],
|
|
773
|
-
priceRows,
|
|
774
|
-
);
|
|
775
|
-
|
|
776
799
|
if (withBundles) {
|
|
777
800
|
out.head(`加量包套餐 · ${bundlePlanRows.length} 个`);
|
|
801
|
+
/**
|
|
802
|
+
* ⚠️ ★ 2026-11-16 task-528(老板 2026-11-16 拍板「删一列比显示错的好」):
|
|
803
|
+
* **不再列「基础价」(`bundle.base_price_cents`)**。
|
|
804
|
+
*
|
|
805
|
+
* 那一列是旧「月价」模型的基础月价(`basic` = ¥180.60/月),与在售档价
|
|
806
|
+
* (`basic` ¥368/年 ≈ ¥30.7/月)差一个量级,既不是客户能买的价格,也不参与本次任何计价;
|
|
807
|
+
* 「各周期」列已经把**真实生效价**按档列全了 ⇒ 显示它只会误导。
|
|
808
|
+
* 基础月价要不要与在售档价对齐(改数据)属定价口径,由老板定;在那之前**不展示**。
|
|
809
|
+
*/
|
|
778
810
|
out.table(
|
|
779
811
|
[
|
|
780
812
|
{ title: '套餐', key: 'name', width: 22 },
|
|
781
813
|
{ title: '代码', key: 'code', width: 16 },
|
|
782
|
-
{
|
|
783
|
-
title: '基础价',
|
|
784
|
-
key: 'base_price_cents',
|
|
785
|
-
width: 12,
|
|
786
|
-
format: (v) => formatMoney(v),
|
|
787
|
-
},
|
|
788
814
|
{
|
|
789
815
|
title: '含项',
|
|
790
816
|
key: 'included',
|
|
@@ -797,14 +823,10 @@ export const plansListCommand = {
|
|
|
797
823
|
{
|
|
798
824
|
title: '各周期',
|
|
799
825
|
key: 'terms',
|
|
800
|
-
width:
|
|
826
|
+
width: 40,
|
|
801
827
|
format: (v) =>
|
|
802
828
|
Array.isArray(v) && v.length
|
|
803
|
-
? v
|
|
804
|
-
.map((t) =>
|
|
805
|
-
`${t.months} 个月 ${t.price_cents_month === null ? '面议' : formatMoney(t.price_cents_month)}`,
|
|
806
|
-
)
|
|
807
|
-
.join(' / ')
|
|
829
|
+
? v.map((t) => `${termTextOf(t)} ${termPriceTextOf(t)}`).join(' / ')
|
|
808
830
|
: '-',
|
|
809
831
|
},
|
|
810
832
|
],
|
|
@@ -812,15 +834,47 @@ export const plansListCommand = {
|
|
|
812
834
|
);
|
|
813
835
|
|
|
814
836
|
out.head(`我已买的加量包 · ${bundleRows.length} 个`);
|
|
837
|
+
/**
|
|
838
|
+
* ★ 2026-11-16 task-528:**不再读 `bundle.price_cents` / `bundle.period_months`**。
|
|
839
|
+
*
|
|
840
|
+
* 那两列是旧「月价」模型的遗留值(`basic` / `trial_7d` 都停在 ¥180.60、`period_months`
|
|
841
|
+
* 为 null),既不是在售档价也不对应任何能买的东西。
|
|
842
|
+
* 档价按「目录价优先、本行 prices 兜底」展示:
|
|
843
|
+
* · 目录(`listBundlePlans`)按商品档价**实时算**出各档生效价(`basic` = ¥368 / ¥577 / ¥786);
|
|
844
|
+
* · `bundle_price.price_cents` 只是**手填快照**(`basic` 停在 ¥400.10,与生效价不同)
|
|
845
|
+
* ⇒ 只在下架件(不在目录里)时兜底,免得给"买不到的东西"假装报一个现价。
|
|
846
|
+
* ⚠️ 只改展示:不碰库、不碰计价(金额仍由服务端 `bundle-pricing` 算)。
|
|
847
|
+
*/
|
|
848
|
+
const catalogTermsByCode = new Map();
|
|
849
|
+
for (const r of bundlePlanRows) {
|
|
850
|
+
const code = String((r && r.code) || '').trim();
|
|
851
|
+
if (code && Array.isArray(r.terms) && r.terms.length) catalogTermsByCode.set(code, r.terms);
|
|
852
|
+
}
|
|
853
|
+
const bundleDisplayRows = bundleRows.map((r) => {
|
|
854
|
+
const code = String((r && r.code) || '').trim();
|
|
855
|
+
const catalogTerms = catalogTermsByCode.get(code);
|
|
856
|
+
return {
|
|
857
|
+
...r,
|
|
858
|
+
terms_display: Array.isArray(catalogTerms)
|
|
859
|
+
? catalogTerms
|
|
860
|
+
: Array.isArray(r && r.prices)
|
|
861
|
+
? r.prices
|
|
862
|
+
: [],
|
|
863
|
+
};
|
|
864
|
+
});
|
|
815
865
|
out.table(
|
|
816
866
|
[
|
|
817
867
|
{ title: '名称', key: 'name', width: 22 },
|
|
818
868
|
{ title: '代码', key: 'code', width: 16 },
|
|
819
869
|
{ title: '状态', key: 'status', width: 10 },
|
|
820
|
-
{
|
|
821
|
-
|
|
870
|
+
{
|
|
871
|
+
title: '各周期',
|
|
872
|
+
key: 'terms_display',
|
|
873
|
+
width: 40,
|
|
874
|
+
format: (v) => priceListText(v),
|
|
875
|
+
},
|
|
822
876
|
],
|
|
823
|
-
|
|
877
|
+
bundleDisplayRows,
|
|
824
878
|
);
|
|
825
879
|
}
|
|
826
880
|
}
|
|
@@ -837,9 +891,10 @@ export const plansListCommand = {
|
|
|
837
891
|
*
|
|
838
892
|
* ⚠️ 只开放 `--name`(改站名)。**`--remark` 目前发不通,CLI 必须如实报缺口**:
|
|
839
893
|
* 服务端 `updateSite` 的字段白名单是
|
|
840
|
-
* `name / template_id /
|
|
894
|
+
* `name / template_id / settings / domain / domains / expires_at / asset_storage_mode`
|
|
895
|
+
* (★ 2026-11-11 task-85:`status` 已移出白名单,显式传会回 400 `STATUS_NOT_EDITABLE`,
|
|
896
|
+
* 上下架走 `siteOffline` / `siteOnline`)
|
|
841
897
|
* —— 没有 remark;`public.site` 表里也没有这一列(remark 只存在于 customer / wallet_txn /
|
|
842
|
-
* user_debt / invoice_request / site_quota_purchase 这些别的表)。
|
|
843
898
|
* 白名单外的 key 会被**静默忽略**,所以"传了就返回成功"是假成功。与其假装能改备注,
|
|
844
899
|
* 不如明确报错 —— 要支持它得后端先加列 + 加白名单,那是另一个任务。
|
|
845
900
|
* (也**不**用 `settings.remark` 变通:`settings` 是整块覆盖,读-改-写会吞掉原有设置。)
|
package/lib/commands/orders.mjs
CHANGED
|
@@ -22,6 +22,20 @@ import { UsageError, CliError, EXIT } from '../errors.mjs';
|
|
|
22
22
|
import { formatMoney, formatTime } from '../format.mjs';
|
|
23
23
|
import { renderQrOptional } from '../qr.mjs';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* 下单幂等键(★ 2026-11-17 task-627)。
|
|
27
|
+
*
|
|
28
|
+
* 服务端 `billing.orderCreate` 的口径:**同一键同一单**(重放回原单,含新的收银台令牌);
|
|
29
|
+
* 同键带不同参数回 409。CLI 不自动重试(`api.mjs` 约定),所以这里只保证
|
|
30
|
+
* 「每次执行 = 一次新尝试 = 一个新键」,绝不会把两次不同的购买合成一张单。
|
|
31
|
+
* 格式受服务端硬约束:`^[A-Za-z0-9_-]{8,80}$`。
|
|
32
|
+
*/
|
|
33
|
+
function newOrderIdempotencyKey() {
|
|
34
|
+
const rand = Math.random().toString(36).slice(2, 11);
|
|
35
|
+
|
|
36
|
+
return `cli-quota-${Date.now().toString(36)}-${rand}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
/* ------------------------------------------------------------------ */
|
|
26
40
|
/* products list */
|
|
27
41
|
/* ------------------------------------------------------------------ */
|
|
@@ -180,7 +194,19 @@ export const ordersCreateCommand = {
|
|
|
180
194
|
);
|
|
181
195
|
}
|
|
182
196
|
|
|
183
|
-
|
|
197
|
+
/**
|
|
198
|
+
* ★ 2026-11-17(task-627):下单**改调账务域** ——
|
|
199
|
+
* `/cli` → `wkgeo-cli-fc` 白名单转发 → `billing.orderCreate{kind:'quota'}`(网关 `/billing-core`)。
|
|
200
|
+
* 不再打 `/order` 的 `createQuotaOrder`(钱路径只留 billing 一条:
|
|
201
|
+
* `placeOrder` + `fulfillOrder`,金额只从 `product.price_cents` 算)。
|
|
202
|
+
* ⚠️ 必须带 `idempotency_key`:同键重放回原单(不会多建单、不会二次扣余额)。
|
|
203
|
+
*/
|
|
204
|
+
const res = await ctx.callData('orderCreate', {
|
|
205
|
+
kind: 'quota',
|
|
206
|
+
quota_key: quotaKey,
|
|
207
|
+
quota_amount: quotaAmount,
|
|
208
|
+
idempotency_key: newOrderIdempotencyKey(),
|
|
209
|
+
});
|
|
184
210
|
const paid = !!(res && res.paid);
|
|
185
211
|
const data = {
|
|
186
212
|
order_id: (res && res.order_id) || null,
|
package/lib/commands/siteops.mjs
CHANGED
|
@@ -614,7 +614,7 @@ export const domainRecordsCommand = {
|
|
|
614
614
|
],
|
|
615
615
|
domains.map((one) => ({
|
|
616
616
|
hostname: one.hostname || '',
|
|
617
|
-
kind: one.
|
|
617
|
+
kind: one.kind || '',
|
|
618
618
|
verify: one.verify_status || '',
|
|
619
619
|
txt: dnsStateLabel(one.dns_txt && one.dns_txt.ok),
|
|
620
620
|
cname: dnsStateLabel(one.dns_cname && one.dns_cname.ok),
|
package/lib/commands/sites.mjs
CHANGED
|
@@ -732,7 +732,6 @@ export const sitesGetCommand = {
|
|
|
732
732
|
if (detail.cert_status || detail.cert_not_after) {
|
|
733
733
|
out.line(` 证书:${detail.cert_status || '-'}${detail.cert_not_after ? `(到期 ${formatTime(detail.cert_not_after)})` : ''}`);
|
|
734
734
|
}
|
|
735
|
-
if (detail.pool_id) out.line(` 计费池:${detail.pool_id}`);
|
|
736
735
|
if (detail.provision_attempts) out.line(` 开通尝试:${detail.provision_attempts} 次`);
|
|
737
736
|
out.line(` 创建时间:${formatTime(site.created_at)}${detail.updated_at ? ` · 更新时间:${formatTime(detail.updated_at)}` : ''}`);
|
|
738
737
|
if (detail.last_error) out.warn(`最近一次错误:${detail.last_error}${detail.last_error_at ? `(${formatTime(detail.last_error_at)})` : ''}`);
|
|
@@ -1325,6 +1325,13 @@ export const templatesPullCommand = {
|
|
|
1325
1325
|
out.ok(
|
|
1326
1326
|
`已拉取 ${r.fileCount} 个文件(${fmtBytes(r.bytes)}${r.binaryCount ? `,其中二进制 ${r.binaryCount}` : ''})→ ${r.dir}`,
|
|
1327
1327
|
);
|
|
1328
|
+
if (r.skipped && r.skipped.length) {
|
|
1329
|
+
for (const one of r.skipped) {
|
|
1330
|
+
out.warn(
|
|
1331
|
+
`跳过超限文件 ${one.path}(${one.measured}${one.reason === 'binary-bytes' ? ' 字节' : ' 字符'}):大体积演示资产不进站点模板副本,其余文件照常同步`,
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1328
1335
|
out.info(`模板:${r.template.name || '-'}(key ${r.template.key || '-'} · id ${r.template.id || '-'})`);
|
|
1329
1336
|
out.info(`manifest:${r.manifestPath}(contentHash ${r.contentHash.slice(0, 12)}…)`);
|
|
1330
1337
|
out.table(
|
|
@@ -1344,6 +1351,8 @@ export const templatesPullCommand = {
|
|
|
1344
1351
|
binary_count: r.binaryCount,
|
|
1345
1352
|
bytes: r.bytes,
|
|
1346
1353
|
files: r.files,
|
|
1354
|
+
skipped: r.skipped || [],
|
|
1355
|
+
warnings: r.warnings || [],
|
|
1347
1356
|
next: 'wkgeo templates push --dir <目录> --dry-run',
|
|
1348
1357
|
});
|
|
1349
1358
|
},
|
|
@@ -1403,6 +1412,7 @@ export const templatesPushCommand = {
|
|
|
1403
1412
|
template: r.template,
|
|
1404
1413
|
plan: r.plan,
|
|
1405
1414
|
warnings: r.warnings,
|
|
1415
|
+
skipped: r.skipped || [],
|
|
1406
1416
|
applied: r.applied === true,
|
|
1407
1417
|
written: r.written,
|
|
1408
1418
|
content_hash: r.contentHash || null,
|
package/lib/errors.mjs
CHANGED
|
@@ -264,6 +264,37 @@ export function classifyResponse({ httpStatus = 200, body = null, action = '', r
|
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
if (codeNum === 404) return bad('not_found', message || '资源不存在', { code: 404 });
|
|
267
|
+
/**
|
|
268
|
+
* ★ 2026-11-17(task-627):**409 = 状态冲突**(下单打进来才有,之前落到 `unknown`)。
|
|
269
|
+
*
|
|
270
|
+
* 两种要分开:
|
|
271
|
+
* · `idempotency_mismatch` —— 同一幂等键的参数与已建订单不一致(**这一单其实已经建好了**)。
|
|
272
|
+
* 服务端原文带实现词 `idempotency_key`,**不能照抄给用户**,翻成"别重复下单 + 怎么继续付";
|
|
273
|
+
* · 其余(`ICP_ASSIST_OPEN_ORDER_EXISTS` 还有未完成服务单 / `VIP_ALREADY_ACTIVE` 仍在有效期)
|
|
274
|
+
* 后端文案本身就是人话 ⇒ 原样透出,只补一句下一步。
|
|
275
|
+
*/
|
|
276
|
+
if (codeNum === 409) {
|
|
277
|
+
const biz = String(
|
|
278
|
+
(body && (body.error_code || (body.data && body.data.code))) || '',
|
|
279
|
+
);
|
|
280
|
+
if (biz === 'idempotency_mismatch' || /idempotency/i.test(message)) {
|
|
281
|
+
return bad(
|
|
282
|
+
'conflict',
|
|
283
|
+
'这一单已经创建,请不要重复下单:订单 30 分钟内未支付会自动关闭(优惠券随之释放),' +
|
|
284
|
+
'关闭后再重新下单即可;也可以在网页「我的订单」里继续支付。',
|
|
285
|
+
{
|
|
286
|
+
code: 409,
|
|
287
|
+
hint:
|
|
288
|
+
`先 \`${cmdName} orders list\` 看这一单在不在;待支付就去网页收银台付,` +
|
|
289
|
+
`或 \`${cmdName} orders pay <订单号>\` 查一次状态。**不要**换个参数再下一单(会锁券、留多张待支付单)。`,
|
|
290
|
+
},
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return bad('conflict', message || '该操作与当前状态冲突,请刷新后重试', {
|
|
294
|
+
code: 409,
|
|
295
|
+
hint: '按提示处理后再试;不要靠重复下单绕过(会锁券 / 留下多张待支付单)。',
|
|
296
|
+
});
|
|
297
|
+
}
|
|
267
298
|
if (codeNum === 400) {
|
|
268
299
|
// 内容类自持动作没带站点(`content-core.js` 的「缺少 siteId:CLI 内容动作必须指定站点…」)
|
|
269
300
|
if (/缺少 siteId|指定站点/.test(message)) {
|