Skip to content

Commit

Permalink
feat(constants): Version Scheme Constants (renovatebot#5159)
Browse files Browse the repository at this point in the history
  • Loading branch information
souravdasslg authored and rarkins committed Jan 21, 2020
1 parent e349003 commit 520429f
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 77 deletions.
98 changes: 59 additions & 39 deletions lib/config/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import { RenovateConfigStage } from './common';
import {
VERSION_SCHEME_CARGO,
VERSION_SCHEME_COMPOSER,
VERSION_SCHEME_DOCKER,
VERSION_SCHEME_GIT,
VERSION_SCHEME_HEX,
VERSION_SCHEME_HASHICORP,
VERSION_SCHEME_IVY,
VERSION_SCHEME_LOOSE,
VERSION_SCHEME_MAVEN,
VERSION_SCHEME_NODE,
VERSION_SCHEME_NPM,
VERSION_SCHEME_NUGET,
VERSION_SCHEME_PEP440,
VERSION_SCHEME_POETRY,
VERSION_SCHEME_REGEX,
VERSION_SCHEME_RUBY,
VERSION_SCHEME_SEMVER,
VERSION_SCHEME_SWIFT,
} from '../constants/version-schemes';
import {
PLATFORM_TYPE_AZURE,
PLATFORM_TYPE_BITBUCKET,
Expand Down Expand Up @@ -601,26 +621,26 @@ const options: RenovateOptions[] = [
description: 'Version scheme to use for filtering and comparisons',
type: 'string',
allowedValues: [
'cargo',
'composer',
'docker',
'git',
'hashicorp',
'hex',
'ivy',
'loose',
'maven',
'node',
'npm',
'nuget',
'pep440',
'poetry',
'regex',
'ruby',
'semver',
'swift',
VERSION_SCHEME_CARGO,
VERSION_SCHEME_COMPOSER,
VERSION_SCHEME_DOCKER,
VERSION_SCHEME_GIT,
VERSION_SCHEME_HASHICORP,
VERSION_SCHEME_HEX,
VERSION_SCHEME_IVY,
VERSION_SCHEME_LOOSE,
VERSION_SCHEME_MAVEN,
VERSION_SCHEME_NODE,
VERSION_SCHEME_NPM,
VERSION_SCHEME_NUGET,
VERSION_SCHEME_PEP440,
VERSION_SCHEME_POETRY,
VERSION_SCHEME_REGEX,
VERSION_SCHEME_RUBY,
VERSION_SCHEME_SEMVER,
VERSION_SCHEME_SWIFT,
],
default: 'semver',
default: VERSION_SCHEME_SEMVER,
cli: false,
env: false,
},
Expand Down Expand Up @@ -1379,7 +1399,7 @@ const options: RenovateOptions[] = [
default: {
fileMatch: ['(^|/)package.json$'],
rollbackPrs: true,
versionScheme: 'npm',
versionScheme: VERSION_SCHEME_NPM,
prBodyDefinitions: {
Change:
'[{{#if displayFrom}}`{{{displayFrom}}}` -> {{else}}{{#if currentValue}}`{{{currentValue}}}` -> {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}](https://renovatebot.com/diffs/npm/{{{depNameEscaped}}}/{{{fromVersion}}}/{{{toVersion}}})',
Expand Down Expand Up @@ -1474,7 +1494,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)Gemfile$'],
versionScheme: 'ruby',
versionScheme: VERSION_SCHEME_RUBY,
},
mergeable: true,
},
Expand All @@ -1485,7 +1505,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)\\.ruby-version$'],
versionScheme: 'ruby',
versionScheme: VERSION_SCHEME_RUBY,
},
mergeable: true,
cli: false,
Expand All @@ -1499,7 +1519,7 @@ const options: RenovateOptions[] = [
commitMessageTopic:
'Terraform {{managerData.terraformDependencyType}} {{depNameShort}}',
fileMatch: ['\\.tf$'],
versionScheme: 'hashicorp',
versionScheme: VERSION_SCHEME_HASHICORP,
},
mergeable: true,
},
Expand All @@ -1510,7 +1530,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)mix\\.exs$'],
versionScheme: 'hex',
versionScheme: VERSION_SCHEME_HEX,
},
mergeable: true,
},
Expand All @@ -1532,7 +1552,7 @@ const options: RenovateOptions[] = [
commitMessageTopic: 'Rust crate {{depName}}',
managerBranchPrefix: 'rust-',
fileMatch: ['(^|/)Cargo.toml$'],
versionScheme: 'cargo',
versionScheme: VERSION_SCHEME_CARGO,
rangeStrategy: 'bump',
},
mergeable: true,
Expand Down Expand Up @@ -1567,7 +1587,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['^.travis.yml$'],
versionScheme: 'node',
versionScheme: VERSION_SCHEME_NODE,
},
mergeable: true,
cli: false,
Expand All @@ -1579,7 +1599,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['^.nvmrc$'],
versionScheme: 'node',
versionScheme: VERSION_SCHEME_NODE,
},
mergeable: true,
cli: false,
Expand All @@ -1591,7 +1611,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)pubspec\\.ya?ml$'],
versionScheme: 'npm',
versionScheme: VERSION_SCHEME_NPM,
},
mergeable: true,
cli: false,
Expand All @@ -1602,7 +1622,7 @@ const options: RenovateOptions[] = [
stage: 'package',
type: 'object',
default: {
versionScheme: 'docker',
versionScheme: VERSION_SCHEME_DOCKER,
managerBranchPrefix: 'docker-',
commitMessageTopic: '{{{depName}}} Docker tag',
major: { enabled: false },
Expand Down Expand Up @@ -1742,7 +1762,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)([\\w-]*)composer.json$'],
versionScheme: 'composer',
versionScheme: VERSION_SCHEME_COMPOSER,
},
mergeable: true,
cli: false,
Expand All @@ -1754,7 +1774,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
enabled: false,
versionScheme: 'git',
versionScheme: VERSION_SCHEME_GIT,
fileMatch: ['(^|/).gitmodules$'],
},
mergeable: true,
Expand Down Expand Up @@ -1808,7 +1828,7 @@ const options: RenovateOptions[] = [
stage: 'package',
type: 'object',
default: {
versionScheme: 'poetry',
versionScheme: VERSION_SCHEME_POETRY,
fileMatch: ['(^|/)pyproject\\.toml$'],
},
mergeable: true,
Expand All @@ -1819,7 +1839,7 @@ const options: RenovateOptions[] = [
stage: 'package',
type: 'object',
default: {
versionScheme: 'pep440',
versionScheme: VERSION_SCHEME_PEP440,
},
mergeable: true,
cli: false,
Expand All @@ -1832,7 +1852,7 @@ const options: RenovateOptions[] = [
default: {
fileMatch: ['\\.sbt$', 'project/[^/]*.scala$'],
timeout: 300,
versionScheme: 'ivy',
versionScheme: VERSION_SCHEME_IVY,
},
mergeable: true,
cli: false,
Expand All @@ -1845,7 +1865,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)project\\.clj$'],
versionScheme: 'maven',
versionScheme: VERSION_SCHEME_MAVEN,
},
mergeable: true,
cli: false,
Expand All @@ -1858,7 +1878,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)deps\\.edn$'],
versionScheme: 'maven',
versionScheme: VERSION_SCHEME_MAVEN,
},
mergeable: true,
cli: false,
Expand Down Expand Up @@ -1888,7 +1908,7 @@ const options: RenovateOptions[] = [
default: {
fileMatch: ['\\.gradle(\\.kts)?$', '(^|/)gradle.properties$'],
timeout: 600,
versionScheme: 'maven',
versionScheme: VERSION_SCHEME_MAVEN,
},
mergeable: true,
cli: false,
Expand All @@ -1911,7 +1931,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['\\.pom\\.xml$', '(^|/)pom\\.xml$'],
versionScheme: 'maven',
versionScheme: VERSION_SCHEME_MAVEN,
},
mergeable: true,
cli: false,
Expand Down Expand Up @@ -2102,7 +2122,7 @@ const options: RenovateOptions[] = [
type: 'object',
default: {
fileMatch: ['(^|/)Package\\.swift'],
versionScheme: 'swift',
versionScheme: VERSION_SCHEME_SWIFT,
rangeStrategy: 'bump',
},
mergeable: true,
Expand Down
18 changes: 18 additions & 0 deletions lib/constants/version-schemes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const VERSION_SCHEME_SEMVER = 'semver';
export const VERSION_SCHEME_NPM = 'npm';
export const VERSION_SCHEME_NODE = 'node';
export const VERSION_SCHEME_HASHICORP = 'hashicorp';
export const VERSION_SCHEME_COMPOSER = 'composer';
export const VERSION_SCHEME_GIT = 'git';
export const VERSION_SCHEME_POETRY = 'poetry';
export const VERSION_SCHEME_MAVEN = 'maven';
export const VERSION_SCHEME_SWIFT = 'swift';
export const VERSION_SCHEME_RUBY = 'ruby';
export const VERSION_SCHEME_HEX = 'hex';
export const VERSION_SCHEME_CARGO = 'cargo';
export const VERSION_SCHEME_DOCKER = 'docker';
export const VERSION_SCHEME_PEP440 = 'pep440';
export const VERSION_SCHEME_IVY = 'ivy';
export const VERSION_SCHEME_LOOSE = 'loose';
export const VERSION_SCHEME_NUGET = 'nuget';
export const VERSION_SCHEME_REGEX = 'regex';
5 changes: 4 additions & 1 deletion lib/datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
ReleaseResult,
DigestConfig,
} from './common';
import { VERSION_SCHEME_SEMVER } from '../constants/version-schemes';

