infra-kit 0.7.8 → 0.7.9
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/dist/{chunk-TNPZPZJJ.js → chunk-DFZ5WUIM.js} +2 -2
- package/dist/{chunk-TNPZPZJJ.js.map → chunk-DFZ5WUIM.js.map} +1 -1
- package/dist/{chunk-4KWVFLSU.js → chunk-MFNMFVI6.js} +67 -67
- package/dist/chunk-MFNMFVI6.js.map +7 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/mcp.js +2 -1
- package/dist/mcp.js.map +4 -4
- package/dist/update-check.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-4KWVFLSU.js.map +0 -7
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{$ as
|
|
2
|
+
import{$ as jt,A as gt,B as ht,C as vt,D as yt,E as Q,F as wt,G as A,H as u,I as St,J as Rt,K as Pt,L as xt,M as bt,N as Ct,O as Et,P as At,Q as Tt,R as Dt,S as It,T as Lt,U as Nt,V as Ot,X as Z,Y as _t,Z as $t,_ as Ft,a as N,aa as Mt,b as We,ba as qt,c as Ge,ca as Ut,da as Wt,e as Je,ea as Gt,f as Ke,fa as Jt,g as He,ga as Kt,h as Ye,i as O,ia as Bt,j as Qe,ja as Ht,k as tt,ka as Yt,l as F,m as ot,n as rt,o as nt,p as it,q as st,r as at,s as ct,t as lt,u as dt,v as X,w as ut,x as mt,y as pt,z as ft}from"./chunk-MFNMFVI6.js";import{b as Be,c as b,d as h,e as _,f as Ve,g as ze,h as Xe,i as R,k as $}from"./chunk-YKCY657C.js";import{p as ee}from"./chunk-KXQQUBGV.js";import{K as l,Q as z,R as qe,T as Ue,a as Fe,r as je}from"./chunk-63VNUKUS.js";import{u as $e}from"./chunk-LDF2KOGN.js";import"./chunk-MFAFQVTW.js";import{l as Me}from"./chunk-DFZ5WUIM.js";import{k as Ne,m as Oe,n as _e}from"./chunk-HHWP3YXW.js";import{a as L,b as Ee,d as Ae,g as Te,h as De,k as V,l as Ie,p as y,s as Le}from"./chunk-NFIFWIO6.js";import{a as kt}from"./chunk-TVG47UHG.js";import{a as Ze,b as et}from"./chunk-QWVLAZ6N.js";import gn,{Separator as _o}from"@inquirer/select";import{existsSync as hn,realpathSync as vn}from"node:fs";import{homedir as yn}from"node:os";import g from"node:process";import{fileURLToPath as Fo}from"node:url";var Mo=(e,t)=>{let o=e,r;for(let n of t){if(r=o.find(s=>s.name()===n),!r)return;o=r.commands}return r},Vt=e=>Jt.flatMap(({key:t,label:o})=>Bt(t).flatMap(r=>{let n=Mo(e,r.groupPath);return n?[{name:r.groupPath.join(" "),description:n.description(),group:o}]:[]}));import{Command as gr}from"commander";import P from"node:process";import zt from"node:process";import{$ as qo}from"zx";var te=async()=>{let e=await z(),t=await Promise.all([{label:"project (committed)",path:e.main},{label:"user global",path:e.userGlobal},{label:"user project",path:e.userProject}].map(async a=>({...a,exists:await b(a.path)}))),o=t.at(-1)?.exists===!0,r=await pt(e.userProject,o),n=o?ft(r):"";l.info(`Project name: ${e.projectName}
|
|
3
3
|
`),l.info(`Config merge chain (later overrides earlier):
|
|
4
4
|
`);for(let a of t){let i=a.exists?" [\u2713]":" [ ]",c=a.path===e.userProject&&n!==""?` ${n}`:"";l.info(`${i} ${a.label.padEnd(22)} ${h(a.path)}${c}`)}let s={projectName:e.projectName,layers:t.map(a=>({label:a.label,path:a.path,exists:a.exists})),hasOverrides:r.hasOverrides,overrideKeys:r.overrideKeys};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s}},oe=async()=>{let e=await z(),t=zt.env.EDITOR||zt.env.VISUAL||"vi",o=await at(e);o.createdConfig&&l.info(ct(o)),l.info(`Opening ${h(e.userProject)} in ${t} (per-machine override \u2014 every key except "mcp")`),await qo({stdio:"inherit"})`${t} ${e.userProject}`,Ue();let r={path:e.userProject,editor:t};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}};var re=e=>{if(typeof e!="object"||e===null)return null;let{config:t,reason:o,at:r}=e;return typeof t!="string"||t.length===0||typeof o!="string"||typeof r!="number"||!Number.isFinite(r)?null:{config:t,reason:o,at:r}},T=e=>`infra-kit: Doppler token for env "${e}" is missing, invalid, or unreadable \u2014 env auto-load is not running. Fix: run \`infra-kit env-token-set ${e}\` (mint one at https://dashboard.doppler.com under this config's Access tab).`;import f from"node:fs";import w from"node:path";import D from"node:process";var Uo="autoload-warn-fail.flag",ne="autoload-warn-auth-fail.flag",ie="autoload-fail.flag",se="autoload-auth-fail.json",Wo=3e4,Qt=async(e=!0)=>{let t;try{t=await qe()}catch{return null}let o=t.envAutoLoad;if(!o)return null;let r={trigger:o.trigger,config:o.config,project:t.envManagement.config.name};try{if(await Qe(o.config))return r}catch{return r}return eo({config:o.config,reason:`No Doppler service token for env "${o.config}"`,at:Date.now()}),e&&j(T(o.config),ne),null},Zt=e=>{let{trigger:t,expectedTrigger:o,targetConfig:r,targetProject:n,env:s,force:a}=e;return t!==o||!s.session||s.cleared||s.currentConfig&&!s.autoLoadedMarker||!a&&s.autoLoadedMarker&&s.currentConfig===r&&s.currentProject===n?"skip":"load"},I=async({expectedTrigger:e,projectDir:t,force:o,isAuthFailure:r=Be})=>{let n=e==="cli-invocation";n&&M();let s=null;try{if(s=await Qt(n),!s||Zt({trigger:s.trigger,expectedTrigger:e,targetConfig:s.config,targetProject:s.project,env:Ko(),force:o})==="skip"||Xt()||Yo())return null;let i=Bo(),c=await ot({config:s.config,autoLoaded:!0,projectDir:t,beforeWrite:()=>!Xt()&&!Ho(i)});return c?(zo(),Jo(),c.filePath):null}catch(a){let i=a.message,c=r(a);return Vo(),c&&s&&eo({config:s.config,reason:i,at:Date.now()}),n&&c&&s?(j(T(s.config),ne),l.debug(`env auto-load auth failure: ${i}`)):n?j(`infra-kit: env auto-load failed \u2014 ${i} (will retry later)`,Uo):l.debug(`env auto-load skipped: ${i}`),null}},M=()=>{let e=Go();e&&(j(T(e.config),ne),l.debug(`env auto-load auth failure (recorded ${new Date(e.at).toISOString()}): ${e.reason}`))},Go=()=>{try{let e=f.readFileSync(w.join(y(),se),"utf-8");return re(JSON.parse(e))}catch{return null}},eo=e=>{try{let t=y();f.mkdirSync(t,{recursive:!0,mode:448}),Le(w.join(t,se),JSON.stringify(e),384)}catch{}},Jo=()=>{try{f.rmSync(w.join(y(),se),{force:!0})}catch{}},Ko=()=>({session:D.env[Ae],cleared:D.env[Ie],currentConfig:D.env[Te],currentProject:D.env[De],autoLoadedMarker:D.env[V]}),Bo=()=>{try{return f.statSync(w.join(y(),L)).mtimeMs}catch{return null}},Ho=e=>{try{let t=w.join(y(),L);if(!f.existsSync(t))return!1;let o=f.statSync(t).mtimeMs;return e!==null&&o<=e?!1:new RegExp(`^unset ${V}$`,"m").test(f.readFileSync(t,"utf-8"))}catch{return!1}},Xt=()=>{try{let e=y(),t=w.join(e,Ee);if(!f.existsSync(t))return!1;let o=w.join(e,L);return f.existsSync(o)?f.statSync(t).mtimeMs>=f.statSync(o).mtimeMs:!0}catch{return!1}},Yo=()=>{try{let e=w.join(y(),ie);return f.existsSync(e)?Date.now()-f.statSync(e).mtimeMs<Wo:!1}catch{return!1}},Vo=()=>{try{let e=y();f.mkdirSync(e,{recursive:!0,mode:448}),f.writeFileSync(w.join(e,ie),"",{mode:384})}catch{}},zo=()=>{try{f.rmSync(w.join(y(),ie),{force:!0})}catch{}},j=(e,t)=>{try{let o=y(),r=w.join(o,t);if(f.existsSync(r))return;f.mkdirSync(o,{recursive:!0,mode:448}),f.writeFileSync(r,"",{mode:384})}catch{}l.warn(e)};var ae=async({projectDir:e}={})=>{await I({expectedTrigger:"shell-startup",projectDir:e,force:!0})};var to="https://dashboard.doppler.com/workplace/projects",Xo=(e,t)=>["Removing it locally does NOT revoke it \u2014 the token still works anywhere else it is stored.",`Revoke it in Doppler (project "${e}", config "${t}"): ${to}/${e}`],ce=async({env:e})=>{let o=!!(await Ve())?.envs[e];await Xe(e);let r=await F(),n=await O(),s=await _();o?l.info(`Removed the "${e}" service token from ${h(s)}.`):l.info(`No "${e}" service token was stored in ${h(s)} \u2014 nothing to remove.`),r.length>0&&l.info(`Purged ${r.length} warm cache(s) across this repo's worktrees.`);for(let i of Xo(n,e))l.warn(i);let a={env:e,removed:o,storePath:s,warmCachesPurged:r.length,revokeUrl:`${to}/${n}`};return{content:N(JSON.stringify(a,null,2)),structuredContent:a}};import Qo from"@inquirer/password";import U from"node:process";import{$ as q}from"zx";var Zo=async({stdin:e,fromEnv:t})=>{if(e)return{token:await er(),source:"stdin"};if(t){let r=U.env[t];if(!r)throw new Error(`${t} is not set (or is empty) \u2014 nothing to store.`);return{token:r,source:"env"}}return R.setInteractive(),{token:(await $(r=>Qo({message:"Paste the Doppler service token (input is hidden)",mask:!0},r),{output:U.stderr})).trim(),source:"prompt"}},er=async()=>{let e=[];U.stdin.setEncoding("utf8");for await(let t of U.stdin)e.push(t);return e.join("").trim()},le="DOPPLER_CONFIG",tr=3e4,or=async(e,t,o)=>{let r=q.quiet;q.quiet=!0;let n;try{n=(await q({env:nt(e)})`doppler secrets download --no-file --format json --project ${t} --config ${o}`.timeout(tr)).stdout}catch(s){throw rr(s,o)}finally{q.quiet=r}return st(n)},rr=(e,t)=>{let o=Fe(e)??(e instanceof Error?e.message:String(e));if(He(o)!=="auth")return e instanceof Error?e:new Error(String(e));let r=Ye(o)==="mis-scoped"?"it is scoped to a DIFFERENT config (pasting another environment's token here is the mistake this check exists to catch).":"it is invalid or has been revoked.";return new Error([`Doppler refused this token for config "${t}" \u2014 ${r}`,"Nothing was written. Issue a service token scoped to that config and try again."].join(`
|
|
5
5
|
`))},nr=e=>[`Could not verify this token's scope: the Doppler payload for "${e}" carries no ${le}.`,"Refusing to store a credential whose scope is unknown (a token for the wrong environment would load","the wrong secrets into every shell).","Re-run with --force if you are certain the token is scoped to this config."].join(`
|