@dashnex/cli 0.5.54 → 0.5.56

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.
@@ -1 +1 @@
1
- import e from"chalk";import o from"fs-extra";import t from"path";import i from"os";import s from"adm-zip";import r from"ignore";import n from"inquirer";import{debug as a,debugError as c}from"../../lib/debug.js";import{getBusinessApiBase as p}from"../../lib/api.js";import{ensureLoggedIn as l}from"../../services/auth.js";import{createSpinner as d}from"../../lib/spinner.js";import{isUserInterrupt as m,INTERRUPTED_MESSAGE as f}from"../../lib/errors.js";import{DeployCommand as h}from"./deploy.js";import{CheckCommand as u}from"../check.js";const g=[".dashnex",".git",".next",".wrangler"],w=async(e,i)=>{const s=[],r=await o.readdir(e,{withFileTypes:!0});for(const o of r){const r=t.relative(process.cwd(),t.join(e,o.name)).split(t.sep).join("/");if(g.some(e=>r===e||r.startsWith(`${e}/`)))continue;if(i.ignores(r))continue;const n=t.join(e,o.name);if(o.isDirectory()){const e=await w(n,i);s.push(...e)}else o.isFile()&&s.push(n)}return s};class y{async execute(y={}){a("Push flow started");if(!1===y.check)a("Skipping pre-push checks (--no-check)");else{a("Running pre-push checks");const o=new u;await o.run()||(console.error(e.red("Push aborted: checks failed.")),process.exit(1))}const j=await l();if(!j)return;const x=process.cwd(),k=t.join(x,".gitignore"),v=r();if(v.add(g),await o.pathExists(k)){const e=await o.readFile(k,"utf8");v.add(e)}a("Building file list");const $=await w(x,v);a(`Including ${$.length} files`);const b=new s;for(const e of $){const o=t.relative(x,e).split(t.sep).join("/"),i="."===t.dirname(o)?"":t.dirname(o),s=t.basename(o);b.addLocalFile(e,i,s)}const F=t.join(i.tmpdir(),`dashnex-push-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),P=d();try{P.start("Packaging application..."),b.writeZip(F),a(`Zip written to ${F}`);const t=`${p()}/business/v1/cli/push`;a(`POST ${t}`);const i=await o.readFile(F),s=new Blob([i],{type:"application/zip"}),r=new FormData;r.append("file",s,"archive.zip");const c=new Headers;c.set("Authorization",`Bearer ${j.token}`),P.text("Uploading...");const l=await fetch(t,{method:"POST",headers:c,body:r});if(P.stop(),a(`Response: ${l.status}`),!l.ok){const o=l.headers.get("content-type")??"";let t="Failed to push application.";if(401===l.status||403===l.status)t="Please run 'dashnex login' to authenticate.";else if(o.includes("application/json")){const e=(e=>"string"==typeof e.error?e.error:"string"==typeof e.message?e.message:void 0)(await l.json().catch(()=>({})));e&&(t=e)}console.error(e.red(t)),process.exit(1)}let d;if(console.log(e.green("Application pushed successfully.")),void 0!==y.deploy)d=y.deploy,a(`Deploy decided via flag: ${d}`);else{d=(await n.prompt([{type:"confirm",name:"deploy",message:"Deploy the application?",default:!0}])).deploy,a(`User chose to deploy: ${d}`)}if(d){a("Running deploy flow");const e=new h;await e.execute()}}catch(z){if(P.stop(),c(z),z instanceof Error&&z.message.startsWith("EXIT:"))throw z;if(m(z))return void console.log(e.yellow(f));console.error(e.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}finally{await o.remove(F).catch(()=>{}),a("Temp zip removed")}}}export{y as PushCommand};
1
+ import e from"chalk";import o from"fs-extra";import t from"path";import i from"os";import s from"adm-zip";import r from"ignore";import n from"inquirer";import{debug as a,debugError as c}from"../../lib/debug.js";import{getBusinessApiBase as p}from"../../lib/api.js";import{ensureLoggedIn as l}from"../../services/auth.js";import{createSpinner as d}from"../../lib/spinner.js";import{isUserInterrupt as m,INTERRUPTED_MESSAGE as f}from"../../lib/errors.js";import{DeployCommand as h}from"./deploy.js";import{CheckCommand as u}from"../check.js";const g=[".dashnex",".git",".next",".wrangler","wrangler.jsonc"],w=async(e,i)=>{const s=[],r=await o.readdir(e,{withFileTypes:!0});for(const o of r){const r=t.relative(process.cwd(),t.join(e,o.name)).split(t.sep).join("/");if(g.some(e=>r===e||r.startsWith(`${e}/`)||r.endsWith(`/${e}`)))continue;if(i.ignores(r))continue;const n=t.join(e,o.name);if(o.isDirectory()){const e=await w(n,i);s.push(...e)}else o.isFile()&&s.push(n)}return s};class y{async execute(y={}){a("Push flow started");if(!1===y.check)a("Skipping pre-push checks (--no-check)");else{a("Running pre-push checks");const o=new u;await o.run()||(console.error(e.red("Push aborted: checks failed.")),process.exit(1))}const j=await l();if(!j)return;const x=process.cwd(),k=t.join(x,".gitignore"),$=r();if($.add(g),await o.pathExists(k)){const e=await o.readFile(k,"utf8");$.add(e)}a("Building file list");const v=await w(x,$);a(`Including ${v.length} files`);const b=new s;for(const e of v){const o=t.relative(x,e).split(t.sep).join("/"),i="."===t.dirname(o)?"":t.dirname(o),s=t.basename(o);b.addLocalFile(e,i,s)}const F=t.join(i.tmpdir(),`dashnex-push-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),P=d();try{P.start("Packaging application..."),b.writeZip(F),a(`Zip written to ${F}`);const t=`${p()}/business/v1/cli/push`;a(`POST ${t}`);const i=await o.readFile(F),s=new Blob([i],{type:"application/zip"}),r=new FormData;r.append("file",s,"archive.zip");const c=new Headers;c.set("Authorization",`Bearer ${j.token}`),P.text("Uploading...");const l=await fetch(t,{method:"POST",headers:c,body:r});if(P.stop(),a(`Response: ${l.status}`),!l.ok){const o=l.headers.get("content-type")??"";let t="Failed to push application.";if(401===l.status||403===l.status)t="Please run 'dashnex login' to authenticate.";else if(o.includes("application/json")){const e=(e=>"string"==typeof e.error?e.error:"string"==typeof e.message?e.message:void 0)(await l.json().catch(()=>({})));e&&(t=e)}console.error(e.red(t)),process.exit(1)}let d;if(console.log(e.green("Application pushed successfully.")),void 0!==y.deploy)d=y.deploy,a(`Deploy decided via flag: ${d}`);else{d=(await n.prompt([{type:"confirm",name:"deploy",message:"Deploy the application?",default:!0}])).deploy,a(`User chose to deploy: ${d}`)}if(d){a("Running deploy flow");const e=new h;await e.execute()}}catch(z){if(P.stop(),c(z),z instanceof Error&&z.message.startsWith("EXIT:"))throw z;if(m(z))return void console.log(e.yellow(f));console.error(e.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}finally{await o.remove(F).catch(()=>{}),a("Temp zip removed")}}}export{y as PushCommand};
@@ -1 +1 @@
1
- import{spawn as e}from"child_process";import r from"path";import n from"fs-extra";import o from"chalk";import{debug as t,debugError as s}from"../lib/debug.js";const i=["Using vars defined in \\.env","\\(node:\\d+\\) MaxListenersExceededWarning:","\\(Use `node --trace-warnings","\\[WARNING\\].*You have defined bindings to the following internal Durable Objects","You have defined bindings to the following internal Durable Objects",'\\{"name":".+","class_name":".+"\\}',"These will not work in local development, but they should work in production","If you want to develop these locally, you can define your DO in a separate Worker","For detailed instructions, refer to the Durable Objects section here:","developers.cloudflare.com/workers/wrangler/api#supported-bindings","workerd/server/server\\.c\\+\\+.*warning:.*DurableObjectNamespace"],a=(e,r)=>r.length>0&&r.some(r=>r.test(e)),c=(e,r)=>{let n="";return{write:o=>{const t="string"==typeof o?o:o.toString();n+=t;const s=n.split(/\r?\n/);n=s.pop()??"";for(const n of s)a(n,r)||e.write(n+"\n")},flush:()=>{n&&!a(n,r)&&e.write(n),n=""}}},l=async(o,a={})=>{const l=r.join(o,"dashnex.json"),p=r.join(o,"package.json");if(t(`Checking for dashnex.json at: ${l}`),!(await n.pathExists(l)))throw new Error("This is not a DashNex project.");if(t("dashnex.json found, checking for package.json"),!(await n.pathExists(p)))throw new Error("package.json is missing.");let d;t("package.json found, checking for dev script");try{d=await n.readJson(p)}catch(u){throw s(u),new Error("Failed to read package.json.")}if(!d.scripts||!d.scripts.dev)throw new Error('The "dev" script is missing from package.json. Please add a "dev" script to package.json.');t("dev script found, checking for npm availability");const h=await(async r=>new Promise(n=>{const o=e(`${r} --version`,{stdio:"ignore",shell:!0});o.on("error",()=>{n(!1)}),o.on("close",e=>{n(0===e)})}))("npm");if(t(`npm available: ${h}`),!h)throw new Error("npm is not available. Please install npm to continue.");const f=a.https?["--","--experimental-https"]:[];t(`npm available, executing: npm run dev in ${o}${a.https?" -- --experimental-https":""}`);return(async(r,n=[],o=process.cwd(),t=[])=>{const i=n.length?`${r} ${n.join(" ")}`:r,a=t.length>0;return new Promise((r,n)=>{const l=e(i,{stdio:a?["inherit","pipe","pipe"]:"inherit",cwd:o,shell:!0,env:{...process.env,NODE_ENV:"development"}});if(l.on("error",e=>{s(e),n(e)}),a&&l.stdout&&l.stderr){const e=c(process.stdout,t),n=c(process.stderr,t);l.stdout.on("data",r=>e.write(r)),l.stderr.on("data",e=>n.write(e)),l.on("close",o=>{e.flush(),n.flush(),r(null===o?0:o)})}else l.on("close",e=>{r(null===e?0:e)})})})("npm run dev",f,o,(()=>{const e=[];for(const r of i)try{e.push(new RegExp(r))}catch{t(`Invalid dev output filter pattern ignored: ${r}`)}return e})())};class p{async execute(e={}){t("Dev flow started");try{const r=await l(process.cwd(),e);process.exit(r)}catch(r){if(r instanceof Error&&r.message.startsWith("EXIT:"))throw r;s(r),r instanceof Error?console.error(o.red(r.message)):console.error(o.red("Failed to run npm run dev")),process.exit(1)}}}export{p as DevCommand,l as runDevInDir};
1
+ import{spawn as e}from"child_process";import r from"path";import t from"fs-extra";import n from"chalk";import{debug as o,debugError as s}from"../lib/debug.js";const i=["Using vars defined in \\.env","\\(node:\\d+\\) MaxListenersExceededWarning:","\\(Use `node --trace-warnings","\\[WARNING\\].*You have defined bindings to the following internal Durable Objects","You have defined bindings to the following internal Durable Objects",'\\{"name":".+","class_name":".+"\\}',"These will not work in local development, but they should work in production","If you want to develop these locally, you can define your DO in a separate Worker","For detailed instructions, refer to the Durable Objects section here:","developers.cloudflare.com/workers/wrangler/api#supported-bindings","workerd/server/server\\.c\\+\\+.*warning:.*DurableObjectNamespace"],a=(e,r)=>r.length>0&&r.some(r=>r.test(e)),c=(e,r)=>{let t="";return{write:n=>{const s="string"==typeof n?n:n.toString();t+=s;const i=t.split(/\r?\n/);t=i.pop()??"";for(const t of i){const n=t.trim();n?a(n,r)?o(`Filtered: ${n}`):e.write(t+"\n"):o("Filtered: <empty line>")}},flush:()=>{const n=t.trim();if(n){if(a(n,r))return o(`Filtered: ${n}`),void(t="");e.write(t),t=""}else t=""}}},l=async(n,a={})=>{const l=r.join(n,"dashnex.json"),d=r.join(n,"package.json");if(o(`Checking for dashnex.json at: ${l}`),!(await t.pathExists(l)))throw new Error("This is not a DashNex project.");if(o("dashnex.json found, checking for package.json"),!(await t.pathExists(d)))throw new Error("package.json is missing.");let p;o("package.json found, checking for dev script");try{p=await t.readJson(d)}catch(u){throw s(u),new Error("Failed to read package.json.")}if(!p.scripts||!p.scripts.dev)throw new Error('The "dev" script is missing from package.json. Please add a "dev" script to package.json.');o("dev script found, checking for npm availability");const h=await(async r=>new Promise(t=>{const n=e(`${r} --version`,{stdio:"ignore",shell:!0});n.on("error",()=>{t(!1)}),n.on("close",e=>{t(0===e)})}))("npm");if(o(`npm available: ${h}`),!h)throw new Error("npm is not available. Please install npm to continue.");const f=a.https?["--","--experimental-https"]:[];o(`npm available, executing: npm run dev in ${n}${a.https?" -- --experimental-https":""}`);return(async(r,t=[],n=process.cwd(),o=[])=>{const i=t.length?`${r} ${t.join(" ")}`:r,a=o.length>0;return new Promise((r,t)=>{const l=e(i,{stdio:a?["inherit","pipe","pipe"]:"inherit",cwd:n,shell:!0,env:{...process.env,NODE_ENV:"development"}});if(l.on("error",e=>{s(e),t(e)}),a&&l.stdout&&l.stderr){const e=c(process.stdout,o),t=c(process.stderr,o);l.stdout.on("data",r=>e.write(r)),l.stderr.on("data",e=>t.write(e)),l.on("close",n=>{e.flush(),t.flush(),r(null===n?0:n)})}else l.on("close",e=>{r(null===e?0:e)})})})("npm run dev",f,n,(()=>{const e=[];for(const r of i)try{e.push(new RegExp(r))}catch{o(`Invalid dev output filter pattern ignored: ${r}`)}return e})())};class d{async execute(e={}){o("Dev flow started");try{const r=await l(process.cwd(),e);process.exit(r)}catch(r){if(r instanceof Error&&r.message.startsWith("EXIT:"))throw r;s(r),r instanceof Error?console.error(n.red(r.message)):console.error(n.red("Failed to run npm run dev")),process.exit(1)}}}export{d as DevCommand,l as runDevInDir};
@@ -1 +1 @@
1
- const e="@dashnex/cli",a="0.5.54",n="Command-line interface for DashNex framework",o={name:e,version:a,description:n};export{o as default,n as description,e as name,a as version};
1
+ const e="@dashnex/cli",a="0.5.56",n="Command-line interface for DashNex framework",o={name:e,version:a,description:n};export{o as default,n as description,e as name,a as version};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dashnex/cli",
4
- "version": "0.5.54",
4
+ "version": "0.5.56",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",