Skip to content

Commit d4aebf9

Browse files
CopilotApollon77
andauthored
Add Node.js 24 support to adapter creator (#1155)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com> Co-authored-by: Ingo Fischer <github@fischer-ka.de>
1 parent d1e308c commit d4aebf9

File tree

13 files changed

+244
-10
lines changed

13 files changed

+244
-10
lines changed

.github/workflows/test-and-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727
strategy:
2828
matrix:
29-
node-version: [18.x, 20.x, 22.x]
29+
node-version: [18.x, 20.x, 22.x, 24.x]
3030
os: [ubuntu-latest]
3131

3232
steps:
@@ -78,7 +78,7 @@ jobs:
7878
runs-on: ubuntu-latest
7979
strategy:
8080
matrix:
81-
node-version: [20.x]
81+
node-version: [22.x]
8282

8383
steps:
8484
- name: Checkout code

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
(at the beginning of a new line)
77
-->
88
## __WORK IN PROGRESS__
9+
* (copilot) Add Node.js 24 as a supported version (#1145) · [Migration guide](docs/updates/20250831_node24_support.md)
910
* (copilot) Replace deprecated `setStateAsync` with `setState` in adapter templates (#1148, [Migration guide](./docs/updates/20250831_setstate_sync.md))
11+
* (copilot) Remove Node.js 18 as a supported version (#1154) · [Migration guide](docs/updates/20250831_remove_nodejs18_support.md)
12+
* (copilot) Adjust the io-package schema location (#1153) · [Migration guide](docs/updates/20250831_jsonconfig_schema_url_fix.md)
1013

1114
## 2.6.5 (2024-09-13)
1215
* (AlCalzone) Update required versions of `js-controller` and `admin` to the current stable versions (#1116)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Add Node.js 24 support to existing adapters
2+
3+
Node.js 24 is now available as an LTS version and can be used for ioBroker adapters. This guide shows how to manually update existing adapters to support Node.js 24.
4+
5+
## Update minimum Node.js version
6+
7+
If you want to set Node.js 24 as the minimum required version, update the `engines` field in `package.json`:
8+
9+
```diff
10+
"engines": {
11+
- "node": ">= 20"
12+
+ "node": ">= 24"
13+
},
14+
```
15+
16+
## Update testing configuration
17+
18+
To test your adapter against Node.js 24, update `.github/workflows/test-and-release.yml`:
19+
20+
```diff
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
- node-version: [18.x, 20.x, 22.x]
25+
+ node-version: [18.x, 20.x, 22.x, 24.x]
26+
os: [ubuntu-latest, windows-latest, macos-latest]
27+
```
28+
29+
If you also want to update the check and deploy steps to use Node.js 24:
30+
31+
```diff
32+
steps:
33+
- uses: ioBroker/testing-action-check@v1
34+
with:
35+
- node-version: '20.x'
36+
+ node-version: '24.x'
37+
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
38+
# install-command: 'npm install'
39+
lint: true
40+
```
41+
42+
```diff
43+
# steps:
44+
# - uses: ioBroker/testing-action-deploy@v1
45+
# with:
46+
-# node-version: '20.x'
47+
+# node-version: '24.x'
48+
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
49+
# # install-command: 'npm install'
50+
# npm-token: ${{ secrets.NPM_TOKEN }}
51+
```
52+
53+
## Update TypeScript configuration (if applicable)
54+
55+
When using TypeScript or when type-checking is enabled, the type definitions and `tsconfig.json` need to be updated.
56+
57+
To update the Node.js type definitions for Node.js 24:
58+
59+
```bash
60+
npm i -D @types/node@24
61+
```
62+
63+
If you are upgrading from an older Node.js version, uninstall the old tsconfig base:
64+
65+
```bash
66+
npm uninstall -D @tsconfig/node20
67+
# or @tsconfig/node22 if upgrading from Node.js 22
68+
```
69+
70+
Then install the Node.js 24 tsconfig base:
71+
72+
```bash
73+
npm i -D @tsconfig/node24
74+
```
75+
76+
Finally, update your `tsconfig.json` to reference the new base:
77+
78+
```diff
79+
{
80+
- "extends": "@tsconfig/node20/tsconfig.json",
81+
+ "extends": "@tsconfig/node24/tsconfig.json",
82+
// ...
83+
}
84+
```
85+
86+
## Note
87+
88+
Remember that using Node.js 24 as the minimum version means users will need to have Node.js 24 or higher installed to run your adapter. Consider your target audience when deciding on the minimum version.

src/lib/core/questions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,16 @@ export const questionGroups: QuestionGroup[] = [
556556
message:
557557
"What's the minimum Node.js version you want to support?",
558558
initial: "20",
559-
choices: ["20", "22"],
559+
choices: ["20", "22", "24"],
560560
migrate: (ctx) => {
561561
if (ctx.hasDevDependency("@tsconfig/node18")) {
562562
return "20"; // For migrations upgrade to Node.js 20 as minimum
563563
} else if (ctx.hasDevDependency("@tsconfig/node20")) {
564564
return "20";
565565
} else if (ctx.hasDevDependency("@tsconfig/node22")) {
566566
return "22";
567+
} else if (ctx.hasDevDependency("@tsconfig/node24")) {
568+
return "24";
567569
} else {
568570
return "20";
569571
}
@@ -981,7 +983,7 @@ export interface Answers {
981983
| "code coverage"
982984
| "devcontainer"
983985
)[];
984-
nodeVersion?: "20" | "22";
986+
nodeVersion?: "20" | "22" | "24";
985987
title?: string;
986988
license?: string;
987989
// Not used on the CLI, but can be provided by the web UI for example

templates/_github/workflows/test-and-release.yml.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const templateFunction: TemplateFunction = answers => {
1515
const isGitHub = answers.target === "github";
1616

1717
const ltsNodeVersion = "20.x";
18-
const adapterTestVersions = ["20.x", "22.x"];
18+
const adapterTestVersions = ["20.x", "22.x", "24.x"];
19+
1920
const adapterTestOS = ["ubuntu-latest", "windows-latest", "macos-latest"];
2021

2122
const adapterName = answers.adapterName;

test/baselines/adapter_JS_JsonUI_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.github/workflows/test-and-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ${{ matrix.os }}
4141
strategy:
4242
matrix:
43-
node-version: [20.x, 22.x]
43+
node-version: [20.x, 22.x, 24.x]
4444
os: [ubuntu-latest, windows-latest, macos-latest]
4545

4646
steps:

test/baselines/adapter_JS_React/.github/workflows/test-and-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ${{ matrix.os }}
4141
strategy:
4242
matrix:
43-
node-version: [20.x, 22.x]
43+
node-version: [20.x, 22.x, 24.x]
4444
os: [ubuntu-latest, windows-latest, macos-latest]
4545

4646
steps:

test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/.github/workflows/test-and-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ${{ matrix.os }}
4242
strategy:
4343
matrix:
44-
node-version: [20.x, 22.x]
44+
node-version: [20.x, 22.x, 24.x]
4545
os: [ubuntu-latest, windows-latest, macos-latest]
4646

4747
steps:

test/baselines/adapter_TS_React/.github/workflows/test-and-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ${{ matrix.os }}
4242
strategy:
4343
matrix:
44-
node-version: [20.x, 22.x]
44+
node-version: [20.x, 22.x, 24.x]
4545
os: [ubuntu-latest, windows-latest, macos-latest]
4646

4747
steps:
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"name": "iobroker.test-adapter",
3+
"version": "0.0.1",
4+
"description": "test-adapter",
5+
"author": {
6+
"name": "Al Calzone",
7+
"email": "al@calzo.ne"
8+
},
9+
"homepage": "https://github.com/AlCalzone/ioBroker.test-adapter",
10+
"license": "MIT",
11+
"keywords": [
12+
"ioBroker",
13+
"template",
14+
"Smart Home",
15+
"home automation"
16+
],
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/AlCalzone/ioBroker.test-adapter.git"
20+
},
21+
"engines": {
22+
"node": ">= 24"
23+
},
24+
"dependencies": {
25+
"@iobroker/adapter-core": "^3.3.2"
26+
},
27+
"devDependencies": {
28+
"@iobroker/adapter-dev": "^1.4.0",
29+
"@iobroker/testing": "^5.1.0",
30+
"@tsconfig/node24": "^24.0.1",
31+
"@types/chai-as-promised": "^7.1.8",
32+
"@types/chai": "^4.3.20",
33+
"@types/mocha": "^10.0.10",
34+
"@types/node": "^24.3.0",
35+
"@types/proxyquire": "^1.3.31",
36+
"@types/sinon": "^17.0.4",
37+
"@types/sinon-chai": "^3.2.12",
38+
"@typescript-eslint/eslint-plugin": "^7.18.0",
39+
"@typescript-eslint/parser": "^7.18.0",
40+
"chai-as-promised": "^7.1.2",
41+
"chai": "^4.5.0",
42+
"eslint": "^8.57.1",
43+
"mocha": "^11.7.1",
44+
"proxyquire": "^2.1.3",
45+
"rimraf": "^6.0.1",
46+
"sinon": "^21.0.0",
47+
"sinon-chai": "^3.7.0",
48+
"source-map-support": "^0.5.21",
49+
"ts-node": "^10.9.2",
50+
"typescript": "~5.0.4"
51+
},
52+
"main": "build/main.js",
53+
"files": [
54+
"admin{,/!(src)/**}/!(tsconfig|tsconfig.*|.eslintrc).{json,json5}",
55+
"admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}",
56+
"build/",
57+
"www/",
58+
"io-package.json",
59+
"LICENSE"
60+
],
61+
"scripts": {
62+
"prebuild": "rimraf build",
63+
"build": "build-adapter ts",
64+
"watch": "build-adapter ts --watch",
65+
"prebuild:ts": "rimraf build",
66+
"build:ts": "build-adapter ts",
67+
"watch:ts": "build-adapter ts --watch",
68+
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
69+
"test:package": "mocha test/package --exit",
70+
"test:integration": "mocha test/integration --exit",
71+
"test": "npm run test:ts && npm run test:package",
72+
"check": "tsc --noEmit",
73+
"lint": "eslint --ext .ts src/",
74+
"translate": "translate-adapter"
75+
},
76+
"bugs": {
77+
"url": "https://github.com/AlCalzone/ioBroker.test-adapter/issues"
78+
},
79+
"readmeFilename": "README.md"
80+
}

0 commit comments

Comments
 (0)