@enke.dev/bumper 0.0.4 → 0.0.5
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/README.md +7 -4
- package/dist/cli.mjs +30 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,12 +19,15 @@ Dependencies are bumped by resolving each package's latest version via the repo'
|
|
|
19
19
|
manager (`pnpm view` / `npm view`, so private scoped registries + `.npmrc` auth just work),
|
|
20
20
|
rewriting `package.json` specs (preserving `^`/`~`), then letting the package manager reinstall.
|
|
21
21
|
|
|
22
|
-
Bumps are **peer-aware**: before rewriting, bumper reads the `peerDependencies` of every
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
Bumps are **peer-aware**: before rewriting, bumper reads the `peerDependencies` of every direct
|
|
23
|
+
dependency — for the version it's about to bump _to_, resolved from the registry rather than the
|
|
24
|
+
stale one in `node_modules` — and caps each shared dependency to the newest version still
|
|
25
|
+
satisfying every declared peer range. So a preset that peer-pins `typescript` to `6.0.3`
|
|
25
26
|
(e.g. [`@enke.dev/lint`](https://www.npmjs.com/package/@enke.dev/lint)) holds `typescript` at
|
|
26
27
|
`6.0.3` instead of jumping to a newer major that would break the preset — no per-repo config
|
|
27
|
-
needed, the declaration lives in the dependency itself.
|
|
28
|
+
needed, the declaration lives in the dependency itself. Because the peers are read for the target
|
|
29
|
+
version, a peer newly introduced (or changed) by that bump is honored in the **same run** — no
|
|
30
|
+
second pass needed to converge.
|
|
28
31
|
|
|
29
32
|
> **Note** — network runs through subprocesses (`curl` for the Node dist index, `pnpm`/`npm view`
|
|
30
33
|
> for versions, `actions-up` via `bunx`), so private-registry auth is handled by the tools that
|
package/dist/cli.mjs
CHANGED
|
@@ -2273,6 +2273,19 @@ async function latestVersion(pkg, tool, cwd, run2 = exec) {
|
|
|
2273
2273
|
return null;
|
|
2274
2274
|
}
|
|
2275
2275
|
}
|
|
2276
|
+
async function peerDependenciesOf(pkg, version, tool, cwd, run2 = exec) {
|
|
2277
|
+
try {
|
|
2278
|
+
const { exitCode, stdout } = await run2([tool, "view", `${pkg}@${version}`, "peerDependencies", "--json"], { cwd });
|
|
2279
|
+
const trimmed = stdout.trim();
|
|
2280
|
+
if (exitCode !== 0 || !trimmed) {
|
|
2281
|
+
return {};
|
|
2282
|
+
}
|
|
2283
|
+
const parsed = JSON.parse(trimmed);
|
|
2284
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
2285
|
+
} catch {
|
|
2286
|
+
return {};
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2276
2289
|
async function latestVersionInRange(pkg, range, tool, cwd, run2 = exec) {
|
|
2277
2290
|
try {
|
|
2278
2291
|
const { exitCode, stdout } = await run2([tool, "view", `${pkg}@${range}`, "version"], { cwd });
|
|
@@ -2491,7 +2504,11 @@ var BUCKETS2 = [
|
|
|
2491
2504
|
"peerDependencies"
|
|
2492
2505
|
];
|
|
2493
2506
|
var CONCURRENCY = 8;
|
|
2494
|
-
var defaultLookups = {
|
|
2507
|
+
var defaultLookups = {
|
|
2508
|
+
latestVersion,
|
|
2509
|
+
latestVersionInRange,
|
|
2510
|
+
peerDependencies: peerDependenciesOf
|
|
2511
|
+
};
|
|
2495
2512
|
async function collectPackages(ctx) {
|
|
2496
2513
|
const entries = await Promise.all(ctx.workspaces.map(async (dir) => [dir, await readPackageJson(dir)]));
|
|
2497
2514
|
return new Map(entries.filter((entry) => entry[1] !== null));
|
|
@@ -2503,13 +2520,20 @@ function collectNames(pkgs, managed) {
|
|
|
2503
2520
|
function collectDependencyNames(pkgs) {
|
|
2504
2521
|
return [...new Set([...pkgs.values()].flatMap((pkg) => Object.keys(allDependencies(pkg))))];
|
|
2505
2522
|
}
|
|
2506
|
-
async function
|
|
2523
|
+
async function targetVersion(cwd, dep, latest) {
|
|
2524
|
+
if (latest.has(dep)) {
|
|
2525
|
+
return latest.get(dep) ?? null;
|
|
2526
|
+
}
|
|
2527
|
+
return (await readPackageJson(join8(cwd, "node_modules", dep)))?.version ?? null;
|
|
2528
|
+
}
|
|
2529
|
+
async function collectPeerCaps(cwd, depNames, latest, managed, tool, lookups) {
|
|
2507
2530
|
const collected = new Map;
|
|
2508
2531
|
await Promise.all(depNames.map(async (dep) => {
|
|
2509
|
-
const
|
|
2510
|
-
if (!
|
|
2532
|
+
const version = await targetVersion(cwd, dep, latest);
|
|
2533
|
+
if (!version) {
|
|
2511
2534
|
return;
|
|
2512
2535
|
}
|
|
2536
|
+
const peers = await lookups.peerDependencies(dep, version, tool, cwd);
|
|
2513
2537
|
Object.entries(peers).forEach(([peer, range]) => {
|
|
2514
2538
|
if (managed.has(peer) || !isPinnable(range) && !isVersionRange(range)) {
|
|
2515
2539
|
return;
|
|
@@ -2553,10 +2577,8 @@ async function upgradeAllWorkspaces(ctx, lookups = defaultLookups) {
|
|
|
2553
2577
|
return;
|
|
2554
2578
|
}
|
|
2555
2579
|
const tool = viewTool(ctx.packageManager);
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
collectPeerCaps(ctx.cwd, collectDependencyNames(pkgs), managed)
|
|
2559
|
-
]);
|
|
2580
|
+
const latest = await resolveLatest(names, tool, ctx.cwd, lookups);
|
|
2581
|
+
const peerCaps = await collectPeerCaps(ctx.cwd, collectDependencyNames(pkgs), latest, managed, tool, lookups);
|
|
2560
2582
|
await Promise.all([...pkgs].map(async ([dir, pkg]) => {
|
|
2561
2583
|
if (await rewriteSpecs(pkg, managed, latest, peerCaps, tool, ctx.cwd, lookups)) {
|
|
2562
2584
|
await writePackageJson(dir, pkg);
|