infra-kit 0.1.82 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -0
- package/.turbo/turbo-build.log +11 -0
- package/.turbo/turbo-eslint-check.log +5 -0
- package/.turbo/turbo-prettier-check.log +5 -0
- package/.turbo/turbo-test.log +17 -0
- package/.turbo/turbo-ts-check.log +5 -0
- package/dist/cli.js +5 -3
- package/dist/cli.js.map +3 -3
- package/dist/mcp.js +6 -4
- package/dist/mcp.js.map +3 -3
- package/package.json +10 -11
- package/src/commands/gh-merge-dev/gh-merge-dev.ts +2 -2
- package/src/lib/command-echo/command-echo.ts +1 -1
- package/src/lib/release-utils/release-utils.ts +2 -1
- package/src/mcp/server.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/.env.example +0 -17
package/dist/mcp.js
CHANGED
|
@@ -4,7 +4,7 @@ import{StdioServerTransport as Ht}from"@modelcontextprotocol/sdk/server/stdio.js
|
|
|
4
4
|
`),Kr.stdout.write(`${o}
|
|
5
5
|
`),pe.unlinkSync(r);let i={variableCount:t.length,unsetStatements:n};return{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i}},Te={name:"env-clear",description:"Clear loaded env vars. Returns a file path that must be sourced (source <path>) to apply. The env-clear shell alias does this automatically.",inputSchema:{},outputSchema:{filePath:me.string().describe("Path to the file that must be sourced to apply"),variableCount:me.number().describe("Number of variables cleared"),unsetStatements:me.array(me.string()).describe("Unset statements generated")},handler:pr};import{z as ke}from"zod";import mr from"node:process";import{$ as ur}from"zx";var D=async()=>{try{await ur`doppler --version`}catch(e){s.error({error:e},"Error: Doppler CLI is not installed."),s.error("Please install it from: https://docs.doppler.com/docs/install-cli"),mr.exit(1)}try{await ur`doppler me`}catch(e){s.error({error:e},"Error: Doppler CLI is not authenticated."),s.error("Please authenticate by running: doppler login"),mr.exit(1)}};import Zr from"node:path";import{$ as dr}from"zx";var N=async e=>{let t=(await dr`git worktree list`).stdout.split(`
|
|
6
6
|
`).filter(Boolean),n={release:Xr,feature:Yr};return t.map(n[e]).filter(o=>o!==null)},Xr=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("release/v")?null:`release/${r[0]?.split("/").pop()||""}`},Yr=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("feature/")?null:`feature/${r[0]?.split("/").pop()||""}`},E=async()=>(await dr`git rev-parse --show-toplevel`).stdout.trim();var Z=async()=>{let e=await E(),r=Zr.basename(e),t=be[r];if(!t)throw new Error(`Could not determine Doppler project for directory "${r}". Expected one of: ${Object.keys(be).join(", ")}`);return t};var fr=async()=>{await D();let e=await Z();s.info(`Doppler project: ${e}
|
|
7
|
-
`),s.info("Available configs:");for(let t of k)s.info(` - ${t}`);let r={project:e,configs:k};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}},$e={name:"env-list",description:"List available Doppler configs for the detected project",inputSchema:{},outputSchema:{project:ke.string().describe("Detected Doppler project name"),configs:ke.array(ke.string()).describe("Available environment configs")},handler:fr};import et from"@inquirer/select";import gr from"node:fs";import rt from"node:path";import hr from"node:process";import{z as Q}from"zod";import{$ as Ee}from"zx";var Qr=()=>{let e="",r=[],t=!1;return{start(n){e=n,r=[],t=!1},setInteractive(){t=!0},addOption(n,o){r.push({flag:n,value:o})},print(){if(!t||r.length===0)return;let n=r.map(o=>typeof o.value=="boolean"?o.value?o.flag:"":Array.isArray(o.value)?`${o.flag} "${o.value.join(", ")}"`:`${o.flag} ${o.value}`).filter(Boolean).join(" ");s.info(`\u{1F4DF} Equivalent command:
|
|
7
|
+
`),s.info("Available configs:");for(let t of k)s.info(` - ${t}`);let r={project:e,configs:k};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}},$e={name:"env-list",description:"List available Doppler configs for the detected project",inputSchema:{},outputSchema:{project:ke.string().describe("Detected Doppler project name"),configs:ke.array(ke.string()).describe("Available environment configs")},handler:fr};import et from"@inquirer/select";import gr from"node:fs";import rt from"node:path";import hr from"node:process";import{z as Q}from"zod";import{$ as Ee}from"zx";var Qr=()=>{let e="",r=[],t=!1;return{start(n){e=n,r=[],t=!1},setInteractive(){t=!0},addOption(n,o){r.push({flag:n,value:o})},print(){if(!t||r.length===0)return;let n=r.map(o=>typeof o.value=="boolean"?o.value?o.flag:"":Array.isArray(o.value)?`${o.flag} "${o.value.join(", ")}"`:`${o.flag} "${o.value}"`).filter(Boolean).join(" ");s.info(`\u{1F4DF} Equivalent command:
|
|
8
8
|
pnpm exec infra-kit ${e} ${n}
|
|
9
9
|
`)},reset(){e="",r=[],t=!1}}},c=Qr();var vr=async e=>{await D();let{config:r}=e;c.start("env-load");let t="";r?t=r:(c.setInteractive(),t=await et({message:"Select environment config",choices:k.map(f=>({name:f,value:f}))},{output:hr.stderr})),c.addOption("--config",t);let n=await Z();Ee.quiet=!0;let o=await Ee`doppler secrets download --no-file --format env --project ${n} --config ${t}`;Ee.quiet=!1;let i=o.stdout.trim(),a=new Date().toISOString(),p=["set -a",i,`${V}=${t}`,`${M}=${n}`,`${F}=${a}`,"set +a"],l=B(),m=rt.resolve(l,L);gr.mkdirSync(l,{recursive:!0}),gr.writeFileSync(m,`${p.join(`
|
|
10
10
|
`)}
|
|
@@ -13,12 +13,14 @@ pnpm exec infra-kit ${e} ${n}
|
|
|
13
13
|
`).filter(f=>f.includes("=")).length,project:n,config:t};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}},Ce={name:"env-load",description:"Load Doppler env vars for a config. Returns a file path that must be sourced (source <path>) to apply variables. The env-load shell alias does this automatically.",inputSchema:{config:Q.string().describe("Environment config name to load (e.g. dev, arthur, renana)")},outputSchema:{filePath:Q.string().describe("Path to the file that must be sourced to apply variables"),variableCount:Q.number().describe("Number of variables loaded"),project:Q.string().describe("Doppler project name"),config:Q.string().describe("Doppler config name")},handler:vr};import tt from"node:path";import ee from"node:process";import{z as U}from"zod";var yr=async()=>{await D(),s.info("Environment session status:");let e=B(),r=ee.env[xe],t=tt.join(e,L),n=0,o=0,i=ee.env[V]??null,a=ee.env[M]??null,p=ee.env[F]??null;if(i){let m=le(t);m.length>0&&(o=m.length,n=m.filter(u=>u in ee.env).length);let d=p?.replace(/\.\d{3}Z$/,"")??null;s.info(` ${i}: ${n} of ${o} vars loaded (project: ${a}, loadedAt: ${d}, session: ${r})
|
|
14
14
|
`)}else s.info(` Session ${r}: no env loaded
|
|
15
15
|
`);let l={sessionId:r,sessionLoadedCount:n,sessionTotalCount:o,sessionConfig:i,sessionProject:a,sessionLoadedAt:p};return{content:[{type:"text",text:JSON.stringify(l,null,2)}],structuredContent:l}},Se={name:"env-status",description:"Show Doppler authentication status and detected project info",inputSchema:{},outputSchema:{sessionId:U.string().describe("Current terminal session ID"),sessionLoadedCount:U.number().describe("Number of cached vars active in the current session"),sessionTotalCount:U.number().describe("Total number of cached var names"),sessionConfig:U.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:U.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:U.string().nullable().describe("ISO 8601 timestamp of when the env was loaded")},handler:yr};import it from"@inquirer/checkbox";import at from"@inquirer/confirm";import ct from"node:process";import{z}from"zod";import{$ as A}from"zx";import{$ as gs}from"zx";import he from"node:process";import{$ as C}from"zx";import{$ as oe}from"zx";import re from"node:process";var Ae=async(e,r)=>{try{let{baseUrl:t,token:n,email:o,projectId:i}=r,a={name:e.name,projectId:e.projectId||i,description:e.description||"",released:e.released||!1,archived:e.archived||!1},p=`${t}/rest/api/3/version`,l=btoa(`${o}:${n}`),m=await fetch(p,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${l}`},body:JSON.stringify(a)});if(!m.ok){let u=await m.text();throw s.error({status:m.status,statusText:m.statusText,error:u},"Failed to create Jira version"),new Error(`HTTP ${m.status}: ${m.statusText}`)}return{success:!0,version:await m.json()}}catch(t){throw s.error({error:t},"Error creating Jira version"),t}},ue=async e=>{try{let{baseUrl:r,token:t,email:n,projectId:o}=e,i=`${r}/rest/api/3/project/${o}/versions`,a=btoa(`${n}:${t}`),p=await fetch(i,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${a}`}});if(!p.ok){let m=await p.text();throw s.error({status:p.status,statusText:p.statusText,error:m},"Failed to get Jira project versions"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return await p.json()}catch(r){throw s.error({error:r},"Error getting Jira project versions"),r}},st=async(e,r)=>{try{return(await ue(r)).find(o=>o.name===e)||null}catch(t){throw s.error({error:t,versionName:e},"Error finding Jira version by name"),t}},nt=async(e,r)=>{try{let{baseUrl:t,token:n,email:o}=r,i={released:e.released??!0,archived:e.archived??!1};e.releaseDate?i.releaseDate=e.releaseDate:e.released!==!1&&(i.releaseDate=new Date().toISOString().split("T")[0]),e.description!==void 0&&(i.description=e.description);let a=`${t}/rest/api/3/version/${e.versionId}`,p=btoa(`${o}:${n}`),l=await fetch(a,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${p}`},body:JSON.stringify(i)});if(!l.ok){let d=await l.text();throw s.error({status:l.status,statusText:l.statusText,error:d},"Failed to update Jira version"),new Error(`HTTP ${l.status}: ${l.statusText}`)}return{success:!0,version:await l.json()}}catch(t){throw s.error({error:t},"Error updating Jira version"),t}},Ie=async(e,r)=>{try{let{versionName:t}=e,n=await st(t,r);if(!n)throw s.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await nt({versionId:n.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw s.error({error:t},"Error delivering Jira release"),t}},q=async()=>{let e=re.env.JIRA_BASE_URL,r=re.env.JIRA_TOKEN||re.env.JIRA_API_TOKEN,t=re.env.JIRA_PROJECT_ID,n=re.env.JIRA_EMAIL,o=[];if(e||o.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||o.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),t||o.push("JIRA_PROJECT_ID (numeric project ID)"),n||o.push("JIRA_EMAIL (your Jira email address)"),o.length>0){let a=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...o.map(p=>` - ${p}`),"","You can set these in your .env file or as environment variables."].join(`
|
|
16
|
-
`);throw new Error(a)}let i=Number.parseInt(t,10);if(Number.isNaN(i))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:i,email:n}},te=async()=>{try{return await q()}catch(e){return s.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var de=e=>e==="hotfix"?"main":"dev",se=async(e="regular")=>{let r=de(e);oe.quiet=!0,await oe`git fetch origin`,await oe`git switch ${r}`,await oe`git pull origin ${r}`,oe.quiet=!1},ne=async e=>{let{version:r,jiraConfig:t,description:n,type:o="regular"}=e,i=`v${r}`,a=await Ae({name:i,projectId:t.projectId,description:n||"",released:!1,archived:!1},t),p=`${t.baseUrl}/projects/${a.version.projectId}/versions/${a.version.id}/tab/release-report-all-issues`,l=await fe({version:r,jiraVersionUrl:p,type:o});return{version:r,type:o,branchName:l.branchName,prUrl:l.prUrl,jiraVersionUrl:p}},y=async()=>{let e=new Map,r=await te();if(!r)return e;try{let t=await ue(r);for(let n of t)n.description&&e.set(n.name,n.description)}catch{}return e},G=(e,r,t)=>{let n=t?" ".repeat(t-e.length+3):" ";return`${e}${n}
|
|
16
|
+
`);throw new Error(a)}let i=Number.parseInt(t,10);if(Number.isNaN(i))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:i,email:n}},te=async()=>{try{return await q()}catch(e){return s.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var de=e=>e==="hotfix"?"main":"dev",se=async(e="regular")=>{let r=de(e);oe.quiet=!0,await oe`git fetch origin`,await oe`git switch ${r}`,await oe`git pull origin ${r}`,oe.quiet=!1},ne=async e=>{let{version:r,jiraConfig:t,description:n,type:o="regular"}=e,i=`v${r}`,a=await Ae({name:i,projectId:t.projectId,description:n||"",released:!1,archived:!1},t),p=`${t.baseUrl}/projects/${a.version.projectId}/versions/${a.version.id}/tab/release-report-all-issues`,l=await fe({version:r,jiraVersionUrl:p,type:o});return{version:r,type:o,branchName:l.branchName,prUrl:l.prUrl,jiraVersionUrl:p}},y=async()=>{let e=new Map,r=await te();if(!r)return e;try{let t=await ue(r);for(let n of t)n.description&&e.set(n.name,n.description)}catch{}return e},G=(e,r,t)=>{let n=t?" ".repeat(t-e.length+3):" ",o=`[${r}]`.padEnd(11);return`${e}${n}${o}`},h=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",x=e=>{let{branches:r,descriptions:t,types:n}=e,o=r.map(a=>a.replace("release/v","")),i=Math.max(...o.map(a=>a.length));return r.map((a,p)=>{let l=o[p],m=n?n.get(a)||"regular":void 0,d=t.get(`v${l}`),u=" ".repeat(i-l.length+3),f=m?G(l,m,i):l;return d&&(f=m?`${f} ${d}`:`${l}${u}${d}`),{name:f,value:a}})};var Pe=e=>e.replace("release/","").slice(1).split(".").map(Number),ge=e=>[...e].sort((r,t)=>{let[n,o,i]=Pe(r),[a,p,l]=Pe(t);return n!==a?(n??0)-(a??0):o!==p?(o??0)-(p??0):(i??0)-(l??0)});var Rr=async()=>{let e=await C`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=await C`gh pr list --search "Hotfix in:title" --base main --json number,title,headRefName,state,baseRefName`,t=[...JSON.parse(e.stdout),...JSON.parse(r.stdout)],n=new Set;return t.filter(o=>n.has(o.headRefName)?!1:(n.add(o.headRefName),!0))},ve=async()=>{try{let e=await Rr();return e.length===0&&(s.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),he.exit(1)),ge(e.map(r=>r.headRefName))}catch(e){s.error({error:e},"\u274C Error fetching release PRs"),he.exit(1)}},v=async()=>{try{let e=await Rr();e.length===0&&(s.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),he.exit(1));let r=ge(e.map(n=>n.headRefName)),t=new Map(e.map(n=>[n.headRefName,n]));return r.map(n=>({branch:n,title:t.get(n).title}))}catch(e){s.error({error:e},"\u274C Error fetching release PRs"),he.exit(1)}},fe=async e=>{let{version:r,jiraVersionUrl:t,type:n}=e,o=n==="hotfix"?"Hotfix":"Release",i=de(n),a=`release/v${r}`;try{C.quiet=!0,await C`git switch ${i}`,await C`git pull origin ${i}`,await C`git checkout -b ${a}`,await C`git push -u origin ${a}`,await C`git commit --allow-empty-message --allow-empty --message ''`,await C`git push origin ${a}`;let l=(await C`gh pr create --title "${o} v${r}" --body "${t} \n" --base ${i} --head ${a}`).stdout.trim();return await C`git switch ${i}`,C.quiet=!1,{branchName:a,prUrl:l}}catch(p){throw s.error({error:p,branchName:a},`Error creating release branch ${a}`),p}};var wr=async e=>{let{all:r,confirmedCommand:t}=e;c.start("merge-dev");let o=(await v()).filter(d=>h(d.title)==="regular").map(d=>d.branch);if(o.length===0)return s.info("\u2139\uFE0F No open release branches found"),c.print(),{content:[{type:"text",text:JSON.stringify({successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0},null,2)}],structuredContent:{successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0}};let i=[];if(r)i=o;else{c.setInteractive();let d=await y();i=await it({required:!0,message:"\u{1F33F} Select release branches",choices:x({branches:o,descriptions:d})})}i.length===o.length?c.addOption("--all",!0):c.addOption("--versions",i.map(d=>d.replace("release/v","")));let p=t?!0:await at({message:`Are you sure you want to merge dev into these branches: ${i.join(", ")}?`});t||c.setInteractive(),p||(s.info("Operation cancelled. Exiting..."),ct.exit(0)),t||c.addOption("--yes",!0),A.quiet=!0,await A`git fetch origin`,await A`git switch dev`,await A`git pull origin dev`;let l=[];for(let d of i)await lt(d)||l.push(d);if(A.quiet=!1,l.length>0){s.info(`
|
|
17
17
|
\u26A0\uFE0F ${l.length} branch(es) failed to merge automatically.
|
|
18
18
|
`),s.info("\u{1F4CB} Manual merge script for failed branches:");for(let d of l)s.info(`# Merge dev into ${d} and resolve conflicts if any
|
|
19
|
+
|
|
19
20
|
git switch ${d} && git pull origin ${d} && git merge origin/dev
|
|
20
21
|
git push origin ${d} && git switch dev
|
|
21
|
-
`);s.info(`\u2705 ${i.length-l.length}/${i.length} merges completed successfully.`)}else s.info("\u2705 All merges completed successfully!");c.print();let m={successfulMerges:i.length-l.length,failedMerges:l.length,failedBranches:l,totalBranches:i.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}},lt=async e=>{try{return await A`git switch ${e}`,await A`git pull origin ${e}`,await A`git merge origin/dev --no-edit`,await A`git push origin ${e}`,await A`git switch dev`,s.info(`Successfully merged dev into ${e}`),!0}catch(r){return s.error({error:r,branch:e},`Error merging dev into ${e}`),await A`git reset --merge HEAD~1`,!1}},Ne={name:"gh-merge-dev",description:"Merge dev branch into selected release branches",inputSchema:{all:z.boolean().describe("Merge dev into all release branches without prompting")},outputSchema:{successfulMerges:z.number().describe("Number of successful merges"),failedMerges:z.number().describe("Number of failed merges"),failedBranches:z.array(z.string()).describe("List of branches that failed to merge"),totalBranches:z.number().describe("Total number of branches processed")},handler:wr};import pt from"@inquirer/confirm";import mt from"@inquirer/select";import Oe from"node:process";import{z as ie}from"zod";import{$}from"zx";var br=async e=>{let{version:r,confirmedCommand:t}=e;c.start("release-deliver");let n=await v(),o=n.map(u=>u.branch),i=new Map(n.map(u=>[u.branch,h(u.title)])),a="";if(r)a=`release/v${r}`;else{c.setInteractive();let u=await y();a=await mt({message:"\u{1F33F} Select release branch",choices:x({branches:o,descriptions:u,types:i})})}let p=a.replace("release/v","");c.addOption("--version",p);let l=n.find(u=>u.branch===a);l||(s.error(`\u274C Release branch ${a} not found in open PRs. Exiting...`),Oe.exit(1));let m=h(l.title),d=t?!0:await pt({message:`Are you sure you want to deliver version ${a} to production?`});t||c.setInteractive(),d||(s.info("Operation cancelled. Exiting..."),Oe.exit(0)),c.addOption("--yes",!0);try{$.quiet=!0,m==="hotfix"?(await $`gh pr merge ${a} --squash --admin --delete-branch`,$.quiet=!1,await $`gh workflow run deploy-all.yml --ref main -f environment=prod`,$.quiet=!0,await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`):(await $`gh pr merge ${a} --squash --admin --delete-branch`,await $`gh pr create --base main --head dev --title "Release v${p} (RC)" --body ""`,await $`gh pr merge dev --squash --admin`,$.quiet=!1,await $`gh workflow run deploy-all.yml --ref main -f environment=prod`,$.quiet=!0,await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`),$.quiet=!1;let u=await te();if(u)try{let g=a.replace("release/","");await Ie({versionName:g},u)}catch(g){s.error({error:g},"Failed to deliver Jira release (non-blocking)")}else s.info("\u{1F514} Jira is not configured, skipping Jira release delivery");s.info(`Successfully delivered ${a} to production!`),c.print();let f={releaseBranch:a,version:a.replace("release/v",""),type:m,success:!0};return{content:[{type:"text",text:JSON.stringify(f,null,2)}],structuredContent:f}}catch(u){s.error({error:u},"\u274C Error merging release branch into dev"),Oe.exit(1)}},_e={name:"gh-release-deliver",description:"Deliver a release branch to production",inputSchema:{version:ie.string().describe('Version to deliver to production (e.g., "1.2.5")')},outputSchema:{releaseBranch:ie.string().describe("The release branch that was delivered"),version:ie.string().describe("The version that was delivered"),type:ie.enum(["regular","hotfix"]).describe("Release type"),success:ie.boolean().describe("Whether the delivery was successful")},handler:br};import xr from"@inquirer/select";import Tr from"node:process";import{z as _}from"zod";import{$ as De}from"zx";var kr=async e=>{let{version:r,env:t,skipTerraform:n}=e;c.start("release-deploy-all");let o="";if(r)o=r==="dev"?"dev":`release/v${r}`;else{c.setInteractive();let l=await v(),m=l.map(f=>f.branch),d=new Map(l.map(f=>[f.branch,h(f.title)])),u=await y();o=await xr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...x({branches:m,descriptions:u,types:d})]})}let i=o==="dev"?"dev":o.replace("release/v","");c.addOption("--version",i);let a="";t?a=t:(c.setInteractive(),a=await xr({message:"\u{1F9EA} Select environment",choices:k.map(l=>({name:l,value:l}))})),c.addOption("--env",a),k.includes(a)||(s.error(`\u274C Invalid environment: ${a}. Exiting...`),Tr.exit(1));let p=n??!1;p&&c.addOption("--skip-terraform",!0);try{De.quiet=!0,await De`gh workflow run deploy-all.yml --ref ${o} -f environment=${a} ${p?["-f","skip_terraform_deploy=true"]:[]}`,De.quiet=!1,s.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${o} and environment: ${a}`),c.print();let m={releaseBranch:o,version:o.replace("release/v",""),environment:a,skipTerraformDeploy:p,success:!0};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(l){s.error({error:l},"\u274C Error launching workflow"),Tr.exit(1)}},Je={name:"gh-release-deploy-all",description:"Deploy a release branch to a specified environment",inputSchema:{version:_.string().describe('Version to deploy (e.g., "1.2.5")'),env:_.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")'),skipTerraform:_.boolean().optional().describe("Skip terraform deployment step")},outputSchema:{releaseBranch:_.string().describe("The release branch that was deployed"),version:_.string().describe("The version that was deployed"),environment:_.string().describe("The environment deployed to"),skipTerraformDeploy:_.boolean().describe("Whether terraform deployment was skipped"),success:_.boolean().describe("Whether the deployment was successful")},handler:kr};import ut from"@inquirer/checkbox";import $r from"@inquirer/select";import dt from"node:fs/promises";import{resolve as ft}from"node:path";import ae from"node:process";import gt from"yaml";import{z as S}from"zod";import{$ as je}from"zx";var Er=async e=>{let{version:r,env:t,services:n,skipTerraform:o}=e;c.start("release-deploy-selected");let i="";if(r)i=r==="dev"?"dev":`release/v${r}`;else{c.setInteractive();let f=await v(),g=f.map(b=>b.branch),R=new Map(f.map(b=>[b.branch,h(b.title)])),T=await y();i=await $r({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...x({branches:g,descriptions:T,types:R})]})}let a=i==="dev"?"dev":i.replace("release/v","");c.addOption("--version",a);let p="";t?p=t:(c.setInteractive(),p=await $r({message:"\u{1F9EA} Select environment",choices:k.map(f=>({name:f,value:f}))})),c.addOption("--env",p),k.includes(p)||(s.error(`\u274C Invalid environment: ${p}. Exiting...`),ae.exit(1));let l=await ht();l.length===0&&(s.error("\u274C No services found in workflow file. Exiting..."),ae.exit(1));let m=[];n&&n.length>0?m=n:(c.setInteractive(),m=await ut({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:l.map(f=>({name:f,value:f}))})),c.addOption("--services",m),m.length===0&&(s.error("\u274C No services selected. Exiting..."),ae.exit(1));let d=m.filter(f=>!l.includes(f));d.length>0&&(s.error(`\u274C Invalid services: ${d.join(", ")}. Available services: ${l.join(", ")}`),ae.exit(1));let u=o??!1;u&&c.addOption("--skip-terraform",!0);try{je.quiet=!0;let f=m.flatMap(T=>["-f",`${T}=true`]);await je`gh workflow run deploy-selected-services.yml --ref ${i} -f environment=${p} ${f} ${u?["-f","skip_terraform_deploy=true"]:[]}`,je.quiet=!1,s.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${i}, environment: ${p}, services: ${m.join(", ")}`),c.print();let R={releaseBranch:i,version:i.replace("release/v",""),environment:p,services:m,skipTerraformDeploy:u,success:!0};return{content:[{type:"text",text:JSON.stringify(R,null,2)}],structuredContent:R}}catch(f){s.error({error:f},"\u274C Error launching workflow"),ae.exit(1)}},ht=async()=>{let e=await E(),r=ft(e,".github/workflows/deploy-selected-services.yml"),t=await dt.readFile(r,"utf-8"),o=gt.parse(t).on.workflow_dispatch.inputs,i=[];for(let[a,p]of Object.entries(o))p.type==="boolean"&&a!=="skip_terraform_deploy"&&i.push(a);return i},Le={name:"gh-release-deploy-selected",description:"Deploy selected services from a release branch to a specified environment",inputSchema:{version:S.string().describe('Version to deploy (e.g., "1.2.5")'),env:S.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")'),services:S.array(S.string()).describe('List of services to deploy (e.g., ["client-be", "client-fe"])'),skipTerraform:S.boolean().optional().describe("Skip terraform deployment step")},outputSchema:{releaseBranch:S.string().describe("The release branch that was deployed"),version:S.string().describe("The version that was deployed"),environment:S.string().describe("The environment deployed to"),services:S.array(S.string()).describe("The services that were deployed"),skipTerraformDeploy:S.boolean().describe("Whether terraform deployment was skipped"),success:S.boolean().describe("Whether the deployment was successful")},handler:Er};import Ve from"@inquirer/select";import vt from"node:fs/promises";import{resolve as yt}from"node:path";import Me from"node:process";import Rt from"yaml";import{z as I}from"zod";import{$ as Fe}from"zx";var Cr=async e=>{let{version:r,env:t,service:n,skipTerraform:o}=e;c.start("release-deploy-service");let i="";if(r)i=r==="dev"?"dev":`release/v${r}`;else{c.setInteractive();let u=await v(),f=u.map(T=>T.branch),g=new Map(u.map(T=>[T.branch,h(T.title)])),R=await y();i=await Ve({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...x({branches:f,descriptions:R,types:g})]})}let a=i==="dev"?"dev":i.replace("release/v","");c.addOption("--version",a);let p="";t?p=t:(c.setInteractive(),p=await Ve({message:"\u{1F9EA} Select environment",choices:k.map(u=>({name:u,value:u}))})),c.addOption("--env",p),k.includes(p)||(s.error(`\u274C Invalid environment: ${p}. Exiting...`),Me.exit(1));let l=await wt(),m="";n?m=n:(c.setInteractive(),m=await Ve({message:"\u{1F680} Select service to deploy",choices:l.map(u=>({name:u,value:u}))})),c.addOption("--service",m),l.includes(m)||(s.error(`\u274C Invalid service: ${m}. Available services: ${l.join(", ")}`),Me.exit(1));let d=o??!1;d&&c.addOption("--skip-terraform",!0);try{Fe.quiet=!0,await Fe`gh workflow run deploy-single-service.yml --ref ${i} -f environment=${p} -f service=${m} ${d?["-f","skip_terraform_deploy=true"]:[]}`,Fe.quiet=!1,s.info(`Successfully launched deploy-single-service workflow_dispatch for release branch: ${i}, environment: ${p}, service: ${m}`),c.print();let f={releaseBranch:i,version:i.replace("release/v",""),environment:p,service:m,skipTerraformDeploy:d,success:!0};return{content:[{type:"text",text:JSON.stringify(f,null,2)}],structuredContent:f}}catch(u){s.error({error:u},"\u274C Error launching workflow"),Me.exit(1)}},wt=async()=>{let e=await E(),r=yt(e,".github/workflows/deploy-single-service.yml"),t=await vt.readFile(r,"utf-8");return Rt.parse(t).on.workflow_dispatch.inputs.service.options},Be={name:"gh-release-deploy-service",description:"Deploy a specific service in a release branch to a specified environment",inputSchema:{version:I.string().describe('Version to deploy (e.g., "1.2.5")'),env:I.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")'),service:I.string().describe('Service to deploy (e.g., "client-be", "client-fe")'),skipTerraform:I.boolean().optional().describe("Skip terraform deployment step")},outputSchema:{releaseBranch:I.string().describe("The release branch that was deployed"),version:I.string().describe("The version that was deployed"),environment:I.string().describe("The environment deployed to"),service:I.string().describe("The service that was deployed"),skipTerraformDeploy:I.boolean().describe("Whether terraform deployment was skipped"),success:I.boolean().describe("Whether the deployment was successful")},handler:Cr};import{z as H}from"zod";var Sr=async()=>{let r=(await v()).map(a=>({version:a.branch.replace("release/",""),type:h(a.title)})),t=await y(),n=Math.max(...r.map(a=>a.version.length)),o=r.map(a=>{let p=G(a.version,a.type,n),l=t.get(a.version);return l?`${p} ${l}`:p});s.info(`All release branches:
|
|
22
|
+
`);s.info(`\u2705 ${i.length-l.length}/${i.length} merges completed successfully.`)}else s.info(`\u2705 All merges completed successfully!
|
|
23
|
+
`);c.print();let m={successfulMerges:i.length-l.length,failedMerges:l.length,failedBranches:l,totalBranches:i.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}},lt=async e=>{try{return await A`git switch ${e}`,await A`git pull origin ${e}`,await A`git merge origin/dev --no-edit`,await A`git push origin ${e}`,await A`git switch dev`,s.info(`Successfully merged dev into ${e}`),!0}catch(r){return s.error({error:r,branch:e},`Error merging dev into ${e}`),await A`git reset --merge HEAD~1`,!1}},Ne={name:"gh-merge-dev",description:"Merge dev branch into selected release branches",inputSchema:{all:z.boolean().describe("Merge dev into all release branches without prompting")},outputSchema:{successfulMerges:z.number().describe("Number of successful merges"),failedMerges:z.number().describe("Number of failed merges"),failedBranches:z.array(z.string()).describe("List of branches that failed to merge"),totalBranches:z.number().describe("Total number of branches processed")},handler:wr};import pt from"@inquirer/confirm";import mt from"@inquirer/select";import Oe from"node:process";import{z as ie}from"zod";import{$}from"zx";var br=async e=>{let{version:r,confirmedCommand:t}=e;c.start("release-deliver");let n=await v(),o=n.map(u=>u.branch),i=new Map(n.map(u=>[u.branch,h(u.title)])),a="";if(r)a=`release/v${r}`;else{c.setInteractive();let u=await y();a=await mt({message:"\u{1F33F} Select release branch",choices:x({branches:o,descriptions:u,types:i})})}let p=a.replace("release/v","");c.addOption("--version",p);let l=n.find(u=>u.branch===a);l||(s.error(`\u274C Release branch ${a} not found in open PRs. Exiting...`),Oe.exit(1));let m=h(l.title),d=t?!0:await pt({message:`Are you sure you want to deliver version ${a} to production?`});t||c.setInteractive(),d||(s.info("Operation cancelled. Exiting..."),Oe.exit(0)),c.addOption("--yes",!0);try{$.quiet=!0,m==="hotfix"?(await $`gh pr merge ${a} --squash --admin --delete-branch`,$.quiet=!1,await $`gh workflow run deploy-all.yml --ref main -f environment=prod`,$.quiet=!0,await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`):(await $`gh pr merge ${a} --squash --admin --delete-branch`,await $`gh pr create --base main --head dev --title "Release v${p} (RC)" --body ""`,await $`gh pr merge dev --squash --admin`,$.quiet=!1,await $`gh workflow run deploy-all.yml --ref main -f environment=prod`,$.quiet=!0,await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`),$.quiet=!1;let u=await te();if(u)try{let g=a.replace("release/","");await Ie({versionName:g},u)}catch(g){s.error({error:g},"Failed to deliver Jira release (non-blocking)")}else s.info("\u{1F514} Jira is not configured, skipping Jira release delivery");s.info(`Successfully delivered ${a} to production!`),c.print();let f={releaseBranch:a,version:a.replace("release/v",""),type:m,success:!0};return{content:[{type:"text",text:JSON.stringify(f,null,2)}],structuredContent:f}}catch(u){s.error({error:u},"\u274C Error merging release branch into dev"),Oe.exit(1)}},_e={name:"gh-release-deliver",description:"Deliver a release branch to production",inputSchema:{version:ie.string().describe('Version to deliver to production (e.g., "1.2.5")')},outputSchema:{releaseBranch:ie.string().describe("The release branch that was delivered"),version:ie.string().describe("The version that was delivered"),type:ie.enum(["regular","hotfix"]).describe("Release type"),success:ie.boolean().describe("Whether the delivery was successful")},handler:br};import xr from"@inquirer/select";import Tr from"node:process";import{z as _}from"zod";import{$ as De}from"zx";var kr=async e=>{let{version:r,env:t,skipTerraform:n}=e;c.start("release-deploy-all");let o="";if(r)o=r==="dev"?"dev":`release/v${r}`;else{c.setInteractive();let l=await v(),m=l.map(f=>f.branch),d=new Map(l.map(f=>[f.branch,h(f.title)])),u=await y();o=await xr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...x({branches:m,descriptions:u,types:d})]})}let i=o==="dev"?"dev":o.replace("release/v","");c.addOption("--version",i);let a="";t?a=t:(c.setInteractive(),a=await xr({message:"\u{1F9EA} Select environment",choices:k.map(l=>({name:l,value:l}))})),c.addOption("--env",a),k.includes(a)||(s.error(`\u274C Invalid environment: ${a}. Exiting...`),Tr.exit(1));let p=n??!1;p&&c.addOption("--skip-terraform",!0);try{De.quiet=!0,await De`gh workflow run deploy-all.yml --ref ${o} -f environment=${a} ${p?["-f","skip_terraform_deploy=true"]:[]}`,De.quiet=!1,s.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${o} and environment: ${a}`),c.print();let m={releaseBranch:o,version:o.replace("release/v",""),environment:a,skipTerraformDeploy:p,success:!0};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(l){s.error({error:l},"\u274C Error launching workflow"),Tr.exit(1)}},Je={name:"gh-release-deploy-all",description:"Deploy a release branch to a specified environment",inputSchema:{version:_.string().describe('Version to deploy (e.g., "1.2.5")'),env:_.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")'),skipTerraform:_.boolean().optional().describe("Skip terraform deployment step")},outputSchema:{releaseBranch:_.string().describe("The release branch that was deployed"),version:_.string().describe("The version that was deployed"),environment:_.string().describe("The environment deployed to"),skipTerraformDeploy:_.boolean().describe("Whether terraform deployment was skipped"),success:_.boolean().describe("Whether the deployment was successful")},handler:kr};import ut from"@inquirer/checkbox";import $r from"@inquirer/select";import dt from"node:fs/promises";import{resolve as ft}from"node:path";import ae from"node:process";import gt from"yaml";import{z as S}from"zod";import{$ as je}from"zx";var Er=async e=>{let{version:r,env:t,services:n,skipTerraform:o}=e;c.start("release-deploy-selected");let i="";if(r)i=r==="dev"?"dev":`release/v${r}`;else{c.setInteractive();let f=await v(),g=f.map(b=>b.branch),R=new Map(f.map(b=>[b.branch,h(b.title)])),T=await y();i=await $r({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...x({branches:g,descriptions:T,types:R})]})}let a=i==="dev"?"dev":i.replace("release/v","");c.addOption("--version",a);let p="";t?p=t:(c.setInteractive(),p=await $r({message:"\u{1F9EA} Select environment",choices:k.map(f=>({name:f,value:f}))})),c.addOption("--env",p),k.includes(p)||(s.error(`\u274C Invalid environment: ${p}. Exiting...`),ae.exit(1));let l=await ht();l.length===0&&(s.error("\u274C No services found in workflow file. Exiting..."),ae.exit(1));let m=[];n&&n.length>0?m=n:(c.setInteractive(),m=await ut({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:l.map(f=>({name:f,value:f}))})),c.addOption("--services",m),m.length===0&&(s.error("\u274C No services selected. Exiting..."),ae.exit(1));let d=m.filter(f=>!l.includes(f));d.length>0&&(s.error(`\u274C Invalid services: ${d.join(", ")}. Available services: ${l.join(", ")}`),ae.exit(1));let u=o??!1;u&&c.addOption("--skip-terraform",!0);try{je.quiet=!0;let f=m.flatMap(T=>["-f",`${T}=true`]);await je`gh workflow run deploy-selected-services.yml --ref ${i} -f environment=${p} ${f} ${u?["-f","skip_terraform_deploy=true"]:[]}`,je.quiet=!1,s.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${i}, environment: ${p}, services: ${m.join(", ")}`),c.print();let R={releaseBranch:i,version:i.replace("release/v",""),environment:p,services:m,skipTerraformDeploy:u,success:!0};return{content:[{type:"text",text:JSON.stringify(R,null,2)}],structuredContent:R}}catch(f){s.error({error:f},"\u274C Error launching workflow"),ae.exit(1)}},ht=async()=>{let e=await E(),r=ft(e,".github/workflows/deploy-selected-services.yml"),t=await dt.readFile(r,"utf-8"),o=gt.parse(t).on.workflow_dispatch.inputs,i=[];for(let[a,p]of Object.entries(o))p.type==="boolean"&&a!=="skip_terraform_deploy"&&i.push(a);return i},Le={name:"gh-release-deploy-selected",description:"Deploy selected services from a release branch to a specified environment",inputSchema:{version:S.string().describe('Version to deploy (e.g., "1.2.5")'),env:S.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")'),services:S.array(S.string()).describe('List of services to deploy (e.g., ["client-be", "client-fe"])'),skipTerraform:S.boolean().optional().describe("Skip terraform deployment step")},outputSchema:{releaseBranch:S.string().describe("The release branch that was deployed"),version:S.string().describe("The version that was deployed"),environment:S.string().describe("The environment deployed to"),services:S.array(S.string()).describe("The services that were deployed"),skipTerraformDeploy:S.boolean().describe("Whether terraform deployment was skipped"),success:S.boolean().describe("Whether the deployment was successful")},handler:Er};import Ve from"@inquirer/select";import vt from"node:fs/promises";import{resolve as yt}from"node:path";import Me from"node:process";import Rt from"yaml";import{z as I}from"zod";import{$ as Fe}from"zx";var Cr=async e=>{let{version:r,env:t,service:n,skipTerraform:o}=e;c.start("release-deploy-service");let i="";if(r)i=r==="dev"?"dev":`release/v${r}`;else{c.setInteractive();let u=await v(),f=u.map(T=>T.branch),g=new Map(u.map(T=>[T.branch,h(T.title)])),R=await y();i=await Ve({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...x({branches:f,descriptions:R,types:g})]})}let a=i==="dev"?"dev":i.replace("release/v","");c.addOption("--version",a);let p="";t?p=t:(c.setInteractive(),p=await Ve({message:"\u{1F9EA} Select environment",choices:k.map(u=>({name:u,value:u}))})),c.addOption("--env",p),k.includes(p)||(s.error(`\u274C Invalid environment: ${p}. Exiting...`),Me.exit(1));let l=await wt(),m="";n?m=n:(c.setInteractive(),m=await Ve({message:"\u{1F680} Select service to deploy",choices:l.map(u=>({name:u,value:u}))})),c.addOption("--service",m),l.includes(m)||(s.error(`\u274C Invalid service: ${m}. Available services: ${l.join(", ")}`),Me.exit(1));let d=o??!1;d&&c.addOption("--skip-terraform",!0);try{Fe.quiet=!0,await Fe`gh workflow run deploy-single-service.yml --ref ${i} -f environment=${p} -f service=${m} ${d?["-f","skip_terraform_deploy=true"]:[]}`,Fe.quiet=!1,s.info(`Successfully launched deploy-single-service workflow_dispatch for release branch: ${i}, environment: ${p}, service: ${m}`),c.print();let f={releaseBranch:i,version:i.replace("release/v",""),environment:p,service:m,skipTerraformDeploy:d,success:!0};return{content:[{type:"text",text:JSON.stringify(f,null,2)}],structuredContent:f}}catch(u){s.error({error:u},"\u274C Error launching workflow"),Me.exit(1)}},wt=async()=>{let e=await E(),r=yt(e,".github/workflows/deploy-single-service.yml"),t=await vt.readFile(r,"utf-8");return Rt.parse(t).on.workflow_dispatch.inputs.service.options},Be={name:"gh-release-deploy-service",description:"Deploy a specific service in a release branch to a specified environment",inputSchema:{version:I.string().describe('Version to deploy (e.g., "1.2.5")'),env:I.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")'),service:I.string().describe('Service to deploy (e.g., "client-be", "client-fe")'),skipTerraform:I.boolean().optional().describe("Skip terraform deployment step")},outputSchema:{releaseBranch:I.string().describe("The release branch that was deployed"),version:I.string().describe("The version that was deployed"),environment:I.string().describe("The environment deployed to"),service:I.string().describe("The service that was deployed"),skipTerraformDeploy:I.boolean().describe("Whether terraform deployment was skipped"),success:I.boolean().describe("Whether the deployment was successful")},handler:Cr};import{z as H}from"zod";var Sr=async()=>{let r=(await v()).map(a=>({version:a.branch.replace("release/",""),type:h(a.title)})),t=await y(),n=Math.max(...r.map(a=>a.version.length)),o=r.map(a=>{let p=G(a.version,a.type,n),l=t.get(a.version);return l?`${p} ${l}`:p});s.info(`All release branches:
|
|
22
24
|
`),s.info(`
|
|
23
25
|
${o.join(`
|
|
24
26
|
`)}
|
|
@@ -27,5 +29,5 @@ ${o.join(`
|
|
|
27
29
|
`)}let a=o.length,p=i.length;a===t.length?s.info(`\u2705 All ${t.length} release branches were created successfully.`):a>0?(s.warn(`\u26A0\uFE0F ${a} of ${t.length} release branches were created successfully.`),s.warn(`\u274C ${p} release(s) failed.`)):s.error(`\u274C All ${t.length} release branches failed to create.`),c.print();let l={createdBranches:o.map(m=>m.branchName),successCount:a,failureCount:p,releases:o,failedReleases:i};return{content:[{type:"text",text:JSON.stringify(l,null,2)}],structuredContent:l}},Ge={name:"release-create-batch",description:"Create multiple release branches for specified versions with Jira version creation (batch operation)",inputSchema:{versions:w.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6")'),type:w.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")')},outputSchema:{createdBranches:w.array(w.string()).describe("List of created release branches"),successCount:w.number().describe("Number of releases created successfully"),failureCount:w.number().describe("Number of releases that failed"),releases:w.array(w.object({version:w.string().describe("Version number"),type:w.enum(["regular","hotfix"]).describe("Release type"),branchName:w.string().describe("Release branch name"),prUrl:w.string().describe("GitHub PR URL"),jiraVersionUrl:w.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:w.array(w.object({version:w.string().describe("Version number that failed"),error:w.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:_r};import Et from"@inquirer/checkbox";import ze from"@inquirer/confirm";import Ct from"node:process";import{z as J}from"zod";import{$ as K}from"zx";var St="feature",At="release",It="release/v",Jr=async e=>{let{confirmedCommand:r,all:t,versions:n,cursor:o,githubDesktop:i}=e;c.start("worktrees-add");try{let a=await N("release"),l=`${await E()}${W}`;await Dr(`${l}/${At}`),await Dr(`${l}/${St}`);let m=[];if(n)m=n.split(",").map(b=>`release/v${b.trim()}`);else{let b=await v(),ye=b.map(Re=>Re.branch);if(ye.length===0)return s.info("\u2139\uFE0F No open release branches found"),c.print(),{content:[{type:"text",text:JSON.stringify({createdWorktrees:[],count:0},null,2)}],structuredContent:{createdWorktrees:[],count:0}};if(t)m=ye;else{c.setInteractive();let Re=new Map(b.map(rr=>[rr.branch,h(rr.title)])),Wr=await y();m=await Et({required:!0,message:"\u{1F33F} Select release branches",choices:x({branches:ye,descriptions:Wr,types:Re})})}}t?c.addOption("--all",!0):c.addOption("--versions",m.map(b=>b.replace("release/v","")));let d=r?!0:await ze({message:"Are you sure you want to proceed with these worktree changes?"});r||c.setInteractive(),d||(s.info("Operation cancelled. Exiting..."),Ct.exit(0)),r||c.addOption("--yes",!0);let u=o??await ze({message:"Open created worktrees in Cursor?"});typeof o>"u"&&c.setInteractive(),u?c.addOption("--cursor",!0):c.addOption("--no-cursor",!0);let f=i??await ze({message:"Open created worktrees in GitHub Desktop?"});typeof i>"u"&&c.setInteractive(),f?c.addOption("--github-desktop",!0):c.addOption("--no-github-desktop",!0);let{branchesToCreate:g}=Pt({selectedReleaseBranches:m,currentWorktrees:a}),R=await Nt(g,l);if(Ot(R),u)for(let b of R)await K`cursor ${l}/${b}`;if(f)for(let b of R)await K`github ${l}/${b}`,await K`sleep 5`;c.print();let T={createdWorktrees:R,count:R.length};return{content:[{type:"text",text:JSON.stringify(T,null,2)}],structuredContent:T}}catch(a){throw s.error({error:a},"\u274C Error managing worktrees"),a}},Dr=async e=>{await K`mkdir -p ${e}`},Pt=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,n=t.filter(i=>i.startsWith(It));return{branchesToCreate:r.filter(i=>!n.includes(i))}},Nt=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let i=`${r}/${o}`;return await K`git worktree add ${i} ${o}`,await K({cwd:i})`pnpm install`,o})),n=[];for(let[o,i]of t.entries())if(i.status==="fulfilled")n.push(i.value);else{let a=e[o];s.error({error:i.reason},`\u274C Failed to create worktree for ${a}`)}return n},Ot=e=>{if(e.length>0){s.info("\u2705 Created git worktrees:");for(let r of e)s.info(r);s.info("")}else s.info("\u2139\uFE0F No new git worktrees to create")},He={name:"worktrees-add",description:"Create git worktrees for selected release branches",inputSchema:{all:J.boolean().describe("Add git worktrees for all release branches without prompting"),versions:J.string().optional().describe("Specify versions by comma, e.g. 1.2.5, 1.2.6"),cursor:J.boolean().optional().describe("Open created git worktrees in Cursor"),githubDesktop:J.boolean().optional().describe("Open created git worktrees in GitHub Desktop")},outputSchema:{createdWorktrees:J.array(J.string()).describe("List of created git worktree branches"),count:J.number().describe("Number of git worktrees created")},handler:Jr};import{z as X}from"zod";var jr=async()=>{let e=await N("release");if(e.length===0)return s.info("\u2139\uFE0F No active worktrees found"),{content:[{type:"text",text:JSON.stringify({worktrees:[],count:0},null,2)}],structuredContent:{worktrees:[],count:0}};let[r,t]=await Promise.all([v(),y()]),n=new Map(r.map(l=>[l.branch,h(l.title)])),o=e.map(l=>{let m=l.replace("release/",""),d=n.get(l)||"regular",u=t.get(m)||null;return{version:m,type:d,description:u}}),i=Math.max(...o.map(l=>l.version.length)),a=o.map(l=>{let m=G(l.version,l.type,i);return l.description?`${m} ${l.description}`:m});s.info("\u{1F33F} Active worktrees:"),s.info(`
|
|
28
30
|
${a.join(`
|
|
29
31
|
`)}
|
|
30
|
-
`);let p={worktrees:o,count:o.length};return{content:[{type:"text",text:JSON.stringify(p,null,2)}],structuredContent:p}},Ke={name:"worktrees-list",description:"List all git worktrees with detailed information",inputSchema:{},outputSchema:{worktrees:X.array(X.object({version:X.string().describe("Release version"),type:X.enum(["regular","hotfix"]).describe("Release type"),description:X.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:X.number().describe("Number of worktrees")},handler:jr};import _t from"@inquirer/checkbox";import Dt from"@inquirer/confirm";import Jt from"node:process";import{z as ce}from"zod";import{$ as Xe}from"zx";var Lr=async e=>{let{confirmedCommand:r,all:t,versions:n}=e;c.start("worktrees-remove");try{let o=await N("release");if(o.length===0)return s.info("\u2139\uFE0F No active worktrees to remove"),c.print(),{content:[{type:"text",text:JSON.stringify({removedWorktrees:[],count:0},null,2)}],structuredContent:{removedWorktrees:[],count:0}};let a=`${await E()}${W}`,p=[];if(t)p=o;else if(n)p=n.split(",").map(f=>`release/v${f.trim()}`);else{c.setInteractive();let[f,g]=await Promise.all([y(),v()]),R=new Map(g.map(T=>[T.branch,h(T.title)]));p=await _t({required:!0,message:"\u{1F33F} Select release branches",choices:x({branches:o,descriptions:f,types:R})})}p.length===o.length?c.addOption("--all",!0):c.addOption("--versions",p.map(f=>f.replace("release/v","")));let m=r?!0:await Dt({message:"Are you sure you want to proceed with these worktree changes?"});r||c.setInteractive(),m||(s.info("Operation cancelled. Exiting..."),Jt.exit(0)),r||c.addOption("--yes",!0);let d=await jt(p,a);Lt(d),c.print();let u={removedWorktrees:d,count:d.length};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}}catch(o){throw s.error({error:o},"\u274C Error managing worktrees"),o}},jt=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let i=`${r}/${o}`;return await Xe`git worktree remove ${i}`,o})),n=[];for(let[o,i]of t.entries())if(i.status==="fulfilled")n.push(i.value);else{let a=e[o];s.error({error:i.reason},`\u274C Failed to remove worktree for ${a}`)}return n.length===e.length&&(await Xe`git worktree prune`,await Xe`rm -rf ${r}`,s.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${r}`),s.info("")),n},Lt=e=>{if(e.length>0){s.info("\u274C Removed worktrees:");for(let r of e)s.info(r);s.info("")}else s.info("\u2139\uFE0F No unused worktrees to remove")},Ye={name:"worktrees-remove",description:"Remove selected worktrees",inputSchema:{all:ce.boolean().describe("Remove all git worktrees without prompting"),versions:ce.string().optional().describe("Specify versions by comma, e.g. 1.2.5, 1.2.6")},outputSchema:{removedWorktrees:ce.array(ce.string()).describe("List of removed git worktree branches"),count:ce.number().describe("Number of git worktrees removed")},handler:Lr};import Vt from"@inquirer/confirm";import Mt from"node:process";import{z as Ze}from"zod";import{$ as Ft}from"zx";var Bt="release/v",Vr=async e=>{let{confirmedCommand:r}=e;c.start("worktrees-sync");try{let t=await N("release"),o=`${await E()}${W}`,i=await ve(),a=r?!0:await Vt({message:"Are you sure you want to proceed with these worktree changes?"});r||c.setInteractive(),a||(s.info("Operation cancelled. Exiting..."),Mt.exit(0)),r||c.addOption("--yes",!0);let{branchesToRemove:p}=Wt({releasePRsList:i,currentWorktrees:t}),l=await Ut(p,o);qt(l),c.print();let m={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(t){throw s.error({error:t},"\u274C Error managing worktrees"),t}},Wt=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(i=>i.startsWith(Bt)).filter(i=>!r.includes(i))}},Ut=async(e,r)=>{let t=[];for(let n of e)try{let o=`${r}/${n}`;await Ft`git worktree remove ${o}`,t.push(n)}catch(o){s.error({error:o,branch:n},`\u274C Failed to remove worktree for ${n}`)}return t},qt=e=>{if(e.length>0){s.info("\u274C Removed worktrees:");for(let r of e)s.info(r);s.info("")}else s.info("\u2139\uFE0F No unused worktrees to remove")},Qe={name:"worktrees-sync",description:"Synchronize worktrees with active release branches",inputSchema:{},outputSchema:{removedWorktrees:Ze.array(Ze.string()).describe("List of removed worktree branches"),count:Ze.number().describe("Number of worktrees removed during sync")},handler:Vr};var er=e=>async r=>{let{toolName:t,handler:n}=e;s.info({msg:`Tool execution started: ${t}`,params:r});try{let o=await n({...r,confirmedCommand:!0});return s.info({msg:`Tool execution successful: ${t}`}),o}catch(o){throw s.error({err:o,params:r,msg:`Tool execution failed: ${t}`}),o}};var Gt=[Se,$e,Ce,Te,Ne,qe,Ge,_e,Je,Le,Be,We,He,Ke,Ye,Qe],Mr=async e=>{for(let r of Gt)e.registerTool(r.name,{description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema},er({toolName:r.name,handler:r.handler}))};async function Fr(){let e=new zt({name:"infra-kit",version:"
|
|
32
|
+
`);let p={worktrees:o,count:o.length};return{content:[{type:"text",text:JSON.stringify(p,null,2)}],structuredContent:p}},Ke={name:"worktrees-list",description:"List all git worktrees with detailed information",inputSchema:{},outputSchema:{worktrees:X.array(X.object({version:X.string().describe("Release version"),type:X.enum(["regular","hotfix"]).describe("Release type"),description:X.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:X.number().describe("Number of worktrees")},handler:jr};import _t from"@inquirer/checkbox";import Dt from"@inquirer/confirm";import Jt from"node:process";import{z as ce}from"zod";import{$ as Xe}from"zx";var Lr=async e=>{let{confirmedCommand:r,all:t,versions:n}=e;c.start("worktrees-remove");try{let o=await N("release");if(o.length===0)return s.info("\u2139\uFE0F No active worktrees to remove"),c.print(),{content:[{type:"text",text:JSON.stringify({removedWorktrees:[],count:0},null,2)}],structuredContent:{removedWorktrees:[],count:0}};let a=`${await E()}${W}`,p=[];if(t)p=o;else if(n)p=n.split(",").map(f=>`release/v${f.trim()}`);else{c.setInteractive();let[f,g]=await Promise.all([y(),v()]),R=new Map(g.map(T=>[T.branch,h(T.title)]));p=await _t({required:!0,message:"\u{1F33F} Select release branches",choices:x({branches:o,descriptions:f,types:R})})}p.length===o.length?c.addOption("--all",!0):c.addOption("--versions",p.map(f=>f.replace("release/v","")));let m=r?!0:await Dt({message:"Are you sure you want to proceed with these worktree changes?"});r||c.setInteractive(),m||(s.info("Operation cancelled. Exiting..."),Jt.exit(0)),r||c.addOption("--yes",!0);let d=await jt(p,a);Lt(d),c.print();let u={removedWorktrees:d,count:d.length};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}}catch(o){throw s.error({error:o},"\u274C Error managing worktrees"),o}},jt=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let i=`${r}/${o}`;return await Xe`git worktree remove ${i}`,o})),n=[];for(let[o,i]of t.entries())if(i.status==="fulfilled")n.push(i.value);else{let a=e[o];s.error({error:i.reason},`\u274C Failed to remove worktree for ${a}`)}return n.length===e.length&&(await Xe`git worktree prune`,await Xe`rm -rf ${r}`,s.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${r}`),s.info("")),n},Lt=e=>{if(e.length>0){s.info("\u274C Removed worktrees:");for(let r of e)s.info(r);s.info("")}else s.info("\u2139\uFE0F No unused worktrees to remove")},Ye={name:"worktrees-remove",description:"Remove selected worktrees",inputSchema:{all:ce.boolean().describe("Remove all git worktrees without prompting"),versions:ce.string().optional().describe("Specify versions by comma, e.g. 1.2.5, 1.2.6")},outputSchema:{removedWorktrees:ce.array(ce.string()).describe("List of removed git worktree branches"),count:ce.number().describe("Number of git worktrees removed")},handler:Lr};import Vt from"@inquirer/confirm";import Mt from"node:process";import{z as Ze}from"zod";import{$ as Ft}from"zx";var Bt="release/v",Vr=async e=>{let{confirmedCommand:r}=e;c.start("worktrees-sync");try{let t=await N("release"),o=`${await E()}${W}`,i=await ve(),a=r?!0:await Vt({message:"Are you sure you want to proceed with these worktree changes?"});r||c.setInteractive(),a||(s.info("Operation cancelled. Exiting..."),Mt.exit(0)),r||c.addOption("--yes",!0);let{branchesToRemove:p}=Wt({releasePRsList:i,currentWorktrees:t}),l=await Ut(p,o);qt(l),c.print();let m={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(t){throw s.error({error:t},"\u274C Error managing worktrees"),t}},Wt=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(i=>i.startsWith(Bt)).filter(i=>!r.includes(i))}},Ut=async(e,r)=>{let t=[];for(let n of e)try{let o=`${r}/${n}`;await Ft`git worktree remove ${o}`,t.push(n)}catch(o){s.error({error:o,branch:n},`\u274C Failed to remove worktree for ${n}`)}return t},qt=e=>{if(e.length>0){s.info("\u274C Removed worktrees:");for(let r of e)s.info(r);s.info("")}else s.info("\u2139\uFE0F No unused worktrees to remove")},Qe={name:"worktrees-sync",description:"Synchronize worktrees with active release branches",inputSchema:{},outputSchema:{removedWorktrees:Ze.array(Ze.string()).describe("List of removed worktree branches"),count:Ze.number().describe("Number of worktrees removed during sync")},handler:Vr};var er=e=>async r=>{let{toolName:t,handler:n}=e;s.info({msg:`Tool execution started: ${t}`,params:r});try{let o=await n({...r,confirmedCommand:!0});return s.info({msg:`Tool execution successful: ${t}`}),o}catch(o){throw s.error({err:o,params:r,msg:`Tool execution failed: ${t}`}),o}};var Gt=[Se,$e,Ce,Te,Ne,qe,Ge,_e,Je,Le,Be,We,He,Ke,Ye,Qe],Mr=async e=>{for(let r of Gt)e.registerTool(r.name,{description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema},er({toolName:r.name,handler:r.handler}))};async function Fr(){let e=new zt({name:"infra-kit",version:"1.0.0"},{capabilities:{resources:{},tools:{},prompts:{}}});return await nr(e),await ir(e),await Mr(e),e}var j=or(),Kt=async()=>{let e;try{e=await Fr(),j.info("MCP Server instance created")}catch(r){j.error({err:r,msg:"Failed to create MCP server"}),j.error("Fatal error during server creation."),Br.exit(1)}try{let r=new Ht;await e.connect(r),j.info({msg:"Server connected to transport. Ready."})}catch(r){j.error({err:r,msg:"Failed to initialize server"}),j.error("Fatal error during server transport init."),Br.exit(1)}};sr(j);Kt();
|
|
31
33
|
//# sourceMappingURL=mcp.js.map
|