This commit is contained in:
Michael Kriese 2021-03-02 17:16:05 +01:00 коммит произвёл GitHub
Родитель 91d2b4e1c5
Коммит 91a7e6b660
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
20 изменённых файлов: 319 добавлений и 1212 удалений

3
.vscode/launch.json поставляемый
Просмотреть файл

@ -8,8 +8,7 @@
"program": "${workspaceFolder}/lib/renovate.ts",
"env": { "LOG_LEVEL": "debug" },
"console": "integratedTerminal",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": ["--extensions", ".ts,.js"],
"runtimeArgs": ["-r", "ts-node/register/transpile-only"],
"protocol": "inspector",
"skipFiles": ["<node_internals>/**/*.js"]
},

Просмотреть файл

@ -1,25 +0,0 @@
{
"presets": [
[
"@babel/env",
{
"targets": {
"node": true
}
}
],
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
],
"sourceMaps": "inline",
"retainLines": true,
"env": {
"test": {
"plugins": ["dynamic-import-node"]
}
}
}

Просмотреть файл

@ -1,6 +1,9 @@
import type { InitialOptionsTsJest } from 'ts-jest/dist/types';
const ci = !!process.env.CI;
module.exports = {
const config: InitialOptionsTsJest = {
preset: 'ts-jest',
cacheDirectory: '.cache/jest',
coverageDirectory: './coverage',
collectCoverage: true,
@ -14,7 +17,7 @@ module.exports = {
: ['html', 'text-summary'],
coverageThreshold: {
global: {
branches: 96,
branches: 94.19,
functions: 100,
lines: 100,
statements: 100,
@ -25,7 +28,11 @@ module.exports = {
snapshotSerializers: ['<rootDir>/test/newline-snapshot-serializer.ts'],
testEnvironment: 'node',
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.(j|t)s$': 'babel-jest',
globals: {
'ts-jest': {
diagnostics: false,
},
},
};
export default config;

Просмотреть файл

@ -1,9 +1,20 @@
import fs from 'fs';
import { DirectoryResult, dir } from 'tmp-promise';
import upath from 'upath';
import customConfig from './config/__fixtures__/file';
import * as file from './file';
describe('config/file', () => {
let tmp: DirectoryResult;
beforeAll(async () => {
tmp = await dir({ unsafeCleanup: true });
});
afterAll(async () => {
await tmp.cleanup();
});
describe('.getConfig()', () => {
it('returns empty env', () => {
expect(file.getConfig({ RENOVATE_CONFIG_FILE: 'dummylocation' })).toEqual(
@ -29,10 +40,7 @@ describe('config/file', () => {
expect(res.rangeStrategy).toEqual('bump');
});
it('informs user when error in parsing config.js', () => {
const configFile = upath.resolve(
__dirname,
'./config/__fixtures__/file3.ts'
);
const configFile = upath.resolve(tmp.path, './file3.js');
const fileContent = `module.exports = {
"platform": "github",
"token":"abcdef",
@ -52,10 +60,7 @@ describe('config/file', () => {
});
});
it('handles when invalid file location is provided', () => {
const configFile = upath.resolve(
__dirname,
'./config/__fixtures__/file4.ts'
);
const configFile = upath.resolve(tmp.path, './file4.js');
expect(file.getConfig({ RENOVATE_CONFIG_FILE: configFile })).toStrictEqual(
{}
);

Просмотреть файл

@ -28,6 +28,9 @@ describe(getName(__filename), () => {
if (!module.extractPackageFile && !module.extractAllPackageFiles) {
return false;
}
if (Object.values(module).some((v) => v === undefined)) {
return false;
}
return true;
}
const mgrs = manager.getManagers();

Просмотреть файл

@ -668,21 +668,25 @@ export function massageMarkdown(input: string): string {
.replace('</details>', '');
}
export /* istanbul ignore next */ function findIssue(): Promise<Issue | null> {
/* istanbul ignore next */
export function findIssue(): Promise<Issue | null> {
logger.warn(`findIssue() is not implemented`);
return null;
}
export /* istanbul ignore next */ function ensureIssue(): Promise<EnsureIssueResult | null> {
/* istanbul ignore next */
export function ensureIssue(): Promise<EnsureIssueResult | null> {
logger.warn(`ensureIssue() is not implemented`);
return Promise.resolve(null);
}
export /* istanbul ignore next */ function ensureIssueClosing(): Promise<void> {
/* istanbul ignore next */
export function ensureIssueClosing(): Promise<void> {
return Promise.resolve();
}
export /* istanbul ignore next */ function getIssueList(): Promise<Issue[]> {
/* istanbul ignore next */
export function getIssueList(): Promise<Issue[]> {
logger.debug(`getIssueList()`);
// TODO: Needs implementation
return Promise.resolve([]);
@ -779,7 +783,7 @@ export async function addReviewers(
);
}
export /* istanbul ignore next */ async function deleteLabel(
export async function deleteLabel(
prNumber: number,
label: string
): Promise<void> {

Просмотреть файл

@ -40,7 +40,7 @@ import {
VulnerabilityAlert,
} from '../common';
import { smartTruncate } from '../utils/pr-body';
import {
import type {
BbsConfig,
BbsPr,
BbsRestBranch,
@ -527,17 +527,8 @@ export async function setBranchStatus({
// Issue
// function getIssueList() {
// logger.debug(`getIssueList()`);
// // TODO: Needs implementation
// // This is used by Renovate when creating its own issues, e.g. for deprecated package warnings, config error notifications, or "dependencyDashboard"
// // BB Server doesnt have issues
// return [];
// }
export /* istanbul ignore next */ function findIssue(
title: string
): Promise<Issue | null> {
/* istanbul ignore next */
export function findIssue(title: string): Promise<Issue | null> {
logger.debug(`findIssue(${title})`);
// TODO: Needs implementation
// This is used by Renovate when creating its own issues, e.g. for deprecated package warnings, config error notifications, or "dependencyDashboard"
@ -545,7 +536,8 @@ export /* istanbul ignore next */ function findIssue(
return null;
}
export /* istanbul ignore next */ function ensureIssue({
/* istanbul ignore next */
export function ensureIssue({
title,
}: EnsureIssueConfig): Promise<EnsureIssueResult | null> {
logger.warn({ title }, 'Cannot ensure issue');
@ -555,15 +547,15 @@ export /* istanbul ignore next */ function ensureIssue({
return null;
}
export /* istanbul ignore next */ function getIssueList(): Promise<Issue[]> {
/* istanbul ignore next */
export function getIssueList(): Promise<Issue[]> {
logger.debug(`getIssueList()`);
// TODO: Needs implementation
return Promise.resolve([]);
}
export /* istanbul ignore next */ function ensureIssueClosing(
title: string
): Promise<void> {
/* istanbul ignore next */
export function ensureIssueClosing(title: string): Promise<void> {
logger.debug(`ensureIssueClosing(${title})`);
// TODO: Needs implementation
// This is used by Renovate when creating its own issues, e.g. for deprecated package warnings, config error notifications, or "dependencyDashboard"

Просмотреть файл

@ -19,11 +19,7 @@ export interface BbsPr extends Pr {
version?: number;
}
export enum BbsRestPrState {
Declined = 'DECLINED',
Open = 'OPEN',
Merged = 'MERGED',
}
export type BbsRestPrState = 'DECLINED' | 'OPEN' | 'MERGED';
export interface BbsRestBranchRef {
displayId: string;

Просмотреть файл

@ -4,7 +4,7 @@ import { HTTPError, Response } from 'got';
import { PrState } from '../../types';
import { HttpOptions, HttpPostOptions, HttpResponse } from '../../util/http';
import { BitbucketServerHttp } from '../../util/http/bitbucket-server';
import { BbsPr, BbsRestPr } from './types';
import type { BbsPr, BbsRestPr } from './types';
const BITBUCKET_INVALID_REVIEWERS_EXCEPTION =
'com.atlassian.bitbucket.pull.InvalidPullRequestReviewersException';

Просмотреть файл

@ -806,6 +806,95 @@ Array [
]
`;
exports[`platform/bitbucket getIssueList() does not throw 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"authorization": "Basic YWJjOjEyMw==",
"host": "api.bitbucket.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"authorization": "Basic YWJjOjEyMw==",
"host": "api.bitbucket.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo/issues?q=(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22",
},
]
`;
exports[`platform/bitbucket getIssueList() get issues 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"authorization": "Basic YWJjOjEyMw==",
"host": "api.bitbucket.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"authorization": "Basic YWJjOjEyMw==",
"host": "api.bitbucket.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo/issues?q=(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22",
},
]
`;
exports[`platform/bitbucket getIssueList() get issues 2`] = `
Array [
Object {
"content": Object {
"raw": "content",
},
"id": 25,
"title": "title",
},
Object {
"content": Object {
"raw": "content",
},
"id": 26,
"title": "title",
},
]
`;
exports[`platform/bitbucket getIssueList() has no issues 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"authorization": "Basic YWJjOjEyMw==",
"host": "api.bitbucket.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo",
},
]
`;
exports[`platform/bitbucket getJsonFile() returns file content 1`] = `
Array [
Object {
@ -1040,8 +1129,6 @@ Array [
]
`;
exports[`platform/bitbucket massageMarkdown() returns diff files 1`] = `"**foo**bartext"`;
exports[`platform/bitbucket getPrList() filters PR list by author 1`] = `
Array [
Object {
@ -1139,6 +1226,8 @@ Array [
]
`;
exports[`platform/bitbucket massageMarkdown() returns diff files 1`] = `"**foo**bartext"`;
exports[`platform/bitbucket mergePr() posts Merge 1`] = `
Array [
Object {

Просмотреть файл

@ -549,6 +549,52 @@ describe('platform/bitbucket', () => {
});
});
describe('getIssueList()', () => {
it('has no issues', async () => {
await initRepoMock();
await bitbucket.getIssueList();
expect(httpMock.getTrace()).toMatchSnapshot();
});
it('get issues', async () => {
const scope = await initRepoMock({}, { has_issues: true });
scope
.get('/2.0/repositories/some/repo/issues')
.query({
q: '(state = "new" OR state = "open") AND reporter.username="abc"',
})
.reply(200, {
values: [
{
id: 25,
title: 'title',
content: { raw: 'content' },
},
{
id: 26,
title: 'title',
content: { raw: 'content' },
},
],
});
const issues = await bitbucket.getIssueList();
expect(httpMock.getTrace()).toMatchSnapshot();
expect(issues).toHaveLength(2);
expect(issues).toMatchSnapshot();
});
it('does not throw', async () => {
const scope = await initRepoMock({}, { has_issues: true });
scope
.get('/2.0/repositories/some/repo/issues')
.query({
q: '(state = "new" OR state = "open") AND reporter.username="abc"',
})
.reply(500, {});
const issues = await bitbucket.getIssueList();
expect(httpMock.getTrace()).toMatchSnapshot();
expect(issues).toHaveLength(0);
});
});
describe('addAssignees()', () => {
it('does not throw', async () => {
expect(await bitbucket.addAssignees(3, ['some'])).toMatchSnapshot();

Просмотреть файл

@ -546,12 +546,10 @@ export async function ensureIssue({
return null;
}
export /* istanbul ignore next */ async function getIssueList(): Promise<
Issue[]
> {
/* istanbul ignore next */
export async function getIssueList(): Promise<Issue[]> {
logger.debug(`getIssueList()`);
/* istanbul ignore if */
if (!config.has_issues) {
logger.debug('Issues are disabled - cannot getIssueList');
return [];
@ -568,9 +566,9 @@ export /* istanbul ignore next */ async function getIssueList(): Promise<
await bitbucketHttp.getJson<{ values: Issue[] }>(
`/2.0/repositories/${config.repository}/issues?q=${filter}`
)
).body.values || /* istanbul ignore next */ []
).body.values || []
);
} catch (err) /* istanbul ignore next */ {
} catch (err) {
logger.warn({ err }, 'Error finding issues');
return [];
}
@ -619,7 +617,8 @@ export async function addReviewers(
);
}
export /* istanbul ignore next */ function deleteLabel(): never {
/* istanbul ignore next */
export function deleteLabel(): never {
throw new Error('deleteLabel not implemented');
}

Просмотреть файл

@ -7,11 +7,16 @@ const range = (count: number) => [...Array(count).keys()];
const baseUrl = 'https://api.bitbucket.org';
describe('accumulateValues()', () => {
it('paginates', async () => {
httpMock.reset();
beforeEach(() => {
httpMock.setup();
setBaseUrl(baseUrl);
});
afterEach(() => {
httpMock.reset();
});
it('paginates', async () => {
httpMock
.scope(baseUrl)
.get('/some-url?pagelen=10')
@ -35,6 +40,11 @@ describe('accumulateValues()', () => {
expect(res).toHaveLength(25);
expect(httpMock.getTrace()).toHaveLength(3);
expect(httpMock.getTrace()).toMatchSnapshot();
httpMock.reset();
});
it('isConflicted', () => {
expect(
utils.isConflicted([{ chunks: [{ changes: [{ content: '+=======' }] }] }])
).toBe(true);
});
});

Просмотреть файл

@ -132,9 +132,7 @@ interface Files {
}[];
}
export /* istanbul ignore next */ function isConflicted(
files: Files[]
): boolean {
export function isConflicted(files: Files[]): boolean {
for (const file of files) {
for (const chunk of file.chunks) {
for (const change of chunk.changes) {

Просмотреть файл

@ -8,6 +8,7 @@ describe(getName(__filename), () => {
const div = body.childNodes[0] as HTMLElement;
expect(div.tagName).toBe('DIV');
expect(div.textContent).toBe('Hello, world!');
expect(div instanceof HTMLElement).toBe(true);
});
it('returns empty', () => {
const body = parse('');

Просмотреть файл

@ -4,7 +4,7 @@ import {
parseRange,
rangeToStr,
} from './compare';
import maven from '.';
import maven, { isValid as _isValid } from '.';
const {
isValid,
@ -290,6 +290,7 @@ describe('versioning/maven/index', () => {
expect(isValid('1.0.0')).toBe(true);
expect(isValid('[1.12.6,1.18.6]')).toBe(true);
expect(isValid(undefined)).toBe(false);
expect(isValid === _isValid).toBe(true);
});
it('validates version string', () => {
expect(isVersion('')).toBe(false);

Просмотреть файл

@ -1,5 +1,5 @@
import { DateTime } from 'luxon';
import { isStable, api as nodever } from '.';
import { isStable, isValid, api as nodever } from '.';
describe('semver.getNewValue()', () => {
let dtLocal: any;
@ -54,4 +54,8 @@ describe('semver.getNewValue()', () => {
expect(isStable(version as string)).toBe(result);
});
});
it('isValid', () => {
expect(isValid === nodever.isValid).toBe(true);
});
});

Просмотреть файл

@ -12,11 +12,11 @@
"clean-cache": "node bin/clean-cache.js",
"compile:ts": "tsc -p tsconfig.app.json",
"compile:dts": "tsc -p tsconfig.dts.json",
"config-validator": "babel-node --extensions \".ts,.js\" -- lib/config-validator.ts",
"config-validator": "node -r ts-node/register/transpile-only -- lib/config-validator.ts",
"generate": "run-s generate:*",
"generate:imports": "node tmp/tools/generate-imports.js",
"create-json-schema": "babel-node --extensions \".ts,.js\" -- bin/create-json-schema.js && prettier --write \"renovate-schema.json\"",
"debug": "babel-node --inspect-brk --extensions \".ts,.js\" -- lib/renovate.ts",
"create-json-schema": "node -r ts-node/register/transpile-only -- bin/create-json-schema.js && prettier --write \"renovate-schema.json\"",
"debug": "node --inspect-brk -r ts-node/register/transpile-only -- lib/renovate.ts",
"eslint": "eslint --ext .js,.mjs,.ts lib/ test/ tools/",
"eslint-fix": "eslint --ext .js,.mjs,.ts --fix lib/ test/ tools/",
"jest": "cross-env NODE_ENV=test LOG_LEVEL=fatal node --expose-gc node_modules/jest/bin/jest.js",
@ -34,10 +34,10 @@
"prettier": "prettier --check \"**/*.{ts,js,mjs,json,md}\"",
"prettier-fix": "prettier --write \"**/*.{ts,js,mjs,json,md}\"",
"release": "node --experimental-modules tools/release.mjs",
"start": "babel-node --extensions \".ts,.js\" -- lib/renovate.ts",
"start": "node -r ts-node/register/transpile-only -- lib/renovate.ts",
"test-dirty": "git diff --exit-code",
"test-e2e": "npm pack && cd test/e2e && yarn install --no-lockfile --ignore-optional --prod && yarn test",
"test-schema": "babel-node --extensions \".ts,.js\" -- test/json-schema.ts",
"test-schema": "node -r ts-node/register/transpile-only -- test/json-schema.ts",
"test": "run-s lint test-schema type-check jest",
"tsc": "tsc",
"type-check": "run-s generate:* \"tsc --noEmit {@}\"",
@ -186,14 +186,6 @@
},
"devDependencies": {
"@actions/core": "1.2.6",
"@babel/cli": "7.13.0",
"@babel/core": "7.13.8",
"@babel/node": "7.13.0",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-proposal-object-rest-spread": "7.13.8",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/preset-env": "7.13.9",
"@babel/preset-typescript": "7.13.0",
"@jest/globals": "26.6.2",
"@jest/reporters": "26.6.2",
"@jest/test-result": "26.6.2",
@ -232,8 +224,6 @@
"@types/xmldoc": "1.1.5",
"@typescript-eslint/eslint-plugin": "4.16.1",
"@typescript-eslint/parser": "4.16.1",
"babel-jest": "26.6.3",
"babel-plugin-dynamic-import-node": "2.3.3",
"conventional-changelog-conventionalcommits": "4.5.0",
"cross-env": "7.0.3",
"eslint": "7.21.0",
@ -261,6 +251,8 @@
"shelljs": "0.8.4",
"strip-ansi": "6.0.0",
"tmp-promise": "3.0.2",
"ts-jest": "26.5.2",
"ts-node": "9.1.1",
"type-fest": "0.21.2",
"typescript": "4.2.2"
},

Просмотреть файл

@ -17,6 +17,7 @@
"**/__fixtures__/**",
"**/__testutil__/**",
"**/*.spec.ts",
"jest.config.ts",
"./test",
"./tools"
]

1211
yarn.lock

Разница между файлами не показана из-за своего большого размера Загрузить разницу