Skip to content

A local-first personal finance app

chore(api): migrate node version validation to TypeScript (#8461)

Ehtasham Yasin0146471d0ea9
diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json
index a3b6d43dbd..d938343d1a 100644
--- a/packages/api/tsconfig.json
+++ b/packages/api/tsconfig.json
@@ -30,7 +30,7 @@
"path": "../crdt"
}
],
- "include": ["."],
+ "include": [".", "package.json"],
"exclude": [
"**/node_modules/*",
"dist",
diff --git a/packages/api/validateNodeVersion.js b/packages/api/validateNodeVersion.js
deleted file mode 100644
index d2bfb828a4..0000000000
--- a/packages/api/validateNodeVersion.js
+++ /dev/null
@@ -1,16 +0,0 @@
-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`,
- );
- }
- }
-}
diff --git a/packages/api/validateNodeVersion.ts b/packages/api/validateNodeVersion.ts
new file mode 100644
index 0000000000..875033a5fa
--- /dev/null
+++ b/packages/api/validateNodeVersion.ts
@@ -0,0 +1,14 @@
+import { satisfies } from 'compare-versions';
+
+import * as packageJson from './package.json';
+
+export function validateNodeVersion(): void {
+ 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`,
+ );
+ }
+}
diff --git a/upcoming-release-notes/wip-chore-api-migrate-node-version-validation-to-typescript.md b/upcoming-release-notes/wip-chore-api-migrate-node-version-validation-to-typescript.md
new file mode 100644
index 0000000000..b8d8264159
--- /dev/null
+++ b/upcoming-release-notes/wip-chore-api-migrate-node-version-validation-to-typescript.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [Ehtasham-Yasin]
+---
+
+Migrate node version validation to TypeScript