denvig 0.4.1 → 0.4.2
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/cli.cjs +22 -22
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.d.cts +57 -5
- package/dist/sdk.d.ts +57 -5
- package/dist/sdk.js +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Mn=Object.create;var Ge=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Gn=Object.getPrototypeOf,qn=Object.prototype.hasOwnProperty;var h=(s,e)=>()=>(s&&(e=s(s=0)),e);var C=(s,e)=>{for(var t in e)Ge(s,t,{get:e[t],enumerable:!0})},Un=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Jn(e))!qn.call(s,r)&&r!==t&&Ge(s,r,{get:()=>e[r],enumerable:!(n=_n(e,r))||n.enumerable});return s};var F=(s,e,t)=>(t=s!=null?Mn(Gn(s)):{},Un(e||!s||!s.__esModule?Ge(t,"default",{value:s,enumerable:!0}):t,s));var $,Hn,qe,Ce,Ue=h(()=>{"use strict";$=require("zod"),Hn=["build","check-types","dev","install","lint","outdated","test"],qe=$.z.object({codeRootDir:$.z.string().optional().default("~/src").describe("The base directory where projects are stored"),quickActions:$.z.array($.z.string()).default(Hn).optional().describe("Quick actions that are available for all projects")}),Ce=$.z.object({name:$.z.string().describe("Unique identifier for the project"),actions:$.z.record($.z.string().describe("Name of the action"),$.z.object({command:$.z.string().describe("Shell command to run for the action")})).optional().describe("Actions that can be run against the project"),quickActions:$.z.array($.z.string()).optional().describe("Actions that are available on the CLI root for quick access"),services:$.z.record($.z.string(),$.z.object({cwd:$.z.string().optional().describe("Working directory for the service (relative to project root)"),command:$.z.string().describe("Shell command to execute"),http:$.z.object({port:$.z.number().optional().describe("Port number the service listens on"),domain:$.z.string().optional().describe("Domain to use for the service URL"),secure:$.z.boolean().optional().describe("Use HTTPS instead of HTTP")}).strict().optional().describe("HTTP configuration for the service URL"),envFile:$.z.string().optional().describe("Path to .env file (relative to project root)"),env:$.z.record($.z.string(),$.z.string()).optional().describe("Environment variables"),keepAlive:$.z.boolean().optional().describe("Restart service if it exits")}).strict()).optional().describe("Service that can be managed for this project")}).strict()});var ht,zn,me,He=h(()=>{"use strict";ht=require("fs"),zn=require("fs/promises"),me=s=>{try{return(0,ht.readFileSync)(s,"utf8").trim()||null}catch(e){if(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")return null;throw e}}});var Z,ze,Oe,Bn,yt,W,vt,ge=h(()=>{"use strict";Z=require("path"),ze=require("yaml");Ue();He();Oe=(0,Z.resolve)(process.env.DENVIG_GLOBAL_CONFIG_PATH||`${process.env.HOME}/.denvig/config.yml`),Bn=(0,Z.resolve)(process.env.DENVIG_CODE_ROOT_DIR||`${process.env.HOME}/src`),yt={codeRootDir:Bn,quickActions:void 0},W=()=>{let s=me(Oe);if(s){let e=(0,ze.parse)(s)||{};try{if(e.codeRootDir?.startsWith(".")){let t=(0,Z.dirname)(Oe);e.codeRootDir=(0,Z.resolve)(`${t}/${e.codeRootDir}`)}return{...qe.parse({...yt,...e}),$sources:[Oe]}}catch(t){console.error(`Error parsing global config at ${Oe}:`,t),process.exit(1)}}return{...qe.parse(yt),$sources:[]}},vt=s=>{let e=W(),t={name:s,actions:{}},n=`${e.codeRootDir}/${s}/.denvig.yml`,r=me(n);if(r)try{return{...t,...Ce.parse((0,ze.parse)(r)),$sources:[n]}}catch(c){console.warn(`Error parsing project config for ${s} at ${n}.`),c instanceof Error?console.warn(c.message):console.warn("Unknown error:",c)}return{...t,$sources:[]}}});var Re,Be=h(()=>{"use strict";Re=(s,e)=>{for(let[t,n]of Object.entries(e))s[t]||(s[t]=[]),s[t].push(...n);return s}});var Ye,_,fe=h(()=>{"use strict";Ye=F(require("fs"),1),_=s=>{let e=`${s.path}/package.json`;if(!Ye.default.existsSync(e))return null;let t=Ye.default.readFileSync(e,"utf-8");return JSON.parse(t)}});var R,B=h(()=>{"use strict";R=s=>s});var J,Yn,bt,Dt=h(()=>{"use strict";J=F(require("fs"),1);Be();fe();B();Yn=R({name:"deno",actions:async s=>{let e=J.default.readdirSync(s.path);if(!(e.includes("deno.json")||e.includes("deno.jsonc")))return{};let r=_(s)?.scripts||{},c={...Object.entries(r).map(([i,o])=>[i,`deno ${o}`]).reduce((i,[o,p])=>(i[o]=[p],i),{}),install:["deno install"],outdated:["deno outdated"]},l=((0,J.existsSync)(`${s.path}/deno.json`)?JSON.parse((0,J.readFileSync)(`${s.path}/deno.json`,"utf8")):(0,J.existsSync)(`${s.path}/deno.jsonc`)?JSON.parse((0,J.readFileSync)(`${s.path}/deno.jsonc`,"utf8")):{}).tasks||{};return c=Re(c,{test:[l?.test?"deno task test":"deno test"],lint:[l?.lint?"deno task lint":"deno lint"],"check-types":[l?.checkTypes?"deno task check-types":"deno check"],...Object.entries(l).reduce((i,[o,p])=>(i[o]=[p.startsWith("deno")?p:`deno task ${o}`],i),{}),install:["deno install"],outdated:["deno outdated"]}),c}}),bt=Yn});var Pt,Kn,St,jt=h(()=>{"use strict";Pt=F(require("fs"),1);fe();B();Kn=R({name:"npm",actions:async s=>{let e=Pt.default.readdirSync(s.path),t=e.includes("package.json"),n=e.includes("package-lock.json");if(!(t&&n))return{};let a=_(s)?.scripts||{};return{...Object.entries(a).map(([i,o])=>[i,`npm run ${i}`]).reduce((i,[o,p])=>(i[o]=[p],i),{}),install:["npm install"],outdated:["npm outdated"]}}}),St=Kn});var N,$t,Zn,Qn,Xn,wt,er,tr,sr,kt,xt=h(()=>{"use strict";N=require("fs"),$t=require("os"),Zn=1800*1e3,Qn=()=>{let s=`${(0,$t.homedir)()}/.cache/denvig/dependencies/npm`;return(0,N.existsSync)(s)||(0,N.mkdirSync)(s,{recursive:!0}),s},Xn=s=>{let e=s.replace(/@/g,"_at_").replace(/\//g,"__");return e=e.replace(/[^a-zA-Z0-9\-_.]/g,"_"),e=e.replace(/\.{2,}/g,"_"),e=e.replace(/^\.+/,"_"),e.length===0&&(e="_empty_"),e.length>200&&(e=e.slice(0,200)),e},wt=s=>{let e=Xn(s);return`${Qn()}/${e}.json`},er=s=>{try{let e=(0,N.statSync)(s);return Date.now()-e.mtimeMs<Zn}catch{return!1}},tr=s=>{let e=wt(s);if(!(0,N.existsSync)(e)||!er(e))return null;try{let t=(0,N.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},sr=(s,e)=>{try{let t=wt(s);(0,N.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},kt=async(s,e=!1)=>{if(!e){let t=tr(s);if(t)return t}try{let t=await fetch(`https://registry.npmjs.com/${encodeURIComponent(s)}`,{headers:{Accept:"application/json"}});if(!t.ok)return null;let n=await t.json(),r=Object.keys(n.versions),c=n["dist-tags"]?.latest||r[r.length-1],a={versions:r,latest:c};return sr(s,a),a}catch{return null}}});var Q,Ne,nr,rr,or,Le,Ke=h(()=>{"use strict";xt();Q=s=>{let e=s.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);return e?{major:Number.parseInt(e[1],10),minor:Number.parseInt(e[2],10),patch:Number.parseInt(e[3],10),prerelease:e[4]||""}:null},Ne=(s,e)=>{let t=Q(s),n=Q(e);return!t||!n?0:t.major!==n.major?t.major-n.major:t.minor!==n.minor?t.minor-n.minor:t.patch!==n.patch?t.patch-n.patch:t.prerelease&&!n.prerelease?-1:!t.prerelease&&n.prerelease?1:0},nr=(s,e)=>{let t=Q(s);if(!t||t.prerelease)return!1;if(e.startsWith("^")){let r=Q(e.slice(1));return r?r.major===0?t.major===0&&t.minor===r.minor&&t.patch>=r.patch:t.major===r.major&&Ne(s,e.slice(1))>=0:!1}if(e.startsWith("~")){let r=Q(e.slice(1));return r?t.major===r.major&&t.minor===r.minor&&t.patch>=r.patch:!1}if(e.startsWith(">="))return Ne(s,e.slice(2))>=0;if(e.startsWith(">")&&!e.startsWith(">="))return Ne(s,e.slice(1))>0;let n=Q(e);return n?t.major===n.major&&t.minor===n.minor&&t.patch===n.patch:!1},rr=(s,e)=>{let t=s.filter(n=>nr(n,e)).sort(Ne);return t.length>0?t[t.length-1]:null},or=s=>{if(s.versions.length===0)return null;let e=s.versions[0],t=e.source.includes("#devDependencies");return{current:e.resolved,specifier:e.specifier,isDevDependency:t}},Le=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(a=>a.versions.some(l=>l.source.includes("#dependencies")||l.source.includes("#devDependencies"))).map(async a=>{let l=or(a);if(!l)return;let i=await kt(a.name,!t);if(!i)return;let o=rr(i.versions,l.specifier),p=i.latest,u=o&&o!==l.current,m=p&&p!==l.current;(u||m)&&n.push({...a,wanted:o||l.current,latest:p,specifier:l.specifier,isDevDependency:l.isDevDependency})});return await Promise.all(c),n}});var he,Ot,Ct,Ze,Rt,Nt,Lt=h(()=>{"use strict";he=require("fs"),Ot=require("yaml");Ke();fe();B();Ct=new Map,Ze=s=>{let e=s.indexOf("(");return e===-1?s:s.slice(0,e)},Rt=R({name:"pnpm",actions:async s=>{if(!s.rootFiles.includes("pnpm-lock.yaml"))return{};let r=_(s)?.scripts||{},c=s.rootFiles.includes("pnpm-workspace.yaml");return{...Object.entries(r).map(([l,i])=>[l,`pnpm run ${l}`]).reduce((l,[i,o])=>(l[i]=[o],l),{}),install:["pnpm install"],outdated:[c?"pnpm outdated -r":"pnpm outdated"]}},dependencies:async s=>{if(!(0,he.existsSync)(`${s.path}/pnpm-lock.yaml`))return[];let e=Ct.get(s.path);if(e)return e;let t=new Map,n=new Set,r=(o,p,u,m,d,g)=>{let f=t.get(o);f?f.versions.push({resolved:m,specifier:g,source:d}):t.set(o,{id:o,name:p,ecosystem:u,versions:[{resolved:m,specifier:g,source:d}]})};t.set("npm:pnpm",{id:"npm:pnpm",name:"pnpm",ecosystem:"system",versions:[]});let c=`${s.path}/pnpm-lock.yaml`,a=(0,he.readFileSync)(c,"utf-8"),l=(0,Ot.parse)(a);if(l?.importers)for(let[o,p]of Object.entries(l.importers)){let u=o==="."?".":o;if(p.dependencies)for(let[m,d]of Object.entries(p.dependencies))d?.specifier&&d?.version&&(n.add(m),r(`npm:${m}`,m,"npm",Ze(d.version),`${u}#dependencies`,d.specifier));if(p.devDependencies)for(let[m,d]of Object.entries(p.devDependencies))d?.specifier&&d?.version&&(n.add(m),r(`npm:${m}`,m,"npm",Ze(d.version),`${u}#devDependencies`,d.specifier))}if(l?.snapshots)for(let[o,p]of Object.entries(l.snapshots)){let u={...p.dependencies};for(let[m,d]of Object.entries(u))if(!n.has(m)){let g=Ze(d),f=`pnpm-lock.yaml:${o}`;r(`npm:${m}`,m,"npm",g,f,g)}}let i=Array.from(t.values()).sort((o,p)=>o.name.localeCompare(p.name));return Ct.set(s.path,i),i},outdatedDependencies:async(s,e)=>{if(!(0,he.existsSync)(`${s.path}/pnpm-lock.yaml`))return[];let t=await Rt.dependencies?.(s);return t?Le(t,e):[]}}),Nt=Rt});var L,Tt,ir,cr,ar,It,lr,pr,dr,At,Ft=h(()=>{"use strict";L=require("fs"),Tt=require("os"),ir=1800*1e3,cr=()=>{let s=`${(0,Tt.homedir)()}/.cache/denvig/dependencies/rubygems`;return(0,L.existsSync)(s)||(0,L.mkdirSync)(s,{recursive:!0}),s},ar=s=>{let e=s.replace(/[^a-zA-Z0-9\-_.]/g,"_");return e=e.replace(/\.{2,}/g,"_"),e=e.replace(/^\.+/,"_"),e.length===0&&(e="_empty_"),e.length>200&&(e=e.slice(0,200)),e},It=s=>{let e=ar(s);return`${cr()}/${e}.json`},lr=s=>{try{let e=(0,L.statSync)(s);return Date.now()-e.mtimeMs<ir}catch{return!1}},pr=s=>{let e=It(s);if(!(0,L.existsSync)(e)||!lr(e))return null;try{let t=(0,L.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},dr=(s,e)=>{try{let t=It(s);(0,L.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},At=async(s,e=!1)=>{if(!e){let t=pr(s);if(t)return t}try{let t=await fetch(`https://rubygems.org/api/v1/versions/${encodeURIComponent(s)}.json`,{headers:{Accept:"application/json"}});if(!t.ok)return null;let n=await t.json(),r=n.map(i=>i.number),a=n.filter(i=>!i.prerelease).map(i=>i.number)[0]||r[0],l={versions:r,latest:a};return dr(s,l),l}catch{return null}}});var ee,X,ur,mr,gr,Et,Vt=h(()=>{"use strict";Ft();ee=s=>{let e=s.match(/^(\d+)\.(\d+)(?:\.(\d+))?(?:-(.+)|\.(.+))?$/);return e?{major:Number.parseInt(e[1],10),minor:Number.parseInt(e[2],10),patch:e[3]?Number.parseInt(e[3],10):0,prerelease:e[4]||e[5]||""}:null},X=(s,e)=>{let t=ee(s),n=ee(e);return!t||!n?0:t.major!==n.major?t.major-n.major:t.minor!==n.minor?t.minor-n.minor:t.patch!==n.patch?t.patch-n.patch:t.prerelease&&!n.prerelease?-1:!t.prerelease&&n.prerelease?1:0},ur=(s,e)=>{let t=ee(s);if(!t||t.prerelease)return!1;if(e==="*")return!0;let n=e.trim();if(n.startsWith("~>")){let c=n.slice(2).trim(),a=ee(c);return a?c.split(".").length>=3?t.major===a.major&&t.minor===a.minor&&t.patch>=a.patch:t.major===a.major&&t.minor>=a.minor&&X(s,`${a.major}.${a.minor}.0`)>=0:!1}if(n.startsWith(">="))return X(s,n.slice(2).trim())>=0;if(n.startsWith(">")&&!n.startsWith(">="))return X(s,n.slice(1).trim())>0;if(n.startsWith("<="))return X(s,n.slice(2).trim())<=0;if(n.startsWith("<")&&!n.startsWith("<="))return X(s,n.slice(1).trim())<0;if(n.startsWith("=")){let c=n.slice(1).trim(),a=ee(c);return a?t.major===a.major&&t.minor===a.minor&&t.patch===a.patch:!1}let r=ee(n);return r?t.major===r.major&&t.minor===r.minor&&t.patch===r.patch:!1},mr=(s,e)=>{let t=s.filter(n=>ur(n,e)).sort(X);return t.length>0?t[t.length-1]:null},gr=s=>{if(s.versions.length===0)return null;let e=s.versions[0],t=e.source.includes("#devDependencies");return{current:e.resolved,specifier:e.specifier,isDevDependency:t}},Et=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(a=>a.versions.some(l=>l.source.includes("#dependencies")||l.source.includes("#devDependencies"))).map(async a=>{let l=gr(a);if(!l)return;let i=await At(a.name,!t);if(!i)return;let o=mr(i.versions,l.specifier),p=i.latest,u=o&&o!==l.current,m=p&&p!==l.current;(u||m)&&n.push({...a,wanted:o||l.current,latest:p,specifier:l.specifier,isDevDependency:l.isDevDependency})});return await Promise.all(c),n}});var te,fr,hr,Wt,Mt=h(()=>{"use strict";te=require("fs"),fr=s=>{let e=[],t=s.split(`
|
|
3
|
-
`),n="dependencies",r=0;for(let c of t){let
|
|
4
|
-
`),r="none",c=null,
|
|
5
|
-
`),n=[],r=null,c=null,
|
|
2
|
+
"use strict";var Kn=Object.create;var Be=Object.defineProperty;var Zn=Object.getOwnPropertyDescriptor;var Qn=Object.getOwnPropertyNames;var Xn=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var h=(s,e)=>()=>(s&&(e=s(s=0)),e);var x=(s,e)=>{for(var t in e)Be(s,t,{get:e[t],enumerable:!0})},tr=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Qn(e))!er.call(s,r)&&r!==t&&Be(s,r,{get:()=>e[r],enumerable:!(n=Zn(e,r))||n.enumerable});return s};var W=(s,e,t)=>(t=s!=null?Kn(Xn(s)):{},tr(e||!s||!s.__esModule?Be(t,"default",{value:s,enumerable:!0}):t,s));var w,sr,Ye,Te,Ke=h(()=>{"use strict";w=require("zod"),sr=["build","check-types","dev","install","lint","outdated","test"],Ye=w.z.object({codeRootDir:w.z.string().optional().default("~/src").describe("The base directory where projects are stored"),quickActions:w.z.array(w.z.string()).default(sr).optional().describe("Quick actions that are available for all projects")}),Te=w.z.object({name:w.z.string().describe("Unique identifier for the project"),actions:w.z.record(w.z.string().describe("Name of the action"),w.z.object({command:w.z.string().describe("Shell command to run for the action")})).optional().describe("Actions that can be run against the project"),quickActions:w.z.array(w.z.string()).optional().describe("Actions that are available on the CLI root for quick access"),services:w.z.record(w.z.string(),w.z.object({cwd:w.z.string().optional().describe("Working directory for the service (relative to project root)"),command:w.z.string().describe("Shell command to execute"),http:w.z.object({port:w.z.number().optional().describe("Port number the service listens on"),domain:w.z.string().optional().describe("Domain to use for the service URL"),secure:w.z.boolean().optional().describe("Use HTTPS instead of HTTP")}).strict().optional().describe("HTTP configuration for the service URL"),envFile:w.z.string().optional().describe("Path to .env file (relative to project root)"),env:w.z.record(w.z.string(),w.z.string()).optional().describe("Environment variables"),keepAlive:w.z.boolean().optional().describe("Restart service if it exits")}).strict()).optional().describe("Service that can be managed for this project")}).strict()});var St,nr,ye,Ze=h(()=>{"use strict";St=require("fs"),nr=require("fs/promises"),ye=s=>{try{return(0,St.readFileSync)(s,"utf8").trim()||null}catch(e){if(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")return null;throw e}}});var Z,Qe,Ie,rr,wt,J,$t,be=h(()=>{"use strict";Z=require("path"),Qe=require("yaml");Ke();Ze();Ie=(0,Z.resolve)(process.env.DENVIG_GLOBAL_CONFIG_PATH||`${process.env.HOME}/.denvig/config.yml`),rr=(0,Z.resolve)(process.env.DENVIG_CODE_ROOT_DIR||`${process.env.HOME}/src`),wt={codeRootDir:rr,quickActions:void 0},J=()=>{let s=ye(Ie);if(s){let e=(0,Qe.parse)(s)||{};try{if(e.codeRootDir?.startsWith(".")){let t=(0,Z.dirname)(Ie);e.codeRootDir=(0,Z.resolve)(`${t}/${e.codeRootDir}`)}return{...Ye.parse({...wt,...e}),$sources:[Ie]}}catch(t){console.error(`Error parsing global config at ${Ie}:`,t),process.exit(1)}}return{...Ye.parse(wt),$sources:[]}},$t=s=>{let e=J(),t={name:s,actions:{}},n=`${e.codeRootDir}/${s}/.denvig.yml`,r=ye(n);if(r)try{return{...t,...Te.parse((0,Qe.parse)(r)),$sources:[n]}}catch(c){console.warn(`Error parsing project config for ${s} at ${n}.`),c instanceof Error?console.warn(c.message):console.warn("Unknown error:",c)}return{...t,$sources:[]}}});var Ae,Xe=h(()=>{"use strict";Ae=(s,e)=>{for(let[t,n]of Object.entries(e))s[t]||(s[t]=[]),s[t].push(...n);return s}});var et,q,De=h(()=>{"use strict";et=W(require("fs"),1),q=s=>{let e=`${s.path}/package.json`;if(!et.default.existsSync(e))return null;let t=et.default.readFileSync(e,"utf-8");return JSON.parse(t)}});var T,Y=h(()=>{"use strict";T=s=>s});var U,or,kt,Ct=h(()=>{"use strict";U=W(require("fs"),1);Xe();De();Y();or=T({name:"deno",actions:async s=>{let e=U.default.readdirSync(s.path);if(!(e.includes("deno.json")||e.includes("deno.jsonc")))return{};let r=q(s)?.scripts||{},c={...Object.entries(r).map(([i,o])=>[i,`deno ${o}`]).reduce((i,[o,p])=>(i[o]=[p],i),{}),install:["deno install"],outdated:["deno outdated"]},a=((0,U.existsSync)(`${s.path}/deno.json`)?JSON.parse((0,U.readFileSync)(`${s.path}/deno.json`,"utf8")):(0,U.existsSync)(`${s.path}/deno.jsonc`)?JSON.parse((0,U.readFileSync)(`${s.path}/deno.jsonc`,"utf8")):{}).tasks||{};return c=Ae(c,{test:[a?.test?"deno task test":"deno test"],lint:[a?.lint?"deno task lint":"deno lint"],"check-types":[a?.checkTypes?"deno task check-types":"deno check"],...Object.entries(a).reduce((i,[o,p])=>(i[o]=[p.startsWith("deno")?p:`deno task ${o}`],i),{}),install:["deno install"],outdated:["deno outdated"]}),c}}),kt=or});var xt,ir,Ot,Rt=h(()=>{"use strict";xt=W(require("fs"),1);De();Y();ir=T({name:"npm",actions:async s=>{let e=xt.default.readdirSync(s.path),t=e.includes("package.json"),n=e.includes("package-lock.json");if(!(t&&n))return{};let l=q(s)?.scripts||{};return{...Object.entries(l).map(([i,o])=>[i,`npm run ${i}`]).reduce((i,[o,p])=>(i[o]=[p],i),{}),install:["npm install"],outdated:["npm outdated"]}}}),Ot=ir});var F,Lt,cr,ar,lr,Nt,pr,dr,ur,Tt,It=h(()=>{"use strict";F=require("fs"),Lt=require("os"),cr=1800*1e3,ar=()=>{let s=`${(0,Lt.homedir)()}/.cache/denvig/dependencies/npm`;return(0,F.existsSync)(s)||(0,F.mkdirSync)(s,{recursive:!0}),s},lr=s=>{let e=s.replace(/@/g,"_at_").replace(/\//g,"__");return e=e.replace(/[^a-zA-Z0-9\-_.]/g,"_"),e=e.replace(/\.{2,}/g,"_"),e=e.replace(/^\.+/,"_"),e.length===0&&(e="_empty_"),e.length>200&&(e=e.slice(0,200)),e},Nt=s=>{let e=lr(s);return`${ar()}/${e}.json`},pr=s=>{try{let e=(0,F.statSync)(s);return Date.now()-e.mtimeMs<cr}catch{return!1}},dr=s=>{let e=Nt(s);if(!(0,F.existsSync)(e)||!pr(e))return null;try{let t=(0,F.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},ur=(s,e)=>{try{let t=Nt(s);(0,F.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},Tt=async(s,e=!1)=>{if(!e){let t=dr(s);if(t)return t}try{let t=await fetch(`https://registry.npmjs.com/${encodeURIComponent(s)}`,{headers:{Accept:"application/json"}});if(!t.ok)return null;let n=await t.json(),r=Object.keys(n.versions),c=n["dist-tags"]?.latest||r[r.length-1],l={versions:r,latest:c};return ur(s,l),l}catch{return null}}});var Q,Fe,mr,gr,fr,Ee,tt=h(()=>{"use strict";It();Q=s=>{let e=s.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);return e?{major:Number.parseInt(e[1],10),minor:Number.parseInt(e[2],10),patch:Number.parseInt(e[3],10),prerelease:e[4]||""}:null},Fe=(s,e)=>{let t=Q(s),n=Q(e);return!t||!n?0:t.major!==n.major?t.major-n.major:t.minor!==n.minor?t.minor-n.minor:t.patch!==n.patch?t.patch-n.patch:t.prerelease&&!n.prerelease?-1:!t.prerelease&&n.prerelease?1:0},mr=(s,e)=>{let t=Q(s);if(!t||t.prerelease)return!1;if(e.startsWith("^")){let r=Q(e.slice(1));return r?r.major===0?t.major===0&&t.minor===r.minor&&t.patch>=r.patch:t.major===r.major&&Fe(s,e.slice(1))>=0:!1}if(e.startsWith("~")){let r=Q(e.slice(1));return r?t.major===r.major&&t.minor===r.minor&&t.patch>=r.patch:!1}if(e.startsWith(">="))return Fe(s,e.slice(2))>=0;if(e.startsWith(">")&&!e.startsWith(">="))return Fe(s,e.slice(1))>0;let n=Q(e);return n?t.major===n.major&&t.minor===n.minor&&t.patch===n.patch:!1},gr=(s,e)=>{let t=s.filter(n=>mr(n,e)).sort(Fe);return t.length>0?t[t.length-1]:null},fr=s=>{if(s.versions.length===0)return null;let e=s.versions[0],t=e.source.includes("#devDependencies");return{current:e.resolved,specifier:e.specifier,isDevDependency:t}},Ee=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(l=>l.versions.some(a=>a.source.includes("#dependencies")||a.source.includes("#devDependencies"))).map(async l=>{let a=fr(l);if(!a)return;let i=await Tt(l.name,!t);if(!i)return;let o=gr(i.versions,a.specifier),p=i.latest,d=o&&o!==a.current,m=p&&p!==a.current;(d||m)&&n.push({...l,wanted:o||a.current,latest:p,specifier:a.specifier,isDevDependency:a.isDevDependency})});return await Promise.all(c),n}});var je,Ft,At,st,Et,Vt,Wt=h(()=>{"use strict";je=require("fs"),Ft=require("yaml");tt();De();Y();At=new Map,st=s=>{let e=s.indexOf("(");return e===-1?s:s.slice(0,e)},Et=T({name:"pnpm",actions:async s=>{if(!s.rootFiles.includes("pnpm-lock.yaml"))return{};let r=q(s)?.scripts||{},c=s.rootFiles.includes("pnpm-workspace.yaml");return{...Object.entries(r).map(([a,i])=>[a,`pnpm run ${a}`]).reduce((a,[i,o])=>(a[i]=[o],a),{}),install:["pnpm install"],outdated:[c?"pnpm outdated -r":"pnpm outdated"]}},dependencies:async s=>{if(!(0,je.existsSync)(`${s.path}/pnpm-lock.yaml`))return[];let e=At.get(s.path);if(e)return e;let t=new Map,n=new Set,r=(o,p,d,m,u,g)=>{let f=t.get(o);f?f.versions.push({resolved:m,specifier:g,source:u}):t.set(o,{id:o,name:p,ecosystem:d,versions:[{resolved:m,specifier:g,source:u}]})};t.set("npm:pnpm",{id:"npm:pnpm",name:"pnpm",ecosystem:"system",versions:[]});let c=`${s.path}/pnpm-lock.yaml`,l=(0,je.readFileSync)(c,"utf-8"),a=(0,Ft.parse)(l);if(a?.importers)for(let[o,p]of Object.entries(a.importers)){let d=o==="."?".":o;if(p.dependencies)for(let[m,u]of Object.entries(p.dependencies))u?.specifier&&u?.version&&(n.add(m),r(`npm:${m}`,m,"npm",st(u.version),`${d}#dependencies`,u.specifier));if(p.devDependencies)for(let[m,u]of Object.entries(p.devDependencies))u?.specifier&&u?.version&&(n.add(m),r(`npm:${m}`,m,"npm",st(u.version),`${d}#devDependencies`,u.specifier))}if(a?.snapshots)for(let[o,p]of Object.entries(a.snapshots)){let d={...p.dependencies};for(let[m,u]of Object.entries(d))if(!n.has(m)){let g=st(u),f=`pnpm-lock.yaml:${o}`;r(`npm:${m}`,m,"npm",g,f,g)}}let i=Array.from(t.values()).sort((o,p)=>o.name.localeCompare(p.name));return At.set(s.path,i),i},outdatedDependencies:async(s,e)=>{if(!(0,je.existsSync)(`${s.path}/pnpm-lock.yaml`))return[];let t=await Et.dependencies?.(s);return t?Ee(t,e):[]}}),Vt=Et});var E,Mt,hr,vr,yr,_t,br,Dr,jr,Jt,Gt=h(()=>{"use strict";E=require("fs"),Mt=require("os"),hr=1800*1e3,vr=()=>{let s=`${(0,Mt.homedir)()}/.cache/denvig/dependencies/rubygems`;return(0,E.existsSync)(s)||(0,E.mkdirSync)(s,{recursive:!0}),s},yr=s=>{let e=s.replace(/[^a-zA-Z0-9\-_.]/g,"_");return e=e.replace(/\.{2,}/g,"_"),e=e.replace(/^\.+/,"_"),e.length===0&&(e="_empty_"),e.length>200&&(e=e.slice(0,200)),e},_t=s=>{let e=yr(s);return`${vr()}/${e}.json`},br=s=>{try{let e=(0,E.statSync)(s);return Date.now()-e.mtimeMs<hr}catch{return!1}},Dr=s=>{let e=_t(s);if(!(0,E.existsSync)(e)||!br(e))return null;try{let t=(0,E.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},jr=(s,e)=>{try{let t=_t(s);(0,E.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},Jt=async(s,e=!1)=>{if(!e){let t=Dr(s);if(t)return t}try{let t=await fetch(`https://rubygems.org/api/v1/versions/${encodeURIComponent(s)}.json`,{headers:{Accept:"application/json"}});if(!t.ok)return null;let n=await t.json(),r=n.map(i=>i.number),l=n.filter(i=>!i.prerelease).map(i=>i.number)[0]||r[0],a={versions:r,latest:l};return jr(s,a),a}catch{return null}}});var ee,X,Pr,Sr,wr,qt,Ut=h(()=>{"use strict";Gt();ee=s=>{let e=s.match(/^(\d+)\.(\d+)(?:\.(\d+))?(?:-(.+)|\.(.+))?$/);return e?{major:Number.parseInt(e[1],10),minor:Number.parseInt(e[2],10),patch:e[3]?Number.parseInt(e[3],10):0,prerelease:e[4]||e[5]||""}:null},X=(s,e)=>{let t=ee(s),n=ee(e);return!t||!n?0:t.major!==n.major?t.major-n.major:t.minor!==n.minor?t.minor-n.minor:t.patch!==n.patch?t.patch-n.patch:t.prerelease&&!n.prerelease?-1:!t.prerelease&&n.prerelease?1:0},Pr=(s,e)=>{let t=ee(s);if(!t||t.prerelease)return!1;if(e==="*")return!0;let n=e.trim();if(n.startsWith("~>")){let c=n.slice(2).trim(),l=ee(c);return l?c.split(".").length>=3?t.major===l.major&&t.minor===l.minor&&t.patch>=l.patch:t.major===l.major&&t.minor>=l.minor&&X(s,`${l.major}.${l.minor}.0`)>=0:!1}if(n.startsWith(">="))return X(s,n.slice(2).trim())>=0;if(n.startsWith(">")&&!n.startsWith(">="))return X(s,n.slice(1).trim())>0;if(n.startsWith("<="))return X(s,n.slice(2).trim())<=0;if(n.startsWith("<")&&!n.startsWith("<="))return X(s,n.slice(1).trim())<0;if(n.startsWith("=")){let c=n.slice(1).trim(),l=ee(c);return l?t.major===l.major&&t.minor===l.minor&&t.patch===l.patch:!1}let r=ee(n);return r?t.major===r.major&&t.minor===r.minor&&t.patch===r.patch:!1},Sr=(s,e)=>{let t=s.filter(n=>Pr(n,e)).sort(X);return t.length>0?t[t.length-1]:null},wr=s=>{if(s.versions.length===0)return null;let e=s.versions[0],t=e.source.includes("#devDependencies");return{current:e.resolved,specifier:e.specifier,isDevDependency:t}},qt=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(l=>l.versions.some(a=>a.source.includes("#dependencies")||a.source.includes("#devDependencies"))).map(async l=>{let a=wr(l);if(!a)return;let i=await Jt(l.name,!t);if(!i)return;let o=Sr(i.versions,a.specifier),p=i.latest,d=o&&o!==a.current,m=p&&p!==a.current;(d||m)&&n.push({...l,wanted:o||a.current,latest:p,specifier:a.specifier,isDevDependency:a.isDevDependency})});return await Promise.all(c),n}});var te,$r,kr,Ht,zt=h(()=>{"use strict";te=require("fs"),$r=s=>{let e=[],t=s.split(`
|
|
3
|
+
`),n="dependencies",r=0;for(let c of t){let l=c.trim();if(l.startsWith("#")||l==="")continue;if(l.startsWith("group ")){(l.includes(":development")||l.includes(":test"))&&(n="devDependencies"),l.includes(" do")&&r++;continue}if(l==="end"){r--,r<=0&&(n="dependencies",r=0);continue}let a=l.match(/^gem\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/);if(a){let i=a[1],o=a[2]||"*";e.push({name:i,specifier:o,group:n})}}return e},kr=s=>{let e={},t={},n=s.split(`
|
|
4
|
+
`),r="none",c=null,l=null;for(let a of n){let i=a.trimEnd();if(i==="GEM"){r="gem";continue}if(i==="PLATFORMS"){r="platforms";continue}if(i==="DEPENDENCIES"){r="dependencies";continue}if(i==="BUNDLED WITH"){r="none";continue}if(r==="gem"&&i===" specs:"){r="specs";continue}if(r==="specs"){if(i==="")continue;let o=a.match(/^(\s*)/),p=o?o[1].length:0,d=a.trim();if(p===4){let m=d.match(/^([^\s(]+)\s+\(([^)]+)\)/);if(m){let u=m[2],g=u.match(/^[\d.]+/),f=g?g[0]:u;c=m[1],l=f,e[c]||(e[c]={version:f,dependencies:{}})}}else if(p===6&&c&&l){let m=d.match(/^([^\s(]+)(?:\s+\(([^)]+)\))?/);if(m){let u=m[1],g=m[2]||"*";e[c].dependencies[u]=g}}}if(r==="dependencies"){if(i===""||i.startsWith(" ")===!1)continue;let o=i.match(/^\s+([^\s(!]+)(?:\s+\(([^)]+)\))?/);if(o){let d=o[1].replace(/!$/,""),m=o[2]||"*";t[d]=m}}}return{specs:e,dependencies:t}},Ht=async s=>{let e=`${s.path}/Gemfile`,t=`${s.path}/Gemfile.lock`;if(!(0,te.existsSync)(e))return[];let n=new Map,r=new Set,c=(0,te.readFileSync)(e,"utf-8"),l=$r(c),a=(i,o,p,d,m,u)=>{let g=n.get(i);g?g.versions.push({resolved:d,specifier:u,source:m}):n.set(i,{id:i,name:o,ecosystem:p,versions:[{resolved:d,specifier:u,source:m}]})};n.set("rubygems:bundler",{id:"rubygems:bundler",name:"bundler",ecosystem:"system",versions:[]});for(let i of l)r.add(i.name);if((0,te.existsSync)(t)){let i=(0,te.readFileSync)(t,"utf-8"),o=kr(i);for(let p of l){let d=o.specs[p.name];d&&a(`rubygems:${p.name}`,p.name,"rubygems",d.version,`.#${p.group}`,p.specifier)}for(let[p,d]of Object.entries(o.specs))if(!r.has(p)){for(let[m,u]of Object.entries(o.specs))if(u.dependencies[p]){let g=`Gemfile.lock:${m}@${u.version}`,f=u.dependencies[p];a(`rubygems:${p}`,p,"rubygems",d.version,g,f)}}}else for(let i of l)a(`rubygems:${i.name}`,i.name,"rubygems",i.specifier,`.#${i.group}`,i.specifier);return Array.from(n.values()).sort((i,o)=>i.name.localeCompare(o.name))}});var nt,Bt,Yt,Kt,Zt=h(()=>{"use strict";nt=W(require("fs"),1);Y();Ut();zt();Bt=new Map,Yt=T({name:"ruby",actions:async s=>{let e=nt.default.readdirSync(s.path),t=e.includes("Gemfile"),n=e.includes("Rakefile"),r=e.includes("config.ru"),c=nt.default.existsSync(`${s.path}/config/application.rb`);if(!(t||n))return{};let a={install:["bundle install"],update:["bundle update"],outdated:["bundle outdated"]};return c&&(a.dev=["bundle exec rails server"],a.repl=["bundle exec rails console"]),r&&!c&&(a.dev=["bundle exec rackup"]),a},dependencies:async s=>{if(!s.rootFiles.includes("Gemfile"))return[];let t=Bt.get(s.path);if(t)return t;let n=await Ht(s);return Bt.set(s.path,n),n},outdatedDependencies:async(s,e)=>{if(!s.rootFiles.includes("Gemfile"))return[];let n=await Yt.dependencies?.(s);return n?qt(n,e):[]}}),Kt=Yt});var V,Qt,Cr,xr,Or,Xt,Rr,Lr,Nr,es,ts=h(()=>{"use strict";V=require("fs"),Qt=require("os"),Cr=1800*1e3,xr=()=>{let s=`${(0,Qt.homedir)()}/.cache/denvig/dependencies/pypi`;return(0,V.existsSync)(s)||(0,V.mkdirSync)(s,{recursive:!0}),s},Or=s=>{let e=s.toLowerCase().replace(/[-_.]+/g,"-");return e=e.replace(/[^a-zA-Z0-9-]/g,"_"),e=e.replace(/\.{2,}/g,"_"),e=e.replace(/^\.+/,"_"),e.length===0&&(e="_empty_"),e.length>200&&(e=e.slice(0,200)),e},Xt=s=>{let e=Or(s);return`${xr()}/${e}.json`},Rr=s=>{try{let e=(0,V.statSync)(s);return Date.now()-e.mtimeMs<Cr}catch{return!1}},Lr=s=>{let e=Xt(s);if(!(0,V.existsSync)(e)||!Rr(e))return null;try{let t=(0,V.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},Nr=(s,e)=>{try{let t=Xt(s);(0,V.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},es=async(s,e=!1)=>{let t=s.toLowerCase().replace(/_/g,"-");if(!e){let n=Lr(t);if(n)return n}try{let n=await fetch(`https://pypi.org/pypi/${encodeURIComponent(t)}/json`,{headers:{Accept:"application/json"}});if(!n.ok)return null;let r=await n.json(),c=Object.entries(r.releases).filter(([,i])=>i.length>0).map(([i])=>i),l=r.info?.version||c[c.length-1],a={versions:c,latest:l};return Nr(t,a),a}catch{return null}}});var ne,se,Tr,Ir,Ar,Fr,ss,ns=h(()=>{"use strict";ts();ne=s=>{let e=s.match(/^(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?(.*)$/);return e?{major:Number.parseInt(e[1],10),minor:Number.parseInt(e[2],10),patch:e[3]?Number.parseInt(e[3],10):0,prerelease:e[5]||""}:null},se=(s,e)=>{let t=ne(s),n=ne(e);return!t||!n?0:t.major!==n.major?t.major-n.major:t.minor!==n.minor?t.minor-n.minor:t.patch!==n.patch?t.patch-n.patch:t.prerelease&&!n.prerelease?-1:!t.prerelease&&n.prerelease?1:0},Tr=s=>/[a-zA-Z]/.test(s),Ir=(s,e)=>{let t=ne(s);if(!t||Tr(s))return!1;if(e==="*")return!0;if(e.startsWith("~=")){let r=e.slice(2).trim(),c=ne(r);return c?r.split(".").length>=3?t.major===c.major&&t.minor===c.minor&&t.patch>=c.patch:t.major===c.major&&t.minor>=c.minor:!1}if(e.startsWith(">="))return se(s,e.slice(2).trim())>=0;if(e.startsWith(">")&&!e.startsWith(">="))return se(s,e.slice(1).trim())>0;if(e.startsWith("<="))return se(s,e.slice(2).trim())<=0;if(e.startsWith("<")&&!e.startsWith("<="))return se(s,e.slice(1).trim())<0;if(e.startsWith("!="))return se(s,e.slice(2).trim())!==0;if(e.startsWith("==")){let r=e.slice(2).trim();if(r.endsWith(".*")){let l=r.slice(0,-2);return s.startsWith(l)}let c=ne(r);return c?t.major===c.major&&t.minor===c.minor&&t.patch===c.patch:!1}let n=ne(e);return n?t.major===n.major&&t.minor===n.minor&&t.patch===n.patch:!1},Ar=(s,e)=>{let t=s.filter(n=>Ir(n,e)).sort(se);return t.length>0?t[t.length-1]:null},Fr=s=>{if(s.versions.length===0)return null;let e=s.versions[0],t=e.source.includes("#devDependencies");return{current:e.resolved,specifier:e.specifier,isDevDependency:t}},ss=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(l=>l.versions.some(a=>a.source.includes("#dependencies")||a.source.includes("#devDependencies"))).map(async l=>{let a=Fr(l);if(!a)return;let i=await es(l.name,!t);if(!i)return;let o=Ar(i.versions,a.specifier),p=i.latest,d=o&&o!==a.current,m=p&&p!==a.current;(d||m)&&n.push({...l,wanted:o||a.current,latest:p,specifier:a.specifier,isDevDependency:a.isDevDependency})});return await Promise.all(c),n}});var Er,rt,ot,We,rs,Ve,it,os=h(()=>{"use strict";Er=s=>{let e=s.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e},rt=s=>{let e=s.trim();return e==="true"?!0:e==="false"?!1:/^-?\d+$/.test(e)?Number.parseInt(e,10):/^-?\d+\.\d+$/.test(e)?Number.parseFloat(e):Er(e)},ot=s=>{let e={},t=s.slice(1,-1).trim();if(!t)return e;let n=[],r="",c=0,l=!1,a="";for(let i=0;i<t.length;i++){let o=t[i];if(!l&&(o==='"'||o==="'")?(l=!0,a=o):l&&o===a&&t[i-1]!=="\\"&&(l=!1),!l){if(o==="{"||o==="[")c++;else if(o==="}"||o==="]")c--;else if(o===","&&c===0){n.push(r.trim()),r="";continue}}r+=o}r.trim()&&n.push(r.trim());for(let i of n){let o=i.indexOf("=");if(o===-1)continue;let p=i.slice(0,o).trim(),d=i.slice(o+1).trim();d.startsWith("{")?e[p]=ot(d):d.startsWith("[")?e[p]=We(d):e[p]=rt(d)}return e},We=s=>{let e=[],t=s.slice(1,-1).trim();if(!t)return e;let n=[],r="",c=0,l=!1,a="";for(let i=0;i<t.length;i++){let o=t[i];if(!l&&(o==='"'||o==="'")?(l=!0,a=o):l&&o===a&&t[i-1]!=="\\"&&(l=!1),!l){if(o==="{"||o==="[")c++;else if(o==="}"||o==="]")c--;else if(o===","&&c===0){n.push(r.trim()),r="";continue}}r+=o}r.trim()&&n.push(r.trim());for(let i of n){let o=i.trim();o.startsWith("{")?e.push(ot(o)):o.startsWith("[")?e.push(We(o)):e.push(rt(o))}return e},rs=(s,e,t)=>{let n=s;for(let r=0;r<e.length-1;r++){let c=e[r];(!(c in n)||typeof n[c]!="object")&&(n[c]={}),n=n[c]}n[e[e.length-1]]=t},Ve=(s,e)=>{let t=s;for(let n of e)(!(n in t)||typeof t[n]!="object")&&(t[n]={}),t=t[n];return t},it=s=>{let e={},t=s.split(`
|
|
5
|
+
`),n=[],r=null,c=null,l=null,a=null;for(let i=0;i<t.length;i++){let o=t[i];if(l!==null&&a!==null){if(l+=o,o.includes("]")){let f=0,v=-1;for(let y=0;y<l.length;y++)if(l[y]==="[")f++;else if(l[y]==="]"&&(f--,f===0)){v=y;break}if(v!==-1){let y=l.slice(0,v+1),j=We(y);if(c)c[a]=j;else{let P=[...n,a];rs(e,P,j)}l=null,a=null}}continue}let p=o.indexOf("#");if(p!==-1){let f=!1,v="";for(let y=0;y<p;y++){let j=o[y];!f&&(j==='"'||j==="'")?(f=!0,v=j):f&&j===v&&o[y-1]!=="\\"&&(f=!1)}f||(o=o.slice(0,p))}if(o=o.trim(),!o)continue;if(o.startsWith("[[")&&o.endsWith("]]")){if(c&&r){let f=Ve(e,r.slice(0,-1)),v=r[r.length-1];Array.isArray(f[v])||(f[v]=[]),f[v].push(c)}r=o.slice(2,-2).split("."),c={},n=[];continue}if(o.startsWith("[")&&o.endsWith("]")){if(c&&r){let f=Ve(e,r.slice(0,-1)),v=r[r.length-1];Array.isArray(f[v])||(f[v]=[]),f[v].push(c),c=null,r=null}n=o.slice(1,-1).split("."),Ve(e,n);continue}let d=o.indexOf("=");if(d===-1)continue;let m=o.slice(0,d).trim(),u=o.slice(d+1).trim();if(u.startsWith("[")&&!u.endsWith("]")){l=u,a=m;continue}let g;if(u.startsWith("{")?g=ot(u):u.startsWith("[")?g=We(u):g=rt(u),c)c[m]=g;else{let f=[...n,m];rs(e,f,g)}}if(c&&r){let i=Ve(e,r.slice(0,-1)),o=r[r.length-1];Array.isArray(i[o])||(i[o]=[]),i[o].push(c)}return e}});var re,Pe,ct,Vr,Wr,is,cs=h(()=>{"use strict";re=require("fs");os();Pe=s=>s.toLowerCase().replace(/_/g,"-"),ct=s=>{let e=s.match(/^([a-zA-Z0-9_-]+(?:\[[^\]]+\])?)(.*)$/);if(e){let t=e[1].replace(/\[.*\]$/,""),n=e[2].trim()||"*";return{name:t,specifier:n}}return{name:s,specifier:"*"}},Vr=s=>{let e=[];try{let t=it(s);if(t.project?.dependencies)for(let n of t.project.dependencies){let{name:r,specifier:c}=ct(n);e.push({name:r,specifier:c,group:"dependencies"})}if(t.tool?.uv?.["dev-dependencies"])for(let n of t.tool.uv["dev-dependencies"]){let{name:r,specifier:c}=ct(n);e.push({name:r,specifier:c,group:"devDependencies"})}if(t.project?.["optional-dependencies"])for(let n of Object.values(t.project["optional-dependencies"]))for(let r of n){let{name:c,specifier:l}=ct(r);e.push({name:c,specifier:l,group:"devDependencies"})}}catch{}return e},Wr=s=>{let e={},t=null;try{let n=it(s);if(n.package)for(let r of n.package){let c=Pe(r.name);r.source?.virtual&&(t=c);let l=r.dependencies?.map(a=>Pe(a.name))||[];e[c]={name:r.name,version:r.version,dependencies:l}}}catch{}return{packages:e,projectName:t}},is=async s=>{let e=`${s.path}/pyproject.toml`,t=`${s.path}/uv.lock`;if(!(0,re.existsSync)(e))return[];let n=new Map,r=new Set,c=(i,o,p,d,m,u)=>{let g=n.get(i);g?g.versions.push({resolved:d,specifier:u,source:m}):n.set(i,{id:i,name:o,ecosystem:p,versions:[{resolved:d,specifier:u,source:m}]})};n.set("pypi:uv",{id:"pypi:uv",name:"uv",ecosystem:"system",versions:[]});let l=(0,re.readFileSync)(e,"utf-8"),a=Vr(l);for(let i of a)r.add(Pe(i.name));if((0,re.existsSync)(t)){let i=(0,re.readFileSync)(t,"utf-8"),o=Wr(i);for(let p of a){let d=Pe(p.name),m=o.packages[d];m&&c(`pypi:${d}`,m.name,"pypi",m.version,`.#${p.group}`,p.specifier)}for(let[p,d]of Object.entries(o.packages))if(!(p===o.projectName||r.has(p))){for(let[,m]of Object.entries(o.packages))if(m.dependencies.includes(p)){let u=`uv.lock:${m.name}@${m.version}`;c(`pypi:${p}`,d.name,"pypi",d.version,u,"*")}}}else for(let i of a){let o=Pe(i.name);c(`pypi:${o}`,i.name,"pypi",i.specifier,`.#${i.group}`,i.specifier)}return Array.from(n.values()).sort((i,o)=>i.name.localeCompare(o.name))}});var ls,as,ps,ds,us=h(()=>{"use strict";ls=W(require("fs"),1);Y();ns();cs();as=new Map,ps=T({name:"uv",actions:async s=>{let e=ls.default.readdirSync(s.path),t=e.includes("pyproject.toml");return e.includes("uv.lock")||t?{install:["uv sync"]}:{}},dependencies:async s=>{let e=s.rootFiles.includes("pyproject.toml"),t=s.rootFiles.includes("uv.lock");if(!e&&!t)return[];let n=as.get(s.path);if(n)return n;let r=await is(s);return as.set(s.path,r),r},outdatedDependencies:async(s,e)=>{if(!s.rootFiles.includes("pyproject.toml"))return[];let n=await ps.dependencies?.(s);return n?ss(n,e):[]}}),ds=ps});var Mr,ms,gs=h(()=>{"use strict";Mr=s=>{let e=s.split(`
|
|
6
6
|
|
|
7
7
|
`),t={};for(let n of e){let r=n.split(`
|
|
8
|
-
`);if(r.length<3)continue;let c=r[0].split(",").map(p=>p.trim().replace(/"|:/g,"")),
|
|
9
|
-
`),p=o[0],
|
|
10
|
-
`).map(t=>console.log(` ${
|
|
11
|
-
`).slice(1).map(r=>{let c=r.trim().split(/\s+/);return c.length<3?null:{pid:c[0]==="-"?"-":parseInt(c[0],10),status:parseInt(c[1],10),label:c[2]}}).filter(r=>r!==null);return s?n.filter(r=>r.label.includes(s)):n}catch{return[]}}var
|
|
12
|
-
`);for(let n=0;n<t.length;n++){let r=t[n].trim();if(!r||r.startsWith("#"))continue;let c=r.indexOf("=");if(c===-1)continue;let
|
|
13
|
-
<string>${
|
|
8
|
+
`);if(r.length<3)continue;let c=r[0].split(",").map(p=>p.trim().replace(/"|:/g,"")),l=r[1]?.match(/version "(.+)"/)?.[1],a=r[2]?.match(/resolved "(.+)"/)?.[1];if(!l||!a)continue;let i={},o=!1;for(let p=3;p<r.length;p++){let d=r[p];if(d.trim()==="dependencies:"){o=!0;continue}if(o&&d.startsWith(" ")){let m=d.trim().match(/^"?([^"\s]+)"?\s+"?([^"]+)"?$/);m&&(i[m[1]]=m[2])}else o&&!d.startsWith(" ")&&(o=!1)}for(let p of c)p&&(t[p]={version:l,resolved:a,dependencies:Object.keys(i).length>0?i:void 0})}return{type:"success",object:t}},ms=s=>{let e={},t=Mr(s),n=new Map;for(let[r,c]of Object.entries(t.object)){let l=/^(@?.+)@(.+)$/,[,a,i]=r.match(l)||[];a&&(n.has(a)||n.set(a,[]),n.get(a)?.push({version:c.version,specifier:i,deps:c.dependencies}))}for(let[r,c]of n.entries()){e[r]||(e[r]={versions:{}});for(let l of c)e[r].versions[l.version]||(e[r].versions[l.version]={}),e[r].versions[l.version]["yarn.lock"]=l.specifier;e[r].versions=Object.fromEntries(Object.entries(e[r].versions).sort((l,a)=>l[0].localeCompare(a[0],void 0,{numeric:!0})))}for(let[r,c]of n.entries())for(let l of c){if(!l.deps)continue;let a=`${r}@${l.version}`;for(let[i,o]of Object.entries(l.deps)){e[i]||(e[i]={versions:{}});let p=n.get(i);if(!p)continue;let m=p.find(u=>u.specifier===o)?.version||p[0]?.version;if(m){e[i].versions[m]||(e[i].versions[m]={});let u=`yarn.lock:${a}`;e[i].versions[m][u]=o}}}return{dependencies:e}}});function _r(s){return s.includes("__metadata:")}function Jr(s){let e=s.match(/^(.+)@npm:/);if(e)return e[1];let t=s.lastIndexOf("@");return t>0?s.slice(0,t):s}var K,hs,fs,vs,ys,bs=h(()=>{"use strict";K=require("fs"),hs=require("yaml");tt();De();gs();Y();fs=new Map;vs=T({name:"yarn",actions:async s=>{let e=s.rootFiles.includes("package.json"),t=s.rootFiles.includes("yarn.lock");if(!(e&&t))return{};let c=q(s)?.scripts||{};return{...Object.entries(c).map(([a,i])=>[a,`yarn run ${a}`]).reduce((a,[i,o])=>(a[i]=[o],a),{}),install:["yarn install"],outdated:["yarn outdated"]}},dependencies:async s=>{let e=`${s.path}/yarn.lock`,t=`${s.path}/package.json`;if(!(0,K.existsSync)(e)||!(0,K.existsSync)(t))return[];let n=fs.get(s.path);if(n)return n;let r=new Map,c=new Set,l=(f,v,y,j,P,k)=>{let A=r.get(f);A?A.versions.push({resolved:j,specifier:k,source:P}):r.set(f,{id:f,name:v,ecosystem:y,versions:[{resolved:j,specifier:k,source:P}]})};r.set("npm:yarn",{id:"npm:yarn",name:"yarn",ecosystem:"system",versions:[]});let a=(0,K.readFileSync)(e,"utf-8"),i=_r(a),o=new Map,p=new Map,d=null;if(i){let f=(0,hs.parse)(a);for(let[v,y]of Object.entries(f)){if(v==="__metadata"||!y?.version||typeof y.version!="string")continue;let j=Jr(v),P=y;o.has(j)||o.set(j,new Map);let k=v.match(/@npm:(.+)$/);k&&o.get(j)?.set(k[1],y.version),P.dependencies&&p.set(`${j}@${P.version}`,P.dependencies)}}else{d=ms(a);for(let[f,v]of Object.entries(d.dependencies)){o.has(f)||o.set(f,new Map);for(let[y,j]of Object.entries(v.versions)){let P=j["yarn.lock"];P&&o.get(f)?.set(P,y)}}}let m=[t],u=s.findFilesByName("package.json");m.push(...u);for(let f of m)try{let v=(0,K.readFileSync)(f,"utf-8"),y=JSON.parse(v),j=".";f!==t&&(j=f.replace(`${s.path}/`,"").replace("/package.json",""));let P=(k,A)=>{if(k)for(let[_,G]of Object.entries(k)){c.add(_);let me=o.get(_),ge=G;if(me){let fe=me.get(G);if(fe)ge=fe;else{let xe=me.values().next().value;xe&&(ge=xe)}}l(`npm:${_}`,_,"npm",ge,`${j}#${A}`,G)}};P(y.dependencies,"dependencies"),P(y.devDependencies,"devDependencies")}catch{}if(i){for(let[f,v]of p.entries())for(let[y,j]of Object.entries(v))if(!c.has(y)){let P=o.get(y),k=j;if(P){let _=P.get(j);if(_)k=_;else{let G=P.values().next().value;G&&(k=G)}}let A=`yarn.lock:${f}`;l(`npm:${y}`,y,"npm",k,A,j)}}else if(d){for(let[f,v]of Object.entries(d.dependencies))if(!c.has(f))for(let[y,j]of Object.entries(v.versions))for(let[P,k]of Object.entries(j))P.startsWith("yarn.lock:")&&l(`npm:${f}`,f,"npm",y,P,k)}let g=Array.from(r.values()).sort((f,v)=>f.name.localeCompare(v.name));return fs.set(s.path,g),g},outdatedDependencies:async(s,e)=>{if(!(0,K.existsSync)(`${s.path}/yarn.lock`))return[];let t=await vs.dependencies?.(s);return t?Ee(t,e):[]}}),ys=vs});var H,Se=h(()=>{"use strict";Ct();Rt();Wt();Zt();us();bs();H={deno:kt,npm:Ot,pnpm:Vt,ruby:Kt,uv:ds,yarn:ys}});var Ds,js=h(()=>{"use strict";Se();Xe();Ds=async s=>{let e={};s.config.actions&&(e={...Object.entries(s.config.actions).reduce((t,[n,r])=>(t[n]=[r.command],t),{})});for(let[t,n]of Object.entries(H)){let r=await n.actions(s);e=Ae(e,r)}return e}});var R,Gr,qr,Li,Ur,Ps,Ss=h(()=>{"use strict";R=require("zod");Se();Gr=R.z.object({resolved:R.z.string().describe("The resolved version of the dependency"),specifier:R.z.string().describe("The version constraint/specifier used"),source:R.z.string().describe("The source file/path of the dependency"),wanted:R.z.string().describe("The wanted version based on semver rules").optional(),latest:R.z.string().describe("The latest available version of the dependency").optional()}),qr=R.z.object({id:R.z.string().describe("Unique identifier for the ecosystem / dependency"),name:R.z.string().describe("Name of the dependency"),versions:R.z.array(Gr).describe("Map of resolved versions to sources. Each source maps a package path to its version specifier."),ecosystem:R.z.string().describe("Ecosystem of the dependency (e.g., npm, rubygems, pip)")}),Li=qr.extend({wanted:R.z.string().describe("Latest version compatible with the specifier (semver)"),latest:R.z.string().describe("Absolute latest version available"),specifier:R.z.string().describe("The version specifier from package manifest"),isDevDependency:R.z.boolean().describe("Whether this is a dev dependency")}),Ur=s=>{let e=new Map;for(let t of s){let n=e.get(t.id);n?e.set(t.id,{...n,versions:[...n.versions,...t.versions]}):e.set(t.id,t)}return Array.from(e.values())},Ps=async s=>{let t=(await Promise.all(Object.values(H).map(n=>n.dependencies?n.dependencies(s):Promise.resolve([])))).flat();return Ur(t)}});var at,M,we=h(()=>{"use strict";at=W(require("fs"),1);js();be();Ss();Se();M=class{slug;config;_rootFilesCache=null;constructor(e){this.slug=e,this.config=$t(e)}get name(){return this.config.name}get path(){return`${J().codeRootDir}/${this.slug}`}get packageManagers(){let e=this.rootFiles,t=[];return e.includes("pnpm-lock.yaml")?t.push("pnpm"):e.includes("package-lock.json")?t.push("npm"):e.includes("yarn.lock")&&t.push("yarn"),(e.includes("deno.json")||e.includes("deno.jsonc"))&&t.push("deno"),e.includes("pyproject.toml")&&t.push("uv"),t}get primaryPackageManager(){return this.packageManagers[0]||null}async dependencies(){return await Ps(this)}async outdatedDependencies(e){return(await Promise.all(Object.values(H).map(n=>n.outdatedDependencies?n.outdatedDependencies(this,e):Promise.resolve([])))).flat()}get actions(){return Ds(this)}get rootFiles(){return this._rootFilesCache===null&&(this._rootFilesCache=at.default.readdirSync(this.path)),this._rootFilesCache}findFilesByName(e){let t=[],n=r=>{let c=at.default.readdirSync(r,{withFileTypes:!0});for(let l of c)l.isDirectory()?l.name!=="node_modules"&&n(`${r}/${l.name}`):l.name===e&&t.push(`${r}/${l.name}`)};return n(this.path),t}}});var $s,ws=h(()=>{$s={name:"denvig",version:"0.4.2",license:"MIT",description:"A CLI tool to consistently manage cross-discipline projects",bin:{denvig:"./dist/cli.cjs"},type:"module",main:"./dist/sdk.cjs",module:"./dist/sdk.js",types:"./dist/sdk.d.ts",exports:{".":{import:{types:"./dist/sdk.d.ts",default:"./dist/sdk.js"},require:{types:"./dist/sdk.d.ts",default:"./dist/sdk.cjs"}}},files:["dist/","LICENSE","README.md"],scripts:{build:"rm -rf dist && tsup","check-types":"tsc --noEmit",codegen:"bin/codegen",prepublishOnly:"npm run build",lint:"biome check","lint:fix":"biome check --fix",test:"node --test --test-skip-pattern='node_modules' src/**/*.test.ts","test:ci":"node --test --test-skip-pattern='node_modules' src/**/*.test.ts --reporter=default",dev:"tsc --watch"},dependencies:{minimist:"^1.2.8",semver:"^7.7.3",yaml:"^2.8.2",zod:"^4.3.5"},devDependencies:{"@biomejs/biome":"^2.3.11","@types/minimist":"^1.2.5","@types/node":"^24","@types/semver":"^7.7.1",tsup:"^8.5.1",typescript:"^5.9.3"},engines:{node:">=22"},repository:{type:"git",url:"git+https://github.com/marcqualie/denvig.git"},keywords:["cli","node","developer-tools","productivity","typescript"]}});function oe(){return $s.version}var Me=h(()=>{"use strict";ws()});var b,C=h(()=>{"use strict";b=class{name;description;usage;example;args;flags;handler;constructor(e){this.name=e.name,this.description=e.description||"",this.usage=e.usage,this.example=e.example,this.args=e.args,this.flags=e.flags,this.handler=e.handler}async run(e,t,n,r){try{return await this.handler({project:e,args:t,flags:n,extraArgs:r})}catch(c){return console.error(`Error executing command "${this.name}":`,c),{success:!1,message:"fail"}}}}});var Cs={};x(Cs,{runCommand:()=>zr});var ks,zr,xs=h(()=>{"use strict";ks=require("child_process");C();Me();zr=new b({name:"run",description:"Run an action from the project. If no action is specified, lists available actions.",usage:"run [action]",example:"run build",args:[{name:"action",description:"The action to run (e.g. build, test, deploy)",required:!1,type:"string"}],flags:[],handler:async({project:s,args:e,extraArgs:t=[]})=>{let n=await s.actions;if(!e.action){console.log(`Denvig v${oe()}`),console.log(""),console.log("Usage: denvig run [action] [...actionArgs]"),console.log(""),console.log("Available actions:");for(let l in n){if(!n[l])continue;let a=n[l];for(let i of a){let o=i.split(`
|
|
9
|
+
`),p=o[0],d=o.slice(1);console.log(` ${l}: ${p}`);for(let m of d)m.trim()&&console.log(`${" ".repeat(l.length+4)}${m}`)}}return{success:!0,message:"No action specified."}}let r=n[e.action];if(!r)return console.error(`Action "${e.action}" not found in project ${s.name}.`),{success:!1,message:`Action "${e.action}" not found.`};let c={success:!0};for(let l of r){let a=`${l} ${t.join(" ")}`.trim();console.log(`$ ${a}`);let i={...process.env,DENVIG_PROJECT:s.slug},o=process.stdout.isTTY&&process.stdin.isTTY,p,d;o?process.platform==="darwin"?(p="script",d=["-q","/dev/null","sh","-c",a]):(p="script",d=["-q","-c",a,"/dev/null"]):(p="sh",d=["-c",a]);let m=(0,ks.spawn)(p,d,{cwd:s.path,env:i,stdio:"inherit"}),u=await new Promise(g=>{m.on("close",f=>{g({success:f===0})})});u.success||(c=u)}return c}})});var ie,lt=h(()=>{"use strict";ie=s=>s.replace(process.env.HOME||"/root","~")});var Ls={};x(Ls,{configCommand:()=>Br});var Rs,Os,Br,Ns=h(()=>{"use strict";Rs=require("yaml");C();be();lt();Os=s=>{let e=Object.fromEntries(Object.entries({...s,$sources:void 0}).filter(([t,n])=>n!==void 0));(0,Rs.stringify)(e,{indent:2,lineWidth:80}).trim().split(`
|
|
10
|
+
`).map(t=>console.log(` ${ie(t)}`))},Br=new b({name:"config",description:"Display the current global and project configuration.",usage:"config",example:"config",args:[],flags:[],handler:({project:s})=>{let e=J(),t=s.config;return console.log("Denvig Config"),console.log(""),console.log(`Global: ${e.$sources.map(n=>ie(n)).join(", ")||"default"}`),Os(e),console.log(""),console.log(`Project: ${s.config.$sources.map(n=>ie(n)).join(", ")||"default"}`),console.log(` slug: ${s.slug}`),Os(t),{success:!0,message:"Configuration displayed."}}})});var Ts={};x(Ts,{pluginsCommand:()=>Yr});var Yr,Is=h(()=>{"use strict";C();Se();Yr=new b({name:"plugins",description:"Show a list of available plugins and their actions",usage:"plugins",example:"denvig plugins",args:[],flags:[],handler:async({project:s})=>{for(let[e,t]of Object.entries(H)){let n=await t.actions(s),r=Object.keys(n);console.log(`${t.name}: ${r.length} actions`);for(let c of r)console.log(` - ${c}: ${n[c].join(" && ")}`)}return{success:!0}}})});var As={};x(As,{versionCommand:()=>Kr});var Kr,Fs=h(()=>{"use strict";C();Me();Kr=new b({name:"version",description:"Show the current version of Denvig",usage:"version",example:"denvig version",args:[],flags:[],handler:()=>(console.log(`v${oe()}`),{success:!0})})});var Es={};x(Es,{infoCommand:()=>Zr});var Zr,Vs=h(()=>{"use strict";C();Zr=new b({name:"info",description:"Show information about the current project",usage:"info",example:"denvig info",args:[],flags:[],handler:async({project:s})=>{let e=null;try{let r=`${s.path}/package.json`,c=await import("fs");if(c.existsSync(r)){let l=JSON.parse(c.readFileSync(r,"utf-8"));l.repository?.url&&(e=l.repository.url.replace("git+","").replace(".git",""))}}catch{}let t=await s.actions,n={name:s.name,primaryPackageManager:s.primaryPackageManager,allPackageManagers:s.packageManagers,numberOfActions:Object.keys(t).length,githubRepository:e};return console.log(`Project: ${n.name}`),console.log(`Primary Package Manager: ${n.primaryPackageManager||"None detected"}`),console.log(`All Package Managers: ${n.allPackageManagers.join(", ")||"None detected"}`),console.log(`Available Actions: ${n.numberOfActions}`),n.githubRepository&&console.log(`GitHub Repository: ${n.githubRepository}`),{success:!0}}})});var $,ce,Ws,z,ae=h(()=>{"use strict";$={reset:"\x1B[0m",white:"\x1B[37m",grey:"\x1B[90m",green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",bold:"\x1B[1m"},ce=s=>s.replace(/\x1b\[[0-9;]*m/g,""),Ws=s=>{if(s.depth===0)return"";let e="";for(let t=0;t<s.parentPath.length-1;t++)e+=s.parentPath[t]?" ":"\u2502 ";return s.hasChildren?e+=s.isLast?"\u2514\u2500\u252C ":"\u251C\u2500\u252C ":e+=s.isLast?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",e},z=s=>{let{columns:e,data:t,tree:n}=s,r=e.filter(o=>o.visible!==!1);if(t.length===0||r.length===0)return[];let c=r.map((o,p)=>{let d=o.header.length,m=Math.max(...t.map(u=>{let g=o.accessor(u);if(n&&p===0){let f={depth:n.getDepth(u),isLast:n.getIsLast(u),hasChildren:n.getHasChildren(u),parentPath:n.getParentPath(u)};g=Ws(f)+ce(g)}return ce(g).length}));return Math.max(d,m)}),l=[],a=r.map((o,p)=>o.header.padEnd(c[p]));l.push(a.join(" "));let i=c.reduce((o,p)=>o+p,0)+(r.length-1)*2;l.push("-".repeat(i));for(let o of t){let d=(n?n.getDepth(o):0)>0,m=r.map((u,g)=>{let f=u.accessor(o),v=c[g];if(n&&g===0){let P={depth:n.getDepth(o),isLast:n.getIsLast(o),hasChildren:n.getHasChildren(o),parentPath:n.getParentPath(o)},k=Ws(P),A=d?`${$.grey}${ce(f)}${$.reset}`:f;f=k+A}else if(d&&!u.format){let P=ce(f);P.trim()&&(f=`${$.grey}${P}${$.reset}`)}let y=ce(f).length,j=v-y;if(u.format){let k=ce(f).padEnd(v);return u.format(k,o)}return f+" ".repeat(Math.max(0,j))});l.push(m.join(" "))}return l}});var $e,_e,pt=h(()=>{"use strict";$e=W(require("fs"),1);be();_e=s=>{let t=J().codeRootDir,n=[],r=s?.withConfig??!1;if(!$e.default.existsSync(t))return n;let c=$e.default.readdirSync(t,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||l.name.startsWith("."))continue;let a=`${t}/${l.name}`,i=$e.default.readdirSync(a,{withFileTypes:!0});for(let o of i){if(!o.isDirectory()||o.name.startsWith("."))continue;let p=`${a}/${o.name}`;if(r){let d=`${p}/.denvig.yml`;if(!$e.default.existsSync(d))continue}n.push(`${l.name}/${o.name}`)}}return n.sort()}});function Je(){return`gui/${process.getuid?.()??501}`}async function Qr(s){try{let e=Je(),{stdout:t,stderr:n}=await le(`launchctl bootstrap ${e} "${s}"`);return{success:!0,output:t||n}}catch(e){let t=e;return{success:!1,output:t.stderr||t.message||"Unknown error"}}}async function Xr(s){try{let e=Je(),{stdout:t,stderr:n}=await le(`launchctl bootout ${e}/${s}`);return{success:!0,output:t||n}}catch(e){let t=e;return{success:!1,output:t.stderr||t.message||"Unknown error"}}}async function eo(s){try{let{stdout:e,stderr:t}=await le(`launchctl start ${s}`);return{success:!0,output:e||t}}catch(e){let t=e;return{success:!1,output:t.stderr||t.message||"Unknown error"}}}async function to(s){try{let{stdout:e,stderr:t}=await le(`launchctl stop ${s}`);return{success:!0,output:e||t}}catch(e){let t=e;return{success:!1,output:t.stderr||t.message||"Unknown error"}}}async function so(s){try{let e=Je(),{stdout:t}=await le(`launchctl print ${e}/${s}`),n=t.match(/pid\s*=\s*(\d+)/),r=t.match(/state\s*=\s*(\w+)/),c=t.match(/last exit code\s*=\s*(\d+)/);return{label:s,pid:n?parseInt(n[1],10):void 0,state:r?r[1]:"unknown",status:r?r[1]:"unknown",lastExitCode:c?parseInt(c[1],10):void 0}}catch{return null}}async function no(s){try{let{stdout:e}=await le("launchctl list"),n=e.trim().split(`
|
|
11
|
+
`).slice(1).map(r=>{let c=r.trim().split(/\s+/);return c.length<3?null:{pid:c[0]==="-"?"-":parseInt(c[0],10),status:parseInt(c[1],10),label:c[2]}}).filter(r=>r!==null);return s?n.filter(r=>r.label.includes(s)):n}catch{return[]}}var Ms,_s,le,O,ke=h(()=>{"use strict";Ms=require("child_process"),_s=require("util"),le=(0,_s.promisify)(Ms.exec);O={bootstrap:Qr,bootout:Xr,start:eo,stop:to,print:so,list:no,getUserDomain:Je}});function ro(s){let e={},t=s.split(`
|
|
12
|
+
`);for(let n=0;n<t.length;n++){let r=t[n].trim();if(!r||r.startsWith("#"))continue;let c=r.indexOf("=");if(c===-1)continue;let l=r.slice(0,c).trim(),a=r.slice(c+1).trim(),i=a.startsWith('"'),o=a.startsWith("'");if(i||o){let p=i?'"':"'",d=a.indexOf(p,1);if(d!==-1)a=a.slice(1,d);else{let m=a.indexOf("#");m!==-1&&(a=a.slice(0,m).trim())}}else{let p=a.indexOf("#");p!==-1&&(a=a.slice(0,p).trim())}l&&(e[l]=a)}return e}async function Gs(s){try{let e=await(0,Js.readFile)(s,"utf-8");return ro(e)}catch(e){let t=e;throw t.code==="ENOENT"?new Error(`Environment file not found: ${s}`):new Error(`Failed to read environment file: ${t.message||"Unknown error"}`)}}var Js,qs=h(()=>{"use strict";Js=require("fs/promises")});function pe(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function oo(s){return`{ ${s.trim()}; } 2>&1 | while IFS= read -r line; do printf '[%s] %s\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$line"; done`}function Us(s){let{label:e,command:t,workingDirectory:n,environmentVariables:r={},standardOutPath:c,keepAlive:l}=s,a=oo(t),i=Object.entries(r).map(([o,p])=>` <key>${pe(o)}</key>
|
|
13
|
+
<string>${pe(p)}</string>`).join(`
|
|
14
14
|
`);return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
15
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
16
16
|
<plist version="1.0">
|
|
17
17
|
<dict>
|
|
18
18
|
<key>Label</key>
|
|
19
|
-
<string>${
|
|
19
|
+
<string>${pe(e)}</string>
|
|
20
20
|
|
|
21
21
|
<key>ProgramArguments</key>
|
|
22
22
|
<array>
|
|
23
23
|
<string>/bin/zsh</string>
|
|
24
24
|
<string>-l</string>
|
|
25
25
|
<string>-c</string>
|
|
26
|
-
<string>${
|
|
26
|
+
<string>${pe(a)}</string>
|
|
27
27
|
</array>
|
|
28
28
|
|
|
29
29
|
<key>WorkingDirectory</key>
|
|
30
|
-
<string>${
|
|
30
|
+
<string>${pe(n)}</string>
|
|
31
31
|
|
|
32
32
|
<key>EnvironmentVariables</key>
|
|
33
33
|
<dict>
|
|
@@ -35,19 +35,19 @@ ${i}
|
|
|
35
35
|
</dict>
|
|
36
36
|
|
|
37
37
|
<key>StandardOutPath</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${pe(c)}</string>
|
|
39
39
|
|
|
40
40
|
<key>KeepAlive</key>
|
|
41
|
-
<${
|
|
41
|
+
<${l?"true":"false"}/>
|
|
42
42
|
|
|
43
43
|
<key>RunAtLoad</key>
|
|
44
44
|
<false/>
|
|
45
45
|
</dict>
|
|
46
46
|
</plist>
|
|
47
|
-
`}var
|
|
48
|
-
`,"utf-8")}catch{}return{name:e,success:!0,message:"Service started successfully"}}async stopService(e){if(!this.getServiceConfig(e))return{name:e,success:!1,message:`Service "${e}" not found in configuration`};let n=this.getServiceLabel(e);if(!await this.isServiceBootstrapped(e))return{name:e,success:!1,message:`Service "${e}" is not running`};let c=await
|
|
49
|
-
`,"utf-8")}catch{}return{name:e,success:!0,message:"Service stopped successfully"}}async restartService(e){if(!this.getServiceConfig(e))return{name:e,success:!1,message:`Service "${e}" not found in configuration`};if(await this.isServiceBootstrapped(e)){let r=await this.stopService(e);if(!r.success)return r}return await this.startService(e)}async getServiceStatus(e){let t=this.getServiceConfig(e);if(!t)return null;let n=this.getServiceLabel(e),r=await
|
|
50
|
-
`).slice(-t)}catch{return[]}}resolveServiceCwd(e){return(0,U.resolve)(this.project.path,e.cwd||".")}getServiceConfig(e){return this.project.config.services?.[e]}getServiceUrl(e){let t=this.getServiceConfig(e);return t?t.http?.domain?`${t.http.secure?"https":"http"}://${t.http.domain}`:t.http?.port?`http://localhost:${t.http.port}`:null:null}async plistExists(e){try{return await(0,I.access)(this.getPlistPath(e)),!0}catch{return!1}}async getServiceResponse(e,t){let n=this.getServiceConfig(e);if(!n)return null;let r=this.getServiceLabel(e),c="stopped",a=null,l=null;if(t?.launchctlList){let o=t.launchctlList.find(p=>p.label===r);o&&(a=o.pid==="-"?null:o.pid,l=o.status,a!==null?c=l!==0?"error":"running":c=l!==0?"error":"stopped")}else if(await this.plistExists(e)){let p=await E.print(r);p&&(a=p.pid??null,l=p.lastExitCode??null,p.state==="running"&&(l!==null&&l!==0?c="error":c="running"))}let i={name:e,project:this.project.slug,status:c,pid:a,url:this.getServiceUrl(e),command:n.command,cwd:this.resolveServiceCwd(n),logPath:this.getLogPath(e,"stdout"),envFile:n.envFile?(0,U.resolve)(this.project.path,n.envFile):null,lastExitCode:l};return t?.includeLogs&&(i.logs=await this.getRecentLogs(e,t.logLines??20)),i}}});var Gs={};C(Gs,{servicesCommand:()=>Zr});var Kr,Zr,qs=h(()=>{"use strict";x();be();Ae();As();rt();We();Kr=s=>{switch(s){case"running":return"\u{1F7E2}";case"error":return"\u{1F534}";default:return"\u25EF"}},Zr=new b({name:"services",description:"List all services across all projects",usage:"services [--format table|json]",example:"services",args:[],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=e.format,n=s.slug,r=Is();if(r.length===0)return console.log(t==="json"?JSON.stringify([]):"No projects found with .denvig.yml configuration."),{success:!0,message:"No projects found."};let c=await E.list("denvig."),a=[];for(let o of r){let p=new q(o),u=new H(p),m=await u.listServices();for(let d of m){let g=await u.getServiceResponse(d.name,{launchctlList:c});g&&a.push(g)}}if(a.length===0)return console.log(t==="json"?JSON.stringify([]):"No services configured across any project."),{success:!0,message:"No services configured."};let l=a.sort((o,p)=>{let u=o.project===n,m=p.project===n;if(u&&!m)return-1;if(!u&&m)return 1;let d=o.project.localeCompare(p.project);return d!==0?d:o.name.localeCompare(p.name)});if(t==="json")return console.log(JSON.stringify(l)),{success:!0,message:"Services listed successfully."};let i=ce({columns:[{header:"",accessor:o=>Kr(o.status)},{header:"Project",accessor:o=>o.project},{header:"Name",accessor:o=>o.name},{header:"URL",accessor:o=>o.url||"-"}],data:l});for(let o of i)console.log(o);return console.log(""),console.log(`${a.length} service${a.length===1?"":"s"} configured across ${r.length} project${r.length===1?"":"s"}`),{success:!0,message:"Services listed successfully."}}})});var Qr,z,Pe=h(()=>{"use strict";Ae();We();Qr=(s,e)=>{if(!s.includes("/"))return{projectSlug:e,serviceName:s};let t=s.split("/"),n=t.pop();return{projectSlug:t.join("/"),serviceName:n}},z=(s,e)=>{let{projectSlug:t,serviceName:n}=Qr(s,e.slug),r=t===e.slug?e:new q(t),c=new H(r);return{project:r,manager:c,serviceName:n}}});var Hs={};C(Hs,{servicesStartCommand:()=>Xr});var Us,Xr,zs=h(()=>{"use strict";Us=require("zod");x();Pe();Xr=new b({name:"services:start",description:"Start a service",usage:"services start <name> [--format table|json]",example:"services start api",args:[{name:"name",description:"Service name or project/service path (e.g., api or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=Us.z.string().parse(e.name),r=t.format,{manager:c,serviceName:a,project:l}=z(n,s),i=l.slug!==s.slug?`${l.slug}/`:"";r!=="json"&&console.log(`Starting ${i}${a}...`);let o=await c.startService(a);if(!o.success)return r==="json"?console.log(JSON.stringify({success:!1,service:a,project:l.slug,message:o.message})):console.error(`\u2717 Failed to start ${i}${a}: ${o.message}`),{success:!1,message:o.message};await new Promise(u=>setTimeout(u,2e3));let p=await c.getServiceResponse(a,{includeLogs:!0});if(p?.status==="running"){if(r==="json")console.log(JSON.stringify(p));else{let u=p.url?` \u2192 ${p.url}`:"";console.log(`\u2713 ${i}${a} started successfully${u}`)}return{success:!0,message:"Service started successfully."}}if(r==="json")console.log(JSON.stringify(p));else if(console.error(`\u2717 ${i}${a} failed to start`),p?.logs&&p.logs.length>0){console.error(""),console.error("Recent logs:");for(let u of p.logs)console.error(` ${u}`)}return{success:!1,message:"Service failed to start."}}})});var Ys={};C(Ys,{servicesStopCommand:()=>eo});var Bs,eo,Ks=h(()=>{"use strict";Bs=require("zod");x();Pe();eo=new b({name:"services:stop",description:"Stop a service",usage:"services stop <name> [--format table|json]",example:"services stop api",args:[{name:"name",description:"Service name or project/service path (e.g., api or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=Bs.z.string().parse(e.name),r=t.format,{manager:c,serviceName:a,project:l}=z(n,s),i=l.slug!==s.slug?`${l.slug}/`:"";r!=="json"&&console.log(`Stopping ${i}${a}...`);let o=await c.stopService(a);if(!o.success)return r==="json"?console.log(JSON.stringify({success:!1,service:a,project:l.slug,message:o.message})):console.error(`\u2717 Failed to stop ${i}${a}: ${o.message}`),{success:!1,message:o.message};let p=await c.getServiceResponse(a);return console.log(r==="json"?JSON.stringify(p):`\u2713 ${i}${a} stopped successfully`),{success:!0,message:"Service stopped successfully."}}})});var Qs={};C(Qs,{servicesRestartCommand:()=>to});var Zs,to,Xs=h(()=>{"use strict";Zs=require("zod");x();Pe();to=new b({name:"services:restart",description:"Restart a service",usage:"services restart <name> [--format table|json]",example:"services restart api",args:[{name:"name",description:"Service name or project/service path (e.g., api or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=Zs.z.string().parse(e.name),r=t.format,{manager:c,serviceName:a,project:l}=z(n,s),i=l.slug!==s.slug?`${l.slug}/`:"";r!=="json"&&console.log(`Restarting ${i}${a}...`);let o=await c.restartService(a);if(!o.success)return r==="json"?console.log(JSON.stringify({success:!1,service:a,project:l.slug,message:o.message})):console.error(`\u2717 Failed to restart ${i}${a}: ${o.message}`),{success:!1,message:o.message};await new Promise(u=>setTimeout(u,2e3));let p=await c.getServiceResponse(a,{includeLogs:!0});if(p?.status==="running"){if(r==="json")console.log(JSON.stringify(p));else{let u=p.url?` \u2192 ${p.url}`:"";console.log(`\u2713 ${i}${a} restarted successfully${u}`)}return{success:!0,message:"Service restarted successfully."}}if(r==="json")console.log(JSON.stringify(p));else if(console.error(`\u2717 ${i}${a} failed to restart`),p?.logs&&p.logs.length>0){console.error(""),console.error("Recent logs:");for(let u of p.logs)console.error(` ${u}`)}return{success:!1,message:"Service failed to restart."}}})});var sn={};C(sn,{servicesStatusCommand:()=>so});var en,Me,tn,so,nn=h(()=>{"use strict";en=require("fs"),Me=require("os"),tn=require("zod");x();Pe();so=new b({name:"services:status",description:"Show status of a specific service",usage:"services status <name> [--format table|json]",example:"services status api or services status marcqualie/denvig/hello",args:[{name:"name",description:"Service name or project/service path (e.g., hello or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=tn.z.string().parse(e.name),r=t.format,{manager:c,serviceName:a,project:l}=z(n,s),i=await c.getServiceResponse(a,{includeLogs:!0});if(!i){let m=l.slug!==s.slug?` in project "${l.slug}"`:"";return r==="json"?console.log(JSON.stringify({success:!1,service:a,project:l.slug,message:`Service "${a}" not found in configuration${m}`})):console.error(`Service "${a}" not found in configuration${m}`),{success:!1,message:`Service "${a}" not found.`}}if(r==="json")return console.log(JSON.stringify(i)),{success:!0,message:"Status retrieved successfully."};let o=l.slug!==s.slug?`${l.slug}/`:"",p=i.status==="running"?"Running":i.status==="error"?"Error":"Stopped";console.log(`Service: ${o}${i.name}`),console.log(`Status: ${p}`),i.status==="running"&&i.pid&&console.log(`PID: ${i.pid}`),console.log(`Command: ${i.command}`),console.log(`CWD: ${i.cwd.replace((0,Me.homedir)(),"~")}`),console.log(`Logs: ${i.logPath.replace((0,Me.homedir)(),"~")}`);let u=c.getPlistPath(a);if((0,en.existsSync)(u)&&console.log(`Plist: ${u.replace((0,Me.homedir)(),"~")}`),i.lastExitCode!==null&&i.lastExitCode!==0&&i.status!=="running"&&console.log(`Last exit code: ${i.lastExitCode}`),i.logs&&i.logs.length>0){console.log(""),console.log("Recent logs (last 10 lines):");for(let m of i.logs.slice(-10))console.log(` ${m}`)}return{success:!0,message:"Status retrieved successfully."}}})});var cn={};C(cn,{logsCommand:()=>no});var rn,on,no,an=h(()=>{"use strict";rn=require("child_process"),on=require("fs/promises");x();We();no=new b({name:"services:logs",description:"Show logs for a service",usage:"services logs <name> [-n <lines>] [--follow]",example:"services logs api -n 50 --follow",args:[{name:"name",description:"Name of the service",required:!0,type:"string"}],flags:[{name:"lines",description:"Number of lines to show (use -n)",required:!1,type:"number",defaultValue:10},{name:"follow",description:"Follow the log output",required:!1,type:"boolean",defaultValue:!1}],handler:async({project:s,args:e,flags:t})=>{let n=new H(s),r=e.name,c=t.lines??t.n??10,a=!!t.follow,l=n.getLogPath(r,"stdout");if(a){let i=["-n",`${c}`,"-f",l];return(0,rn.spawn)("tail",i,{stdio:"inherit"}),new Promise(()=>{})}try{let p=(await(0,on.readFile)(l,"utf-8")).trim().split(`
|
|
51
|
-
`).filter(Boolean).slice(-c);for(let
|
|
52
|
-
${a.hash}`),{success:!0,message:"Hash generated successfully"}}}),oo=new b({name:"internals:resource-id",description:"Generate ID for a denvig resource",usage:"internals:resource-id <resource>",example:"denvig internals:id service/hello",args:[{name:"resource",description:"Resource identifier (e.g., service/api, action/build, apps/web|action/dev)",required:!0,type:"string"}],flags:[{name:"workspace",description:'Workspace path (defaults to "root")',required:!1,type:"string"}],handler:async({project:s,args:e,flags:t})=>{let n=e.resource,r=t.workspace,c=n;if(n.includes("|")){let l=n.split("|");r=l[0],c=l[1]}if(!c.startsWith("action/")&&!c.startsWith("service/"))return console.error('Error: Resource must start with "action/" or "service/" (e.g., service/api, action/build)'),{success:!1,message:"Invalid resource format"};let a=it({project:s,workspace:r,resource:c});return console.log(a),{success:!0,message:"ID generated successfully"}}})});var gn,ct,at,io,lt,fn,hn,pt=h(()=>{"use strict";gn=["pnpm-lock.yaml:","yarn.lock:","Gemfile.lock:","uv.lock:"],ct=s=>{for(let e of gn)if(s.startsWith(e)){let n=s.slice(e.length).match(/^([^@]+)@([^(@]+)/);if(n)return{name:n[1],version:n[2]}}return null},at=s=>gn.some(e=>s.startsWith(e)),io=s=>s.endsWith("#dependencies"),lt=s=>s.endsWith("#devDependencies"),fn=(s,e,t)=>{let n=new Map;for(let i of s)n.set(i.name,i);let r=[],c=new Set;for(let i of s)if(!(t&&i.ecosystem!==t)){for(let o of i.versions)if(!at(o.source)){let p=lt(o.source);if(io(o.source)||p){let m=`${i.name}@${o.resolved}`;c.has(m)||(c.add(m),r.push({dep:i,version:o.resolved,isDevDependency:p,children:[]}))}}}if(e>0){let i=new Map;for(let p of s)if(!(t&&p.ecosystem!==t))for(let u of p.versions){let m=ct(u.source);if(m){let d=`${m.name}@${m.version}`,g=i.get(d)||[];g.some(f=>f.name===p.name)||(g.push(p),i.set(d,g))}}let o=(p,u,m)=>{if(u>=e)return;let d=`${p.dep.name}@${p.version}`;if(m.has(d))return;m.add(d);let g=i.get(d)||[];for(let f of g){let y=f.versions.find(v=>{let D=ct(v.source);return D?.name===p.dep.name&&D?.version===p.version});if(y){let v={dep:f,version:y.resolved,isDevDependency:!1,children:[]};p.children.push(v),o(v,u+1,new Set(m))}}p.children.sort((f,y)=>f.dep.name.localeCompare(y.dep.name))};for(let p of r)o(p,0,new Set)}r.sort((i,o)=>{let p=i.dep.ecosystem.localeCompare(o.dep.ecosystem);return p!==0?p:i.dep.name.localeCompare(o.dep.name)});let a=[],l=(i,o,p,u)=>{a.push({name:i.dep.name,version:i.version,ecosystem:i.dep.ecosystem,isDevDependency:i.isDevDependency,depth:o,isLast:p,hasChildren:i.children.length>0,parentPath:[...u]});let m=[...u,p];i.children.forEach((d,g)=>{l(d,o+1,g===i.children.length-1,m)})};return r.forEach((i,o)=>{l(i,0,o===r.length-1,[])}),a},hn=(s,e,t,n)=>{if(!at(t))return{name:s,version:e,children:[]};let r=[{name:s,version:e}],c=t,a=50,l=0;for(;l<a;){let p=ct(c);if(!p)break;r.unshift({name:p.name,version:p.version});let u=n.get(p.name);if(!u)break;let m=u.versions.find(d=>d.resolved===p.version);if(!m||!at(m.source))break;c=m.source,l++}if(r.length===0)return null;let i={name:r[0].name,version:r[0].version,children:[]},o=i;for(let p=1;p<r.length;p++){let u={name:r[p].name,version:r[p].version,children:[]};o.children.push(u),o=u}return i}});var yn={};C(yn,{depsListCommand:()=>co});var co,vn=h(()=>{"use strict";x();pt();be();co=new b({name:"deps:list",description:"List all dependencies detected by plugins",usage:"deps:list [--depth <n>] [--ecosystem <name>] [--format table|json]",example:"denvig deps:list --depth 1",args:[],flags:[{name:"depth",description:"Show subdependencies up to N levels deep (default: 0)",required:!1,type:"number",defaultValue:0},{name:"ecosystem",description:"Filter to a specific ecosystem (e.g., npm, rubygems, pypi)",required:!1,type:"string",defaultValue:void 0},{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=e.ecosystem,n=e.depth??0,r=e.format,c=await s.dependencies();if(c.length===0)return console.log(r==="json"?JSON.stringify([]):"No dependencies detected in this project."),{success:!0,message:"No dependencies detected."};let a=fn(c,n,t);if(a.length===0){if(r==="json")console.log(JSON.stringify([]));else{let g=t?`No dependencies found for ecosystem "${t}".`:"No direct dependencies detected in this project.";console.log(g)}return{success:!0,message:t?`No dependencies found for ecosystem "${t}".`:"No direct dependencies detected in this project."}}if(r==="json")return console.log(JSON.stringify(c)),{success:!0,message:"Dependencies listed successfully."};let i=new Set(a.map(g=>g.ecosystem)).size>1&&!t,o=ce({columns:[{header:"Package",accessor:g=>g.name},{header:"",accessor:g=>g.depth===0&&g.isDevDependency?`${w.grey}(dev)${w.reset}`:" "},{header:"Current",accessor:g=>g.version},{header:"Ecosystem",accessor:g=>g.ecosystem,visible:i}],data:a,tree:{getDepth:g=>g.depth,getIsLast:g=>g.isLast,getHasChildren:g=>g.hasChildren,getParentPath:g=>g.parentPath}});for(let g of o)console.log(g);let p=a.filter(g=>g.depth===0),u=p.filter(g=>!g.isDevDependency).length,m=p.filter(g=>g.isDevDependency).length,d=c.length-p.length;return console.log(""),console.log(`${c.length} total (${u} dependencies, ${m} devDependencies, ${d} subdependencies)`),{success:!0,message:"Dependencies listed successfully."}}})});var bn,dt,Dn,Pn=h(()=>{"use strict";bn=F(require("semver"),1),dt=(s,e)=>{if(s===e)return null;try{let t=bn.default.diff(s,e);return t?t==="major"||t==="premajor"?"major":t==="minor"||t==="preminor"?"minor":t==="patch"||t==="prepatch"||t==="prerelease"?"patch":null:null}catch{return null}},Dn=(s,e)=>s===null?!1:e==="patch"?s==="patch":e==="minor"?s==="patch"||s==="minor":!1});var jn={};C(jn,{depsOutdatedCommand:()=>ao});var Sn,ao,$n=h(()=>{"use strict";x();be();Pn();Sn=(s,e)=>{if(s===e)return w.white;let t=dt(s,e);return t?t==="major"?w.red:t==="minor"?w.yellow:t==="patch"?w.green:w.white:w.white},ao=new b({name:"deps:outdated",description:"Show outdated dependencies",usage:"deps:outdated [--no-cache] [--semver patch|minor] [--ecosystem <name>] [--format table|json]",example:"denvig deps:outdated --semver patch",args:[],flags:[{name:"no-cache",description:"Skip cache and fetch fresh data from registry",required:!1,type:"boolean",defaultValue:!1},{name:"semver",description:'Filter by semver level: "patch" for patch updates only, "minor" for minor and patch updates',required:!1,type:"string",defaultValue:void 0},{name:"ecosystem",description:"Filter to a specific ecosystem (e.g., npm, rubygems, pypi)",required:!1,type:"string",defaultValue:void 0},{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=!e["no-cache"],n=e.semver,r=e.ecosystem,c=e.format;if(n&&n!=="patch"&&n!=="minor")return console.error(`Invalid --semver value: "${n}". Must be "patch" or "minor".`),{success:!1,message:"Invalid --semver value."};let l=await s.outdatedDependencies({cache:t}),i=d=>d.versions[0]?.resolved||"";if(r&&(l=l.filter(d=>d.ecosystem===r)),n&&(l=l.filter(d=>{let g=dt(i(d),d.latest);return Dn(g,n)})),l.length===0){if(c==="json")console.log(JSON.stringify([]));else{let g="All dependencies are up to date!";r&&n?g=`No ${n}-level updates available for ecosystem "${r}".`:r?g=`No outdated dependencies found for ecosystem "${r}".`:n&&(g=`No ${n}-level updates available.`),console.log(g)}let d="All dependencies are up to date!";return r&&n?d=`No ${n}-level updates available for ecosystem "${r}".`:r?d=`No outdated dependencies found for ecosystem "${r}".`:n&&(d=`No ${n}-level updates available.`),{success:!0,message:d}}let o=l.sort((d,g)=>{let f=d.ecosystem.localeCompare(g.ecosystem);return f!==0?f:d.name.localeCompare(g.name)});if(c==="json")return console.log(JSON.stringify(o)),{success:!0,message:"Outdated dependencies listed."};let u=new Set(l.map(d=>d.ecosystem)).size>1&&!r,m=ce({columns:[{header:"Package",accessor:d=>d.name},{header:"",accessor:d=>d.isDevDependency?`${w.grey}(dev)${w.reset}`:" "},{header:"Current",accessor:d=>i(d)},{header:"Wanted",accessor:d=>d.wanted,format:(d,g)=>`${Sn(i(g),g.wanted)}${d}${w.reset}`},{header:"Latest",accessor:d=>d.latest,format:(d,g)=>`${Sn(i(g),g.latest)}${d}${w.reset}`},{header:"Ecosystem",accessor:d=>d.ecosystem,visible:u}],data:o});for(let d of m)console.log(d);return{success:!0,message:"Outdated dependencies listed."}}})});var _e,Je,wn=h(()=>{"use strict";be();_e=(s,e="",t=!0,n=!0)=>{let r=[],c=s.children.length>0;if(n)r.push(`${s.name} ${w.grey}${s.version}${w.reset}`);else{let l=c?t?"\u2514\u2500\u252C ":"\u251C\u2500\u252C ":t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ";r.push(`${e}${l}${s.name} ${w.grey}${s.version}${w.reset}`)}let a=n?"":e+(t?" ":"\u2502 ");for(let l=0;l<s.children.length;l++){let i=s.children[l],o=l===s.children.length-1;r.push(..._e(i,a,o,!1))}return r},Je=(s,e)=>{let t=s.find(n=>n.name===e.name&&n.version===e.version);if(t)for(let n of e.children)Je(t.children,n);else s.push(e)}});var kn={};C(kn,{depsWhyCommand:()=>lo});var lo,xn=h(()=>{"use strict";x();pt();wn();lo=new b({name:"deps:why",description:"Show why a dependency is installed",usage:"deps:why <dependency>",example:"denvig deps:why yaml",args:[{name:"dependency",description:"The dependency name to look up",required:!0,type:"string"}],flags:[],handler:async({project:s,args:e})=>{let t=e.dependency,n=await s.dependencies(),r=n.find(i=>i.name===t);if(!r)return console.log(`Dependency "${t}" not found in this project.`),{success:!1,message:"Dependency not found."};let c=new Map;for(let i of n)c.set(i.name,i);console.log(`${s.name} ${s.path}`),console.log("");let a=[],l=[];for(let i of r.versions){let o=hn(r.name,i.resolved,i.source,c);o&&(c.get(o.name)?.versions.some(m=>lt(m.source))?Je(l,o):Je(a,o))}if(a.length>0){console.log("dependencies:");for(let i=0;i<a.length;i++){let o=_e(a[i],"",i===a.length-1,!0);for(let p of o)console.log(p)}console.log("")}if(l.length>0){console.log("devDependencies:");for(let i=0;i<l.length;i++){let o=_e(l[i],"",i===l.length-1,!0);for(let p of o)console.log(p)}console.log("")}return a.length===0&&l.length===0&&console.log(`Could not determine dependency chain for "${t}".`),{success:!0,message:"Dependency chain shown."}}})});var Rn={};C(Rn,{configVerifyCommand:()=>po});var Cn,On,po,Nn=h(()=>{"use strict";Cn=require("path"),On=require("yaml");x();He();Ue();po=new b({name:"config:verify",description:"Verify a .denvig.yml file against the config schema.",usage:"config verify [path]",example:"config verify .denvig.yml",args:[{name:"path",description:"Path to the config file (defaults to .denvig.yml)",required:!1,type:"string",defaultValue:".denvig.yml"}],flags:[],handler:({project:s,args:e})=>{let t=(0,Cn.resolve)(s.path,e.path?.toString()||".denvig.yml"),n=me(t);if(!n)return console.error(`Config file not found: ${t}`),{success:!1,message:"Config file not found."};let r;try{r=(0,On.parse)(n)}catch(a){return console.error(`Failed to parse YAML at ${t}:`),a instanceof Error&&console.error(` ${a.message}`),{success:!1,message:"Invalid YAML syntax."}}let c=Ce.safeParse(r);if(!c.success){console.error(`Config validation failed for ${t}:`);for(let a of c.error.issues){let l=a.path.length>0?a.path.join("."):"(root)";console.error(` - ${l}: ${a.message}`)}return{success:!1,message:"Config validation failed."}}return console.log(`Config is valid: ${t}`),{success:!0,message:"Config is valid."}}})});var ut=F(require("minimist"),1);ge();Ae();Fe();var Ln=[{name:"project",description:"The project slug to run against. Defaults to current directory.",required:!1,type:"string",defaultValue:void 0}];async function uo(){let s=process.argv[2],e=process.argv.slice(2),t=W(),n=process.cwd(),r=(0,ut.default)(process.argv.slice(2)).project?.toString()||n.replace(`${t.codeRootDir}/`,"").split("/").slice(0,2).join("/"),c=new q(r),a={outdated:"deps:outdated"};a[s]&&(s=a[s]);let l=["start","stop","restart","status","logs"];if(s==="services"){let P=process.argv[3];P&&l.includes(P)&&(s=`services:${P}`,e=[process.argv[2],...process.argv.slice(4)])}let i=["list","outdated","why"];if(s==="deps"){let P=process.argv[3];P&&i.includes(P)&&(s=`deps:${P}`,e=[process.argv[2],...process.argv.slice(4)])}let o=["verify"];if(s==="config"){let P=process.argv[3];P&&o.includes(P)&&(s=`config:${P}`,e=[process.argv[2],...process.argv.slice(4)])}let p=[...t.quickActions||[],...c?.config?.quickActions||[]].sort();p.includes(s)&&(e=["run",...process.argv.slice(2)],s="run",console.log("> Proxying to denvig run",...process.argv.slice(2)));let{runCommand:u}=await Promise.resolve().then(()=>(Ps(),Ds)),{configCommand:m}=await Promise.resolve().then(()=>(ks(),ws)),{pluginsCommand:d}=await Promise.resolve().then(()=>(Cs(),xs)),{versionCommand:g}=await Promise.resolve().then(()=>(Rs(),Os)),{infoCommand:f}=await Promise.resolve().then(()=>(Ls(),Ns)),{servicesCommand:y}=await Promise.resolve().then(()=>(qs(),Gs)),{servicesStartCommand:v}=await Promise.resolve().then(()=>(zs(),Hs)),{servicesStopCommand:D}=await Promise.resolve().then(()=>(Ks(),Ys)),{servicesRestartCommand:S}=await Promise.resolve().then(()=>(Xs(),Qs)),{servicesStatusCommand:k}=await Promise.resolve().then(()=>(nn(),sn)),{logsCommand:A}=await Promise.resolve().then(()=>(an(),cn)),{internalsResourceHashCommand:V,internalsResourceIdCommand:M}=await Promise.resolve().then(()=>(mn(),un)),{depsListCommand:K}=await Promise.resolve().then(()=>(vn(),yn)),{depsOutdatedCommand:pe}=await Promise.resolve().then(()=>($n(),jn)),{depsWhyCommand:Se}=await Promise.resolve().then(()=>(xn(),kn)),{configVerifyCommand:je}=await Promise.resolve().then(()=>(Nn(),Rn)),de={run:u,config:m,"config:verify":je,plugins:d,version:g,info:f,services:y,"services:start":v,"services:stop":D,"services:restart":S,"services:status":k,"services:logs":A,deps:K,"deps:list":K,"deps:outdated":pe,"deps:why":Se,"internals:resource-hash":V,"internals:resource-id":M},$e=de[s],ue=(0,ut.default)(e),Tn=$e?.args.reduce((P,j,ke)=>{let xe=ue._[ke+1];return xe!==void 0?P[j.name]=xe:j.required&&(console.error(`Missing required argument: ${j.name}`),process.exit(1)),P},{})||{},In=ue._.slice($e?.args.length+1).map(P=>String(P))||[],mt=[...Ln,...$e?.flags||[]],An=new Set(mt.map(P=>P.name)),Fn=mt.reduce((P,j)=>(ue[j.name]!==void 0?P[j.name]=ue[j.name]:j.defaultValue!==void 0?P[j.name]=j.defaultValue:j.required&&(console.error(`Missing required flag: ${j.name}`),process.exit(1)),P),{}),we=[];for(let[P,j]of Object.entries(ue))P!=="_"&&!An.has(P)&&(j===!0?we.push(`--${P}`):j===!1?we.push(`--no-${P}`):we.push(`--${P}`,String(j)));let En=[...In,...we];if(!s){console.log(`Denvig v${oe()}`),console.log(""),console.log("Usage: denvig <command> [args] [flags]"),console.log(""),console.log("Available commands:"),Object.keys(de).forEach(j=>{j.startsWith("internals:")||console.log(` - ${de[j].usage.padEnd(20," ")} ${de[j].description}`)}),console.log(""),console.log("Quick Actions:");for(let j of p){let ke=(await c?.actions)?.[j];if(!ke){console.log(` - ${j.padEnd(20," ")} not defined`);return}for(let xe of ke){let gt=xe.split(`
|
|
53
|
-
`),
|
|
47
|
+
`}var Hs=h(()=>{"use strict"});var L,Ge,N,I,de=h(()=>{"use strict";L=require("fs/promises"),Ge=require("os"),N=require("path");qs();ke();Hs();I=class{project;constructor(e){this.project=e}async listServices(){let e=this.project.config.services||{};return Object.entries(e).map(([t,n])=>({name:t,cwd:n.cwd||".",command:n.command,http:n.http}))}async startService(e){let t=this.getServiceConfig(e);if(!t)return{name:e,success:!1,message:`Service "${e}" not found in configuration`};let n=this.getServiceLabel(e),r=await this.isServiceBootstrapped(e);await this.ensureDenvigDirectories();let c=this.getPlistPath(e),l=this.resolveServiceCwd(t),a={DENVIG_PROJECT:this.project.slug,DENVIG_SERVICE:e};if(t.envFile)try{let o=(0,N.resolve)(this.project.path,t.envFile),p=await Gs(o);Object.assign(a,p)}catch(o){let p=o instanceof Error?o.message:"Unknown error";return{name:e,success:!1,message:`Failed to load environment file: ${p}`}}t.env&&Object.assign(a,t.env),t.http?.port!==void 0&&(a.PORT=t.http.port.toString());let i=Us({label:n,command:t.command,workingDirectory:l,environmentVariables:a,standardOutPath:this.getLogPath(e,"stdout"),keepAlive:t.keepAlive??!0});if(await(0,L.writeFile)(c,i,"utf-8"),r){let o=await O.bootout(n);if(!o.success)return{name:e,success:!1,message:`Failed to bootout service: ${o.output}`};await new Promise(d=>setTimeout(d,1e3));let p=await O.bootstrap(c);if(!p.success)return{name:e,success:!1,message:`Failed to bootstrap service: ${p.output}`}}else{let o=await O.bootstrap(c);if(!o.success)return{name:e,success:!1,message:`Failed to bootstrap service: ${o.output}`}}try{let o=new Date().toISOString();await(0,L.appendFile)(this.getLogPath(e,"stdout"),`[${o}] Service Started
|
|
48
|
+
`,"utf-8")}catch{}return{name:e,success:!0,message:"Service started successfully"}}async stopService(e){if(!this.getServiceConfig(e))return{name:e,success:!1,message:`Service "${e}" not found in configuration`};let n=this.getServiceLabel(e);if(!await this.isServiceBootstrapped(e))return{name:e,success:!1,message:`Service "${e}" is not running`};let c=await O.bootout(n);if(!c.success)return{name:e,success:!1,message:`Failed to stop service: ${c.output}`};try{let l=new Date().toISOString();await(0,L.appendFile)(this.getLogPath(e,"stdout"),`[${l}] Service Stopped
|
|
49
|
+
`,"utf-8")}catch{}return{name:e,success:!0,message:"Service stopped successfully"}}async restartService(e){if(!this.getServiceConfig(e))return{name:e,success:!1,message:`Service "${e}" not found in configuration`};if(await this.isServiceBootstrapped(e)){let r=await this.stopService(e);if(!r.success)return r}return await this.startService(e)}async getServiceStatus(e){let t=this.getServiceConfig(e);if(!t)return null;let n=this.getServiceLabel(e),r=await O.print(n);if(!r)return{name:e,running:!1,command:t.command,cwd:this.resolveServiceCwd(t),logPath:this.getLogPath(e,"stdout")};let c=await this.getRecentLogs(e,20);return{name:e,running:r.state==="running",pid:r.pid,command:t.command,cwd:this.resolveServiceCwd(t),logs:c,logPath:this.getLogPath(e,"stdout"),lastExitCode:r.lastExitCode}}async startAll(){let e=this.project.config.services||{},t=Object.keys(e);return await Promise.all(t.map(n=>this.startService(n)))}async stopAll(){let e=this.project.config.services||{},t=Object.keys(e),r=(await Promise.all(t.map(async c=>({name:c,isBootstrapped:await this.isServiceBootstrapped(c)})))).filter(c=>c.isBootstrapped).map(c=>c.name);return await Promise.all(r.map(c=>this.stopService(c)))}async restartAll(){let e=this.project.config.services||{},t=Object.keys(e),r=(await Promise.all(t.map(async c=>({name:c,isBootstrapped:await this.isServiceBootstrapped(c)})))).filter(c=>c.isBootstrapped).map(c=>c.name);return await Promise.all(r.map(c=>this.restartService(c)))}async teardownAll(e){let t=[],r=`denvig.${this.normalizeForLabel(this.project.slug)}__`,c=[],l=await O.list(r);for(let i of l){let o=await O.bootout(i.label),p=i.label.replace(r,"");o.success?(c.push(i.label),t.push({name:p,success:!0,message:"Service removed from launchctl"})):t.push({name:p,success:!1,message:`Failed to bootout: ${o.output}`})}let a=(0,N.resolve)((0,Ge.homedir)(),"Library","LaunchAgents");if(await Promise.all(c.map(async i=>{try{await(0,L.unlink)((0,N.resolve)(a,`${i}.plist`))}catch{}})),e?.removeLogs&&c.length>0){let i=(0,N.resolve)(this.getDenvigHomeDir(),"logs"),o=c.map(p=>p.replace("denvig.",""));await Promise.all(o.flatMap(p=>[(0,L.unlink)((0,N.resolve)(i,`${p}.log`)).catch(()=>{}),(0,L.unlink)((0,N.resolve)(i,`${p}.error.log`)).catch(()=>{})]))}return t}async isServiceBootstrapped(e){let t=this.getServiceLabel(e);return await O.print(t)!==null}normalizeForLabel(e){return e.replace(/\//g,"__").replace(/:/g,"-").replace(/[^a-zA-Z0-9_.-]/g,"_")}getServiceLabel(e){let t=this.normalizeForLabel(this.project.slug),n=this.normalizeForLabel(e);return`denvig.${t}__${n}`}getDenvigHomeDir(){return(0,N.resolve)((0,Ge.homedir)(),".denvig")}getPlistPath(e){let t=this.getServiceLabel(e);return(0,N.resolve)((0,Ge.homedir)(),"Library","LaunchAgents",`${t}.plist`)}getLogPath(e,t){let n=this.normalizeForLabel(this.project.slug),r=this.normalizeForLabel(e),c=t==="stderr"?".error":"";return(0,N.resolve)(this.getDenvigHomeDir(),"logs",`${n}__${r}${c}.log`)}async ensureDenvigDirectories(){let e=this.getDenvigHomeDir();await(0,L.mkdir)((0,N.resolve)(e,"logs"),{recursive:!0})}async getRecentLogs(e,t){try{let n=this.getLogPath(e,"stdout");return(await(0,L.readFile)(n,"utf-8")).trim().split(`
|
|
50
|
+
`).slice(-t)}catch{return[]}}resolveServiceCwd(e){return(0,N.resolve)(this.project.path,e.cwd||".")}getServiceConfig(e){return this.project.config.services?.[e]}getServiceUrl(e){let t=this.getServiceConfig(e);return t?t.http?.domain?`${t.http.secure?"https":"http"}://${t.http.domain}`:t.http?.port?`http://localhost:${t.http.port}`:null:null}async plistExists(e){try{return await(0,L.access)(this.getPlistPath(e)),!0}catch{return!1}}async getServiceResponse(e,t){let n=this.getServiceConfig(e);if(!n)return null;let r=this.getServiceLabel(e),c="stopped",l=null,a=null;if(t?.launchctlList){let o=t.launchctlList.find(p=>p.label===r);o&&(l=o.pid==="-"?null:o.pid,a=o.status,l!==null?c=a!==0?"error":"running":c=a!==0?"error":"stopped")}else if(await this.plistExists(e)){let p=await O.print(r);p&&(l=p.pid??null,a=p.lastExitCode??null,p.state==="running"&&(a!==null&&a!==0?c="error":c="running"))}let i={name:e,project:this.project.slug,status:c,pid:l,url:this.getServiceUrl(e),command:n.command,cwd:this.resolveServiceCwd(n),logPath:this.getLogPath(e,"stdout"),envFile:n.envFile?(0,N.resolve)(this.project.path,n.envFile):null,lastExitCode:a};return t?.includeLogs&&(i.logs=await this.getRecentLogs(e,t.logLines??20)),i}}});var zs={};x(zs,{servicesCommand:()=>co});var io,co,Bs=h(()=>{"use strict";C();ae();we();pt();ke();de();io=s=>{switch(s){case"running":return"\u{1F7E2}";case"error":return"\u{1F534}";default:return"\u25EF"}},co=new b({name:"services",description:"List all services across all projects",usage:"services [--format table|json]",example:"services",args:[],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=e.format,n=s.slug,r=_e();if(r.length===0)return console.log(t==="json"?JSON.stringify([]):"No projects found with .denvig.yml configuration."),{success:!0,message:"No projects found."};let c=await O.list("denvig."),l=[];for(let o of r){let p=new M(o),d=new I(p),m=await d.listServices();for(let u of m){let g=await d.getServiceResponse(u.name,{launchctlList:c});g&&l.push(g)}}if(l.length===0)return console.log(t==="json"?JSON.stringify([]):"No services configured across any project."),{success:!0,message:"No services configured."};let a=l.sort((o,p)=>{let d=o.project===n,m=p.project===n;if(d&&!m)return-1;if(!d&&m)return 1;let u=o.project.localeCompare(p.project);return u!==0?u:o.name.localeCompare(p.name)});if(t==="json")return console.log(JSON.stringify(a)),{success:!0,message:"Services listed successfully."};let i=z({columns:[{header:"",accessor:o=>io(o.status)},{header:"Project",accessor:o=>o.project},{header:"Name",accessor:o=>o.name},{header:"URL",accessor:o=>o.url||"-"}],data:a});for(let o of i)console.log(o);return console.log(""),console.log(`${l.length} service${l.length===1?"":"s"} configured across ${r.length} project${r.length===1?"":"s"}`),{success:!0,message:"Services listed successfully."}}})});var ao,B,Ce=h(()=>{"use strict";we();de();ao=(s,e)=>{if(!s.includes("/"))return{projectSlug:e,serviceName:s};let t=s.split("/"),n=t.pop();return{projectSlug:t.join("/"),serviceName:n}},B=(s,e)=>{let{projectSlug:t,serviceName:n}=ao(s,e.slug),r=t===e.slug?e:new M(t),c=new I(r);return{project:r,manager:c,serviceName:n}}});var Ks={};x(Ks,{servicesStartCommand:()=>lo});var Ys,lo,Zs=h(()=>{"use strict";Ys=require("zod");C();Ce();lo=new b({name:"services:start",description:"Start a service",usage:"services start <name> [--format table|json]",example:"services start api",args:[{name:"name",description:"Service name or project/service path (e.g., api or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=Ys.z.string().parse(e.name),r=t.format,{manager:c,serviceName:l,project:a}=B(n,s),i=a.slug!==s.slug?`${a.slug}/`:"";r!=="json"&&console.log(`Starting ${i}${l}...`);let o=await c.startService(l);if(!o.success)return r==="json"?console.log(JSON.stringify({success:!1,service:l,project:a.slug,message:o.message})):console.error(`\u2717 Failed to start ${i}${l}: ${o.message}`),{success:!1,message:o.message};await new Promise(d=>setTimeout(d,2e3));let p=await c.getServiceResponse(l,{includeLogs:!0});if(p?.status==="running"){if(r==="json")console.log(JSON.stringify(p));else{let d=p.url?` \u2192 ${p.url}`:"";console.log(`\u2713 ${i}${l} started successfully${d}`)}return{success:!0,message:"Service started successfully."}}if(r==="json")console.log(JSON.stringify(p));else if(console.error(`\u2717 ${i}${l} failed to start`),p?.logs&&p.logs.length>0){console.error(""),console.error("Recent logs:");for(let d of p.logs)console.error(` ${d}`)}return{success:!1,message:"Service failed to start."}}})});var Xs={};x(Xs,{servicesStopCommand:()=>po});var Qs,po,en=h(()=>{"use strict";Qs=require("zod");C();Ce();po=new b({name:"services:stop",description:"Stop a service",usage:"services stop <name> [--format table|json]",example:"services stop api",args:[{name:"name",description:"Service name or project/service path (e.g., api or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=Qs.z.string().parse(e.name),r=t.format,{manager:c,serviceName:l,project:a}=B(n,s),i=a.slug!==s.slug?`${a.slug}/`:"";r!=="json"&&console.log(`Stopping ${i}${l}...`);let o=await c.stopService(l);if(!o.success)return r==="json"?console.log(JSON.stringify({success:!1,service:l,project:a.slug,message:o.message})):console.error(`\u2717 Failed to stop ${i}${l}: ${o.message}`),{success:!1,message:o.message};let p=await c.getServiceResponse(l);return console.log(r==="json"?JSON.stringify(p):`\u2713 ${i}${l} stopped successfully`),{success:!0,message:"Service stopped successfully."}}})});var sn={};x(sn,{servicesRestartCommand:()=>uo});var tn,uo,nn=h(()=>{"use strict";tn=require("zod");C();Ce();uo=new b({name:"services:restart",description:"Restart a service",usage:"services restart <name> [--format table|json]",example:"services restart api",args:[{name:"name",description:"Service name or project/service path (e.g., api or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=tn.z.string().parse(e.name),r=t.format,{manager:c,serviceName:l,project:a}=B(n,s),i=a.slug!==s.slug?`${a.slug}/`:"";r!=="json"&&console.log(`Restarting ${i}${l}...`);let o=await c.restartService(l);if(!o.success)return r==="json"?console.log(JSON.stringify({success:!1,service:l,project:a.slug,message:o.message})):console.error(`\u2717 Failed to restart ${i}${l}: ${o.message}`),{success:!1,message:o.message};await new Promise(d=>setTimeout(d,2e3));let p=await c.getServiceResponse(l,{includeLogs:!0});if(p?.status==="running"){if(r==="json")console.log(JSON.stringify(p));else{let d=p.url?` \u2192 ${p.url}`:"";console.log(`\u2713 ${i}${l} restarted successfully${d}`)}return{success:!0,message:"Service restarted successfully."}}if(r==="json")console.log(JSON.stringify(p));else if(console.error(`\u2717 ${i}${l} failed to restart`),p?.logs&&p.logs.length>0){console.error(""),console.error("Recent logs:");for(let d of p.logs)console.error(` ${d}`)}return{success:!1,message:"Service failed to restart."}}})});var cn={};x(cn,{servicesStatusCommand:()=>mo});var rn,qe,on,mo,an=h(()=>{"use strict";rn=require("fs"),qe=require("os"),on=require("zod");C();Ce();mo=new b({name:"services:status",description:"Show status of a specific service",usage:"services status <name> [--format table|json]",example:"services status api or services status marcqualie/denvig/hello",args:[{name:"name",description:"Service name or project/service path (e.g., hello or marcqualie/denvig/hello)",required:!0,type:"string"}],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,args:e,flags:t})=>{let n=on.z.string().parse(e.name),r=t.format,{manager:c,serviceName:l,project:a}=B(n,s),i=await c.getServiceResponse(l,{includeLogs:!0});if(!i){let m=a.slug!==s.slug?` in project "${a.slug}"`:"";return r==="json"?console.log(JSON.stringify({success:!1,service:l,project:a.slug,message:`Service "${l}" not found in configuration${m}`})):console.error(`Service "${l}" not found in configuration${m}`),{success:!1,message:`Service "${l}" not found.`}}if(r==="json")return console.log(JSON.stringify(i)),{success:!0,message:"Status retrieved successfully."};let o=a.slug!==s.slug?`${a.slug}/`:"",p=i.status==="running"?"Running":i.status==="error"?"Error":"Stopped";console.log(`Service: ${o}${i.name}`),console.log(`Status: ${p}`),i.status==="running"&&i.pid&&console.log(`PID: ${i.pid}`),console.log(`Command: ${i.command}`),console.log(`CWD: ${i.cwd.replace((0,qe.homedir)(),"~")}`),console.log(`Logs: ${i.logPath.replace((0,qe.homedir)(),"~")}`);let d=c.getPlistPath(l);if((0,rn.existsSync)(d)&&console.log(`Plist: ${d.replace((0,qe.homedir)(),"~")}`),i.lastExitCode!==null&&i.lastExitCode!==0&&i.status!=="running"&&console.log(`Last exit code: ${i.lastExitCode}`),i.logs&&i.logs.length>0){console.log(""),console.log("Recent logs (last 10 lines):");for(let m of i.logs.slice(-10))console.log(` ${m}`)}return{success:!0,message:"Status retrieved successfully."}}})});var dn={};x(dn,{logsCommand:()=>go});var ln,pn,go,un=h(()=>{"use strict";ln=require("child_process"),pn=require("fs/promises");C();de();go=new b({name:"services:logs",description:"Show logs for a service",usage:"services logs <name> [-n <lines>] [--follow]",example:"services logs api -n 50 --follow",args:[{name:"name",description:"Name of the service",required:!0,type:"string"}],flags:[{name:"lines",description:"Number of lines to show (use -n)",required:!1,type:"number",defaultValue:10},{name:"follow",description:"Follow the log output",required:!1,type:"boolean",defaultValue:!1}],handler:async({project:s,args:e,flags:t})=>{let n=new I(s),r=e.name,c=t.lines??t.n??10,l=!!t.follow,a=n.getLogPath(r,"stdout");if(l){let i=["-n",`${c}`,"-f",a];return(0,ln.spawn)("tail",i,{stdio:"inherit"}),new Promise(()=>{})}try{let p=(await(0,pn.readFile)(a,"utf-8")).trim().split(`
|
|
51
|
+
`).filter(Boolean).slice(-c);for(let d of p)console.log(d);return{success:!0}}catch(i){return console.error(`Failed to read logs for ${r}:`,i instanceof Error?i.message:i),{success:!1,message:"failed to read logs"}}}})});var mn={};x(mn,{servicesTeardownCommand:()=>ho});async function fo(s){let e=[],t=[],n=await O.list("denvig.");for(let c of n){let l=await O.bootout(c.label);l.success?(t.push(c.label),e.push({name:c.label,success:!0,message:"Service removed from launchctl"})):e.push({name:c.label,success:!1,message:`Failed to bootout: ${l.output}`})}let r=(0,ue.resolve)((0,dt.homedir)(),"Library","LaunchAgents");if(await Promise.all(t.map(async c=>{try{await(0,Ue.unlink)((0,ue.resolve)(r,`${c}.plist`))}catch{}})),s?.removeLogs&&t.length>0){let c=(0,ue.resolve)((0,dt.homedir)(),".denvig","logs"),l=t.map(a=>a.replace("denvig.",""));await Promise.all(l.flatMap(a=>[(0,Ue.unlink)((0,ue.resolve)(c,`${a}.log`)).catch(()=>{}),(0,Ue.unlink)((0,ue.resolve)(c,`${a}.error.log`)).catch(()=>{})]))}return{success:!0,services:e,logsRemoved:s?.removeLogs??!1}}var Ue,dt,ue,ho,gn=h(()=>{"use strict";Ue=require("fs/promises"),dt=require("os"),ue=require("path");C();ke();de();ho=new b({name:"services:teardown",description:"Stop all services and remove them from launchctl",usage:"services teardown [--global] [--remove-logs] [--format table|json]",example:"services teardown",args:[],flags:[{name:"global",description:"Teardown all denvig services across all projects",required:!1,type:"boolean",defaultValue:!1},{name:"remove-logs",description:"Also remove log files",required:!1,type:"boolean",defaultValue:!1},{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=e.format,n=e["remove-logs"];if(e.global){t!=="json"&&console.log("Tearing down all denvig services globally...");let a=await fo({removeLogs:n});if(t==="json")console.log(JSON.stringify(a));else if(a.services.length===0)console.log("No services found to teardown.");else{for(let i of a.services)i.success?console.log(`\u2713 ${i.name} removed`):console.log(`\u2717 ${i.name}: ${i.message}`);console.log(""),console.log(`Teardown complete. ${a.services.filter(i=>i.success).length}/${a.services.length} services removed.`),n&&console.log("Log files have been removed.")}return{success:!0,message:"Global teardown complete"}}let c=new I(s);t!=="json"&&console.log(`Tearing down all services for ${s.slug}...`);let l=await c.teardownAll({removeLogs:n});if(t==="json")console.log(JSON.stringify({success:!0,project:s.slug,services:l,logsRemoved:n}));else if(l.length===0)console.log("No services found to teardown.");else{for(let a of l)a.success?console.log(`\u2713 ${a.name} removed`):console.log(`\u2717 ${a.name}: ${a.message}`);console.log(""),console.log(`Teardown complete. ${l.filter(a=>a.success).length}/${l.length} services removed.`),n&&console.log("Log files have been removed.")}return{success:!0,message:"Teardown complete"}}})});var fn,ut,hn,vn=h(()=>{"use strict";fn=require("crypto"),ut=s=>{let{project:e,workspace:t="root",resource:n}=s;if(!n.startsWith("action/")&&!n.startsWith("service/"))throw new Error(`Invalid resource format: ${n}. Must start with "action/" or "service/".`);return`@${e.slug}|${t}|${n}`},hn=s=>{let e=ut(s),t=(0,fn.createHash)("sha256").update(e).digest("hex");return{id:e,hash:t}}});var yn={};x(yn,{internalsResourceHashCommand:()=>vo,internalsResourceIdCommand:()=>yo});var vo,yo,bn=h(()=>{"use strict";C();vn();vo=new b({name:"internals:resource-hash",description:"Generate hash for a denvig resource",usage:"internals:resource-hash <resource>",example:"denvig internals:resource-hash service/hello",args:[{name:"resource",description:"Resource identifier (e.g., service/api, action/build, apps/web|action/dev, or full ID)",required:!0,type:"string"}],flags:[{name:"workspace",description:'Workspace path (defaults to "root")',required:!1,type:"string"}],handler:async({project:s,args:e,flags:t})=>{let n=e.resource,r=t.workspace,c=n;if(n.startsWith("@")){let a=n.match(/^@([^#]+)#([^|]+)\|(.+)$/);if(!a)return console.error("Error: Invalid full ID format. Expected: @project#workspace|resource"),{success:!1,message:"Invalid ID format"};r=a[2],c=a[3]}else if(n.includes("|")){let a=n.split("|");r=a[0],c=a[1]}if(!c.startsWith("action/")&&!c.startsWith("service/"))return console.error('Error: Resource must start with "action/" or "service/" (e.g., service/api, action/build)'),{success:!1,message:"Invalid resource format"};let l=hn({project:s,workspace:r,resource:c});return console.log(`${l.id}
|
|
52
|
+
${l.hash}`),{success:!0,message:"Hash generated successfully"}}}),yo=new b({name:"internals:resource-id",description:"Generate ID for a denvig resource",usage:"internals:resource-id <resource>",example:"denvig internals:id service/hello",args:[{name:"resource",description:"Resource identifier (e.g., service/api, action/build, apps/web|action/dev)",required:!0,type:"string"}],flags:[{name:"workspace",description:'Workspace path (defaults to "root")',required:!1,type:"string"}],handler:async({project:s,args:e,flags:t})=>{let n=e.resource,r=t.workspace,c=n;if(n.includes("|")){let a=n.split("|");r=a[0],c=a[1]}if(!c.startsWith("action/")&&!c.startsWith("service/"))return console.error('Error: Resource must start with "action/" or "service/" (e.g., service/api, action/build)'),{success:!1,message:"Invalid resource format"};let l=ut({project:s,workspace:r,resource:c});return console.log(l),{success:!0,message:"ID generated successfully"}}})});var Dn,mt,gt,bo,ft,jn,Pn,ht=h(()=>{"use strict";Dn=["pnpm-lock.yaml:","yarn.lock:","Gemfile.lock:","uv.lock:"],mt=s=>{for(let e of Dn)if(s.startsWith(e)){let n=s.slice(e.length).match(/^([^@]+)@([^(@]+)/);if(n)return{name:n[1],version:n[2]}}return null},gt=s=>Dn.some(e=>s.startsWith(e)),bo=s=>s.endsWith("#dependencies"),ft=s=>s.endsWith("#devDependencies"),jn=(s,e,t)=>{let n=new Map;for(let i of s)n.set(i.name,i);let r=[],c=new Set;for(let i of s)if(!(t&&i.ecosystem!==t)){for(let o of i.versions)if(!gt(o.source)){let p=ft(o.source);if(bo(o.source)||p){let m=`${i.name}@${o.resolved}`;c.has(m)||(c.add(m),r.push({dep:i,version:o.resolved,isDevDependency:p,children:[]}))}}}if(e>0){let i=new Map;for(let p of s)if(!(t&&p.ecosystem!==t))for(let d of p.versions){let m=mt(d.source);if(m){let u=`${m.name}@${m.version}`,g=i.get(u)||[];g.some(f=>f.name===p.name)||(g.push(p),i.set(u,g))}}let o=(p,d,m)=>{if(d>=e)return;let u=`${p.dep.name}@${p.version}`;if(m.has(u))return;m.add(u);let g=i.get(u)||[];for(let f of g){let v=f.versions.find(y=>{let j=mt(y.source);return j?.name===p.dep.name&&j?.version===p.version});if(v){let y={dep:f,version:v.resolved,isDevDependency:!1,children:[]};p.children.push(y),o(y,d+1,new Set(m))}}p.children.sort((f,v)=>f.dep.name.localeCompare(v.dep.name))};for(let p of r)o(p,0,new Set)}r.sort((i,o)=>{let p=i.dep.ecosystem.localeCompare(o.dep.ecosystem);return p!==0?p:i.dep.name.localeCompare(o.dep.name)});let l=[],a=(i,o,p,d)=>{l.push({name:i.dep.name,version:i.version,ecosystem:i.dep.ecosystem,isDevDependency:i.isDevDependency,depth:o,isLast:p,hasChildren:i.children.length>0,parentPath:[...d]});let m=[...d,p];i.children.forEach((u,g)=>{a(u,o+1,g===i.children.length-1,m)})};return r.forEach((i,o)=>{a(i,0,o===r.length-1,[])}),l},Pn=(s,e,t,n)=>{if(!gt(t))return{name:s,version:e,children:[]};let r=[{name:s,version:e}],c=t,l=50,a=0;for(;a<l;){let p=mt(c);if(!p)break;r.unshift({name:p.name,version:p.version});let d=n.get(p.name);if(!d)break;let m=d.versions.find(u=>u.resolved===p.version);if(!m||!gt(m.source))break;c=m.source,a++}if(r.length===0)return null;let i={name:r[0].name,version:r[0].version,children:[]},o=i;for(let p=1;p<r.length;p++){let d={name:r[p].name,version:r[p].version,children:[]};o.children.push(d),o=d}return i}});var Sn={};x(Sn,{depsListCommand:()=>Do});var Do,wn=h(()=>{"use strict";C();ht();ae();Do=new b({name:"deps:list",description:"List all dependencies detected by plugins",usage:"deps:list [--depth <n>] [--ecosystem <name>] [--format table|json]",example:"denvig deps:list --depth 1",args:[],flags:[{name:"depth",description:"Show subdependencies up to N levels deep (default: 0)",required:!1,type:"number",defaultValue:0},{name:"ecosystem",description:"Filter to a specific ecosystem (e.g., npm, rubygems, pypi)",required:!1,type:"string",defaultValue:void 0},{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=e.ecosystem,n=e.depth??0,r=e.format,c=await s.dependencies();if(c.length===0)return console.log(r==="json"?JSON.stringify([]):"No dependencies detected in this project."),{success:!0,message:"No dependencies detected."};let l=jn(c,n,t);if(l.length===0){if(r==="json")console.log(JSON.stringify([]));else{let g=t?`No dependencies found for ecosystem "${t}".`:"No direct dependencies detected in this project.";console.log(g)}return{success:!0,message:t?`No dependencies found for ecosystem "${t}".`:"No direct dependencies detected in this project."}}if(r==="json")return console.log(JSON.stringify(c)),{success:!0,message:"Dependencies listed successfully."};let i=new Set(l.map(g=>g.ecosystem)).size>1&&!t,o=z({columns:[{header:"Package",accessor:g=>g.name},{header:"",accessor:g=>g.depth===0&&g.isDevDependency?`${$.grey}(dev)${$.reset}`:" "},{header:"Current",accessor:g=>g.version},{header:"Ecosystem",accessor:g=>g.ecosystem,visible:i}],data:l,tree:{getDepth:g=>g.depth,getIsLast:g=>g.isLast,getHasChildren:g=>g.hasChildren,getParentPath:g=>g.parentPath}});for(let g of o)console.log(g);let p=l.filter(g=>g.depth===0),d=p.filter(g=>!g.isDevDependency).length,m=p.filter(g=>g.isDevDependency).length,u=c.length-p.length;return console.log(""),console.log(`${c.length} total (${d} dependencies, ${m} devDependencies, ${u} subdependencies)`),{success:!0,message:"Dependencies listed successfully."}}})});var $n,vt,kn,Cn=h(()=>{"use strict";$n=W(require("semver"),1),vt=(s,e)=>{if(s===e)return null;try{let t=$n.default.diff(s,e);return t?t==="major"||t==="premajor"?"major":t==="minor"||t==="preminor"?"minor":t==="patch"||t==="prepatch"||t==="prerelease"?"patch":null:null}catch{return null}},kn=(s,e)=>s===null?!1:e==="patch"?s==="patch":e==="minor"?s==="patch"||s==="minor":!1});var On={};x(On,{depsOutdatedCommand:()=>jo});var xn,jo,Rn=h(()=>{"use strict";C();ae();Cn();xn=(s,e)=>{if(s===e)return $.white;let t=vt(s,e);return t?t==="major"?$.red:t==="minor"?$.yellow:t==="patch"?$.green:$.white:$.white},jo=new b({name:"deps:outdated",description:"Show outdated dependencies",usage:"deps:outdated [--no-cache] [--semver patch|minor] [--ecosystem <name>] [--format table|json]",example:"denvig deps:outdated --semver patch",args:[],flags:[{name:"no-cache",description:"Skip cache and fetch fresh data from registry",required:!1,type:"boolean",defaultValue:!1},{name:"semver",description:'Filter by semver level: "patch" for patch updates only, "minor" for minor and patch updates',required:!1,type:"string",defaultValue:void 0},{name:"ecosystem",description:"Filter to a specific ecosystem (e.g., npm, rubygems, pypi)",required:!1,type:"string",defaultValue:void 0},{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"}],handler:async({project:s,flags:e})=>{let t=!e["no-cache"],n=e.semver,r=e.ecosystem,c=e.format;if(n&&n!=="patch"&&n!=="minor")return console.error(`Invalid --semver value: "${n}". Must be "patch" or "minor".`),{success:!1,message:"Invalid --semver value."};let a=await s.outdatedDependencies({cache:t}),i=u=>u.versions[0]?.resolved||"";if(r&&(a=a.filter(u=>u.ecosystem===r)),n&&(a=a.filter(u=>{let g=vt(i(u),u.latest);return kn(g,n)})),a.length===0){if(c==="json")console.log(JSON.stringify([]));else{let g="All dependencies are up to date!";r&&n?g=`No ${n}-level updates available for ecosystem "${r}".`:r?g=`No outdated dependencies found for ecosystem "${r}".`:n&&(g=`No ${n}-level updates available.`),console.log(g)}let u="All dependencies are up to date!";return r&&n?u=`No ${n}-level updates available for ecosystem "${r}".`:r?u=`No outdated dependencies found for ecosystem "${r}".`:n&&(u=`No ${n}-level updates available.`),{success:!0,message:u}}let o=a.sort((u,g)=>{let f=u.ecosystem.localeCompare(g.ecosystem);return f!==0?f:u.name.localeCompare(g.name)});if(c==="json")return console.log(JSON.stringify(o)),{success:!0,message:"Outdated dependencies listed."};let d=new Set(a.map(u=>u.ecosystem)).size>1&&!r,m=z({columns:[{header:"Package",accessor:u=>u.name},{header:"",accessor:u=>u.isDevDependency?`${$.grey}(dev)${$.reset}`:" "},{header:"Current",accessor:u=>i(u)},{header:"Wanted",accessor:u=>u.wanted,format:(u,g)=>`${xn(i(g),g.wanted)}${u}${$.reset}`},{header:"Latest",accessor:u=>u.latest,format:(u,g)=>`${xn(i(g),g.latest)}${u}${$.reset}`},{header:"Ecosystem",accessor:u=>u.ecosystem,visible:d}],data:o});for(let u of m)console.log(u);return{success:!0,message:"Outdated dependencies listed."}}})});var He,ze,Ln=h(()=>{"use strict";ae();He=(s,e="",t=!0,n=!0)=>{let r=[],c=s.children.length>0;if(n)r.push(`${s.name} ${$.grey}${s.version}${$.reset}`);else{let a=c?t?"\u2514\u2500\u252C ":"\u251C\u2500\u252C ":t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ";r.push(`${e}${a}${s.name} ${$.grey}${s.version}${$.reset}`)}let l=n?"":e+(t?" ":"\u2502 ");for(let a=0;a<s.children.length;a++){let i=s.children[a],o=a===s.children.length-1;r.push(...He(i,l,o,!1))}return r},ze=(s,e)=>{let t=s.find(n=>n.name===e.name&&n.version===e.version);if(t)for(let n of e.children)ze(t.children,n);else s.push(e)}});var Nn={};x(Nn,{depsWhyCommand:()=>Po});var Po,Tn=h(()=>{"use strict";C();ht();Ln();Po=new b({name:"deps:why",description:"Show why a dependency is installed",usage:"deps:why <dependency>",example:"denvig deps:why yaml",args:[{name:"dependency",description:"The dependency name to look up",required:!0,type:"string"}],flags:[],handler:async({project:s,args:e})=>{let t=e.dependency,n=await s.dependencies(),r=n.find(i=>i.name===t);if(!r)return console.log(`Dependency "${t}" not found in this project.`),{success:!1,message:"Dependency not found."};let c=new Map;for(let i of n)c.set(i.name,i);console.log(`${s.name} ${s.path}`),console.log("");let l=[],a=[];for(let i of r.versions){let o=Pn(r.name,i.resolved,i.source,c);o&&(c.get(o.name)?.versions.some(m=>ft(m.source))?ze(a,o):ze(l,o))}if(l.length>0){console.log("dependencies:");for(let i=0;i<l.length;i++){let o=He(l[i],"",i===l.length-1,!0);for(let p of o)console.log(p)}console.log("")}if(a.length>0){console.log("devDependencies:");for(let i=0;i<a.length;i++){let o=He(a[i],"",i===a.length-1,!0);for(let p of o)console.log(p)}console.log("")}return l.length===0&&a.length===0&&console.log(`Could not determine dependency chain for "${t}".`),{success:!0,message:"Dependency chain shown."}}})});var Fn={};x(Fn,{configVerifyCommand:()=>So});var In,An,So,En=h(()=>{"use strict";In=require("path"),An=require("yaml");C();Ze();Ke();So=new b({name:"config:verify",description:"Verify a .denvig.yml file against the config schema.",usage:"config verify [path]",example:"config verify .denvig.yml",args:[{name:"path",description:"Path to the config file (defaults to .denvig.yml)",required:!1,type:"string",defaultValue:".denvig.yml"}],flags:[],handler:({project:s,args:e})=>{let t=(0,In.resolve)(s.path,e.path?.toString()||".denvig.yml"),n=ye(t);if(!n)return console.error(`Config file not found: ${t}`),{success:!1,message:"Config file not found."};let r;try{r=(0,An.parse)(n)}catch(l){return console.error(`Failed to parse YAML at ${t}:`),l instanceof Error&&console.error(` ${l.message}`),{success:!1,message:"Invalid YAML syntax."}}let c=Te.safeParse(r);if(!c.success){console.error(`Config validation failed for ${t}:`);for(let l of c.error.issues){let a=l.path.length>0?l.path.join("."):"(root)";console.error(` - ${a}: ${l.message}`)}return{success:!1,message:"Config validation failed."}}return console.log(`Config is valid: ${t}`),{success:!0,message:"Config is valid."}}})});var Vn={};x(Vn,{projectsListCommand:()=>$o});var wo,$o,Wn=h(()=>{"use strict";C();ae();lt();we();pt();ke();de();wo=s=>{switch(s){case"running":return"\u{1F7E2}";case"stopped":return"\u25EF";default:return""}},$o=new b({name:"projects",description:"List all projects on the system",usage:"projects [list] [--format table|json] [--with-config]",example:"projects --format json",args:[],flags:[{name:"format",description:"Output format: table or json (default: table)",required:!1,type:"string",defaultValue:"table"},{name:"with-config",description:"Only show projects with a .denvig.yml configuration file",required:!1,type:"boolean",defaultValue:!1}],handler:async({project:s,flags:e})=>{let t=e.format,n=e["with-config"],r=s.slug,c=_e({withConfig:n});if(c.length===0)return console.log(t==="json"?JSON.stringify([]):"No projects found."),{success:!0,message:"No projects found."};let l=await O.list("denvig."),a=[];for(let p of c){let d=new M(p),m=d.config.$sources.length>0,{$sources:u,...g}=d.config,f="none",v=d.config.services||{},y=Object.keys(v);if(y.length>0){let j=new I(d),P=!1;for(let k of y)if((await j.getServiceResponse(k,{launchctlList:l}))?.status==="running"){P=!0;break}f=P?"running":"stopped"}a.push({slug:p,name:d.name,path:d.path,config:m?g:null,serviceStatus:f})}let i=a.sort((p,d)=>{let m=p.slug===r,u=d.slug===r;return m&&!u?-1:!m&&u?1:p.slug.localeCompare(d.slug)});if(t==="json")return console.log(JSON.stringify(i)),{success:!0,message:"Projects listed successfully."};let o=z({columns:[{header:"",accessor:p=>wo(p.serviceStatus)},{header:"Name",accessor:p=>p.config?.name||p.slug},{header:"Path",accessor:p=>ie(p.path)}],data:i});for(let p of o)console.log(p);return console.log(""),console.log(`${a.length} project${a.length===1?"":"s"} found`),{success:!0,message:"Projects listed successfully."}}})});var yt=W(require("minimist"),1);be();we();Me();var Mn=[{name:"project",description:"The project slug to run against. Defaults to current directory.",required:!1,type:"string",defaultValue:void 0}];async function ko(){let s=process.argv[2],e=process.argv.slice(2),t=J(),n=process.cwd(),r=(0,yt.default)(process.argv.slice(2)).project?.toString()||n.replace(`${t.codeRootDir}/`,"").split("/").slice(0,2).join("/"),c=new M(r),l={outdated:"deps:outdated"};l[s]&&(s=l[s]);let a=["start","stop","restart","status","logs","teardown"];if(s==="services"){let D=process.argv[3];D&&a.includes(D)&&(s=`services:${D}`,e=[process.argv[2],...process.argv.slice(4)])}let i=["list","outdated","why"];if(s==="deps"){let D=process.argv[3];D&&i.includes(D)&&(s=`deps:${D}`,e=[process.argv[2],...process.argv.slice(4)])}let o=["verify"];if(s==="config"){let D=process.argv[3];D&&o.includes(D)&&(s=`config:${D}`,e=[process.argv[2],...process.argv.slice(4)])}let p=["list"];if(s==="projects"){let D=process.argv[3];D&&p.includes(D)&&(s=`projects:${D}`,e=[process.argv[2],...process.argv.slice(4)])}let d=[...t.quickActions||[],...c?.config?.quickActions||[]].sort();d.includes(s)&&(e=["run",...process.argv.slice(2)],s="run",console.log("> Proxying to denvig run",...process.argv.slice(2)));let{runCommand:m}=await Promise.resolve().then(()=>(xs(),Cs)),{configCommand:u}=await Promise.resolve().then(()=>(Ns(),Ls)),{pluginsCommand:g}=await Promise.resolve().then(()=>(Is(),Ts)),{versionCommand:f}=await Promise.resolve().then(()=>(Fs(),As)),{infoCommand:v}=await Promise.resolve().then(()=>(Vs(),Es)),{servicesCommand:y}=await Promise.resolve().then(()=>(Bs(),zs)),{servicesStartCommand:j}=await Promise.resolve().then(()=>(Zs(),Ks)),{servicesStopCommand:P}=await Promise.resolve().then(()=>(en(),Xs)),{servicesRestartCommand:k}=await Promise.resolve().then(()=>(nn(),sn)),{servicesStatusCommand:A}=await Promise.resolve().then(()=>(an(),cn)),{logsCommand:_}=await Promise.resolve().then(()=>(un(),dn)),{servicesTeardownCommand:G}=await Promise.resolve().then(()=>(gn(),mn)),{internalsResourceHashCommand:me,internalsResourceIdCommand:ge}=await Promise.resolve().then(()=>(bn(),yn)),{depsListCommand:fe}=await Promise.resolve().then(()=>(wn(),Sn)),{depsOutdatedCommand:xe}=await Promise.resolve().then(()=>(Rn(),On)),{depsWhyCommand:_n}=await Promise.resolve().then(()=>(Tn(),Nn)),{configVerifyCommand:Jn}=await Promise.resolve().then(()=>(En(),Fn)),{projectsListCommand:bt}=await Promise.resolve().then(()=>(Wn(),Vn)),he={run:m,config:u,"config:verify":Jn,plugins:g,version:f,info:v,services:y,"services:start":j,"services:stop":P,"services:restart":k,"services:status":A,"services:logs":_,"services:teardown":G,deps:fe,"deps:list":fe,"deps:outdated":xe,"deps:why":_n,"internals:resource-hash":me,"internals:resource-id":ge,projects:bt,"projects:list":bt},Oe=he[s],ve=(0,yt.default)(e),Gn=Oe?.args.reduce((D,S,Le)=>{let Ne=ve._[Le+1];return Ne!==void 0?D[S.name]=Ne:S.required&&(console.error(`Missing required argument: ${S.name}`),process.exit(1)),D},{})||{},qn=ve._.slice(Oe?.args.length+1).map(D=>String(D))||[],Dt=[...Mn,...Oe?.flags||[]],Un=new Set(Dt.map(D=>D.name)),Hn=Dt.reduce((D,S)=>(ve[S.name]!==void 0?D[S.name]=ve[S.name]:S.defaultValue!==void 0?D[S.name]=S.defaultValue:S.required&&(console.error(`Missing required flag: ${S.name}`),process.exit(1)),D),{}),Re=[];for(let[D,S]of Object.entries(ve))D!=="_"&&!Un.has(D)&&(S===!0?Re.push(`--${D}`):S===!1?Re.push(`--no-${D}`):Re.push(`--${D}`,String(S)));let zn=[...qn,...Re];if(!s){console.log(`Denvig v${oe()}`),console.log(""),console.log("Usage: denvig <command> [args] [flags]"),console.log(""),console.log("Available commands:"),Object.keys(he).forEach(S=>{S.startsWith("internals:")||console.log(` - ${he[S].usage.padEnd(20," ")} ${he[S].description}`)}),console.log(""),console.log("Quick Actions:");for(let S of d){let Le=(await c?.actions)?.[S];if(!Le){console.log(` - ${S.padEnd(20," ")} not defined`);return}for(let Ne of Le){let jt=Ne.split(`
|
|
53
|
+
`),Bn=jt[0],Yn=jt.slice(1);console.log(` - ${S.padEnd(20," ")} $ ${Bn}`);for(let Pt of Yn)Pt.trim()&&console.log(`${" ".repeat(27)}${Pt}`)}}console.log(""),console.log("Global flags:"),Mn.forEach(S=>{console.log(` --${S.name.padEnd(20," ")} ${S.description}`)}),process.exit(1)}he[s]||(console.error(`Command "${s}" not found.`),process.exit(1));try{r||console.error("No project provided or detected.");let{success:D}=await Oe.run(c,Gn,Hn,zn);D||process.exit(1)}catch(D){console.error(`Error executing command "${s}":`,D),process.exit(1)}}ko();
|
package/dist/sdk.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var v=(i,e)=>{for(var s in e)a(i,s,{get:e[s],enumerable:!0})},m=(i,e,s,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!h.call(i,r)&&r!==s&&a(i,r,{get:()=>e[r],enumerable:!(t=u(e,r))||t.enumerable});return i};var y=i=>m(a({},"__esModule",{value:!0}),i);var O={};v(O,{DenvigSDK:()=>o,DenvigSDKError:()=>n,default:()=>f});module.exports=y(O);var l=require("child_process"),d=require("util"),p=(0,d.promisify)(l.exec),o=class{locale;cliPath;cwd;shell;constructor(e={}){this.locale=e.locale??"en_GB.UTF-8",this.cliPath=e.cliPath??"./node_modules/.bin/denvig",this.cwd=e.cwd??process.cwd(),this.shell=e.shell??"/bin/zsh"}async run(e){try{let{stdout:s}=await p(`${this.cliPath} ${e} --format json`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return JSON.parse(s)}catch(s){let t=s;if(t.stdout)try{return JSON.parse(t.stdout)}catch{}throw new n(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}async runText(e){try{let{stdout:s}=await p(`${this.cliPath} ${e}`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return s.trim()}catch(s){let t=s;throw new n(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}buildFlags(e){let s=[];for(let[t,r]of Object.entries(e)){if(r==null)continue;let c=t.replace(/([A-Z])/g,"-$1").toLowerCase();typeof r=="boolean"?r&&s.push(`--${c}`):s.push(`--${c}`,String(r))}return s.join(" ")}async version(){return(await this.runText("version")).replace(/^v/,"")}services={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`services ${s}`.trim())},status:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services status ${e} ${t}`.trim())},start:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services start ${e} ${t}`.trim())},stop:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services stop ${e} ${t}`.trim())},restart:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services restart ${e} ${t}`.trim())}};deps={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps list ${s}`.trim())},outdated:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps outdated ${s}`.trim())}}},n=class extends Error{constructor(s,t,r,c){super(s);this.originalMessage=t;this.stderr=r;this.stdout=c;this.name="DenvigSDKError"}},f=o;0&&(module.exports={DenvigSDK,DenvigSDKError});
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var v=(i,e)=>{for(var s in e)a(i,s,{get:e[s],enumerable:!0})},m=(i,e,s,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!h.call(i,r)&&r!==s&&a(i,r,{get:()=>e[r],enumerable:!(t=u(e,r))||t.enumerable});return i};var y=i=>m(a({},"__esModule",{value:!0}),i);var O={};v(O,{DenvigSDK:()=>o,DenvigSDKError:()=>n,default:()=>f});module.exports=y(O);var l=require("child_process"),d=require("util"),p=(0,d.promisify)(l.exec),o=class{locale;cliPath;cwd;shell;constructor(e={}){this.locale=e.locale??"en_GB.UTF-8",this.cliPath=e.cliPath??"./node_modules/.bin/denvig",this.cwd=e.cwd??process.cwd(),this.shell=e.shell??"/bin/zsh"}async run(e){try{let{stdout:s}=await p(`${this.cliPath} ${e} --format json`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return JSON.parse(s)}catch(s){let t=s;if(t.stdout)try{return JSON.parse(t.stdout)}catch{}throw new n(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}async runText(e){try{let{stdout:s}=await p(`${this.cliPath} ${e}`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return s.trim()}catch(s){let t=s;throw new n(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}buildFlags(e){let s=[];for(let[t,r]of Object.entries(e)){if(r==null)continue;let c=t.replace(/([A-Z])/g,"-$1").toLowerCase();typeof r=="boolean"?r&&s.push(`--${c}`):s.push(`--${c}`,String(r))}return s.join(" ")}async version(){return(await this.runText("version")).replace(/^v/,"")}services={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`services ${s}`.trim())},status:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services status ${e} ${t}`.trim())},start:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services start ${e} ${t}`.trim())},stop:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services stop ${e} ${t}`.trim())},restart:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services restart ${e} ${t}`.trim())}};deps={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps list ${s}`.trim())},outdated:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps outdated ${s}`.trim())}};projects={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`projects list ${s}`.trim())}}},n=class extends Error{constructor(s,t,r,c){super(s);this.originalMessage=t;this.stderr=r;this.stdout=c;this.name="DenvigSDKError"}},f=o;0&&(module.exports={DenvigSDK,DenvigSDKError});
|
package/dist/sdk.d.cts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The per project configuration.
|
|
5
|
+
* This is usually loaded from ~/.denvig.yml or ~/.denvig/config.yml
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* name: My Project
|
|
9
|
+
* actions:
|
|
10
|
+
* build:
|
|
11
|
+
* command: pnpm build
|
|
12
|
+
* clean:
|
|
13
|
+
* command: rf -rf dist
|
|
14
|
+
*/
|
|
15
|
+
declare const ProjectConfigSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
18
|
+
command: z.ZodString;
|
|
19
|
+
}, z.core.$strip>>>;
|
|
20
|
+
quickActions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
services: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
22
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
23
|
+
command: z.ZodString;
|
|
24
|
+
http: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
27
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
envFile: z.ZodOptional<z.ZodString>;
|
|
30
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
31
|
+
keepAlive: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
}, z.core.$strict>>>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
type ProjectConfigSchema = z.infer<typeof ProjectConfigSchema>;
|
|
35
|
+
|
|
1
36
|
/**
|
|
2
37
|
* Shared response types for CLI JSON output and SDK.
|
|
3
38
|
* This is the single source of truth for all JSON response shapes.
|
|
4
39
|
* @module
|
|
5
40
|
*/
|
|
41
|
+
|
|
6
42
|
/**
|
|
7
43
|
* Service information for display.
|
|
8
44
|
*/
|
|
@@ -83,12 +119,15 @@ type OutdatedDependency = Dependency & {
|
|
|
83
119
|
specifier: string;
|
|
84
120
|
isDevDependency: boolean;
|
|
85
121
|
};
|
|
86
|
-
|
|
87
122
|
/**
|
|
88
|
-
*
|
|
89
|
-
* These are the single source of truth for CLI JSON responses.
|
|
90
|
-
* @module
|
|
123
|
+
* A project from projects:list command.
|
|
91
124
|
*/
|
|
125
|
+
type ProjectResponse = {
|
|
126
|
+
slug: string;
|
|
127
|
+
name: string;
|
|
128
|
+
path: string;
|
|
129
|
+
config: ProjectConfigSchema | null;
|
|
130
|
+
};
|
|
92
131
|
|
|
93
132
|
/**
|
|
94
133
|
* Response when a service operation fails.
|
|
@@ -147,6 +186,10 @@ type DepsOutdatedOptions = {
|
|
|
147
186
|
/** Filter to a specific ecosystem (e.g., npm, rubygems, pypi) */
|
|
148
187
|
ecosystem?: string;
|
|
149
188
|
};
|
|
189
|
+
type ProjectsListOptions = {
|
|
190
|
+
/** Only include projects with a .denvig.yml configuration file */
|
|
191
|
+
withConfig?: boolean;
|
|
192
|
+
};
|
|
150
193
|
/**
|
|
151
194
|
* Denvig SDK for programmatic access to the CLI.
|
|
152
195
|
*
|
|
@@ -229,6 +272,15 @@ declare class DenvigSDK {
|
|
|
229
272
|
*/
|
|
230
273
|
outdated: (options?: DepsOutdatedOptions) => Promise<OutdatedDependency[]>;
|
|
231
274
|
};
|
|
275
|
+
/**
|
|
276
|
+
* Project management commands.
|
|
277
|
+
*/
|
|
278
|
+
projects: {
|
|
279
|
+
/**
|
|
280
|
+
* List all projects on the system.
|
|
281
|
+
*/
|
|
282
|
+
list: (options?: ProjectsListOptions) => Promise<ProjectResponse[]>;
|
|
283
|
+
};
|
|
232
284
|
}
|
|
233
285
|
/**
|
|
234
286
|
* Error thrown when a denvig CLI command fails.
|
|
@@ -240,4 +292,4 @@ declare class DenvigSDKError extends Error {
|
|
|
240
292
|
constructor(message: string, originalMessage?: string | undefined, stderr?: string | undefined, stdout?: string | undefined);
|
|
241
293
|
}
|
|
242
294
|
|
|
243
|
-
export { DenvigSDK, DenvigSDKError, type DenvigSDKOptions, type Dependency, type DependencyVersion, type DepsListOptions, type DepsOutdatedOptions, type ListServicesOptions, type OutdatedDependency, type ServiceInfo, type ServiceOperationError, type ServiceOperationOptions, type ServiceResponse, type ServiceResult, type ServiceStatus, DenvigSDK as default };
|
|
295
|
+
export { DenvigSDK, DenvigSDKError, type DenvigSDKOptions, type Dependency, type DependencyVersion, type DepsListOptions, type DepsOutdatedOptions, type ListServicesOptions, type OutdatedDependency, ProjectConfigSchema, type ProjectResponse, type ProjectsListOptions, type ServiceInfo, type ServiceOperationError, type ServiceOperationOptions, type ServiceResponse, type ServiceResult, type ServiceStatus, DenvigSDK as default };
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The per project configuration.
|
|
5
|
+
* This is usually loaded from ~/.denvig.yml or ~/.denvig/config.yml
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* name: My Project
|
|
9
|
+
* actions:
|
|
10
|
+
* build:
|
|
11
|
+
* command: pnpm build
|
|
12
|
+
* clean:
|
|
13
|
+
* command: rf -rf dist
|
|
14
|
+
*/
|
|
15
|
+
declare const ProjectConfigSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
18
|
+
command: z.ZodString;
|
|
19
|
+
}, z.core.$strip>>>;
|
|
20
|
+
quickActions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
services: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
22
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
23
|
+
command: z.ZodString;
|
|
24
|
+
http: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
27
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
envFile: z.ZodOptional<z.ZodString>;
|
|
30
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
31
|
+
keepAlive: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
}, z.core.$strict>>>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
type ProjectConfigSchema = z.infer<typeof ProjectConfigSchema>;
|
|
35
|
+
|
|
1
36
|
/**
|
|
2
37
|
* Shared response types for CLI JSON output and SDK.
|
|
3
38
|
* This is the single source of truth for all JSON response shapes.
|
|
4
39
|
* @module
|
|
5
40
|
*/
|
|
41
|
+
|
|
6
42
|
/**
|
|
7
43
|
* Service information for display.
|
|
8
44
|
*/
|
|
@@ -83,12 +119,15 @@ type OutdatedDependency = Dependency & {
|
|
|
83
119
|
specifier: string;
|
|
84
120
|
isDevDependency: boolean;
|
|
85
121
|
};
|
|
86
|
-
|
|
87
122
|
/**
|
|
88
|
-
*
|
|
89
|
-
* These are the single source of truth for CLI JSON responses.
|
|
90
|
-
* @module
|
|
123
|
+
* A project from projects:list command.
|
|
91
124
|
*/
|
|
125
|
+
type ProjectResponse = {
|
|
126
|
+
slug: string;
|
|
127
|
+
name: string;
|
|
128
|
+
path: string;
|
|
129
|
+
config: ProjectConfigSchema | null;
|
|
130
|
+
};
|
|
92
131
|
|
|
93
132
|
/**
|
|
94
133
|
* Response when a service operation fails.
|
|
@@ -147,6 +186,10 @@ type DepsOutdatedOptions = {
|
|
|
147
186
|
/** Filter to a specific ecosystem (e.g., npm, rubygems, pypi) */
|
|
148
187
|
ecosystem?: string;
|
|
149
188
|
};
|
|
189
|
+
type ProjectsListOptions = {
|
|
190
|
+
/** Only include projects with a .denvig.yml configuration file */
|
|
191
|
+
withConfig?: boolean;
|
|
192
|
+
};
|
|
150
193
|
/**
|
|
151
194
|
* Denvig SDK for programmatic access to the CLI.
|
|
152
195
|
*
|
|
@@ -229,6 +272,15 @@ declare class DenvigSDK {
|
|
|
229
272
|
*/
|
|
230
273
|
outdated: (options?: DepsOutdatedOptions) => Promise<OutdatedDependency[]>;
|
|
231
274
|
};
|
|
275
|
+
/**
|
|
276
|
+
* Project management commands.
|
|
277
|
+
*/
|
|
278
|
+
projects: {
|
|
279
|
+
/**
|
|
280
|
+
* List all projects on the system.
|
|
281
|
+
*/
|
|
282
|
+
list: (options?: ProjectsListOptions) => Promise<ProjectResponse[]>;
|
|
283
|
+
};
|
|
232
284
|
}
|
|
233
285
|
/**
|
|
234
286
|
* Error thrown when a denvig CLI command fails.
|
|
@@ -240,4 +292,4 @@ declare class DenvigSDKError extends Error {
|
|
|
240
292
|
constructor(message: string, originalMessage?: string | undefined, stderr?: string | undefined, stdout?: string | undefined);
|
|
241
293
|
}
|
|
242
294
|
|
|
243
|
-
export { DenvigSDK, DenvigSDKError, type DenvigSDKOptions, type Dependency, type DependencyVersion, type DepsListOptions, type DepsOutdatedOptions, type ListServicesOptions, type OutdatedDependency, type ServiceInfo, type ServiceOperationError, type ServiceOperationOptions, type ServiceResponse, type ServiceResult, type ServiceStatus, DenvigSDK as default };
|
|
295
|
+
export { DenvigSDK, DenvigSDKError, type DenvigSDKOptions, type Dependency, type DependencyVersion, type DepsListOptions, type DepsOutdatedOptions, type ListServicesOptions, type OutdatedDependency, ProjectConfigSchema, type ProjectResponse, type ProjectsListOptions, type ServiceInfo, type ServiceOperationError, type ServiceOperationOptions, type ServiceResponse, type ServiceResult, type ServiceStatus, DenvigSDK as default };
|
package/dist/sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exec as p}from"child_process";import{promisify as l}from"util";var c=l(p),o=class{locale;cliPath;cwd;shell;constructor(e={}){this.locale=e.locale??"en_GB.UTF-8",this.cliPath=e.cliPath??"./node_modules/.bin/denvig",this.cwd=e.cwd??process.cwd(),this.shell=e.shell??"/bin/zsh"}async run(e){try{let{stdout:s}=await c(`${this.cliPath} ${e} --format json`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return JSON.parse(s)}catch(s){let t=s;if(t.stdout)try{return JSON.parse(t.stdout)}catch{}throw new i(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}async runText(e){try{let{stdout:s}=await c(`${this.cliPath} ${e}`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return s.trim()}catch(s){let t=s;throw new i(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}buildFlags(e){let s=[];for(let[t,r]of Object.entries(e)){if(r==null)continue;let n=t.replace(/([A-Z])/g,"-$1").toLowerCase();typeof r=="boolean"?r&&s.push(`--${n}`):s.push(`--${n}`,String(r))}return s.join(" ")}async version(){return(await this.runText("version")).replace(/^v/,"")}services={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`services ${s}`.trim())},status:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services status ${e} ${t}`.trim())},start:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services start ${e} ${t}`.trim())},stop:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services stop ${e} ${t}`.trim())},restart:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services restart ${e} ${t}`.trim())}};deps={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps list ${s}`.trim())},outdated:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps outdated ${s}`.trim())}}},i=class extends Error{constructor(s,t,r,n){super(s);this.originalMessage=t;this.stderr=r;this.stdout=n;this.name="DenvigSDKError"}},g=o;export{o as DenvigSDK,i as DenvigSDKError,g as default};
|
|
1
|
+
import{exec as p}from"child_process";import{promisify as l}from"util";var c=l(p),o=class{locale;cliPath;cwd;shell;constructor(e={}){this.locale=e.locale??"en_GB.UTF-8",this.cliPath=e.cliPath??"./node_modules/.bin/denvig",this.cwd=e.cwd??process.cwd(),this.shell=e.shell??"/bin/zsh"}async run(e){try{let{stdout:s}=await c(`${this.cliPath} ${e} --format json`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return JSON.parse(s)}catch(s){let t=s;if(t.stdout)try{return JSON.parse(t.stdout)}catch{}throw new i(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}async runText(e){try{let{stdout:s}=await c(`${this.cliPath} ${e}`,{encoding:"utf-8",cwd:this.cwd,shell:this.shell,env:{...process.env,LC_ALL:this.locale}});return s.trim()}catch(s){let t=s;throw new i(`Command failed: denvig ${e}`,t.message,t.stderr,t.stdout)}}buildFlags(e){let s=[];for(let[t,r]of Object.entries(e)){if(r==null)continue;let n=t.replace(/([A-Z])/g,"-$1").toLowerCase();typeof r=="boolean"?r&&s.push(`--${n}`):s.push(`--${n}`,String(r))}return s.join(" ")}async version(){return(await this.runText("version")).replace(/^v/,"")}services={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`services ${s}`.trim())},status:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services status ${e} ${t}`.trim())},start:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services start ${e} ${t}`.trim())},stop:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services stop ${e} ${t}`.trim())},restart:async(e,s)=>{let t=s?this.buildFlags(s):"";return this.run(`services restart ${e} ${t}`.trim())}};deps={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps list ${s}`.trim())},outdated:async e=>{let s=e?this.buildFlags(e):"";return this.run(`deps outdated ${s}`.trim())}};projects={list:async e=>{let s=e?this.buildFlags(e):"";return this.run(`projects list ${s}`.trim())}}},i=class extends Error{constructor(s,t,r,n){super(s);this.originalMessage=t;this.stderr=r;this.stdout=n;this.name="DenvigSDKError"}},g=o;export{o as DenvigSDK,i as DenvigSDKError,g as default};
|