Skip to content

Commit

Permalink
refactor: update WorkerExtractConfig type definition (#16020)
Browse files Browse the repository at this point in the history
* update WorkerExtractConfig types

* update comment

* move worker-extract

* update CustomManager

* move interface RegExManagerTemplates manager->config

* fix import error

* rename CustomManager -> RegExManager

* fix lint error
  • Loading branch information
RahulGautamSingh committed Jun 16, 2022
1 parent ffe8cfb commit abe821a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 34 deletions.
27 changes: 13 additions & 14 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { LogLevel } from 'bunyan';
import type { Range } from 'semver';
import type { ExtractConfig } from '../modules/manager/types';
import type { HostRule } from '../types';
import type { GitNoVerifyOption } from '../util/git/types';

Expand Down Expand Up @@ -161,15 +160,21 @@ export type RenovateRepository =
repository: string;
secrets?: Record<string, string>;
};

export interface CustomManager {
fileMatch: string[];
matchStrings: string[];
matchStringsStrategy?: string;
export interface RegexManagerTemplates {
depNameTemplate?: string;
datasourceTemplate?: string;
packageNameTemplate?: string;
datasourceTemplate?: string;
versioningTemplate?: string;
depTypeTemplate?: string;
currentValueTemplate?: string;
currentDigestTemplate?: string;
extractVersionTemplate?: string;
registryUrlTemplate?: string;
}
export interface RegExManager extends RegexManagerTemplates {
fileMatch: string[];
matchStrings: string[];
matchStringsStrategy?: string;
autoReplaceStringTemplate?: string;
}

Expand Down Expand Up @@ -228,7 +233,7 @@ export interface RenovateConfig

warnings?: ValidationMessage[];
vulnerabilityAlerts?: RenovateSharedConfig;
regexManagers?: CustomManager[];
regexManagers?: RegExManager[];

fetchReleaseNotes?: boolean;
secrets?: Record<string, string>;
Expand Down Expand Up @@ -446,12 +451,6 @@ export interface ManagerConfig extends RenovateConfig {
language?: string | null;
}

export interface WorkerExtractConfig extends ExtractConfig {
manager: string;
enabled?: boolean;
fileList: string[];
}

export interface ValidationResult {
errors: ValidationMessage[];
warnings: ValidationMessage[];
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/regex/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import is from '@sindresorhus/is';
import type { RegexManagerTemplates } from '../../../config/types';
import type {
CustomExtractConfig,
PackageDependency,
PackageFile,
RegexManagerTemplates,
Result,
} from '../types';
import { handleAny, handleCombination, handleRecursive } from './strategies';
Expand Down
7 changes: 2 additions & 5 deletions lib/modules/manager/regex/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { URL } from 'url';
import type { RegexManagerTemplates } from '../../../config/types';
import { logger } from '../../../logger';
import * as template from '../../../util/template';
import type {
CustomExtractConfig,
PackageDependency,
RegexManagerTemplates,
} from '../types';
import type { CustomExtractConfig, PackageDependency } from '../types';
import type { ExtractionTemplate } from './types';

export const validMatchFields = [
Expand Down
9 changes: 1 addition & 8 deletions lib/modules/manager/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReleaseType } from 'semver';
import type {
MatchStringsStrategy,
RegexManagerTemplates,
UpdateType,
ValidationMessage,
} from '../../config/types';
Expand All @@ -21,14 +22,6 @@ export interface ExtractConfig {
skipInstalls?: boolean;
}

export interface RegexManagerTemplates {
depNameTemplate?: string;
packageNameTemplate?: string;
datasourceTemplate?: string;
versioningTemplate?: string;
depTypeTemplate?: string;
}

export interface CustomExtractConfig
extends ExtractConfig,
RegexManagerTemplates {
Expand Down
7 changes: 2 additions & 5 deletions lib/workers/repository/extract/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import is from '@sindresorhus/is';
import { getManagerConfig, mergeChildConfig } from '../../../config';
import type {
ManagerConfig,
RenovateConfig,
WorkerExtractConfig,
} from '../../../config/types';
import type { ManagerConfig, RenovateConfig } from '../../../config/types';
import { logger } from '../../../logger';
import { getManagerList } from '../../../modules/manager';
import type { PackageFile } from '../../../modules/manager/types';
import { getFileList } from '../../../util/git';
import type { WorkerExtractConfig } from '../../types';
import { getMatchingFiles } from './file-match';
import { getManagerPackageFiles } from './manager-files';

Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/extract/manager-files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import is from '@sindresorhus/is';
import type { WorkerExtractConfig } from '../../../config/types';
import { logger } from '../../../logger';
import {
extractAllPackageFiles,
Expand All @@ -8,6 +7,7 @@ import {
} from '../../../modules/manager';
import type { PackageFile } from '../../../modules/manager/types';
import { readLocalFile } from '../../../util/fs';
import type { WorkerExtractConfig } from '../../types';

export async function getManagerPackageFiles(
config: WorkerExtractConfig
Expand Down
17 changes: 17 additions & 0 deletions lib/workers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import type { Merge } from 'type-fest';
import type {
GroupConfig,
LegacyAdminConfig,
RegExManager,
RenovateConfig,
RenovateSharedConfig,
ValidationMessage,
} from '../config/types';
import type { Release } from '../modules/datasource/types';
import type {
ArtifactError,
CustomExtractConfig,
ExtractConfig,
LookupUpdate,
PackageDependency,
PackageFile,
Expand Down Expand Up @@ -123,3 +126,17 @@ export interface BranchConfig
stopUpdating?: boolean;
isConflicted?: boolean;
}

export interface WorkerExtractConfig
extends ExtractConfig,
Partial<CustomExtractConfig> {
manager: string;
fileList: string[];
fileMatch?: string[];
updateInternalDeps?: boolean;
includePaths?: string[];
ignorePaths?: string[];
regexManagers?: RegExManager[];
enabledManagers?: string[];
enabled?: boolean;
}

0 comments on commit abe821a

Please sign in to comment.