From b5fba92f91a931a8a01b5ae479232a5165ca1ef7 Mon Sep 17 00:00:00 2001 From: Shikanime Deva Date: Wed, 9 Aug 2023 09:59:58 +0000 Subject: [PATCH 1/5] Avoid unexpected shell expansion --- src/node/install.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/node/install.sh b/src/node/install.sh index 9048ac22e..1ce8fee3f 100755 --- a/src/node/install.sh +++ b/src/node/install.sh @@ -9,7 +9,7 @@ export NODE_VERSION="${VERSION:-"lts"}" export NVM_VERSION="${NVMVERSION:-"0.39.2"}" -export NVM_DIR=${NVMINSTALLPATH:-"/usr/local/share/nvm"} +export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}" INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}" # Comma-separated list of node versions to be installed (with nvm) @@ -118,10 +118,10 @@ set -e umask 0002 # Do not update profile - we'll do this manually export PROFILE=/dev/null -curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash -source ${NVM_DIR}/nvm.sh +curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash +source "${NVM_DIR}/nvm.sh" if [ "${NODE_VERSION}" != "" ]; then - nvm alias default ${NODE_VERSION} + nvm alias default "${NODE_VERSION}" fi EOF )" @@ -149,9 +149,9 @@ usermod -a -G nvm ${USERNAME} umask 0002 if [ ! -d "${NVM_DIR}" ]; then # Create nvm dir, and set sticky bit - mkdir -p ${NVM_DIR} - chown "${USERNAME}:nvm" ${NVM_DIR} - chmod g+rws ${NVM_DIR} + mkdir -p "${NVM_DIR}" + chown "${USERNAME}:nvm" "${NVM_DIR}" + chmod g+rws "${NVM_DIR}" su ${USERNAME} -c "${nvm_install_snippet}" 2>&1 # Update rc files if [ "${UPDATE_RC}" = "true" ]; then @@ -160,11 +160,11 @@ if [ ! -d "${NVM_DIR}" ]; then else echo "NVM already installed." if [ "${NODE_VERSION}" != "" ]; then - su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm alias default ${NODE_VERSION}" + su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm install '${NODE_VERSION}' && nvm alias default '${NODE_VERSION}'" fi fi -# Additional node versions to be installed but not be set as +# Additional node versions to be installed but not be set as # default we can assume the nvm is the group owner of the nvm # directory and the sticky bit on directories so any installed # files will have will have the correct ownership (nvm) @@ -173,12 +173,12 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then IFS="," read -a additional_versions <<< "$ADDITIONAL_VERSIONS" for ver in "${additional_versions[@]}"; do - su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm install ${ver}" + su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm install '${ver}'" done # Ensure $NODE_VERSION is on the $PATH if [ "${NODE_VERSION}" != "" ]; then - su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm use default" + su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm use default" fi IFS=$OLDIFS fi @@ -218,7 +218,7 @@ fi # Clean up -su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm clear-cache" +su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm clear-cache" rm -rf /var/lib/apt/lists/* # Ensure privs are correct for installed node versions. Unfortunately the From 4c8b692257d2fc08585a22a091acd95a8d4237f4 Mon Sep 17 00:00:00 2001 From: Shikanime Deva Date: Wed, 9 Aug 2023 10:23:27 +0000 Subject: [PATCH 2/5] Add install Node with ZSH as default test --- test/node/scenarios.json | 11 +++++++++++ test/node/zsh_default.sh | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 test/node/zsh_default.sh diff --git a/test/node/scenarios.json b/test/node/scenarios.json index 6112a6ea4..fb90b22be 100644 --- a/test/node/scenarios.json +++ b/test/node/scenarios.json @@ -17,6 +17,17 @@ } } }, + "zsh_default": { + "image": "mcr.microsoft.com/devcontainers/base", + "features": { + "node": { + "version": "lts" + }, + "common-utils": { + "configureZshAsDefaultShell": true + } + } + }, "version_none": { "image": "mcr.microsoft.com/devcontainers/base", "remoteUser": "vscode", diff --git a/test/node/zsh_default.sh b/test/node/zsh_default.sh new file mode 100755 index 000000000..c7c9e57f4 --- /dev/null +++ b/test/node/zsh_default.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10" + +# Report result +reportResults From 516be4664fa5fb80954e7626d3fe43c33b14f547 Mon Sep 17 00:00:00 2001 From: Shikanime Deva Date: Wed, 9 Aug 2023 19:15:59 +0000 Subject: [PATCH 3/5] Fix LTS only work on >bionic --- test/node/scenarios.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/node/scenarios.json b/test/node/scenarios.json index fb90b22be..f659adb76 100644 --- a/test/node/scenarios.json +++ b/test/node/scenarios.json @@ -18,7 +18,7 @@ } }, "zsh_default": { - "image": "mcr.microsoft.com/devcontainers/base", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "node": { "version": "lts" @@ -54,4 +54,4 @@ } } } -} +} \ No newline at end of file From 5128a41391094f5423c781c8ccd4fe6d4ae094fc Mon Sep 17 00:00:00 2001 From: Shikanime Deva Date: Wed, 9 Aug 2023 19:16:11 +0000 Subject: [PATCH 4/5] Bump Node feature version --- src/node/devcontainer-feature.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json index 9bf90b67f..80bd91275 100644 --- a/src/node/devcontainer-feature.json +++ b/src/node/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "node", - "version": "1.2.0", + "version": "1.2.1", "name": "Node.js (via nvm), yarn and pnpm", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/node", "description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.", @@ -49,4 +49,4 @@ "installsAfter": [ "ghcr.io/devcontainers/features/common-utils" ] -} +} \ No newline at end of file From f136ceecbc33b3ce6917244bc82aa764d8c93416 Mon Sep 17 00:00:00 2001 From: Shikanime Deva Date: Wed, 9 Aug 2023 22:51:01 +0000 Subject: [PATCH 5/5] Remove huge universal image on scenarios --- test/node/scenarios.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/node/scenarios.json b/test/node/scenarios.json index f659adb76..5524f5c52 100644 --- a/test/node/scenarios.json +++ b/test/node/scenarios.json @@ -37,15 +37,6 @@ } } }, - "install_node_on_universal_image": { - "image": "mcr.microsoft.com/devcontainers/universal", - "remoteUser": "codespace", - "features": { - "node": { - "version": "19.1.0" - } - } - }, "install_node_16_on_bionic": { "image": "mcr.microsoft.com/devcontainers/base:ubuntu-18.04", "features": {