Skip to content

Commit

Permalink
chore: security deps update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhus committed Mar 17, 2020
1 parent 414bef4 commit 777834e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
50 changes: 24 additions & 26 deletions package.json
Expand Up @@ -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",
Expand All @@ -38,36 +38,34 @@
"author": "imqueue.com <support@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": {
Expand Down
5 changes: 3 additions & 2 deletions src/TravisClient.ts
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
);
}

Expand Down Expand Up @@ -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!');
}

/**
Expand Down
17 changes: 11 additions & 6 deletions test/src/TravisClient.ts
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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(),
Expand All @@ -212,6 +217,7 @@ describe('TravisClient', function() {

// fill chain
while (context) {
// noinspection JSIncompatibleTypesComparison
if (chain[name] === null) {
break;
}
Expand All @@ -226,7 +232,7 @@ describe('TravisClient', function() {

try {
// it should normally process
await context[name](callData);
await (context[name] as any)(callData);
}

catch (err) {
Expand All @@ -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;
Expand Down

0 comments on commit 777834e

Please sign in to comment.