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
4 changes: 2 additions & 2 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]
os: [ubuntu-latest]

steps:
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
node-version: [22.x]

steps:
- name: Checkout code
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
(at the beginning of a new line)
-->
## __WORK IN PROGRESS__
* (copilot) Add Node.js 24 as a supported version (#1145) · [Migration guide](docs/updates/20250831_node24_support.md)
* (copilot) Replace deprecated `setStateAsync` with `setState` in adapter templates (#1148, [Migration guide](./docs/updates/20250831_setstate_sync.md))
* (copilot) Remove Node.js 18 as a supported version (#1154) · [Migration guide](docs/updates/20250831_remove_nodejs18_support.md)
* (copilot) Adjust the io-package schema location (#1153) · [Migration guide](docs/updates/20250831_jsonconfig_schema_url_fix.md)

## 2.6.5 (2024-09-13)
* (AlCalzone) Update required versions of `js-controller` and `admin` to the current stable versions (#1116)
Expand Down
88 changes: 88 additions & 0 deletions docs/updates/20250831_node24_support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Add Node.js 24 support to existing adapters

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.

## Update minimum Node.js version

If you want to set Node.js 24 as the minimum required version, update the `engines` field in `package.json`:

```diff
"engines": {
- "node": ">= 20"
+ "node": ">= 24"
},
```

## Update testing configuration

To test your adapter against Node.js 24, update `.github/workflows/test-and-release.yml`:

```diff
runs-on: ${{ matrix.os }}
strategy:
matrix:
- node-version: [18.x, 20.x, 22.x]
+ node-version: [18.x, 20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]
```

If you also want to update the check and deploy steps to use Node.js 24:

```diff
steps:
- uses: ioBroker/testing-action-check@v1
with:
- node-version: '20.x'
+ node-version: '24.x'
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: true
```

```diff
# steps:
# - uses: ioBroker/testing-action-deploy@v1
# with:
-# node-version: '20.x'
+# node-version: '24.x'
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
# # install-command: 'npm install'
# npm-token: ${{ secrets.NPM_TOKEN }}
```

## Update TypeScript configuration (if applicable)

When using TypeScript or when type-checking is enabled, the type definitions and `tsconfig.json` need to be updated.

To update the Node.js type definitions for Node.js 24:

```bash
npm i -D @types/node@24
```

If you are upgrading from an older Node.js version, uninstall the old tsconfig base:

```bash
npm uninstall -D @tsconfig/node20
# or @tsconfig/node22 if upgrading from Node.js 22
```

Then install the Node.js 24 tsconfig base:

```bash
npm i -D @tsconfig/node24
```

Finally, update your `tsconfig.json` to reference the new base:

```diff
{
- "extends": "@tsconfig/node20/tsconfig.json",
+ "extends": "@tsconfig/node24/tsconfig.json",
// ...
}
```

## Note

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.
6 changes: 4 additions & 2 deletions src/lib/core/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,16 @@ export const questionGroups: QuestionGroup[] = [
message:
"What's the minimum Node.js version you want to support?",
initial: "20",
choices: ["20", "22"],
choices: ["20", "22", "24"],
migrate: (ctx) => {
if (ctx.hasDevDependency("@tsconfig/node18")) {
return "20"; // For migrations upgrade to Node.js 20 as minimum
} else if (ctx.hasDevDependency("@tsconfig/node20")) {
return "20";
} else if (ctx.hasDevDependency("@tsconfig/node22")) {
return "22";
} else if (ctx.hasDevDependency("@tsconfig/node24")) {
return "24";
} else {
return "20";
}
Expand Down Expand Up @@ -981,7 +983,7 @@ export interface Answers {
| "code coverage"
| "devcontainer"
)[];
nodeVersion?: "20" | "22";
nodeVersion?: "20" | "22" | "24";
title?: string;
license?: string;
// Not used on the CLI, but can be provided by the web UI for example
Expand Down
3 changes: 2 additions & 1 deletion templates/_github/workflows/test-and-release.yml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const templateFunction: TemplateFunction = answers => {
const isGitHub = answers.target === "github";

const ltsNodeVersion = "20.x";
const adapterTestVersions = ["20.x", "22.x"];
const adapterTestVersions = ["20.x", "22.x", "24.x"];

const adapterTestOS = ["ubuntu-latest", "windows-latest", "macos-latest"];

const adapterName = answers.adapterName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
80 changes: 80 additions & 0 deletions test/baselines/minNodeVersion_24/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "iobroker.test-adapter",
"version": "0.0.1",
"description": "test-adapter",
"author": {
"name": "Al Calzone",
"email": "al@calzo.ne"
},
"homepage": "https://github.com/AlCalzone/ioBroker.test-adapter",
"license": "MIT",
"keywords": [
"ioBroker",
"template",
"Smart Home",
"home automation"
],
"repository": {
"type": "git",
"url": "https://github.com/AlCalzone/ioBroker.test-adapter.git"
},
"engines": {
"node": ">= 24"
},
"dependencies": {
"@iobroker/adapter-core": "^3.3.2"
},
"devDependencies": {
"@iobroker/adapter-dev": "^1.4.0",
"@iobroker/testing": "^5.1.0",
"@tsconfig/node24": "^24.0.1",
"@types/chai-as-promised": "^7.1.8",
"@types/chai": "^4.3.20",
"@types/mocha": "^10.0.10",
"@types/node": "^24.3.0",
"@types/proxyquire": "^1.3.31",
"@types/sinon": "^17.0.4",
"@types/sinon-chai": "^3.2.12",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"chai-as-promised": "^7.1.2",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"mocha": "^11.7.1",
"proxyquire": "^2.1.3",
"rimraf": "^6.0.1",
"sinon": "^21.0.0",
"sinon-chai": "^3.7.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"typescript": "~5.0.4"
},
"main": "build/main.js",
"files": [
"admin{,/!(src)/**}/!(tsconfig|tsconfig.*|.eslintrc).{json,json5}",
"admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}",
"build/",
"www/",
"io-package.json",
"LICENSE"
],
"scripts": {
"prebuild": "rimraf build",
"build": "build-adapter ts",
"watch": "build-adapter ts --watch",
"prebuild:ts": "rimraf build",
"build:ts": "build-adapter ts",
"watch:ts": "build-adapter ts --watch",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test:package": "mocha test/package --exit",
"test:integration": "mocha test/integration --exit",
"test": "npm run test:ts && npm run test:package",
"check": "tsc --noEmit",
"lint": "eslint --ext .ts src/",
"translate": "translate-adapter"
},
"bugs": {
"url": "https://github.com/AlCalzone/ioBroker.test-adapter/issues"
},
"readmeFilename": "README.md"
}
46 changes: 46 additions & 0 deletions test/baselines/minNodeVersion_24/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Root tsconfig to set the settings and power editor support for all TS files
{
// To update the compilation target, install a different version of @tsconfig/node... and reference it here
// https://github.com/tsconfig/bases#node-24-tsconfigjson
"extends": "@tsconfig/node24/tsconfig.json",
"compilerOptions": {
// do not compile anything, this file is just to configure type checking
// the compilation is configured in tsconfig.build.json
"noEmit": true,

// check JS files, but do not compile them => tsconfig.build.json
"allowJs": true,
"checkJs": true,

"noEmitOnError": true,
"outDir": "./build/",
"removeComments": false,

// This is necessary for the automatic typing of the adapter config
"resolveJsonModule": true,

// If you want to disable the stricter type checks (not recommended), uncomment the following line
// "strict": false,
// And enable some of those features for more fine-grained control
// "strictNullChecks": true,
// "strictPropertyInitialization": true,
// "strictBindCallApply": true,
// "noImplicitAny": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
// Uncomment this if you want the old behavior of catch variables being `any`
// "useUnknownInCatchVariables": false,

"sourceMap": true,
"inlineSourceMap": false
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
],
"exclude": [
"build/**",
"node_modules/**",
"widgets/**"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
14 changes: 14 additions & 0 deletions test/create-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,20 @@ describe("adapter creation =>", () => {
);
});

it(`Node.js 24 as minimum`, async () => {
const answers: Answers = {
...baseAnswers,
nodeVersion: "24",
};
await expectSuccess(
"minNodeVersion_24",
answers,
(file) =>
file.name === "package.json" ||
file.name === "tsconfig.json",
);
});

it(`TS(X) with single quotes`, async () => {
const answers: Answers = {
...baseAnswers,
Expand Down