Skip to content

Commit

Permalink
fix: synth.py clean up for multiple version (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
summer-ji-eng authored May 5, 2020
1 parent 2f584bf commit 099090a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
16 changes: 8 additions & 8 deletions packages/google-cloud-asset/src/index.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-asset/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
],
Expand Down
27 changes: 16 additions & 11 deletions packages/google-cloud-asset/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 099090a

Please sign in to comment.