File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " trigger.dev " : patch
3
+ ---
4
+
5
+ Added a Node.js runtime check for the CLI
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import { isLoggedIn } from "../utilities/session.js";
40
40
import { createTaskFileImports , gatherTaskFiles } from "../utilities/taskFiles" ;
41
41
import { UncaughtExceptionError } from "../workers/common/errors" ;
42
42
import { BackgroundWorker , BackgroundWorkerCoordinator } from "../workers/dev/backgroundWorker.js" ;
43
+ import { runtimeCheck } from "../utilities/runtimeCheck" ;
43
44
44
45
let apiClient : CliApiClient | undefined ;
45
46
@@ -72,7 +73,18 @@ export function configureDevCommand(program: Command) {
72
73
} ) ;
73
74
}
74
75
76
+ const MINIMUM_NODE_MAJOR = 18 ;
77
+ const MINIMUM_NODE_MINOR = 16 ;
78
+
75
79
export async function devCommand ( dir : string , options : DevCommandOptions ) {
80
+ try {
81
+ runtimeCheck ( MINIMUM_NODE_MAJOR , MINIMUM_NODE_MINOR ) ;
82
+ } catch ( e ) {
83
+ logger . log ( `${ chalkError ( "X Error:" ) } ${ e } ` ) ;
84
+ process . exitCode = 1 ;
85
+ return ;
86
+ }
87
+
76
88
const authorization = await isLoggedIn ( options . profile ) ;
77
89
78
90
if ( ! authorization . ok ) {
Original file line number Diff line number Diff line change
1
+ import { logger } from "./logger" ;
2
+
3
+ /**
4
+ * This function is used by the dev CLI to make sure that the runtime is compatible
5
+ */
6
+ export function runtimeCheck ( minimumMajor : number , minimumMinor : number ) {
7
+ // Check if the runtime is Node.js
8
+ if ( typeof process === "undefined" ) {
9
+ throw "The dev CLI can only be run in a Node.js compatible environment" ;
10
+ }
11
+
12
+ // Check if the runtime version is compatible
13
+ const [ major = 0 , minor = 0 ] = process . versions . node . split ( "." ) . map ( Number ) ;
14
+
15
+ const isBun = typeof process . versions . bun === "string" ;
16
+
17
+ if ( major < minimumMajor || ( major === minimumMajor && minor < minimumMinor ) ) {
18
+ if ( isBun ) {
19
+ throw `The dev CLI requires at least Node.js ${ minimumMajor } .${ minimumMinor } . You are running Bun ${ process . versions . bun } , which is compatible with Node.js ${ process . versions . node } ` ;
20
+ } else {
21
+ throw `The dev CLI requires at least Node.js ${ minimumMajor } .${ minimumMinor } . You are running Node.js ${ process . versions . node } ` ;
22
+ }
23
+ }
24
+
25
+ logger . debug (
26
+ `Node.js version: ${ process . versions . node } ${ isBun ? ` (Bun ${ process . versions . bun } )` : "" } `
27
+ ) ;
28
+ }
You can’t perform that action at this time.
0 commit comments