Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dep)!: upgrade gts 2.0.0 #194

Merged
merged 11 commits into from Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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')
}
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -8,15 +8,14 @@
"scripts": {
"test": "c8 mocha build/test",
"lint": "gts check",
"clean": "gts clean",
"compile": "tsc -p .",
"fix": "gts fix",
"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 ../",
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcoe do we do this in other places?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all that should be required is this:

"samples-test": "cd samples/ && npm link ../ && npm test && cd ../"

which is what we use in other libraries, npm link ../ should perform the install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: The couple libraries I converted use samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../, like https://github.com/googleapis/nodejs-monitoring/blob/master/package.json#L32

"system-test": "mocha build/system-test",
"docs-test": "linkinator docs",
"predocs-test": "npm run docs"
Expand All @@ -37,7 +36,7 @@
"@types/sinon": "^7.0.0",
"@types/uuid": "^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",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Expand Up @@ -92,7 +92,7 @@ export class Paginator {

// overwrite the original to auto-paginate
// tslint:disable-next-line:no-any
Class.prototype[methodName] = function(...args: any[]) {
Class.prototype[methodName] = function (...args: any[]) {// eslint-disable-line
const parsedArguments = paginator.parseArguments_(args);
return paginator.run_(parsedArguments, originalMethod.bind(this));
};
Expand All @@ -113,7 +113,7 @@ export class Paginator {
*/
// tslint:disable-next-line:no-any
streamify<T = any>(methodName: string) {
return function(
return function (// eslint-disable-line
// tslint:disable-next-line:no-any
this: {[index: string]: Function},
// tslint:disable-next-line:no-any
Expand Down
28 changes: 17 additions & 11 deletions test/index.ts
Expand Up @@ -22,14 +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});
this.calledWith = arguments;
this.calledWith = arguments; // eslint-disable-line
summer-ji-eng marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -39,7 +41,7 @@ const p = proxyquire('../src', {

const sandbox = sinon.createSandbox();

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

Expand All @@ -50,9 +52,11 @@ function createFakeStream<T = any>() {

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

beforeEach(() => {
beforeEach(() => { // eslint-disable-line
FakeClass.prototype.methodToExtend = () => {
return UUID;
};
Expand All @@ -75,7 +79,9 @@ describe('paginator', () => {

it('should accept an array or string method names', () => {
const originalMethod = FakeClass.prototype.methodToExtend;
FakeClass.prototype.anotherMethodToExtend = () => {};
FakeClass.prototype.anotherMethodToExtend = () => {
// do nothing
summer-ji-eng marked this conversation as resolved.
Show resolved Hide resolved
};
const anotherMethod = FakeClass.prototype.anotherMethodToExtend;
const methodsToExtend = ['methodToExtend', 'anotherMethodToExtend'];
paginator.extend(FakeClass, methodsToExtend);
Expand Down Expand Up @@ -109,11 +115,11 @@ describe('paginator', () => {
});

paginator.extend(FakeClass, 'methodToExtend');
FakeClass.prototype.methodToExtend();
FakeClass.prototype.methodToExtend(); // eslint-disable-line
});

it('should maintain `this` context', done => {
FakeClass.prototype.methodToExtend = function() {
FakeClass.prototype.methodToExtend = function () { // eslint-disable-line
return this.uuid;
};

Expand Down Expand Up @@ -141,7 +147,7 @@ describe('paginator', () => {
});

describe('streamify', () => {
beforeEach(() => {
beforeEach(() => { // eslint-disable-line
FakeClass.prototype.streamMethod = paginator.streamify('methodToExtend');
});

Expand All @@ -159,7 +165,7 @@ describe('paginator', () => {
return args as ParsedArguments;
});
sandbox.stub(paginator, 'runAsStream_').callsFake(createFakeStream);
FakeClass.prototype.streamMethod.apply(FakeClass.prototype, fakeArgs);
FakeClass.prototype.streamMethod.apply(FakeClass.prototype, fakeArgs); // eslint-disable-line
});

it('should run the method as a stream', done => {
Expand All @@ -179,7 +185,7 @@ describe('paginator', () => {

it('should apply the proper context', done => {
const parsedArguments = {a: 'b', c: 'd'} as ParsedArguments;
FakeClass.prototype.methodToExtend = function() {
FakeClass.prototype.methodToExtend = function () { // eslint-disable-line
summer-ji-eng marked this conversation as resolved.
Show resolved Hide resolved
return this;
};
sandbox.stub(paginator, 'parseArguments_').callsFake(() => {
Expand Down
4 changes: 2 additions & 2 deletions test/resource-stream.ts
Expand Up @@ -31,12 +31,12 @@ describe('ResourceStream', () => {
let requestSpy: sinon.SinonSpy;
let stream: ResourceStream<{}>;

beforeEach(() => {
beforeEach(() => { // eslint-disable-line
summer-ji-eng marked this conversation as resolved.
Show resolved Hide resolved
requestSpy = sandbox.spy();
stream = new ResourceStream(config, requestSpy);
});

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

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
@@ -1,6 +1,7 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"lib": ["es2015", "dom"],
summer-ji-eng marked this conversation as resolved.
Show resolved Hide resolved
"rootDir": ".",
"outDir": "build"
},
Expand Down