denvig 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,12 +16,6 @@ You can install the CLI tool globally using npm:
16
16
  npm install -g denvig
17
17
  ```
18
18
 
19
-
20
- ### Binary
21
-
22
- Prebuilt binaries can be downloaded from the [releases page](https://github.com/marcqualie/denvig/releases).
23
-
24
-
25
19
  After installation, the `denvig` command will be available in your terminal.
26
20
 
27
21
 
@@ -29,10 +23,10 @@ After installation, the `denvig` command will be available in your terminal.
29
23
  ## Commands
30
24
 
31
25
 
32
- ### Run
26
+ ### Actions
33
27
 
34
- Execites an action inside the project. Defaults are detected for common languages/frameworks, but you can also
35
- specify your own actions in the `denvig.yml` file.
28
+ Executes an action inside the project. Defaults are detected for common languages/frameworks, but you can also
29
+ specify your own actions in the `.denvig.yml` file.
36
30
 
37
31
  ```shell
38
32
  denvig run build
@@ -41,7 +35,7 @@ denvig run test
41
35
  denvig run dev
42
36
  ```
43
37
 
44
- Some commands are common to many frameworks so they have root aliases for convenience:
38
+ Some actions are common to many frameworks so they have quick access for convenience:
45
39
 
46
40
  ```shell
47
41
  denvig build
@@ -58,10 +52,14 @@ denvig outdated
58
52
  There is a set of core languages and frameworks that Denvig will support out of the box. Any language or framework
59
53
  can be supported by using the per project configs.
60
54
 
61
- - [ ] Deno
62
- - [ ] Node.js / NextJS / Vite
63
- - [ ] Ruby / Rails
64
- - [ ] Python / Pip
55
+ - [x] Node.js (npm, pnpm, yarn)
56
+ - [ ] Bun
57
+ - [ ] Vite
58
+ - [x] Deno
59
+ - [ ] NextJS
60
+ - [ ] Ruby
61
+ - [ ] Rails
62
+ - [ ] Python
65
63
 
66
64
 
67
65
 
