@tamai/hub-cli 0.1.9 → 0.1.10

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 CHANGED
@@ -158,6 +158,9 @@ hub infra list --management all # 他社管理を含む全件
158
158
  hub infra show example.jp
159
159
  hub infra update example.jp --status to_cancel --reason '11/30までに解約と決めた'
160
160
  hub infra update example.jp --prod-platform none # 本番の置き場なし(確定値)
161
+ hub infra update example.jp --renew-source bundled --bundle-server motokura
162
+ hub infra update example.jp --transfer-to cloudflare --transfer-stage awaiting_approval \
163
+ --transfer-due 2026-09-26T11:00:00+09:00
161
164
  hub infra note example.jp --note 'Xserverのパネルで自動更新onを確認'
162
165
  hub infra note example.jp --note-file /tmp/note.md
163
166
  hub infra note example.jp --note '…' --operation-id 01M33H236V8MACB2DFR641ATK3 # 送り直し
@@ -171,6 +174,20 @@ hub infra unlink example.jp # 紐付けを全部外す
171
174
  1回だけ再試行する。`link` は現在の紐付けへ追加、`unlink` は指定分を削除し、APIへはどちらも
172
175
  `PUT /:id/projects` の全置換として送る。
173
176
 
177
+ `--renew-source` は更新の**方式**(`paid` / `bundled`)で、`--auto-renew`(確認できた更新状態)とは
178
+ **別の軸**である。特典ドメインでも `on` には化けない——特典元のサーバー契約が解約されれば更新は止まる。
179
+ `--bundle-server` は特典元のサーバーで、`bundled` のときだけ持てる(`--hosted-on` と同じく名前かIDで指定する)。
180
+ 収容先(どのサーバーに乗っているか)とは別の事実なので、一致しない行がある。
181
+
182
+ `--transfer-to` / `--transfer-stage` / `--transfer-due` は移管の進み。段階は
183
+ `requested` / `awaiting_approval` / `approved` / `rejected` / `cancelled` で、`rejected` と `cancelled` は
184
+ `provider` を変えない(移管しなかった)。`--transfer-due` は**時刻を含む** ISO 8601 だけを受ける。
185
+ 移管の完了は `--provider <移管先> --transfer-to none --transfer-stage none --transfer-due none` を
186
+ 1回で送る(移管先が残ったまま `--provider` を変えると400)。
187
+ **移管の3項目を含む更新は409で自動再送しない**(`--reason` と同じ扱い。段階は人が申請・承認メールを
188
+ 見て書く値なので、取り直して自分の古い認識で巻き戻さない)。
189
+ 特典元にしているドメインがあるサーバーは、`hub infra` からは消せない(APIが409で拒む)。
190
+
174
191
  `note` は台帳の**経緯**を1件足す(`POST /:id/notes`)。資産の `version` を進めないので、
175
192
  画面を開いたまま追記しても、そのあとの保存が競合しない。本文は2,000文字までで**分割しない**
176
193
  (`hub task note` と違い、長い本文は要点へ縮める。旧メモの原文保管はCLIでは行わない)。
@@ -28,9 +28,29 @@ const OPTION_FIELDS = {
28
28
  "account-ref": "account_ref",
29
29
  note: "note",
30
30
  "hosted-on-basis": "hosted_on_basis",
31
+ // 特典と移管(記録191 / migration 0029)。`--bundle-server` だけは名前解決が要るので
32
+ // ここには入れず、`--hosted-on` と同じ扱いで別に処理する
33
+ "renew-source": "renew_source",
34
+ "transfer-to": "transfer_to",
35
+ "transfer-stage": "transfer_stage",
36
+ "transfer-due": "transfer_due_at",
31
37
  };
32
38
 
