From 777834e7fa05108e5ce0f0c2db9dfac090d111a5 Mon Sep 17 00:00:00 2001 From: Mykhailo Stadnyk Date: Tue, 17 Mar 2020 13:15:29 +0200 Subject: [PATCH] chore: security deps update --- package.json | 50 +++++++++++++++++++--------------------- src/TravisClient.ts | 5 ++-- test/src/TravisClient.ts | 17 +++++++++----- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index bcf501c..6d25a90 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "build": "tsc", "mocha": "nyc mocha", "cover": "nyc report --reporter=text-lcov | coveralls", - "show:test": "/usr/bin/env node -e \"require('opn')('file://`pwd`/coverage/index.html',{wait:false});\"", - "show:doc": "/usr/bin/env node -e \"require('opn')('file://`pwd`/docs/index.html',{wait:false});\"", + "show:test": "/usr/bin/env node -e \"require('open')('file://`pwd`/coverage/index.html',{wait:false});\"", + "show:doc": "/usr/bin/env node -e \"require('open')('file://`pwd`/docs/index.html',{wait:false});\"", "test": "npm run build && npm run mocha ; npm run show:test ; npm run cover", "clean:dts": "find . -name '*.d.ts' -not -wholename '*node_modules*' -type f -delete", "clean:map": "find . -name '*.js.map' -not -wholename '*node_modules*' -type f -delete", @@ -38,36 +38,34 @@ "author": "imqueue.com (https://imqueue.com)", "license": "ISC", "dependencies": { - "@types/request": "^2.47.0", - "request": "^2.87.0" + "@types/request": "^2.48.4", + "request": "^2.88.2" }, "preferGlobal": true, "devDependencies": { - "@types/chai": "^4.1.4", - "@types/chai-as-promised": "^7.1.0", - "@types/chalk": "^2.2.0", - "@types/dotenv": "^4.0.3", - "@types/mocha": "^5.2.2", + "@types/chai": "^4.2.11", + "@types/chai-as-promised": "^7.1.2", + "@types/mocha": "^7.0.2", "@types/mock-require": "^2.0.0", - "@types/node": "^10.3.3", - "@types/sinon": "^5.0.1", - "@types/yargs": "^11.0.0", - "chai": "^4.1.2", + "@types/node": "^13.9.1", + "@types/sinon": "^7.5.2", + "@types/yargs": "^15.0.4", + "chai": "^4.2.0", "chai-as-promised": "^7.1.1", - "codeclimate-test-reporter": "^0.5.0", - "coveralls": "^3.0.0", - "dotenv": "^6.0.0", - "mocha": "^5.2.0", + "codeclimate-test-reporter": "^0.5.1", + "coveralls": "^3.0.9", + "dotenv": "^8.2.0", + "mocha": "^7.1.0", "mocha-lcov-reporter": "^1.3.0", - "mock-require": "^3.0.1", - "nyc": "^12.0.2", - "opn": "^5.2.0", - "reflect-metadata": "^0.1.12", - "sinon": "^6.0.0", - "source-map-support": "^0.5.6", - "ts-node": "^6.1.1", - "typedoc": "^0.11.1", - "typescript": "^2.9.2" + "mock-require": "^3.0.3", + "nyc": "^15.0.0", + "open": "^7.0.3", + "reflect-metadata": "^0.1.13", + "sinon": "^9.0.1", + "source-map-support": "^0.5.16", + "ts-node": "^8.6.2", + "typedoc": "^0.17.0", + "typescript": "^3.8.3" }, "main": "index.js", "bin": { diff --git a/src/TravisClient.ts b/src/TravisClient.ts index a8698e4..171f837 100644 --- a/src/TravisClient.ts +++ b/src/TravisClient.ts @@ -110,6 +110,7 @@ function buildUrl( * @returns {TravisRoutesDescription} */ function buildRoutes(api: any): TravisRoutesDescription { + // noinspection TypeScriptUnresolvedVariable return api.map((section: any) => section.routes) .reduce((curr: any[], next: any[]) => curr.concat(next), []) .map((route: any) => { @@ -289,7 +290,7 @@ async function authenticateGithubToken(msg: TravisAuthMessage) { } return await authenticateAccessToken.call(this, - await this.auth.github.post(msg) + await (this.auth as TravisClient).github.post(msg) ); } @@ -355,7 +356,7 @@ export class TravisClient implements FunctionObject { return await authenticateGithubToken.call(this, msg); } - throw new Error('Unexpected arguments!'); + throw new TypeError('Unexpected arguments!'); } /** diff --git a/test/src/TravisClient.ts b/test/src/TravisClient.ts index 50301f1..e4cbcd0 100644 --- a/test/src/TravisClient.ts +++ b/test/src/TravisClient.ts @@ -64,10 +64,12 @@ describe('TravisClient', function() { }); it('should throw if non-object argument given', () => { const travis: any = new TravisClient(); + // noinspection TypeScriptValidateJSTypes expect(travis.authenticate()).to.be.rejectedWith(TypeError); expect(travis.authenticate([])).to.be.rejectedWith(TypeError); expect(travis.authenticate('')).to.be.rejectedWith(TypeError); expect(travis.authenticate(()=>{})).to.be.rejectedWith(TypeError); + // noinspection TypeScriptValidateJSTypes expect(travis.authenticate(null)).to.be.rejectedWith(TypeError); expect(travis.authenticate(true)).to.be.rejectedWith(TypeError); expect(travis.authenticate(false)).to.be.rejectedWith(TypeError); @@ -136,6 +138,7 @@ describe('TravisClient', function() { it(`should expose calls chain`, () => { let context = travis; Object.keys(chain).forEach((name: string) => { + // noinspection JSIncompatibleTypesComparison if (chain[name] === null) { return; } @@ -153,6 +156,7 @@ describe('TravisClient', function() { it('should throw if invalid number of args given', () => { let context = travis; Object.keys(chain).forEach((name: string) => { + // noinspection JSIncompatibleTypesComparison if (chain[name] === null) { return; } @@ -173,10 +177,11 @@ describe('TravisClient', function() { let name = names[i]; const stub = sinon.stub(travis.agent, 'request') - .callsFake(() => {}); + .callsFake(async () => ({})); // fill chain while (context) { + // noinspection JSIncompatibleTypesComparison if (chain[name] === null) { break; } @@ -189,7 +194,7 @@ describe('TravisClient', function() { const callData = { fake: name }; - await context[name](callData); + await (context[name] as any)(callData); const [ callMethod, callUri ] = [ name.toUpperCase(), @@ -212,6 +217,7 @@ describe('TravisClient', function() { // fill chain while (context) { + // noinspection JSIncompatibleTypesComparison if (chain[name] === null) { break; } @@ -226,7 +232,7 @@ describe('TravisClient', function() { try { // it should normally process - await context[name](callData); + await (context[name] as any)(callData); } catch (err) { @@ -249,11 +255,10 @@ function toCamelCase(name: string): string { function getChains( version: string ): Array<{ uri: string, chain: { [name: string]: string[] }}> { + // noinspection TypeScriptUnresolvedVariable return require(`../../api/v${version}/routes.json`) .filter((section: any) => section.prefix !== '/error') - .map((section: { routes: { uri: string, verb: string}[] }) => - section.routes - ) + .map((section: any) => section.routes) .reduce((prev: any, next: any) => prev.concat(next), []) .map((route: { uri: string, verb: string }) => { const { uri, verb }: any = route;