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

feat(deps): update gts to v2 #340

Merged
merged 23 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/node_modules
**/.coverage
build/
docs/
protos/
test-fixtures/
pbjs-genfiles/
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules
**/.coverage
build/
docs/
protos/
17 changes: 17 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -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')
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"c8": "^7.1.0",
"codecov": "^3.6.5",
"espower-typescript": "^9.0.2",
"gts": "^1.1.2",
"gts": "next",
"mocha": "^7.1.1",
"ncp": "^2.0.0",
"rimraf": "^3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions test-fixtures/test-application-js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
const fs = require('fs-extra');
const { spawn } = require('child_process');
var kill = require('tree-kill');
const {spawn} = require('child_process');
const kill = require('tree-kill');
const path = require('path');
const SHOWCASE_SERVER = path.join(
__dirname,
Expand Down
13 changes: 6 additions & 7 deletions test-fixtures/test-application-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import * as showcase from 'showcase';
import * as grpc from '@grpc/grpc-js'; // to create credentials for local Showcase server

interface ClientOptions{
[name: string] : Object,
servicePath: string,
port: number
[name: string]: Object;
servicePath: string;
port: number;
}
interface Options{
[name: string] : Object
interface Options {
[name: string]: Object;
}
// Fake auth client for fallback
const authStub = {
Expand Down Expand Up @@ -115,7 +115,7 @@ function testExpand(client: showcase.v1beta1.EchoClient) {
};
const result = await new Promise((resolve, reject) => {
const stream = client.expand(request);
const result:string[] = [];
const result: string[] = [];
stream.on('data', response => {
result.push(response.content);
});
Expand Down Expand Up @@ -211,4 +211,3 @@ function testWait(client: showcase.v1beta1.EchoClient) {
assert.deepStrictEqual(response.content, request.success.content);
});
}

2 changes: 1 addition & 1 deletion test-fixtures/test-application-ts/src/integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as path from 'path';
import * as fs from 'fs-extra';
import {Server} from './server';
const exec = util.promisify(child_process.exec);
const SHOWCASE_SERVER = path.join(__dirname,'..', '..', 'showcase-server');
const SHOWCASE_SERVER = path.join(__dirname, '..', '..', 'showcase-server');
const SHOWCASE_SERVER_TAR = path.join(
SHOWCASE_SERVER,
'gapic-showcase-server.tar.gz'
Expand Down
6 changes: 3 additions & 3 deletions test-fixtures/test-application-ts/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const SHOWCASE_SERVER = path.join(
'gapic-showcase'
);

export class Server{
export class Server {
pid: number = -1;
constrcutor() {}
run(){
run() {
if (!fs.existsSync(SHOWCASE_SERVER)) {
console.warn(
'gapic showcase server does not exist, please download it first.'
Expand All @@ -36,4 +36,4 @@ export class Server{
kill() {
process.kill(this.pid);
}
};
}
78 changes: 39 additions & 39 deletions test-fixtures/test-application-ts/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
const path = require('path');

module.exports = {
entry: './build/src/index.js',
output: {
library: "showcaseTest",
filename: "./main.js"
},
node: {
child_process: 'empty',
fs: 'empty',
crypto: 'empty',
},
resolve: {
extensions: ['.js', '.json']
},
module: {
rules: [
{
test: /node_modules[\\\/]@grpc[\\\/]grpc-js/,
use: 'null-loader'
},
{
test: /node_modules[\\\/]grpc/,
use: 'null-loader'
},
{
test: /node_modules[\\\/]retry-request/,
use: 'null-loader'
},
{
test: /node_modules[\\\/]https-proxy-agent/,
use: 'null-loader'
},
{
test: /node_modules[\\\/]gtoken/,
use: 'null-loader'
},
]
},
mode: 'production'
}
entry: './build/src/index.js',
output: {
library: 'showcaseTest',
filename: './main.js',
},
node: {
child_process: 'empty',
fs: 'empty',
crypto: 'empty',
},
resolve: {
extensions: ['.js', '.json'],
},
module: {
rules: [
{
test: /node_modules[\\\/]@grpc[\\\/]grpc-js/,
use: 'null-loader',
},
{
test: /node_modules[\\\/]grpc/,
use: 'null-loader',
},
{
test: /node_modules[\\\/]retry-request/,
use: 'null-loader',
},
{
test: /node_modules[\\\/]https-proxy-agent/,
use: 'null-loader',
},
{
test: /node_modules[\\\/]gtoken/,
use: 'null-loader',
},
],
},
mode: 'production',
};
2 changes: 1 addition & 1 deletion typescript/src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface BundleConfig {

export class BundleConfigClient {
bundleConfigs: BundleConfig[] = [];
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
fromObject(yaml: any) {
// construct meaning Object from GAPIC v2 file.
const interfaces = yaml['interfaces'];
Expand Down
10 changes: 3 additions & 7 deletions typescript/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,18 @@
// limitations under the License.

import * as yargs from 'yargs';
import { Generator } from './generator';
import {Generator} from './generator';

async function main() {
const argv = yargs.argv;

if (argv.descriptor) {
console.error('Descriptor option is not yet supported.');
process.exit(1);
throw new Error('Descriptor option is not yet supported.');
}

const generator = new Generator();
await generator.initializeFromStdin();
await generator.generate();
}

main().catch(err => {
console.error(err);
process.exit(1);
});
main();
10 changes: 5 additions & 5 deletions typescript/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import * as yaml from 'js-yaml';

import * as plugin from '../../pbjs-genfiles/plugin';

import { API } from './schema/api';
import { processTemplates } from './templater';
import { BundleConfigClient, BundleConfig } from './bundle';
import { commonPrefix, duration } from './util';
import {API} from './schema/api';
import {processTemplates} from './templater';
import {BundleConfigClient, BundleConfig} from './bundle';
import {commonPrefix, duration} from './util';

export interface OptionsMap {
[name: string]: string;
Expand Down Expand Up @@ -57,7 +57,7 @@ export class Generator {
// Fixes gRPC service config to replace string google.protobuf.Duration
// to a proper Duration message, since protobufjs does not support
// string Durations such as "30s".
private static updateDuration(obj: { [key: string]: {} }) {
private static updateDuration(obj: {[key: string]: {}}) {
const fieldNames = [
'timeout',
'initialBackoff',
Expand Down
6 changes: 3 additions & 3 deletions typescript/src/schema/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import * as plugin from '../../../pbjs-genfiles/plugin';

import { Naming, Options as namingOptions } from './naming';
import { Proto } from './proto';
import { ResourceDatabase, ResourceDescriptor } from './resource-database';
import {Naming, Options as namingOptions} from './naming';
import {Proto} from './proto';
import {ResourceDatabase, ResourceDescriptor} from './resource-database';

export interface ProtosMap {
[filename: string]: Proto;
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/schema/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ export class CommentsMap {
}
getParamComments(messageName: string, fieldName: string): Comment {
const key = messageName + ':' + fieldName;
return this.comments[key] ?? { paramName: '', paramType: '', comments: [] };
return this.comments[key] ?? {paramName: '', paramType: '', comments: []};
}
}
6 changes: 3 additions & 3 deletions typescript/src/schema/naming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

import * as plugin from '../../../pbjs-genfiles/plugin';
import { commonPrefix } from '../util';
import { API } from './api';
import { BundleConfig } from 'src/bundle';
import {commonPrefix} from '../util';
import {API} from './api';
import {BundleConfig} from 'src/bundle';

export interface Options {
grpcServiceConfig: plugin.grpc.service_config.ServiceConfig;
Expand Down
12 changes: 6 additions & 6 deletions typescript/src/schema/proto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
// limitations under the License.

import * as plugin from '../../../pbjs-genfiles/plugin';
import { CommentsMap, Comment } from './comments';
import { milliseconds } from '../util';
import { ResourceDescriptor, ResourceDatabase } from './resource-database';
import {CommentsMap, Comment} from './comments';
import {milliseconds} from '../util';
import {ResourceDescriptor, ResourceDatabase} from './resource-database';
import {
RetryableCodeMap,
defaultParametersName,
defaultNonIdempotentRetryCodesName,
defaultParameters,
} from './retryable-code-map';
import { BundleConfig } from 'src/bundle';
import {BundleConfig} from 'src/bundle';

interface MethodDescriptorProto
extends plugin.google.protobuf.IMethodDescriptorProto {
Expand Down Expand Up @@ -359,7 +359,7 @@ function augmentMethod(
}
if (method.methodConfig.retryPolicy) {
// converting retry parameters to the syntax google-gax supports
const retryParams: { [key: string]: number } = {};
const retryParams: {[key: string]: number} = {};
if (method.methodConfig.retryPolicy.initialBackoff) {
retryParams.initial_retry_delay_millis = milliseconds(
method.methodConfig.retryPolicy.initialBackoff
Expand Down Expand Up @@ -499,7 +499,7 @@ function augmentService(

// allResourceDatabase: resources that defined by `google.api.resource`
// resourceDatabase: all resources defined by `google.api.resource` or `google.api.resource_definition`
const uniqueResources: { [name: string]: ResourceDescriptor } = {};
const uniqueResources: {[name: string]: ResourceDescriptor} = {};
// Copy all resources in resourceDatabase to uniqueResources
const allPatterns = resourceDatabase.patterns;
for (const pattern of Object.keys(allPatterns)) {
Expand Down
6 changes: 3 additions & 3 deletions typescript/src/schema/resource-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as plugin from '../../../pbjs-genfiles/plugin';
import { getResourceNameByPattern } from '../util';
import {getResourceNameByPattern} from '../util';

export interface ResourceDescriptor
extends plugin.google.api.IResourceDescriptor {
Expand All @@ -22,8 +22,8 @@ export interface ResourceDescriptor
}

export class ResourceDatabase {
patterns: { [pattern: string]: ResourceDescriptor };
types: { [type: string]: ResourceDescriptor };
patterns: {[pattern: string]: ResourceDescriptor};
types: {[type: string]: ResourceDescriptor};

constructor() {
this.patterns = {};
Expand Down
Loading