{"_id":"@ai-universe/typescript-server-launcher","_rev":"2-da228b960a21d14ac8dad2ff810fa319","name":"@ai-universe/typescript-server-launcher","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ai-universe/typescript-server-launcher","version":"1.0.0","keywords":["typescript","server","launcher","process-manager","port-management","development-tools","ai-universe"],"author":{"name":"AI Universe Team"},"license":"MIT","_id":"@ai-universe/typescript-server-launcher@1.0.0","maintainers":[{"name":"jleechan","email":"jleechan+npm@gmail.com"}],"dist":{"shasum":"357fbb6beffc6d24353c06ada8b7ea420f0f8bdc","tarball":"https://registry.npmjs.org/@ai-universe/typescript-server-launcher/-/typescript-server-launcher-1.0.0.tgz","fileCount":32,"integrity":"sha512-wOdqX+EII8i22BRVWrz2msVHgLdskJU586++Pxg0e+N5YyCg6+aBErL9DRBMWney7eUI2KpFKWfZgowlwFp6Fw==","signatures":[{"sig":"MEYCIQDwMM8qWPhNm7akVi3l6LvOBCfxiACo/J6Z9OOqPrpurQIhALyEhC7MOoq+c68I90HN57TcQT2mQvaoeWsF3bKTBV9q","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122402},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","gitHead":"876753e9eac9fb65b53793801d7329e87867bbe1","scripts":{"test":"jest","build":"tsc","clean":"rm -rf dist","prepare":"node ../../scripts/run-build-if-ready.mjs","test:watch":"jest --watch"},"_npmUser":{"name":"jleechan","email":"jleechan+npm@gmail.com"},"_npmVersion":"8.19.4","description":"Generic TypeScript server launcher with port management, process control, and build orchestration","directories":{},"_nodeVersion":"20.19.4","dependencies":{"@types/node":"^20.11.19"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.2","typescript":"^5.9.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/typescript-server-launcher_1.0.0_1762927157750_0.9551779256508004","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@ai-universe/typescript-server-launcher","version":"1.0.1","description":"Generic TypeScript server launcher with port management, process control, and build orchestration","type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"node ../../scripts/run-build-if-ready.mjs","clean":"rm -rf dist","test":"jest","test:watch":"jest --watch"},"dependencies":{"@types/node":"^20.11.19"},"devDependencies":{"@types/jest":"^29.5.12","jest":"^29.7.0","ts-jest":"^29.1.2","typescript":"^5.9.3"},"keywords":["typescript","server","launcher","process-manager","port-management","development-tools","ai-universe"],"author":{"name":"AI Universe Team"},"license":"MIT","publishConfig":{"access":"public"},"_id":"@ai-universe/typescript-server-launcher@1.0.1","_nodeVersion":"20.19.4","_npmVersion":"8.19.4","dist":{"integrity":"sha512-PXxKeM76efh7gSrFONOG11b2DqapLfBqxh/KhiePLuS10ZNh8U1Yrp/vTVQOzHkYZ5sfrQ7NHCcUCVdbq+IIWA==","shasum":"14273caee4a98977658117a8bf439eff595948e3","tarball":"https://registry.npmjs.org/@ai-universe/typescript-server-launcher/-/typescript-server-launcher-1.0.1.tgz","fileCount":31,"unpackedSize":122337,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC/sKptXWwPy+YztGnS376q9HySZtjDGP5qzv5YMw2zDwIgf4PlwANe7NQQ1jdmmvgfkdXM4p6Z7t1Iox++emzhNmw="}]},"_npmUser":{"name":"jleechan","email":"jleechan+npm@gmail.com"},"directories":{},"maintainers":[{"name":"jleechan","email":"jleechan+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-server-launcher_1.0.1_1763755342856_0.4476828202609944"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-12T05:59:17.681Z","modified":"2025-11-21T20:02:23.271Z","1.0.0":"2025-11-12T05:59:17.915Z","1.0.1":"2025-11-21T20:02:23.058Z"},"author":{"name":"AI Universe Team"},"license":"MIT","keywords":["typescript","server","launcher","process-manager","port-management","development-tools","ai-universe"],"description":"Generic TypeScript server launcher with port management, process control, and build orchestration","maintainers":[{"name":"jleechan","email":"jleechan+npm@gmail.com"}],"readme":"# @ai-universe/typescript-server-launcher\n\nGeneric TypeScript server launcher with advanced port management, process control, and build orchestration.\n\n## Features\n\n- ✅ **Configurable Port Selection**: Preferred port with automatic fallback\n- ✅ **Process Management**: PID tracking, graceful/forceful termination, cross-platform support\n- ✅ **Build Orchestration**: Automatic dependency installation, TypeScript compilation, custom prepare scripts\n- ✅ **Watch Mode**: Auto-restart on file changes for development\n- ✅ **Production Mode**: Single-run server startup for production\n- ✅ **Retry Logic**: Automatic retry for EADDRINUSE (port conflict) errors\n- ✅ **Lifecycle Hooks**: Custom callbacks for build stages and server events\n- ✅ **Port Reclamation**: Force reclaim ports by terminating existing processes\n\n## Installation\n\n```bash\nnpm install @ai-universe/typescript-server-launcher\n```\n\n## Quick Start\n\n```typescript\nimport { TypeScriptServerLauncher } from '@ai-universe/typescript-server-launcher';\n\nconst launcher = new TypeScriptServerLauncher({\n  serverDir: 'backend',\n  devCommand: ['npm', 'run', 'dev'],\n  startCommand: ['npm', 'run', 'start']\n});\n\nawait launcher.launch();\n```\n\n## Documentation\n\nSee [docs/TYPESCRIPT_SERVER_LAUNCHER_LIBRARY.md](../../../docs/TYPESCRIPT_SERVER_LAUNCHER_LIBRARY.md) for comprehensive documentation including:\n\n- Complete API reference\n- Configuration options\n- Usage examples\n- Migration guide\n- Best practices\n\n## API Reference\n\n### TypeScriptServerLauncher\n\nMain orchestrator class for launching TypeScript servers.\n\n```typescript\nconst launcher = new TypeScriptServerLauncher({\n  projectRoot?: string;\n  serverDir: string;\n  devCommand: string[];\n  startCommand: string[];\n  preferredPort?: number;\n  minPort?: number;\n  maxPort?: number;\n  forcePort?: boolean;\n  watchMode?: boolean;\n  env?: Record<string, string>;\n  buildCommand?: string[];\n  skipDependencyInstall?: boolean;\n  skipBuild?: boolean;\n  prepareScriptPath?: string;\n  maxRetries?: number;\n  pidFile?: string;\n  onBeforeBuild?: () => Promise<void> | void;\n  onAfterBuild?: () => Promise<void> | void;\n  onServerStarted?: (port: number, pid: number) => Promise<void> | void;\n  onServerExit?: (code: number | null) => Promise<void> | void;\n});\n\nawait launcher.launch();  // Launch with full build pipeline\nawait launcher.stop();    // Stop the server\nconst port = launcher.getPort();  // Get current port\nconst pid = launcher.getPid();    // Get process PID\n```\n\n### Port Management\n\n```typescript\nimport { findAvailablePort, isPortAvailable, parsePortEnv } from '@ai-universe/typescript-server-launcher';\n\n// Find available port with randomized search\nconst port = await findAvailablePort({ minPort: 2000, maxPort: 2500 });\n\n// Check if specific port is available\nconst available = await isPortAvailable(3000);\n\n// Parse port from environment variable\nconst port = parsePortEnv(process.env.PORT, 'PORT') ?? 2000;\n```\n\n### Process Management\n\n```typescript\nimport {\n  isProcessAlive,\n  terminateProcessByPid,\n  writePidFile,\n  readPidFile,\n  removePidFile\n} from '@ai-universe/typescript-server-launcher';\n\n// Check if process is running\nif (isProcessAlive(1234)) {\n  await terminateProcessByPid(1234);\n}\n\n// PID file management\nwritePidFile('/path/to/pid', 1234);\nconst pid = readPidFile('/path/to/pid');\nremovePidFile('/path/to/pid');\n```\n\n### Build Orchestration\n\n```typescript\nimport {\n  checkAndInstallDependencies,\n  buildTypeScript,\n  runCustomPrepareScript\n} from '@ai-universe/typescript-server-launcher';\n\n// Install dependencies if needed\ncheckAndInstallDependencies('/path/to/project');\n\n// Build TypeScript project\nbuildTypeScript('/path/to/project');\n\n// Run custom prepare script\nrunCustomPrepareScript('scripts/prepare.mjs', '/path/to/project');\n```\n\n## License\n\nMIT\n\n## Author\n\nAI Universe Team\n","readmeFilename":"README.md"}