Skip to content

Commit

Permalink
Merge pull request #189 from Automattic/update/vip
Browse files Browse the repository at this point in the history
refactor(vip-cli): support Debian-based distros
  • Loading branch information
sjinks authored May 27, 2024
2 parents f782d4a + 1cc8c5b commit 2899c79
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion features/src/vip-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "vip-cli",
"name": "VIP-CLI",
"version": "1.4.1",
"version": "1.4.2",
"description": "Installs VIP-CLI into the Dev Environment",
"options": {
"enabled": {
Expand Down
50 changes: 48 additions & 2 deletions features/src/vip-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,54 @@ fi
if [ "${ENABLED}" = "true" ]; then
echo '(*) Installing VIP CLI...'

apk add --no-cache nodejs npm
npm i -g "@automattic/vip@${VERSION}"
# /etc/os-release may overwrite VERSION
VIP_CLI_VERSION="${VERSION}"

if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1; then
# shellcheck source=/dev/null
. /etc/os-release

: "${ID:=}"
: "${ID_LIKE:=${ID}}"

case "${ID_LIKE}" in
"debian")
PACKAGES=""

if ! hash curl >/dev/null 2>&1; then
PACKAGES="${PACKAGES} curl"
fi

if ! hash update-ca-certificates >/dev/null 2>&1; then
PACKAGES="${PACKAGES} ca-certificates"
fi

if [ -n "${PACKAGES}" ]; then
apt-get update
# shellcheck disable=SC2086
apt-get install -y --no-install-recommends ${PACKAGES}
fi

curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh && chmod +x nodesource_setup.sh
./nodesource_setup.sh
apt-get install -y nodejs

apt-get clean
rm -rf /var/lib/apt/lists/*
;;

"alpine")
apk add --no-cache nodejs npm
;;

*)
echo "(!) Unsupported distribution: ${ID}"
exit 1
;;
esac
fi

npm i -g "@automattic/vip@${VIP_CLI_VERSION+}"

install -D -m 0755 -o root -g root vip-sync-db.sh /usr/local/bin/vip-sync-db

Expand Down

0 comments on commit 2899c79

Please sign in to comment.