|
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. |
|
30 | 30 | # Added so that we can pass copy_excludes in the owlbot_main() call |
31 | 31 | _tracked_paths.add(src) |
32 | 32 |
|
33 | | -php.owlbot_main( |
34 | | - src=src, |
35 | | - dest=dest, |
36 | | - copy_excludes=[ |
37 | | - src / "*/proto/src/Google/Cloud/Datastore/V1/TransactionOptions/ReadOnly.php" |
38 | | - ] |
39 | | -) |
| 33 | +php.owlbot_main(src=src, dest=dest) |
40 | 34 |
|
41 | | - |
42 | | -# Fix class references in gapic samples |
43 | | -for version in ['V1']: |
44 | | - pathExpr = 'src/' + version + '/Gapic/DatastoreGapicClient.php' |
45 | | - |
46 | | - types = { |
47 | | - '= new DatastoreClient': r'= new Google\\Cloud\\Datastore\\' + version + r'\\DatastoreClient', |
48 | | - '= Mode::': r'= Google\\Cloud\\Datastore\\' + version + r'\\CommitRequest\\Mode::', |
49 | | - 'new PartitionId': r'new Google\\Cloud\\Datastore\\' + version + r'\\PartitionId', |
50 | | - } |
51 | | - |
52 | | - for search, replace in types.items(): |
53 | | - s.replace( |
54 | | - pathExpr, |
55 | | - search, |
56 | | - replace) |
57 | | - |
58 | | -# remove ReadOnly class_alias code |
| 35 | +# remove class_alias code |
59 | 36 | s.replace( |
60 | | - "src/V*/**/PBReadOnly.php", |
61 | | - r"^// Adding a class alias for backwards compatibility with the \"readonly\" keyword.$" |
| 37 | + "src/V*/**/*.php", |
| 38 | + r"^// Adding a class alias for backwards compatibility with the previous class name.$" |
62 | 39 | + "\n" |
63 | | - + r"^class_alias\(PBReadOnly::class, __NAMESPACE__ . '\\ReadOnly'\);$" |
| 40 | + + r"^class_alias\(.*\);$" |
64 | 41 | + "\n", |
65 | 42 | '') |
66 | 43 |
|
67 | | -### [START] protoc backwards compatibility fixes |
68 | | - |
69 | | -# roll back to private properties. |
70 | | -s.replace( |
71 | | - "src/**/V*/**/*.php", |
72 | | - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", |
73 | | - r"""Generated from protobuf field \1 |
74 | | - */ |
75 | | - private $""") |
76 | | - |
77 | | -# Replace "Unwrapped" with "Value" for method names. |
78 | | -s.replace( |
79 | | - "src/**/V*/**/*.php", |
80 | | - r"public function ([s|g]\w{3,})Unwrapped", |
81 | | - r"public function \1Value" |
82 | | -) |
83 | | - |
84 | | -### [END] protoc backwards compatibility fixes |
85 | | - |
86 | | -# fix relative cloud.google.com links |
87 | | -s.replace( |
88 | | - "src/**/V*/**/*.php", |
89 | | - r"(.{0,})\]\((/.{0,})\)", |
90 | | - r"\1](https://cloud.google.com\2)" |
91 | | -) |
92 | | - |
93 | | -# Address breaking changes |
94 | | -subprocess.run('git show 8ada2c97c72ffabf5c3031021378874f8caa8804 | git apply', shell=True) |
| 44 | +# format generated clients |
| 45 | +subprocess.run([ |
| 46 | + 'npm', |
| 47 | + 'exec', |
| 48 | + '--yes', |
| 49 | + '--package=@prettier/plugin-php@^0.19', |
| 50 | + '--', |
| 51 | + 'prettier', |
| 52 | + '**/Client/*', |
| 53 | + '--write', |
| 54 | + '--parser=php', |
| 55 | + '--single-quote', |
| 56 | + '--print-width=120']) |
0 commit comments