denvig 0.4.0 → 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/README.md CHANGED
@@ -67,31 +67,24 @@ denvig deps --format json # Output as JSON
67
67
  Manage background services defined in `.denvig.yml`. Services run via launchctl on macOS:
68
68
 
69
69
  ```shell
70
- denvig services # List services and their status
71
- denvig services start # Start all services
72
- denvig services stop # Stop all services
73
- denvig services restart # Restart all services
70
+ denvig services # List all services and their status
71
+ denvig services start api # Start a service
72
+ denvig services stop api # Stop a service
73
+ denvig services restart api # Restart a service
74
+ denvig services status api # Check status of a service
75
+ denvig services logs api # View service logs
74
76
  ```
75
77
 
76
- Target a specific service by name:
78
+ Manage services from other projects using the full path:
77
79
 
78
80
  ```shell
79
- denvig services start api # Start only the 'api' service
80
- denvig services status api # Start only the 'api' service
81
- denvig services stop api # Stop only the 'api' service
82
- denvig services restart api # Restart only the 'api' service
83
- ```
84
-
85
- Manage services globally from any directory:
86
-
87
- ```shell
88
- denvig services start marcqualie/denvig/hello # Start 'api' in marcqualie/denvig project
89
- denvig services status marcqualie/denvig/hello # Check status of 'api' service
81
+ denvig services start marcqualie/denvig/dev # Start 'dev' service in marcqualie/denvig project
82
+ denvig services status marcqualie/denvig/hello # Check status of 'hello' in marcqualie/denvig project
90
83
  ```
91
84
 
92
85
  See [docs/configuration.md](docs/configuration.md) for service configuration options.
93
86
 
94
- All services commands also accept `--format json` for programmatic output.
87
+ All services commands accept `--format json` for programmatic output.
95
88
 
96
89
 
97
90
 
@@ -126,6 +119,36 @@ For troubleshooting guides including service management, resource identification
126
119
 
127
120
 
128
121
 
122
+ ## SDK
123
+
124
+ Denvig can be used programmatically in TypeScript projects:
125
+
126
+ ```ts
127
+ import { DenvigSDK } from 'denvig'
128
+
129
+ const denvig = new DenvigSDK()
130
+
131
+ // Services
132
+ const services = await denvig.services.list()
133
+ await denvig.services.start('api')
134
+ await denvig.services.stop('api')
135
+
136
+ // Dependencies
137
+ const deps = await denvig.deps.list()
138
+ const outdated = await denvig.deps.outdated({ semver: 'minor' })
139
+
140
+ // Execute in context of another project
141
+ await denvig.deps.outdated({ project: 'marcqualie/denvig' })
142
+ ```
143
+
144
+ All response types are exported for TypeScript consumers:
145
+
146
+ ```ts
147
+ import type { ServiceResponse, Dependency, OutdatedDependency } from 'denvig'
148
+ ```
149
+
150
+
151
+
129
152
  ## Building from source
130
153
 
131
154
  You can build from source instead of using the provided methods above:
