infra-kit 0.24.0 → 0.27.0

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.
@@ -1,7 +1,7 @@
1
- import{P as v,S as w,ca as $,d as g,f as h,ga as x}from"./chunk-T462KY3S.js";import{p as D}from"./chunk-I23MDR4X.js";import{a as j,b as I}from"./chunk-QWVLAZ6N.js";var H=()=>{let e="",t=[],r=!1;return{start(n){e=n,t=[],r=!1},setInteractive(){r=!0},addOption(n,o){t.push({flag:n,value:o})},formatOptions(){return t.map(n=>typeof n.value=="boolean"?n.value?n.flag:"":Array.isArray(n.value)?`${n.flag} "${n.value.join(", ")}"`:`${n.flag} "${n.value}"`).filter(Boolean).join(" ")},snapshot(){return t.length===0?null:{formattedOptions:this.formatOptions()}},print(){!r||t.length===0||!e||v.info(`\u{1F4DF} Equivalent command:
1
+ import{P as v,S as w,d as g,da as $,f as h,ha as x}from"./chunk-MUYD4QA4.js";import{p as D}from"./chunk-I23MDR4X.js";import{a as j,b as I}from"./chunk-QWVLAZ6N.js";var H=()=>{let e="",t=[],r=!1;return{start(n){e=n,t=[],r=!1},setInteractive(){r=!0},addOption(n,o){t.push({flag:n,value:o})},formatOptions(){return t.map(n=>typeof n.value=="boolean"?n.value?n.flag:"":Array.isArray(n.value)?`${n.flag} "${n.value.join(", ")}"`:`${n.flag} "${n.value}"`).filter(Boolean).join(" ")},snapshot(){return t.length===0?null:{formattedOptions:this.formatOptions()}},print(){!r||t.length===0||!e||v.info(`\u{1F4DF} Equivalent command:
2
2
  pnpm exec infra-kit ${e} ${this.formatOptions()}
3
3
  `)},reset(){e="",t=[],r=!1}}},T=H();import{isAbsolute as _,resolve as N}from"node:path";import K from"node:process";var k=null,S=null,q=e=>{k=[...e],S=K.cwd()},B=new Set(["--yes","-y"]),J=(e,t)=>{let r=[...e];for(let[n,o]of r.entries())o==="-C"&&r[n+1]!==void 0&&!_(r[n+1])?r[n+1]=N(t,r[n+1]):o.startsWith("-C")&&o.length>2&&!o.startsWith("--")&&!_(o.slice(2))&&(r[n]=`-C${N(t,o.slice(2))}`);return r},O=()=>{if(k===null||S===null)return["--yes"];let e=k.slice(2),t=e.indexOf("--"),r=t===-1?e.length:t,n=J(e.slice(0,r),S),o=e.slice(r);return n.some(s=>B.has(s))?[...n,...o]:[...n,"--yes",...o]};import M from"node:process";var L=27,W=e=>e===null?"an interactive prompt was reached under --json, which never prompts":`an interactive prompt was reached in agent mode (${e==="flag"?"--agent":"INFRA_KIT_AGENT / CLAUDECODE"}), where there is no human to answer it`,z=e=>`${e===void 0?"pass the value explicitly instead of relying on the prompt":`pass --${e}`} on the re-run`,U=e=>{if(typeof e=="object"&&"value"in e)return e.value;let t=typeof e=="object"?e.refuse:void 0,{source:r}=g;throw new x(t===void 0?{status:"refused",agentMode:r}:{status:"argument_required",argument:t,agentMode:r},2,{operation:"interactive prompt",remediation:z(t),stderrExcerpt:W(r)})},R=async(e,t)=>{let r=new AbortController,{whenHeadless:n="refuse",...o}=t??{},a={...o,signal:r.signal};if(h())return U(n);if(!M.stdin.isTTY)return e(a);let s=M.stdin,m=c=>{c.length===1&&c[0]===L&&r.abort()};j();try{let c=e(a);return s.isPaused()&&s.resume(),s.on("data",m),await c}finally{s.removeListener("data",m),I()}};import Y from"@inquirer/confirm";import G from"node:process";var d=class extends Error{constructor(t="Operation cancelled by the operator"){super(t),this.name="CommandDeclinedError"}},pe=e=>e instanceof d;var F=(e,t,r=O())=>{let{source:n}=g;throw new x({status:"confirmation_required",message:e,plan:t,rerun:r,agentMode:n},2,{operation:"confirm before running",remediation:n===null?"pass `--yes` to confirm, or drop `--json` to be prompted":`show the plan to the human, then re-run \`infra-kit ${r.join(" ")}\` to confirm`,stderrExcerpt:"confirmation required and nobody to ask"})},V=async(e,t,r={})=>{!e&&h()&&F(t,r.plan,r.rerun);let n=e?!0:await R(o=>Y({message:t},o),{whenHeadless:"refuse"});if(e||T.setInteractive(),!n){if(r.throwOnDecline)throw new d;v.info("Operation cancelled. Exiting..."),G.exit(0)}};import l from"node:fs/promises";import i from"node:path";import{z as u}from"zod";var f=class extends Error{env;constructor(t,r=null){super(t),this.name="EnvAuthError",this.env=r}};var Q="tokens.json",E=1,P=384,p=448,X=u.object({version:u.literal(E).default(E),envs:u.record(u.string().min(1),u.string().min(1))}).strict(),y=async()=>{let e=await $();return i.join(i.dirname(e.userProject),Q)},C=async()=>{let e=await y(),t;try{t=await l.readFile(e,"utf-8")}catch{return null}let r;try{r=JSON.parse(t)}catch(o){throw new f(`Invalid JSON in the token store at ${w(e)}: ${o.message}
4
4
  Fix or delete the file, then re-add the token with \`infra-kit env-token-set <env>\`.`)}let n=X.safeParse(r);if(!n.success)throw new f(`Invalid token store at ${w(e)}: ${u.prettifyError(n.error)}
5
5
  Fix or delete the file, then re-add the token with \`infra-kit env-token-set <env>\`.`);return n.data},b=async e=>{let t=await y(),r=i.dirname(t),n=i.dirname(r),o=i.dirname(n);for(let a of[o,n,r])await l.mkdir(a,{recursive:!0,mode:p}),await l.chmod(a,p);D(t,`${JSON.stringify(e,null,2)}
6
6
  `,P),await l.chmod(t,P)},Z=async()=>{let e=await y().catch(()=>null);if(e===null)return null;let t=i.dirname(e),r=i.dirname(t),o=[[i.dirname(r),p],[r,p],[t,p],[e,P]];if(!await l.stat(e).then(()=>!0,()=>!1))return null;let s=[];for(let[m,c]of o){let A=(await l.stat(m)).mode&511;A!==c&&(await l.chmod(m,c),s.push(`${w(m)} was 0${A.toString(8)}`))}return s};var ee=async e=>{let t=await C();await b({version:E,envs:{...t?.envs,...e}})},te=async e=>{let t=await C();if(!t||!(e in t.envs))return;let r={...t.envs};delete r[e],await b({version:E,envs:r})};export{T as a,pe as b,q as c,O as d,R as e,F as f,V as g,f as h,y as i,C as j,Z as k,ee as l,te as m};
7
- //# sourceMappingURL=chunk-AHEFQJVD.js.map
7
+ //# sourceMappingURL=chunk-Q32KHZHK.js.map