denvig 0.3.0 → 0.4.1

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