Skip to content

Commit

Permalink
Features update logic for PPA in bionic (#1079)
Browse files Browse the repository at this point in the history
* Features update logic for PPA in bionic

* node failing fixed after pnpm install from npm package manager

* for node version 16 pnpm version 7 is installed

* uninstalled pnpm package first and then reinstalled as per node version

* force installing pnpm package

* optimized logic to install compatible pnpm for node 16

* pnpm install specific version compatible for node

* new variable added pnpmVersion in node feature

* test case failure fixed

* fixed test cases

* fixing test cases

* pnpm version fixed for test cases

* default version for pnpm updated

* review comments addressed

* Update src/node/devcontainer-feature.json

---------

Co-authored-by: Samruddhi Khandale <[email protected]>
  • Loading branch information
prathameshzarkar9 and samruddhikhandale authored Aug 27, 2024
1 parent 07dc028 commit 52c79b4
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 17 deletions.
8 changes: 8 additions & 0 deletions src/common-utils/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
fi

if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then
# As of 1 July 2024, mirrorlist.centos.org no longer exists.
# Update the repo files to reference vault.centos.org.
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
fi

# Install packages for appropriate OS
case "${ADJUSTED_ID}" in
"debian")
Expand Down
8 changes: 8 additions & 0 deletions src/go/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ else
exit 1
fi

if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then
# As of 1 July 2024, mirrorlist.centos.org no longer exists.
# Update the repo files to reference vault.centos.org.
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
fi

# Setup INSTALL_CMD & PKG_MGR_CMD
if type apt-get > /dev/null 2>&1; then
PKG_MGR_CMD=apt-get
Expand Down
16 changes: 15 additions & 1 deletion src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "node",
"version": "1.5.0",
"version": "1.6.0",
"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.",
Expand Down Expand Up @@ -28,6 +28,20 @@
"default": "/usr/local/share/nvm",
"description": "The path where NVM will be installed."
},
"pnpmVersion": {
"type": "string",
"proposals": [
"latest",
"8.8.0",
"8.0.0",
"7.30.0",
"6.14.8",
"5.18.10",
"none"
],
"default": "latest",
"description": "Select or enter the PNPM version to install"
},
"nvmVersion": {
"type": "string",
"proposals": [
Expand Down
15 changes: 12 additions & 3 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Maintainer: The Dev Container spec maintainers

export NODE_VERSION="${VERSION:-"lts"}"
export PNPM_VERSION="${PNPMVERSION:-"latest"}"
export NVM_VERSION="${NVMVERSION:-"latest"}"
export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}"
INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}"
Expand Down Expand Up @@ -45,6 +46,14 @@ else
exit 1
fi

if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then
# As of 1 July 2024, mirrorlist.centos.org no longer exists.
# Update the repo files to reference vault.centos.org.
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
fi

# Setup INSTALL_CMD & PKG_MGR_CMD
if type apt-get > /dev/null 2>&1; then
PKG_MGR_CMD=apt-get
Expand Down Expand Up @@ -370,16 +379,16 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
fi

# Install pnpm
if bash -c ". '${NVM_DIR}/nvm.sh' && type pnpm >/dev/null 2>&1"; then
echo "pnpm already installed."
if [ ! -z "${PNPM_VERSION}" ] && [ "${PNPM_VERSION}" = "none" ]; then
echo "Ignoring installation of PNPM"
else
if bash -c ". '${NVM_DIR}/nvm.sh' && type npm >/dev/null 2>&1"; then
(
. "${NVM_DIR}/nvm.sh"
[ ! -z "$http_proxy" ] && npm set proxy="$http_proxy"
[ ! -z "$https_proxy" ] && npm set https-proxy="$https_proxy"
[ ! -z "$no_proxy" ] && npm set noproxy="$no_proxy"
npm install -g pnpm
npm install -g pnpm@$PNPM_VERSION --force
)
else
echo "Skip installing pnpm because npm is missing"
Expand Down
2 changes: 1 addition & 1 deletion src/python/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "python",
"version": "1.6.3",
"version": "1.6.4",
"name": "Python",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/python",
"description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.",
Expand Down
8 changes: 8 additions & 0 deletions src/python/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ else
exit 1
fi

