MCPcopy Create free account
hub / github.com/dyoshikawa/rulesync / updateCommand

Function updateCommand

src/cli/commands/update.ts:27–100  ·  view source on GitHub ↗
(
  logger: Logger,
  currentVersion: string,
  options: UpdateCommandOptions,
)

Source from the content-addressed store, hash-verified

25 * Update command handler
26 */
27export async function updateCommand(
28 logger: Logger,
29 currentVersion: string,
30 options: UpdateCommandOptions,
31): Promise<void> {
32 const { check = false, force = false, token } = options;
33
34 try {
35 const environment = detectExecutionEnvironment();
36 logger.debug(`Detected environment: ${environment}`);
37
38 if (environment === "npm") {
39 logger.info(getNpmUpgradeInstructions());
40 return;
41 }
42
43 if (environment === "homebrew") {
44 logger.info(getHomebrewUpgradeInstructions());
45 return;
46 }
47
48 // Single-binary mode
49 if (check) {
50 // Check-only mode
51 logger.info("Checking for updates...");
52 const updateCheck = await checkForUpdate(currentVersion, token);
53
54 // Capture JSON data if in JSON mode
55 if (logger.jsonMode) {
56 logger.captureData("currentVersion", updateCheck.currentVersion);
57 logger.captureData("latestVersion", updateCheck.latestVersion);
58 logger.captureData("updateAvailable", updateCheck.hasUpdate);
59 logger.captureData(
60 "message",
61 updateCheck.hasUpdate
62 ? `Update available: ${updateCheck.currentVersion} -> ${updateCheck.latestVersion}`
63 : `Already at the latest version (${updateCheck.currentVersion})`,
64 );
65 }
66
67 if (updateCheck.hasUpdate) {
68 logger.success(
69 `Update available: ${updateCheck.currentVersion} -> ${updateCheck.latestVersion}`,
70 );
71 } else {
72 logger.info(`Already at the latest version (${updateCheck.currentVersion})`);
73 }
74 return;
75 }
76
77 // Perform update
78 logger.info("Checking for updates...");
79 const message = await performBinaryUpdate(currentVersion, { force, token });
80 logger.success(message);
81 } catch (error) {
82 if (error instanceof GitHubClientError) {
83 // Include auth hints in error message for JSON mode
84 const authHint =

Callers 2

mainFunction · 0.85
update.test.tsFile · 0.85

Calls 9

checkForUpdateFunction · 0.85
performBinaryUpdateFunction · 0.85
debugMethod · 0.45
infoMethod · 0.45
captureDataMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…