Skip to content

Commit

Permalink
chore(dep)!: upgrade gts 2.0.0 (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
summer-ji-eng committed Mar 23, 2020
1 parent f6434ab commit 4eaf9be
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
@@ -1,5 +1,5 @@
**/node_modules
src/**/doc/*
**/.coverage
build/
docs/
protos/
3 changes: 3 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
15 changes: 0 additions & 15 deletions .eslintrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 10, 12, 13]
node: [10, 12, 13]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
Expand Down
8 changes: 5 additions & 3 deletions .prettierignore
@@ -1,3 +1,5 @@
node_modules/*
samples/node_modules/*
src/**/doc/*
**/node_modules
**/.coverage
build/
docs/
protos/
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

17 changes: 17 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,17 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

module.exports = {
...require('gts/.prettierrc.json')
}
11 changes: 5 additions & 6 deletions package.json
Expand Up @@ -7,13 +7,12 @@
"repository": "googleapis/nodejs-paginator",
"scripts": {
"test": "c8 mocha build/test",
"lint": "gts check",
"clean": "gts clean",
"compile": "tsc -p .",
"fix": "gts fix",
"prelint": "cd samples; npm link ../; npm i",
"lint": "gts check",
"prepare": "npm run compile",
"pretest": "npm run compile",
"posttest": "npm run lint",
"docs": "compodoc src/",
"presystem-test": "npm run compile",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
Expand All @@ -36,11 +35,11 @@
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^7.0.0",
"@types/uuid": "^7.0.0",
"c8": "^7.0.0",
"codecov": "^3.0.4",
"gts": "^1.0.0",
"gts": "2.0.0-alpha.4",
"linkinator": "^2.0.0",
"mocha": "^7.0.0",
"c8": "^7.0.0",
"mocha": "^7.1.1",
"proxyquire": "^2.0.1",
"sinon": "^9.0.0",
"typescript": "^3.8.3",
Expand Down
2 changes: 1 addition & 1 deletion samples/package.json
Expand Up @@ -3,7 +3,7 @@
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
"node": ">=8"
"node": ">=10"
},
"repository": "googleapis/nodejs-paginator",
"private": true,
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Expand Up @@ -91,7 +91,7 @@ export class Paginator {
Class.prototype[methodName + '_'] = originalMethod;

// overwrite the original to auto-paginate
// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
Class.prototype[methodName] = function(...args: any[]) {
const parsedArguments = paginator.parseArguments_(args);
return paginator.run_(parsedArguments, originalMethod.bind(this));
Expand All @@ -111,12 +111,12 @@ export class Paginator {
* @param {string} methodName - Name of the method to streamify.
* @return {function} - Wrapped function.
*/
// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
streamify<T = any>(methodName: string) {
return function(
// tslint:disable-next-line:no-any
this: {[index: string]: Function},
// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
...args: any[]
): ResourceStream<T> {
const parsedArguments = paginator.parseArguments_(args);
Expand All @@ -134,7 +134,7 @@ export class Paginator {
* @param {array} args - The original `arguments` pseduo-array that the original
* method received.
*/
// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
parseArguments_(args: any[]) {
let query: string | ParsedArguments | undefined;
let autoPaginate = true;
Expand Down Expand Up @@ -255,7 +255,7 @@ export class Paginator {
* and returns `nextQuery` to receive more results.
* @return {stream} - Readable object stream.
*/
// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
runAsStream_<T = any>(
parsedArguments: ParsedArguments,
originalMethod: Function
Expand Down
2 changes: 1 addition & 1 deletion src/resource-stream.ts
Expand Up @@ -47,7 +47,7 @@ export class ResourceStream<T> extends Transform implements ResourceEvents<T> {
this._requestsMade = 0;
this._resultsToSend = args.maxResults === -1 ? Infinity : args.maxResults!;
}
// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
end(...args: any[]) {
this._ended = true;
return super.end(...args);
Expand Down
19 changes: 12 additions & 7 deletions test/index.ts
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, beforeEach, afterEach} from 'mocha';
import * as proxyquire from 'proxyquire';
import * as sinon from 'sinon';
import {PassThrough, Transform} from 'stream';
Expand All @@ -22,13 +22,16 @@ import * as P from '../src';
import {paginator, ParsedArguments} from '../src';

const util = {
noop: () => {},
noop: () => {
// do nothing
},
};

class FakeResourceStream extends Transform {
calledWith: IArguments;
constructor() {
super({objectMode: true});
/* eslint-disable-next-line prefer-rest-params */
this.calledWith = arguments;
}
}
Expand All @@ -39,18 +42,21 @@ const p = proxyquire('../src', {

const sandbox = sinon.createSandbox();

// eslint-disable-next-line no-undef
afterEach(() => {
sandbox.restore();
});

// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
function createFakeStream<T = any>() {
return new PassThrough({objectMode: true}) as P.ResourceStream<T>;
}

describe('paginator', () => {
const UUID = uuid.v1();
function FakeClass() {}
function FakeClass() {
// do nothing
}

beforeEach(() => {
FakeClass.prototype.methodToExtend = () => {
Expand All @@ -75,7 +81,6 @@ describe('paginator', () => {

it('should accept an array or string method names', () => {
const originalMethod = FakeClass.prototype.methodToExtend;
FakeClass.prototype.anotherMethodToExtend = () => {};
const anotherMethod = FakeClass.prototype.anotherMethodToExtend;
const methodsToExtend = ['methodToExtend', 'anotherMethodToExtend'];
paginator.extend(FakeClass, methodsToExtend);
Expand Down Expand Up @@ -117,7 +122,7 @@ describe('paginator', () => {
return this.uuid;
};

// tslint:disable-next-line:no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
const cls = new (FakeClass as any)();
cls.uuid = uuid.v1();

Expand Down Expand Up @@ -159,7 +164,7 @@ describe('paginator', () => {
return args as ParsedArguments;
});
sandbox.stub(paginator, 'runAsStream_').callsFake(createFakeStream);
FakeClass.prototype.streamMethod.apply(FakeClass.prototype, fakeArgs);
FakeClass.prototype.streamMethod(...fakeArgs);
});

it('should run the method as a stream', done => {
Expand Down
2 changes: 1 addition & 1 deletion test/resource-stream.ts
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {describe, it, beforeEach, afterEach} from 'mocha';
import * as sinon from 'sinon';
import {Transform} from 'stream';

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
@@ -1,6 +1,7 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"lib": ["es2018", "dom"],
"rootDir": ".",
"outDir": "build"
},
Expand Down

0 comments on commit 4eaf9be

Please sign in to comment.