@enke.dev/bumper 0.0.5 → 0.0.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/dist/cli.mjs +40 -11
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -2253,6 +2253,7 @@ import { readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises
|
|
|
2253
2253
|
import { relative as relative2 } from "node:path";
|
|
2254
2254
|
|
|
2255
2255
|
// src/utils/npm-registry.utils.ts
|
|
2256
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
2256
2257
|
async function curlJson(url, run2 = execOk) {
|
|
2257
2258
|
const { stdout } = await run2(["curl", "-sSL", "--fail", "--connect-timeout", "20", url]);
|
|
2258
2259
|
return JSON.parse(stdout);
|
|
@@ -2300,6 +2301,27 @@ async function latestVersionInRange(pkg, range, tool, cwd, run2 = exec) {
|
|
|
2300
2301
|
return null;
|
|
2301
2302
|
}
|
|
2302
2303
|
}
|
|
2304
|
+
async function maxSatisfyingRanges(pkg, ranges, tool, cwd, run2 = exec) {
|
|
2305
|
+
if (ranges.length === 0) {
|
|
2306
|
+
return null;
|
|
2307
|
+
}
|
|
2308
|
+
try {
|
|
2309
|
+
const { exitCode, stdout } = await run2([tool, "view", pkg, "versions", "--json"], { cwd });
|
|
2310
|
+
if (exitCode !== 0) {
|
|
2311
|
+
return null;
|
|
2312
|
+
}
|
|
2313
|
+
const trimmed = stdout.trim();
|
|
2314
|
+
if (!trimmed) {
|
|
2315
|
+
return null;
|
|
2316
|
+
}
|
|
2317
|
+
const parsed = JSON.parse(trimmed);
|
|
2318
|
+
const versions = Array.isArray(parsed) ? parsed : typeof parsed === "string" ? [parsed] : [];
|
|
2319
|
+
const match = versions.filter((v) => import_semver.default.valid(v) && import_semver.default.prerelease(v) === null).filter((v) => ranges.every((range) => import_semver.default.satisfies(v, range))).sort(import_semver.default.rcompare)[0];
|
|
2320
|
+
return match ?? null;
|
|
2321
|
+
} catch {
|
|
2322
|
+
return null;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2303
2325
|
|
|
2304
2326
|
// src/modules/runtimes/node/node-lts.utils.ts
|
|
2305
2327
|
var DIST_INDEX = "https://nodejs.org/dist/index.json";
|
|
@@ -2384,9 +2406,9 @@ var githubActionsFeature = {
|
|
|
2384
2406
|
import { relative as relative3 } from "node:path";
|
|
2385
2407
|
|
|
2386
2408
|
// src/utils/spec.utils.ts
|
|
2387
|
-
var
|
|
2409
|
+
var import_semver2 = __toESM(require_semver2(), 1);
|
|
2388
2410
|
function isPinnable(spec) {
|
|
2389
|
-
return
|
|
2411
|
+
return import_semver2.default.valid(spec.replace(/^[\^~]/, "")) !== null;
|
|
2390
2412
|
}
|
|
2391
2413
|
function operatorOf(spec) {
|
|
2392
2414
|
return spec.startsWith("^") ? "^" : spec.startsWith("~") ? "~" : "";
|
|
@@ -2472,13 +2494,20 @@ import { join as join9 } from "node:path";
|
|
|
2472
2494
|
// src/utils/deps.utils.ts
|
|
2473
2495
|
import { rm } from "node:fs/promises";
|
|
2474
2496
|
import { join as join7 } from "node:path";
|
|
2497
|
+
var LOCKFILES = {
|
|
2498
|
+
["npm" /* Npm */]: ["package-lock.json", "npm-shrinkwrap.json"],
|
|
2499
|
+
["pnpm" /* Pnpm */]: ["pnpm-lock.yaml"],
|
|
2500
|
+
["bun" /* Bun */]: ["bun.lock", "bun.lockb"]
|
|
2501
|
+
};
|
|
2475
2502
|
async function cleanInstall(ctx, installCmd) {
|
|
2503
|
+
const lockfiles = LOCKFILES[ctx.packageManager] ?? [];
|
|
2476
2504
|
if (ctx.dryRun) {
|
|
2477
|
-
planLine("rm -rf node_modules");
|
|
2505
|
+
planLine(["rm -rf", "node_modules", ...lockfiles].join(" "));
|
|
2478
2506
|
planLine(installCmd.join(" "));
|
|
2479
2507
|
return;
|
|
2480
2508
|
}
|
|
2481
2509
|
await rm(join7(ctx.cwd, "node_modules"), { recursive: true, force: true });
|
|
2510
|
+
await Promise.all(lockfiles.map((file) => rm(join7(ctx.cwd, file), { force: true })));
|
|
2482
2511
|
await execOk(installCmd, { cwd: ctx.cwd });
|
|
2483
2512
|
}
|
|
2484
2513
|
async function selfUpdate(ctx, cmd) {
|
|
@@ -2506,7 +2535,7 @@ var BUCKETS2 = [
|
|
|
2506
2535
|
var CONCURRENCY = 8;
|
|
2507
2536
|
var defaultLookups = {
|
|
2508
2537
|
latestVersion,
|
|
2509
|
-
|
|
2538
|
+
maxSatisfyingRanges,
|
|
2510
2539
|
peerDependencies: peerDependenciesOf
|
|
2511
2540
|
};
|
|
2512
2541
|
async function collectPackages(ctx) {
|
|
@@ -2541,7 +2570,7 @@ async function collectPeerCaps(cwd, depNames, latest, managed, tool, lookups) {
|
|
|
2541
2570
|
(collected.get(peer) ?? collected.set(peer, new Set).get(peer))?.add(range);
|
|
2542
2571
|
});
|
|
2543
2572
|
}));
|
|
2544
|
-
return new Map([...collected].map(([peer, ranges]) => [peer, [...ranges]
|
|
2573
|
+
return new Map([...collected].map(([peer, ranges]) => [peer, [...ranges]]));
|
|
2545
2574
|
}
|
|
2546
2575
|
async function resolveLatest(names, tool, cwd, lookups) {
|
|
2547
2576
|
const resolved = [];
|
|
@@ -2603,15 +2632,15 @@ function cappedRanges(pkg, managed) {
|
|
|
2603
2632
|
}
|
|
2604
2633
|
async function rewriteSpecs(pkg, managed, latest, peerCaps, tool, cwd, lookups) {
|
|
2605
2634
|
const present = allDependencies(pkg);
|
|
2606
|
-
const
|
|
2607
|
-
|
|
2635
|
+
const capRanges = new Map;
|
|
2636
|
+
cappedRanges(pkg, managed).forEach((range, name) => capRanges.set(name, [range]));
|
|
2637
|
+
peerCaps.forEach((ranges, name) => {
|
|
2608
2638
|
if (!(name in present)) {
|
|
2609
2639
|
return;
|
|
2610
2640
|
}
|
|
2611
|
-
|
|
2612
|
-
caps.set(name, own ? `${own} ${range}` : range);
|
|
2641
|
+
capRanges.set(name, [...new Set([...capRanges.get(name) ?? [], ...ranges])]);
|
|
2613
2642
|
});
|
|
2614
|
-
const capped = new Map(await Promise.all([...
|
|
2643
|
+
const capped = new Map(await Promise.all([...capRanges].map(async ([name, ranges]) => [name, await lookups.maxSatisfyingRanges(name, ranges, tool, cwd)])));
|
|
2615
2644
|
return BUCKETS2.reduce((bucketChanged, bucket) => {
|
|
2616
2645
|
const deps = pkg[bucket];
|
|
2617
2646
|
if (!deps) {
|
|
@@ -2621,7 +2650,7 @@ async function rewriteSpecs(pkg, managed, latest, peerCaps, tool, cwd, lookups)
|
|
|
2621
2650
|
if (managed.has(name) || !isPinnable(spec)) {
|
|
2622
2651
|
return acc;
|
|
2623
2652
|
}
|
|
2624
|
-
const version =
|
|
2653
|
+
const version = capRanges.has(name) ? capped.get(name) : latest.get(name);
|
|
2625
2654
|
if (!version) {
|
|
2626
2655
|
return acc;
|
|
2627
2656
|
}
|