Skip to content

Commit

Permalink
bump the default node version from 20 to 22
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Oct 26, 2024
1 parent 640c821 commit 37289c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Plugin developers:
- retire use of `pnpm` and code references
- check for service mode when querying child bridge status
- enable strict config validation for the UI
- bump the default node version from 20 to 22

### Homebridge Dependencies

Expand Down
26 changes: 12 additions & 14 deletions src/modules/status/status.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ export class StatusService {

// Get the newest v18 and v20 in the list
const latest18 = versionList.filter((x: { version: string }) => x.version.startsWith('v18'))[0]
const latest20 = versionList.filter((x: { version: string }) => x.version.startsWith('v20'))[0]
const latest22 = versionList.filter((x: { version: string }) => x.version.startsWith('v22'))[0]

let updateAvailable = false
Expand All @@ -481,25 +480,26 @@ export class StatusService {
*
* 18 2.28
* 20 2.31
* 22 2.31 (assumption - the code below assumes this)
*/

// Behaviour depends on the installed version of node
switch (process.version.split('.')[0]) {
case 'v18': {
// Currently using v18, but v20 is available
// Currently using v18, but v22 is available
// If the user is running linux, then check their glibc version
// If they are running glibc 2.31 or higher, then show the option to update to v20
// If they are running glibc 2.31 or higher, then show the option to update to v22
// Otherwise we would still want to see if there is a minor/patch update available for v18
// Otherwise, already show the option for updating to node 20
// Otherwise, already show the option for updating to node 22
if (platform() === 'linux') {
const glibcVersion = this.getGlibcVersion()
if (glibcVersion) {
if (Number.parseFloat(glibcVersion) >= 2.31) {
// glibc version is high enough to support v20
// glibc version is high enough to support v22
updateAvailable = true
latestVersion = latest20.version
latestVersion = latest22.version
} else {
// glibc version is too low to support v20
// glibc version is too low to support v22
// Check if there is a new minor/patch version available
if (gt(latest18.version, process.version)) {
updateAvailable = true
Expand All @@ -513,19 +513,17 @@ export class StatusService {
}
}
} else {
// Not running linux, so show the option for updating to node 20
// Not running linux, so show the option for updating to node 22
updateAvailable = true
latestVersion = latest20.version
latestVersion = latest22.version
}
break
}
case 'v20': {
// Currently using v20
// Check if there is a new minor/patch version available
if (gt(latest20.version, process.version)) {
updateAvailable = true
latestVersion = latest20.version
}
// Show the option for updating to node 22
updateAvailable = true
latestVersion = latest22.version
break
}
case 'v22': {
Expand Down

0 comments on commit 37289c2

Please sign in to comment.