cli-atom 0.2.5 → 0.2.7
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/atom.js +25 -1
- package/package.json +1 -1
package/atom.js
CHANGED
|
@@ -6,6 +6,8 @@ import path from "path";
|
|
|
6
6
|
import { marked } from "marked";
|
|
7
7
|
import { markedTerminal } from "marked-terminal";
|
|
8
8
|
import { exec } from "child_process";
|
|
9
|
+
import { createRequire } from "module";
|
|
10
|
+
const _require = createRequire(import.meta.url);
|
|
9
11
|
|
|
10
12
|
marked.use(markedTerminal());
|
|
11
13
|
|
|
@@ -39,7 +41,7 @@ const IGNORE_EXTS = [".png", ".jpg", ".jpeg", ".gif", ".ico", ".svg", ".woff", "
|
|
|
39
41
|
const MAX_FILE_SIZE = 15_000;
|
|
40
42
|
let MODEL = "z-ai/glm-5-turbo";
|
|
41
43
|
let MODEL_LABEL = "glm-5-turbo";
|
|
42
|
-
const VERSION = "
|
|
44
|
+
const VERSION = _require("./package.json").version;
|
|
43
45
|
|
|
44
46
|
const MODELS = [
|
|
45
47
|
{ id: "z-ai/glm-5-turbo", label: "glm-5-turbo" },
|
|
@@ -955,6 +957,18 @@ function getDate() {
|
|
|
955
957
|
}
|
|
956
958
|
|
|
957
959
|
|
|
960
|
+
|
|
961
|
+
async function checkForUpdate() {
|
|
962
|
+
try {
|
|
963
|
+
const res = await fetch(`https://registry.npmjs.org/cli-atom/latest`, { signal: AbortSignal.timeout(3000) });
|
|
964
|
+
if (!res.ok) return null;
|
|
965
|
+
const data = await res.json();
|
|
966
|
+
return data.version || null;
|
|
967
|
+
} catch {
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
958
972
|
async function start() {
|
|
959
973
|
console.clear();
|
|
960
974
|
|
|
@@ -966,6 +980,10 @@ async function start() {
|
|
|
966
980
|
const now = getNow();
|
|
967
981
|
const date = getDate();
|
|
968
982
|
|
|
983
|
+
// check for update in background
|
|
984
|
+
const latestVersion = await checkForUpdate();
|
|
985
|
+
const hasUpdate = latestVersion && latestVersion !== VERSION;
|
|
986
|
+
|
|
969
987
|
console.log();
|
|
970
988
|
console.log(rule("─"));
|
|
971
989
|
console.log();
|
|
@@ -998,6 +1016,12 @@ async function start() {
|
|
|
998
1016
|
console.log(rule("─"));
|
|
999
1017
|
console.log();
|
|
1000
1018
|
|
|
1019
|
+
if (hasUpdate) {
|
|
1020
|
+
console.log(` ${t.warn}update available${t.reset} ${t.muted}v${VERSION} → ${t.accent}v${latestVersion}${t.reset}`);
|
|
1021
|
+
console.log(` ${t.dim}run ${t.accent}npm install -g cli-atom${t.dim} to update${t.reset}`);
|
|
1022
|
+
console.log();
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1001
1025
|
console.log(`${t.violetDim}ready${t.reset}`);
|
|
1002
1026
|
|
|
1003
1027
|
askPrompt();
|