UNPKG

@lunora/cli

Version:

The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands

2 lines (1 loc) 1.32 kB
import{spawnSync as o}from"node:child_process";import{LunoraError as t}from"@lunora/errors";import{findPackageManagerSync as c,identifyInitiatingPackageManager as d}from"@visulima/package/package-manager";const m=["pnpm","bun","yarn","npm"],s=new Set(m),i=n=>s.has(n),p=n=>{try{return o(n,["--version"],{stdio:"ignore",timeout:5e3}).status===0}catch{return!1}},u=(n=p)=>m.filter(a=>n(a)),y=n=>({args:["install"],command:n}),b=(n,a,r={})=>{const e=r.dev===!0;return n==="npm"?{args:["install",...e?["--save-dev"]:[],...a],command:"npm"}:n==="bun"?{args:["add",...e?["-d"]:[],...a],command:"bun"}:{args:["add",...e?["-D"]:[],...a],command:n}},k=n=>{try{return c(n).packageManager}catch{}const a=d();if(a!==void 0){const e=a.name==="cnpm"?"npm":a.name;if(i(e))return e}const[r]=u();if(r!==void 0)return r;throw new t("INTERNAL","Could not detect a package manager: no lock file or `packageManager` field was found, and none (pnpm, bun, yarn, npm) is installed on PATH.")},v=(n,a,r)=>n==="yarn"?{args:[a,...r],command:"yarn"}:n==="bun"?{args:["x",a,...r],command:"bun"}:n==="npm"?{args:["--",a,...r],command:"npx"}:{args:["exec",a,...r],command:"pnpm"},w=(n,a)=>({args:["run",a],command:n}),M=(n,a)=>n==="npm"?`npm run ${a}`:n==="bun"?`bun run ${a}`:`${n} ${a}`;export{v as M,b as P,w as f,u as g,M as k,k as l,y as p};