Added requirements script to ensure the current system can run Makerkit. (#78)
1. Check Node.js version is greater than 18.18.0 2. Check the current path doesn't include OneDrive. OneDrive causes issue with importing modules.
This commit is contained in:
committed by
GitHub
parent
f9bd5b3802
commit
3bfc643691
@@ -10,6 +10,7 @@
|
||||
"name": "MakerKit"
|
||||
},
|
||||
"scripts": {
|
||||
"preinstall": "pnpm run --filter scripts requirements",
|
||||
"postinstall": "manypkg fix",
|
||||
"build": "turbo build --cache-dir=.turbo",
|
||||
"clean": "git clean -xdf node_modules dist .next",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"dev": "node ./src/dev.mjs",
|
||||
"checks": "node ./src/checks.mjs"
|
||||
"checks": "node ./src/checks.mjs",
|
||||
"requirements": "node ./src/requirements.mjs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
import './version.mjs';
|
||||
import './license.mjs';
|
||||
import './license.mjs';
|
||||
import './requirements.mjs';
|
||||
48
tooling/scripts/src/requirements.mjs
Normal file
48
tooling/scripts/src/requirements.mjs
Normal file
@@ -0,0 +1,48 @@
|
||||
// check requirements to run Makerkit
|
||||
void checkRequirements();
|
||||
|
||||
function checkRequirements() {
|
||||
checkNodeVersion();
|
||||
checkPathNotOneDrive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current Node version is compatible with Makerkit.
|
||||
* If the current Node version is not compatible, it exits the script with an error message.
|
||||
*/
|
||||
function checkNodeVersion() {
|
||||
const requiredNodeVersion = '>=v18.18.0';
|
||||
const currentNodeVersion = process.versions.node;
|
||||
const [major, minor] = currentNodeVersion.split('.').map(Number);
|
||||
|
||||
if (major < 18 || (major === 18 && minor < 18)) {
|
||||
console.error(
|
||||
`\x1b[31m%s\x1b[0m`,
|
||||
`You are running Node ${currentNodeVersion}. Makerkit requires Node ${requiredNodeVersion}.`,
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log(
|
||||
`\x1b[32m%s\x1b[0m`,
|
||||
`You are running Node ${currentNodeVersion}.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current working directory is not OneDrive.
|
||||
* If the current working directory is OneDrive, it exits the script with an error message.
|
||||
*/
|
||||
function checkPathNotOneDrive() {
|
||||
const path = process.cwd();
|
||||
|
||||
if (path.includes('OneDrive')) {
|
||||
console.error(
|
||||
`\x1b[31m%s\x1b[0m`,
|
||||
`You are running Makerkit from OneDrive. Please move your project to a local folder.`,
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user