-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-build
executable file
·124 lines (104 loc) · 3.51 KB
/
run-build
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
# see https://github.com/OpenAPITools/openapi-generator/tree/v7.8.0/modules/openapi-generator/src/main/resources/typescript-node
set -e
DIR=$(cd `dirname $0` && pwd)
WORKING_DIR="/app/javascript"
if [[ -n "$GITHUB_ACTIONS" ]]; then
printf "\nLogging in to docker.com ...\n"
echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
fi
# cleanup
rm -f "${DIR}/api/"*.ts
rm -f "${DIR}/model/"*.ts
rm -f "${DIR}/types/api/"*.ts
rm -f "${DIR}/types/model/"*.ts
# Generate code
docker run --rm \
-v "${DIR}/:/local" \
--user "$(id -u):$(id -g)" \
openapitools/openapi-generator-cli:v7.8.0 generate \
-i "/local/openapi-sdk.yaml" \
-c "/local/openapi-config.yaml" \
-t "/local/templates" \
-o "/local/" \
--global-property=api=true \
--global-property=model=true \
--global-property=apiDocs=false \
--global-property=modelDocs=false
# Generate API docs
rm -rf "${DIR}/docs/api" "${DIR}/tmp_docs"
mkdir -p "${DIR}/docs/api"
mkdir -p "${DIR}/tmp_docs"
docker run --rm \
-v "${DIR}/:/local" \
--user "$(id -u):$(id -g)" \
openapitools/openapi-generator-cli:v7.8.0 generate \
-i "/local/openapi-sdk.yaml" \
-c "/local/openapi-config.yaml" \
-t "/local/templates" \
-o "/local/tmp_docs" \
--global-property=api=false \
--global-property=model=false \
--global-property=apiDocs=true \
--global-property=modelDocs=false
# Only need README.md from initial run
rm -f "${DIR}/tmp_docs/README.md"
mv "${DIR}/tmp_docs/"*.md "${DIR}/docs/api/"
# Generate Model docs
rm -rf "${DIR}/docs/model" "${DIR}/tmp_docs"
mkdir -p "${DIR}/docs/model"
mkdir -p "${DIR}/tmp_docs"
docker run --rm \
-v "${DIR}/:/local" \
--user "$(id -u):$(id -g)" \
openapitools/openapi-generator-cli:v7.8.0 generate \
-i "/local/openapi-sdk.yaml" \
-c "/local/openapi-config.yaml" \
-t "/local/templates" \
-o "/local/tmp_docs" \
--global-property=api=false \
--global-property=model=false \
--global-property=apiDocs=false \
--global-property=modelDocs=true
# Only need README.md from initial run
rm -f "${DIR}/tmp_docs/README.md"
mv "${DIR}/tmp_docs/"*.md "${DIR}/docs/model/"
rm -rf "${DIR}/tmp_docs"
printf "\nInstalling composer dependencies ...\n"
mkdir -p "${DIR}/vendor"
bash "${DIR}/bin/php" composer install
printf "\n"
printf "Adding examples to Docs ...\n"
bash "${DIR}/bin/php" ./bin/generate-examples.php
printf "Install NPM dependencies ...\n"
mkdir -p "${DIR}/node_modules"
bash "${DIR}/bin/node" npm install
printf "Running prettier ...\n"
bash "${DIR}/bin/node" npm run prettier
printf "Replacing strings ...\n"
docker run --rm \
-v "${DIR}:${WORKING_DIR}" \
-w "${WORKING_DIR}" \
perl bash ./bin/replace
printf "Scanning for prohibited keywords ...\n"
docker run --rm \
-v "${DIR}:${WORKING_DIR}" \
-w "${WORKING_DIR}" \
perl bash ./bin/scan_for
printf "Running build ...\n"
bash "${DIR}/bin/node" npm run build
bash "${DIR}/bin/node" npm run build-types
# avoid docker messing with permissions
if [[ -z "$GITHUB_ACTIONS" ]]; then
chmod 644 "${DIR}/README.md"
find "${DIR}/docs/" -type f -exec chmod 644 {} \;
find "${DIR}/examples/" -type f -exec chmod 644 {} \;
find "${DIR}/test_fixtures/" -type f -exec chmod 644 {} \;
find "${DIR}/api/" -type f -exec chmod 644 {} \;
find "${DIR}/dist/" -type f -exec chmod 644 {} \;
find "${DIR}/model/" -type f -exec chmod 644 {} \;
find "${DIR}/types/" -type f -exec chmod 644 {} \;
fi
printf "Running tests ...\n"
bash "${DIR}/bin/node" npm run test
printf "Success!\n"