Skip to content

Commit d424770

Browse files
committed
Migrate to Node 18 and fix breaking dependencies
Node 18 Migration (enables corepack + yarn 4): - Update Dockerfile: node:16-alpine -> node:18-alpine - Update workflows: node-version [16.x] -> [18.x] - Restore corepack enable in all jobs - Re-add cache: 'yarn' for faster CI builds Breaking Dependency Fixes: - Replace bcrypt-nodejs@0.0.3 with bcryptjs@2.4.3 (bcrypt-nodejs abandoned 2014, won't compile on modern Node) - Fix deprecated new Buffer() -> Buffer.from() in auth.js - Updated related imports in auth.test.js Additional Changes: - Remove --immutable-cache flag (not needed for node-modules linker) - Regenerated yarn.lock with new dependencies - All 643 tests passing - Docker build verified This unblocks the deployment pipeline which was failing due to: 1. Node 16 incompatibility with corepack (missing URL.canParse) 2. npm install -g yarn@4.12.0 not working (Yarn 4 not on npm registry)
1 parent 9fe9bb0 commit d424770

File tree

8 files changed

+149
-93
lines changed

8 files changed

+149
-93
lines changed

.github/workflows/deploy-to-dev.yaml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ jobs:
3131
runs-on: ubuntu-latest
3232
strategy:
3333
matrix:
34-
node-version: [16.x]
34+
node-version: [18.x]
3535
steps:
3636
- name: Checkout
3737
uses: actions/checkout@v4
3838

39+
- name: Enable Corepack
40+
run: corepack enable
41+
3942
- name: Setup node
4043
uses: actions/setup-node@v4
4144
with:
4245
node-version: ${{ matrix.node-version }}
43-
44-
- name: Install Yarn
45-
run: npm install -g yarn@4.12.0
46+
cache: "yarn"
4647

4748
- run: yarn install --immutable
4849

@@ -52,18 +53,19 @@ jobs:
5253
needs: install
5354
strategy:
5455
matrix:
55-
node-version: [16.x]
56+
node-version: [18.x]
5657
steps:
5758
- name: Checkout
5859
uses: actions/checkout@v4
5960

61+
- name: Enable Corepack
62+
run: corepack enable
63+
6064
- name: Setup node
6165
uses: actions/setup-node@v4
6266
with:
6367
node-version: ${{ matrix.node-version }}
64-
65-
- name: Install Yarn
66-
run: npm install -g yarn@4.12.0
68+
cache: "yarn"
6769

6870
- run: yarn install --immutable
6971
- name: Lint (stubbed)
@@ -77,18 +79,19 @@ jobs:
7779
needs: install
7880
strategy:
7981
matrix:
80-
node-version: [16.x]
82+
node-version: [18.x]
8183
steps:
8284
- name: Checkout
8385
uses: actions/checkout@v4
8486

87+
- name: Enable Corepack
88+
run: corepack enable
89+
8590
- name: Setup node
8691
uses: actions/setup-node@v4
8792
with:
8893
node-version: ${{ matrix.node-version }}
89-
90-
- name: Install Yarn
91-
run: npm install -g yarn@4.12.0
94+
cache: "yarn"
9295

9396
- run: yarn install --immutable
9497
- run: yarn test
@@ -99,18 +102,19 @@ jobs:
99102
needs: install
100103
strategy:
101104
matrix:
102-
node-version: [16.x]
105+
node-version: [18.x]
103106
steps:
104107
- name: Checkout
105108
uses: actions/checkout@v4
106109

110+
- name: Enable Corepack
111+
run: corepack enable
112+
107113
- name: Setup node
108114
uses: actions/setup-node@v4
109115
with:
110116
node-version: ${{ matrix.node-version }}
111-
112-
- name: Install Yarn
113-
run: npm install -g yarn@4.12.0
117+
cache: "yarn"
114118

115119
- run: yarn install --immutable
116120

.github/workflows/pr.yaml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
node-version: [16.x]
15+
node-version: [18.x]
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
1919

20+
- name: Enable Corepack
21+
run: corepack enable
22+
2023
- name: Setup node
2124
uses: actions/setup-node@v4
2225
with:
2326
node-version: ${{ matrix.node-version }}
24-
25-
- name: Install Yarn
26-
run: npm install -g yarn@4.12.0
27+
cache: "yarn"
2728

2829
- run: yarn install --immutable
2930

@@ -33,18 +34,19 @@ jobs:
3334
needs: install
3435
strategy:
3536
matrix:
36-
node-version: [16.x]
37+
node-version: [18.x]
3738
steps:
3839
- name: Checkout
3940
uses: actions/checkout@v4
4041

42+
- name: Enable Corepack
43+
run: corepack enable
44+
4145
- name: Setup node
4246
uses: actions/setup-node@v4
4347
with:
4448
node-version: ${{ matrix.node-version }}
45-
46-
- name: Install Yarn
47-
run: npm install -g yarn@4.12.0
49+
cache: "yarn"
4850

4951
- run: yarn install --immutable
5052
- run: echo "Linting step - configure linter when ready"
@@ -55,18 +57,19 @@ jobs:
5557
needs: install
5658
strategy:
5759
matrix:
58-
node-version: [16.x]
60+
node-version: [18.x]
5961
steps:
6062
- name: Checkout
6163
uses: actions/checkout@v4
6264

65+
- name: Enable Corepack
66+
run: corepack enable
67+
6368
- name: Setup node
6469
uses: actions/setup-node@v4
6570
with:
6671
node-version: ${{ matrix.node-version }}
67-
68-
- name: Install Yarn
69-
run: npm install -g yarn@4.12.0
72+
cache: "yarn"
7073

7174
- run: yarn install --immutable
7275
- run: yarn test
@@ -77,18 +80,19 @@ jobs:
7780
needs: install
7881
strategy:
7982
matrix:
80-
node-version: [16.x]
83+
node-version: [18.x]
8184
steps:
8285
- name: Checkout
8386
uses: actions/checkout@v4
8487

88+
- name: Enable Corepack
89+
run: corepack enable
90+
8591
- name: Setup node
8692
uses: actions/setup-node@v4
8793
with:
8894
node-version: ${{ matrix.node-version }}
89-
90-
- name: Install Yarn
91-
run: npm install -g yarn@4.12.0
95+
cache: "yarn"
9296

9397
- run: yarn install --immutable
9498
- run: echo "Build step - API doesn't require compilation, dependencies installed successfully"

.yarn/install-state.gz

61.6 KB
Binary file not shown.

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =============================================================================
22
# Eagle-API Multi-Stage Dockerfile
33
# =============================================================================
4-
# Node.js 16 API server for EPIC (Environmental Assessment Office)
4+
# Node.js 18 API server for EPIC (Environmental Assessment Office)
55
#
66
# Build: docker build -t eagle-api .
77
# Run: docker run -p 3000:3000 eagle-api
@@ -10,23 +10,23 @@
1010
# -----------------------------------------------------------------------------
1111
# Stage 1: Dependencies
1212
# -----------------------------------------------------------------------------
13-
FROM node:16-alpine AS base
13+
FROM node:18-alpine AS base
1414

1515
WORKDIR /app
1616

17-
# Install Yarn 4.12.0 globally (Node 16 doesn't support corepack's URL.canParse)
18-
RUN npm install -g yarn@4.12.0
17+
# Enable Corepack for Yarn
18+
RUN corepack enable
1919

2020
# Copy package files
2121
COPY package.json yarn.lock .yarnrc.yml ./
2222

2323
# Install production dependencies only
24-
RUN yarn install --immutable --immutable-cache
24+
RUN yarn install --immutable
2525

2626
# -----------------------------------------------------------------------------
2727
# Stage 2: Production Runtime
2828
# -----------------------------------------------------------------------------
29-
FROM node:16-alpine
29+
FROM node:18-alpine
3030

3131
# Build arguments for labels
3232
ARG COMMIT_SHA

api/helpers/auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ exports.issueToken = function(user,
150150
var hashPassword = function (user, password) {
151151
if (user.salt && password) {
152152
var crypto = require('crypto');
153-
return crypto.pbkdf2Sync(password, new Buffer(user.salt, 'base64'), 10000, 64, 'sha1').toString('base64');
153+
return crypto.pbkdf2Sync(password, Buffer.from(user.salt, 'base64'), 10000, 64, 'sha1').toString('base64');
154154
} else {
155155
return password;
156156
}
157157
};
158158

159159
exports.setPassword = function (user) {
160-
var bcrypt = require('bcrypt-nodejs');
160+
var bcrypt = require('bcryptjs');
161161
user.salt = bcrypt.genSaltSync(16);
162162
user.password = hashPassword(user, user.password);
163163
return user;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@turf/turf": "~5.1.6",
2323
"@types/node-cron": "~2.0.3",
2424
"axios": "^0.28.0",
25-
"bcrypt-nodejs": "~0.0.3",
25+
"bcryptjs": "^2.4.3",
2626
"biguint-format": "~1.0.0",
2727
"body-parser": "^1.20.3",
2828
"clamav.js": "~0.12.0",

test/helpers/auth.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
const { expect } = require('chai');
88
const sinon = require('sinon');
99
const jwt = require('jsonwebtoken');
10-
const bcrypt = require('bcrypt-nodejs');
11-
const mongoose = require('mongoose');
1210

1311
describe('Auth Helper Functions', () => {
1412
let auth;

0 commit comments

Comments
 (0)