freespace-freemind / setup.js
SmartySmile's picture
Upload 45 files
0e0fe0a verified
Raw History Blame Contribute Delete
4.87 kB
#!/usr/bin/env node
/**
* Setup Script for appsONLINE Launcher
* Checks prerequisites and installs dependencies
*/
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
console.log('\n╔════════════════════════════════════════╗');
console.log('║ appsONLINE Setup & Verification ║');
console.log('╚════════════════════════════════════════╝\n');
let allChecks = true;
// Helper function to run commands
function runCommand(cmd, silent = false) {
try {
const output = execSync(cmd, { encoding: 'utf8', stdio: silent ? 'pipe' : 'inherit' });
return { success: true, output: output.trim() };
} catch (error) {
return { success: false, error: error.message };
}
}
// Check Node.js
console.log('📦 Checking Node.js...');
const nodeCheck = runCommand('node --version', true);
if (nodeCheck.success) {
const version = nodeCheck.output;
console.log(` ✅ Node.js ${version} found\n`);
} else {
console.log(' ❌ Node.js not found!');
console.log(' Download from: https://nodejs.org/\n');
allChecks = false;
}
// Check npm
console.log('📦 Checking npm...');
const npmCheck = runCommand('npm --version', true);
if (npmCheck.success) {
const version = npmCheck.output;
console.log(` ✅ npm ${version} found\n`);
} else {
console.log(' ❌ npm not found!\n');
allChecks = false;
}
// Check .NET SDK
console.log('📦 Checking .NET SDK...');
const dotnetCheck = runCommand('dotnet --version', true);
if (dotnetCheck.success) {
const version = dotnetCheck.output;
console.log(` ✅ .NET SDK ${version} found\n`);
} else {
console.log(' ❌ .NET SDK 8.0+ not found!');
console.log(' Download from: https://dotnet.microsoft.com/download\n');
allChecks = false;
}
// Check for .csproj files
console.log('📁 Scanning for MVC applications...');
const csprojFiles = [];
function findCsprojFiles(dir, depth = 0) {
if (depth > 4) return;
try {
const files = fs.readdirSync(dir);
for (const file of files) {
const fullPath = path.join(dir, file);
const stat = fs.statSync(fullPath);
if (stat.isDirectory() && !file.startsWith('.') && file !== 'node_modules') {
if (file.endsWith('.csproj')) {
csprojFiles.push(fullPath);
}
findCsprojFiles(fullPath, depth + 1);
} else if (file.endsWith('.csproj')) {
csprojFiles.push(fullPath);
}
}
} catch (e) {
// Ignore errors
}
}
findCsprojFiles(__dirname);
if (csprojFiles.length > 0) {
console.log(` ✅ Found ${csprojFiles.length} MVC application(s):`);
csprojFiles.forEach(file => {
console.log(` - ${path.relative(__dirname, file)}`);
});
console.log();
} else {
console.log(' ⚠️ No MVC applications found (yet)');
console.log(' You can add them later in subfolders\n');
}
// Check for package.json
console.log('📄 Checking configuration files...');
if (fs.existsSync(path.join(__dirname, 'package.json'))) {
console.log(' ✅ package.json found\n');
} else {
console.log(' ❌ package.json not found!\n');
allChecks = false;
}
// Check if node_modules exists
console.log('📚 Checking dependencies...');
if (fs.existsSync(path.join(__dirname, 'node_modules'))) {
console.log(' ✅ Dependencies already installed\n');
} else {
console.log(' ⚠️ Dependencies not installed yet');
console.log(' Running: npm install...\n');
const installResult = runCommand('npm install');
if (installResult.success) {
console.log(' ✅ Dependencies installed successfully\n');
} else {
console.log(' ❌ Failed to install dependencies!');
console.log(` Error: ${installResult.error}\n`);
allChecks = false;
}
}
// Summary
console.log('╔════════════════════════════════════════╗');
if (allChecks) {
console.log('║ ✅ All checks passed! ║');
console.log('╚════════════════════════════════════════╝\n');
console.log('🚀 Ready to start!\n');
console.log('Run this command to launch the app:\n');
console.log(' npm start\n');
} else {
console.log('║ ⚠️ Some checks failed ║');
console.log('╚════════════════════════════════════════╝\n');
console.log('Please install missing dependencies and try again.\n');
}