coding-friend-cli 1.20.1 → 1.21.0
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/{chunk-V23HBD3E.js → chunk-3KXYEC2T.js} +6 -4
- package/dist/{chunk-JFGLNTZI.js → chunk-5UEY7HQX.js} +6 -4
- package/dist/chunk-5UVDWG5L.js +28 -0
- package/dist/{chunk-C5LYVVEI.js → chunk-BIX7AJU3.js} +6 -4
- package/dist/{chunk-RWUTFVRB.js → chunk-DO6FV6BL.js} +4 -30
- package/dist/{chunk-CYQU33FY.js → chunk-EVGXUDX4.js} +2 -1
- package/dist/{chunk-7CAIGH2Y.js → chunk-HEBLANJO.js} +37 -1
- package/dist/{chunk-PHQK2MMO.js → chunk-PDVSGGH6.js} +8 -6
- package/dist/{chunk-POC2WHU2.js → chunk-PRIH34UB.js} +4 -0
- package/dist/{chunk-NEQZP5D4.js → chunk-PYTEAC6K.js} +3 -1
- package/dist/{chunk-QMD7P67N.js → chunk-SIQJPT47.js} +5 -3
- package/dist/{chunk-ORACWEDN.js → chunk-TRIALFOQ.js} +17 -10
- package/dist/{config-RLSM3UAF.js → config-5I3XJEEL.js} +13 -11
- package/dist/{dev-7DLYIXBO.js → dev-4A5CTBGK.js} +13 -10
- package/dist/{disable-XYZRE3TD.js → disable-FNMRPUO7.js} +5 -4
- package/dist/{enable-3NZBQWLQ.js → enable-HUKTMK5U.js} +5 -4
- package/dist/{host-QDWBFJB2.js → host-V5O3PDCF.js} +5 -4
- package/dist/index.js +37 -31
- package/dist/{init-ONUC6QMM.js → init-3XMC6YJI.js} +33 -15
- package/dist/{install-35IWHBIS.js → install-5ZBHH2OM.js} +9 -8
- package/dist/{mcp-GFIOFXOL.js → mcp-U34LFD34.js} +5 -4
- package/dist/{memory-N6Q2ENBI.js → memory-PDENAODU.js} +10 -8
- package/dist/{permission-Z3LOBJ4X.js → permission-BEC6YZQA.js} +15 -8
- package/dist/postinstall.js +1 -1
- package/dist/{session-JGRF5SNX.js → session-ZDJ2APGL.js} +25 -13
- package/dist/{status-WK3TBDN7.js → status-F6WASK7N.js} +14 -12
- package/dist/{statusline-6Y2EBAFQ.js → statusline-AISH77XP.js} +10 -4
- package/dist/{uninstall-NNCEKPIE.js → uninstall-RJ6SBB76.js} +10 -8
- package/dist/update-536C3YG7.js +22 -0
- package/dist/update-check-L5TNWT2J.js +91 -0
- package/package.json +1 -1
- package/dist/update-NZ2HRWEN.js +0 -21
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
run
|
|
3
|
+
} from "./chunk-EVGXUDX4.js";
|
|
4
|
+
import {
|
|
5
|
+
globalConfigDir
|
|
6
|
+
} from "./chunk-DO6FV6BL.js";
|
|
7
|
+
import {
|
|
8
|
+
log
|
|
9
|
+
} from "./chunk-W5CD7WTX.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/update-check.ts
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
var UPDATE_CHECK_FILE = "cli-update-check.json";
|
|
16
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
17
|
+
function getUpdateCachePath() {
|
|
18
|
+
return join(globalConfigDir(), UPDATE_CHECK_FILE);
|
|
19
|
+
}
|
|
20
|
+
function readUpdateCache() {
|
|
21
|
+
try {
|
|
22
|
+
const path = getUpdateCachePath();
|
|
23
|
+
if (!existsSync(path)) return null;
|
|
24
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function writeUpdateCache(latestVersion) {
|
|
30
|
+
const dir = globalConfigDir();
|
|
31
|
+
mkdirSync(dir, { recursive: true });
|
|
32
|
+
writeFileSync(
|
|
33
|
+
getUpdateCachePath(),
|
|
34
|
+
JSON.stringify({ lastCheck: Date.now(), latestVersion })
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
function isCheckStale(cache, now = Date.now()) {
|
|
38
|
+
if (!cache) return true;
|
|
39
|
+
return now - cache.lastCheck > CHECK_INTERVAL_MS;
|
|
40
|
+
}
|
|
41
|
+
function semverCompare(a, b) {
|
|
42
|
+
const pa = a.split(".").map(Number);
|
|
43
|
+
const pb = b.split(".").map(Number);
|
|
44
|
+
for (let i = 0; i < 3; i++) {
|
|
45
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
46
|
+
if (diff !== 0) return diff > 0 ? 1 : -1;
|
|
47
|
+
}
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
function checkAndNotifyCliUpdate(currentVersion, opts = {}) {
|
|
51
|
+
const { autoUpdate = true } = opts;
|
|
52
|
+
try {
|
|
53
|
+
const cache = readUpdateCache();
|
|
54
|
+
let latestVersion = null;
|
|
55
|
+
if (isCheckStale(cache)) {
|
|
56
|
+
latestVersion = run("npm", ["view", "coding-friend-cli", "version"]);
|
|
57
|
+
if (latestVersion) {
|
|
58
|
+
writeUpdateCache(latestVersion);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
latestVersion = cache.latestVersion;
|
|
62
|
+
}
|
|
63
|
+
if (!latestVersion) return;
|
|
64
|
+
const cmp = semverCompare(currentVersion, latestVersion);
|
|
65
|
+
if (cmp >= 0) return;
|
|
66
|
+
console.log();
|
|
67
|
+
log.warn(
|
|
68
|
+
`Update available: ${chalk.dim(`v${currentVersion}`)} \u2192 ${chalk.green(`v${latestVersion}`)}. Run ${chalk.cyan("cf update --cli")} to update.`
|
|
69
|
+
);
|
|
70
|
+
if (autoUpdate) {
|
|
71
|
+
log.step("Auto-updating CLI...");
|
|
72
|
+
const result = run("npm", ["install", "-g", "coding-friend-cli@latest"]);
|
|
73
|
+
if (result !== null) {
|
|
74
|
+
log.success(`CLI auto-updated to ${chalk.green(`v${latestVersion}`)}`);
|
|
75
|
+
} else {
|
|
76
|
+
log.dim(
|
|
77
|
+
"Auto-update failed. Run manually: npm install -g coding-friend-cli@latest"
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
CHECK_INTERVAL_MS,
|
|
86
|
+
checkAndNotifyCliUpdate,
|
|
87
|
+
getUpdateCachePath,
|
|
88
|
+
isCheckStale,
|
|
89
|
+
readUpdateCache,
|
|
90
|
+
writeUpdateCache
|
|
91
|
+
};
|
package/package.json
CHANGED
package/dist/update-NZ2HRWEN.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCliVersion,
|
|
3
|
-
getLatestCliVersion,
|
|
4
|
-
getLatestVersion,
|
|
5
|
-
semverCompare,
|
|
6
|
-
updateCommand
|
|
7
|
-
} from "./chunk-PHQK2MMO.js";
|
|
8
|
-
import "./chunk-ORACWEDN.js";
|
|
9
|
-
import "./chunk-POC2WHU2.js";
|
|
10
|
-
import "./chunk-NEQZP5D4.js";
|
|
11
|
-
import "./chunk-C5LYVVEI.js";
|
|
12
|
-
import "./chunk-CYQU33FY.js";
|
|
13
|
-
import "./chunk-RWUTFVRB.js";
|
|
14
|
-
import "./chunk-W5CD7WTX.js";
|
|
15
|
-
export {
|
|
16
|
-
getCliVersion,
|
|
17
|
-
getLatestCliVersion,
|
|
18
|
-
getLatestVersion,
|
|
19
|
-
semverCompare,
|
|
20
|
-
updateCommand
|
|
21
|
-
};
|