Skip to content

Commit

Permalink
Validates minimum node version to 18.12.0 for @actual-app/api npm pac…
Browse files Browse the repository at this point in the history
…kage (#1980)
  • Loading branch information
Marethyu1 authored Nov 28, 2023
1 parent c462604 commit 29f323e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// eslint-disable-next-line import/extensions
import * as bundle from './app/bundle.api.js';
import * as injected from './injected';
import { validateNodeVersion } from './validateNodeVersion';

let actualApp;
export const internal = bundle.lib;
Expand All @@ -18,6 +19,8 @@ export async function init(config = {}) {
return;
}

validateNodeVersion();

global.fetch = (...args) =>
import('node-fetch').then(({ default: fetch }) => fetch(...args));

Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"dependencies": {
"better-sqlite3": "^9.1.1",
"compare-versions": "^6.1.0",
"node-fetch": "^3.3.2",
"uuid": "^9.0.0"
},
Expand Down
16 changes: 16 additions & 0 deletions packages/api/validateNodeVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { satisfies } from 'compare-versions';

import * as packageJson from './package.json';

export function validateNodeVersion() {
if (process?.versions?.node) {
const nodeVersion = process?.versions?.node;
const minimumNodeVersion = packageJson.engines.node;

if (!satisfies(nodeVersion, minimumNodeVersion)) {
throw new Error(
`@actual-app/api requires a node version ${minimumNodeVersion}. Found that you are using: ${nodeVersion}. Please upgrade to a higher version`,
);
}
}
}
6 changes: 6 additions & 0 deletions upcoming-release-notes/1980.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [Marethyu1]
---

Validates minimum node version to 18.12.0 for @actual-app/api npm package
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ __metadata:
dependencies:
"@types/uuid": "npm:^9.0.2"
better-sqlite3: "npm:^9.1.1"
compare-versions: "npm:^6.1.0"
node-fetch: "npm:^3.3.2"
typescript: "npm:^5.0.2"
uuid: "npm:^9.0.0"
Expand Down Expand Up @@ -7169,6 +7170,13 @@ __metadata:
languageName: node
linkType: hard

"compare-versions@npm:^6.1.0":
version: 6.1.0
resolution: "compare-versions@npm:6.1.0"
checksum: 20f349e7f8ad784704c68265f4e660e2abbe2c3d5c75793184fccb85f0c5c0263260e01fdd4488376f6b74b0f069e16c9684463f7316b075716fb1581eb36b77
languageName: node
linkType: hard

"compressible@npm:~2.0.16":
version: 2.0.18
resolution: "compressible@npm:2.0.18"
Expand Down

0 comments on commit 29f323e

Please sign in to comment.