-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate.sh
executable file
·47 lines (37 loc) · 1.19 KB
/
generate.sh
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
# #!/bin/bash
# set -e
if [ -z "$1" ]; then
echo "Required generator file is missing."
exit 1
fi
file="$1"
rm -rf ./generated
docker run --rm -v "${PWD}:/local" -u $(id -u) openapitools/openapi-generator-cli:latest generate \
-i "/local/$file" \
-g php \
-o /local/generated \
--global-property apiTests=false,modelTests=false,apiDocs=false,modelDocs=false
rm generated/composer.json
rm generated/.gitignore
add_passage_version_header() {
local header_comment="// Add Passage version header"
if grep -q "$header_comment" generated/lib/HeaderSelector.php; then
echo "Passage version header already exists"
return 0
fi
local package_name="passage-php"
sed -i "/return \$headers;/i \\
$header_comment\\
\$packageVersion = 'unknown';\\
\\
try {\\
\$packageVersion = \\\\Composer\\\\InstalledVersions::getPrettyVersion('passageidentity/$package_name');\\
} catch (\\\\Throwable \$ignored) {\\
// Don't throw an exception if we can't determine the package version\\
}\\
\\
\$headers['Passage-Version'] = '$package_name ' . \$packageVersion;\\
" \
generated/lib/HeaderSelector.php
}
add_passage_version_header