nebutra 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-DTSPVLT5.js +9 -0
- package/dist/delegate-MQWQZT5V.js +1 -0
- package/dist/index.js +77 -78
- package/package.json +6 -5
- package/dist/chunk-LGUMYJ4Q.js +0 -6
- package/dist/delegate-GIJ3G5CK.js +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{spawn as A}from"child_process";import{readdirSync as M,readFileSync as v}from"fs";import{dirname as w,parse as L,resolve as O}from"path";import l from"picocolors";import{stderr as D}from"process";import s from"picocolors";var n={SUCCESS:0,ERROR:1,INVALID_ARGS:2,NOT_FOUND:3,PERMISSION_DENIED:4,CONFLICT:5,NETWORK_ERROR:6,TIMEOUT:7,CANCELLED:8,CONFIG_ERROR:9,DRY_RUN_OK:10,INCOMPATIBLE:11,RESOURCE_EXHAUSTED:12},G={[n.SUCCESS]:"Command completed successfully",[n.ERROR]:"General or unknown error occurred",[n.INVALID_ARGS]:"Invalid arguments or options provided",[n.NOT_FOUND]:"Requested resource not found",[n.PERMISSION_DENIED]:"Permission denied or authentication required",[n.CONFLICT]:"Resource already exists",[n.NETWORK_ERROR]:"Network or external service error (may be retryable)",[n.TIMEOUT]:"Operation timed out (may be retryable)",[n.CANCELLED]:"Operation cancelled by user",[n.CONFIG_ERROR]:"Configuration error or missing configuration",[n.DRY_RUN_OK]:"Dry-run completed successfully",[n.INCOMPATIBLE]:"Incompatible version or dependency conflict",[n.RESOURCE_EXHAUSTED]:"System resource exhausted"};function _(){return process.stderr.isTTY===!0&&!process.env.CI&&!process.env.NEBUTRA_NON_TTY}function h(r){let e=[];return e.push(s.red(`\u2716 ${r.error}`)),e.push(s.white(r.message)),r.suggestion&&(e.push(""),e.push(s.cyan("\u{1F4A1} Suggestion:")),e.push(s.gray(` ${r.suggestion}`))),process.env.NEBUTRA_DEBUG&&r.context&&Object.keys(r.context).length>0&&(e.push(""),e.push(s.dim("Debug context:")),e.push(s.dim(JSON.stringify(r.context,null,2)))),process.env.NEBUTRA_DEBUG&&r.stack&&(e.push(""),e.push(s.dim("Stack trace:")),e.push(s.dim(r.stack))),e.join(`
|
|
2
|
+
`)}function U(r){let e={error:r.error,message:r.message,...r.suggestion&&{suggestion:r.suggestion},retryable:r.retryable,exitCode:r.exitCode,...r.context&&Object.keys(r.context).length>0&&{context:r.context},...process.env.NEBUTRA_DEBUG&&r.stack&&{stack:r.stack}};return JSON.stringify(e)}function T(r){return{error:r.error,message:r.message,suggestion:r.suggestion,retryable:r.retryable??!1,exitCode:r.exitCode??n.ERROR,context:r.context,stack:r.cause?.stack}}function k(r){let e=_()?h(r):U(r);D.write(e+`
|
|
3
|
+
`)}function I(r){k(r),process.exit(r.exitCode)}function b(r,e){I(T({error:"config_error",message:r,suggestion:e??"Check your nebutra configuration file and try again",exitCode:n.CONFIG_ERROR}))}function W(r,e){I(T({error:"not_found",message:r,suggestion:e??"Check the resource path and try again",exitCode:n.NOT_FOUND}))}var f=class extends Error{constructor(e){super(`Could not find a Nebutra project root above ${e} (looked for nebutra.config.json, pnpm-workspace.yaml, or a package.json with "workspaces"). Run this command inside a Sailor project, or scaffold one with \`npx create-sailor my-app\`.`),this.name="ProjectRootNotFoundError"}};function P(r){try{return!!JSON.parse(v(r,"utf-8")).workspaces}catch{return!1}}function F(r=process.cwd()){let e=O(r),{root:t}=L(e);for(;;){let o=[];try{o=M(e)}catch{o=[]}if(o.includes("nebutra.config.json")||o.includes("pnpm-workspace.yaml")||o.includes("package.json")&&P(O(e,"package.json")))return e;if(e===t)break;e=w(e)}throw new f(O(r))}function B(r){try{return F(r)}catch(e){throw e instanceof f&&b(e.message,"Run inside a Sailor project, or `npx create-sailor my-app`."),e}}async function R(r){let{command:e,args:t,cwd:o=B(),env:m={},interactive:g=!1,label:d=e,dryRun:S=!1,timeoutMs:E}=r;if(S){let u={mode:"dry-run",timestamp:new Date().toISOString(),command:e,args:t,cwd:o,env:Object.keys(m).length>0?m:void 0};return process.stdout.write(JSON.stringify(u,null,2)+`
|
|
4
|
+
`),{exitCode:0,stdout:JSON.stringify(u),stderr:""}}return g&&!process.env.NEBUTRA_QUIET&&process.stderr.write(l.cyan(`\u2192 ${d}: ${e} ${t.join(" ")}
|
|
5
|
+
`)),new Promise(u=>{let a=A(e,t,{cwd:o,env:{...process.env,...m},stdio:g?"inherit":["pipe","pipe","pipe"]}),x="",N="",C=!1,p=!1,c=E&&E>0?setTimeout(()=>{p=!0,process.stderr.write(l.red(`\u2716 ${d} timed out after ${E}ms \u2014 killing the process
|
|
6
|
+
`)),a.kill("SIGTERM"),setTimeout(()=>{C||a.kill("SIGKILL")},2e3).unref()},E):void 0;c?.unref(),g||(a.stdout?.on("data",i=>{x+=i.toString()}),a.stderr?.on("data",i=>{N+=i.toString()})),a.on("close",i=>{C=!0,c&&clearTimeout(c);let y=p?124:i??1;!g&&!process.env.NEBUTRA_QUIET&&!p&&(y===0?process.stderr.write(l.green(`\u2713 ${d} completed
|
|
7
|
+
`)):process.stderr.write(l.red(`\u2716 ${d} failed with exit code ${y}
|
|
8
|
+
`))),u({exitCode:y,stdout:x,stderr:N,timedOut:p})}),a.on("error",i=>{C=!0,c&&clearTimeout(c),process.stderr.write(l.red(`\u2716 Failed to execute ${e}: ${i.message}
|
|
9
|
+
`)),u({exitCode:1,stdout:x,stderr:i.message})})})}async function z(r,e){let t=["run"];return e?.filter&&t.push("--filter",e.filter),t.push(r),e?.args&&t.push("--",...e.args),R({command:"pnpm",args:t,dryRun:e?.dryRun,interactive:e?.interactive??!0,label:`pnpm run ${r}`})}async function Z(r,e){let t=["run",r];return e?.filter&&t.push("--filter",e.filter),R({command:"turbo",args:t,dryRun:e?.dryRun,interactive:!0,label:`turbo run ${r}`})}async function ee(r,e){let t=["compose"];return e?.profile&&t.push("--profile",e.profile),e?.file&&t.push("-f",e.file),t.push(...r.split(" ")),R({command:"docker",args:t,dryRun:e?.dryRun,interactive:e?.interactive??!0,label:`docker compose ${r}`,timeoutMs:e?.timeoutMs})}async function re(r,e){let t=["prisma",r];return e?.args&&t.push(...e.args),R({command:"npx",args:t,dryRun:e?.dryRun,interactive:e?.interactive??!0,label:`prisma ${r}`,timeoutMs:e?.timeoutMs})}export{n as a,G as b,T as c,k as d,b as e,W as f,f as g,F as h,B as i,R as j,z as k,Z as l,ee as m,re as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h}from"./chunk-DTSPVLT5.js";export{a as ProjectRootNotFoundError,d as delegate,g as dockerCompose,b as findMonorepoRoot,c as findMonorepoRootOrExit,e as pnpmRun,h as prismaRun,f as turboRun};
|