From 099090a9d2eb489ae2744e8c8272f08347225a97 Mon Sep 17 00:00:00 2001 From: Summer Ji Date: Mon, 4 May 2020 17:03:06 -0700 Subject: [PATCH] fix: synth.py clean up for multiple version (#326) --- packages/google-cloud-asset/src/index.ts | 16 ++++++------- packages/google-cloud-asset/synth.metadata | 10 ++++---- packages/google-cloud-asset/synth.py | 27 +++++++++++++--------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/packages/google-cloud-asset/src/index.ts b/packages/google-cloud-asset/src/index.ts index d10510bfa80..41d52a5b663 100644 --- a/packages/google-cloud-asset/src/index.ts +++ b/packages/google-cloud-asset/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. @@ -12,22 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** This file is automatically generated by synthtool. ** +// ** https://github.com/googleapis/synthtool ** // ** All changes to this file may be overwritten. ** -import * as v1 from './v1'; import * as v1beta1 from './v1beta1'; +import * as v1 from './v1'; import * as v1p1beta1 from './v1p1beta1'; import * as v1p2beta1 from './v1p2beta1'; import * as v1p4beta1 from './v1p4beta1'; + const AssetServiceClient = v1.AssetServiceClient; -export {v1, v1beta1, v1p1beta1, v1p4beta1, v1p2beta1, AssetServiceClient}; -// For compatibility with JavaScript libraries we need to provide this default export: -// tslint:disable-next-line no-default-export + +export {v1beta1, v1, v1p1beta1, v1p2beta1, v1p4beta1, AssetServiceClient}; export default { - v1, v1beta1, + v1, v1p1beta1, v1p2beta1, v1p4beta1, diff --git a/packages/google-cloud-asset/synth.metadata b/packages/google-cloud-asset/synth.metadata index e301403ed67..3a052a12d25 100644 --- a/packages/google-cloud-asset/synth.metadata +++ b/packages/google-cloud-asset/synth.metadata @@ -3,23 +3,23 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/nodejs-asset.git", - "sha": "972750658188f9761fdc296157b689e7b96915e4" + "remote": "git@github.com:googleapis/nodejs-asset.git", + "sha": "8d72abc44abe6fb805190cf49bcb2f692d77c407" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "3f5f8a2258c6a41f9fbf7b80acbca631dda0a952", - "internalRef": "308922843" + "sha": "e0f9d9e1f9de890db765be46f45ca8490723e3eb", + "internalRef": "309824146" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "19465d3ec5e5acdb01521d8f3bddd311bcbee28d" + "sha": "a2c1c4f89a5e220e7b39420ebea33623c7c72804" } } ], diff --git a/packages/google-cloud-asset/synth.py b/packages/google-cloud-asset/synth.py index 2aafb831925..c0564882971 100644 --- a/packages/google-cloud-asset/synth.py +++ b/packages/google-cloud-asset/synth.py @@ -37,31 +37,36 @@ }, # This API has dependencies outside of its own folder so we list them here. # Switching to bazel build should help get rid of this. - extra_proto_files=['google/cloud/common_resources.proto', 'google/cloud/orgpolicy/v1', 'google/identity/accesscontextmanager'], + extra_proto_files=['google/cloud/common_resources.proto', + 'google/cloud/orgpolicy/v1', 'google/identity/accesscontextmanager'], version=version), # skip index, protos, package.json, and README.md s.copy( library, - excludes=['package.json', 'src/index.ts'] + excludes=['package.json'] ) # Copy common templates common_templates = gcp.CommonTemplates() -templates = common_templates.node_library(source_location='build/src') +templates = common_templates.node_library( + source_location='build/src', versions=versions, default_version='v1') s.copy(templates) # Extra proto dependencies make the *_proto_list.json have some common files # that conflict with the same common files imported from gax. This is likely # a generator problem that needs to be fixed when we start handling synth.py # custom fixes. -proto_lists=[f'src/{version}/asset_service_proto_list.json' for version in versions] -remove_proto_keywords=['/google/api', '/google/protobuf', '/google/rpc', '/google/type'] +proto_lists = [ + f'src/{version}/asset_service_proto_list.json' for version in versions] +remove_proto_keywords = ['/google/api', + '/google/protobuf', '/google/rpc', '/google/type'] for file in proto_lists: - with open(file, 'r') as f: - items=json.load(f) - content =[item for item in items if all([(x not in item) for x in remove_proto_keywords])] - new_file=json.dumps(content, indent=2) + '\n' - with open(file, 'w') as f: - f.write(new_file) + with open(file, 'r') as f: + items = json.load(f) + content = [item for item in items if all( + [(x not in item) for x in remove_proto_keywords])] + new_file = json.dumps(content, indent=2) + '\n' + with open(file, 'w') as f: + f.write(new_file) node.postprocess_gapic_library()