|
| 1 | +#!/usr/bin/env node |
| 2 | +/** |
| 3 | + * Quick check script to verify TypeScript LSP is ready |
| 4 | + * Run: node check-lsp-ready.js |
| 5 | + */ |
| 6 | + |
| 7 | +const fs = require('fs'); |
| 8 | +const path = require('path'); |
| 9 | +const { execSync } = require('child_process'); |
| 10 | + |
| 11 | +console.log('╔════════════════════════════════════════════════════════════╗'); |
| 12 | +console.log('║ TypeScript LSP Integration - Readiness Check ║'); |
| 13 | +console.log('╚════════════════════════════════════════════════════════════╝\n'); |
| 14 | + |
| 15 | +let allGood = true; |
| 16 | + |
| 17 | +// Check 1: LSP Infrastructure Enabled |
| 18 | +console.log('1. LSP Infrastructure'); |
| 19 | +const clientLoaderPath = './src/languageTools/ClientLoader.js'; |
| 20 | +const clientLoaderContent = fs.readFileSync(clientLoaderPath, 'utf8'); |
| 21 | +const lspEnabled = clientLoaderContent.includes('initDomainAndHandleNodeCrash();') && |
| 22 | + !clientLoaderContent.includes('//initDomainAndHandleNodeCrash();'); |
| 23 | +console.log(' Status:', lspEnabled ? '✓ Enabled' : '✗ Disabled'); |
| 24 | +if (!lspEnabled) allGood = false; |
| 25 | + |
| 26 | +// Check 2: Extension Registered |
| 27 | +console.log('\n2. TypeScriptLanguageServer Extension'); |
| 28 | +const extensionsPath = './src/extensions/default/DefaultExtensions.json'; |
| 29 | +const extensionsContent = fs.readFileSync(extensionsPath, 'utf8'); |
| 30 | +const registered = extensionsContent.includes('"TypeScriptLanguageServer"'); |
| 31 | +console.log(' Registered:', registered ? '✓ Yes' : '✗ No'); |
| 32 | +if (!registered) allGood = false; |
| 33 | + |
| 34 | +// Check 3: Extension Files |
| 35 | +console.log('\n3. Extension Files'); |
| 36 | +const mainJs = './src/extensions/default/TypeScriptLanguageServer/main.js'; |
| 37 | +const clientJs = './src/extensions/default/TypeScriptLanguageServer/client.js'; |
| 38 | +console.log(' main.js:', fs.existsSync(mainJs) ? '✓ Exists' : '✗ Missing'); |
| 39 | +console.log(' client.js:', fs.existsSync(clientJs) ? '✓ Exists' : '✗ Missing'); |
| 40 | +if (!fs.existsSync(mainJs) || !fs.existsSync(clientJs)) allGood = false; |
| 41 | + |
| 42 | +// Check 4: TypeScript Language Server |
| 43 | +console.log('\n4. TypeScript Language Server'); |
| 44 | +const serverPath = './node_modules/.bin/typescript-language-server'; |
| 45 | +const serverExists = fs.existsSync(serverPath); |
| 46 | +console.log(' Installed:', serverExists ? '✓ Yes' : '✗ No'); |
| 47 | + |
| 48 | +if (serverExists) { |
| 49 | + try { |
| 50 | + const version = execSync(serverPath + ' --version', { encoding: 'utf8' }).trim(); |
| 51 | + console.log(' Version:', version); |
| 52 | + } catch (err) { |
| 53 | + console.log(' Version: ✗ Cannot execute'); |
| 54 | + allGood = false; |
| 55 | + } |
| 56 | +} else { |
| 57 | + allGood = false; |
| 58 | +} |
| 59 | + |
| 60 | +// Check 5: Client Path Resolution |
| 61 | +console.log('\n5. Path Resolution in client.js'); |
| 62 | +const clientContent = fs.readFileSync(clientJs, 'utf8'); |
| 63 | +const hasCorrectPath = clientContent.includes('../../../../node_modules/.bin/typescript-language-server'); |
| 64 | +console.log(' Path:', hasCorrectPath ? '✓ Correct (4 levels up)' : '✗ Wrong'); |
| 65 | +if (!hasCorrectPath) allGood = false; |
| 66 | + |
| 67 | +// Check 6: Simulate Path Resolution |
| 68 | +console.log('\n6. Path Resolution Test'); |
| 69 | +const clientDir = path.dirname(path.resolve(clientJs)); |
| 70 | +const resolvedPath = path.resolve(clientDir, '../../../../node_modules/.bin/typescript-language-server'); |
| 71 | +const pathCorrect = fs.existsSync(resolvedPath); |
| 72 | +console.log(' From:', clientDir); |
| 73 | +console.log(' To:', resolvedPath); |
| 74 | +console.log(' Valid:', pathCorrect ? '✓ Yes' : '✗ No'); |
| 75 | +if (!pathCorrect) allGood = false; |
| 76 | + |
| 77 | +// Summary |
| 78 | +console.log('\n' + '═'.repeat(60)); |
| 79 | +if (allGood) { |
| 80 | + console.log('✓✓✓ ALL CHECKS PASSED ✓✓✓'); |
| 81 | + console.log('\nTypeScript LSP is ready! To test:'); |
| 82 | + console.log(' 1. npm run serve'); |
| 83 | + console.log(' 2. Open http://localhost:8000/src in browser'); |
| 84 | + console.log(' 3. Check browser console for initialization messages'); |
| 85 | + console.log(' 4. Open a .js file and test code completion'); |
| 86 | +} else { |
| 87 | + console.log('✗✗✗ SOME CHECKS FAILED ✗✗✗'); |
| 88 | + console.log('\nPlease fix the issues above before testing.'); |
| 89 | +} |
| 90 | +console.log('═'.repeat(60)); |
| 91 | + |
| 92 | +process.exit(allGood ? 0 : 1); |
0 commit comments