if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then
# As of 1 July 2024, mirrorlist.centos.org no longer exists.
# Update the repo files to reference vault.centos.org.
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
fi

# To find some devel packages, some rhel need to enable specific extra repos, but not on RedHat ubi images...
INSTALL_CMD_ADDL_REPO=""
if [ ${ADJUSTED_ID} = "rhel" ] && [ ${ID} != "rhel" ]; then
Expand Down
2 changes: 1 addition & 1 deletion test/node/centos-7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib

# Definition specific tests
check "version" node --version
check "pnpm" pnpm -v
check "pnpm" bash -c "pnpm -v | grep 8.8.0"
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
check "yarn" yarn --version

Expand Down
2 changes: 1 addition & 1 deletion test/node/install_additional_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib

# 'lts' is now some version of node 20...
check "version_on_path" node -v | grep 20
check "pnpm" pnpm -v
check "pnpm" bash -c "pnpm -v | grep 8.8.0"

check "v20_installed" ls -1 /usr/local/share/nvm/versions/node | grep 20
check "v14_installed" ls -1 /usr/local/share/nvm/versions/node | grep 14.19.3
Expand Down
2 changes: 1 addition & 1 deletion test/node/install_additional_node_on_rhel_family.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib

# 'lts' is now some version of node 20...
check "version_on_path" node -v | grep 20
check "pnpm" pnpm -v
check "pnpm" bash -c "pnpm -v | grep 6.16.0"

check "v20_installed" ls -1 /usr/local/share/nvm/versions/node | grep 20
check "v14_installed" ls -1 /usr/local/share/nvm/versions/node | grep 14.19.3
Expand Down
2 changes: 1 addition & 1 deletion test/node/install_node_16_on_bionic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib

# Definition specific tests
check "version" bash -c "node --version | grep 16"
check "pnpm" pnpm -v
check "pnpm" bash -c "pnpm -v | grep 8.8.0"
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"

# Report result
Expand Down
2 changes: 1 addition & 1 deletion test/node/install_nvm_0.39.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib

# Definition specific tests
check "version" bash -c "node --version"
check "pnpm" pnpm -v
check "pnpm" bash -c "pnpm -v | grep 6.16.0"
check "nvm version" bash -c ". /usr/local/share/nvm/nvm.sh && nvm --version | grep 0.39"

# Report result
Expand Down
2 changes: 1 addition & 1 deletion test/node/non_root_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib

# Definition specific tests
check "version" node --version
check "pnpm" pnpm -v
check "pnpm" bash -c "pnpm -v | grep 8.8.0"
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"

# Report result
Expand Down
18 changes: 12 additions & 6 deletions test/node/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"features": {
"node": {
"version": "lts",
"additionalVersions": "v17.9.1,v14.19.3"
"additionalVersions": "v17.9.1,v14.19.3",
"pnpmVersion": "8.8.0"
}
}
},
Expand All @@ -21,7 +22,8 @@
"features": {
"node": {
"version": "lts",
"additionalVersions": "v17.9.1,v14.19.3"
"additionalVersions": "v17.9.1,v14.19.3",
"pnpmVersion": "6.16.0"
}
}
},
Expand All @@ -30,7 +32,8 @@
"remoteUser": "vscode",
"features": {
"node": {
"version": "latest"
"version": "latest",
"pnpmVersion": "8.8.0"
}
}
},
Expand Down Expand Up @@ -78,15 +81,17 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-18.04",
"features": {
"node": {
"version": "16"
"version": "16",
"pnpmVersion":"8.8.0"
}
}
},
"install_nvm_0.39": {
"image": "mcr.microsoft.com/devcontainers/base",
"features": {
"node": {
"nvmVersion": "0.39"
"nvmVersion": "0.39",
"pnpmVersion": "6.16.0"
}
}
},
Expand All @@ -102,7 +107,8 @@
"image": "centos:centos7",
"features": {
"node": {
"version": "16"
"version": "16",
"pnpmVersion": "8.8.0"
}
}
},
Expand Down

0 comments on commit 52c79b4

Please sign in to comment.