fix: Revert "fix: move update internal deps to worker logic" (#15756)

This commit is contained in:
Michael Kriese 2022-05-27 16:44:58 +02:00 committed by GitHub
parent 9e7659f754
commit 3ee32bce6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 69 deletions

View file

@ -216,7 +216,7 @@ export interface RenovateConfig
repoIsOnboarded?: boolean;
repoIsActivated?: boolean;
updateInternalDeps?: boolean;
updateType?: UpdateType;
warnings?: ValidationMessage[];

View file

@ -6,11 +6,9 @@ Array [
"deps": Array [
Object {
"depName": "@org/a",
"isInternal": true,
},
Object {
"depName": "@org/b",
"isInternal": true,
},
Object {
"depName": "@org/c",
@ -34,7 +32,6 @@ Array [
"deps": Array [
Object {
"depName": "@org/b",
"isInternal": true,
},
Object {
"depName": "@org/c",
@ -75,11 +72,11 @@ Array [
"deps": Array [
Object {
"depName": "@org/a",
"isInternal": true,
"skipReason": "internal-package",
},
Object {
"depName": "@org/b",
"isInternal": true,
"skipReason": "internal-package",
},
Object {
"depName": "@org/c",
@ -103,7 +100,7 @@ Array [
"deps": Array [
Object {
"depName": "@org/b",
"isInternal": true,
"skipReason": "internal-package",
},
Object {
"depName": "@org/c",

View file

@ -752,7 +752,7 @@ describe('modules/manager/npm/extract/index', () => {
describe('.postExtract()', () => {
it('runs', async () => {
await expect(npmExtract.postExtract([])).resolves.not.toThrow();
await expect(npmExtract.postExtract([], false)).resolves.not.toThrow();
});
});
});

View file

@ -472,8 +472,11 @@ export async function extractPackageFile(
};
}
export async function postExtract(packageFiles: PackageFile[]): Promise<void> {
await detectMonorepos(packageFiles);
export async function postExtract(
packageFiles: PackageFile[],
updateInternalDeps: boolean
): Promise<void> {
await detectMonorepos(packageFiles, updateInternalDeps);
await getLockedVersions(packageFiles);
}
@ -497,8 +500,7 @@ export async function extractAllPackageFiles(
logger.debug({ packageFile }, 'packageFile has no content');
}
}
await postExtract(npmFiles);
await postExtract(npmFiles, !!config.updateInternalDeps);
return npmFiles;
}

View file

@ -48,12 +48,12 @@ describe('modules/manager/npm/extract/monorepo', () => {
packageJsonName: '@org/b',
},
] as any;
await detectMonorepos(packageFiles);
await detectMonorepos(packageFiles, false);
expect(packageFiles).toMatchSnapshot();
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
expect(
packageFiles.some((packageFile) =>
packageFile.deps?.some((dep) => dep.isInternal)
packageFile.deps?.some((dep) => dep.skipReason)
)
).toBeTrue();
});
@ -102,14 +102,14 @@ describe('modules/manager/npm/extract/monorepo', () => {
packageJsonName: '@org/b',
},
] as any;
await detectMonorepos(packageFiles);
await detectMonorepos(packageFiles, true);
expect(packageFiles).toMatchSnapshot();
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
expect(
packageFiles.some((packageFile) =>
packageFile.deps?.some((dep) => dep.isInternal)
packageFile.deps?.some((dep) => dep.skipReason)
)
).toBeTrue();
).toBeFalse();
});
it('uses yarn workspaces package settings with lerna', async () => {
@ -132,7 +132,7 @@ describe('modules/manager/npm/extract/monorepo', () => {
packageJsonName: '@org/b',
},
];
await detectMonorepos(packageFiles);
await detectMonorepos(packageFiles, false);
expect(packageFiles).toMatchSnapshot();
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
});
@ -154,7 +154,7 @@ describe('modules/manager/npm/extract/monorepo', () => {
packageJsonName: '@org/b',
},
];
await detectMonorepos(packageFiles);
await detectMonorepos(packageFiles, false);
expect(packageFiles).toMatchSnapshot([
{},
{ npmrc: '@org:registry=//registry.some.org\n' },
@ -184,7 +184,7 @@ describe('modules/manager/npm/extract/monorepo', () => {
skipInstalls: true,
},
];
await detectMonorepos(packageFiles);
await detectMonorepos(packageFiles, false);
expect(packageFiles).toMatchSnapshot([
{},
{ managerData: { yarnZeroInstall: true }, skipInstalls: false },

View file

@ -6,7 +6,8 @@ import { detectPnpmWorkspaces } from './pnpm';
import { matchesAnyPattern } from './utils';
export async function detectMonorepos(
packageFiles: Partial<PackageFile>[]
packageFiles: Partial<PackageFile>[],
updateInternalDeps: boolean
): Promise<void> {
await detectPnpmWorkspaces(packageFiles);
logger.debug('Detecting Lerna and Yarn Workspaces');
@ -40,13 +41,13 @@ export async function detectMonorepos(
const internalPackageNames = internalPackageFiles
.map((sp) => sp.packageJsonName)
.filter(Boolean);
if (!updateInternalDeps) {
p.deps?.forEach((dep) => {
if (internalPackageNames.includes(dep.depName)) {
dep.isInternal = true;
dep.skipReason = 'internal-package';
}
});
}
for (const subPackage of internalPackageFiles) {
subPackage.managerData = subPackage.managerData || {};
subPackage.managerData.lernaJsonFile = lernaJsonFile;
@ -59,13 +60,14 @@ export async function detectMonorepos(
subPackage.hasYarnWorkspaces = !!yarnWorkspacesPackages;
subPackage.npmrc = subPackage.npmrc || npmrc;
}
if (!updateInternalDeps) {
subPackage.deps?.forEach((dep) => {
if (internalPackageNames.includes(dep.depName)) {
dep.isInternal = true;
dep.skipReason = 'internal-package';
}
});
}
}
}
}
}

View file

@ -21,6 +21,7 @@ export interface ExtractConfig {
npmrc?: string;
npmrcMerge?: boolean;
skipInstalls?: boolean;
updateInternalDeps?: boolean;
}
export interface RegexManagerTemplates {
@ -171,7 +172,6 @@ export interface PackageDependency<T = Record<string, any>> extends Package<T> {
editFile?: string;
separateMinorPatch?: boolean;
extractVersion?: string;
isInternal?: boolean;
}
export interface Upgrade<T = Record<string, any>>

View file

@ -40,30 +40,6 @@ describe('workers/repository/extract/index', () => {
expect(logger.debug).toHaveBeenCalled();
});
it('adds skipReason to internal deps when updateInternalDeps is false/undefined', async () => {
config.enabledManagers = ['npm'];
managerFiles.getManagerPackageFiles.mockResolvedValue([
{
deps: [{ depName: 'a', isInternal: true }, { depName: 'b' }],
},
]);
expect(await extractAllDependencies(config)).toEqual({
npm: [
{
deps: [
{
depName: 'a',
isInternal: true,
skipReason: 'internal-package',
},
{ depName: 'b' },
],
},
],
});
expect(logger.debug).toHaveBeenCalled();
});
it('checks custom managers', async () => {
managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]);
config.regexManagers = [{ fileMatch: ['README'], matchStrings: [''] }];

View file

@ -47,16 +47,6 @@ export async function extractAllDependencies(
const extractResults = await Promise.all(
extractList.map(async (managerConfig) => {
const packageFiles = await getManagerPackageFiles(managerConfig);
for (const p of packageFiles) {
//istanbul ignore if
if (p.deps) {
for (const dep of p.deps) {
if (!config.updateInternalDeps && dep.isInternal) {
dep.skipReason = 'internal-package';
}
}
}
}
return { manager: managerConfig.manager, packageFiles };
})
);