|
1 | | -# Copyright 2018 Google LLC |
| 1 | +# Copyright 2024 Google LLC |
2 | 2 | # |
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | # you may not use this file except in compliance with the License. |
|
16 | 16 |
|
17 | 17 | import logging |
18 | 18 | from pathlib import Path |
19 | | -import synthtool as s |
20 | 19 | import subprocess |
| 20 | + |
| 21 | +import synthtool as s |
21 | 22 | from synthtool.languages import php |
22 | 23 | from synthtool import _tracked_paths |
23 | 24 |
|
|
29 | 30 | # Added so that we can pass copy_excludes in the owlbot_main() call |
30 | 31 | _tracked_paths.add(src) |
31 | 32 |
|
32 | | -# Exclude partial veneer files. |
33 | | -php.owlbot_main( |
34 | | - src=src, |
35 | | - dest=dest, |
36 | | - copy_excludes=[ |
37 | | - src / "*/src/V1/ProductSearchClient.php", |
38 | | - src / "*/src/V1/ImageAnnotatorClient.php", |
39 | | - ] |
40 | | -) |
41 | | - |
42 | | -# Change the wording for the deprecation warning. |
43 | | -s.replace( |
44 | | - 'src/*/*_*.php', |
45 | | - r'will be removed in the next major release', |
46 | | - 'will be removed in a future release') |
47 | | - |
48 | | -### [START] protect vision backwards compatibility |
49 | | - |
50 | | -# format generated clients |
51 | | -subprocess.run([ |
52 | | - 'git', |
53 | | - 'apply', |
54 | | - '.owlbot/safesearchannotation.patch']) |
55 | | - |
56 | | -### [START] protoc backwards compatibility fixes |
57 | | - |
58 | | -# roll back to private properties. |
59 | | -s.replace( |
60 | | - "src/**/V*/**/*.php", |
61 | | - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", |
62 | | - r"""Generated from protobuf field \1 |
63 | | - */ |
64 | | - private $""") |
65 | | - |
66 | | -# Replace "Unwrapped" with "Value" for method names. |
67 | | -s.replace( |
68 | | - "src/**/V*/**/*.php", |
69 | | - r"public function ([s|g]\w{3,})Unwrapped", |
70 | | - r"public function \1Value" |
71 | | -) |
72 | | - |
73 | | -### [END] protoc backwards compatibility fixes |
| 33 | +php.owlbot_main(src=src, dest=dest) |
74 | 34 |
|
75 | | -# fix relative cloud.google.com links |
| 35 | +# remove class_alias code |
76 | 36 | s.replace( |
77 | | - "src/**/V*/**/*.php", |
78 | | - r"(.{0,})\]\((/.{0,})\)", |
79 | | - r"\1](https://cloud.google.com\2)" |
80 | | -) |
| 37 | + "src/V*/**/*.php", |
| 38 | + r"^// Adding a class alias for backwards compatibility with the previous class name.$" |
| 39 | + + "\n" |
| 40 | + + r"^class_alias\(.*\);$" |
| 41 | + + "\n", |
| 42 | + '') |
81 | 43 |
|
82 | 44 | # format generated clients |
83 | 45 | subprocess.run([ |
84 | | - 'npx', |
85 | | - '-y', |
86 | | - '-p', |
87 | | - '@prettier/plugin-php@^0.16', |
| 46 | + 'npm', |
| 47 | + 'exec', |
| 48 | + '--yes', |
| 49 | + '--package=@prettier/plugin-php@^0.16', |
| 50 | + '--', |
88 | 51 | 'prettier', |
89 | | - '**/Gapic/*', |
| 52 | + '**/Client/*', |
90 | 53 | '--write', |
91 | 54 | '--parser=php', |
92 | 55 | '--single-quote', |
93 | | - '--print-width=80']) |
| 56 | + '--print-width=120']) |
0 commit comments