|
18 | 18 | import os |
19 | 19 | from pathlib import Path |
20 | 20 | from synthtool import _tracked_paths |
21 | | -from typing import AnyStr |
22 | 21 | import shutil |
23 | 22 |
|
24 | 23 | logging.basicConfig(level=logging.DEBUG) |
25 | 24 |
|
26 | 25 | staging = Path("owl-bot-staging") |
27 | 26 |
|
28 | 27 | if staging.is_dir(): |
29 | | - versions = ['v2'] |
30 | | - versions_admin = [f"admin/{p}" for p in versions] |
| 28 | + logging.info(f"Copying files from staging directory ${staging}.") |
31 | 29 |
|
32 | | - logging.info(f"Copying files from staging directory {staging}.") |
33 | | - |
34 | | - src_paths = {} |
35 | | - src_files = {} |
36 | | - for version in versions + versions_admin: |
37 | | - src_paths[version] = staging / version |
38 | | - src_files[version] = list([fn for fn in src_paths[version].glob('**/*.*')]) |
39 | 30 |
|
40 | 31 | # Copy bigtable library. |
41 | | - # src/index.ts src/admin/v2/index.ts has added AdminClients manually, we don't wanna override it. |
| 32 | + # src/index.ts src/v2/index.ts has added AdminClients manually, we don't wanna override it. |
42 | 33 | # src/*.ts is a added layer for the client libraries, they need extra setting in tsconfig.json & tslint.json |
43 | 34 | # Tracking issues: 1. https://github.com/googleapis/nodejs-bigtable/issues/636 |
44 | 35 | # 2. https://github.com/googleapis/nodejs-bigtable/issues/635 |
45 | | - for version in versions: |
46 | | - library = src_paths[version] |
| 36 | + for version in ['v2']: |
| 37 | + library = staging / version |
47 | 38 | _tracked_paths.add(library) |
48 | | - admin_files = filter( |
49 | | - lambda f: str(f).find('_admin') >= 0, |
50 | | - src_files[version] |
51 | | - ) |
52 | | - excludes = [ |
53 | | - 'package.json', |
54 | | - 'README.md', |
55 | | - 'src/index.ts', |
56 | | - 'src/v2/index.ts', |
57 | | - 'tsconfig.json', |
58 | | - 'tslint.json', |
59 | | - '.github/sync-repo-settings.yaml', |
60 | | - '.OwlBot.yaml', |
61 | | - ] + list(admin_files) |
62 | | - logging.info(f"excluding files for non-admin: {excludes}") |
63 | | - s.copy([library], excludes = excludes) |
| 39 | + s.copy([library], excludes=['package.json', 'README.md', 'src/index.ts', 'src/v2/index.ts', 'tsconfig.json', 'tslint.json', '.github/sync-repo-settings.yaml']) |
64 | 40 |
|
65 | | - # Copy the admin library pieces and knit them in. |
66 | | - # Don't override system-test for admin/v2, just keep the v2 version. |
67 | | - for version in versions: |
68 | | - admin_version = f"admin/{version}" |
69 | | - library = src_paths[admin_version] |
70 | | - inProtoPath = f"protos/google/bigtable/{admin_version}" |
71 | | - protos = library / inProtoPath |
72 | | - classes = library / 'src' / version |
73 | | - samples = library / 'samples' / 'generated' |
74 | | - tests = library / 'test' |
| 41 | + # Copy the admin library. |
| 42 | + # Not override system-test for admin/v2, just keep the v2 version. |
| 43 | + for version in ['v2']: |
| 44 | + library = staging / 'admin' / version |
75 | 45 | _tracked_paths.add(library) |
76 | | - |
77 | | - # We also have to munge the proto paths in the *_proto_list.json due to making it a level deeper. |
78 | | - # That also applies to the classes themselves. |
79 | | - classesStr = str(classes) |
80 | | - jsons = [fn |
81 | | - for fn |
82 | | - in src_files[admin_version] |
83 | | - if str(fn)[:len(classesStr)] == classesStr] |
84 | | - for jfn in jsons: |
85 | | - logging.info(f"munging json file: {str(jfn)}") |
86 | | - contents = jfn.read_text() |
87 | | - contents = contents.replace("'../..", "'../../..") |
88 | | - contents = contents.replace('"../..', '"../../..') |
89 | | - jfn.write_text(contents) |
90 | | - |
91 | | - # Also to the tests that import stuff from src. ../ -> ../../../ |
92 | | - testsStr = str(tests) |
93 | | - tfns = [fn |
94 | | - for fn |
95 | | - in src_files[admin_version] |
96 | | - if str(fn)[:len(testsStr)] == testsStr] |
97 | | - for tfn in tfns: |
98 | | - logging.info(f"munging test file: {str(tfn)}") |
99 | | - contents = tfn.read_text() |
100 | | - contents = contents.replace("'../", "'../../../") |
101 | | - tfn.write_text(contents) |
102 | | - |
103 | | - # Finally, the samples. .v2 -> .admin.v2 |
104 | | - samplesStr = str(samples) |
105 | | - sfns = [fn |
106 | | - for fn |
107 | | - in src_files[admin_version] |
108 | | - if str(fn)[:len(samplesStr)] == samplesStr] |
109 | | - for sfn in sfns: |
110 | | - logging.info(f"munging sample file: {str(sfn)}") |
111 | | - contents = sfn.read_text() |
112 | | - contents = contents.replace(').v2', ').admin.v2') |
113 | | - sfn.write_text(contents) |
114 | | - |
115 | | - os.system(f"mkdir -p {inProtoPath}") |
116 | | - s.copy([protos / '*'], destination=inProtoPath) |
117 | | - os.system(f"mkdir -p src/{admin_version}") |
118 | | - s.copy([classes / '*'], destination=f"src/{admin_version}") |
119 | | - os.system(f"mkdir -p samples/generated/{admin_version}") |
120 | | - s.copy([samples / 'v2' / '*admin*'], destination=f"samples/generated/{admin_version}") |
121 | | - os.system(f"mkdir -p test/{admin_version}") |
122 | | - s.copy([tests / '*admin*.ts'], destination=f"test/{admin_version}") |
| 46 | + s.copy([library], excludes=['package.json', 'README.md', 'src/index.ts', 'src/v2/index.ts', 'tsconfig.json', 'tslint.json', 'system-test/fixtures/sample/src/index.ts', 'system-test/fixtures/sample/src/index.js', '.github/sync-repo-settings.yaml']) |
123 | 47 |
|
124 | 48 | # Replace the client name for generated system-test. |
125 | 49 | system_test_files=['system-test/fixtures/sample/src/index.ts','system-test/fixtures/sample/src/index.js'] |
|
0 commit comments