UNPKG

@railway/mcp-server

Version:
62 lines (60 loc) 2.67 kB
import { analyzeRailwayError } from "./error-handling-mxVa5oOu.js"; import { checkRailwayCliStatus, runRailwayCommand } from "./core-BMlc7cvF.js"; import { getLinkedProjectInfo } from "./projects-ENU6yIz7.js"; import { getRailwayServices } from "./services-BXZqOgoN.js"; import { getCliFeatureSupport, getRailwayVersion } from "./version-BriONvFH.js"; //#region src/cli/deployment.ts const deployRailwayProject = async ({ workspacePath, environment, service, ci }) => { try { await checkRailwayCliStatus(); const result = await getLinkedProjectInfo({ workspacePath }); if (!result.success) throw new Error(result.error); let command = "railway up"; if (ci) command += " --ci"; if (environment) command += ` --environment ${environment}`; if (service) command += ` --service ${service}`; const { output: deployOutput } = await runRailwayCommand(command, workspacePath); try { const servicesResult = await getRailwayServices({ workspacePath }); if (servicesResult.success && servicesResult.services && servicesResult.services.length > 0) { const firstService = servicesResult.services[0]; const { output: linkOutput } = await runRailwayCommand(`railway service ${firstService}`, workspacePath); return `${deployOutput}\n\nService linked: ${firstService}\n${linkOutput}`; } } catch (linkError) { console.warn("Warning: Could not automatically link service after deployment:", linkError); } return deployOutput; } catch (error) { return analyzeRailwayError(error, "railway up"); } }; const listDeployments = async ({ workspacePath, service, environment, limit = 20, json = false }) => { try { await checkRailwayCliStatus(); if (!(await getCliFeatureSupport()).deployment.list) return { success: false, error: `Railway CLI version ${await getRailwayVersion() || "unknown"} does not support 'deployment list' command. Please upgrade to version 4.10.0 or later.` }; const projectResult = await getLinkedProjectInfo({ workspacePath }); if (!projectResult.success) return { success: false, error: projectResult.error ?? "Failed to get project info" }; let command = "railway deployment list"; if (service) command += ` --service ${service}`; if (environment) command += ` --environment ${environment}`; if (limit) command += ` --limit ${limit}`; if (json) command += " --json"; const { output } = await runRailwayCommand(command, workspacePath); return { success: true, output }; } catch (error) { return analyzeRailwayError(error, `railway deployment list`); } }; //#endregion export { deployRailwayProject, listDeployments }; //# sourceMappingURL=deployment-DXcNTO8k.js.map