File size: 4,867 Bytes
0e0fe0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/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');
}