build(docs-infra): upgrade all JS dependencies to latest versions (#36837)
This commit upgrades all dependencies in `scripts-js/` to latest versions and also includes all necessary code changes to ensure the tests are passing with the new dependency versions. PR Close #36837
This commit is contained in:
parent
333abf16e4
commit
eef01160f4
|
@ -1,5 +1,4 @@
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import {promisify} from 'util';
|
|
||||||
import {PreviewServerError} from './preview-error';
|
import {PreviewServerError} from './preview-error';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +12,7 @@ export async function respondWithError(res: express.Response, err: any): Promise
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(err.status);
|
res.status(err.status);
|
||||||
await promisify(res.end.bind(res))(err.message);
|
return new Promise(resolve => res.end(err.message, resolve));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,7 +93,7 @@ class Helper {
|
||||||
return fs.readFileSync(absFilePath, 'utf8');
|
return fs.readFileSync(absFilePath, 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
public runCmd(cmd: string, opts: cp.ExecFileOptions = {}): Promise<CmdResult> {
|
public runCmd(cmd: string, opts: cp.ExecOptions = {}): Promise<CmdResult> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const proc = cp.exec(cmd, opts, (err, stdout, stderr) => resolve({success: !err, err, stdout, stderr}));
|
const proc = cp.exec(cmd, opts, (err, stdout, stderr) => resolve({success: !err, err, stdout, stderr}));
|
||||||
this.createCleanUpFn(() => proc.kill());
|
this.createCleanUpFn(() => proc.kill());
|
||||||
|
|
|
@ -25,31 +25,31 @@
|
||||||
"~~test-watch": "nodemon --delay 1 --exec \"yarn ~~test-only\" --watch dist"
|
"~~test-watch": "nodemon --delay 1 --exec \"yarn ~~test-only\" --watch dist"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.18.3",
|
"body-parser": "^1.19.0",
|
||||||
"delete-empty": "^2.0.0",
|
"delete-empty": "^3.0.0",
|
||||||
"express": "^4.16.3",
|
"express": "^4.17.1",
|
||||||
"jasmine": "^3.2.0",
|
"jasmine": "^3.5.0",
|
||||||
"nock": "^9.6.1",
|
"nock": "^12.0.3",
|
||||||
"node-fetch": "^2.2.0",
|
"node-fetch": "^2.6.0",
|
||||||
"shelljs": "^0.8.2",
|
"shelljs": "^0.8.4",
|
||||||
"source-map-support": "^0.5.9",
|
"source-map-support": "^0.5.19",
|
||||||
"tar-stream": "^1.6.1",
|
"tar-stream": "^2.1.2",
|
||||||
"tslib": "^1.10.0"
|
"tslib": "^1.11.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/body-parser": "^1.17.0",
|
"@types/body-parser": "^1.19.0",
|
||||||
"@types/express": "^4.16.0",
|
"@types/express": "^4.17.6",
|
||||||
"@types/jasmine": "^2.8.8",
|
"@types/jasmine": "^3.5.10",
|
||||||
"@types/nock": "^9.3.0",
|
"@types/nock": "^11.1.0",
|
||||||
"@types/node": "^10.9.2",
|
"@types/node": "^13.13.2",
|
||||||
"@types/node-fetch": "^2.1.2",
|
"@types/node-fetch": "^2.5.7",
|
||||||
"@types/shelljs": "^0.8.0",
|
"@types/shelljs": "^0.8.7",
|
||||||
"@types/supertest": "^2.0.5",
|
"@types/supertest": "^2.0.8",
|
||||||
"nodemon": "^1.18.3",
|
"nodemon": "^2.0.3",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"supertest": "^3.1.0",
|
"supertest": "^4.0.2",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.1.1",
|
||||||
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
|
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
|
||||||
"typescript": "^3.0.1"
|
"typescript": "^3.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,9 @@ describe('BuildCleaner', () => {
|
||||||
let promise: Promise<number[]>;
|
let promise: Promise<number[]>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake((_: string, cb: typeof readdirCb) => readdirCb = cb);
|
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake(
|
||||||
|
((_: string, cb: typeof readdirCb) => readdirCb = cb) as unknown as typeof fs.readdir,
|
||||||
|
);
|
||||||
promise = cleaner.getExistingBuildNumbers();
|
promise = cleaner.getExistingBuildNumbers();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -304,7 +306,9 @@ describe('BuildCleaner', () => {
|
||||||
let promise: Promise<string[]>;
|
let promise: Promise<string[]>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake((_: string, cb: typeof readdirCb) => readdirCb = cb);
|
fsReaddirSpy = spyOn(fs, 'readdir').and.callFake(
|
||||||
|
((_: string, cb: typeof readdirCb) => readdirCb = cb) as unknown as typeof fs.readdir,
|
||||||
|
);
|
||||||
promise = cleaner.getExistingDownloads();
|
promise = cleaner.getExistingDownloads();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ describe('GithubApi', () => {
|
||||||
|
|
||||||
describe('request()', () => {
|
describe('request()', () => {
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
nock('https://api.github.com').get('').reply(200);
|
nock('https://api.github.com').get('/').reply(200);
|
||||||
expect((api as any).request()).toEqual(jasmine.any(Promise));
|
expect((api as any).request()).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Imports
|
// Imports
|
||||||
import {GithubApi} from '../../lib/common/github-api';
|
import {GithubApi} from '../../lib/common/github-api';
|
||||||
import {GithubPullRequests} from '../../lib/common/github-pull-requests';
|
import {GithubPullRequests, PullRequest} from '../../lib/common/github-pull-requests';
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('GithubPullRequests', () => {
|
describe('GithubPullRequests', () => {
|
||||||
|
@ -47,7 +47,7 @@ describe('GithubPullRequests', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should make a POST request to Github with the correct pathname, params and data', () => {
|
it('should make a POST request to Github with the correct pathname, params and data', () => {
|
||||||
githubApi.post.and.callFake(() => Promise.resolve());
|
githubApi.post.and.resolveTo();
|
||||||
prs.addComment(42, 'body');
|
prs.addComment(42, 'body');
|
||||||
expect(githubApi.post).toHaveBeenCalledWith('/repos/foo/bar/issues/42/comments', null, {body: 'body'});
|
expect(githubApi.post).toHaveBeenCalledWith('/repos/foo/bar/issues/42/comments', null, {body: 'body'});
|
||||||
});
|
});
|
||||||
|
@ -63,7 +63,7 @@ describe('GithubPullRequests', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with the data from the Github POST', done => {
|
it('should resolve with the data from the Github POST', done => {
|
||||||
githubApi.post.and.callFake(() => Promise.resolve('Test'));
|
githubApi.post.and.resolveTo('Test');
|
||||||
prs.addComment(42, 'body').then(data => {
|
prs.addComment(42, 'body').then(data => {
|
||||||
expect(data).toBe('Test');
|
expect(data).toBe('Test');
|
||||||
done();
|
done();
|
||||||
|
@ -125,9 +125,14 @@ describe('GithubPullRequests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should forward the value returned by \'getPaginated()\'', () => {
|
it('should forward the value returned by \'getPaginated()\'', async () => {
|
||||||
githubApi.getPaginated.and.returnValue('Test');
|
const mockPrs: PullRequest[] = [
|
||||||
expect(prs.fetchAll() as any).toBe('Test');
|
{number: 1, user: {login: 'foo'}, labels: []},
|
||||||
|
{number: 2, user: {login: 'bar'}, labels: []},
|
||||||
|
];
|
||||||
|
|
||||||
|
githubApi.getPaginated.and.resolveTo(mockPrs);
|
||||||
|
expect(await prs.fetchAll()).toBe(mockPrs);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {GithubApi} from '../../lib/common/github-api';
|
import {GithubApi} from '../../lib/common/github-api';
|
||||||
import {GithubTeams} from '../../lib/common/github-teams';
|
import {GithubTeams, Team} from '../../lib/common/github-teams';
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('GithubTeams', () => {
|
describe('GithubTeams', () => {
|
||||||
|
@ -33,9 +33,14 @@ describe('GithubTeams', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should forward the value returned by \'getPaginated()\'', () => {
|
it('should forward the value returned by \'getPaginated()\'', async () => {
|
||||||
githubApi.getPaginated.and.returnValue('Test');
|
const mockTeams: Team[] = [
|
||||||
expect(teams.fetchAll() as any).toBe('Test');
|
{id: 1, slug: 'foo'},
|
||||||
|
{id: 2, slug: 'bar'},
|
||||||
|
];
|
||||||
|
|
||||||
|
githubApi.getPaginated.and.resolveTo(mockTeams);
|
||||||
|
expect(await teams.fetchAll()).toBe(mockTeams);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -50,7 +55,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', () => {
|
||||||
githubApi.get.and.callFake(() => Promise.resolve());
|
githubApi.get.and.resolveTo();
|
||||||
const promise = teams.isMemberById('user', [1]);
|
const promise = teams.isMemberById('user', [1]);
|
||||||
expect(promise).toEqual(jasmine.any(Promise));
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
@ -66,7 +71,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should call \'get()\' with the correct pathname', done => {
|
it('should call \'get()\' with the correct pathname', done => {
|
||||||
githubApi.get.and.callFake(() => Promise.resolve());
|
githubApi.get.and.resolveTo();
|
||||||
teams.isMemberById('user', [1]).then(() => {
|
teams.isMemberById('user', [1]).then(() => {
|
||||||
expect(githubApi.get).toHaveBeenCalledWith('/teams/1/memberships/user');
|
expect(githubApi.get).toHaveBeenCalledWith('/teams/1/memberships/user');
|
||||||
done();
|
done();
|
||||||
|
@ -85,7 +90,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if the membership is not active', done => {
|
it('should resolve with false if the membership is not active', done => {
|
||||||
githubApi.get.and.callFake(() => Promise.resolve({state: 'pending'}));
|
githubApi.get.and.resolveTo({state: 'pending'});
|
||||||
teams.isMemberById('user', [1]).then(isMember => {
|
teams.isMemberById('user', [1]).then(isMember => {
|
||||||
expect(isMember).toBe(false);
|
expect(isMember).toBe(false);
|
||||||
expect(githubApi.get).toHaveBeenCalled();
|
expect(githubApi.get).toHaveBeenCalled();
|
||||||
|
@ -95,7 +100,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with true if the membership is active', done => {
|
it('should resolve with true if the membership is active', done => {
|
||||||
githubApi.get.and.callFake(() => Promise.resolve({state: 'active'}));
|
githubApi.get.and.resolveTo({state: 'active'});
|
||||||
teams.isMemberById('user', [1]).then(isMember => {
|
teams.isMemberById('user', [1]).then(isMember => {
|
||||||
expect(isMember).toBe(true);
|
expect(isMember).toBe(true);
|
||||||
done();
|
done();
|
||||||
|
@ -104,7 +109,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should sequentially call \'get()\' until an active membership is found', done => {
|
it('should sequentially call \'get()\' until an active membership is found', done => {
|
||||||
const trainedResponses: {[pathname: string]: Promise<{state: string}>} = {
|
const trainedResponses: {[pathname: string]: Promise<any>} = {
|
||||||
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
|
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
|
||||||
'/teams/2/memberships/user': Promise.reject(null),
|
'/teams/2/memberships/user': Promise.reject(null),
|
||||||
'/teams/3/memberships/user': Promise.resolve({state: 'active'}),
|
'/teams/3/memberships/user': Promise.resolve({state: 'active'}),
|
||||||
|
@ -125,7 +130,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should resolve with false if no active membership is found', done => {
|
it('should resolve with false if no active membership is found', done => {
|
||||||
const trainedResponses: {[pathname: string]: Promise<{state: string}>} = {
|
const trainedResponses: {[pathname: string]: Promise<any>} = {
|
||||||
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
|
'/teams/1/memberships/user': Promise.resolve({state: 'pending'}),
|
||||||
'/teams/2/memberships/user': Promise.reject(null),
|
'/teams/2/memberships/user': Promise.reject(null),
|
||||||
'/teams/3/memberships/user': Promise.resolve({state: 'not active'}),
|
'/teams/3/memberships/user': Promise.resolve({state: 'not active'}),
|
||||||
|
|
|
@ -443,7 +443,9 @@ describe('BuildCreator', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fsAccessCbs = [];
|
fsAccessCbs = [];
|
||||||
fsAccessSpy = spyOn(fs, 'access').and.callFake((_: string, cb: (v?: any) => void) => fsAccessCbs.push(cb));
|
fsAccessSpy = spyOn(fs, 'access').and.callFake(
|
||||||
|
((_: string, cb: (v?: any) => void) => fsAccessCbs.push(cb)) as unknown as typeof fs.access,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -495,7 +497,10 @@ describe('BuildCreator', () => {
|
||||||
consoleWarnSpy = spyOn(Logger.prototype, 'warn');
|
consoleWarnSpy = spyOn(Logger.prototype, 'warn');
|
||||||
shellChmodSpy = spyOn(shell, 'chmod');
|
shellChmodSpy = spyOn(shell, 'chmod');
|
||||||
shellRmSpy = spyOn(shell, 'rm');
|
shellRmSpy = spyOn(shell, 'rm');
|
||||||
cpExecSpy = spyOn(cp, 'exec').and.callFake((_: string, cb: (...args: any[]) => void) => cpExecCbs.push(cb));
|
cpExecSpy = spyOn(cp, 'exec').and.callFake(
|
||||||
|
((_: string, cb: (...args: any[]) => void) =>
|
||||||
|
cpExecCbs.push(cb)) as unknown as typeof cp.exec,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -600,7 +605,7 @@ describe('BuildCreator', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
shellLsSpy = spyOn(shell, 'ls').and.returnValue([]);
|
shellLsSpy = spyOn(shell, 'ls').and.returnValue([] as unknown as shell.ShellArray);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,13 @@ describe('BuildRetriever', () => {
|
||||||
|
|
||||||
WRITEFILE_RESULT = undefined;
|
WRITEFILE_RESULT = undefined;
|
||||||
writeFileSpy = spyOn(fs, 'writeFile').and.callFake(
|
writeFileSpy = spyOn(fs, 'writeFile').and.callFake(
|
||||||
(_path: string, _buffer: Buffer, callback: (err?: any) => {}) => callback(WRITEFILE_RESULT),
|
((_path: string, _buffer: Buffer, callback: fs.NoParamCallback) =>
|
||||||
|
callback(WRITEFILE_RESULT)) as typeof fs.writeFile,
|
||||||
);
|
);
|
||||||
|
|
||||||
EXISTS_RESULT = false;
|
EXISTS_RESULT = false;
|
||||||
existsSpy = spyOn(fs, 'exists').and.callFake(
|
existsSpy = spyOn(fs, 'exists').and.callFake(
|
||||||
(_path: string, callback: (exists: boolean) => {}) => callback(EXISTS_RESULT),
|
((_path, callback) => callback(EXISTS_RESULT)) as typeof fs.exists,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,10 @@ describe('BuildVerifier', () => {
|
||||||
describe('getSignificantFilesChanged', () => {
|
describe('getSignificantFilesChanged', () => {
|
||||||
it('should return false if none of the fetched files match the given pattern', async () => {
|
it('should return false if none of the fetched files match the given pattern', async () => {
|
||||||
const fetchFilesSpy = spyOn(prs, 'fetchFiles');
|
const fetchFilesSpy = spyOn(prs, 'fetchFiles');
|
||||||
fetchFilesSpy.and.callFake(() => Promise.resolve([{filename: 'a/b/c'}, {filename: 'd/e/f'}]));
|
fetchFilesSpy.and.callFake(() => Promise.resolve([
|
||||||
|
{filename: 'a/b/c', sha: 'a1'},
|
||||||
|
{filename: 'd/e/f', sha: 'b2'},
|
||||||
|
]));
|
||||||
expect(await bv.getSignificantFilesChanged(777, /^x/)).toEqual(false);
|
expect(await bv.getSignificantFilesChanged(777, /^x/)).toEqual(false);
|
||||||
expect(fetchFilesSpy).toHaveBeenCalledWith(777);
|
expect(fetchFilesSpy).toHaveBeenCalledWith(777);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Imports
|
// Imports
|
||||||
import * as express from 'express';
|
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as supertest from 'supertest';
|
import * as supertest from 'supertest';
|
||||||
import {CircleCiApi} from '../../lib/common/circle-ci-api';
|
import {CircleCiApi} from '../../lib/common/circle-ci-api';
|
||||||
|
@ -134,7 +133,7 @@ describe('PreviewServerFactory', () => {
|
||||||
const buildCreator = jasmine.any(BuildCreator);
|
const buildCreator = jasmine.any(BuildCreator);
|
||||||
expect(usfCreateMiddlewareSpy).toHaveBeenCalledWith(buildRetriever, buildVerifier, buildCreator, defaultConfig);
|
expect(usfCreateMiddlewareSpy).toHaveBeenCalledWith(buildRetriever, buildVerifier, buildCreator, defaultConfig);
|
||||||
|
|
||||||
const middleware: express.Express = usfCreateMiddlewareSpy.calls.mostRecent().returnValue;
|
const middleware = usfCreateMiddlewareSpy.calls.mostRecent().returnValue;
|
||||||
expect(httpCreateServerSpy).toHaveBeenCalledWith(middleware);
|
expect(httpCreateServerSpy).toHaveBeenCalledWith(middleware);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue