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
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
ARG NODE_JS_VERSION=16
|
ARG NODE_JS_VERSION=18
|
||||||
FROM node:${NODE_JS_VERSION}
|
FROM node:${NODE_JS_VERSION}
|
||||||
|
|
||||||
# Create app directory
|
# Create app directory
|
||||||
|
|||||||
10
.ci/make.mjs
10
.ci/make.mjs
@ -96,21 +96,23 @@ async function bump (args) {
|
|||||||
|
|
||||||
// this command can only be executed locally for now
|
// this command can only be executed locally for now
|
||||||
async function codegen (args) {
|
async function codegen (args) {
|
||||||
assert(args.length === 1, 'Bump task expects one parameter')
|
assert(args.length === 1, 'Codegen task expects one parameter')
|
||||||
const clientGeneratorPath = join(import.meta.url, '..', '..', 'elastic-client-generator-js')
|
|
||||||
const [version] = args
|
const [version] = args
|
||||||
|
|
||||||
|
const clientGeneratorPath = join(import.meta.url, '..', '..', 'elastic-client-generator-js')
|
||||||
const isGeneratorCloned = await $`[[ -d ${clientGeneratorPath} ]]`.exitCode === 0
|
const isGeneratorCloned = await $`[[ -d ${clientGeneratorPath} ]]`.exitCode === 0
|
||||||
assert(isGeneratorCloned, 'You must clone the elastic-client-generator-js first')
|
assert(isGeneratorCloned, 'You must clone the elastic-client-generator-js first')
|
||||||
|
|
||||||
await $`npm install --prefix ${clientGeneratorPath}`
|
await $`npm install --prefix ${clientGeneratorPath}`
|
||||||
// this command will take a while!
|
|
||||||
|
// generate elasticsearch client. this command will take a while!
|
||||||
if (version === 'main') {
|
if (version === 'main') {
|
||||||
await $`npm run elasticsearch --prefix ${clientGeneratorPath} -- --version main`
|
await $`npm run elasticsearch --prefix ${clientGeneratorPath} -- --version main`
|
||||||
} else {
|
} else {
|
||||||
await $`npm run elasticsearch --prefix ${clientGeneratorPath} -- --version ${version.split('.').slice(0, 2).join('.')}`
|
await $`npm run elasticsearch --prefix ${clientGeneratorPath} -- --version ${version.split('.').slice(0, 2).join('.')}`
|
||||||
}
|
}
|
||||||
await $`npm run lint --prefix ${clientGeneratorPath}`
|
// clean up fixable linter issues
|
||||||
|
await $`npm run fix --prefix ${clientGeneratorPath}`
|
||||||
|
|
||||||
await $`rm -rf ${join(import.meta.url, '..', 'src', 'api')}`
|
await $`rm -rf ${join(import.meta.url, '..', 'src', 'api')}`
|
||||||
await $`mkdir ${join(import.meta.url, '..', 'src', 'api')}`
|
await $`mkdir ${join(import.meta.url, '..', 'src', 'api')}`
|
||||||
|
|||||||
59
.ci/make.sh
59
.ci/make.sh
@ -1,9 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# ------------------------------------------------------- #
|
# ------------------------------------------------------- #
|
||||||
#
|
#
|
||||||
# Skeleton for common build entry script for all elastic
|
# Build entry script for elasticsearch-js
|
||||||
# clients. Needs to be adapted to individual client usage.
|
|
||||||
#
|
#
|
||||||
# Must be called: ./.ci/make.sh <target> <params>
|
# Must be called: ./.ci/make.sh <target> <params>
|
||||||
#
|
#
|
||||||
@ -11,19 +9,19 @@
|
|||||||
#
|
#
|
||||||
# Targets:
|
# Targets:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# assemble <VERSION> : build client artefacts with version
|
# assemble <VERSION> : build client artifacts with version
|
||||||
# bump <VERSION> : bump client internals to version
|
# bump <VERSION> : bump client internals to version
|
||||||
# codegen <VERSION> : generate endpoints
|
# bumpmatrix <VERSION> : bump stack version in test matrix to version
|
||||||
# docsgen <VERSION> : generate documentation
|
# codegen : generate endpoints
|
||||||
# examplegen : generate the doc examples
|
# docsgen <VERSION> : generate documentation
|
||||||
# clean : clean workspace
|
# examplegen : generate the doc examples
|
||||||
|
# clean : clean workspace
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------- #
|
# ------------------------------------------------------- #
|
||||||
|
|
||||||
# ------------------------------------------------------- #
|
# ------------------------------------------------------- #
|
||||||
# Bootstrap
|
# Bootstrap
|
||||||
# ------------------------------------------------------- #
|
# ------------------------------------------------------- #
|
||||||
|
|
||||||
script_path=$(dirname "$(realpath -s "$0")")
|
script_path=$(dirname "$(realpath -s "$0")")
|
||||||
repo=$(realpath "$script_path/../")
|
repo=$(realpath "$script_path/../")
|
||||||
generator=$(realpath "$script_path/../../elastic-client-generator-js")
|
generator=$(realpath "$script_path/../../elastic-client-generator-js")
|
||||||
@ -34,24 +32,21 @@ TASK=$1
|
|||||||
TASK_ARGS=()
|
TASK_ARGS=()
|
||||||
VERSION=$2
|
VERSION=$2
|
||||||
STACK_VERSION=$VERSION
|
STACK_VERSION=$VERSION
|
||||||
NODE_JS_VERSION=16
|
|
||||||
WORKFLOW=${WORKFLOW-staging}
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
product="elastic/elasticsearch-js"
|
product="elastic/elasticsearch-js"
|
||||||
output_folder=".ci/output"
|
output_folder=".ci/output"
|
||||||
|
codegen_folder=".ci/output"
|
||||||
OUTPUT_DIR="$repo/${output_folder}"
|
OUTPUT_DIR="$repo/${output_folder}"
|
||||||
REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
|
# REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
|
||||||
|
NODE_JS_VERSION=18
|
||||||
|
WORKFLOW=${WORKFLOW-staging}
|
||||||
mkdir -p "$OUTPUT_DIR"
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
|
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
|
||||||
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
|
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
|
||||||
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
|
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
|
||||||
|
|
||||||
# ------------------------------------------------------- #
|
|
||||||
# Parse Command
|
|
||||||
# ------------------------------------------------------- #
|
|
||||||
|
|
||||||
case $CMD in
|
case $CMD in
|
||||||
clean)
|
clean)
|
||||||
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
|
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
|
||||||
@ -104,8 +99,21 @@ case $CMD in
|
|||||||
# VERSION is BRANCH here for now
|
# VERSION is BRANCH here for now
|
||||||
TASK_ARGS=("$VERSION")
|
TASK_ARGS=("$VERSION")
|
||||||
;;
|
;;
|
||||||
|
bumpmatrix)
|
||||||
|
if [ -v $VERSION ]; then
|
||||||
|
echo -e "\033[31;1mTARGET: bumpmatrix -> missing version parameter\033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "\033[36;1mTARGET: bump stack in test matrix to version $VERSION\033[0m"
|
||||||
|
TASK=bumpmatrix
|
||||||
|
TASK_ARGS=("$VERSION")
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\nUsage:\n\t $CMD is not supported right now\n"
|
echo -e "\n'$CMD' is not supported right now\n"
|
||||||
|
echo -e "\nUsage:"
|
||||||
|
echo -e "\t $0 release \$VERSION\n"
|
||||||
|
echo -e "\t $0 bump \$VERSION"
|
||||||
|
echo -e "\t $0 codegen \$VERSION"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -118,10 +126,8 @@ echo -e "\033[34;1mINFO: building $product container\033[0m"
|
|||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--file .ci/Dockerfile \
|
--file .ci/Dockerfile \
|
||||||
--tag ${product} \
|
--tag "$product" \
|
||||||
--build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \
|
--build-arg NODE_JS_VERSION="$NODE_JS_VERSION" \
|
||||||
--build-arg USER_ID="$(id -u)" \
|
|
||||||
--build-arg GROUP_ID="$(id -g)" \
|
|
||||||
.
|
.
|
||||||
|
|
||||||
# ------------------------------------------------------- #
|
# ------------------------------------------------------- #
|
||||||
@ -131,14 +137,15 @@ docker build \
|
|||||||
echo -e "\033[34;1mINFO: running $product container\033[0m"
|
echo -e "\033[34;1mINFO: running $product container\033[0m"
|
||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
--volume $repo:/usr/src/app \
|
--volume "$repo:/usr/src/app" \
|
||||||
--volume $generator:/usr/src/elastic-client-generator-js \
|
--volume "$generator:/usr/src/elastic-client-generator-js" \
|
||||||
--volume /usr/src/app/node_modules \
|
--volume /usr/src/app/node_modules \
|
||||||
--env "WORKFLOW=${WORKFLOW}" \
|
-u "$(id -u):$(id -g)" \
|
||||||
|
--env "WORKFLOW=$WORKFLOW" \
|
||||||
--name make-elasticsearch-js \
|
--name make-elasticsearch-js \
|
||||||
--rm \
|
--rm \
|
||||||
$product \
|
$product \
|
||||||
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}
|
node .ci/make.mjs --task $TASK "${TASK_ARGS[@]}"
|
||||||
|
|
||||||
# ------------------------------------------------------- #
|
# ------------------------------------------------------- #
|
||||||
# Post Command tasks & checks
|
# Post Command tasks & checks
|
||||||
|
|||||||
Reference in New Issue
Block a user