Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
features:
- actionlint
- google-cloud-cli
- node
- postgresql-client
- shellcheck
baseImage:
Expand All @@ -33,6 +34,7 @@ jobs:
features:
- actionlint
- google-cloud-cli
- node
- postgresql-client
- shellcheck
continue-on-error: true
Expand Down
21 changes: 21 additions & 0 deletions src/node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# node

Install [Node.js](https://nodejs.org) from [Nodesource's DEB repository](https://deb.nodesource.com).

## Usage

```json
"features": {
"ghcr.io/CargoSense/devcontainer-features/node:1": {}
}
```

## Options

| Option ID | Description | Type | Default Value |
|:----------|:--------------------------------|:-------|:--------------|
| `version` | The Node.js version to install. | string | `22` |

## OS Support

This Feature should work on recent versions of Debian/Ubuntu and Linux distributions using the [apt](https://wiki.debian.org/AptCLI) management tool.
23 changes: 23 additions & 0 deletions src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "Node.js",
"id": "node",
"version": "1.0.0",
"description": "Install Node.js from Nodesource's DEB repository.",
"options": {
"version": {
"type": "string",
"enum": [
"18",
"20",
"21",
"22",
"23"
],
"default": "22",
"description": "Select or enter a Node.js version."
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
23 changes: 23 additions & 0 deletions src/node/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env sh

set -e

NODE_VERSION="${VERSION:-"22"}"

curl_installed=""

if ! type curl >/dev/null 2>&1; then
apt update --yes
apt install --no-install-recommends --yes curl ca-certificates

curl_installed="true"
fi

curl -fsSL https://deb.nodesource.com/setup_"${NODE_VERSION}".x | bash -

apt update --yes
apt install --no-install-recommends --yes nodejs

if [ -n "${curl_installed}" ]; then
apt purge curl --autoremove --yes
fi
13 changes: 13 additions & 0 deletions test/node/node-20.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Feature-specific tests
check "version" bash -c "node --version | grep -E 'v20\..+'"

# Report result
reportResults
10 changes: 10 additions & 0 deletions test/node/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"node-20": {
"image": "debian:latest",
"features": {
"node": {
"version": "20"
}
}
}
}
14 changes: 14 additions & 0 deletions test/node/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Feature-specific tests
check "version" node --version
check "which node" bash -c "which node | grep /usr/bin/node"

# Report result
reportResults