diff --git a/.github/workflows/pr-docs-tests.yml b/.github/workflows/pr-docs-tests.yml index ea07050..908d18d 100644 --- a/.github/workflows/pr-docs-tests.yml +++ b/.github/workflows/pr-docs-tests.yml @@ -11,11 +11,11 @@ jobs: os: - ubuntu-24.04 node-version: - - '18' + - '20' steps: # Install deps and cache - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Cache version builds uses: actions/cache@v4 with: @@ -23,7 +23,7 @@ jobs: path: docs/.vitepress/cache/@lando/mvb save-always: true - name: Install node ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: npm diff --git a/.github/workflows/pr-linter.yml b/.github/workflows/pr-linter.yml index dcad303..37bc23b 100644 --- a/.github/workflows/pr-linter.yml +++ b/.github/workflows/pr-linter.yml @@ -11,13 +11,13 @@ jobs: os: - ubuntu-24.04 node-version: - - '18' + - '20' steps: # Install deps and cache - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install node ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: npm diff --git a/.github/workflows/pr-node-tests.yml b/.github/workflows/pr-node-tests.yml index 81ee1df..dc690dd 100644 --- a/.github/workflows/pr-node-tests.yml +++ b/.github/workflows/pr-node-tests.yml @@ -22,17 +22,18 @@ jobs: - examples/21 - examples/22 - examples/23 + - examples/24 lando-version: - 3-edge os: - ubuntu-24.04 node-version: - - '18' + - '20' steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install node ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org diff --git a/.github/workflows/pr-unit-tests.yml b/.github/workflows/pr-unit-tests.yml index e9047c8..ad21efc 100644 --- a/.github/workflows/pr-unit-tests.yml +++ b/.github/workflows/pr-unit-tests.yml @@ -11,15 +11,15 @@ jobs: os: - windows-2022 - ubuntu-24.04 - - macos-14 + - macos-15 node-version: - - '18' + - '20' steps: # Install deps and cache - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install node ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: npm diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1135c23..f794ea7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,11 @@ name: Publish to NPM on: release: types: - - published - - edited + - created + +permissions: + id-token: write + contents: read jobs: deploy: @@ -18,11 +21,10 @@ jobs: node-version: - '20' steps: - # Install deps and cache - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install node ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} registry-url: https://registry.npmjs.org @@ -30,13 +32,11 @@ jobs: - name: Install dependencies run: npm clean-install --prefer-offline --frozen-lockfile - # Let's do tests rq just to make sure we dont push something that is fundamentally broken - name: Lint code run: npm run lint - name: Run unit tests run: npm run test:unit - # Prepare release. - name: Prepare release uses: lando/prepare-release-action@v3 with: @@ -45,7 +45,8 @@ jobs: sync-token: ${{ secrets.RTFM47_COAXIUM_INJECTOR }} sync-username: rtfm-47 - # Deploy + - name: Upgrade npm for trusted publishing + run: npm install -g "npm@^11.5.1" - name: Publish to npm run: | VERSION=$(node -p "require('./package.json').version") diff --git a/CHANGELOG.md b/CHANGELOG.md index cc551ea..bcbc0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Added support for Node LTS `24` (up to `24.11`) +* Updated Node LTS support to include the latest minor versions for `22` (up to `22.21`) and `20` (up to `20.19`) +* Fixed `test:leia` + ## v1.5.0 - [March 5, 2025](https://github.com/lando/node/releases/tag/v1.5.0) * Updated Node support to include the latest minor versions for Node `23` (up to `23.8`), `22` (up to `22.14`), `20` (up to `20.18`), `19` (up to `19.9`), `18` (up to `18.20`), and `16` (up to `16.20`) diff --git a/README.md b/README.md index c83108d..96d0301 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Add a `node` service to your Landofile ```yaml services: myservice: - type: node:16 + type: node:24 command: npm start ``` diff --git a/builders/node.js b/builders/node.js index 0ce200f..55a0883 100644 --- a/builders/node.js +++ b/builders/node.js @@ -6,6 +6,18 @@ const _ = require('lodash'); // Constants const LEGACY_DEFAULT_VERSION = '14'; const supportedVersions = [ + '24', + '24.11', + '24.10', + '24.9', + '24.8', + '24.7', + '24.6', + '24.5', + '24.4', + '24.3', + '24.2', + '24.1', '23', '23.8', '23.7', @@ -16,6 +28,13 @@ const supportedVersions = [ '23.2', '23.1', '22', + '22.21', + '22.20', + '22.19', + '22.18', + '22.17', + '22.16', + '22.15', '22.14', '22.13', '22.12', @@ -39,6 +58,7 @@ const supportedVersions = [ '21.2', '21.1', '20', + '20.19', '20.18', '20.17', '20.16', diff --git a/docs/config.md b/docs/config.md index d925ef6..cab9c17 100644 --- a/docs/config.md +++ b/docs/config.md @@ -12,7 +12,7 @@ Also note that options, in addition to the [build steps](https://docs.lando.dev/ ```yaml services: myservice: - type: node:18 + type: node:24 ssl: false command: tail -f /dev/null globals: [] @@ -70,7 +70,7 @@ You can also set `ssl` to a specific port. This will do the same thing as `ssl: ```yaml services: myservice: - type: node + type: node:24 port: 3000 ssl: 4444 ``` @@ -90,7 +90,7 @@ An example of globally installing the `latest` `gulp-cli` is shown below: ```yaml services: myservice: - type: node + type: node:24 globals: gulp-cli: latest command: npm start @@ -101,7 +101,7 @@ An example of using a [build step](https://docs.lando.dev/services/lando-3.html# ```yaml services: myservice: - type: node + type: node:24 build: - npm install command: yarn start-app diff --git a/docs/development.md b/docs/development.md index f18922d..78bd6af 100644 --- a/docs/development.md +++ b/docs/development.md @@ -13,7 +13,7 @@ At the very least you will need to have the following installed: * [Lando 3.21.0+](https://docs.lando.dev/getting-started/installation.html) preferably installed [from source](https://docs.lando.dev/install/source.html). * [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) -* [Node 18](https://nodejs.org/dist/latest-v18.x/) +* [Node 20](https://nodejs.org/dist/latest-v20.x/) ## Installation diff --git a/docs/index.md b/docs/index.md index f84f7e9..052257d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,6 @@ --- title: Node Lando Plugin description: Add a highly configurable NodeJS service to Lando for local development with all the power of Docker and Docker Compose; comes with composer, xdebug and multiple versions for lols. -next: ./config.html --- # Node @@ -13,12 +12,13 @@ You can easily add it to your Lando app by adding an entry to the [services](htt ```yaml services: myservice: - type: node:16 + type: node:24 command: npm start ``` ## Supported versions +* [24](https://hub.docker.com/_/node) * [23](https://hub.docker.com/_/node) * [22](https://hub.docker.com/_/node) * [21](https://hub.docker.com/_/node) @@ -28,7 +28,7 @@ services: * [17](https://hub.docker.com/_/node) * [16](https://hub.docker.com/_/node) * [15](https://hub.docker.com/_/node) -* **[14](https://hub.docker.com/_/node)** **(default)** +* [14](https://hub.docker.com/_/node) * [custom](https://docs.lando.dev/services/lando-3.html#overrides) ## Legacy versions diff --git a/docs/install.md b/docs/install.md index 8fc3a7f..f5cf098 100644 --- a/docs/install.md +++ b/docs/install.md @@ -30,7 +30,7 @@ mkdir -p ~/.lando/plugins # Install plugin # NOTE: Modify the "npm install @lando/node" line to install a particular version eg # npm install @lando/node@0.5.2 -docker run --rm -it -v ${HOME}/.lando/plugins:/plugins -w /tmp node:18-alpine sh -c \ +docker run --rm -it -v ${HOME}/.lando/plugins:/plugins -w /tmp node:20-alpine sh -c \ "npm init -y \ && npm install @lando/node --production --flat --no-default-rc --no-lockfile --link-duplicates \ && npm install --production --cwd /tmp/node_modules/@lando/node \ diff --git a/examples/24/.gitignore b/examples/24/.gitignore new file mode 100644 index 0000000..740a0a4 --- /dev/null +++ b/examples/24/.gitignore @@ -0,0 +1,3 @@ +node_modules +*.log +package-lock.json diff --git a/examples/24/.lando.yml b/examples/24/.lando.yml new file mode 100644 index 0000000..97e784f --- /dev/null +++ b/examples/24/.lando.yml @@ -0,0 +1,39 @@ +name: lando-node-24 +services: + defaults: + type: node:24 + build: + - yarn + command: /app/node_modules/.bin/nodemon src/app-http.js --watch src --ignore *.test.js + cli: + type: node + compass: + type: node:24 + globals: + grunt-cli: latest + custom: + type: node:24 + ssl: true + globals: + gulp-cli: latest + port: 3000 + build: + - yarn + command: /app/node_modules/.bin/nodemon src/app-https.js --watch src --ignore *.test.js + custom2: + type: node:24.7.0 + ssl: 4444 + port: 3000 + build: + - yarn + command: /app/node_modules/.bin/nodemon src/app-custom.js --watch src --ignore *.test.js +tooling: + grunt: + service: compass + npx: + service: cli + +# This is important because it lets lando know to test against the plugin in this repo +# DO NOT REMOVE THIS! +plugins: + "@lando/node": ../.. diff --git a/examples/24/README.md b/examples/24/README.md new file mode 100644 index 0000000..7dd65b8 --- /dev/null +++ b/examples/24/README.md @@ -0,0 +1,86 @@ +# Node 24 Example + +This example exists primarily to test the following documentation: + +* [Node 14-24 Service](https://docs.devwithlando.io/tutorials/node.html) +* [Installing compass in your node service](https://docs.lando.dev/guides/using-compass-on-a-lando-node-service.html) + +## Start up tests + +Run the following commands to get up and running with this example. + +```bash +# Should start up successfully +lando poweroff +lando start +``` + +## Verification commands + +Run the following commands to validate things are rolling as they should. + +```bash +# Should use 24.x as the default version +lando exec defaults -- "env | grep NODE_VERSION=24." + +# Should use a user specified version if given +lando exec custom -- "env | grep NODE_VERSION=24." + +# Should use a user specified patch version if given +lando exec custom2 -- "env | grep NODE_VERSION=24.7.0" + +# Should serve over port 80 by default +lando exec defaults -- "curl http://localhost | grep tune" + +# Should set NODE_EXTRA_CA_CERTS with lando domain CA +lando exec defaults -- "env" | grep NODE_EXTRA_CA_CERTS | grep "$LANDO_CA_CERT" + +# Should only serve over http by default +lando exec defaults -- "curl https://localhost" || echo $? | grep 7 + +# Should serve over specified ports if given +lando exec custom -- "curl http://localhost:3000 | grep tune" + +# Should serve over https is ssl is set by user +lando exec custom -- "curl https://localhost | grep tune" + +# Should serve over a custom https port if ssl is set to a specific port +lando exec custom2 -- "curl https://localhost:4444 | grep DANCING" + +# Should run as root if using ports below 1024 +lando exec defaults -- pgrep -c -u root -f "node src/app-http.js" | grep 1 +lando exec custom -- pgrep -c -u root -f "node src/app-https.js" | grep 1 + +# Should run as node if using ports 1024 and above +lando exec custom2 -- pgrep -c -u node -f "node src/app-custom.js" | grep 1 + +# Should install global dependencies if specified by user and have them available in PATH +lando exec custom -- "gulp -v" +lando exec custom -- "which gulp | grep /var/www/.npm-global" + +# Should PATH prefer node dependency binaries installed in /app/node_modules over global ones +lando exec custom -- "npm install gulp-cli --no-save" +lando exec custom -- "gulp -v" +lando exec custom -- "which gulp | grep /app/node_modules/.bin" +lando exec custom -- "npm uninstall gulp-cli" +lando exec custom -- "which gulp | grep /var/www/.npm-global" + +# Should not serve port for cli +lando exec cli -- "curl http://localhost" || echo $? | grep 7 + +# Should install gruntcli +lando grunt -V + +# Should execute npx scripts +lando npx cowsay "Hello World" +``` + +## Destroy tests + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/24/package.json b/examples/24/package.json new file mode 100644 index 0000000..7f9f428 --- /dev/null +++ b/examples/24/package.json @@ -0,0 +1,27 @@ +{ + "name": "node-lando", + "version": "1.0.0", + "description": "Node example for Lando", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/lando/lando/tree/master/examples/node" + }, + "keywords": [ + "node", + "docker", + "localdev" + ], + "author": "Mike Pirog", + "license": "MIT", + "dependencies": { + "express": "^4.19.2" + }, + "devDependencies": { + "grunt-contrib-compass": "^1.1.1", + "nodemon": "^3.0.1" + } +} diff --git a/examples/24/src/app-custom.js b/examples/24/src/app-custom.js new file mode 100644 index 0000000..b47fc14 --- /dev/null +++ b/examples/24/src/app-custom.js @@ -0,0 +1,28 @@ +/** + * Lando node express example + * + * @name taylorswift + */ + +'use strict'; + +// Load modules +const fs = require('fs'); +const http = require('http'); +const https = require('https'); +const express = require('express'); +const app = express(); + +// Create our HTTPS server options +const key = fs.readFileSync('/certs/cert.key'); +const cert = fs.readFileSync('/certs/cert.crt'); + +// Create our servers +https.createServer({key, cert}, app).listen(4444); +http.createServer(app).listen(3000); + +// Basic HTTP response +app.get('/', (req, res) => { + res.header('Content-type', 'text/html'); + return res.end('