Skip to content

Commit 9414b34

Browse files
committed
chore: add check for docker and node in setup dev-demo
1 parent 91725a6 commit 9414b34

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

dev-demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"install-adapters": "cd ../adapters && bash install-adapters.sh",
1919
"build-adminforth": "cd ../adminforth && npm ci && npm run build && npm link",
2020
"migrate:all": "npm run migrate:sqlite && npm run migrate:mysql && npm run migrate:postgres && npm run migrate:clickhouse",
21-
"setup-dev-demo": "npm run build-adminforth && cp .env.local .env && npm run install-plugins && npm run install-adapters && npm install && npm link adminforth && bash ./run_inventory.sh"
21+
"preinstall": "node scripts/check-node.js && node scripts/check-docker.js",
22+
"setup-dev-demo": "npm run preinstall && npm run build-adminforth && cp .env.local .env && npm run install-plugins && npm run install-adapters && npm install && npm link adminforth && bash ./scripts/run_inventory.sh"
2223
},
2324
"author": "",
2425
"license": "ISC",

dev-demo/scripts/check-docker.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { execSync } from 'node:child_process';
2+
3+
try {
4+
execSync('docker --version', { stdio: 'ignore' });
5+
console.log('✅ Docker is installed');
6+
try {
7+
execSync('docker info', { stdio: 'ignore' });
8+
} catch {
9+
console.error('❌ Docker is installed but not running');
10+
process.exit(1);
11+
}
12+
console.log('✅ Docker is Running');
13+
} catch {
14+
console.error(
15+
'❌ Docker is not installed or not available in PATH.\n' +
16+
'Please install Docker: https://docs.docker.com/get-docker/'
17+
);
18+
process.exit(1);
19+
}

dev-demo/scripts/check-node.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const [major] = process.versions.node.split('.').map(Number);
2+
3+
if (major < 20) {
4+
console.error(
5+
`❌ Node.js ${process.versions.node} detected.\n` +
6+
`Please install Node.js 20 or newer.`
7+
);
8+
process.exit(1);
9+
}
10+
11+
console.log(`✅ Node.js ${process.versions.node}`);

0 commit comments

Comments
 (0)