package/dist/cli.cjs CHANGED
@@ -1,56 +1,53 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var kn=Object.create;var Me=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var On=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var h=(s,e)=>()=>(s&&(e=s(s=0)),e);var C=(s,e)=>{for(var t in e)Me(s,t,{get:e[t],enumerable:!0})},Nn=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Cn(e))!Rn.call(s,r)&&r!==t&&Me(s,r,{get:()=>e[r],enumerable:!(n=xn(e,r))||n.enumerable});return s};var F=(s,e,t)=>(t=s!=null?kn(On(s)):{},Nn(e||!s||!s.__esModule?Me(t,"default",{value:s,enumerable:!0}):t,s));var P,Ln,_e,pt,dt=h(()=>{"use strict";P=require("zod"),Ln=["build","check-types","dev","install","lint","outdated","test"],_e=P.z.object({codeRootDir:P.z.string().optional().default("~/src").describe("The base directory where projects are stored"),quickActions:P.z.array(P.z.string()).default(Ln).optional().describe("Quick actions that are available for all projects")}),pt=P.z.object({name:P.z.string().describe("Unique identifier for the project"),actions:P.z.record(P.z.string().describe("Name of the action"),P.z.object({command:P.z.string().describe("Shell command to run for the action")})).optional().describe("Actions that can be run against the project"),quickActions:P.z.array(P.z.string()).optional().describe("Actions that are available on the CLI root for quick access"),services:P.z.record(P.z.string(),P.z.object({cwd:P.z.string().optional().describe("Working directory for the service (relative to project root)"),command:P.z.string().describe("Shell command to execute"),http:P.z.object({port:P.z.number().optional().describe("Port number the service listens on"),domain:P.z.string().optional().describe("Domain to use for the service URL"),secure:P.z.boolean().optional().describe("Use HTTPS instead of HTTP")}).optional().describe("HTTP configuration for the service URL"),envFile:P.z.string().optional().describe("Path to .env file (relative to project root)"),env:P.z.record(P.z.string(),P.z.string()).optional().describe("Environment variables"),keepAlive:P.z.boolean().optional().describe("Restart service if it exits")})).optional().describe("Service that can be managed for this project")})});var ut,An,Je,mt=h(()=>{"use strict";ut=require("fs"),An=require("fs/promises"),Je=s=>{try{return(0,ut.readFileSync)(s,"utf8").trim()||null}catch(e){if(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")return null;throw e}}});var Z,Ge,ke,In,gt,E,ft,ue=h(()=>{"use strict";Z=require("path"),Ge=require("yaml");dt();mt();ke=(0,Z.resolve)(process.env.DENVIG_GLOBAL_CONFIG_PATH||`${process.env.HOME}/.denvig/config.yml`),In=(0,Z.resolve)(process.env.DENVIG_CODE_ROOT_DIR||`${process.env.HOME}/src`),gt={codeRootDir:In,quickActions:void 0},E=()=>{let s=Je(ke);if(s){let e=(0,Ge.parse)(s)||{};try{if(e.codeRootDir?.startsWith(".")){let t=(0,Z.dirname)(ke);e.codeRootDir=(0,Z.resolve)(`${t}/${e.codeRootDir}`)}return{..._e.parse({...gt,...e}),$sources:[ke]}}catch(t){console.error(`Error parsing global config at ${ke}:`,t),process.exit(1)}}return{..._e.parse(gt),$sources:[]}},ft=s=>{let e=E(),t={name:s,actions:{}},n=`${e.codeRootDir}/${s}/.denvig.yml`,r=Je(n);if(r)try{return{...t,...pt.parse((0,Ge.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 xe,qe=h(()=>{"use strict";xe=(s,e)=>{for(let[t,n]of Object.entries(e))s[t]||(s[t]=[]),s[t].push(...n);return s}});var Ue,V,me=h(()=>{"use strict";Ue=F(require("fs"),1),V=s=>{let e=`${s.path}/package.json`;if(!Ue.default.existsSync(e))return null;let t=Ue.default.readFileSync(e,"utf-8");return JSON.parse(t)}});var N,H=h(()=>{"use strict";N=s=>s});var M,Tn,ht,yt=h(()=>{"use strict";M=F(require("fs"),1);qe();me();H();Tn=N({name:"deno",actions:async s=>{let e=M.default.readdirSync(s.path);if(!(e.includes("deno.json")||e.includes("deno.jsonc")))return{};let r=V(s)?.scripts||{},c={...Object.entries(r).map(([o,i])=>[o,`deno ${i}`]).reduce((o,[i,l])=>(o[i]=[l],o),{}),install:["deno install"],outdated:["deno outdated"]},a=((0,M.existsSync)(`${s.path}/deno.json`)?JSON.parse((0,M.readFileSync)(`${s.path}/deno.json`,"utf8")):(0,M.existsSync)(`${s.path}/deno.jsonc`)?JSON.parse((0,M.readFileSync)(`${s.path}/deno.jsonc`,"utf8")):{}).tasks||{};return c=xe(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((o,[i,l])=>(o[i]=[l.startsWith("deno")?l:`deno task ${i}`],o),{}),install:["deno install"],outdated:["deno outdated"]}),c}}),ht=Tn});var vt,Fn,bt,Dt=h(()=>{"use strict";vt=F(require("fs"),1);me();H();Fn=N({name:"npm",actions:async s=>{let e=vt.default.readdirSync(s.path),t=e.includes("package.json"),n=e.includes("package-lock.json");if(!(t&&n))return{};let p=V(s)?.scripts||{};return{...Object.entries(p).map(([o,i])=>[o,`npm run ${o}`]).reduce((o,[i,l])=>(o[i]=[l],o),{}),install:["npm install"],outdated:["npm outdated"]}}}),bt=Fn});var L,St,En,Wn,Vn,jt,Mn,_n,Jn,Pt,$t=h(()=>{"use strict";L=require("fs"),St=require("os"),En=1800*1e3,Wn=()=>{let s=`${(0,St.homedir)()}/.cache/denvig/dependencies/npm`;return(0,L.existsSync)(s)||(0,L.mkdirSync)(s,{recursive:!0}),s},Vn=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},jt=s=>{let e=Vn(s);return`${Wn()}/${e}.json`},Mn=s=>{try{let e=(0,L.statSync)(s);return Date.now()-e.mtimeMs<En}catch{return!1}},_n=s=>{let e=jt(s);if(!(0,L.existsSync)(e)||!Mn(e))return null;try{let t=(0,L.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},Jn=(s,e)=>{try{let t=jt(s);(0,L.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},Pt=async(s,e=!1)=>{if(!e){let t=_n(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],p={versions:r,latest:c};return Jn(s,p),p}catch{return null}}});var Q,Ce,Gn,qn,Un,Oe,He=h(()=>{"use strict";$t();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},Ce=(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},Gn=(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&&Ce(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 Ce(s,e.slice(2))>=0;if(e.startsWith(">")&&!e.startsWith(">="))return Ce(s,e.slice(1))>0;let n=Q(e);return n?t.major===n.major&&t.minor===n.minor&&t.patch===n.patch:!1},qn=(s,e)=>{let t=s.filter(n=>Gn(n,e)).sort(Ce);return t.length>0?t[t.length-1]:null},Un=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}},Oe=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(p=>p.versions.some(a=>a.source.includes("#dependencies")||a.source.includes("#devDependencies"))).map(async p=>{let a=Un(p);if(!a)return;let o=await Pt(p.name,!t);if(!o)return;let i=qn(o.versions,a.specifier),l=o.latest,d=i&&i!==a.current,m=l&&l!==a.current;(d||m)&&n.push({...p,wanted:i||a.current,latest:l,specifier:a.specifier,isDevDependency:a.isDevDependency})});return await Promise.all(c),n}});var ge,wt,ze,kt,xt,Ct=h(()=>{"use strict";ge=require("fs"),wt=require("yaml");He();me();H();ze=s=>{let e=s.indexOf("(");return e===-1?s:s.slice(0,e)},kt=N({name:"pnpm",actions:async s=>{if(!s.rootFiles.includes("pnpm-lock.yaml"))return{};let r=V(s)?.scripts||{},c=s.rootFiles.includes("pnpm-workspace.yaml");return{...Object.entries(r).map(([a,o])=>[a,`pnpm run ${a}`]).reduce((a,[o,i])=>(a[o]=[i],a),{}),install:["pnpm install"],outdated:[c?"pnpm outdated -r":"pnpm outdated"]}},dependencies:async s=>{if(!(0,ge.existsSync)(`${s.path}/pnpm-lock.yaml`))return[];let e=new Map,t=new Set,n=(a,o,i,l,d,m)=>{let u=e.get(a);u?u.versions.push({resolved:l,specifier:m,source:d}):e.set(a,{id:a,name:o,ecosystem:i,versions:[{resolved:l,specifier:m,source:d}]})};e.set("npm:pnpm",{id:"npm:pnpm",name:"pnpm",ecosystem:"system",versions:[]});let r=`${s.path}/pnpm-lock.yaml`,c=(0,ge.readFileSync)(r,"utf-8"),p=(0,wt.parse)(c);if(p?.importers)for(let[a,o]of Object.entries(p.importers)){let i=a==="."?".":a;if(o.dependencies)for(let[l,d]of Object.entries(o.dependencies))d?.specifier&&d?.version&&(t.add(l),n(`npm:${l}`,l,"npm",ze(d.version),`${i}#dependencies`,d.specifier));if(o.devDependencies)for(let[l,d]of Object.entries(o.devDependencies))d?.specifier&&d?.version&&(t.add(l),n(`npm:${l}`,l,"npm",ze(d.version),`${i}#devDependencies`,d.specifier))}if(p?.snapshots)for(let[a,o]of Object.entries(p.snapshots)){let i={...o.dependencies};for(let[l,d]of Object.entries(i))if(!t.has(l)){let m=ze(d),u=`pnpm-lock.yaml:${a}`;n(`npm:${l}`,l,"npm",m,u,m)}}return Array.from(e.values()).sort((a,o)=>a.name.localeCompare(o.name))},outdatedDependencies:async(s,e)=>{if(!(0,ge.existsSync)(`${s.path}/pnpm-lock.yaml`))return[];let t=await kt.dependencies?.(s);return t?Oe(t,e):[]}}),xt=kt});var A,Ot,Hn,zn,Bn,Rt,Yn,Kn,Zn,Nt,Lt=h(()=>{"use strict";A=require("fs"),Ot=require("os"),Hn=1800*1e3,zn=()=>{let s=`${(0,Ot.homedir)()}/.cache/denvig/dependencies/rubygems`;return(0,A.existsSync)(s)||(0,A.mkdirSync)(s,{recursive:!0}),s},Bn=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},Rt=s=>{let e=Bn(s);return`${zn()}/${e}.json`},Yn=s=>{try{let e=(0,A.statSync)(s);return Date.now()-e.mtimeMs<Hn}catch{return!1}},Kn=s=>{let e=Rt(s);if(!(0,A.existsSync)(e)||!Yn(e))return null;try{let t=(0,A.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},Zn=(s,e)=>{try{let t=Rt(s);(0,A.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},Nt=async(s,e=!1)=>{if(!e){let t=Kn(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(o=>o.number),p=n.filter(o=>!o.prerelease).map(o=>o.number)[0]||r[0],a={versions:r,latest:p};return Zn(s,a),a}catch{return null}}});var ee,X,Qn,Xn,er,At,It=h(()=>{"use strict";Lt();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},Qn=(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(),p=ee(c);return p?c.split(".").length>=3?t.major===p.major&&t.minor===p.minor&&t.patch>=p.patch:t.major===p.major&&t.minor>=p.minor&&X(s,`${p.major}.${p.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(),p=ee(c);return p?t.major===p.major&&t.minor===p.minor&&t.patch===p.patch:!1}let r=ee(n);return r?t.major===r.major&&t.minor===r.minor&&t.patch===r.patch:!1},Xn=(s,e)=>{let t=s.filter(n=>Qn(n,e)).sort(X);return t.length>0?t[t.length-1]:null},er=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}},At=async(s,e={})=>{let t=e.cache??!0,n=[],c=s.filter(p=>p.versions.some(a=>a.source.includes("#dependencies")||a.source.includes("#devDependencies"))).map(async p=>{let a=er(p);if(!a)return;let o=await Nt(p.name,!t);if(!o)return;let i=Xn(o.versions,a.specifier),l=o.latest,d=i&&i!==a.current,m=l&&l!==a.current;(d||m)&&n.push({...p,wanted:i||a.current,latest:l,specifier:a.specifier,isDevDependency:a.isDevDependency})});return await Promise.all(c),n}});var te,tr,sr,Tt,Ft=h(()=>{"use strict";te=require("fs"),tr=s=>{let e=[],t=s.split(`
3
- `),n="dependencies",r=0;for(let c of t){let p=c.trim();if(p.startsWith("#")||p==="")continue;if(p.startsWith("group ")){(p.includes(":development")||p.includes(":test"))&&(n="devDependencies"),p.includes(" do")&&r++;continue}if(p==="end"){r--,r<=0&&(n="dependencies",r=0);continue}let a=p.match(/^gem\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/);if(a){let o=a[1],i=a[2]||"*";e.push({name:o,specifier:i,group:n})}}return e},sr=s=>{let e={},t={},n=s.split(`
4
- `),r="none",c=null,p=null;for(let a of n){let o=a.trimEnd();if(o==="GEM"){r="gem";continue}if(o==="PLATFORMS"){r="platforms";continue}if(o==="DEPENDENCIES"){r="dependencies";continue}if(o==="BUNDLED WITH"){r="none";continue}if(r==="gem"&&o===" specs:"){r="specs";continue}if(r==="specs"){if(o==="")continue;let i=a.match(/^(\s*)/),l=i?i[1].length:0,d=a.trim();if(l===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],p=f,e[c]||(e[c]={version:f,dependencies:{}})}}else if(l===6&&c&&p){let m=d.match(/^([^\s(]+)(?:\s+\(([^)]+)\))?/);if(m){let u=m[1],g=m[2]||"*";e[c].dependencies[u]=g}}}if(r==="dependencies"){if(o===""||o.startsWith(" ")===!1)continue;let i=o.match(/^\s+([^\s(!]+)(?:\s+\(([^)]+)\))?/);if(i){let d=i[1].replace(/!$/,""),m=i[2]||"*";t[d]=m}}}return{specs:e,dependencies:t}},Tt=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"),p=tr(c),a=(o,i,l,d,m,u)=>{let g=n.get(o);g?g.versions.push({resolved:d,specifier:u,source:m}):n.set(o,{id:o,name:i,ecosystem:l,versions:[{resolved:d,specifier:u,source:m}]})};n.set("rubygems:bundler",{id:"rubygems:bundler",name:"bundler",ecosystem:"system",versions:[]});for(let o of p)r.add(o.name);if((0,te.existsSync)(t)){let o=(0,te.readFileSync)(t,"utf-8"),i=sr(o);for(let l of p){let d=i.specs[l.name];d&&a(`rubygems:${l.name}`,l.name,"rubygems",d.version,`.#${l.group}`,l.specifier)}for(let[l,d]of Object.entries(i.specs))if(!r.has(l)){for(let[m,u]of Object.entries(i.specs))if(u.dependencies[l]){let g=`Gemfile.lock:${m}@${u.version}`,f=u.dependencies[l];a(`rubygems:${l}`,l,"rubygems",d.version,g,f)}}}else for(let o of p)a(`rubygems:${o.name}`,o.name,"rubygems",o.specifier,`.#${o.group}`,o.specifier);return Array.from(n.values()).sort((o,i)=>o.name.localeCompare(i.name))}});var Be,Et,Wt,Vt=h(()=>{"use strict";Be=F(require("fs"),1);H();It();Ft();Et=N({name:"ruby",actions:async s=>{let e=Be.default.readdirSync(s.path),t=e.includes("Gemfile"),n=e.includes("Rakefile"),r=e.includes("config.ru"),c=Be.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=>s.rootFiles.includes("Gemfile")?Tt(s):[],outdatedDependencies:async(s,e)=>{if(!s.rootFiles.includes("Gemfile"))return[];let n=await Et.dependencies?.(s);return n?At(n,e):[]}}),Wt=Et});var I,Mt,nr,rr,or,_t,ir,cr,ar,Jt,Gt=h(()=>{"use strict";I=require("fs"),Mt=require("os"),nr=1800*1e3,rr=()=>{let s=`${(0,Mt.homedir)()}/.cache/denvig/dependencies/pypi`;return(0,I.existsSync)(s)||(0,I.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},_t=s=>{let e=or(s);return`${rr()}/${e}.json`},ir=s=>{try{let e=(0,I.statSync)(s);return Date.now()-e.mtimeMs<nr}catch{return!1}},cr=s=>{let e=_t(s);if(!(0,I.existsSync)(e)||!ir(e))return null;try{let t=(0,I.readFileSync)(e,"utf-8");return JSON.parse(t)}catch{return null}},ar=(s,e)=>{try{let t=_t(s);(0,I.writeFileSync)(t,JSON.stringify(e),"utf-8")}catch{}},Jt=async(s,e=!1)=>{let t=s.toLowerCase().replace(/_/g,"-");if(!e){let n=cr(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(([,o])=>o.length>0).map(([o])=>o),p=r.info?.version||c[c.length-1],a={versions:c,latest:p};return ar(t,a),a}catch{return null}}});var ne,se,lr,pr,dr,ur,qt,Ut=h(()=>{"use strict";Gt();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},lr=s=>/[a-zA-Z]/.test(s),pr=(s,e)=>{let t=ne(s);if(!t||lr(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 p=r.slice(0,-2);return s.startsWith(p)}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},dr=(s,e)=>{let t=s.filter(n=>pr(n,e)).sort(se);return t.length>0?t[t.length-1]:null},ur=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(p=>p.versions.some(a=>a.source.includes("#dependencies")||a.source.includes("#devDependencies"))).map(async p=>{let a=ur(p);if(!a)return;let o=await Jt(p.name,!t);if(!o)return;let i=dr(o.versions,a.specifier),l=o.latest,d=i&&i!==a.current,m=l&&l!==a.current;(d||m)&&n.push({...p,wanted:i||a.current,latest:l,specifier:a.specifier,isDevDependency:a.isDevDependency})});return await Promise.all(c),n}});var mr,Ye,Ke,Ne,Ht,Re,Ze,zt=h(()=>{"use strict";mr=s=>{let e=s.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e},Ye=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):mr(e)},Ke=s=>{let e={},t=s.slice(1,-1).trim();if(!t)return e;let n=[],r="",c=0,p=!1,a="";for(let o=0;o<t.length;o++){let i=t[o];if(!p&&(i==='"'||i==="'")?(p=!0,a=i):p&&i===a&&t[o-1]!=="\\"&&(p=!1),!p){if(i==="{"||i==="[")c++;else if(i==="}"||i==="]")c--;else if(i===","&&c===0){n.push(r.trim()),r="";continue}}r+=i}r.trim()&&n.push(r.trim());for(let o of n){let i=o.indexOf("=");if(i===-1)continue;let l=o.slice(0,i).trim(),d=o.slice(i+1).trim();d.startsWith("{")?e[l]=Ke(d):d.startsWith("[")?e[l]=Ne(d):e[l]=Ye(d)}return e},Ne=s=>{let e=[],t=s.slice(1,-1).trim();if(!t)return e;let n=[],r="",c=0,p=!1,a="";for(let o=0;o<t.length;o++){let i=t[o];if(!p&&(i==='"'||i==="'")?(p=!0,a=i):p&&i===a&&t[o-1]!=="\\"&&(p=!1),!p){if(i==="{"||i==="[")c++;else if(i==="}"||i==="]")c--;else if(i===","&&c===0){n.push(r.trim()),r="";continue}}r+=i}r.trim()&&n.push(r.trim());for(let o of n){let i=o.trim();i.startsWith("{")?e.push(Ke(i)):i.startsWith("[")?e.push(Ne(i)):e.push(Ye(i))}return e},Ht=(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},Re=(s,e)=>{let t=s;for(let n of e)(!(n in t)||typeof t[n]!="object")&&(t[n]={}),t=t[n];return t},Ze=s=>{let e={},t=s.split(`
5
- `),n=[],r=null,c=null,p=null,a=null;for(let o=0;o<t.length;o++){let i=t[o];if(p!==null&&a!==null){if(p+=i,i.includes("]")){let f=0,y=-1;for(let v=0;v<p.length;v++)if(p[v]==="[")f++;else if(p[v]==="]"&&(f--,f===0)){y=v;break}if(y!==-1){let v=p.slice(0,y+1),D=Ne(v);if(c)c[a]=D;else{let w=[...n,a];Ht(e,w,D)}p=null,a=null}}continue}let l=i.indexOf("#");if(l!==-1){let f=!1,y="";for(let v=0;v<l;v++){let D=i[v];!f&&(D==='"'||D==="'")?(f=!0,y=D):f&&D===y&&i[v-1]!=="\\"&&(f=!1)}f||(i=i.slice(0,l))}if(i=i.trim(),!i)continue;if(i.startsWith("[[")&&i.endsWith("]]")){if(c&&r){let f=Re(e,r.slice(0,-1)),y=r[r.length-1];Array.isArray(f[y])||(f[y]=[]),f[y].push(c)}r=i.slice(2,-2).split("."),c={},n=[];continue}if(i.startsWith("[")&&i.endsWith("]")){if(c&&r){let f=Re(e,r.slice(0,-1)),y=r[r.length-1];Array.isArray(f[y])||(f[y]=[]),f[y].push(c),c=null,r=null}n=i.slice(1,-1).split("."),Re(e,n);continue}let d=i.indexOf("=");if(d===-1)continue;let m=i.slice(0,d).trim(),u=i.slice(d+1).trim();if(u.startsWith("[")&&!u.endsWith("]")){p=u,a=m;continue}let g;if(u.startsWith("{")?g=Ke(u):u.startsWith("[")?g=Ne(u):g=Ye(u),c)c[m]=g;else{let f=[...n,m];Ht(e,f,g)}}if(c&&r){let o=Re(e,r.slice(0,-1)),i=r[r.length-1];Array.isArray(o[i])||(o[i]=[]),o[i].push(c)}return e}});var re,fe,Qe,gr,fr,Bt,Yt=h(()=>{"use strict";re=require("fs");zt();fe=s=>s.toLowerCase().replace(/_/g,"-"),Qe=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:"*"}},gr=s=>{let e=[];try{let t=Ze(s);if(t.project?.dependencies)for(let n of t.project.dependencies){let{name:r,specifier:c}=Qe(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}=Qe(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:p}=Qe(r);e.push({name:c,specifier:p,group:"devDependencies"})}}catch{}return e},fr=s=>{let e={},t=null;try{let n=Ze(s);if(n.package)for(let r of n.package){let c=fe(r.name);r.source?.virtual&&(t=c);let p=r.dependencies?.map(a=>fe(a.name))||[];e[c]={name:r.name,version:r.version,dependencies:p}}}catch{}return{packages:e,projectName:t}},Bt=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=(o,i,l,d,m,u)=>{let g=n.get(o);g?g.versions.push({resolved:d,specifier:u,source:m}):n.set(o,{id:o,name:i,ecosystem:l,versions:[{resolved:d,specifier:u,source:m}]})};n.set("pypi:uv",{id:"pypi:uv",name:"uv",ecosystem:"system",versions:[]});let p=(0,re.readFileSync)(e,"utf-8"),a=gr(p);for(let o of a)r.add(fe(o.name));if((0,re.existsSync)(t)){let o=(0,re.readFileSync)(t,"utf-8"),i=fr(o);for(let l of a){let d=fe(l.name),m=i.packages[d];m&&c(`pypi:${d}`,m.name,"pypi",m.version,`.#${l.group}`,l.specifier)}for(let[l,d]of Object.entries(i.packages))if(!(l===i.projectName||r.has(l))){for(let[,m]of Object.entries(i.packages))if(m.dependencies.includes(l)){let u=`uv.lock:${m.name}@${m.version}`;c(`pypi:${l}`,d.name,"pypi",d.version,u,"*")}}}else for(let o of a){let i=fe(o.name);c(`pypi:${i}`,o.name,"pypi",o.specifier,`.#${o.group}`,o.specifier)}return Array.from(n.values()).sort((o,i)=>o.name.localeCompare(i.name))}});var Kt,Zt,Qt,Xt=h(()=>{"use strict";Kt=F(require("fs"),1);H();Ut();Yt();Zt=N({name:"uv",actions:async s=>{let e=Kt.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");return!e&&!t?[]:Bt(s)},outdatedDependencies:async(s,e)=>{if(!s.rootFiles.includes("pyproject.toml"))return[];let n=await Zt.dependencies?.(s);return n?qt(n,e):[]}}),Qt=Zt});var hr,es,ts=h(()=>{"use strict";hr=s=>{let e=s.split(`
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(l=>l.trim().replace(/"|:/g,"")),p=r[1]?.match(/version "(.+)"/)?.[1],a=r[2]?.match(/resolved "(.+)"/)?.[1];if(!p||!a)continue;let o={},i=!1;for(let l=3;l<r.length;l++){let d=r[l];if(d.trim()==="dependencies:"){i=!0;continue}if(i&&d.startsWith(" ")){let m=d.trim().match(/^"?([^"\s]+)"?\s+"?([^"]+)"?$/);m&&(o[m[1]]=m[2])}else i&&!d.startsWith(" ")&&(i=!1)}for(let l of c)l&&(t[l]={version:p,resolved:a,dependencies:Object.keys(o).length>0?o:void 0})}return{type:"success",object:t}},es=s=>{let e={},t=hr(s),n=new Map;for(let[r,c]of Object.entries(t.object)){let p=/^(@?.+)@(.+)$/,[,a,o]=r.match(p)||[];a&&(n.has(a)||n.set(a,[]),n.get(a)?.push({version:c.version,specifier:o,deps:c.dependencies}))}for(let[r,c]of n.entries()){e[r]||(e[r]={versions:{}});for(let p of c)e[r].versions[p.version]||(e[r].versions[p.version]={}),e[r].versions[p.version]["yarn.lock"]=p.specifier;e[r].versions=Object.fromEntries(Object.entries(e[r].versions).sort((p,a)=>p[0].localeCompare(a[0],void 0,{numeric:!0})))}for(let[r,c]of n.entries())for(let p of c){if(!p.deps)continue;let a=`${r}@${p.version}`;for(let[o,i]of Object.entries(p.deps)){e[o]||(e[o]={versions:{}});let l=n.get(o);if(!l)continue;let m=l.find(u=>u.specifier===i)?.version||l[0]?.version;if(m){e[o].versions[m]||(e[o].versions[m]={});let u=`yarn.lock:${a}`;e[o].versions[m][u]=i}}}return{dependencies:e}}});function yr(s){return s.includes("__metadata:")}function vr(s){let e=s.match(/^(.+)@npm:/);if(e)return e[1];let t=s.lastIndexOf("@");return t>0?s.slice(0,t):s}var z,ss,ns,rs,os=h(()=>{"use strict";z=require("fs"),ss=require("yaml");He();me();ts();H();ns=N({name:"yarn",actions:async s=>{let e=s.rootFiles.includes("package.json"),t=s.rootFiles.includes("yarn.lock");if(!(e&&t))return{};let c=V(s)?.scripts||{};return{...Object.entries(c).map(([a,o])=>[a,`yarn run ${a}`]).reduce((a,[o,i])=>(a[o]=[i],a),{}),install:["yarn install"],outdated:["yarn outdated"]}},dependencies:async s=>{let e=`${s.path}/yarn.lock`,t=`${s.path}/package.json`;if(!(0,z.existsSync)(e)||!(0,z.existsSync)(t))return[];let n=new Map,r=new Set,c=(u,g,f,y,v,D)=>{let w=n.get(u);w?w.versions.push({resolved:y,specifier:D,source:v}):n.set(u,{id:u,name:g,ecosystem:f,versions:[{resolved:y,specifier:D,source:v}]})};n.set("npm:yarn",{id:"npm:yarn",name:"yarn",ecosystem:"system",versions:[]});let p=(0,z.readFileSync)(e,"utf-8"),a=yr(p),o=new Map,i=new Map,l=null;if(a){let u=(0,ss.parse)(p);for(let[g,f]of Object.entries(u)){if(g==="__metadata"||!f?.version||typeof f.version!="string")continue;let y=vr(g),v=f;o.has(y)||o.set(y,new Map);let D=g.match(/@npm:(.+)$/);D&&o.get(y)?.set(D[1],f.version),v.dependencies&&i.set(`${y}@${v.version}`,v.dependencies)}}else{l=es(p);for(let[u,g]of Object.entries(l.dependencies)){o.has(u)||o.set(u,new Map);for(let[f,y]of Object.entries(g.versions)){let v=y["yarn.lock"];v&&o.get(u)?.set(v,f)}}}let d=[t],m=s.findFilesByName("package.json");d.push(...m);for(let u of d)try{let g=(0,z.readFileSync)(u,"utf-8"),f=JSON.parse(g),y=".";u!==t&&(y=u.replace(`${s.path}/`,"").replace("/package.json",""));let v=(D,w)=>{if(D)for(let[R,T]of Object.entries(D)){r.add(R);let le=o.get(R),K=T;if(le){let De=le.get(T);if(De)K=De;else{let Se=le.values().next().value;Se&&(K=Se)}}c(`npm:${R}`,R,"npm",K,`${y}#${w}`,T)}};v(f.dependencies,"dependencies"),v(f.devDependencies,"devDependencies")}catch{}if(a){for(let[u,g]of i.entries())for(let[f,y]of Object.entries(g))if(!r.has(f)){let v=o.get(f),D=y;if(v){let R=v.get(y);if(R)D=R;else{let T=v.values().next().value;T&&(D=T)}}let w=`yarn.lock:${u}`;c(`npm:${f}`,f,"npm",D,w,y)}}else if(l){for(let[u,g]of Object.entries(l.dependencies))if(!r.has(u))for(let[f,y]of Object.entries(g.versions))for(let[v,D]of Object.entries(y))v.startsWith("yarn.lock:")&&c(`npm:${u}`,u,"npm",f,v,D)}return Array.from(n.values()).sort((u,g)=>u.name.localeCompare(g.name))},outdatedDependencies:async(s,e)=>{if(!(0,z.existsSync)(`${s.path}/yarn.lock`))return[];let t=await ns.dependencies?.(s);return t?Oe(t,e):[]}}),rs=ns});var _,he=h(()=>{"use strict";yt();Dt();Ct();Vt();Xt();os();_={deno:ht,npm:bt,pnpm:xt,ruby:Wt,uv:Qt,yarn:rs}});var is,cs=h(()=>{"use strict";he();qe();is=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(_)){let r=await n.actions(s);e=xe(e,r)}return e}});var k,br,Dr,ni,Sr,as,ls=h(()=>{"use strict";k=require("zod");he();br=k.z.object({resolved:k.z.string().describe("The resolved version of the dependency"),specifier:k.z.string().describe("The version constraint/specifier used"),source:k.z.string().describe("The source file/path of the dependency"),wanted:k.z.string().describe("The wanted version based on semver rules").optional(),latest:k.z.string().describe("The latest available version of the dependency").optional()}),Dr=k.z.object({id:k.z.string().describe("Unique identifier for the ecosystem / dependency"),name:k.z.string().describe("Name of the dependency"),versions:k.z.array(br).describe("Map of resolved versions to sources. Each source maps a package path to its version specifier."),ecosystem:k.z.string().describe("Ecosystem of the dependency (e.g., npm, rubygems, pip)")}),ni=Dr.extend({wanted:k.z.string().describe("Latest version compatible with the specifier (semver)"),latest:k.z.string().describe("Absolute latest version available"),specifier:k.z.string().describe("The version specifier from package manifest"),isDevDependency:k.z.boolean().describe("Whether this is a dev dependency")}),Sr=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())},as=async s=>{let e=[];for(let[t,n]of Object.entries(_)){let r=n.dependencies?await n.dependencies(s):[];e.push(...r)}return Sr(e)}});var Xe,J,Le=h(()=>{"use strict";Xe=F(require("fs"),1);cs();ue();ls();he();J=class{slug;config;constructor(e){this.slug=e,this.config=ft(e)}get name(){return this.config.name}get path(){return`${E().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 as(this)}async outdatedDependencies(e){let t=[];for(let n of Object.values(_))if(n.outdatedDependencies){let r=await n.outdatedDependencies(this,e);t.push(...r)}return t}get actions(){return is(this)}get rootFiles(){return Xe.default.readdirSync(this.path)}findFilesByName(e){let t=[],n=r=>{let c=Xe.default.readdirSync(r,{withFileTypes:!0});for(let p of c)p.isDirectory()?p.name!=="node_modules"&&n(`${r}/${p.name}`):p.name===e&&t.push(`${r}/${p.name}`)};return n(this.path),t}}});var ds,ps=h(()=>{ds={name:"denvig",version:"0.4.0",license:"MIT",description:"A CLI tool to consistently manage cross-discipline projects",bin:{denvig:"./dist/cli.cjs"},type:"module",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",yaml:"^2.8.2",zod:"^4.3.5"},devDependencies:{"@biomejs/biome":"^2.3.11","@types/minimist":"^1.2.5","@types/node":"^24",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 ds.version}var Ae=h(()=>{"use strict";ps()});var b,x=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 ms={};C(ms,{runCommand:()=>Pr});var us,Pr,gs=h(()=>{"use strict";us=require("child_process");x();Ae();Pr=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 p in n){if(!n[p])continue;let a=n[p];for(let o of a){let i=o.split(`
9
- `),l=i[0],d=i.slice(1);console.log(` ${p}: ${l}`);for(let m of d)m.trim()&&console.log(`${" ".repeat(p.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 p of r){let a=`${p} ${t.join(" ")}`.trim();console.log(`$ ${a}`);let o={...process.env,DENVIG_PROJECT:s.slug},i=process.stdout.isTTY&&process.stdin.isTTY,l,d;i?process.platform==="darwin"?(l="script",d=["-q","/dev/null","sh","-c",a]):(l="script",d=["-q","-c",a,"/dev/null"]):(l="sh",d=["-c",a]);let m=(0,us.spawn)(l,d,{cwd:s.path,env:o,stdio:"inherit"}),u=await new Promise(g=>{m.on("close",f=>{g({success:f===0})})});u.success||(c=u)}return c}})});var Ie,fs=h(()=>{"use strict";Ie=s=>s.replace(process.env.HOME||"/root","~")});var vs={};C(vs,{configCommand:()=>$r});var ys,hs,$r,bs=h(()=>{"use strict";ys=require("yaml");x();ue();fs();hs=s=>{let e=Object.fromEntries(Object.entries({...s,$sources:void 0}).filter(([t,n])=>n!==void 0));(0,ys.stringify)(e,{indent:2,lineWidth:80}).trim().split(`
10
- `).map(t=>console.log(` ${Ie(t)}`))},$r=new b({name:"config",description:"Display the current global and project configuration.",usage:"config",example:"config",args:[],flags:[],handler:({project:s})=>{let e=E(),t=s.config;return console.log("Denvig Config"),console.log(""),console.log(`Global: ${e.$sources.map(n=>Ie(n)).join(", ")||"default"}`),hs(e),console.log(""),console.log(`Project: ${s.config.$sources.map(n=>Ie(n)).join(", ")||"default"}`),console.log(` slug: ${s.slug}`),hs(t),{success:!0,message:"Configuration displayed."}}})});var Ds={};C(Ds,{pluginsCommand:()=>wr});var wr,Ss=h(()=>{"use strict";x();he();wr=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(_)){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 js={};C(js,{versionCommand:()=>kr});var kr,Ps=h(()=>{"use strict";x();Ae();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 $s={};C($s,{infoCommand:()=>xr});var xr,ws=h(()=>{"use strict";x();xr=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 p=JSON.parse(c.readFileSync(r,"utf-8"));p.repository?.url&&(e=p.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 $,ie,ks,ce,ye=h(()=>{"use strict";$={reset:"\x1B[0m",white:"\x1B[37m",grey:"\x1B[90m",green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",bold:"\x1B[1m"},ie=s=>s.replace(/\x1b\[[0-9;]*m/g,""),ks=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},ce=s=>{let{columns:e,data:t,tree:n}=s,r=e.filter(i=>i.visible!==!1);if(t.length===0||r.length===0)return[];let c=r.map((i,l)=>{let d=i.header.length,m=Math.max(...t.map(u=>{let g=i.accessor(u);if(n&&l===0){let f={depth:n.getDepth(u),isLast:n.getIsLast(u),hasChildren:n.getHasChildren(u),parentPath:n.getParentPath(u)};g=ks(f)+ie(g)}return ie(g).length}));return Math.max(d,m)}),p=[],a=r.map((i,l)=>i.header.padEnd(c[l]));p.push(a.join(" "));let o=c.reduce((i,l)=>i+l,0)+(r.length-1)*2;p.push("-".repeat(o));for(let i of t){let d=(n?n.getDepth(i):0)>0,m=r.map((u,g)=>{let f=u.accessor(i),y=c[g];if(n&&g===0){let w={depth:n.getDepth(i),isLast:n.getIsLast(i),hasChildren:n.getHasChildren(i),parentPath:n.getParentPath(i)},R=ks(w),T=d?`${$.grey}${ie(f)}${$.reset}`:f;f=R+T}else if(d&&!u.format){let w=ie(f);w.trim()&&(f=`${$.grey}${w}${$.reset}`)}let v=ie(f).length,D=y-v;if(u.format){let R=ie(f).padEnd(y);return u.format(R,i)}return f+" ".repeat(Math.max(0,D))});p.push(m.join(" "))}return p}});var ve,xs,Cs=h(()=>{"use strict";ve=F(require("fs"),1);ue();xs=()=>{let e=E().codeRootDir,t=[];if(!ve.default.existsSync(e))return t;let n=ve.default.readdirSync(e,{withFileTypes:!0});for(let r of n){if(!r.isDirectory()||r.name.startsWith("."))continue;let c=`${e}/${r.name}`,p=ve.default.readdirSync(c,{withFileTypes:!0});for(let a of p){if(!a.isDirectory()||a.name.startsWith("."))continue;let i=`${`${c}/${a.name}`}/.denvig.yml`;ve.default.existsSync(i)&&t.push(`${r.name}/${a.name}`)}}return t.sort()}});function Cr(s){let e={},t=s.split(`
11
- `);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 p=r.slice(0,c).trim(),a=r.slice(c+1).trim();(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),p&&(e[p]=a)}return e}async function Rs(s){try{let e=await(0,Os.readFile)(s,"utf-8");return Cr(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 Os,Ns=h(()=>{"use strict";Os=require("fs/promises")});function Te(){return`gui/${process.getuid?.()??501}`}async function Or(s){try{let e=Te(),{stdout:t,stderr:n}=await ae(`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 Rr(s){try{let e=Te(),{stdout:t,stderr:n}=await ae(`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 Nr(s){try{let{stdout:e,stderr:t}=await ae(`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 Lr(s){try{let{stdout:e,stderr:t}=await ae(`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 Ar(s){try{let e=Te(),{stdout:t}=await ae(`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 Ir(s){try{let{stdout:e}=await ae("launchctl list"),n=e.trim().split(`
12
- `).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 Ls,As,ae,G,Is=h(()=>{"use strict";Ls=require("child_process"),As=require("util"),ae=(0,As.promisify)(Ls.exec);G={bootstrap:Or,bootout:Rr,start:Nr,stop:Lr,print:Ar,list:Ir,getUserDomain:Te}});function B(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Ts(s){let{label:e,command:t,workingDirectory:n,environmentVariables:r={},standardOutPath:c,standardErrorPath:p,keepAlive:a}=s,o=Object.entries(r).map(([i,l])=>` <key>${B(i)}</key>
13
- <string>${B(l)}</string>`).join(`
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}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>${B(e)}</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>${B(t.trim())}</string>
26
+ <string>${pe(a)}</string>
27
27
  </array>
28
28
 
29
29
  <key>WorkingDirectory</key>
30
- <string>${B(n)}</string>
30
+ <string>${pe(n)}</string>
31
31
 
32
32
  <key>EnvironmentVariables</key>
33
33
  <dict>
34
- ${o}
34
+ ${i}
35
35
  </dict>
36
36
 
37
37
  <key>StandardOutPath</key>
38
- <string>${B(c)}</string>
39
-
40
- <key>StandardErrorPath</key>
41
- <string>${B(p)}</string>
38
+ <string>${pe(c)}</string>
42
39
 
43
40
  <key>KeepAlive</key>
44
- <${a?"true":"false"}/>
41
+ <${l?"true":"false"}/>
45
42
 
46
43
  <key>RunAtLoad</key>
47
44
  <false/>
48
45
  </dict>
49
46
  </plist>
50
- `}var Fs=h(()=>{"use strict"});var W,et,q,O,Y=h(()=>{"use strict";W=require("fs/promises"),et=require("os"),q=require("path");Ns();Is();Fs();O=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),p=this.resolveServiceCwd(t),a={DENVIG_PROJECT:this.project.slug,DENVIG_SERVICE:e};if(t.envFile)try{let i=(0,q.resolve)(this.project.path,t.envFile),l=await Rs(i);Object.assign(a,l)}catch(i){let l=i instanceof Error?i.message:"Unknown error";return{name:e,success:!1,message:`Failed to load environment file: ${l}`}}t.env&&Object.assign(a,t.env),t.http?.port!==void 0&&(a.PORT=t.http.port.toString());let o=Ts({label:n,command:t.command,workingDirectory:p,environmentVariables:a,standardOutPath:this.getLogPath(e,"stdout"),standardErrorPath:this.getLogPath(e,"stderr"),keepAlive:t.keepAlive??!0});if(await(0,W.writeFile)(c,o,"utf-8"),r){let i=await G.bootout(n);if(!i.success)return{name:e,success:!1,message:`Failed to bootout service: ${i.output}`};await new Promise(d=>setTimeout(d,1e3));let l=await G.bootstrap(c);if(!l.success)return{name:e,success:!1,message:`Failed to bootstrap service: ${l.output}`}}else{let i=await G.bootstrap(c);if(!i.success)return{name:e,success:!1,message:`Failed to bootstrap service: ${i.output}`}}try{let i=new Date().toISOString();await(0,W.appendFile)(this.getLogPath(e,"stdout"),`[${i}] Service Started
51
- `,"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 G.bootout(n);if(!c.success)return{name:e,success:!1,message:`Failed to stop service: ${c.output}`};try{let p=new Date().toISOString();await(0,W.appendFile)(this.getLogPath(e,"stdout"),`[${p}] Service Stopped
52
- `,"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 G.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=[];for(let n of Object.keys(e))t.push(await this.startService(n));return t}async stopAll(){let e=this.project.config.services||{},t=[];for(let n of Object.keys(e))await this.isServiceBootstrapped(n)&&t.push(await this.stopService(n));return t}async restartAll(){let e=this.project.config.services||{},t=[];for(let n of Object.keys(e))await this.isServiceBootstrapped(n)&&t.push(await this.restartService(n));return t}async isServiceBootstrapped(e){let t=this.getServiceLabel(e);return await G.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,q.resolve)((0,et.homedir)(),".denvig")}getPlistPath(e){let t=this.getServiceLabel(e);return(0,q.resolve)((0,et.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,q.resolve)(this.getDenvigHomeDir(),"logs",`${n}__${r}${c}.log`)}async ensureDenvigDirectories(){let e=this.getDenvigHomeDir();await(0,W.mkdir)((0,q.resolve)(e,"logs"),{recursive:!0})}async getRecentLogs(e,t){try{let n=this.getLogPath(e,"stdout");return(await(0,W.readFile)(n,"utf-8")).trim().split(`
53
- `).slice(-t)}catch{return[]}}resolveServiceCwd(e){return(0,q.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 getServiceResponse(e,t){let n=this.getServiceConfig(e);if(!n)return null;let r=this.getServiceLabel(e),c=await G.print(r),p="stopped",a=null,o=null;c&&(a=c.pid??null,o=c.lastExitCode??null,c.state==="running"&&(o!==null&&o!==0?p="error":p="running"));let i={name:e,project:this.project.slug,status:p,pid:a,url:this.getServiceUrl(e),command:n.command,cwd:this.resolveServiceCwd(n),logPath:this.getLogPath(e,"stdout"),envFile:n.envFile?(0,q.resolve)(this.project.path,n.envFile):null,lastExitCode:o};return t?.includeLogs&&(i.logs=await this.getRecentLogs(e,t.logLines??20)),i}}});var Es={};C(Es,{servicesCommand:()=>Fr});var Tr,Fr,Ws=h(()=>{"use strict";x();ye();Le();Cs();Y();Tr=s=>{switch(s){case"running":return"\u{1F7E2}";case"error":return"\u{1F534}";default:return"\u25EF"}},Fr=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=xs();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=[];for(let o of r){let i=new J(o),l=new O(i),d=await l.listServices();for(let m of d){let u=await l.getServiceResponse(m.name);u&&c.push(u)}}if(c.length===0)return console.log(t==="json"?JSON.stringify([]):"No services configured across any project."),{success:!0,message:"No services configured."};let p=c.sort((o,i)=>{let l=o.project===n,d=i.project===n;if(l&&!d)return-1;if(!l&&d)return 1;let m=o.project.localeCompare(i.project);return m!==0?m:o.name.localeCompare(i.name)});if(t==="json")return console.log(JSON.stringify(p)),{success:!0,message:"Services listed successfully."};let a=ce({columns:[{header:"",accessor:o=>Tr(o.status)},{header:"Project",accessor:o=>o.project},{header:"Name",accessor:o=>o.name},{header:"URL",accessor:o=>o.url||"-"}],data:p});for(let o of a)console.log(o);return console.log(""),console.log(`${c.length} service${c.length===1?"":"s"} configured across ${r.length} project${r.length===1?"":"s"}`),{success:!0,message:"Services listed successfully."}}})});var Er,U,be=h(()=>{"use strict";Le();Y();Er=(s,e)=>{if(!s.includes("/"))return{projectSlug:e,serviceName:s};let t=s.split("/"),n=t.pop();return{projectSlug:t.join("/"),serviceName:n}},U=(s,e)=>{let{projectSlug:t,serviceName:n}=Er(s,e.slug),r=t===e.slug?e:new J(t),c=new O(r);return{project:r,manager:c,serviceName:n}}});var Ms={};C(Ms,{servicesStartCommand:()=>Wr});var Vs,Wr,_s=h(()=>{"use strict";Vs=require("zod");x();be();Y();Wr=new b({name:"services:start",description:"Start all services or a specific service",usage:"services start [name] [--format table|json]",example:"services start api or services start marcqualie/api/dev",args:[{name:"name",description:"Service name or project/service path (e.g., hello or marcqualie/api/dev)",required:!1,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=Vs.z.string().parse(e.name),r=t.format;if(n){let{manager:l,serviceName:d,project:m}=U(n,s),u=m.slug!==s.slug?`${m.slug}/`:"";r!=="json"&&console.log(`Starting ${u}${d}...`);let g=await l.startService(d);if(!g.success)return r==="json"?console.log(JSON.stringify({success:!1,service:d,project:m.slug,message:g.message})):console.error(`\u2717 Failed to start ${u}${d}: ${g.message}`),{success:!1,message:g.message};await new Promise(y=>setTimeout(y,2e3));let f=await l.getServiceResponse(d,{includeLogs:!0});if(f?.status==="running"){if(r==="json")console.log(JSON.stringify(f));else{let y=f.url?` \u2192 ${f.url}`:"";console.log(`\u2713 ${u}${d} started successfully${y}`)}return{success:!0,message:"Service started successfully."}}if(r==="json")console.log(JSON.stringify(f));else if(console.error(`\u2717 ${u}${d} failed to start`),f?.logs&&f.logs.length>0){console.error(""),console.error("Recent logs:");for(let y of f.logs)console.error(` ${y}`)}return{success:!1,message:"Service failed to start."}}let c=new O(s);if((await c.listServices()).length===0)return console.log(r==="json"?JSON.stringify({success:!0,project:s.slug,services:[]}):"No services configured in this project."),{success:!0,message:"No services to start."};let a=await c.startAll();await new Promise(l=>setTimeout(l,2e3));let o=[],i=!1;for(let l of a){let d=await c.getServiceResponse(l.name,{includeLogs:!l.success});if(d){if(o.push(d),!l.success||d.status!=="running"){if(i=!0,r!=="json"){if(!l.success)console.error(`Starting ${l.name}... \u2717`),console.error(` ${l.message}`);else if(console.error(`Starting ${l.name}... \u2717 (failed to start)`),d.logs&&d.logs.length>0){console.error(" Recent logs:");for(let m of d.logs.slice(-3))console.error(` ${m}`)}}}else if(r!=="json"){let m=d.url?` \u2192 ${d.url}`:"";console.log(`Starting ${l.name}... \u2713${m}`)}}}return r==="json"?console.log(JSON.stringify({success:!i,project:s.slug,services:o})):(console.log(""),console.log(i?"Some services failed to start":"All services started successfully")),i?{success:!1,message:"Some services failed to start."}:{success:!0,message:"All services started successfully."}}})});var Js={};C(Js,{servicesStopCommand:()=>Vr});var Vr,Gs=h(()=>{"use strict";x();be();Y();Vr=new b({name:"services:stop",description:"Stop all services or a specific service",usage:"services stop [name] [--format table|json]",example:"services stop api or services stop marcqualie/api/dev",args:[{name:"name",description:"Service name or project/service path (e.g., hello or marcqualie/api/dev)",required:!1,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=t.format;if(typeof e.name=="string"&&e.name){let{manager:o,serviceName:i,project:l}=U(e.name,s),d=l.slug!==s.slug?`${l.slug}/`:"";n!=="json"&&console.log(`Stopping ${d}${i}...`);let m=await o.stopService(i);if(!m.success)return n==="json"?console.log(JSON.stringify({success:!1,service:i,project:l.slug,message:m.message})):console.error(`\u2717 Failed to stop ${d}${i}: ${m.message}`),{success:!1,message:m.message};let u=await o.getServiceResponse(i);return console.log(n==="json"?JSON.stringify(u):`\u2713 ${d}${i} stopped successfully`),{success:!0,message:"Service stopped successfully."}}let r=new O(s),c=await r.stopAll();if(c.length===0)return console.log(n==="json"?JSON.stringify({success:!0,project:s.slug,services:[]}):"No running services to stop."),{success:!0,message:"No services to stop."};let p=[],a=!1;for(let o of c){let i=await r.getServiceResponse(o.name);i&&(p.push(i),o.success?n!=="json"&&console.log(`Stopping ${o.name}... \u2713`):(a=!0,n!=="json"&&(console.error(`Stopping ${o.name}... \u2717`),console.error(` ${o.message}`))))}return n==="json"?console.log(JSON.stringify({success:!a,project:s.slug,services:p})):(console.log(""),console.log(a?"Some services failed to stop":"All services stopped successfully")),a?{success:!1,message:"Some services failed to stop."}:{success:!0,message:"All services stopped successfully."}}})});var Us={};C(Us,{servicesRestartCommand:()=>Mr});var qs,Mr,Hs=h(()=>{"use strict";qs=require("zod");x();be();Y();Mr=new b({name:"services:restart",description:"Restart all services or a specific service",usage:"services restart [name] [--format table|json]",example:"services restart api or services restart marcqualie/api/dev",args:[{name:"name",description:"Service name or project/service path (e.g., hello or marcqualie/api/dev)",required:!1,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;if(n){let{manager:i,serviceName:l,project:d}=U(n,s),m=d.slug!==s.slug?`${d.slug}/`:"";r!=="json"&&console.log(`Restarting ${m}${l}...`);let u=await i.restartService(l);if(!u.success)return r==="json"?console.log(JSON.stringify({success:!1,service:l,project:d.slug,message:u.message})):console.error(`\u2717 Failed to restart ${m}${l}: ${u.message}`),{success:!1,message:u.message};await new Promise(f=>setTimeout(f,2e3));let g=await i.getServiceResponse(l,{includeLogs:!0});if(g?.status==="running"){if(r==="json")console.log(JSON.stringify(g));else{let f=g.url?` \u2192 ${g.url}`:"";console.log(`\u2713 ${m}${l} restarted successfully${f}`)}return{success:!0,message:"Service restarted successfully."}}if(r==="json")console.log(JSON.stringify(g));else if(console.error(`\u2717 ${m}${l} failed to start`),g?.logs&&g.logs.length>0){console.error(""),console.error("Recent logs:");for(let f of g.logs)console.error(` ${f}`)}return{success:!1,message:"Service failed to start."}}let c=new O(s),p=await c.restartAll();if(p.length===0)return console.log(r==="json"?JSON.stringify({success:!0,project:s.slug,services:[]}):"No running services to restart."),{success:!0,message:"No services to restart."};await new Promise(i=>setTimeout(i,2e3));let a=[],o=!1;for(let i of p){let l=await c.getServiceResponse(i.name,{includeLogs:!i.success});if(l){if(a.push(l),!i.success||l.status!=="running"){if(o=!0,r!=="json"){if(!i.success)console.error(`Restarting ${i.name}... \u2717`),console.error(` ${i.message}`);else if(console.error(`Restarting ${i.name}... \u2717 (failed to start)`),l.logs&&l.logs.length>0){console.error(" Recent logs:");for(let d of l.logs.slice(-3))console.error(` ${d}`)}}}else if(r!=="json"){let d=l.url?` \u2192 ${l.url}`:"";console.log(`Restarting ${i.name}... \u2713${d}`)}}}return r==="json"?console.log(JSON.stringify({success:!o,project:s.slug,services:a})):(console.log(""),console.log(o?"Some services failed to restart":"All services restarted successfully")),o?{success:!1,message:"Some services failed to restart."}:{success:!0,message:"All services restarted successfully."}}})});var Ys={};C(Ys,{servicesStatusCommand:()=>_r});var zs,Fe,Bs,_r,Ks=h(()=>{"use strict";zs=require("fs"),Fe=require("os"),Bs=require("zod");x();be();_r=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/api/dev",args:[{name:"name",description:"Service name or project/service path (e.g., hello or marcqualie/api/dev)",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:p,project:a}=U(n,s),o=await c.getServiceResponse(p,{includeLogs:!0});if(!o){let m=a.slug!==s.slug?` in project "${a.slug}"`:"";return r==="json"?console.log(JSON.stringify({success:!1,service:p,project:a.slug,message:`Service "${p}" not found in configuration${m}`})):console.error(`Service "${p}" not found in configuration${m}`),{success:!1,message:`Service "${p}" not found.`}}if(r==="json")return console.log(JSON.stringify(o)),{success:!0,message:"Status retrieved successfully."};let i=a.slug!==s.slug?`${a.slug}/`:"",l=o.status==="running"?"Running":o.status==="error"?"Error":"Stopped";console.log(`Service: ${i}${o.name}`),console.log(`Status: ${l}`),o.status==="running"&&o.pid&&console.log(`PID: ${o.pid}`),console.log(`Command: ${o.command}`),console.log(`CWD: ${o.cwd.replace((0,Fe.homedir)(),"~")}`),console.log(`Logs: ${o.logPath.replace((0,Fe.homedir)(),"~")}`);let d=c.getPlistPath(p);if((0,zs.existsSync)(d)&&console.log(`Plist: ${d.replace((0,Fe.homedir)(),"~")}`),o.lastExitCode!==null&&o.lastExitCode!==0&&o.status!=="running"&&console.log(`Last exit code: ${o.lastExitCode}`),o.logs&&o.logs.length>0){console.log(""),console.log("Recent logs (last 10 lines):");for(let m of o.logs.slice(-10))console.log(` ${m}`)}return{success:!0,message:"Status retrieved successfully."}}})});var Xs={};C(Xs,{logsCommand:()=>Jr});var Zs,Qs,Jr,en=h(()=>{"use strict";Zs=require("child_process"),Qs=require("fs/promises");x();Y();Jr=new b({name:"logs",description:"Show logs for a service",usage:"logs <name> [-n <lines>] [--follow]",example:"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 O(s),r=e.name,c=t.lines??t.n??10,p=!!t.follow,a=n.getLogPath(r,"stdout");if(p){let o=["-n",`${c}`,"-f",a];return(0,Zs.spawn)("tail",o,{stdio:"inherit"}),new Promise(()=>{})}try{let l=(await(0,Qs.readFile)(a,"utf-8")).trim().split(`
54
- `).filter(Boolean).slice(-c);for(let d of l)console.log(d);return{success:!0}}catch(o){return console.error(`Failed to read logs for ${r}:`,o instanceof Error?o.message:o),{success:!1,message:"failed to read logs"}}}})});var tn,tt,sn,nn=h(()=>{"use strict";tn=require("crypto"),tt=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}`},sn=s=>{let e=tt(s),t=(0,tn.createHash)("sha256").update(e).digest("hex");return{id:e,hash:t}}});var rn={};C(rn,{internalsResourceHashCommand:()=>Gr,internalsResourceIdCommand:()=>qr});var Gr,qr,on=h(()=>{"use strict";x();nn();Gr=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 p=sn({project:s,workspace:r,resource:c});return console.log(`${p.id}
55
- ${p.hash}`),{success:!0,message:"Hash generated successfully"}}}),qr=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 p=tt({project:s,workspace:r,resource:c});return console.log(p),{success:!0,message:"ID generated successfully"}}})});var cn,st,nt,Ur,rt,an,ln,ot=h(()=>{"use strict";cn=["pnpm-lock.yaml:","yarn.lock:","Gemfile.lock:","uv.lock:"],st=s=>{for(let e of cn)if(s.startsWith(e)){let n=s.slice(e.length).match(/^([^@]+)@([^(@]+)/);if(n)return{name:n[1],version:n[2]}}return null},nt=s=>cn.some(e=>s.startsWith(e)),Ur=s=>s.endsWith("#dependencies"),rt=s=>s.endsWith("#devDependencies"),an=(s,e,t)=>{let n=new Map;for(let o of s)n.set(o.name,o);let r=[],c=new Set;for(let o of s)if(!(t&&o.ecosystem!==t)){for(let i of o.versions)if(!nt(i.source)){let l=rt(i.source);if(Ur(i.source)||l){let m=`${o.name}@${i.resolved}`;c.has(m)||(c.add(m),r.push({dep:o,version:i.resolved,isDevDependency:l,children:[]}))}}}if(e>0){let o=new Map;for(let l of s)if(!(t&&l.ecosystem!==t))for(let d of l.versions){let m=st(d.source);if(m){let u=`${m.name}@${m.version}`,g=o.get(u)||[];g.some(f=>f.name===l.name)||(g.push(l),o.set(u,g))}}let i=(l,d,m)=>{if(d>=e)return;let u=`${l.dep.name}@${l.version}`;if(m.has(u))return;m.add(u);let g=o.get(u)||[];for(let f of g){let y=f.versions.find(v=>{let D=st(v.source);return D?.name===l.dep.name&&D?.version===l.version});if(y){let v={dep:f,version:y.resolved,isDevDependency:!1,children:[]};l.children.push(v),i(v,d+1,new Set(m))}}l.children.sort((f,y)=>f.dep.name.localeCompare(y.dep.name))};for(let l of r)i(l,0,new Set)}r.sort((o,i)=>{let l=o.dep.ecosystem.localeCompare(i.dep.ecosystem);return l!==0?l:o.dep.name.localeCompare(i.dep.name)});let p=[],a=(o,i,l,d)=>{p.push({name:o.dep.name,version:o.version,ecosystem:o.dep.ecosystem,isDevDependency:o.isDevDependency,depth:i,isLast:l,hasChildren:o.children.length>0,parentPath:[...d]});let m=[...d,l];o.children.forEach((u,g)=>{a(u,i+1,g===o.children.length-1,m)})};return r.forEach((o,i)=>{a(o,0,i===r.length-1,[])}),p},ln=(s,e,t,n)=>{if(!nt(t))return{name:s,version:e,children:[]};let r=[{name:s,version:e}],c=t,p=50,a=0;for(;a<p;){let l=st(c);if(!l)break;r.unshift({name:l.name,version:l.version});let d=n.get(l.name);if(!d)break;let m=d.versions.find(u=>u.resolved===l.version);if(!m||!nt(m.source))break;c=m.source,a++}if(r.length===0)return null;let o={name:r[0].name,version:r[0].version,children:[]},i=o;for(let l=1;l<r.length;l++){let d={name:r[l].name,version:r[l].version,children:[]};i.children.push(d),i=d}return o}});var pn={};C(pn,{depsListCommand:()=>Hr});var Hr,dn=h(()=>{"use strict";x();ot();ye();Hr=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 p=an(c,n,t);if(p.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 o=new Set(p.map(g=>g.ecosystem)).size>1&&!t,i=ce({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:o}],data:p,tree:{getDepth:g=>g.depth,getIsLast:g=>g.isLast,getHasChildren:g=>g.hasChildren,getParentPath:g=>g.parentPath}});for(let g of i)console.log(g);let l=p.filter(g=>g.depth===0),d=l.filter(g=>!g.isDevDependency).length,m=l.filter(g=>g.isDevDependency).length,u=c.length-l.length;return console.log(""),console.log(`${c.length} total (${d} dependencies, ${m} devDependencies, ${u} subdependencies)`),{success:!0,message:"Dependencies listed successfully."}}})});var mn={};C(mn,{depsOutdatedCommand:()=>Yr});var Ee,un,zr,Br,Yr,gn=h(()=>{"use strict";x();ye();Ee=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)}:null},un=(s,e)=>{if(s===e)return $.white;let t=Ee(s),n=Ee(e);return!t||!n?$.white:n.major!==t.major?$.red:n.minor!==t.minor?$.yellow:n.patch!==t.patch?$.green:$.white},zr=(s,e)=>{if(s===e)return null;let t=Ee(s),n=Ee(e);return!t||!n?null:n.major!==t.major?"major":n.minor!==t.minor?"minor":n.patch!==t.patch?"patch":null},Br=(s,e)=>s===null?!1:e==="patch"?s==="patch":e==="minor"?s==="patch"||s==="minor":!1,Yr=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}),o=u=>u.versions[0]?.resolved||"";if(r&&(a=a.filter(u=>u.ecosystem===r)),n&&(a=a.filter(u=>{let g=zr(o(u),u.wanted);return Br(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 i=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(i)),{success:!0,message:"Outdated dependencies listed."};let d=new Set(a.map(u=>u.ecosystem)).size>1&&!r,m=ce({columns:[{header:"Package",accessor:u=>u.name},{header:"",accessor:u=>u.isDevDependency?`${$.grey}(dev)${$.reset}`:" "},{header:"Current",accessor:u=>o(u)},{header:"Wanted",accessor:u=>u.wanted,format:(u,g)=>`${un(o(g),g.wanted)}${u}${$.reset}`},{header:"Latest",accessor:u=>u.latest,format:(u,g)=>`${un(o(g),g.latest)}${u}${$.reset}`},{header:"Ecosystem",accessor:u=>u.ecosystem,visible:d}],data:i});for(let u of m)console.log(u);return{success:!0,message:"Outdated dependencies listed."}}})});var We,Ve,fn=h(()=>{"use strict";ye();We=(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 p=n?"":e+(t?" ":"\u2502 ");for(let a=0;a<s.children.length;a++){let o=s.children[a],i=a===s.children.length-1;r.push(...We(o,p,i,!1))}return r},Ve=(s,e)=>{let t=s.find(n=>n.name===e.name&&n.version===e.version);if(t)for(let n of e.children)Ve(t.children,n);else s.push(e)}});var hn={};C(hn,{depsWhyCommand:()=>Kr});var Kr,yn=h(()=>{"use strict";x();ot();fn();Kr=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(o=>o.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 o of n)c.set(o.name,o);console.log(`${s.name} ${s.path}`),console.log("");let p=[],a=[];for(let o of r.versions){let i=ln(r.name,o.resolved,o.source,c);i&&(c.get(i.name)?.versions.some(m=>rt(m.source))?Ve(a,i):Ve(p,i))}if(p.length>0){console.log("dependencies:");for(let o=0;o<p.length;o++){let i=We(p[o],"",o===p.length-1,!0);for(let l of i)console.log(l)}console.log("")}if(a.length>0){console.log("devDependencies:");for(let o=0;o<a.length;o++){let i=We(a[o],"",o===a.length-1,!0);for(let l of i)console.log(l)}console.log("")}return p.length===0&&a.length===0&&console.log(`Could not determine dependency chain for "${t}".`),{success:!0,message:"Dependency chain shown."}}})});var it=F(require("minimist"),1);ue();Le();Ae();var vn=[{name:"project",description:"The project slug to run against. Defaults to current directory.",required:!1,type:"string",defaultValue:void 0}];async function Zr(){let s=process.argv[2],e=process.argv.slice(2),t=E(),n=process.cwd(),r=(0,it.default)(process.argv.slice(2)).project?.toString()||n.replace(`${t.codeRootDir}/`,"").split("/").slice(0,2).join("/"),c=new J(r),p={outdated:"deps:outdated"};p[s]&&(s=p[s]);let a=["start","stop","restart","status"];if(s==="services"){let S=process.argv[3];S&&a.includes(S)&&(s=`services:${S}`,e=[process.argv[2],...process.argv.slice(4)])}let o=["list","outdated","why"];if(s==="deps"){let S=process.argv[3];S&&o.includes(S)&&(s=`deps:${S}`,e=[process.argv[2],...process.argv.slice(4)])}let i=[...t.quickActions||[],...c?.config?.quickActions||[]].sort();i.includes(s)&&(e=["run",...process.argv.slice(2)],s="run",console.log("> Proxying to denvig run",...process.argv.slice(2)));let{runCommand:l}=await Promise.resolve().then(()=>(gs(),ms)),{configCommand:d}=await Promise.resolve().then(()=>(bs(),vs)),{pluginsCommand:m}=await Promise.resolve().then(()=>(Ss(),Ds)),{versionCommand:u}=await Promise.resolve().then(()=>(Ps(),js)),{infoCommand:g}=await Promise.resolve().then(()=>(ws(),$s)),{servicesCommand:f}=await Promise.resolve().then(()=>(Ws(),Es)),{servicesStartCommand:y}=await Promise.resolve().then(()=>(_s(),Ms)),{servicesStopCommand:v}=await Promise.resolve().then(()=>(Gs(),Js)),{servicesRestartCommand:D}=await Promise.resolve().then(()=>(Hs(),Us)),{servicesStatusCommand:w}=await Promise.resolve().then(()=>(Ks(),Ys)),{logsCommand:R}=await Promise.resolve().then(()=>(en(),Xs)),{internalsResourceHashCommand:T,internalsResourceIdCommand:le}=await Promise.resolve().then(()=>(on(),rn)),{depsListCommand:K}=await Promise.resolve().then(()=>(dn(),pn)),{depsOutdatedCommand:De}=await Promise.resolve().then(()=>(gn(),mn)),{depsWhyCommand:Se}=await Promise.resolve().then(()=>(yn(),hn)),pe={run:l,config:d,plugins:m,version:u,info:g,services:f,"services:start":y,"services:stop":v,"services:restart":D,"services:status":w,logs:R,deps:K,"deps:list":K,"deps:outdated":De,"deps:why":Se,"internals:resource-hash":T,"internals:resource-id":le},je=pe[s],de=(0,it.default)(e),bn=je?.args.reduce((S,j,$e)=>{let we=de._[$e+1];return we!==void 0?S[j.name]=we:j.required&&(console.error(`Missing required argument: ${j.name}`),process.exit(1)),S},{})||{},Dn=de._.slice(je?.args.length+1).map(S=>String(S))||[],ct=[...vn,...je?.flags||[]],Sn=new Set(ct.map(S=>S.name)),jn=ct.reduce((S,j)=>(de[j.name]!==void 0?S[j.name]=de[j.name]:j.defaultValue!==void 0?S[j.name]=j.defaultValue:j.required&&(console.error(`Missing required flag: ${j.name}`),process.exit(1)),S),{}),Pe=[];for(let[S,j]of Object.entries(de))S!=="_"&&!Sn.has(S)&&(j===!0?Pe.push(`--${S}`):j===!1?Pe.push(`--no-${S}`):Pe.push(`--${S}`,String(j)));let Pn=[...Dn,...Pe];if(!s){console.log(`Denvig v${oe()}`),console.log(""),console.log("Usage: denvig <command> [args] [flags]"),console.log(""),console.log("Available commands:"),Object.keys(pe).forEach(j=>{j.startsWith("internals:")||console.log(` - ${pe[j].usage.padEnd(20," ")} ${pe[j].description}`)}),console.log(""),console.log("Quick Actions:");for(let j of i){let $e=(await c?.actions)?.[j];if(!$e){console.log(` - ${j.padEnd(20," ")} not defined`);return}for(let we of $e){let at=we.split(`
56
- `),$n=at[0],wn=at.slice(1);console.log(` - ${j.padEnd(20," ")} $ ${$n}`);for(let lt of wn)lt.trim()&&console.log(`${" ".repeat(27)}${lt}`)}}console.log(""),console.log("Global flags:"),vn.forEach(j=>{console.log(` --${j.name.padEnd(20," ")} ${j.description}`)}),process.exit(1)}pe[s]||(console.error(`Command "${s}" not found.`),process.exit(1));try{r||console.error("No project provided or detected.");let{success:S}=await je.run(c,bn,jn,Pn);S||process.exit(1)}catch(S){console.error(`Error executing command "${s}":`,S),process.exit(1)}}Zr();
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 ADDED
@@ -0,0 +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())}};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 ADDED
@@ -0,0 +1,295 @@
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
+
36
+ /**
37
+ * Shared response types for CLI JSON output and SDK.
38
+ * This is the single source of truth for all JSON response shapes.
39
+ * @module
40
+ */
41
+
42
+ /**
43
+ * Service information for display.
44
+ */
45
+ type ServiceInfo = {
46
+ name: string;
47
+ cwd: string;
48
+ command: string;
49
+ http?: {
50
+ port?: number;
51
+ domain?: string;
52
+ secure?: boolean;
53
+ };
54
+ };
55
+ /**
56
+ * Result of a service operation.
57
+ */
58
+ type ServiceResult = {
59
+ name: string;
60
+ success: boolean;
61
+ message: string;
62
+ };
63
+ /**
64
+ * Status of a running service.
65
+ */
66
+ type ServiceStatus = {
67
+ name: string;
68
+ running: boolean;
69
+ pid?: number;
70
+ uptime?: string;
71
+ command: string;
72
+ cwd: string;
73
+ logs?: string[];
74
+ logPath: string;
75
+ lastExitCode?: number;
76
+ };
77
+ /**
78
+ * Unified service response for all service commands.
79
+ * Used by list, status, start, stop, and restart commands.
80
+ */
81
+ type ServiceResponse = {
82
+ name: string;
83
+ project: string;
84
+ status: 'running' | 'error' | 'stopped';
85
+ pid: number | null;
86
+ url: string | null;
87
+ command: string;
88
+ cwd: string;
89
+ logPath: string;
90
+ envFile: string | null;
91
+ lastExitCode: number | null;
92
+ logs?: string[];
93
+ };
94
+ /**
95
+ * Version information for a dependency.
96
+ */
97
+ type DependencyVersion = {
98
+ resolved: string;
99
+ specifier: string;
100
+ source: string;
101
+ wanted?: string;
102
+ latest?: string;
103
+ };
104
+ /**
105
+ * A project dependency from deps:list command.
106
+ */
107
+ type Dependency = {
108
+ id: string;
109
+ name: string;
110
+ versions: DependencyVersion[];
111
+ ecosystem: string;
112
+ };
113
+ /**
114
+ * An outdated dependency from deps:outdated command.
115
+ */
116
+ type OutdatedDependency = Dependency & {
117
+ wanted: string;
118
+ latest: string;
119
+ specifier: string;
120
+ isDevDependency: boolean;
121
+ };
122
+ /**
123
+ * A project from projects:list command.
124
+ */
125
+ type ProjectResponse = {
126
+ slug: string;
127
+ name: string;
128
+ path: string;
129
+ config: ProjectConfigSchema | null;
130
+ };
131
+
132
+ /**
133
+ * Response when a service operation fails.
134
+ */
135
+ type ServiceOperationError = {
136
+ success: false;
137
+ service: string;
138
+ project: string;
139
+ message: string;
140
+ };
141
+ type DenvigSDKOptions = {
142
+ /**
143
+ * Locale to use for shell commands.
144
+ * @default 'en_GB.UTF-8'
145
+ */
146
+ locale?: string;
147
+ /**
148
+ * Path to the denvig CLI binary.
149
+ * @default './node_modules/.bin/denvig'
150
+ */
151
+ cliPath?: string;
152
+ /**
153
+ * Working directory to run commands in.
154
+ * @default process.cwd()
155
+ */
156
+ cwd?: string;
157
+ /**
158
+ * Shell to use for executing commands.
159
+ * @default '/bin/zsh'
160
+ */
161
+ shell?: string;
162
+ };
163
+ type ListServicesOptions = {
164
+ /** Filter to a specific project slug */
165
+ project?: string;
166
+ };
167
+ type ServiceOperationOptions = {
168
+ /** Filter to a specific project slug */
169
+ project?: string;
170
+ };
171
+ type DepsListOptions = {
172
+ /** Execute in the context of a specific project */
173
+ project?: string;
174
+ /** Show subdependencies up to N levels deep */
175
+ depth?: number;
176
+ /** Filter to a specific ecosystem (e.g., npm, rubygems, pypi) */
177
+ ecosystem?: string;
178
+ };
179
+ type DepsOutdatedOptions = {
180
+ /** Execute in the context of a specific project */
181
+ project?: string;
182
+ /** Skip cache and fetch fresh data from registry */
183
+ noCache?: boolean;
184
+ /** Filter by semver level: "patch" for patch updates only, "minor" for minor and patch updates */
185
+ semver?: 'patch' | 'minor';
186
+ /** Filter to a specific ecosystem (e.g., npm, rubygems, pypi) */
187
+ ecosystem?: string;
188
+ };
189
+ type ProjectsListOptions = {
190
+ /** Only include projects with a .denvig.yml configuration file */
191
+ withConfig?: boolean;
192
+ };
193
+ /**
194
+ * Denvig SDK for programmatic access to the CLI.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { DenvigSDK } from 'denvig'
199
+ *
200
+ * const denvig = new DenvigSDK()
201
+ *
202
+ * // List all services across all projects
203
+ * const services = await denvig.services.list()
204
+ *
205
+ * // Start a specific service
206
+ * const result = await denvig.services.start('api')
207
+ *
208
+ * // Get outdated dependencies
209
+ * const outdated = await denvig.deps.outdated()
210
+ * ```
211
+ */
212
+ declare class DenvigSDK {
213
+ private locale;
214
+ private cliPath;
215
+ private cwd;
216
+ private shell;
217
+ constructor(options?: DenvigSDKOptions);
218
+ /**
219
+ * Run a denvig CLI command and parse the JSON output.
220
+ */
221
+ private run;
222
+ /**
223
+ * Run a denvig CLI command that returns plain text (like version).
224
+ */
225
+ private runText;
226
+ /**
227
+ * Build flag string from options object.
228
+ */
229
+ private buildFlags;
230
+ /**
231
+ * Get the version of the denvig CLI.
232
+ */
233
+ version(): Promise<string>;
234
+ /**
235
+ * Service management commands.
236
+ */
237
+ services: {
238
+ /**
239
+ * List all services across all projects.
240
+ */
241
+ list: (options?: ListServicesOptions) => Promise<ServiceResponse[]>;
242
+ /**
243
+ * Get the status of a specific service.
244
+ */
245
+ status: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
246
+ /**
247
+ * Start a service.
248
+ * @param name - Service name to start
249
+ */
250
+ start: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
251
+ /**
252
+ * Stop a service.
253
+ * @param name - Service name to stop
254
+ */
255
+ stop: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
256
+ /**
257
+ * Restart a service.
258
+ * @param name - Service name to restart
259
+ */
260
+ restart: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
261
+ };
262
+ /**
263
+ * Dependency management commands.
264
+ */
265
+ deps: {
266
+ /**
267
+ * List all dependencies in the project.
268
+ */
269
+ list: (options?: DepsListOptions) => Promise<Dependency[]>;
270
+ /**
271
+ * List outdated dependencies in the project.
272
+ */
273
+ outdated: (options?: DepsOutdatedOptions) => Promise<OutdatedDependency[]>;
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
+ };
284
+ }
285
+ /**
286
+ * Error thrown when a denvig CLI command fails.
287
+ */
288
+ declare class DenvigSDKError extends Error {
289
+ readonly originalMessage?: string | undefined;
290
+ readonly stderr?: string | undefined;
291
+ readonly stdout?: string | undefined;
292
+ constructor(message: string, originalMessage?: string | undefined, stderr?: string | undefined, stdout?: string | undefined);
293
+ }
294
+
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 ADDED
@@ -0,0 +1,295 @@
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
+
36
+ /**
37
+ * Shared response types for CLI JSON output and SDK.
38
+ * This is the single source of truth for all JSON response shapes.
39
+ * @module
40
+ */
41
+
42
+ /**
43
+ * Service information for display.
44
+ */
45
+ type ServiceInfo = {
46
+ name: string;
47
+ cwd: string;
48
+ command: string;
49
+ http?: {
50
+ port?: number;
51
+ domain?: string;
52
+ secure?: boolean;
53
+ };
54
+ };
55
+ /**
56
+ * Result of a service operation.
57
+ */
58
+ type ServiceResult = {
59
+ name: string;
60
+ success: boolean;
61
+ message: string;
62
+ };
63
+ /**
64
+ * Status of a running service.
65
+ */
66
+ type ServiceStatus = {
67
+ name: string;
68
+ running: boolean;
69
+ pid?: number;
70
+ uptime?: string;
71
+ command: string;
72
+ cwd: string;
73
+ logs?: string[];
74
+ logPath: string;
75
+ lastExitCode?: number;
76
+ };
77
+ /**
78
+ * Unified service response for all service commands.
79
+ * Used by list, status, start, stop, and restart commands.
80
+ */
81
+ type ServiceResponse = {
82
+ name: string;
83
+ project: string;
84
+ status: 'running' | 'error' | 'stopped';
85
+ pid: number | null;
86
+ url: string | null;
87
+ command: string;
88
+ cwd: string;
89
+ logPath: string;
90
+ envFile: string | null;
91
+ lastExitCode: number | null;
92
+ logs?: string[];
93
+ };
94
+ /**
95
+ * Version information for a dependency.
96
+ */
97
+ type DependencyVersion = {
98
+ resolved: string;
99
+ specifier: string;
100
+ source: string;
101
+ wanted?: string;
102
+ latest?: string;
103
+ };
104
+ /**
105
+ * A project dependency from deps:list command.
106
+ */
107
+ type Dependency = {
108
+ id: string;
109
+ name: string;
110
+ versions: DependencyVersion[];
111
+ ecosystem: string;
112
+ };
113
+ /**
114
+ * An outdated dependency from deps:outdated command.
115
+ */
116
+ type OutdatedDependency = Dependency & {
117
+ wanted: string;
118
+ latest: string;
119
+ specifier: string;
120
+ isDevDependency: boolean;
121
+ };
122
+ /**
123
+ * A project from projects:list command.
124
+ */
125
+ type ProjectResponse = {
126
+ slug: string;
127
+ name: string;
128
+ path: string;
129
+ config: ProjectConfigSchema | null;
130
+ };
131
+
132
+ /**
133
+ * Response when a service operation fails.
134
+ */
135
+ type ServiceOperationError = {
136
+ success: false;
137
+ service: string;
138
+ project: string;
139
+ message: string;
140
+ };
141
+ type DenvigSDKOptions = {
142
+ /**
143
+ * Locale to use for shell commands.
144
+ * @default 'en_GB.UTF-8'
145
+ */
146
+ locale?: string;
147
+ /**
148
+ * Path to the denvig CLI binary.
149
+ * @default './node_modules/.bin/denvig'
150
+ */
151
+ cliPath?: string;
152
+ /**
153
+ * Working directory to run commands in.
154
+ * @default process.cwd()
155
+ */
156
+ cwd?: string;
157
+ /**
158
+ * Shell to use for executing commands.
159
+ * @default '/bin/zsh'
160
+ */
161
+ shell?: string;
162
+ };
163
+ type ListServicesOptions = {
164
+ /** Filter to a specific project slug */
165
+ project?: string;
166
+ };
167
+ type ServiceOperationOptions = {
168
+ /** Filter to a specific project slug */
169
+ project?: string;
170
+ };
171
+ type DepsListOptions = {
172
+ /** Execute in the context of a specific project */
173
+ project?: string;
174
+ /** Show subdependencies up to N levels deep */
175
+ depth?: number;
176
+ /** Filter to a specific ecosystem (e.g., npm, rubygems, pypi) */
177
+ ecosystem?: string;
178
+ };
179
+ type DepsOutdatedOptions = {
180
+ /** Execute in the context of a specific project */
181
+ project?: string;
182
+ /** Skip cache and fetch fresh data from registry */
183
+ noCache?: boolean;
184
+ /** Filter by semver level: "patch" for patch updates only, "minor" for minor and patch updates */
185
+ semver?: 'patch' | 'minor';
186
+ /** Filter to a specific ecosystem (e.g., npm, rubygems, pypi) */
187
+ ecosystem?: string;
188
+ };
189
+ type ProjectsListOptions = {
190
+ /** Only include projects with a .denvig.yml configuration file */
191
+ withConfig?: boolean;
192
+ };
193
+ /**
194
+ * Denvig SDK for programmatic access to the CLI.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { DenvigSDK } from 'denvig'
199
+ *
200
+ * const denvig = new DenvigSDK()
201
+ *
202
+ * // List all services across all projects
203
+ * const services = await denvig.services.list()
204
+ *
205
+ * // Start a specific service
206
+ * const result = await denvig.services.start('api')
207
+ *
208
+ * // Get outdated dependencies
209
+ * const outdated = await denvig.deps.outdated()
210
+ * ```
211
+ */
212
+ declare class DenvigSDK {
213
+ private locale;
214
+ private cliPath;
215
+ private cwd;
216
+ private shell;
217
+ constructor(options?: DenvigSDKOptions);
218
+ /**
219
+ * Run a denvig CLI command and parse the JSON output.
220
+ */
221
+ private run;
222
+ /**
223
+ * Run a denvig CLI command that returns plain text (like version).
224
+ */
225
+ private runText;
226
+ /**
227
+ * Build flag string from options object.
228
+ */
229
+ private buildFlags;
230
+ /**
231
+ * Get the version of the denvig CLI.
232
+ */
233
+ version(): Promise<string>;
234
+ /**
235
+ * Service management commands.
236
+ */
237
+ services: {
238
+ /**
239
+ * List all services across all projects.
240
+ */
241
+ list: (options?: ListServicesOptions) => Promise<ServiceResponse[]>;
242
+ /**
243
+ * Get the status of a specific service.
244
+ */
245
+ status: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
246
+ /**
247
+ * Start a service.
248
+ * @param name - Service name to start
249
+ */
250
+ start: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
251
+ /**
252
+ * Stop a service.
253
+ * @param name - Service name to stop
254
+ */
255
+ stop: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
256
+ /**
257
+ * Restart a service.
258
+ * @param name - Service name to restart
259
+ */
260
+ restart: (name: string, options?: ServiceOperationOptions) => Promise<ServiceResponse>;
261
+ };
262
+ /**
263
+ * Dependency management commands.
264
+ */
265
+ deps: {
266
+ /**
267
+ * List all dependencies in the project.
268
+ */
269
+ list: (options?: DepsListOptions) => Promise<Dependency[]>;
270
+ /**
271
+ * List outdated dependencies in the project.
272
+ */
273
+ outdated: (options?: DepsOutdatedOptions) => Promise<OutdatedDependency[]>;
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
+ };
284
+ }
285
+ /**
286
+ * Error thrown when a denvig CLI command fails.
287
+ */
288
+ declare class DenvigSDKError extends Error {
289
+ readonly originalMessage?: string | undefined;
290
+ readonly stderr?: string | undefined;
291
+ readonly stdout?: string | undefined;
292
+ constructor(message: string, originalMessage?: string | undefined, stderr?: string | undefined, stdout?: string | undefined);
293
+ }
294
+
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 ADDED
@@ -0,0 +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())}};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};
package/package.json CHANGED
@@ -1,12 +1,27 @@
1
1
  {
2
2
  "name": "denvig",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "description": "A CLI tool to consistently manage cross-discipline projects",
6
6
  "bin": {
7
7
  "denvig": "./dist/cli.cjs"
8
8
  },
9
9
  "type": "module",
10
+ "main": "./dist/sdk.cjs",
11
+ "module": "./dist/sdk.js",
12
+ "types": "./dist/sdk.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "import": {
16
+ "types": "./dist/sdk.d.ts",
17
+ "default": "./dist/sdk.js"
18
+ },
19
+ "require": {
20
+ "types": "./dist/sdk.d.ts",
21
+ "default": "./dist/sdk.cjs"
22
+ }
23
+ }
24
+ },
10
25
  "files": [
11
26
  "dist/",
12
27
  "LICENSE",
@@ -25,6 +40,7 @@
25
40
  },
26
41
  "dependencies": {
27
42
  "minimist": "^1.2.8",
43
+ "semver": "^7.7.3",
28
44
  "yaml": "^2.8.2",
29
45
  "zod": "^4.3.5"
30
46
  },
@@ -32,6 +48,7 @@
32
48
  "@biomejs/biome": "^2.3.11",
33
49
  "@types/minimist": "^1.2.5",
34
50
  "@types/node": "^24",
51
+ "@types/semver": "^7.7.1",
35
52
  "tsup": "^8.5.1",
36
53
  "typescript": "^5.9.3"
37
54
  },