Skip to content

Commit

Permalink
chore: Add node22 Support
Browse files Browse the repository at this point in the history
Signed-off-by: Jefferson <jefferson.rios.caro@gmail.com>
  • Loading branch information
riosje committed Apr 24, 2024
1 parent 978daa5 commit 12be649
Show file tree
Hide file tree
Showing 12 changed files with 251 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [18, 20, 21]
version: [18, 20, 21, 22]
os: ["ubuntu:22.04", "debian:10"]
container:
image: ${{ matrix.os }}
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [18, 20, 21]
version: [18, 20, 21, 22]
os: ["fedora:36", "amazonlinux:2023", "rockylinux:9", "redhat/ubi9:latest"]
container:
image: ${{ matrix.os }}
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [18, 20, 21]
version: [18, 20, 21, 22]
os: ["rockylinux:9-minimal", "redhat/ubi9-minimal:latest"]
container:
image: ${{ matrix.os }}
Expand Down
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,41 +58,41 @@ NodeSource will continue to maintain the following architectures and may add add

#### **Ubuntu versions**

| Distro Name | Node 18x | Node 20x | Node 21x |
| :------------------- | :------: | :------: | :------: |
| Ubuntu Bionic ^18.04 ||||
| Ubuntu Focal ^20.04 ||||
| Ubuntu Jammy ^22.04 ||||
| Distro Name | Node 18x | Node 20x | Node 21x | Node 22x |
| :------------------- | :------: | :------: | :------: | :------: |
| Ubuntu Bionic ^18.04 |||||
| Ubuntu Focal ^20.04 |||||
| Ubuntu Jammy ^22.04 |||||

#### **Debian versions**

| Distro Name | Node 18x | Node 20x | Node 21x |
| :----------------- | :------: | :------: | :------: |
| Debian 8 Jessie ||||
| Debian 9 Stretch ||||
| Debian 10 Buster ||||
| Debian 11 Bullseye ||||
| Debian 12 Bookworm ||||
| Distro Name | Node 18x | Node 20x | Node 21x | Node 22x |
| :----------------- | :------: | :------: | :------: | :------: |
| Debian 8 Jessie |||||
| Debian 9 Stretch |||||
| Debian 10 Buster |||||
| Debian 11 Bullseye |||||
| Debian 12 Bookworm |||||

