Skip to content

Commit 41cc5fa

Browse files
authored
Fixes to make.sh (#1850f
* Get make.sh targets running on Node.js v18 * Catch up make.sh to match other clients * Readability tweaks to make.mjs code
1 parent 0d4a291 commit 41cc5fa

File tree

3 files changed

+40
-31
lines changed

3 files changed

+40
-31
lines changed

.ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG NODE_JS_VERSION=16
1+
ARG NODE_JS_VERSION=18
22
FROM node:${NODE_JS_VERSION}
33

44
# Create app directory

.ci/make.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,23 @@ async function bump (args) {
9696

9797
// this command can only be executed locally for now
9898
async function codegen (args) {
99-
assert(args.length === 1, 'Bump task expects one parameter')
100-
const clientGeneratorPath = join(import.meta.url, '..', '..', 'elastic-client-generator-js')
99+
assert(args.length === 1, 'Codegen task expects one parameter')
101100
const [version] = args
102101

102+
const clientGeneratorPath = join(import.meta.url, '..', '..', 'elastic-client-generator-js')
103103
const isGeneratorCloned = await $`[[ -d ${clientGeneratorPath} ]]`.exitCode === 0
104104
assert(isGeneratorCloned, 'You must clone the elastic-client-generator-js first')
105105

106106
await $`npm install --prefix ${clientGeneratorPath}`
107-
// this command will take a while!
107+
108+
// generate elasticsearch client. this command will take a while!
108109
if (version === 'main') {
109110
await $`npm run elasticsearch --prefix ${clientGeneratorPath} -- --version main`
110111
} else {
111112
await $`npm run elasticsearch --prefix ${clientGeneratorPath} -- --version ${version.split('.').slice(0, 2).join('.')}`
112113
}
113-
await $`npm run lint --prefix ${clientGeneratorPath}`
114+
// clean up fixable linter issues
115+
await $`npm run fix --prefix ${clientGeneratorPath}`
114116

115117
await $`rm -rf ${join(import.meta.url, '..', 'src', 'api')}`
116118
await $`mkdir ${join(import.meta.url, '..', 'src', 'api')}`

.ci/make.sh

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
#!/usr/bin/env bash
2-
32
# ------------------------------------------------------- #
43
#
5-
# Skeleton for common build entry script for all elastic
6-
# clients. Needs to be adapted to individual client usage.
4+
# Build entry script for elasticsearch-js
75
#
86
# Must be called: ./.ci/make.sh <target> <params>
97
#
108
# Version: 1.1.0
119
#
1210
# Targets:
1311
# ---------------------------
14-
# assemble <VERSION> : build client artefacts with version
15-
# bump <VERSION> : bump client internals to version
16-
# codegen <VERSION> : generate endpoints
17-
# docsgen <VERSION> : generate documentation
18-
# examplegen : generate the doc examples
19-
# clean : clean workspace
12+
# assemble <VERSION> : build client artifacts with version
13+
# bump <VERSION> : bump client internals to version
14+
# bumpmatrix <VERSION> : bump stack version in test matrix to version
15+
# codegen : generate endpoints
16+
# docsgen <VERSION> : generate documentation
17+
# examplegen : generate the doc examples
18+
# clean : clean workspace
2019
#
2120
# ------------------------------------------------------- #
2221

2322
# ------------------------------------------------------- #
2423
# Bootstrap
2524
# ------------------------------------------------------- #
26-
2725
script_path=$(dirname "$(realpath -s "$0")")
2826
repo=$(realpath "$script_path/../")
2927
generator=$(realpath "$script_path/../../elastic-client-generator-js")
@@ -34,24 +32,21 @@ TASK=$1
3432
TASK_ARGS=()
3533
VERSION=$2
3634
STACK_VERSION=$VERSION
37-
NODE_JS_VERSION=16
38-
WORKFLOW=${WORKFLOW-staging}
3935
set -euo pipefail
4036

4137
product="elastic/elasticsearch-js"
4238
output_folder=".ci/output"
39+
codegen_folder=".ci/output"
4340
OUTPUT_DIR="$repo/${output_folder}"
44-
REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
41+
# REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
42+
NODE_JS_VERSION=18
43+
WORKFLOW=${WORKFLOW-staging}
4544
mkdir -p "$OUTPUT_DIR"
4645

4746
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
4847
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
4948
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
5049

51-
# ------------------------------------------------------- #
52-
# Parse Command
53-
# ------------------------------------------------------- #
54-
5550
case $CMD in
5651
clean)
5752
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
@@ -104,8 +99,21 @@ case $CMD in
10499
# VERSION is BRANCH here for now
105100
TASK_ARGS=("$VERSION")
106101
;;
102+
bumpmatrix)
103+
if [ -v $VERSION ]; then
104+
echo -e "\033[31;1mTARGET: bumpmatrix -> missing version parameter\033[0m"
105+
exit 1
106+
fi
107+
echo -e "\033[36;1mTARGET: bump stack in test matrix to version $VERSION\033[0m"
108+
TASK=bumpmatrix
109+
TASK_ARGS=("$VERSION")
110+
;;
107111
*)
108-
echo -e "\nUsage:\n\t $CMD is not supported right now\n"
112+
echo -e "\n'$CMD' is not supported right now\n"
113+
echo -e "\nUsage:"
114+
echo -e "\t $0 release \$VERSION\n"
115+
echo -e "\t $0 bump \$VERSION"
116+
echo -e "\t $0 codegen \$VERSION"
109117
exit 1
110118
esac
111119

@@ -118,10 +126,8 @@ echo -e "\033[34;1mINFO: building $product container\033[0m"
118126

119127
docker build \
120128
--file .ci/Dockerfile \
121-
--tag ${product} \
122-
--build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \
123-
--build-arg USER_ID="$(id -u)" \
124-
--build-arg GROUP_ID="$(id -g)" \
129+
--tag "$product" \
130+
--build-arg NODE_JS_VERSION="$NODE_JS_VERSION" \
125131
.
126132

127133
# ------------------------------------------------------- #
@@ -131,14 +137,15 @@ docker build \
131137
echo -e "\033[34;1mINFO: running $product container\033[0m"
132138

133139
docker run \
134-
--volume $repo:/usr/src/app \
135-
--volume $generator:/usr/src/elastic-client-generator-js \
140+
--volume "$repo:/usr/src/app" \
141+
--volume "$generator:/usr/src/elastic-client-generator-js" \
136142
--volume /usr/src/app/node_modules \
137-
--env "WORKFLOW=${WORKFLOW}" \
143+
-u "$(id -u):$(id -g)" \
144+
--env "WORKFLOW=$WORKFLOW" \
138145
--name make-elasticsearch-js \
139146
--rm \
140147
$product \
141-
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}
148+
node .ci/make.mjs --task $TASK "${TASK_ARGS[@]}"
142149

143150
# ------------------------------------------------------- #
144151
# Post Command tasks & checks

0 commit comments

Comments
 (0)