Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade to Node 22 (LTS) #4107

Merged
merged 4 commits into from
Jan 3, 2025
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: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.16.1
v22.10.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ planx-new is a monorepo containing our full application stack. Here's a quick su
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [PNPM](https://github.com/pnpm/pnpm) `npm install -g pnpm@8.6.6`
- [Node](https://nodejs.org/en/download) `pnpm env use --global 18.16.1`
- [Node](https://nodejs.org/en/download) `pnpm env use --global 22.10.0`
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

**If you're an OSL developer:**
Expand Down
6 changes: 3 additions & 3 deletions api.planx.uk/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## BASE ##
# 18.16.1 = LTS
FROM node:18.16.1-alpine as base
# 22.10.0 = LTS
FROM node:22.10.0-alpine as base

# Setup Git - required for fetching git dependencies (planx-core)
RUN apk add --no-cache git
Expand All @@ -21,7 +21,7 @@ RUN pnpm install --recursive --prefer-offline
RUN pnpm build
RUN pnpm prune --production

FROM node:18.16.1-alpine as production
FROM node:22.10.0-alpine as production
WORKDIR /api

## PRODUCTION ##
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"exports": "./dist/index.js",
"engines": {
"node": ">=18.16",
"node": ">=22.10",
"pnpm": "8.6.6"
},
"dependencies": {
Expand Down Expand Up @@ -92,7 +92,7 @@
"@types/jsonwebtoken": "^9.0.5",
"@types/lodash": "^4.17.0",
"@types/multer": "^1.4.11",
"@types/node": "^18.19.13",
"@types/node": "22.10.5",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, do we also want to update L9 above?

"engines": {
    "node": ">=18.16",
    "pnpm": "8.6.6"
  },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find! 🙌 I searched for 18.16.1 in the codebase and missed this.

"@types/passport": "^1.0.16",
"@types/passport-google-oauth20": "^2.0.14",
"@types/supertest": "^6.0.2",
Expand Down
74 changes: 32 additions & 42 deletions api.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions doc/how-to/how-to-upgrade-nodejs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# How to upgrade Node.js

This guide walks through the required steps to upgrade Node.js versions across the PlanX repositories.

We should always aim to be on an LTS version (even release numbers). For the full release schedule please see https://nodejs.org/en/about/previous-releases

## planx-new
1. Locally install desired Node.js version

```shell
nvm install 22.10.0
nvm use 22.10.0
```

2. Update `.nvmrc` file

3. Update Dockerfiles -
- `api.planx.uk/Dockerfile`
- `sharedb.planx.uk/Dockerfile`

4. Update `@types/node` package across all projects ([npm](https://www.npmjs.com/package/@types/node)). Note: Only major.minor version need to match e.g. types version 22.10.7893 would be fine for Node 22.10.x ([docs](https://github.com/definitelytyped/definitelytyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library)).

5. Fix any type issues flagged by the above change

6. Update references to `engines` in API `package.json` file

7. Update `README.md`

8. Rebuild docker containers, test and run locally

9. Upgrade the `NODE_VERSION` on GitHub (Settings > Secrets and variables > Actions > "Variables" tab > Update `NODE_VERSION` variable). This variable is used across our GitHub actions to define which Node version runs our CI services.

Please note - this update is immediate and will effect other open PRs. It's advisable to hardcode the desired Node version into the GitHub action files initially to test CI and regression tests, before making this change.

## planx-core
Steps 4, 5 & 9 also apply here and should be updated shortly after.
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"packageManager": "pnpm@8.6.6",
"devDependencies": {
"@types/node": "18.16.1",
"@types/node": "22.10.5",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.57.0",
Expand Down
Loading
Loading