> _NOTE: If you are looking to run Node.js in a non-supported Linux version take a look to [Node.js Unofficial Builds](https://unofficial-builds.nodejs.org/)_
### Installation Instructions

#### Node.js

**Node.js v21.x**:
**Node.js v22.x**:

##### Using Ubuntu

```sh
curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
```

##### Using Debian, as root

```sh
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - &&\
apt-get install -y nodejs
```

Expand Down Expand Up @@ -185,47 +185,47 @@ NodeSource will continue to maintain the following architectures and may add add

#### **Fedora versions**

| Distro Name | Node 18x | Node 20x | Node 21x |
| :-------------------- | :------: | :------: | :------: |
| Fedora >= 20 (20->28) ||||
| Fedora >= 29 ||||
| Fedora >= 36 ||||
| Distro Name | Node 18x | Node 20x | Node 21x | Node 22x |
| :-------------------- | :------: | :------: | :------: | :------: |
| Fedora >= 20 (20->28) |||||
| Fedora >= 29 |||||
| Fedora >= 36 |||||

#### **Redhat versions**

| Distro Name | Node 18x | Node 20x | Node 21x |
|:-----------------| :------: | :------: | :------: |
| Redhat 7 ||||
| Redhat 8 ||||
| Redhat 9 ||||
| Redhat 9-minimal ||||
| Distro Name | Node 18x | Node 20x | Node 21x | Node 22x |
|:-----------------| :------: | :------: | :------: | :------: |
| Redhat 7 |||||
| Redhat 8 |||||
| Redhat 9 |||||
| Redhat 9-minimal |||||

#### **Amazon Linux versions**

| Distro Name | Node 18x | Node 20x | Node 21x |
| :---------------- | :------: | :------: | :------: |
| Amazon Linux 2 ||||
| Amazon Linux 2023 ||||
| Distro Name | Node 18x | Node 20x | Node 21x | Node 22x |
| :---------------- | :------: | :------: | :------: | :------: |
| Amazon Linux 2 |||||
| Amazon Linux 2023 |||||

> _NOTE: If you are looking to run Node.js in a non-supported Linux version take a look to [Node.js Unofficial Builds](https://unofficial-builds.nodejs.org/)_
### RPM Installation Instructions

The Nodesource RPM package signing key is available here: <https://rpm.nodesource.com/gpgkey/nodesource.gpg.key>

**Node.js v21.x**
**Node.js v22.x**

##### As root

```sh
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -
curl -fsSL https://rpm.nodesource.com/setup_22.x | bash -
yum install -y nodejs
```

##### No root privileges

```sh
curl -fsSL https://rpm.nodesource.com/setup_21.x | sudo bash -
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
yum install -y nodejs
```

Expand Down Expand Up @@ -277,7 +277,7 @@ curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
yum install -y nodejs
```

**Node.js Current (21.x)**
**Node.js Current (22.x)**

##### As root

Expand Down
4 changes: 2 additions & 2 deletions scripts/deb/script_generator/generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ ! -f "$base_script" ]; then
fi

# List of versions
versions=("18" "20" "21")
versions=("18" "20" "21" "22")

# Iterate over the versions and create scripts
for version in "${versions[@]}"; do
Expand All @@ -34,7 +34,7 @@ done

# Define LTS and current Node.js versions
lts_version="20"
current_version="21"
current_version="22"

# Create setup_lts and setup_current scripts
create_script "$lts_version" "lts"
Expand Down
102 changes: 102 additions & 0 deletions scripts/deb/setup_22.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

# Logger Function
log() {
local message="$1"
local type="$2"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
local color
local endcolor="\033[0m"

case "$type" in
"info") color="\033[38;5;79m" ;;
"success") color="\033[1;32m" ;;
"error") color="\033[1;31m" ;;
*) color="\033[1;34m" ;;
esac

echo -e "${color}${timestamp} - ${message}${endcolor}"
}

# Error handler function
handle_error() {
local exit_code=$1
local error_message="$2"
log "Error: $error_message (Exit Code: $exit_code)" "error"
exit $exit_code
}

# Function to check for command availability
command_exists() {
command -v "$1" &> /dev/null
}

check_os() {
if ! [ -f "/etc/debian_version" ]; then
echo "Error: This script is only supported on Debian-based systems."
exit 1
fi
}

# Function to Install the script pre-requisites
install_pre_reqs() {
log "Installing pre-requisites" "info"

# Run 'apt-get update'
if ! apt-get update -y; then
handle_error "$?" "Failed to run 'apt-get update'"
fi

# Run 'apt-get install'
if ! apt-get install -y apt-transport-https ca-certificates curl gnupg; then
handle_error "$?" "Failed to install packages"
fi

mkdir -p /usr/share/keyrings
rm -f /usr/share/keyrings/nodesource.gpg
rm -f /etc/apt/sources.list.d/nodesource.list

# Run 'curl' and 'gpg'
if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then
handle_error "$?" "Failed to download and import the NodeSource signing key"
fi
}

# Function to configure the Repo
configure_repo() {
local node_version=$1

arch=$(dpkg --print-architecture)
if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ] && [ "$arch" != "armhf" ]; then
handle_error "1" "Unsupported architecture: $arch. Only amd64, arm64, and armhf are supported."
fi

echo "deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_version nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null

# N|solid Config
echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null

# Nodejs Config
echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null

# Run 'apt-get update'
if ! apt-get update -y; then
handle_error "$?" "Failed to run 'apt-get update'"
else
log "Repository configured successfully. To install Node.js, run: apt-get install nodejs -y" "success"
fi
}

# Define Node.js version
NODE_VERSION="22.x"

# Check OS
check_os

# Main execution
install_pre_reqs || handle_error $? "Failed installing pre-requisites"
configure_repo "$NODE_VERSION" || handle_error $? "Failed configuring repository"
2 changes: 1 addition & 1 deletion scripts/deb/setup_current.x
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ configure_repo() {
}

# Define Node.js version
NODE_VERSION="21.x"
NODE_VERSION="22.x"

# Check OS
check_os
Expand Down
4 changes: 2 additions & 2 deletions scripts/rpm/script_generator/generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ ! -f "$base_script" ]; then
fi

# List of versions
versions=("18" "20" "21")
versions=("18" "20" "21" "22")

# Iterate over the versions and create scripts
for version in "${versions[@]}"; do
Expand All @@ -34,7 +34,7 @@ done

# Define LTS and current Node.js versions
lts_version="20"
current_version="21"
current_version="22"

# Create setup_lts and setup_current scripts
create_script "$lts_version" "lts"
Expand Down
2 changes: 1 addition & 1 deletion scripts/rpm/setup_18.x
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if [[ "$NODE_VERSION" == "18.x" ]] || [[ "$NODE_VERSION" == "20.x" ]]; then
log "Added N|Solid repository for LTS version: $NODE_VERSION" "info"
fi

# Check for availability of dnf or yum
# Check for availability of dnf, yum or microdnf
if command_exists dnf; then
log "dnf available, updating..." "info"
dnf makecache --disablerepo="*" --enablerepo="nodesource-nodejs" --enablerepo="nodesource-nsolid"
Expand Down
2 changes: 1 addition & 1 deletion scripts/rpm/setup_20.x
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if [[ "$NODE_VERSION" == "18.x" ]] || [[ "$NODE_VERSION" == "20.x" ]]; then
log "Added N|Solid repository for LTS version: $NODE_VERSION" "info"
fi

# Check for availability of dnf or yum
# Check for availability of dnf, yum or microdnf
if command_exists dnf; then
log "dnf available, updating..." "info"
dnf makecache --disablerepo="*" --enablerepo="nodesource-nodejs" --enablerepo="nodesource-nsolid"
Expand Down
2 changes: 1 addition & 1 deletion scripts/rpm/setup_21.x
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if [[ "$NODE_VERSION" == "18.x" ]] || [[ "$NODE_VERSION" == "20.x" ]]; then
log "Added N|Solid repository for LTS version: $NODE_VERSION" "info"
fi

# Check for availability of dnf or yum
# Check for availability of dnf, yum or microdnf
if command_exists dnf; then
log "dnf available, updating..." "info"
dnf makecache --disablerepo="*" --enablerepo="nodesource-nodejs" --enablerepo="nodesource-nsolid"
Expand Down
Loading

0 comments on commit 12be649

Please sign in to comment.