33
- const ALLOWED_OPTIONS = [...Object.keys(OPTION_FIELDS), "append-note", "hosted-on", "reason"];
39
+ const ALLOWED_OPTIONS = [
40
+ ...Object.keys(OPTION_FIELDS), "append-note", "hosted-on", "reason", "bundle-server",
41
+ ];
42
+
43
+ /**
44
+ * 移管の3項目を含む更新は **409 で自動再送しない**(所見 Medium 2・記録191)。
45
+ *
46
+ * 理由(`--reason`)と同じ扱いである。移管は「いまどこまで進んだか」を人が外の出来事
47
+ * (申請・承認メール・authcode)を見て書く列で、取り直して送り直すと**他人が進めた段階を
48
+ * 自分の古い認識で巻き戻す**。`--renew-source` / `--bundle-server` は現在値に依存しない
49
+ * ので再送してよい。
50
+ */
51
+ const TRANSFER_OPTIONS = ["transfer-to", "transfer-stage", "transfer-due"];
52
+ const TRANSFER_CONFLICT_GUIDANCE =
53
+ "移管の更新は自動で再送しません。最新の段階を確認してからもう一度実行してください";
34
54
 
35
55
  /**
36
56
  * `--append-note` は次の版で外す(記録188 §3.5)。既存noteの末尾へ「 / 」で足す作りは、
@@ -52,6 +72,10 @@ const NULLABLE_VALUE_OPTIONS = new Set([
52
72
  "migration-plan",
53
73
  "contract",
54
74
  "hosted-on-basis",
75
+ "renew-source",
76
+ "transfer-to",
77
+ "transfer-stage",
78
+ "transfer-due",
55
79
  ]);
56
80
 
57
81
  function amountValue(value) {
@@ -129,6 +153,18 @@ export const infraUpdateCommand = {
129
153
  }
130
154
  }
131
155
 
156
+ // 特典元も server の名前かidで指定する(`--hosted-on` と同じ解決。記録191)
157
+ if (flags["bundle-server"]) {
158
+ const bundleReference = options["bundle-server"].trim();
159
+ if (bundleReference === "none") {
160
+ prepared.bundle_server = null;
161
+ } else {
162
+ const bundle = await getInfraAsset(bundleReference, api, { kind: "server" });
163
+ if (bundle.item.kind !== "server") throw cliError("--bundle-server にはserver資産の名前またはidを指定してください");
164
+ prepared.bundle_server = bundle.item.id;
165
+ }
166
+ }
167
+
132
168
  for (let attempt = 0; attempt < 2; attempt += 1) {
133
169
  try {
134
170
  const payload = await api(`/api/infra/assets/${encodeURIComponent(current.id)}`, {
@@ -142,6 +178,10 @@ export const infraUpdateCommand = {
142
178
  // 理由つきは取り直して送り直さない。**書いた理由が古い前提のままになる**ので、
143
179
  // 人が最新を読んで理由を書き直す(所見 Medium 2・記録188 §3.5)
144
180
  if (reason !== null) throw withGuidance(error, REASON_CONFLICT_GUIDANCE);
181
+ // 移管も同じ(記録191)。段階は外の出来事を見て人が書く値なので巻き戻さない
182
+ if (TRANSFER_OPTIONS.some((name) => flags[name])) {
183
+ throw withGuidance(error, TRANSFER_CONFLICT_GUIDANCE);
184
+ }
145
185
  if (attempt === 1) {
146
186
  throw withGuidance(error, "再取得後にも競合しました。最新の内容を確認してから、もう一度実行してください");
147
187
  }
package/lib/args.mjs CHANGED
@@ -119,6 +119,11 @@ export const INFRA_USAGE = `使い方:
119
119
  [--note <text>] [--append-note <text>]
120
120
  [--hosted-on <server name|id>|none]
121
121
  [--hosted-on-basis <value>|none]
122
+ [--renew-source paid|bundled|none]
123
+ [--bundle-server <server name|id>|none]
124
+ [--transfer-to <provider>|none]
125
+ [--transfer-stage <stage>|none]
126
+ [--transfer-due <ISO8601>|none]
122
127
  [--reason <text>] [--json]
123
128
  hub infra note <name|id> (--note <text> | --note-file <path>)
124
129
  [--operation-id <ULID>] [--json]
@@ -136,12 +141,23 @@ export const INFRA_USAGE = `使い方:
136
141
  note は台帳の経緯を1件足す(2,000文字まで・分割しない)。noteは資産のversionを進めない
137
142
  ので、シートを開いたまま追記しても、その後の保存が競合しない。
138
143
  --note-file はファイルの中身をそのまま1件として送る(超過分は切らずにエラーにする)。
144
+ --renew-source は更新の方式(paid=自分で払う / bundled=サーバー契約の特典)。
145
+ --bundle-server は特典元のサーバー(--renew-source bundled のときだけ持てる)。
146
+ **--auto-renew は別の軸**で、特典でも on には化けない(確認できた更新状態を書く)。
147
+ --transfer-to / --transfer-stage / --transfer-due は移管の進み。段階は
148
+ requested / awaiting_approval / approved / rejected / cancelled。
149
+ --transfer-due は時刻を含むISO 8601(例 2026-09-26T11:00:00+09:00)。日付だけは受け付けない。
150
+ 移管の完了は「--provider <移管先> --transfer-to none --transfer-stage none --transfer-due none」を
151
+ 1回で送る(移管先が残ったまま --provider を変えると400)。
152
+ **移管の3項目を含む更新は409で自動再送しない**(--reason と同じ。段階は人が外の出来事を
153
+ 見て書く値なので、取り直して巻き戻さない)。
139
154
  note の操作IDは1操作につき1つ。応答の前に通信が切れた失敗だけ、**同じIDで1回だけ**
140
155
  送り直す(届いていればAPIが既存のイベントを返すので二重に積まれない)。
141
156
  失敗すると「操作ID: …」を出すので、後から送り直すときは --operation-id <ULID> に
142
157
  その値を渡す(素で打ち直すと別の操作になり、届いていた場合は2件積まれる)。
143
158
  server資産には dns-host / mail-host / migration-plan / hosted-on / hosted-on-basis /
144
- prod-platform / prod-ref を指定できない。
159
+ prod-platform / prod-ref / renew-source / bundle-server / transfer-to / transfer-stage /
160
+ transfer-due を指定できない。
145
161
  link は現在の紐付けへ追加し、unlink は指定分を外す。unlink の --project 省略は全解除。
146
162
  作成・削除はCLIから行えない。
147
163
  オプションは --name=value の形でも書ける(値が -- で始まるときはこの形で渡す)。
package/lib/format.mjs CHANGED
@@ -228,6 +228,34 @@ function remainingDays(expiresOn, now = new Date()) {
228
228
  return `残${days}日`;
229
229
  }
230
230
 
231
+ /**
232
+ * 特典の印(記録191)。`bundled` の行だけに出す。特典元が未確定なら**そう書く**
233
+ * ——「特典」だけだと、更新が誰の契約に乗っているか分からないまま安心してしまう。
234
+ */
235
+ function bundleMark(item) {
236
+ if (item?.renew_source !== "bundled") return "";
237
+ const server = item?.bundle_server;
238
+ const name = server === null || server === undefined ? "" : oneLineValue(server.name);
239
+ return name === "" ? " [特典:元サーバー未確定]" : ` [特典:${name}]`;
240
+ }
241
+
242
+ /**
243
+ * 移管中の印(記録191)。`rejected` / `cancelled` は「移管しなかった」なので
244
+ * 移管先を出さない——出すと、まだ動いているように読める。
245
+ */
246
+ function transferMark(item) {
247
+ const stage = item?.transfer_stage;
248
+ if (stage === null || stage === undefined) return "";
249
+ if (stage === "rejected") return " [移管:却下]";
250
+ if (stage === "cancelled") return " [移管:中止]";
251
+ const due = item?.transfer_due_at ? ` 期限${oneLineValue(item.transfer_due_at)}` : "";
252
+ return ` [移管→${displayValue(item?.transfer_to)}:${displayValue(stage)}${due}]`;
253
+ }
254
+
255
+ function oneLineValue(value) {
256
+ return String(value ?? "").replace(/\s+/g, " ").trim();
257
+ }
258
+
231
259
  export function infraListLine(item, now = new Date()) {
232
260
  const projects = Array.isArray(item?.projects)
233
261
  ? item.projects.map((project) => displayValue(project?.slug)).filter((slug) => slug !== "-")
@@ -238,9 +266,9 @@ export function infraListLine(item, now = new Date()) {
238
266
  `[${displayValue(item?.kind)}]`,
239
267
  `provider:${displayValue(item?.provider)}`,
240
268
  `status:${displayValue(item?.status)}`,
241
- `auto-renew:${displayValue(item?.auto_renew)}`,
269
+ `auto-renew:${displayValue(item?.auto_renew)}${bundleMark(item)}`,
242
270
  `expires:${displayValue(item?.expires_on)} (${remainingDays(item?.expires_on, now)})`,
243
- `projects:${projects.join(",") || "-"}${external}`,
271
+ `projects:${projects.join(",") || "-"}${external}${transferMark(item)}`,
244
272
  ].join(" ");
245
273
  }
