hermes-git 0.2.3 → 0.2.4
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/dist/index.js +74 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25809,9 +25809,81 @@ Project-specific:`);
|
|
|
25809
25809
|
});
|
|
25810
25810
|
}
|
|
25811
25811
|
|
|
25812
|
+
// src/lib/update-notifier.ts
|
|
25813
|
+
import { readFile as readFile4, writeFile as writeFile4, mkdir as mkdir3 } from "fs/promises";
|
|
25814
|
+
import { existsSync as existsSync4 } from "fs";
|
|
25815
|
+
import { homedir } from "os";
|
|
25816
|
+
import path2 from "path";
|
|
25817
|
+
var PACKAGE_NAME = "hermes-git";
|
|
25818
|
+
var CHECK_INTERVAL = 24 * 60 * 60 * 1000;
|
|
25819
|
+
var CACHE_DIR = path2.join(homedir(), ".hermes", "cache");
|
|
25820
|
+
var CACHE_FILE = path2.join(CACHE_DIR, "update-check.json");
|
|
25821
|
+
async function getLatestVersion() {
|
|
25822
|
+
try {
|
|
25823
|
+
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`);
|
|
25824
|
+
if (!response.ok)
|
|
25825
|
+
return null;
|
|
25826
|
+
const data = await response.json();
|
|
25827
|
+
return data.version || null;
|
|
25828
|
+
} catch {
|
|
25829
|
+
return null;
|
|
25830
|
+
}
|
|
25831
|
+
}
|
|
25832
|
+
async function readCache() {
|
|
25833
|
+
try {
|
|
25834
|
+
if (!existsSync4(CACHE_FILE))
|
|
25835
|
+
return null;
|
|
25836
|
+
const content = await readFile4(CACHE_FILE, "utf-8");
|
|
25837
|
+
return JSON.parse(content);
|
|
25838
|
+
} catch {
|
|
25839
|
+
return null;
|
|
25840
|
+
}
|
|
25841
|
+
}
|
|
25842
|
+
async function writeCache(cache) {
|
|
25843
|
+
try {
|
|
25844
|
+
await mkdir3(CACHE_DIR, { recursive: true });
|
|
25845
|
+
await writeFile4(CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
25846
|
+
} catch {}
|
|
25847
|
+
}
|
|
25848
|
+
function isNewerVersion(current, latest) {
|
|
25849
|
+
const currentParts = current.split(".").map(Number);
|
|
25850
|
+
const latestParts = latest.split(".").map(Number);
|
|
25851
|
+
for (let i = 0;i < 3; i++) {
|
|
25852
|
+
if (latestParts[i] > currentParts[i])
|
|
25853
|
+
return true;
|
|
25854
|
+
if (latestParts[i] < currentParts[i])
|
|
25855
|
+
return false;
|
|
25856
|
+
}
|
|
25857
|
+
return false;
|
|
25858
|
+
}
|
|
25859
|
+
async function checkForUpdates(currentVersion) {
|
|
25860
|
+
try {
|
|
25861
|
+
const cache = await readCache();
|
|
25862
|
+
const now = Date.now();
|
|
25863
|
+
const shouldCheck = !cache || now - cache.lastChecked > CHECK_INTERVAL;
|
|
25864
|
+
let latestVersion = cache?.latestVersion || null;
|
|
25865
|
+
if (shouldCheck) {
|
|
25866
|
+
latestVersion = await getLatestVersion();
|
|
25867
|
+
await writeCache({
|
|
25868
|
+
lastChecked: now,
|
|
25869
|
+
latestVersion: latestVersion || undefined
|
|
25870
|
+
});
|
|
25871
|
+
}
|
|
25872
|
+
if (latestVersion && isNewerVersion(currentVersion, latestVersion)) {
|
|
25873
|
+
console.log(source_default.yellow(`
|
|
25874
|
+
┌─────────────────────────────────────────────────────┐`));
|
|
25875
|
+
console.log(source_default.yellow("│") + " " + source_default.bold("Update available!") + " " + source_default.dim(currentVersion) + " → " + source_default.green.bold(latestVersion) + " " + source_default.yellow("│"));
|
|
25876
|
+
console.log(source_default.yellow("│") + " Run: " + source_default.cyan("npm install -g hermes-git@latest") + " " + source_default.yellow("│"));
|
|
25877
|
+
console.log(source_default.yellow(`└─────────────────────────────────────────────────────┘
|
|
25878
|
+
`));
|
|
25879
|
+
}
|
|
25880
|
+
} catch {}
|
|
25881
|
+
}
|
|
25882
|
+
|
|
25812
25883
|
// src/index.ts
|
|
25813
25884
|
var program2 = new Command;
|
|
25814
|
-
|
|
25885
|
+
var CURRENT_VERSION = "0.2.4";
|
|
25886
|
+
program2.name("hermes").description("\uD83E\uDEBD Intent-driven Git, guided by AI").version(CURRENT_VERSION);
|
|
25815
25887
|
initCommand(program2);
|
|
25816
25888
|
planCommand(program2);
|
|
25817
25889
|
startCommand(program2);
|
|
@@ -25821,4 +25893,5 @@ conflictCommand(program2);
|
|
|
25821
25893
|
worktreeCommand(program2);
|
|
25822
25894
|
statsCommand(program2);
|
|
25823
25895
|
workflowCommand(program2);
|
|
25896
|
+
checkForUpdates(CURRENT_VERSION).catch(() => {});
|
|
25824
25897
|
program2.parse();
|