From 74da9bf9b4a3ca3baa01bff42a81649cd6001bc2 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Sun, 4 Oct 2026 06:30:10 +0300 Subject: [PATCH 1/3] fix(vip-cli): vip-cli may require a compiler --- .../src/vip-cli/devcontainer-feature.json | 2 +- features/src/vip-cli/install.sh | 98 +++++++++++++------ 2 files changed, 69 insertions(+), 31 deletions(-) diff --git a/features/src/vip-cli/devcontainer-feature.json b/features/src/vip-cli/devcontainer-feature.json index a35709c1..36ec5fc5 100644 --- a/features/src/vip-cli/devcontainer-feature.json +++ b/features/src/vip-cli/devcontainer-feature.json @@ -1,7 +1,7 @@ { "id": "vip-cli", "name": "VIP-CLI", - "version": "1.5.0", + "version": "1.5.1", "description": "Installs VIP-CLI into the Dev Environment", "options": { "enabled": { diff --git a/features/src/vip-cli/install.sh b/features/src/vip-cli/install.sh index c1771cea..2b68195b 100755 --- a/features/src/vip-cli/install.sh +++ b/features/src/vip-cli/install.sh @@ -18,7 +18,7 @@ if [ "${ENABLED}" = "true" ]; then install -d -D -m 0755 /usr/local/etc/vscode-dev-containers/vip-codespaces/vip-cli install -m 0644 devcontainer-feature.json devcontainer-features.env /usr/local/etc/vscode-dev-containers/vip-codespaces/vip-cli/ - if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1; then + if ! hash node > /dev/null 2>&1 || ! hash npm > /dev/null 2>&1; then # shellcheck source=/dev/null . /etc/os-release @@ -28,43 +28,66 @@ if [ "${ENABLED}" = "true" ]; then case "${ID_LIKE}" in "debian") export DEBIAN_FRONTEND=noninteractive + PACKAGES="" + if ! hash curl > /dev/null 2>&1; then + PACKAGES="${PACKAGES} curl" + fi - if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1 || ! hash npx >/dev/null 2>&1; then - 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/* + if ! hash update-ca-certificates > /dev/null 2>&1; then + PACKAGES="${PACKAGES} ca-certificates" fi - ;; - "alpine") - if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1; then - apk add --no-cache nodejs npm + 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 + + CLEAN="" + if ! hash g++ > /dev/null 2>&1; then + # shellcheck source=/dev/null + . /etc/os-release + + : "${ID:=}" + : "${ID_LIKE:=${ID}}" + + case "${ID_LIKE}" in + "debian") + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends g++ + CLEAN=1 + ;; + + "alpine") + apk add --no-cache g++ + CLEAN=1 + ;; + + *) + echo "(!) Unsupported distribution: ${ID}" + exit 1 + ;; esac fi @@ -72,5 +95,20 @@ if [ "${ENABLED}" = "true" ]; then install -D -m 0755 -o root -g root vip-sync-db.sh /usr/local/bin/vip-sync-db + if [ -n "${CLEAN}" ]; then + # shellcheck source=/dev/null + . /etc/os-release + : "${ID:=}" + : "${ID_LIKE:=${ID}}" + + if [ "${ID_LIKE}" = "debian" ]; then + apt-get remove -y --purge g++ + apt-get clean + rm -rf /var/lib/apt/lists/* + elif [ "${ID_LIKE}" = "alpine" ]; then + apk del --no-cache g++ + fi + fi + echo 'Done!' fi From 4351897e2abd3b26cb578765364200a89ff72cf5 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Sun, 4 Oct 2026 06:37:22 +0300 Subject: [PATCH 2/3] fix(vip-cli): `make` is also required --- features/src/vip-cli/install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/src/vip-cli/install.sh b/features/src/vip-cli/install.sh index 2b68195b..9e0dddd5 100755 --- a/features/src/vip-cli/install.sh +++ b/features/src/vip-cli/install.sh @@ -75,12 +75,12 @@ if [ "${ENABLED}" = "true" ]; then "debian") export DEBIAN_FRONTEND=noninteractive apt-get update - apt-get install -y --no-install-recommends g++ + apt-get install -y --no-install-recommends g++ make CLEAN=1 ;; "alpine") - apk add --no-cache g++ + apk add --no-cache g++ make CLEAN=1 ;; @@ -102,11 +102,11 @@ if [ "${ENABLED}" = "true" ]; then : "${ID_LIKE:=${ID}}" if [ "${ID_LIKE}" = "debian" ]; then - apt-get remove -y --purge g++ + apt-get remove -y --purge g++ make apt-get clean rm -rf /var/lib/apt/lists/* elif [ "${ID_LIKE}" = "alpine" ]; then - apk del --no-cache g++ + apk del --no-cache g++ make fi fi From 78df1ed1f01bd1fb00eb3c4b6774afcf32800b5e Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Sun, 4 Oct 2026 06:46:33 +0300 Subject: [PATCH 3/3] refactor(vip-cli): more robust approach --- features/src/vip-cli/install.sh | 135 +++++++++++++++++--------------- 1 file changed, 71 insertions(+), 64 deletions(-) diff --git a/features/src/vip-cli/install.sh b/features/src/vip-cli/install.sh index 9e0dddd5..4242d45c 100755 --- a/features/src/vip-cli/install.sh +++ b/features/src/vip-cli/install.sh @@ -18,17 +18,19 @@ if [ "${ENABLED}" = "true" ]; then install -d -D -m 0755 /usr/local/etc/vscode-dev-containers/vip-codespaces/vip-cli install -m 0644 devcontainer-feature.json devcontainer-features.env /usr/local/etc/vscode-dev-containers/vip-codespaces/vip-cli/ - if ! hash node > /dev/null 2>&1 || ! hash npm > /dev/null 2>&1; then - # shellcheck source=/dev/null - . /etc/os-release + # shellcheck source=/dev/null + . /etc/os-release - : "${ID:=}" - : "${ID_LIKE:=${ID}}" + : "${ID:=}" + : "${ID_LIKE:=${ID}}" - case "${ID_LIKE}" in - "debian") - export DEBIAN_FRONTEND=noninteractive - PACKAGES="" + TMP_PKGS="" + + case "${ID_LIKE}" in + "debian") + export DEBIAN_FRONTEND=noninteractive + PACKAGES="" + if ! hash node > /dev/null 2>&1 || ! hash npm > /dev/null 2>&1 || ! hash npx > /dev/null 2>&1; then if ! hash curl > /dev/null 2>&1; then PACKAGES="${PACKAGES} curl" fi @@ -36,77 +38,82 @@ if [ "${ENABLED}" = "true" ]; then if ! hash update-ca-certificates > /dev/null 2>&1; then PACKAGES="${PACKAGES} ca-certificates" fi + fi - if [ -n "${PACKAGES}" ]; then - apt-get update - # shellcheck disable=SC2086 - apt-get install -y --no-install-recommends ${PACKAGES} - fi + if [ -n "${PACKAGES}" ]; then + apt-get update + # shellcheck disable=SC2086 + apt-get install -y --no-install-recommends ${PACKAGES} + fi + if ! hash node > /dev/null 2>&1 || ! hash npm > /dev/null 2>&1 || ! hash npx > /dev/null 2>&1; then 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 + fi - apt-get clean - rm -rf /var/lib/apt/lists/* - ;; + if ! hash g++ > /dev/null 2>&1; then + TMP_PKGS="${TMP_PKGS} g++" + fi - "alpine") - apk add --no-cache nodejs npm - ;; - - *) - echo "(!) Unsupported distribution: ${ID}" - exit 1 - ;; - esac - fi + if ! hash make > /dev/null 2>&1; then + TMP_PKGS="${TMP_PKGS} make" + fi - CLEAN="" - if ! hash g++ > /dev/null 2>&1; then - # shellcheck source=/dev/null - . /etc/os-release + if ! hash python3 > /dev/null 2>&1; then + TMP_PKGS="${TMP_PKGS} python3" + fi - : "${ID:=}" - : "${ID_LIKE:=${ID}}" - - case "${ID_LIKE}" in - "debian") - export DEBIAN_FRONTEND=noninteractive + if [ -n "${TMP_PKGS}" ]; then apt-get update - apt-get install -y --no-install-recommends g++ make - CLEAN=1 - ;; - - "alpine") - apk add --no-cache g++ make - CLEAN=1 - ;; - - *) - echo "(!) Unsupported distribution: ${ID}" - exit 1 - ;; - esac - fi + # shellcheck disable=SC2086 + apt-get install -y --no-install-recommends ${TMP_PKGS} + fi + ;; + + "alpine") + apk add --no-cache nodejs npm + if ! hash g++ > /dev/null 2>&1; then + TMP_PKGS="${TMP_PKGS} g++" + fi + + if ! hash make > /dev/null 2>&1; then + TMP_PKGS="${TMP_PKGS} make" + fi + + if ! hash python3 > /dev/null 2>&1; then + TMP_PKGS="${TMP_PKGS} python3" + fi + + if [ -n "${TMP_PKGS}" ]; then + # shellcheck disable=SC2086 + apk add --no-cache ${TMP_PKGS} + fi + ;; + + *) + echo "(!) Unsupported distribution: ${ID}" + exit 1 + ;; + esac 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 - if [ -n "${CLEAN}" ]; then - # shellcheck source=/dev/null - . /etc/os-release - : "${ID:=}" - : "${ID_LIKE:=${ID}}" - - if [ "${ID_LIKE}" = "debian" ]; then - apt-get remove -y --purge g++ make - apt-get clean - rm -rf /var/lib/apt/lists/* - elif [ "${ID_LIKE}" = "alpine" ]; then - apk del --no-cache g++ make + if [ "${ID_LIKE}" = "debian" ]; then + if [ -n "${TMP_PKGS}" ]; then + # shellcheck disable=SC2086 + apt-get remove -y --purge ${TMP_PKGS} + fi + + apt-get clean + rm -rf /var/lib/apt/lists/* + elif [ "${ID_LIKE}" = "alpine" ]; then + if [ -n "${TMP_PKGS}" ]; then + # shellcheck disable=SC2086 + apk del --no-cache ${TMP_PKGS} fi fi