mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix: Revert "fix: move update internal deps to worker logic" (#15756)
This commit is contained in:
parent
9e7659f754
commit
3ee32bce6c
9 changed files with 36 additions and 69 deletions
|
@ -216,7 +216,7 @@ export interface RenovateConfig
|
||||||
|
|
||||||
repoIsOnboarded?: boolean;
|
repoIsOnboarded?: boolean;
|
||||||
repoIsActivated?: boolean;
|
repoIsActivated?: boolean;
|
||||||
updateInternalDeps?: boolean;
|
|
||||||
updateType?: UpdateType;
|
updateType?: UpdateType;
|
||||||
|
|
||||||
warnings?: ValidationMessage[];
|
warnings?: ValidationMessage[];
|
||||||
|
|
|
@ -6,11 +6,9 @@ Array [
|
||||||
"deps": Array [
|
"deps": Array [
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/a",
|
"depName": "@org/a",
|
||||||
"isInternal": true,
|
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/b",
|
"depName": "@org/b",
|
||||||
"isInternal": true,
|
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/c",
|
"depName": "@org/c",
|
||||||
|
@ -34,7 +32,6 @@ Array [
|
||||||
"deps": Array [
|
"deps": Array [
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/b",
|
"depName": "@org/b",
|
||||||
"isInternal": true,
|
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/c",
|
"depName": "@org/c",
|
||||||
|
@ -75,11 +72,11 @@ Array [
|
||||||
"deps": Array [
|
"deps": Array [
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/a",
|
"depName": "@org/a",
|
||||||
"isInternal": true,
|
"skipReason": "internal-package",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/b",
|
"depName": "@org/b",
|
||||||
"isInternal": true,
|
"skipReason": "internal-package",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/c",
|
"depName": "@org/c",
|
||||||
|
@ -103,7 +100,7 @@ Array [
|
||||||
"deps": Array [
|
"deps": Array [
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/b",
|
"depName": "@org/b",
|
||||||
"isInternal": true,
|
"skipReason": "internal-package",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"depName": "@org/c",
|
"depName": "@org/c",
|
||||||
|
|
|
@ -752,7 +752,7 @@ describe('modules/manager/npm/extract/index', () => {
|
||||||
|
|
||||||
describe('.postExtract()', () => {
|
describe('.postExtract()', () => {
|
||||||
it('runs', async () => {
|
it('runs', async () => {
|
||||||
await expect(npmExtract.postExtract([])).resolves.not.toThrow();
|
await expect(npmExtract.postExtract([], false)).resolves.not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -472,8 +472,11 @@ export async function extractPackageFile(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postExtract(packageFiles: PackageFile[]): Promise<void> {
|
export async function postExtract(
|
||||||
await detectMonorepos(packageFiles);
|
packageFiles: PackageFile[],
|
||||||
|
updateInternalDeps: boolean
|
||||||
|
): Promise<void> {
|
||||||
|
await detectMonorepos(packageFiles, updateInternalDeps);
|
||||||
await getLockedVersions(packageFiles);
|
await getLockedVersions(packageFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,8 +500,7 @@ export async function extractAllPackageFiles(
|
||||||
logger.debug({ packageFile }, 'packageFile has no content');
|
logger.debug({ packageFile }, 'packageFile has no content');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await postExtract(npmFiles, !!config.updateInternalDeps);
|
||||||
await postExtract(npmFiles);
|
|
||||||
return npmFiles;
|
return npmFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,12 @@ describe('modules/manager/npm/extract/monorepo', () => {
|
||||||
packageJsonName: '@org/b',
|
packageJsonName: '@org/b',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
await detectMonorepos(packageFiles);
|
await detectMonorepos(packageFiles, false);
|
||||||
expect(packageFiles).toMatchSnapshot();
|
expect(packageFiles).toMatchSnapshot();
|
||||||
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
|
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
|
||||||
expect(
|
expect(
|
||||||
packageFiles.some((packageFile) =>
|
packageFiles.some((packageFile) =>
|
||||||
packageFile.deps?.some((dep) => dep.isInternal)
|
packageFile.deps?.some((dep) => dep.skipReason)
|
||||||
)
|
)
|
||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
});
|
});
|
||||||
|
@ -102,14 +102,14 @@ describe('modules/manager/npm/extract/monorepo', () => {
|
||||||
packageJsonName: '@org/b',
|
packageJsonName: '@org/b',
|
||||||
},
|
},
|
||||||
] as any;
|
] as any;
|
||||||
await detectMonorepos(packageFiles);
|
await detectMonorepos(packageFiles, true);
|
||||||
expect(packageFiles).toMatchSnapshot();
|
expect(packageFiles).toMatchSnapshot();
|
||||||
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
|
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
|
||||||
expect(
|
expect(
|
||||||
packageFiles.some((packageFile) =>
|
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 () => {
|
it('uses yarn workspaces package settings with lerna', async () => {
|
||||||
|
@ -132,7 +132,7 @@ describe('modules/manager/npm/extract/monorepo', () => {
|
||||||
packageJsonName: '@org/b',
|
packageJsonName: '@org/b',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
await detectMonorepos(packageFiles);
|
await detectMonorepos(packageFiles, false);
|
||||||
expect(packageFiles).toMatchSnapshot();
|
expect(packageFiles).toMatchSnapshot();
|
||||||
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
|
expect(packageFiles[1].managerData.lernaJsonFile).toBe('lerna.json');
|
||||||
});
|
});
|
||||||
|
@ -154,7 +154,7 @@ describe('modules/manager/npm/extract/monorepo', () => {
|
||||||
packageJsonName: '@org/b',
|
packageJsonName: '@org/b',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
await detectMonorepos(packageFiles);
|
await detectMonorepos(packageFiles, false);
|
||||||
expect(packageFiles).toMatchSnapshot([
|
expect(packageFiles).toMatchSnapshot([
|
||||||
{},
|
{},
|
||||||
{ npmrc: '@org:registry=//registry.some.org\n' },
|
{ npmrc: '@org:registry=//registry.some.org\n' },
|
||||||
|
@ -184,7 +184,7 @@ describe('modules/manager/npm/extract/monorepo', () => {
|
||||||
skipInstalls: true,
|
skipInstalls: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
await detectMonorepos(packageFiles);
|
await detectMonorepos(packageFiles, false);
|
||||||
expect(packageFiles).toMatchSnapshot([
|
expect(packageFiles).toMatchSnapshot([
|
||||||
{},
|
{},
|
||||||
{ managerData: { yarnZeroInstall: true }, skipInstalls: false },
|
{ managerData: { yarnZeroInstall: true }, skipInstalls: false },
|
||||||
|
|
|
@ -6,7 +6,8 @@ import { detectPnpmWorkspaces } from './pnpm';
|
||||||
import { matchesAnyPattern } from './utils';
|
import { matchesAnyPattern } from './utils';
|
||||||
|
|
||||||
export async function detectMonorepos(
|
export async function detectMonorepos(
|
||||||
packageFiles: Partial<PackageFile>[]
|
packageFiles: Partial<PackageFile>[],
|
||||||
|
updateInternalDeps: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await detectPnpmWorkspaces(packageFiles);
|
await detectPnpmWorkspaces(packageFiles);
|
||||||
logger.debug('Detecting Lerna and Yarn Workspaces');
|
logger.debug('Detecting Lerna and Yarn Workspaces');
|
||||||
|
@ -40,13 +41,13 @@ export async function detectMonorepos(
|
||||||
const internalPackageNames = internalPackageFiles
|
const internalPackageNames = internalPackageFiles
|
||||||
.map((sp) => sp.packageJsonName)
|
.map((sp) => sp.packageJsonName)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
if (!updateInternalDeps) {
|
||||||
p.deps?.forEach((dep) => {
|
p.deps?.forEach((dep) => {
|
||||||
if (internalPackageNames.includes(dep.depName)) {
|
if (internalPackageNames.includes(dep.depName)) {
|
||||||
dep.isInternal = true;
|
dep.skipReason = 'internal-package';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
for (const subPackage of internalPackageFiles) {
|
for (const subPackage of internalPackageFiles) {
|
||||||
subPackage.managerData = subPackage.managerData || {};
|
subPackage.managerData = subPackage.managerData || {};
|
||||||
subPackage.managerData.lernaJsonFile = lernaJsonFile;
|
subPackage.managerData.lernaJsonFile = lernaJsonFile;
|
||||||
|
@ -59,13 +60,14 @@ export async function detectMonorepos(
|
||||||
subPackage.hasYarnWorkspaces = !!yarnWorkspacesPackages;
|
subPackage.hasYarnWorkspaces = !!yarnWorkspacesPackages;
|
||||||
subPackage.npmrc = subPackage.npmrc || npmrc;
|
subPackage.npmrc = subPackage.npmrc || npmrc;
|
||||||
}
|
}
|
||||||
|
if (!updateInternalDeps) {
|
||||||
subPackage.deps?.forEach((dep) => {
|
subPackage.deps?.forEach((dep) => {
|
||||||
if (internalPackageNames.includes(dep.depName)) {
|
if (internalPackageNames.includes(dep.depName)) {
|
||||||
dep.isInternal = true;
|
dep.skipReason = 'internal-package';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ export interface ExtractConfig {
|
||||||
npmrc?: string;
|
npmrc?: string;
|
||||||
npmrcMerge?: boolean;
|
npmrcMerge?: boolean;
|
||||||
skipInstalls?: boolean;
|
skipInstalls?: boolean;
|
||||||
|
updateInternalDeps?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegexManagerTemplates {
|
export interface RegexManagerTemplates {
|
||||||
|
@ -171,7 +172,6 @@ export interface PackageDependency<T = Record<string, any>> extends Package<T> {
|
||||||
editFile?: string;
|
editFile?: string;
|
||||||
separateMinorPatch?: boolean;
|
separateMinorPatch?: boolean;
|
||||||
extractVersion?: string;
|
extractVersion?: string;
|
||||||
isInternal?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Upgrade<T = Record<string, any>>
|
export interface Upgrade<T = Record<string, any>>
|
||||||
|
|
|
@ -40,30 +40,6 @@ describe('workers/repository/extract/index', () => {
|
||||||
expect(logger.debug).toHaveBeenCalled();
|
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 () => {
|
it('checks custom managers', async () => {
|
||||||
managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]);
|
managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]);
|
||||||
config.regexManagers = [{ fileMatch: ['README'], matchStrings: [''] }];
|
config.regexManagers = [{ fileMatch: ['README'], matchStrings: [''] }];
|
||||||
|
|
|
@ -47,16 +47,6 @@ export async function extractAllDependencies(
|
||||||
const extractResults = await Promise.all(
|
const extractResults = await Promise.all(
|
||||||
extractList.map(async (managerConfig) => {
|
extractList.map(async (managerConfig) => {
|
||||||
const packageFiles = await getManagerPackageFiles(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 };
|
return { manager: managerConfig.manager, packageFiles };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue