0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-03-13 07:43:27 +00:00

fix(pnpm): Revert "feat(manager/npm): ignore scripts for pnpmDedupe" ()

This commit is contained in:
Rhys Arkins 2023-10-14 11:56:57 +01:00 committed by GitHub
parent b74c09fc0c
commit 3609cddbbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 50 deletions
docs/usage
lib/modules/manager/npm/post-update
__fixtures__/dedupe-ignore-scripts
pnpm.spec.tspnpm.ts

View file

@ -2973,7 +2973,7 @@ Table with options:
| `gomodUpdateImportPaths` | Update source import paths on major module updates, using [mod](https://github.com/marwan-at-work/mod). |
| `helmUpdateSubChartArchives` | Update subchart archives in the `/charts` folder. |
| `npmDedupe` | Run `npm dedupe` after `package-lock.json` updates. |
| `pnpmDedupe` | Run `pnpm dedupe --ignore-scripts` after `pnpm-lock.yaml` updates. |
| `pnpmDedupe` | Run `pnpm dedupe` after `pnpm-lock.yaml` updates. |
| `yarnDedupeFewer` | Run `yarn-deduplicate --strategy fewer` after `yarn.lock` updates. |
| `yarnDedupeHighest` | Run `yarn-deduplicate --strategy highest` (`yarn dedupe --strategy highest` for Yarn >=2.2.0) after `yarn.lock` updates. |

View file

@ -1,9 +0,0 @@
{
"name": "dedupe-ignore-scripts",
"version": "1.0.0",
"engines": {
"pnpm": ">=8.8.0"
},
"engine-strict": true,
"packageManager": "pnpm@8.8.0"
}

View file

@ -77,7 +77,7 @@ describe('modules/manager/npm/post-update/pnpm', () => {
{},
{ ...config, postUpdateOptions }
);
expect(fs.readLocalFile).toHaveBeenCalledTimes(2);
expect(fs.readLocalFile).toHaveBeenCalledTimes(1);
expect(res.lockFile).toBe('package-lock-contents');
expect(execSnapshots).toMatchObject([
{
@ -89,30 +89,6 @@ describe('modules/manager/npm/post-update/pnpm', () => {
]);
});
it('performs dedupe --ignore-scripts for pnpm >= 8.8.0', async () => {
const execSnapshots = mockExecAll();
const fileContent = Fixtures.get('dedupe-ignore-scripts/package.json');
fs.readLocalFile
.mockResolvedValueOnce(fileContent)
.mockResolvedValue('package-lock-contents');
const postUpdateOptions = ['pnpmDedupe'];
const res = await pnpmHelper.generateLockFile(
'some-dir',
{},
{ ...config, postUpdateOptions }
);
expect(fs.readLocalFile).toHaveBeenCalledTimes(2);
expect(res.lockFile).toBe('package-lock-contents');
expect(execSnapshots).toMatchObject([
{
cmd: 'pnpm install --recursive --lockfile-only --ignore-scripts --ignore-pnpmfile',
},
{
cmd: 'pnpm dedupe --ignore-scripts',
},
]);
});
it('uses the new version if packageManager is updated', async () => {
const execSnapshots = mockExecAll();
fs.readLocalFile.mockResolvedValue('package-lock-contents');

View file

@ -1,6 +1,5 @@
import is from '@sindresorhus/is';
import { load } from 'js-yaml';
import semver from 'semver';
import upath from 'upath';
import { GlobalConfig } from '../../../../config/global';
import { TEMPORARY_ERROR } from '../../../../constants/error-messages';
@ -40,7 +39,6 @@ export async function generateLockFile(
let cmd = 'pnpm';
try {
const lazyPgkJson = lazyLoadPackageJson(lockFileDir);
const pnpmToolConstraint: ToolConstraint = {
toolName: 'pnpm',
constraint:
@ -81,19 +79,8 @@ export async function generateLockFile(
// postUpdateOptions
if (config.postUpdateOptions?.includes('pnpmDedupe')) {
const pnpmVersionFromPackageJson = getPackageManagerVersion(
'pnpm',
await lazyPgkJson.getValue()
);
if (
pnpmVersionFromPackageJson &&
semver.gte(pnpmVersionFromPackageJson, '8.8.0')
) {
commands.push('pnpm dedupe --ignore-scripts');
} else {
commands.push('pnpm dedupe');
}
logger.debug('Performing pnpm dedupe');
commands.push('pnpm dedupe');
}
if (upgrades.find((upgrade) => upgrade.isLockFileMaintenance)) {