forked from googleapis/nodejs-firestore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synth.py
95 lines (85 loc) · 3.12 KB
/
synth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import synthtool as s
import synthtool.gcp as gcp
import logging
import subprocess
import os
logging.basicConfig(level=logging.DEBUG)
gapic_micro = gcp.GAPICMicrogenerator()
v1_admin_library = gapic_micro.typescript_library(
"firestore-admin", "v1", proto_path="/google/firestore/admin/v1",
generator_args={'grpc-service-config': 'google/firestore/admin/v1/firestore_admin_grpc_service_config.json'}
)
v1beta1_library = gapic_micro.typescript_library(
"firestore", "v1beta1", proto_path="/google/firestore/v1beta1",
generator_args={'grpc-service-config': 'google/firestore/v1beta1/firestore_grpc_service_config.json'}
)
v1_library = gapic_micro.typescript_library(
"firestore", "v1", proto_path="/google/firestore/v1",
generator_args={'grpc-service-config': 'google/firestore/v1/firestore_grpc_service_config.json'}
)
# skip index, protos, package.json, and README.md
s.copy(v1_admin_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts",
"tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"])
s.copy(v1beta1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1beta1/index.ts",
"tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"])
s.copy(v1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts",
"tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"])
# Fix dropping of google-cloud-resource-header
# See: https://github.com/googleapis/nodejs-firestore/pull/375
s.replace(
"dev/src/v1beta1/firestore_client.ts",
"return this\._innerApiCalls\.listen\(options\);",
"return this._innerApiCalls.listen({}, options);",
)
s.replace(
"dev/src/v1/firestore_client.ts",
"return this\._innerApiCalls\.listen\(options\);",
"return this._innerApiCalls.listen({}, options);",
)
# Copy template files
common_templates = gcp.CommonTemplates()
templates = common_templates.node_library(
source_location="build/src", test_project="node-gcloud-ci"
)
s.copy(templates)
# use the existing proto .js / .d.ts files
s.replace(
"dev/src/v1/firestore_client.ts",
"/protos/protos'",
"/protos/firestore_v1_proto_api'"
)
s.replace(
"dev/test/gapic-firestore-v1.ts",
"/protos/protos'",
"/protos/firestore_v1_proto_api'"
)
s.replace(
"dev/src/v1/firestore_admin_client.ts",
"/protos/protos'",
"/protos/firestore_admin_v1_proto_api'"
)
s.replace(
"dev/test/gapic-firestore_admin-v1.ts",
"/protos/protos'",
"/protos/firestore_admin_v1_proto_api'"
)
s.replace(
"dev/src/v1beta1/firestore_client.ts",
"/protos/protos'",
"/protos/firestore_v1beta1_proto_api'"
)
s.replace(
"dev/test/gapic-firestore-v1beta1.ts",
"/protos/protos'",
"/protos/firestore_v1beta1_proto_api'"
)
# Remove auto-generated packaging tests
os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts')
# Node.js specific cleanup
subprocess.run(["npm", "install"])
subprocess.run(["npm", "run", "fix"])
os.chdir("dev")
subprocess.run(["npx", "compileProtos", "src"])
os.unlink('protos/protos.js')
os.unlink('protos/protos.d.ts')
os.unlink('.jsdoc.js')