package/dist/cli.cjs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var he=Object.create;var L=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var m=(e,n)=>()=>(e&&(n=e(e=0)),n);var q=(e,n)=>{for(var o in n)L(e,o,{get:n[o],enumerable:!0})},ve=(e,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of be(n))!De.call(e,t)&&t!==o&&L(e,t,{get:()=>n[t],enumerable:!(s=ye(n,t))||s.enumerable});return e};var Ce=(e,n,o)=>(o=e!=null?he($e(e)):{},ve(n||!e||!e.__esModule?L(o,"default",{value:e,enumerable:!0}):o,e));var g,Ae,W,N,H,M=m(()=>{"use strict";g=require("zod"),Ae=["build","check-types","dev","install","lint","outdated","test"],W=g.z.object({}),N=W.extend({codeRootDir:g.z.string().describe("The root directory where all code is stored"),quickActions:g.z.array(g.z.string()).default(Ae).optional().describe("Actions that are available on the CLI root for quick access")}),H=W.extend({name:g.z.string().describe("Unique identifier for the project"),actions:g.z.record(g.z.string().describe("Name of the action"),g.z.object({command:g.z.string().describe("Shell command to run for the action")})).optional().describe("Actions that can be run against the project"),quickActions:g.z.array(g.z.string()).optional().describe("Actions that are available on the CLI root for quick access")})});var U,xe,_,z=m(()=>{"use strict";U=require("fs"),xe=require("fs/promises"),_=e=>{try{return(0,U.readFileSync)(e,"utf8").trim()||null}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code==="ENOENT")return null;throw n}}});var D,I,S,Pe,B,b,K,F=m(()=>{"use strict";D=require("path"),I=require("yaml");M();z();S=(0,D.resolve)(process.env.DENVIG_GLOBAL_CONFIG_PATH||`${process.env.HOME}/.denvig/config.yml`),Pe=(0,D.resolve)(process.env.DENVIG_CODE_ROOT_DIR||`${process.env.HOME}/src`),B={codeRootDir:Pe,quickActions:void 0},b=()=>{let e=_(S);if(e){let n=(0,I.parse)(e)||{};try{if(n.codeRootDir?.startsWith(".")){let o=(0,D.dirname)(S);n.codeRootDir=(0,D.resolve)(`${o}/${n.codeRootDir}`)}return{...N.parse({...B,...n}),$sources:[S]}}catch(o){console.error(`Error parsing global config at ${S}:`,o),process.exit(1)}}return{...N.parse(B),$sources:[]}},K=e=>{let n=b(),o={name:e,actions:{}},s=`${n.codeRootDir}/${e}/.denvig.yml`,t=_(s);if(t)try{return{...o,...H.parse((0,I.parse)(t)),$sources:[s]}}catch(i){console.warn(`Error parsing project config for ${e} at ${s}.`),i instanceof Error?console.warn(i.message):console.warn("Unknown error:",i)}return{...o,$sources:[]}}});var ee,Z=m(()=>{ee={name:"denvig",version:"0.2.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.0.14"},devDependencies:{"@biomejs/biome":"^2.1.3","@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 v(){return ee.version}var O=m(()=>{"use strict";Z()});var y,w=m(()=>{"use strict";y=class{name;description;usage;example;args;flags;handler;constructor(n){this.name=n.name,this.description=n.description||"",this.usage=n.usage,this.example=n.example,this.args=n.args,this.flags=n.flags,this.handler=n.handler}async run(n,o,s,t){try{return await this.handler({project:n,args:o,flags:s,extraArgs:t})}catch(i){return console.error(`Error executing command "${this.name}":`,i),{success:!1,message:"fail"}}}}});var oe={};q(oe,{runCommand:()=>ke});var ne,ke,te=m(()=>{"use strict";ne=require("child_process");w();O();ke=new y({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:e,args:n,extraArgs:o=[]})=>{if(!n.action){console.log(`Denvig v${v()}`),console.log(""),console.log("Usage: denvig run [action] [...actionArgs]"),console.log(""),console.log("Available actions:");for(let l in e.actions){if(!e.actions[l])continue;let A=e.actions[l].split(`
3
+ `),T=A[0],x=A.slice(1);console.log(` ${l}: ${T}`);for(let P of x)P.trim()&&console.log(`${" ".repeat(l.length+4)}${P}`)}return{success:!0,message:"No action specified."}}let s=e.actions[n.action];if(!s)return console.error(`Action "${n.action}" not found in project ${e.name}.`),{success:!1,message:`Action "${n.action}" not found.`};let t=`${s} ${o.join(" ")}`.trim();console.log(`$ ${t}`);let i={...process.env,DENVIG_PROJECT:e.slug},d=process.stdout.isTTY&&process.stdin.isTTY,a,p;d?process.platform==="darwin"?(a="script",p=["-q","/dev/null","sh","-c",t]):(a="script",p=["-q","-c",t,"/dev/null"]):(a="sh",p=["-c",t]);let G=(0,ne.spawn)(a,p,{cwd:e.path,env:i,stdio:"inherit"});return await new Promise(l=>{G.on("close",u=>{l({success:u===0})})})}})});var E,se=m(()=>{"use strict";E=e=>e.replace(process.env.HOME||"/root","~")});var ce={};q(ce,{configCommand:()=>Se});var re,ie,Se,ae=m(()=>{"use strict";re=require("yaml");w();F();se();ie=e=>{let n=Object.fromEntries(Object.entries({...e,$sources:void 0}).filter(([o,s])=>s!==void 0));(0,re.stringify)(n,{indent:2,lineWidth:80}).trim().split(`
4
+ `).map(o=>console.log(` ${E(o)}`))},Se=new y({name:"config",description:"Display the current global and project configuration.",usage:"config",example:"config",args:[],flags:[],handler:({project:e})=>{let n=b(),o=e.config;return console.log("Denvig Config"),console.log(""),console.log(`Global: ${n.$sources.map(s=>E(s)).join(", ")||"default"}`),ie(n),console.log(""),console.log(`Project: ${e.config.$sources.map(s=>E(s)).join(", ")||"default"}`),console.log(` slug: ${e.slug}`),ie(o),{success:!0,message:"Configuration displayed."}}})});var le={};q(le,{versionCommand:()=>Fe});var Fe,ge=m(()=>{"use strict";w();O();Fe=new y({name:"version",description:"Show the current version of Denvig",usage:"version",example:"denvig version",args:[],flags:[],handler:()=>(console.log(`v${v()}`),{success:!0})})});var V=Ce(require("minimist"),1);F();var f=require("fs"),Y=e=>{let n=e.dependencies,o={};if(e.config.actions&&(o={...o,...Object.entries(e.config.actions).reduce((s,[t,i])=>(s[t]=i.command,s),{})}),n.some(s=>s.name==="deno")){let t=((0,f.existsSync)(`${e.path}/deno.json`)?JSON.parse((0,f.readFileSync)(`${e.path}/deno.json`,"utf8")):(0,f.existsSync)(`${e.path}/deno.jsonc`)?JSON.parse((0,f.readFileSync)(`${e.path}/deno.jsonc`,"utf8")):{}).tasks||{};o=Q(o,{...o,test:t?.test?"deno task test":"deno test",lint:t?.lint?"deno task lint":"deno lint","check-types":t?.checkTypes?"deno task check-types":"deno check",...Object.entries(t).reduce((i,[d,a])=>(i[d]=a.startsWith("deno")?a:`deno task ${d}`,i),{}),install:"deno install",outdated:"deno outdated"})}if(n.some(s=>s.name==="npm")){let t=JSON.parse((0,f.readFileSync)(`${e.path}/package.json`,"utf8")).scripts||{},i="npm";(0,f.existsSync)(`${e.path}/pnpm-lock.yaml`)?i="pnpm":(0,f.existsSync)(`${e.path}/yarn.lock`)&&(i="yarn"),o=Q(o,{build:`${i} ${t.build||"run build"}`,test:`${i} ${t.test||"run test"}`,lint:`${i} ${t.lint||"run lint"}`,dev:`${i} ${t.dev||"run dev"}`,...Object.entries(t).reduce((d,[a,p])=>(d[a]=p.startsWith(i)?p:`${i} run ${a}`,d),{}),install:`${i} install`,outdated:`${i} outdated`})}return o},Q=(e,n)=>{for(let[o,s]of Object.entries(n))e[o]||(e[o]=s);return e};F();var h=require("fs"),X=e=>{let n=[];if((0,h.existsSync)(`${e.path}/package.json`)){n.push({id:"npm:npm",name:"npm",ecosystem:"system",versions:[]});let o=JSON.parse((0,h.readFileSync)(`${e.path}/package.json`,"utf8"));if(o.dependencies)for(let[s,t]of Object.entries({...o.dependencies,...o.devDependencies}))n.push({id:`npm:${s}`,name:s,ecosystem:"npm",versions:Array.isArray(t)?t:[t]})}return(0,h.existsSync)(`${e.path}/yarn.lock`)&&n.push({id:"npm:yarn",name:"yarn",ecosystem:"system",versions:[]}),(0,h.existsSync)(`${e.path}/pnpm-lock.yaml`)&&n.push({id:"npm:pnpm",name:"pnpm",ecosystem:"system",versions:[]}),((0,h.existsSync)(`${e.path}/deno.json`)||(0,h.existsSync)(`${e.path}/deno.jsonc`))&&n.push({id:"deno:deno",name:"deno",ecosystem:"system",versions:[process.version]}),n};var R=class{slug;config;constructor(n){this.slug=n,this.config=K(n)}get name(){return this.config.name}get path(){return`${b().codeRootDir}/${this.slug}`}get dependencies(){return X(this)}get actions(){return Y(this)}};O();var de=[{name:"project",description:"The project slug to run against. Defaults to current directory.",required:!1,type:"string",defaultValue:void 0}];async function Re(){let e=process.argv[2],n=process.argv.slice(2),o=b(),s=process.cwd(),t=(0,V.default)(process.argv.slice(2)).project?.toString()||s.replace(`${o.codeRootDir}/`,"").split("/").slice(0,2).join("/"),i=new R(t),d=[...o.quickActions||[],...i?.config?.quickActions||[]].sort();d.includes(e)&&(n=["run",...process.argv.slice(2)],e="run",console.log("> Proxying to denvig run",...process.argv.slice(2)));let{runCommand:a}=await Promise.resolve().then(()=>(te(),oe)),{configCommand:p}=await Promise.resolve().then(()=>(ae(),ce)),{versionCommand:G}=await Promise.resolve().then(()=>(ge(),le)),$={run:a,config:p,version:G},l=$[e],u=(0,V.default)(n),A=l?.args.reduce((c,r,k)=>{let C=u._[k+1];return C!==void 0?c[r.name]=C:r.required&&(console.error(`Missing required argument: ${r.name}`),process.exit(1)),c},{})||{},T=u._.slice(l?.args.length+1).map(c=>String(c))||[],x=[...de,...l?.flags||[]],P=new Set(x.map(c=>c.name)),me=x.reduce((c,r)=>(u[r.name]!==void 0?c[r.name]=u[r.name]:r.defaultValue!==void 0?c[r.name]=r.defaultValue:r.required&&(console.error(`Missing required flag: ${r.name}`),process.exit(1)),c),{}),j=[];for(let[c,r]of Object.entries(u))c!=="_"&&!P.has(c)&&(r===!0?j.push(`--${c}`):r===!1?j.push(`--no-${c}`):j.push(`--${c}`,String(r)));let pe=[...T,...j];e||(console.log(`Denvig v${v()}`),console.log(""),console.log("Usage: denvig <command> [args] [flags]"),console.log(""),console.log("Available commands:"),Object.keys($).forEach(r=>{console.log(` - ${$[r].usage.padEnd(20," ")} ${$[r].description}`)}),console.log(""),console.log("Quick Actions:"),d.forEach(r=>{let k=i?.actions?.[r];if(!k){console.log(` - ${r.padEnd(20," ")} not defined`);return}let C=k.split(`
5
+ `),fe=C[0],ue=C.slice(1);console.log(` - ${r.padEnd(20," ")} $ ${fe}`);for(let J of ue)J.trim()&&console.log(`${" ".repeat(27)}${J}`)}),console.log(""),console.log("Global flags:"),de.forEach(r=>{console.log(` --${r.name.padEnd(20," ")} ${r.description}`)}),process.exit(1)),$[e]||(console.error(`Command "${e}" not found.`),process.exit(1));try{t||console.error("No project provided or detected.");let{success:c}=await l.run(i,A,me,pe);c||process.exit(1)}catch(c){console.error(`Error executing command "${e}":`,c),process.exit(1)}}Re();
package/package.json CHANGED
@@ -1,25 +1,40 @@
1
1
  {
2
2
  "name": "denvig",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "A CLI tool to consistently manage cross-discipline projects",
6
6
  "bin": {
7
- "denvig": "./dist/denvig"
7
+ "denvig": "./dist/cli.cjs"
8
8
  },
9
+ "type": "module",
9
10
  "files": [
10
- "dist/denvig",
11
+ "dist/",
11
12
  "LICENSE",
12
13
  "README.md"
13
14
  ],
14
15
  "scripts": {
15
- "build": "deno task build",
16
- "prepublishOnly": "npm run build"
16
+ "build": "rm -rf dist && tsup",
17
+ "check-types": "tsc --noEmit",
18
+ "prepublishOnly": "npm run build",
19
+ "lint": "biome check",
20
+ "lint:fix": "biome check --fix",
21
+ "test": "node --test src/**/*.test.ts",
22
+ "test:ci": "node --test src/**/*.test.ts --reporter=default",
23
+ "dev": "tsc --watch"
17
24
  },
18
25
  "dependencies": {
26
+ "minimist": "^1.2.8",
27
+ "yaml": "^2.4.5",
19
28
  "zod": "^4.0.14"
20
29
  },
30
+ "devDependencies": {
31
+ "@biomejs/biome": "^2.1.3",
32
+ "@types/minimist": "^1.2.5",
33
+ "@types/node": "^22",
34
+ "tsup": "^8.5.0",
35
+ "typescript": "^5.0.0"
36
+ },
21
37
  "engines": {
22
- "deno": ">=2.4",
23
38
  "node": ">=22"
24
39
  },
25
40
  "repository": {
@@ -28,7 +43,7 @@
28
43
  },
29
44
  "keywords": [
30
45
  "cli",
31
- "deno",
46
+ "node",
32
47
  "developer-tools",
33
48
  "productivity",
34
49
  "typescript"
package/dist/denvig DELETED
Binary file
File without changes