export * from './common';

Expand Down Expand Up @@ -105,7 +106,9 @@ export async function getPkgReleases(
return res;
}
const versionScheme =
config && config.versionScheme ? config.versionScheme : 'semver';
config && config.versionScheme
? config.versionScheme
: VERSION_SCHEME_SEMVER;
// Filter by version scheme
const version = versioning.get(versionScheme);
// Return a sorted list of valid Versions
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/ansible/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { logger } from '../../logger';
import { getDep } from '../dockerfile/extract';
import { PackageFile, PackageDependency } from '../common';
import { VERSION_SCHEME_DOCKER } from '../../constants/version-schemes';

export default function extractPackageFile(
content: string
Expand All @@ -22,7 +23,7 @@ export default function extractPackageFile(
'Docker image inside ansible'
);
dep.managerData = { lineNumber };
dep.versionScheme = 'docker';
dep.versionScheme = VERSION_SCHEME_DOCKER;
deps.push(dep);
}
lineNumber += 1;
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/bazel/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { parse as _parse } from 'url';
import { logger } from '../../logger';
import { PackageDependency, PackageFile } from '../common';
import { regEx } from '../../util/regex';
import { VERSION_SCHEME_DOCKER } from '../../constants/version-schemes';
import {
DATASOURCE_DOCKER,
DATASOURCE_GITHUB,
Expand Down Expand Up @@ -241,8 +242,8 @@ export function extractPackageFile(content: string): PackageFile | null {
dep.currentDigest = digest;
dep.currentValue = currentValue;
dep.depName = depName;
dep.versionScheme = VERSION_SCHEME_DOCKER;
dep.datasource = DATASOURCE_DOCKER;
dep.versionScheme = 'docker';
dep.lookupName = repository;
deps.push(dep);
} else {
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/circleci/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { logger } from '../../logger';
import { getDep } from '../dockerfile/extract';
import { PackageFile, PackageDependency } from '../common';
import { VERSION_SCHEME_NPM } from '../../constants/version-schemes';
import { DATASOURCE_ORB } from '../../constants/data-binary-source';

export function extractPackageFile(content: string): PackageFile | null {
Expand Down Expand Up @@ -32,7 +33,7 @@ export function extractPackageFile(content: string): PackageFile | null {
datasource: DATASOURCE_ORB,
lookupName: orbName,
commitMessageTopic: '{{{depName}}} orb',
versionScheme: 'npm',
versionScheme: VERSION_SCHEME_NPM,
rangeStrategy: 'pin',
};
deps.push(dep);
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/github-actions/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { logger } from '../../logger';
import { getDep } from '../dockerfile/extract';
import { PackageFile, PackageDependency } from '../common';
import { VERSION_SCHEME_DOCKER } from '../../constants/version-schemes';

export function extractPackageFile(content: string): PackageFile | null {
logger.debug('github-actions.extractPackageFile()');
Expand All @@ -24,7 +25,7 @@ export function extractPackageFile(content: string): PackageFile | null {
'Docker image inside GitHub Actions'
);
dep.managerData = { lineNumber };
dep.versionScheme = 'docker';
dep.versionScheme = VERSION_SCHEME_DOCKER;
deps.push(dep);
}
lineNumber += 1;
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/gradle-wrapper/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { coerce } from 'semver';
import { logger } from '../../logger';
import { PackageFile, PackageDependency } from '../common';
import { VERSION_SCHEME_SEMVER } from '../../constants/version-schemes';
import { DATASOURCE_GRADLE_VERSION } from '../../constants/data-binary-source';

export function extractPackageFile(fileContent: string): PackageFile | null {
Expand All @@ -19,7 +20,7 @@ export function extractPackageFile(fileContent: string): PackageFile | null {
depName: 'gradle',
currentValue: coerce(match[1]).toString(),
managerData: { lineNumber, gradleWrapperType: match[3] },
versionScheme: 'semver',
versionScheme: VERSION_SCHEME_SEMVER,
};

let shaLineNumber = 0;
Expand Down
Loading

0 comments on commit 520429f

Please sign in to comment.