UNPKG

haloapi-mcp-tools

Version:

Model Context Protocol (MCP) server for interacting with the HaloPSA API

102 lines (87 loc) 3.08 kB
#!/usr/bin/env node /** * TypeScript Build Script * * This script builds all TypeScript modules in the project. * Currently focused on the HaloAPI MCP server. */ const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); // Define the path to the TypeScript configuration file const tsConfigPath = path.join(__dirname, '..', 'tsconfig.json'); // Define the path to the haloapi directory const haloApiPath = path.join(__dirname, '..', 'src', 'haloapi'); // Check if the tsconfig.json file exists if (!fs.existsSync(tsConfigPath)) { console.error('Error: tsconfig.json file not found'); process.exit(1); } // Check if the haloapi directory exists if (!fs.existsSync(haloApiPath)) { console.error('Error: src/haloapi directory not found'); process.exit(1); } // Build the TypeScript code try { console.log('Building TypeScript code...'); execSync('tsc', { stdio: 'inherit' }); console.log('TypeScript build completed successfully'); } catch (error) { console.error('Error building TypeScript code:', error.message); process.exit(1); } // Make the output files executable try { console.log('Making output files executable...'); const distDir = path.join(__dirname, '..', 'dist'); if (fs.existsSync(distDir)) { const files = fs.readdirSync(distDir); files.forEach(file => { if (file.endsWith('.js')) { const filePath = path.join(distDir, file); // Check if file exists if (fs.existsSync(filePath)) { const isWindows = process.platform === 'win32'; if (!isWindows) { try { // Make the file executable (Unix-like systems only) fs.chmodSync(filePath, '755'); console.log(`Made ${filePath} executable`); } catch (chmodErr) { console.warn(`Warning: Could not make ${filePath} executable: ${chmodErr.message}`); } } } } }); } // Also make the HaloAPI MCP server executable const haloApiDistDir = path.join(haloApiPath, 'dist'); if (fs.existsSync(haloApiDistDir)) { const files = fs.readdirSync(haloApiDistDir); files.forEach(file => { if (file.endsWith('.js')) { const filePath = path.join(haloApiDistDir, file); // Check if file exists if (fs.existsSync(filePath)) { const isWindows = process.platform === 'win32'; if (!isWindows) { try { // Make the file executable (Unix-like systems only) fs.chmodSync(filePath, '755'); console.log(`Made ${filePath} executable`); } catch (chmodErr) { console.warn(`Warning: Could not make ${filePath} executable: ${chmodErr.message}`); } } } } }); } console.log('All output files made executable successfully'); } catch (error) { console.error('Error making output files executable:', error.message); process.exit(1); } console.log('Build process completed successfully');