refactor: centralize lookup types

This commit is contained in:
Rhys Arkins 2021-02-18 08:35:26 +01:00
parent 71e26d835d
commit e7f2beebdb
6 changed files with 65 additions and 60 deletions

View file

@ -12,7 +12,8 @@ import { PackageDependency, PackageFile } from '../../../manager/common';
import { SkipReason } from '../../../types';
import { clone } from '../../../util/clone';
import { applyPackageRules } from '../../../util/package-rules';
import { LookupUpdateConfig, lookupUpdates } from './lookup';
import { lookupUpdates } from './lookup';
import { LookupUpdateConfig } from './lookup/common';
async function fetchDepUpdates(
packageFileConfig: ManagerConfig & PackageFile,

View file

@ -0,0 +1,53 @@
import { RenovateConfig, ValidationMessage } from '../../../../config/common';
import { Release } from '../../../../datasource';
import { LookupUpdate, RangeConfig } from '../../../../manager/common';
import { SkipReason } from '../../../../types';
export interface FilterConfig {
allowedVersions?: string;
depName?: string;
followTag?: string;
ignoreDeprecated?: boolean;
ignoreUnstable?: boolean;
respectLatest?: boolean;
versioning: string;
}
export interface RollbackConfig {
currentValue?: string;
depName?: string;
packageFile?: string;
versioning: string;
}
export interface LookupUpdateConfig
extends RollbackConfig,
FilterConfig,
RangeConfig,
RenovateConfig {
separateMinorPatch?: boolean;
digestOneAndOnly?: boolean;
pinDigests?: boolean;
rollbackPrs?: boolean;
currentDigest?: string;
lockedVersion?: string;
vulnerabilityAlert?: boolean;
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
datasource: string;
depName: string;
}
export interface UpdateResult {
sourceDirectory?: string;
changelogUrl?: string;
dependencyUrl?: string;
homepage?: string;
deprecationMessage?: string;
sourceUrl?: string;
skipReason: SkipReason;
releases: Release[];
fixedVersion?: string;
updates: LookupUpdate[];
warnings: ValidationMessage[];
}

View file

@ -7,16 +7,7 @@ import * as allVersioning from '../../../../versioning';
import * as npmVersioning from '../../../../versioning/npm';
import * as pep440 from '../../../../versioning/pep440';
import * as poetryVersioning from '../../../../versioning/poetry';
export interface FilterConfig {
allowedVersions?: string;
depName?: string;
followTag?: string;
ignoreDeprecated?: boolean;
ignoreUnstable?: boolean;
respectLatest?: boolean;
versioning: string;
}
import { FilterConfig } from './common';
export function filterVersions(
config: FilterConfig,

View file

@ -22,6 +22,7 @@ import { id as gitVersioningId } from '../../../../versioning/git';
import { id as npmVersioningId } from '../../../../versioning/npm';
import { id as pep440VersioningId } from '../../../../versioning/pep440';
import { id as poetryVersioningId } from '../../../../versioning/poetry';
import { LookupUpdateConfig } from './common';
import * as lookup from '.';
jest.mock('../../../../datasource/docker');
@ -37,12 +38,12 @@ const githubReleases = mocked(datasourceGithubReleases);
Object.assign(githubReleases, { defaultRegistryUrls: ['https://github.com'] });
let config: lookup.LookupUpdateConfig;
let config: LookupUpdateConfig;
describe('workers/repository/process/lookup', () => {
beforeEach(() => {
// TODO: fix types
config = partial<lookup.LookupUpdateConfig>(getConfig());
config = partial<LookupUpdateConfig>(getConfig());
config.manager = 'npm';
config.versioning = npmVersioningId;
config.rangeStrategy = 'replace';

View file

@ -1,8 +1,4 @@
import {
RenovateConfig,
UpdateType,
ValidationMessage,
} from '../../../../config';
import { UpdateType, ValidationMessage } from '../../../../config';
import {
Release,
getDefaultVersioning,
@ -14,45 +10,14 @@ import {
import * as datasourceGitSubmodules from '../../../../datasource/git-submodules';
import { logger } from '../../../../logger';
import { getRangeStrategy } from '../../../../manager';
import { LookupUpdate, RangeConfig } from '../../../../manager/common';
import { LookupUpdate } from '../../../../manager/common';
import { SkipReason } from '../../../../types';
import { clone } from '../../../../util/clone';
import { applyPackageRules } from '../../../../util/package-rules';
import * as allVersioning from '../../../../versioning';
import { FilterConfig, filterVersions } from './filter';
import { RollbackConfig, getRollbackUpdate } from './rollback';
export interface UpdateResult {
sourceDirectory?: string;
changelogUrl?: string;
dependencyUrl?: string;
homepage?: string;
deprecationMessage?: string;
sourceUrl?: string;
skipReason: SkipReason;
releases: Release[];
fixedVersion?: string;
updates: LookupUpdate[];
warnings: ValidationMessage[];
}
export interface LookupUpdateConfig
extends RollbackConfig,
FilterConfig,
RangeConfig,
RenovateConfig {
separateMinorPatch?: boolean;
digestOneAndOnly?: boolean;
pinDigests?: boolean;
rollbackPrs?: boolean;
currentDigest?: string;
lockedVersion?: string;
vulnerabilityAlert?: boolean;
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
datasource: string;
depName: string;
}
import { LookupUpdateConfig, UpdateResult } from './common';
import { filterVersions } from './filter';
import { getRollbackUpdate } from './rollback';
function getUpdateType(
config: LookupUpdateConfig,

View file

@ -2,13 +2,7 @@ import { Release } from '../../../../datasource/common';
import { logger } from '../../../../logger';
import { LookupUpdate } from '../../../../manager/common';
import * as allVersioning from '../../../../versioning';
export interface RollbackConfig {
currentValue?: string;
depName?: string;
packageFile?: string;
versioning: string;
}
import { RollbackConfig } from './common';
export function getRollbackUpdate(
config: RollbackConfig,