@enke.dev/bumper 0.0.2 → 0.0.4
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 +1 -1
- package/dist/cli.mjs +55 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ then the remaining file-rewriting features:
|
|
|
122
122
|
| id | kind | detects | does |
|
|
123
123
|
| ---------------- | --------------- | ------------------------------- | ------------------------------------------------------- |
|
|
124
124
|
| `node` | runtime | node runtime / `.node-version` | install latest LTS via fnm/asdf, write `.node-version` |
|
|
125
|
-
| `types-node` | feature | `@types/node` in any package | pin spec to Node LTS major
|
|
125
|
+
| `types-node` | feature | `@types/node` in any package | pin spec to exact latest in the Node LTS major line |
|
|
126
126
|
| `bun` | package-manager | bun packageManager / lockfile | self-upgrade, bump specs, pin `.bun-version`, reinstall |
|
|
127
127
|
| `npm` | package-manager | npm packageManager / lockfile | bump specs to latest, clean reinstall |
|
|
128
128
|
| `pnpm` | package-manager | pnpm packageManager / lockfile | self-update, bump specs to latest, clean reinstall |
|
package/dist/cli.mjs
CHANGED
|
@@ -2298,7 +2298,7 @@ async function fetchLatestLts() {
|
|
|
2298
2298
|
}
|
|
2299
2299
|
const version = latest.version.replace(/^v/, "");
|
|
2300
2300
|
const major = Number(version.split(".")[0]);
|
|
2301
|
-
return { version, major };
|
|
2301
|
+
return { version, major, ...latest.npm ? { npm: latest.npm } : {} };
|
|
2302
2302
|
}
|
|
2303
2303
|
async function ensureNodeLts(ctx) {
|
|
2304
2304
|
ctx.nodeLts ??= await fetchLatestLts();
|
|
@@ -2400,17 +2400,45 @@ async function dirsWithTypesNode(ctx) {
|
|
|
2400
2400
|
}));
|
|
2401
2401
|
return dirs.filter((dir) => dir !== null);
|
|
2402
2402
|
}
|
|
2403
|
-
function pinTypesNode(pkg,
|
|
2403
|
+
function pinTypesNode(pkg, version) {
|
|
2404
2404
|
return BUCKETS.reduce((changed, bucket) => {
|
|
2405
2405
|
const deps = pkg[bucket];
|
|
2406
2406
|
const spec = deps?.[TYPES_NODE_PACKAGE];
|
|
2407
2407
|
if (deps && spec && !isVersionRange(spec)) {
|
|
2408
|
-
|
|
2409
|
-
|
|
2408
|
+
const next = `${operatorOf(spec)}${version}`;
|
|
2409
|
+
if (next !== spec) {
|
|
2410
|
+
deps[TYPES_NODE_PACKAGE] = next;
|
|
2411
|
+
return true;
|
|
2412
|
+
}
|
|
2410
2413
|
}
|
|
2411
2414
|
return changed;
|
|
2412
2415
|
}, false);
|
|
2413
2416
|
}
|
|
2417
|
+
async function updateTypesNode(ctx, resolveInRange = latestVersionInRange) {
|
|
2418
|
+
const { major } = await ensureNodeLts(ctx);
|
|
2419
|
+
const majorSpec = String(major);
|
|
2420
|
+
const dirs = await dirsWithTypesNode(ctx);
|
|
2421
|
+
if (dirs.length === 0) {
|
|
2422
|
+
return;
|
|
2423
|
+
}
|
|
2424
|
+
if (ctx.dryRun) {
|
|
2425
|
+
dirs.forEach((dir) => {
|
|
2426
|
+
const label = relative3(ctx.cwd, dir) || ".";
|
|
2427
|
+
planLine(`pin ${TYPES_NODE_PACKAGE} to latest ${majorSpec}.x in ${label}`);
|
|
2428
|
+
});
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
const version = await resolveInRange(TYPES_NODE_PACKAGE, majorSpec, viewTool(ctx.packageManager), ctx.cwd);
|
|
2432
|
+
if (!version) {
|
|
2433
|
+
return;
|
|
2434
|
+
}
|
|
2435
|
+
await Promise.all(dirs.map(async (dir) => {
|
|
2436
|
+
const pkg = await readPackageJson(dir);
|
|
2437
|
+
if (pkg && pinTypesNode(pkg, version)) {
|
|
2438
|
+
await writePackageJson(dir, pkg);
|
|
2439
|
+
}
|
|
2440
|
+
}));
|
|
2441
|
+
}
|
|
2414
2442
|
var typesNodeFeature = {
|
|
2415
2443
|
kind: "feature" /* Feature */,
|
|
2416
2444
|
id: "types-node",
|
|
@@ -2421,22 +2449,7 @@ var typesNodeFeature = {
|
|
|
2421
2449
|
async managedDependencies() {
|
|
2422
2450
|
return [TYPES_NODE_PACKAGE];
|
|
2423
2451
|
},
|
|
2424
|
-
|
|
2425
|
-
const { major } = await ensureNodeLts(ctx);
|
|
2426
|
-
const majorSpec = String(major);
|
|
2427
|
-
const dirs = await dirsWithTypesNode(ctx);
|
|
2428
|
-
await Promise.all(dirs.map(async (dir) => {
|
|
2429
|
-
const label = relative3(ctx.cwd, dir) || ".";
|
|
2430
|
-
if (ctx.dryRun) {
|
|
2431
|
-
planLine(`pin ${TYPES_NODE_PACKAGE}@${majorSpec} in ${label}`);
|
|
2432
|
-
return;
|
|
2433
|
-
}
|
|
2434
|
-
const pkg = await readPackageJson(dir);
|
|
2435
|
-
if (pkg && pinTypesNode(pkg, majorSpec)) {
|
|
2436
|
-
await writePackageJson(dir, pkg);
|
|
2437
|
-
}
|
|
2438
|
-
}));
|
|
2439
|
-
}
|
|
2452
|
+
update: updateTypesNode
|
|
2440
2453
|
};
|
|
2441
2454
|
|
|
2442
2455
|
// src/modules/package-managers/bun/bun.package-manager.ts
|
|
@@ -2517,7 +2530,7 @@ async function resolveLatest(names, tool, cwd, lookups) {
|
|
|
2517
2530
|
async function bumpPackageManagerField(ctx, root, lookups) {
|
|
2518
2531
|
const match = root?.packageManager?.match(/^([a-z]+)@(.+)$/);
|
|
2519
2532
|
const name = match?.[1];
|
|
2520
|
-
if (!root || !name) {
|
|
2533
|
+
if (!root || !name || name === "npm") {
|
|
2521
2534
|
return;
|
|
2522
2535
|
}
|
|
2523
2536
|
const version = await lookups.latestVersion(name, viewTool(ctx.packageManager), ctx.cwd);
|
|
@@ -2631,6 +2644,26 @@ var bunPackageManager = {
|
|
|
2631
2644
|
};
|
|
2632
2645
|
|
|
2633
2646
|
// src/modules/package-managers/npm/npm.package-manager.ts
|
|
2647
|
+
async function alignNpmToNodeLts(ctx) {
|
|
2648
|
+
const root = await readPackageJson(ctx.cwd);
|
|
2649
|
+
if (!root?.packageManager?.startsWith("npm@")) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
const { npm } = await ensureNodeLts(ctx);
|
|
2653
|
+
if (!npm) {
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
const next = `npm@${npm}`;
|
|
2657
|
+
if (next === root.packageManager) {
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
if (ctx.dryRun) {
|
|
2661
|
+
planLine(`set packageManager to ${next} (bundled with Node LTS)`);
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
root.packageManager = next;
|
|
2665
|
+
await writePackageJson(ctx.cwd, root);
|
|
2666
|
+
}
|
|
2634
2667
|
var npmPackageManager = {
|
|
2635
2668
|
kind: "package-manager" /* PackageManager */,
|
|
2636
2669
|
id: "npm",
|
|
@@ -2640,6 +2673,7 @@ var npmPackageManager = {
|
|
|
2640
2673
|
},
|
|
2641
2674
|
async update(ctx) {
|
|
2642
2675
|
await upgradeAllWorkspaces(ctx);
|
|
2676
|
+
await alignNpmToNodeLts(ctx);
|
|
2643
2677
|
await cleanInstall(ctx, ["npm", "install"]);
|
|
2644
2678
|
}
|
|
2645
2679
|
};
|