@kenkaiiii/gg-core 5.100.2 → 5.100.3

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.
@@ -350,6 +350,15 @@ async function download(asset, dest, opts) {
350
350
  );
351
351
  }
352
352
  }
353
+ function compareVersions(a, b) {
354
+ const pa = a.split(/[.-]/).map((n) => Number.parseInt(n, 10) || 0);
355
+ const pb = b.split(/[.-]/).map((n) => Number.parseInt(n, 10) || 0);
356
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
357
+ const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
358
+ if (diff !== 0) return diff;
359
+ }
360
+ return 0;
361
+ }
353
362
  async function removeOldVersions(home, keep) {
354
363
  let entries;
355
364
  try {
@@ -360,6 +369,7 @@ async function removeOldVersions(home, keep) {
360
369
  for (const entry of entries) {
361
370
  if (!entry.isDirectory() || entry.name === keep || entry.name === "config") continue;
362
371
  if (!/^\d+\.\d+\.\d+/.test(entry.name)) continue;
372
+ if (compareVersions(entry.name, keep) > 0) continue;
363
373
  await fsp2.rm(path.join(home, entry.name), { recursive: true, force: true }).catch(() => {
364
374
  });
365
375
  }
@@ -3255,4 +3265,4 @@ export {
3255
3265
  getDefaultThinkingLevel,
3256
3266
  getSummaryModel
3257
3267
  };
3258
- //# sourceMappingURL=chunk-GNWS4RGZ.js.map
3268
+ //# sourceMappingURL=chunk-7OUR44Y4.js.map