@kenkaiiii/gg-core 5.100.2 → 5.101.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-GNWS4RGZ.js → chunk-7OUR44Y4.js} +11 -1
- package/dist/chunk-7OUR44Y4.js.map +1 -0
- package/dist/index.cjs +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/model-registry.cjs.map +1 -1
- package/dist/model-registry.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-GNWS4RGZ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -546,6 +546,15 @@ async function download(asset, dest, opts) {
|
|
|
546
546
|
);
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
|
+
function compareVersions(a, b) {
|
|
550
|
+
const pa = a.split(/[.-]/).map((n) => Number.parseInt(n, 10) || 0);
|
|
551
|
+
const pb = b.split(/[.-]/).map((n) => Number.parseInt(n, 10) || 0);
|
|
552
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
553
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
554
|
+
if (diff !== 0) return diff;
|
|
555
|
+
}
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
549
558
|
async function removeOldVersions(home, keep) {
|
|
550
559
|
let entries;
|
|
551
560
|
try {
|
|
@@ -556,6 +565,7 @@ async function removeOldVersions(home, keep) {
|
|
|
556
565
|
for (const entry of entries) {
|
|
557
566
|
if (!entry.isDirectory() || entry.name === keep || entry.name === "config") continue;
|
|
558
567
|
if (!/^\d+\.\d+\.\d+/.test(entry.name)) continue;
|
|
568
|
+
if (compareVersions(entry.name, keep) > 0) continue;
|
|
559
569
|
await import_promises2.default.rm(import_node_path2.default.join(home, entry.name), { recursive: true, force: true }).catch(() => {
|
|
560
570
|
});
|
|
561
571
|
}
|
|
@@ -4782,7 +4792,7 @@ var import_node_fs5 = __toESM(require("fs"), 1);
|
|
|
4782
4792
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
4783
4793
|
var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
|
|
4784
4794
|
var FETCH_TIMEOUT_MS = 1e4;
|
|
4785
|
-
function
|
|
4795
|
+
function compareVersions2(a, b) {
|
|
4786
4796
|
const pa = a.split(".").map(Number);
|
|
4787
4797
|
const pb = b.split(".").map(Number);
|
|
4788
4798
|
for (let i = 0; i < 3; i++) {
|
|
@@ -4868,7 +4878,7 @@ function createAutoUpdater(config) {
|
|
|
4868
4878
|
latestVersion: latestVersion ?? void 0,
|
|
4869
4879
|
updatePending: false
|
|
4870
4880
|
};
|
|
4871
|
-
if (latestVersion &&
|
|
4881
|
+
if (latestVersion && compareVersions2(latestVersion, currentVersion) > 0) {
|
|
4872
4882
|
newState.updatePending = true;
|
|
4873
4883
|
}
|
|
4874
4884
|
writeState(newState);
|
|
@@ -4880,7 +4890,7 @@ function createAutoUpdater(config) {
|
|
|
4880
4890
|
const state = readState();
|
|
4881
4891
|
let message = null;
|
|
4882
4892
|
if (state?.updatePending && state.latestVersion) {
|
|
4883
|
-
if (
|
|
4893
|
+
if (compareVersions2(state.latestVersion, currentVersion) > 0) {
|
|
4884
4894
|
const info = detectInstallInfo();
|
|
4885
4895
|
if (info.updateCommand) {
|
|
4886
4896
|
performUpdateInBackground(info.updateCommand);
|
|
@@ -4907,7 +4917,7 @@ function createAutoUpdater(config) {
|
|
|
4907
4917
|
try {
|
|
4908
4918
|
const state = readState();
|
|
4909
4919
|
if (!state?.latestVersion) return null;
|
|
4910
|
-
if (
|
|
4920
|
+
if (compareVersions2(state.latestVersion, currentVersion) <= 0) return null;
|
|
4911
4921
|
return { latestVersion: state.latestVersion };
|
|
4912
4922
|
} catch {
|
|
4913
4923
|
return null;
|
|
@@ -4918,7 +4928,7 @@ function createAutoUpdater(config) {
|
|
|
4918
4928
|
periodicTimer = setInterval(() => {
|
|
4919
4929
|
fetchLatestVersion().then((latestVersion) => {
|
|
4920
4930
|
if (!latestVersion) return;
|
|
4921
|
-
if (
|
|
4931
|
+
if (compareVersions2(latestVersion, currentVersion) <= 0) return;
|
|
4922
4932
|
const info = detectInstallInfo();
|
|
4923
4933
|
if (!info.updateCommand) return;
|
|
4924
4934
|
writeState({ lastCheckedAt: Date.now(), latestVersion, updatePending: true });
|