246
274
 
@@ -248,7 +276,8 @@ export function infraAssetLines(item) {
248
276
  const fields = [
249
277
  "id", "provider", "status", "management", "auto_renew", "expires_on", "purpose",
250
278
  "dns_host", "mail_host", "migration_plan", "hosted_on_basis", "prod_platform", "prod_ref",
251
- "contract", "amount_yen", "payer", "holder", "account", "account_ref", "note", "version",
279
+ "contract", "amount_yen", "payer", "holder", "account", "account_ref", "note",
280
+ "renew_source", "transfer_to", "transfer_stage", "transfer_due_at", "version",
252
281
  "created_at", "updated_at",
253
282
  ];
254
283
  const lines = [`${displayValue(item?.name)} [${displayValue(item?.kind)}]`];
@@ -259,6 +288,15 @@ export function infraAssetLines(item) {
259
288
  : `${displayValue(item.hosted_on.name)} (${displayValue(item.hosted_on.id)})`;
260
289
  lines.splice(11, 0, `hosted_on: ${hosted}`);
261
290
  }
291
+ // 特典元は名前とid、そして**特典元の契約の状態**を添える(記録191)。
292
+ // 依存警告の根拠(解約予定・期限)を人が同じ行で読めるようにする
293
+ if (item?.bundle_server !== undefined) {
294
+ const bundle = item.bundle_server === null
295
+ ? "-"
296
+ : `${displayValue(item.bundle_server.name)} (${displayValue(item.bundle_server.id)})`
297
+ + ` status:${displayValue(item.bundle_server_status)} expires:${displayValue(item.bundle_server_expires_on)}`;
298
+ lines.push(`bundle_server: ${bundle}`);
299
+ }
262
300
  const projects = Array.isArray(item?.projects)
263
301
  ? item.projects.map((project) => `${displayValue(project?.slug)}(${displayValue(project?.name)})`)
264
302
  : [];
package/lib/infra.mjs CHANGED
@@ -11,6 +11,13 @@ export const INFRA_DOMAIN_ONLY_OPTIONS = [
11
11
  "hosted-on-basis",
12
12
  "prod-platform",
13
13
  "prod-ref",
14
+ // 特典と移管(migration 0029 / 記録191)。**DBのCHECKには入っていない**ので、
15
+ // server 行で弾いているのは Worker の routes とこの表だけ
16
+ "renew-source",
17
+ "bundle-server",
18
+ "transfer-to",
19
+ "transfer-stage",
20
+ "transfer-due",
14
21
  ];
15
22
 
16
23
  function oneLine(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamai/hub-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "CLI for the hub personal dashboard: D1-backed task board and project registry.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",