Files
gitea/tools/migrate-nolyfills.ts
silverwind b4085c7e3c build: update pnpm to v11 (#37591)
Update to https://github.com/pnpm/pnpm/releases/tag/v11.0.0

- move all pnpm settings to `pnpm-workspace.yaml`, pnpm v11 only reads
that file
- drop redundant or no-op settings
- disable `strictDepBuilds` to avoid having to manually specify deps
with build scripts, this is equivalent to v10 where it will not execute
and warn.
- add workarounds for https://github.com/SukkaW/nolyfill/issues/119
- remove dead eslintrc entry

---
This PR was written with the help of Claude Opus 4.7

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-08 04:17:20 +00:00

34 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
// nolyfill writes overrides to package.json#pnpm.overrides which pnpm v11 ignores.
// This moves them to pnpm-workspace.yaml until SukkaW/nolyfill#119 is fixed.
import {readFileSync, writeFileSync} from 'node:fs';
import {exit} from 'node:process';
import {fileURLToPath} from 'node:url';
import {dump} from 'js-yaml';
const packagePath = fileURLToPath(new URL('../package.json', import.meta.url));
const workspacePath = fileURLToPath(new URL('../pnpm-workspace.yaml', import.meta.url));
const packageJson: {pnpm?: {overrides?: Record<string, string>}} = JSON.parse(readFileSync(packagePath, 'utf8'));
const overrides = packageJson.pnpm?.overrides;
if (!overrides || !Object.keys(overrides).length) {
exit(0);
}
const block = dump({overrides}, {lineWidth: -1, quotingType: "'"});
const workspace = readFileSync(workspacePath, 'utf8');
const overridesRegex = /^overrides:[^\n]*(?:\n(?:[ \t][^\n]*|[ \t]*(?=\n[ \t])))*\n?/m;
if (!overridesRegex.test(workspace)) {
console.error(`No 'overrides:' block found in pnpm-workspace.yaml`);
exit(1);
}
writeFileSync(workspacePath, workspace.replace(overridesRegex, block));
const pnpm = packageJson.pnpm!;
delete pnpm.overrides;
if (!Object.keys(pnpm).length) delete packageJson.pnpm;
writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}\n`);