Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(npm): issue with npm lerna deleting unrelated lockfile files #17233

Merged
merged 29 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b64ae75
Add .whitesource configuration file (#3)
mend-for-github-com[bot] May 9, 2022
2e8b77b
Update .whitesource
PhilipAbed May 9, 2022
c846068
build(deps): update dependency simple-git to v3.5.0 (#17)
mend-for-github-com[bot] May 9, 2022
1c0676e
a
PhilipAbed Jun 9, 2022
45671e0
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 12, 2022
57da7f6
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 13, 2022
84d4b67
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 21, 2022
352d2ff
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 21, 2022
120e580
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 23, 2022
1836ce1
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 27, 2022
7b1d4f2
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 28, 2022
5b960c9
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 7, 2022
4bc0613
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 10, 2022
71fc0d5
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 12, 2022
999c297
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 20, 2022
94bde20
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 21, 2022
816c9cf
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 27, 2022
984bf67
Update private-packages.md
PhilipAbed Aug 3, 2022
016716b
Update private-packages.md
PhilipAbed Aug 7, 2022
3043e6a
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 7, 2022
3337358
Merge branch 'patch-3' of https://github.com/philipabed/renovate
PhilipAbed Aug 7, 2022
4944342
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 14, 2022
a280503
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 17, 2022
4b21b2d
and a check before deleting from lockfile and move out nested function
PhilipAbed Aug 17, 2022
52bb15b
and a check before deleting from lockfile and move out nested function
PhilipAbed Aug 17, 2022
8132539
fix lockfile lerna issue and add unit tests
PhilipAbed Aug 17, 2022
280a5ce
fix lockfile lerna issue and add unit tests
PhilipAbed Aug 17, 2022
bf77f7e
Merge branch 'main' into lockFileLernaIssue
PhilipAbed Aug 17, 2022
ca11604
Merge branch 'main' into lockFileLernaIssue
rarkins Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/modules/manager/npm/post-update/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ describe('modules/manager/npm/post-update/index', () => {
npmLock: 'package-lock.json',
rangeStrategy: 'widen',
},
{
depName: 'core-js',
isRemediation: true,
managerData: {
lernaJsonFile: 'lerna.json',
},
npmLock: 'randomFolder/package-lock.json',
lockFiles: ['randomFolder/package-lock.json'],
rangeStrategy: 'pin',
},
{
isLockfileUpdate: true,
npmLock: 'package-lock.json',
Expand Down Expand Up @@ -209,6 +219,19 @@ describe('modules/manager/npm/post-update/index', () => {
]);
});

it('works only on relevant folders', async () => {
git.getFile.mockResolvedValueOnce(
Fixtures.get('update-lockfile-massage-1/package-lock.json')
);
await expect(
writeExistingFiles(updateConfig, additionalFiles)
).resolves.toBeUndefined();

expect(fs.writeLocalFile).toHaveBeenCalledTimes(2);
expect(fs.deleteLocalFile).not.toHaveBeenCalled();
expect(git.getFile).toHaveBeenCalledOnce();
});

it('has no npm files', async () => {
await expect(writeExistingFiles(baseConfig, {})).toResolve();
});
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/manager/npm/post-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export async function writeExistingFiles(
const widens: string[] = [];
let lockFileChanged = false;
for (const upgrade of config.upgrades) {
if (upgrade.lockFiles && !upgrade.lockFiles.includes(npmLock)) {
continue;
}
if (
upgrade.rangeStrategy === 'widen' &&
upgrade.npmLock === npmLock
Expand Down