Skip to content

Commit

Permalink
chore: make install-plugins POSIX
Browse files Browse the repository at this point in the history
Instead of relying on `bash` (which may not be installed, such as in
alpine images), use POSIX bash.

Signed-off-by: JP-Ellis <[email protected]>
  • Loading branch information
JP-Ellis committed Dec 16, 2024
1 parent fc04239 commit af75965
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"release": "commit-and-tag-version",
"test": "mocha",
"coverage": "nyc npm run test",
"pretest": "bash scripts/install-plugins.sh",
"pretest": "./scripts/install-plugins",
"docker:alpine:build": "docker build --build-arg NODE_VERSION=${NODE_VERSION:-current} -f Dockerfile.alpine -t pact-js:alpine .",
"docker:debian:build": "docker build --build-arg NODE_VERSION=${NODE_VERSION:-current} -f Dockerfile.debian -t pact-js:debian .",
"docker:alpine:run": "docker run -e LOG_LEVEL=${LOG_LEVEL:-info} -e GIT_REF=${GIT_REF:-test} -e GITHUB_ACTIONS=${GITHUB_ACTIONS:-false} -e SKIP_EXAMPLES=${SKIP_EXAMPLES:-''} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN -w /home -v $(pwd):/home --rm pact-js:alpine",
Expand Down
59 changes: 59 additions & 0 deletions scripts/install-plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh
#
# Usage:
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh | bash
# or
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh -O- | bash

set -o errexit # Exit on error
set -o nounset # Treat unset variables as an error

detect_osarch() {
case $(uname -sm) in
'Linux x86_64')
os='linux'
arch='x86_64'
;;
'Linux aarch64')
os='linux'
arch='aarch64'
;;
'Darwin x86' | 'Darwin x86_64')
os='osx'
arch='x86_64'
;;
'Darwin arm64')
os='osx'
arch='aarch64'
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*)
os="windows"
arch='x86_64'
ext='.exe'
;;
*)
echo "Sorry, you'll need to install the plugin CLI manually."
exit 1
;;
esac
}

VERSION="0.1.2"
detect_osarch

if [ ! -f ~/.pact/bin/pact-plugin-cli ]; then
echo "--- 🐿 Installing plugins CLI version '${VERSION}' (from tag ${TAG})"
mkdir -p ~/.pact/bin
DOWNLOAD_LOCATION=https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-${os}-${arch}${ext}.gz
echo " Downloading from: ${DOWNLOAD_LOCATION}"
curl -L -o ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz "${DOWNLOAD_LOCATION}"
echo " Downloaded $(file ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz)"
gunzip -f ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz
mv ~/.pact/bin/pact-plugin-cli-${os}-${arch} ~/.pact/bin/pact-plugin-cli
chmod +x ~/.pact/bin/pact-plugin-cli
fi

if [ ! -d ~/.pact/plugins/matt-0.1.1 ]; then
echo "--- 🐿 Installing MATT plugin"
~/.pact/bin/pact-plugin-cli install https://github.com/mefellows/pact-matt-plugin/releases/tag/v0.1.1
fi
59 changes: 0 additions & 59 deletions scripts/install-plugins.sh

This file was deleted.

0 comments on commit af75965

Please sign in to comment.