@tamai/hub-cli 0.1.10 → 0.1.11
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/README.md +7 -1
- package/commands/infra-update.mjs +27 -1
- package/lib/args.mjs +7 -1
- package/lib/format.mjs +18 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ hub task brief 183 --role review --worker codex1 --out /tmp/brief-183.md --sandb
|
|
|
156
156
|
hub infra list # 自分で管理する資産だけ(既定)
|
|
157
157
|
hub infra list --management all # 他社管理を含む全件
|
|
158
158
|
hub infra show example.jp
|
|
159
|
-
hub infra update example.jp --
|
|
159
|
+
hub infra update example.jp --renewal-policy let_expire --reason '11/30までに解約と決めた'
|
|
160
160
|
hub infra update example.jp --prod-platform none # 本番の置き場なし(確定値)
|
|
161
161
|
hub infra update example.jp --renew-source bundled --bundle-server motokura
|
|
162
162
|
hub infra update example.jp --transfer-to cloudflare --transfer-stage awaiting_approval \
|
|
@@ -174,6 +174,12 @@ hub infra unlink example.jp # 紐付けを全部外す
|
|
|
174
174
|
1回だけ再試行する。`link` は現在の紐付けへ追加、`unlink` は指定分を削除し、APIへはどちらも
|
|
175
175
|
`PUT /:id/projects` の全置換として送る。
|
|
176
176
|
|
|
177
|
+
`--status` は契約の**現在**(`active`=契約中 / `cancelled`=終了 / `needs_review`=要確認)で、
|
|
178
|
+
`--renewal-policy` が継続の**意思**(`renew` / `let_expire` / `cancel_now` / `while_bundled` / `undecided`)を持つ。
|
|
179
|
+
`--status to_cancel` と `--migration-plan cancel` は**APIを呼ぶ前にCLIが拒否**する——どちらも意思なので
|
|
180
|
+
`--renewal-policy` へ移った(台帳に残っている行はデータ移行で消える)。`--renewal-policy none` は
|
|
181
|
+
`undecided` へ戻す(NOT NULLの列なので空にはしない)。
|
|
182
|
+
|
|
177
183
|
`--renew-source` は更新の**方式**(`paid` / `bundled`)で、`--auto-renew`(確認できた更新状態)とは
|
|
178
184
|
**別の軸**である。特典ドメインでも `on` には化けない——特典元のサーバー契約が解約されれば更新は止まる。
|
|
179
185
|
`--bundle-server` は特典元のサーバーで、`bundled` のときだけ持てる(`--hosted-on` と同じく名前かIDで指定する)。
|
|
@@ -34,12 +34,28 @@ const OPTION_FIELDS = {
|
|
|
34
34
|
"transfer-to": "transfer_to",
|
|
35
35
|
"transfer-stage": "transfer_stage",
|
|
36
36
|
"transfer-due": "transfer_due_at",
|
|
37
|
+
// 継続の意思(記録192 / migration 0030)。`status`(契約の現在)とは別の軸
|
|
38
|
+
"renewal-policy": "renewal_policy",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 互換で残した値(記録192)。APIも400にするが、**往復する前にCLIが止める**——
|
|
43
|
+
* 打ち間違いではなく「古い言い方が手に残っている」ので、案内を先に出す方が早い。
|
|
44
|
+
*/
|
|
45
|
+
const LEGACY_VALUES = {
|
|
46
|
+
status: {
|
|
47
|
+
to_cancel: "status に to_cancel は書けません。継続の意思は --renewal-policy let_expire / cancel_now で指定します",
|
|
48
|
+
},
|
|
49
|
+
"migration-plan": {
|
|
50
|
+
cancel: "migration-plan に cancel は書けません。継続の意思は --renewal-policy let_expire / cancel_now で指定します",
|
|
51
|
+
},
|
|
37
52
|
};
|
|
38
53
|
|
|
39
54
|
const ALLOWED_OPTIONS = [
|
|
40
55
|
...Object.keys(OPTION_FIELDS), "append-note", "hosted-on", "reason", "bundle-server",
|
|
41
56
|
];
|
|
42
57
|
|
|
58
|
+
|
|
43
59
|
/**
|
|
44
60
|
* 移管の3項目を含む更新は **409 で自動再送しない**(所見 Medium 2・記録191)。
|
|
45
61
|
*
|
|
@@ -116,6 +132,14 @@ export const infraUpdateCommand = {
|
|
|
116
132
|
reason = options.reason.trim();
|
|
117
133
|
if (reason === "") throw usageError("--reason に空文字は指定できません");
|
|
118
134
|
}
|
|
135
|
+
// **互換で残した値はAPIを呼ぶ前に止める**(記録192・codex2 Medium 1)。引数だけで決まる
|
|
136
|
+
// 拒否なので、認証も接続も無い場所で打っても案内が出る——詳細GETの後ろに置くと、
|
|
137
|
+
// 台帳が引けないときに「古い言い方だ」と気づけない
|
|
138
|
+
for (const [option, values] of Object.entries(LEGACY_VALUES)) {
|
|
139
|
+
if (!flags[option]) continue;
|
|
140
|
+
const legacy = values[options[option].trim()];
|
|
141
|
+
if (legacy !== undefined) throw usageError(legacy);
|
|
142
|
+
}
|
|
119
143
|
if (flags["append-note"]) dependencies.stderr.write(APPEND_NOTE_DEPRECATION);
|
|
120
144
|
|
|
121
145
|
let currentPayload = await getInfraAsset(reference, api);
|
|
@@ -129,7 +153,9 @@ export const infraUpdateCommand = {
|
|
|
129
153
|
for (const [option, field] of Object.entries(OPTION_FIELDS)) {
|
|
130
154
|
if (!flags[option] || option === "note") continue;
|
|
131
155
|
const value = options[option].trim();
|
|
132
|
-
|
|
156
|
+
// 継続方針は NOT NULL の列なので、`none` は null ではなく `undecided` へ戻す
|
|
157
|
+
if (option === "renewal-policy") prepared[field] = value === "none" ? "undecided" : value;
|
|
158
|
+
else if (option === "expires") prepared[field] = value === "none" ? null : value;
|
|
133
159
|
else if (option === "amount") prepared[field] = amountValue(value);
|
|
134
160
|
else if (NULLABLE_VALUE_OPTIONS.has(option) && value === "none") prepared[field] = null;
|
|
135
161
|
else prepared[field] = value;
|
package/lib/args.mjs
CHANGED
|
@@ -108,7 +108,9 @@ export const INFRA_USAGE = `使い方:
|
|
|
108
108
|
hub infra list [--kind server|domain] [--status <status[,status...]>] [--management self|external|all]
|
|
109
109
|
[--project <slug>] [--q <text>] [--json]
|
|
110
110
|
hub infra show <name|id> [--json]
|
|
111
|
-
hub infra update <name|id> [--status
|
|
111
|
+
hub infra update <name|id> [--status active|cancelled|needs_review]
|
|
112
|
+
[--renewal-policy renew|let_expire|cancel_now|while_bundled|undecided|none]
|
|
113
|
+
[--auto-renew on|off|unknown]
|
|
112
114
|
[--expires YYYY-MM-DD|none] [--dns-host <value>|none]
|
|
113
115
|
[--mail-host <value>|none] [--migration-plan <value>|none]
|
|
114
116
|
[--management self|external] [--purpose <text>]
|
|
@@ -134,6 +136,10 @@ export const INFRA_USAGE = `使い方:
|
|
|
134
136
|
list の --status はカンマ区切りで複数指定できる。
|
|
135
137
|
show / update / link / unlink の資産は名前の完全一致またはidで指定する。
|
|
136
138
|
update は指定した項目だけを更新する。version競合時は最新を取り直して1回だけ再試行する。
|
|
139
|
+
--status は契約の**現在**(active=契約中 / cancelled=終了 / needs_review=要確認)。
|
|
140
|
+
--renewal-policy は継続の**意思**(更新するか)。--status to_cancel と
|
|
141
|
+
--migration-plan cancel は書けない(どちらも意思なので --renewal-policy へ移す)。
|
|
142
|
+
--renewal-policy none は要判断(undecided)へ戻す(NOT NULLの列なので空にはしない)。
|
|
137
143
|
--reason は更新の理由(500文字まで)。値の変更と一緒に指定する(理由だけの更新はできない)。
|
|
138
144
|
**--reason を含む更新は409で自動再送しない**(理由は読んだ状態に依存するため、
|
|
139
145
|
最新を確認して書き直す)。
|
package/lib/format.mjs
CHANGED
|
@@ -243,6 +243,22 @@ function bundleMark(item) {
|
|
|
243
243
|
* 移管中の印(記録191)。`rejected` / `cancelled` は「移管しなかった」なので
|
|
244
244
|
* 移管先を出さない——出すと、まだ動いているように読める。
|
|
245
245
|
*/
|
|
246
|
+
/**
|
|
247
|
+
* 継続方針(記録192)。**`renew` は出さない**——一覧の大半がそれになり、密度だけ食う
|
|
248
|
+
* (SPAのバッジと同じ流儀)。`undecided` は出す(意思を決めていない行は拾いたい)。
|
|
249
|
+
*/
|
|
250
|
+
const RENEWAL_POLICY_MARKS = {
|
|
251
|
+
let_expire: "期限で終了",
|
|
252
|
+
cancel_now: "解約手続き中",
|
|
253
|
+
while_bundled: "特典が続く間",
|
|
254
|
+
undecided: "要判断",
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
function policyMark(item) {
|
|
258
|
+
const mark = RENEWAL_POLICY_MARKS[item?.renewal_policy];
|
|
259
|
+
return mark === undefined ? "" : ` [方針:${mark}]`;
|
|
260
|
+
}
|
|
261
|
+
|
|
246
262
|
function transferMark(item) {
|
|
247
263
|
const stage = item?.transfer_stage;
|
|
248
264
|
if (stage === null || stage === undefined) return "";
|
|
@@ -265,7 +281,7 @@ export function infraListLine(item, now = new Date()) {
|
|
|
265
281
|
displayValue(item?.name),
|
|
266
282
|
`[${displayValue(item?.kind)}]`,
|
|
267
283
|
`provider:${displayValue(item?.provider)}`,
|
|
268
|
-
`status:${displayValue(item?.status)}`,
|
|
284
|
+
`status:${displayValue(item?.status)}${policyMark(item)}`,
|
|
269
285
|
`auto-renew:${displayValue(item?.auto_renew)}${bundleMark(item)}`,
|
|
270
286
|
`expires:${displayValue(item?.expires_on)} (${remainingDays(item?.expires_on, now)})`,
|
|
271
287
|
`projects:${projects.join(",") || "-"}${external}${transferMark(item)}`,
|
|
@@ -274,7 +290,7 @@ export function infraListLine(item, now = new Date()) {
|
|
|
274
290
|
|
|
275
291
|
export function infraAssetLines(item) {
|
|
276
292
|
const fields = [
|
|
277
|
-
"id", "provider", "status", "management", "auto_renew", "expires_on", "purpose",
|
|
293
|
+
"id", "provider", "status", "renewal_policy", "management", "auto_renew", "expires_on", "purpose",
|
|
278
294
|
"dns_host", "mail_host", "migration_plan", "hosted_on_basis", "prod_platform", "prod_ref",
|
|
279
295
|
"contract", "amount_yen", "payer", "holder", "account", "account_ref", "note",
|
|
280
296
|
"renew_source", "transfer_to", "transfer_stage", "transfer_due_at", "version",
|