renovate/lib/config/types.ts

382 lines
9 KiB
TypeScript
Raw Normal View History

2021-03-02 20:44:55 +00:00
import type { LogLevel } from 'bunyan';
import type { Range } from 'semver';
import type { HostRule } from '../types';
2019-08-23 13:46:31 +00:00
export type RenovateConfigStage =
| 'global'
| 'repository'
| 'package'
| 'branch'
| 'pr';
export type RepositoryCacheConfig = 'disabled' | 'enabled' | 'reset';
export interface GroupConfig extends Record<string, unknown> {
branchName?: string;
branchTopic?: string;
}
2019-08-23 13:46:31 +00:00
// TODO: Proper typings
export interface RenovateSharedConfig {
$schema?: string;
2019-08-23 13:46:31 +00:00
automerge?: boolean;
branchPrefix?: string;
branchName?: string;
2020-05-03 08:14:22 +00:00
manager?: string;
commitMessage?: string;
commitMessagePrefix?: string;
draftPR?: boolean;
2019-08-23 13:46:31 +00:00
enabled?: boolean;
enabledManagers?: string[];
extends?: string[];
2020-05-03 08:14:22 +00:00
fileMatch?: string[];
group?: GroupConfig;
groupName?: string;
groupSlug?: string;
2020-05-03 08:14:22 +00:00
includePaths?: string[];
ignoreDeps?: string[];
ignorePaths?: string[];
labels?: string[];
addLabels?: string[];
2020-07-11 09:55:30 +00:00
dependencyDashboardApproval?: boolean;
hashedBranchLength?: number;
npmrc?: string;
platform?: string;
postUpgradeTasks?: PostUpgradeTasks;
prBodyColumns?: string[];
prBodyDefinitions?: Record<string, string>;
prCreation?: 'immediate' | 'not-pending' | 'status-success' | 'approval';
productLinks?: Record<string, string>;
prPriority?: number;
rebaseLabel?: string;
rebaseWhen?: string;
recreateClosed?: boolean;
repository?: string;
repositoryCache?: RepositoryCacheConfig;
requiredStatusChecks?: string[];
schedule?: string[];
semanticCommits?: 'auto' | 'enabled' | 'disabled';
semanticCommitScope?: string;
2019-08-23 13:46:31 +00:00
semanticCommitType?: string;
suppressNotifications?: string[];
timezone?: string;
unicodeEmoji?: boolean;
gitIgnoredAuthors?: string[];
}
2021-02-05 09:49:34 +00:00
// Config options used only within the global worker
2021-02-05 12:08:17 +00:00
// The below should contain config options where stage=global
2021-02-07 21:12:54 +00:00
export interface GlobalOnlyConfig {
2021-02-05 09:49:34 +00:00
autodiscover?: boolean;
autodiscoverFilter?: string;
2021-02-05 21:35:03 +00:00
baseDir?: string;
2021-02-05 11:43:26 +00:00
forceCli?: boolean;
gitPrivateKey?: string;
2021-02-05 09:49:34 +00:00
logFile?: string;
logFileLevel?: LogLevel;
2021-02-05 11:43:26 +00:00
prCommitsPerRunLimit?: number;
privateKeyPath?: string;
2021-02-05 09:49:34 +00:00
redisUrl?: string;
repositories?: RenovateRepository[];
}
2021-02-05 12:08:17 +00:00
// Config options used within the repository worker, but not user configurable
// The below should contain config options where admin=true
2021-02-05 08:20:47 +00:00
export interface RepoAdminConfig {
allowCustomCrateRegistries?: boolean;
allowPostUpgradeCommandTemplating?: boolean;
allowScripts?: boolean;
allowedPostUpgradeCommands?: string[];
customEnvVariables?: Record<string, string>;
dockerChildPrefix?: string;
2021-02-05 08:20:47 +00:00
dockerImagePrefix?: string;
dockerUser?: string;
2021-02-05 21:21:24 +00:00
dryRun?: boolean;
exposeAllEnv?: boolean;
2021-02-05 16:53:50 +00:00
privateKey?: string | Buffer;
2021-02-05 08:20:47 +00:00
}
2021-02-07 21:13:55 +00:00
export interface LegacyAdminConfig {
cacheDir?: string;
endpoint?: string;
localDir?: string;
2021-02-05 09:49:34 +00:00
logContext?: string;
onboarding?: boolean;
onboardingBranch?: string;
onboardingCommitMessage?: string;
onboardingPrTitle?: string;
onboardingConfig?: RenovateSharedConfig;
onboardingConfigFileName?: string;
platform?: string;
requireConfig?: boolean;
2019-08-23 13:46:31 +00:00
}
2021-04-09 03:51:03 +00:00
export type ExecutionMode = 'branch' | 'update';
2019-08-23 13:46:31 +00:00
2020-02-04 05:59:13 +00:00
export type PostUpgradeTasks = {
commands?: string[];
fileFilters?: string[];
2021-04-09 03:51:03 +00:00
executionMode: ExecutionMode;
2020-02-04 05:59:13 +00:00
};
type UpdateConfig<T extends RenovateSharedConfig = RenovateSharedConfig> =
Partial<Record<UpdateType, T>>;
2019-08-23 13:46:31 +00:00
export type RenovateRepository =
| string
| {
repository: string;
2021-03-22 14:51:38 +00:00
secrets?: Record<string, string>;
};
2020-03-06 08:07:55 +00:00
export interface CustomManager {
fileMatch: string[];
2020-03-06 08:07:55 +00:00
matchStrings: string[];
matchStringsStrategy?: string;
2020-03-06 08:07:55 +00:00
depNameTemplate?: string;
datasourceTemplate?: string;
lookupNameTemplate?: string;
versioningTemplate?: string;
}
2019-08-23 13:46:31 +00:00
// TODO: Proper typings
export interface RenovateConfig
2021-02-07 21:13:55 +00:00
extends LegacyAdminConfig,
RenovateSharedConfig,
2019-08-23 13:46:31 +00:00
UpdateConfig<PackageRule>,
AssigneesAndReviewersConfig,
Record<string, unknown> {
depName?: string;
2019-08-23 13:46:31 +00:00
baseBranches?: string[];
baseBranch?: string;
defaultBranch?: string;
branchList?: string[];
2020-04-29 12:27:33 +00:00
description?: string | string[];
force?: RenovateConfig;
2019-08-23 13:46:31 +00:00
errors?: ValidationMessage[];
gitAuthor?: string;
hostRules?: HostRule[];
ignorePresets?: string[];
includeForks?: boolean;
isFork?: boolean;
fileList?: string[];
2021-02-05 21:24:20 +00:00
configWarningReuseIssue?: boolean;
2020-07-11 09:55:30 +00:00
dependencyDashboard?: boolean;
dependencyDashboardAutoclose?: boolean;
dependencyDashboardChecks?: Record<string, string>;
dependencyDashboardRebaseAllOpen?: boolean;
dependencyDashboardTitle?: string;
dependencyDashboardHeader?: string;
dependencyDashboardFooter?: string;
packageFile?: string;
2019-08-23 13:46:31 +00:00
packageRules?: PackageRule[];
2021-02-05 16:55:37 +00:00
postUpdateOptions?: string[];
prConcurrentLimit?: number;
prHourlyLimit?: number;
registryUrls?: string[];
repoIsOnboarded?: boolean;
updateType?: UpdateType;
2019-08-23 13:46:31 +00:00
warnings?: ValidationMessage[];
vulnerabilityAlerts?: RenovateSharedConfig;
2020-03-06 08:07:55 +00:00
regexManagers?: CustomManager[];
fetchReleaseNotes?: boolean;
2021-03-22 14:51:38 +00:00
secrets?: Record<string, string>;
2019-08-23 13:46:31 +00:00
}
2021-02-07 21:12:54 +00:00
export interface GlobalConfig extends RenovateConfig, GlobalOnlyConfig {}
2021-02-05 09:49:34 +00:00
export interface AssigneesAndReviewersConfig {
assigneesFromCodeOwners?: boolean;
assignees?: string[];
assigneesSampleSize?: number;
reviewersFromCodeOwners?: boolean;
reviewers?: string[];
reviewersSampleSize?: number;
additionalReviewers?: string[];
2021-04-22 19:16:58 +00:00
filterUnavailableUsers?: boolean;
}
2019-08-23 13:46:31 +00:00
export type UpdateType =
| 'major'
| 'minor'
| 'patch'
| 'pin'
| 'digest'
| 'lockFileMaintenance'
| 'lockfileUpdate'
2019-08-23 13:46:31 +00:00
| 'rollback'
| 'bump';
export type MatchStringsStrategy = 'any' | 'recursive' | 'combination';
2019-08-23 13:46:31 +00:00
// TODO: Proper typings
export interface PackageRule
extends RenovateSharedConfig,
UpdateConfig,
Record<string, any> {
2021-02-19 15:29:50 +00:00
matchFiles?: string[];
matchPaths?: string[];
matchLanguages?: string[];
matchBaseBranches?: string[];
matchManagers?: string | string[];
matchDatasources?: string[];
matchDepTypes?: string[];
matchPackageNames?: string[];
matchPackagePatterns?: string[];
matchPackagePrefixes?: string[];
2019-08-23 13:46:31 +00:00
excludePackageNames?: string[];
excludePackagePatterns?: string[];
excludePackagePrefixes?: string[];
2019-08-23 13:46:31 +00:00
matchCurrentVersion?: string | Range;
matchSourceUrlPrefixes?: string[];
matchUpdateTypes?: UpdateType[];
2019-08-23 13:46:31 +00:00
}
export interface ValidationMessage {
topic: string;
2019-08-23 13:46:31 +00:00
message: string;
}
2021-03-02 20:44:55 +00:00
export interface RenovateOptionBase {
admin?: boolean;
allowedValues?: string[];
allowString?: boolean;
cli?: boolean;
description: string;
env?: false | string;
freeChoice?: boolean;
mergeable?: boolean;
autogenerated?: boolean;
name: string;
parent?: 'hostRules' | 'packageRules' | 'postUpgradeTasks' | 'regexManagers';
// used by tests
relatedOptions?: string[];
releaseStatus?: 'alpha' | 'beta' | 'unpublished';
stage?: RenovateConfigStage;
}
export interface RenovateArrayOption<
T extends string | number | Record<string, unknown> = Record<string, unknown>
> extends RenovateOptionBase {
default?: T[];
mergeable?: boolean;
type: 'array';
subType?: 'string' | 'object' | 'number';
}
export interface RenovateStringArrayOption extends RenovateArrayOption<string> {
format?: 'regex';
subType: 'string';
}
export interface RenovateNumberArrayOption extends RenovateArrayOption<number> {
subType: 'number';
}
export interface RenovateBooleanOption extends RenovateOptionBase {
default?: boolean;
type: 'boolean';
}
export interface RenovateIntegerOption extends RenovateOptionBase {
default?: number;
type: 'integer';
}
export interface RenovateStringOption extends RenovateOptionBase {
default?: string;
format?: 'regex';
// Not used
replaceLineReturns?: boolean;
type: 'string';
}
export interface RenovateObjectOption extends RenovateOptionBase {
default?: any;
additionalProperties?: Record<string, unknown> | boolean;
mergeable?: boolean;
type: 'object';
}
export type RenovateOptions =
| RenovateStringOption
| RenovateNumberArrayOption
| RenovateStringArrayOption
| RenovateIntegerOption
| RenovateBooleanOption
| RenovateArrayOption
| RenovateObjectOption;
export interface PackageRuleInputConfig extends Record<string, unknown> {
versioning?: string;
packageFile?: string;
depType?: string;
depTypes?: string[];
depName?: string;
currentValue?: string;
currentVersion?: string;
lockedVersion?: string;
updateType?: UpdateType;
isBump?: boolean;
sourceUrl?: string;
language?: string;
baseBranch?: string;
manager?: string;
datasource?: string;
packageRules?: (PackageRule & PackageRuleInputConfig)[];
}
export interface ManagerConfig extends RenovateConfig {
language: string;
manager: string;
}
export interface RenovateCliConfig extends Record<string, any> {
repositories?: string[];
}
export interface MigratedConfig {
isMigrated: boolean;
migratedConfig: RenovateConfig;
}
export interface MigratedRenovateConfig extends RenovateConfig {
endpoints?: HostRule[];
pathRules: PackageRule[];
packages: PackageRule[];
node?: RenovateConfig;
travis?: RenovateConfig;
}
export interface ValidationResult {
errors: ValidationMessage[];
warnings: ValidationMessage[];
}