-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add node version validation script
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const semver = require('semver'); | ||
const { resolveRootPath } = require('../helper'); | ||
|
||
module.exports = { | ||
execute: () => { | ||
const packageJsonPath = path.join(resolveRootPath(), 'package.json'); | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
const requiredNodeVersion = packageJson?.engines?.node; | ||
const currentNodeVersion = process.version; | ||
|
||
if (!requiredNodeVersion) { | ||
console.error('No engines.node configuration found in package.json'); | ||
process.exit(1); | ||
} | ||
|
||
if (!semver.satisfies(currentNodeVersion, requiredNodeVersion)) { | ||
console.error(`\nCurrent Node.js version ${currentNodeVersion} does not meet requirements!`); | ||
console.error(`Please use Node.js version ${requiredNodeVersion}\n`); | ||
process.exit(1); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,14 @@ | |
}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"env": "node .knosys/scripts env", | ||
"presetup": "npm run env", | ||
"setup": "cross-env cp .env.example .env.local && npx auth secret", | ||
"predev": "npm run env", | ||
"dev": "cross-env NEXT_PUBLIC_DOMAIN_ENV=development next dev -p 3000", | ||
"build": "next build", | ||
"build:test": "NODE_ENV=test NEXT_PUBLIC_DOMAIN_ENV=test next build", | ||
"prestart": "npm run env", | ||
"start": "cross-env NEXT_PUBLIC_DOMAIN_ENV=development next dev -p 3000", | ||
"start:test": "NODE_ENV=test NEXT_PUBLIC_DOMAIN_ENV=test next start -p 3001", | ||
"analyze": "cross-env ANALYZE=true next build", | ||
|
@@ -134,6 +138,7 @@ | |
"lint-staged": "15.3.0", | ||
"postcss": "^8.4.18", | ||
"prettier": "^2.5.1", | ||
"semver": "^7.6.3", | ||
"tailwindcss": "3.4.16" | ||
} | ||
} | ||
} |