diff --git a/package.json b/package.json index ca9aaf76..8f7a9db3 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "ee:check": "infisical run --env=remote -- turbo run ee:check", "ee:build:all": "dotenv -e .env.local -- turbo run ee:build --cache-dir=.turbo", "mock:incoming-mail": "dotenv -e .env.local -- pnpm --dir apps/mail-bridge mock:incoming-mail", - "prepare": "husky" + "prepare": "husky", + "predev": "tsx predev.ts" }, "keywords": [], "author": "Omar McAdam - @McPizza0", diff --git a/predev.ts b/predev.ts new file mode 100644 index 00000000..86139377 --- /dev/null +++ b/predev.ts @@ -0,0 +1,21 @@ +import { lstatSync, readFileSync } from 'fs'; + +// Check Node version +const nodeVersion = process.version; +const requiredVersion = readFileSync('.nvmrc', 'utf-8').trim(); + +if (!nodeVersion.startsWith(requiredVersion)) { + console.error( + `You are using Node ${nodeVersion}, but this project requires Node ${requiredVersion}.\nUse the correct node version to run this project` + ); + process.exit(1); +} + +// Check for env file +const envFile = lstatSync('.env.local', { throwIfNoEntry: false }); +if (!envFile?.isFile()) { + console.error( + 'You are missing a .env.local file. Please refer to the README for instructions on how to create one.' + ); + process.exit(1); +}