Skip to content

Commit a1071c9

Browse files
authored
feat: geonic cli update コマンドを追加 (#94)
* feat: `geonic cli update` コマンドを追加 `npm update -g @geolonia/geonicdb-cli` のエイリアスとして `geonic cli update` で CLI を最新版に更新できるようにした。 * docs: CHANGELOG に cli update エントリを追加 * fix: `cli update` で --dry-run グローバルオプションに対応
1 parent 4930149 commit a1071c9

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
## [Unreleased]
99

1010
### 2026-04-03
11+
- **Feat**: `geonic cli update` コマンドを追加 — `npm update -g` のエイリアスとして CLI を最新版に更新可能に (#94)
1112
- **Fix**: 複数ターミナルで同一プロファイルを使用時、refresh token rotation によりセッションが無効化される問題を修正 — トークンリフレッシュ前に config を再読み込みし、別プロセスが既にリフレッシュ済みならそのトークンを使用する (#93)
1213

1314
## [0.9.0] - 2026-03-25

src/commands/cli.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import { execSync } from "node:child_process";
12
import { createRequire } from "node:module";
23
import type { Command, Option } from "commander";
4+
import { printInfo, printSuccess } from "../output.js";
5+
import { withErrorHandler, resolveOptions } from "../helpers.js";
36
import { addExamples } from "./help.js";
47

58
function findOption(
@@ -275,4 +278,29 @@ export function registerCliCommand(program: Command): void {
275278
command: "geonic cli version",
276279
},
277280
]);
281+
282+
const update = cli
283+
.command("update")
284+
.description("Update the CLI to the latest version")
285+
.action(
286+
withErrorHandler(async (...args: unknown[]) => {
287+
const cmd = args[args.length - 1] as Command;
288+
const opts = resolveOptions(cmd);
289+
const updateCommand = "npm update -g @geolonia/geonicdb-cli";
290+
if (opts.dryRun) {
291+
printInfo(`[dry-run] ${updateCommand}`);
292+
return;
293+
}
294+
printInfo("Updating @geolonia/geonicdb-cli...");
295+
execSync(updateCommand, { stdio: "inherit" });
296+
printSuccess("Update complete.");
297+
}),
298+
);
299+
300+
addExamples(update, [
301+
{
302+
description: "Update CLI to the latest version",
303+
command: "geonic cli update",
304+
},
305+
]);
278306
}

0 commit comments

Comments
 (0)