Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(constants): Language list constants #5167

Merged
merged 5 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/constants/languages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const LANGUAGE_DART = 'dart';
export const LANGUAGE_DOCKER = 'docker';
export const LANGUAGE_DOT_NET = 'dotnet';
export const LANGUAGE_ELIXIR = 'elixir';
export const LANGUAGE_GOLANG = 'golang';
export const LANGUAGE_JAVA = 'java';
export const LANGUAGE_JAVASCRIPT = 'js';
export const LANGUAGE_NODE = 'node';
export const LANGUAGE_PHP = 'php';
export const LANGUAGE_PYTHON = 'python';
export const LANGUAGE_RUBY = 'ruby';
export const LANGUAGE_RUST = 'rust';
3 changes: 2 additions & 1 deletion lib/manager/ansible/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import extractPackageFile from './extract';
import updateDependency from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { updateArtifacts } from './artifacts';
import { getRangeStrategy } from './range';
import { LANGUAGE_RUBY } from '../../constants/languages';

const language = 'ruby';
const language = LANGUAGE_RUBY;

/*
* Each of the below functions contain some explanations within their own files.
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/cargo/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { updateArtifacts } from './artifacts';
import { LANGUAGE_RUST } from '../../constants/languages';

const language = 'rust';
const language = LANGUAGE_RUST;
// TODO: Support this
export const supportsLockFileMaintenance = false;

Expand Down
3 changes: 2 additions & 1 deletion lib/manager/circleci/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/composer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { extractPackageFile } from './extract';
import { updateDependency } from '../npm/update';
import { updateArtifacts } from './artifacts';
import { getRangeStrategy } from './range';
import { LANGUAGE_PHP } from '../../constants/languages';

const language = 'php';
const language = LANGUAGE_PHP;
export const supportsLockFileMaintenance = true;

export {
Expand Down
3 changes: 2 additions & 1 deletion lib/manager/docker-compose/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/dockerfile/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/droneci/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/github-actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/gitlabci/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { LANGUAGE_DOCKER } from '../../constants/languages';

const language = 'docker';
const language = LANGUAGE_DOCKER;

export { extractPackageFile, language, updateDependency };
3 changes: 2 additions & 1 deletion lib/manager/gomod/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractPackageFile } from './extract';
import { updateDependency } from './update';
import { updateArtifacts } from './artifacts';
import { LANGUAGE_GOLANG } from '../../constants/languages';

export const language = 'golang';
export const language = LANGUAGE_GOLANG;
export { extractPackageFile, updateDependency, updateArtifacts };
3 changes: 2 additions & 1 deletion lib/manager/gradle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from './gradle-updates-report';
import { PackageFile, ExtractConfig, Upgrade } from '../common';
import { platform } from '../../platform';
import { LANGUAGE_JAVA } from '../../constants/languages';
import { MANAGER_GRADLE } from '../../constants/managers';
import {
BINARY_SOURCE_DOCKER,
Expand Down Expand Up @@ -178,4 +179,4 @@ export function updateDependency(
);
}

export const language = 'java';
export const language = LANGUAGE_JAVA;
35 changes: 24 additions & 11 deletions lib/manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ import {
PackageUpdateResult,
} from './common';
import { RangeStrategy } from '../versioning';
import {
LANGUAGE_DART,
LANGUAGE_DOCKER,
LANGUAGE_DOT_NET,
LANGUAGE_ELIXIR,
LANGUAGE_GOLANG,
LANGUAGE_JAVASCRIPT,
LANGUAGE_NODE,
LANGUAGE_PHP,
LANGUAGE_PYTHON,
LANGUAGE_RUBY,
LANGUAGE_RUST,
} from '../constants/languages';
import {
MANAGER_ANSIBLE,
MANAGER_BAZEL,
Expand Down Expand Up @@ -96,17 +109,17 @@ for (const manager of managerList) {
}

const languageList = [
'dart',
'docker',
'dotnet',
'elixir',
'golang',
'js',
'node',
'php',
'python',
'ruby',
'rust',
LANGUAGE_DART,
LANGUAGE_DOCKER,
LANGUAGE_DOT_NET,
LANGUAGE_ELIXIR,
LANGUAGE_GOLANG,
LANGUAGE_JAVASCRIPT,
LANGUAGE_NODE,
LANGUAGE_PHP,
LANGUAGE_PYTHON,
LANGUAGE_RUBY,
LANGUAGE_RUST,
];

export const get = <T extends keyof ManagerApi>(
Expand Down
4 changes: 3 additions & 1 deletion lib/manager/kubernetes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_DOCKER } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';

export const language = 'docker';
export const language = LANGUAGE_DOCKER;
4 changes: 3 additions & 1 deletion lib/manager/maven/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_JAVA } from '../../constants/languages';

export { extractAllPackageFiles } from './extract';
export { updateDependency } from './update';

export const language = 'java';
export const language = LANGUAGE_JAVA;
4 changes: 3 additions & 1 deletion lib/manager/meteor/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_JAVASCRIPT } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';

export const language = 'js';
export const language = LANGUAGE_JAVASCRIPT;
4 changes: 3 additions & 1 deletion lib/manager/mix/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LANGUAGE_ELIXIR } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';
export { updateArtifacts } from './artifacts';

export const language = 'elixir';
export const language = LANGUAGE_ELIXIR;
4 changes: 3 additions & 1 deletion lib/manager/npm/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { LANGUAGE_JAVASCRIPT } from '../../constants/languages';

export { extractAllPackageFiles } from './extract';
export { updateDependency } from './update';
export { getRangeStrategy } from './range';

export const language = 'js';
export const language = LANGUAGE_JAVASCRIPT;
export const supportsLockFileMaintenance = true;
4 changes: 3 additions & 1 deletion lib/manager/nuget/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_DOT_NET } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';

export const language = 'dotnet';
export const language = LANGUAGE_DOT_NET;
4 changes: 3 additions & 1 deletion lib/manager/nvm/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_NODE } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';

export const language = 'node';
export const language = LANGUAGE_NODE;
4 changes: 3 additions & 1 deletion lib/manager/pip_requirements/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LANGUAGE_PYTHON } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';
export { getRangeStrategy } from './range';

export const language = 'python';
export const language = LANGUAGE_PYTHON;
4 changes: 3 additions & 1 deletion lib/manager/pip_setup/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_PYTHON } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from '../pip_requirements/update';

export const language = 'python';
export const language = LANGUAGE_PYTHON;
4 changes: 3 additions & 1 deletion lib/manager/pipenv/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LANGUAGE_PYTHON } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';
export { updateArtifacts } from './artifacts';

export const language = 'python';
export const language = LANGUAGE_PYTHON;
4 changes: 3 additions & 1 deletion lib/manager/poetry/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { LANGUAGE_PYTHON } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';
export { updateArtifacts } from './artifacts';

export const language = 'python';
export const language = LANGUAGE_PYTHON;
export const supportsLockFileMaintenance = false;
4 changes: 3 additions & 1 deletion lib/manager/ruby-version/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGE_RUBY } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { updateDependency } from './update';

export const language = 'ruby';
export const language = LANGUAGE_RUBY;
4 changes: 3 additions & 1 deletion lib/manager/travis/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LANGUAGE_NODE } from '../../constants/languages';

export { extractPackageFile } from './extract';
export { getPackageUpdates } from './package';
export { updateDependency } from './update';

export const language = 'node';
export const language = LANGUAGE_NODE;
3 changes: 2 additions & 1 deletion lib/workers/repository/updates/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../config';
import { applyPackageRules } from '../../../util/package-rules';
import { get } from '../../../manager';
import { LANGUAGE_DOCKER } from '../../../constants/languages';

// Return only rules that contain an updateType
function getUpdateTypeRules(packageRules: PackageRule[]): PackageRule[] {
Expand Down Expand Up @@ -63,7 +64,7 @@ export function flattenUpdates(
.toLowerCase()
: undefined;
if (
updateConfig.language === 'docker' &&
updateConfig.language === LANGUAGE_DOCKER &&
updateConfig.depName.match(/(^|\/)node$/) &&
updateConfig.depName !== 'calico/node'
) {
Expand Down
18 changes: 12 additions & 6 deletions test/util/package-rules.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { applyPackageRules, Config } from '../../lib/util/package-rules';
import { UpdateType } from '../../lib/config';
import {
LANGUAGE_DOCKER,
LANGUAGE_JAVASCRIPT,
LANGUAGE_NODE,
LANGUAGE_PYTHON,
} from '../../lib/constants/languages';
import {
MANAGER_DOCKERFILE,
MANAGER_METEOR,
Expand Down Expand Up @@ -195,7 +201,7 @@ describe('applyPackageRules()', () => {
};
const dep = {
depType: 'dependencies',
language: 'js',
language: LANGUAGE_JAVASCRIPT,
manager: MANAGER_METEOR,
depName: 'node',
};
Expand All @@ -214,7 +220,7 @@ describe('applyPackageRules()', () => {
};
const dep = {
depType: 'dependencies',
language: 'python',
language: LANGUAGE_PYTHON,
manager: MANAGER_PIPENV,
depName: 'node',
};
Expand All @@ -225,15 +231,15 @@ describe('applyPackageRules()', () => {
const config: TestConfig = {
packageRules: [
{
languages: ['js', 'node'],
languages: [LANGUAGE_JAVASCRIPT, LANGUAGE_NODE],
packageNames: ['node'],
x: 1,
},
],
};
const dep = {
depType: 'dependencies',
language: 'js',
language: LANGUAGE_JAVASCRIPT,
manager: MANAGER_METEOR,
depName: 'node',
};
Expand All @@ -244,15 +250,15 @@ describe('applyPackageRules()', () => {
const config: TestConfig = {
packageRules: [
{
languages: ['docker'],
languages: [LANGUAGE_DOCKER],
packageNames: ['node'],
x: 1,
},
],
};
const dep = {
depType: 'dependencies',
language: 'python',
language: LANGUAGE_PYTHON,
manager: MANAGER_PIPENV,
depName: 'node',
};
Expand Down
Loading