@dashnex/cli 0.5.41 → 0.5.43

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
@@ -51,9 +51,7 @@ dashnex <command> [options]
51
51
 
52
52
  **app push**:
53
53
  - `--deploy` / `--no-deploy` — Auto-deploy or skip deploy after push
54
+ - `--no-check` — Skip pre-push checks
54
55
 
55
56
  **app delete**:
56
57
  - `-y, --yes` — Skip confirmation prompt
57
-
58
- **app deploy**:
59
- - `--no-check` — Skip pre-deploy checks
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as o}from"commander";import e from"chalk";import n from"fs-extra";import s from"path";import{fileURLToPath as a}from"url";import c from"dotenv";import r from"./package.json.js";import{isUserInterrupt as t,INTERRUPTED_MESSAGE as i}from"./lib/errors.js";const l=new o,{name:d,version:m,description:p}=r;async function f(o,a){const c=[];try{const e=function(o,e){const a=s.join(e,"package.json");if(n.existsSync(a))try{if(JSON.parse(n.readFileSync(a,"utf8")).name===o)return e}catch{}return s.join(e,"node_modules",o)}(o,a),r=s.join(e,"dist","commands","index.js");if(n.existsSync(r)){const o=await import(r);let e=[];o.default?e=Array.isArray(o.default)?o.default:[]:o.commands&&(e=Array.isArray(o.commands)?o.commands:[]),e.length>0&&c.push(...e)}}catch(r){if(process.env.DEBUG){const n=r instanceof Error?r.message:String(r);console.log(e.yellow(`Module ${o} has no commands or failed to load: ${n}`))}}return c}function u(o,n,s={}){const a=o.command(n.name).description(n.description);"pull"===n.name&&a.arguments("[folder]"),n.options&&n.options.forEach(o=>{void 0!==o.defaultValue?"number"==typeof o.defaultValue?a.option(o.flags,o.description,String(o.defaultValue)):a.option(o.flags,o.description,o.defaultValue):a.option(o.flags,o.description)}),n.subcommands&&n.subcommands.forEach(o=>{u(a,o,{...s,...n.options})}),"pull"===n.name?a.action(async(o,a,c)=>{try{const e={...s,...a};o&&(e.folder=o),await n.handler.execute(e)}catch(r){if(t(r))return void console.log(e.yellow(i));console.error(e.red(`❌ Command failed in ${n.name}:`),r),process.exit(1)}}):a.action(async(o,a)=>{try{const e={...s,...o};await n.handler.execute(e)}catch(c){if(t(c))return void console.log(e.yellow(i));console.error(e.red(`❌ Command failed in ${n.name}:`),c),process.exit(1)}})}l.name(d).description(p).version(m),async function(){c.config({quiet:!0}),process.env.DASHNEX_CLI="1";let o=process.cwd();const r=s.dirname(a(import.meta.url)),t=s.resolve(r,"..");process.env.DEBUG&&(console.log(`CLI started from directory: ${o}`),console.log(`CLI package directory: ${t}`));const i=await async function(o){try{const e=[],a=/* @__PURE__ */new Set,c=o=>{a.has(o)||(a.add(o),e.push(o))},r=s.join(o,"dashnex.json");if(n.existsSync(r)){const e=s.join(o,"package.json");if(n.existsSync(e)){const o=JSON.parse(n.readFileSync(e,"utf8"));o.name&&c(o.name)}}const t=s.join(o,"package.json");if(!n.existsSync(t))return e;const i=JSON.parse(n.readFileSync(t,"utf8")),l={...i.dependencies,...i.devDependencies,...i.optionalDependencies};for(const[d]of Object.entries(l)){const e=s.join(o,"node_modules",d);n.existsSync(s.join(e,"dashnex.json"))&&c(d)}return e}catch(e){if(process.env.DEBUG){const o=e instanceof Error?e.message:String(e);console.log("⚠ Error reading app package.json:",o)}return[]}}(o),d=t.includes("node_modules");let m=!1;try{const e=s.join(o,"package.json");if(await n.pathExists(e)){const o=JSON.parse(await n.readFile(e,"utf8"));m="@dashnex/cli"in{...o.dependencies,...o.devDependencies,...o.optionalDependencies}}}catch{}!d&&!m||i.includes("@dashnex/cli")||i.push("@dashnex/cli"),process.env.DEBUG&&(console.log(`CLI package directory: ${t}`),console.log(`Is installed package: ${d}`),console.log(`CLI in dependencies: ${m}`),console.log(`Discovered modules: ${i.join(", ")}`));for(const a of i){let c=[];if("@dashnex/cli"===a&&(d||m))try{const o=s.join(t,"dist","commands","index.js");if(process.env.DEBUG&&console.log(`Loading @dashnex/cli commands from: ${o}`),await n.pathExists(o)){const e=await import(o);e.default?c=Array.isArray(e.default)?e.default:[]:e.commands&&(c=Array.isArray(e.commands)?e.commands:[]),process.env.DEBUG&&console.log(`Loaded ${c.length} commands from @dashnex/cli`)}}catch(p){if(process.env.DEBUG){const o=p instanceof Error?p.message:String(p);console.log(e.yellow(`Failed to load @dashnex/cli commands: ${o}`))}}else c=await f(a,o);for(const o of c)u(l,o)}try{const{default:e}=await import(s.join(o,"dist","commands","index.js"));if(e&&Array.isArray(e))for(const o of e)u(l,o)}catch(p){process.env.DEBUG&&console.error(e.yellow("⚠ Failed to discover application commands"))}l.parse(process.argv),process.argv.slice(2).length||l.outputHelp()}().catch(o=>{t(o)&&(console.log(e.yellow(i)),process.exit(0)),console.error(e.red("❌ CLI failed:"),o),process.exit(1)});
2
+ import{Command as o}from"commander";import e from"chalk";import n from"fs-extra";import s from"path";import{fileURLToPath as a}from"url";import c from"dotenv";import t from"./package.json.js";import{isUserInterrupt as r,INTERRUPTED_MESSAGE as i}from"./lib/errors.js";const d=new o,{name:l,version:m,description:p}=t;async function f(o,a){const c=[];try{const e=function(o,e){const a=s.join(e,"package.json");if(n.existsSync(a))try{if(JSON.parse(n.readFileSync(a,"utf8")).name===o)return e}catch{}return s.join(e,"node_modules",o)}(o,a),t=s.join(e,"dist","commands","index.js");if(n.existsSync(t)){const o=await import(t);let e=[];o.default?e=Array.isArray(o.default)?o.default:[]:o.commands&&(e=Array.isArray(o.commands)?o.commands:[]),e.length>0&&c.push(...e)}}catch(t){if(process.env.DEBUG){const n=t instanceof Error?t.message:String(t);console.log(e.yellow(`Module ${o} has no commands or failed to load: ${n}`))}}return c}function u(o,n,s={}){const a=o.command(n.name).description(n.description);"pull"===n.name&&a.arguments("[folder]"),n.options&&n.options.forEach(o=>{void 0!==o.defaultValue?"number"==typeof o.defaultValue?a.option(o.flags,o.description,String(o.defaultValue)):a.option(o.flags,o.description,o.defaultValue):a.option(o.flags,o.description)}),n.subcommands&&n.subcommands.forEach(o=>{u(a,o,{...s,...n.options})});const c=n.subcommands&&n.subcommands.length>0;"pull"===n.name?a.action(async(o,a,c)=>{try{const e={...s,...a};o&&(e.folder=o),await n.handler.execute(e)}catch(t){if(r(t))return void console.log(e.yellow(i));console.error(e.red(`❌ Command failed in ${n.name}:`),t),process.exit(1)}}):c?a.action(async()=>{a.outputHelp()}):a.action(async(o,a)=>{try{const e={...s,...o};await n.handler.execute(e)}catch(c){if(r(c))return void console.log(e.yellow(i));console.error(e.red(`❌ Command failed in ${n.name}:`),c),process.exit(1)}})}d.name(l).description(p).version(m),async function(){c.config({quiet:!0}),process.env.DASHNEX_CLI="1";let o=process.cwd();const t=s.dirname(a(import.meta.url)),r=s.resolve(t,"..");process.env.DEBUG&&(console.log(`CLI started from directory: ${o}`),console.log(`CLI package directory: ${r}`));const i=await async function(o){try{const e=[],a=/* @__PURE__ */new Set,c=o=>{a.has(o)||(a.add(o),e.push(o))},t=s.join(o,"dashnex.json");if(n.existsSync(t)){const e=s.join(o,"package.json");if(n.existsSync(e)){const o=JSON.parse(n.readFileSync(e,"utf8"));o.name&&c(o.name)}}const r=s.join(o,"package.json");if(!n.existsSync(r))return e;const i=JSON.parse(n.readFileSync(r,"utf8")),d={...i.dependencies,...i.devDependencies,...i.optionalDependencies};for(const[l]of Object.entries(d)){const e=s.join(o,"node_modules",l);n.existsSync(s.join(e,"dashnex.json"))&&c(l)}return e}catch(e){if(process.env.DEBUG){const o=e instanceof Error?e.message:String(e);console.log("⚠ Error reading app package.json:",o)}return[]}}(o),l=r.includes("node_modules");let m=!1;try{const e=s.join(o,"package.json");if(await n.pathExists(e)){const o=JSON.parse(await n.readFile(e,"utf8"));m="@dashnex/cli"in{...o.dependencies,...o.devDependencies,...o.optionalDependencies}}}catch{}!l&&!m||i.includes("@dashnex/cli")||i.push("@dashnex/cli"),process.env.DEBUG&&(console.log(`CLI package directory: ${r}`),console.log(`Is installed package: ${l}`),console.log(`CLI in dependencies: ${m}`),console.log(`Discovered modules: ${i.join(", ")}`));for(const a of i){let c=[];if("@dashnex/cli"===a&&(l||m))try{const o=s.join(r,"dist","commands","index.js");if(process.env.DEBUG&&console.log(`Loading @dashnex/cli commands from: ${o}`),await n.pathExists(o)){const e=await import(o);e.default?c=Array.isArray(e.default)?e.default:[]:e.commands&&(c=Array.isArray(e.commands)?e.commands:[]),process.env.DEBUG&&console.log(`Loaded ${c.length} commands from @dashnex/cli`)}}catch(p){if(process.env.DEBUG){const o=p instanceof Error?p.message:String(p);console.log(e.yellow(`Failed to load @dashnex/cli commands: ${o}`))}}else c=await f(a,o);for(const o of c)u(d,o)}try{const{default:e}=await import(s.join(o,"dist","commands","index.js"));if(e&&Array.isArray(e))for(const o of e)u(d,o)}catch(p){process.env.DEBUG&&console.error(e.yellow("⚠ Failed to discover application commands"))}d.parse(process.argv),process.argv.slice(2).length||function(o){const e=[];e.push("Usage: dashnex [options] [command]"),e.push(""),e.push(o.description()),e.push(""),e.push("Options:"),o.options.forEach(o=>{const n=o.flags.padEnd(20);e.push(` ${n} ${o.description}`)}),e.push(""),e.push("Commands:"),o.commands.forEach(o=>{const n=` ${o.name().padEnd(20)} ${o.description()}`;e.push(n),o.commands.length>0&&o.commands.forEach(n=>{const s=` ${(o.name()+" "+n.name()).padEnd(20)} ${n.description()}`;e.push(s)})}),console.log(e.join("\n"))}(d)}().catch(o=>{r(o)&&(console.log(e.yellow(i)),process.exit(0)),console.error(e.red("❌ CLI failed:"),o),process.exit(1)});
@@ -1 +1 @@
1
- import e from"chalk";import{debug as t,debugError as o}from"../../lib/debug.js";import{getDeployerBase as s,getBusinessApiBase as r}from"../../lib/api.js";import{ensureLoggedIn as n}from"../../services/auth.js";import{createSpinner as a}from"../../lib/spinner.js";import{isUserInterrupt as i,INTERRUPTED_MESSAGE as c}from"../../lib/errors.js";import{getApplicationUrl as l}from"../../lib/app-url.js";import{ensureAgreements as p}from"../../services/agreements.js";import{CheckCommand as d}from"../check.js";const m=3e5,f=99,u=e=>new Promise(t=>setTimeout(t,e)),y=async(s,r,n,a)=>{const i=await fetch(s,{method:"GET",headers:{Authorization:`Bearer ${r}`,Accept:"text/event-stream"}});if(t(`SSE connection opened: ${i.status}`),!i.ok){const t=i.status;let o="Failed to start deployment.";if(401===t||403===t)o="Please run 'dashnex login' to authenticate.";else try{const e=await i.text(),t=JSON.parse(e);"string"==typeof t.error?o=t.error:"string"==typeof t.message&&(o=t.message)}catch{}throw console.error(e.red(o)),new Error(`HTTP ${t}: ${o}`)}if(!i.body)throw new Error("Response body is null");t("SSE connection established successfully"),a?.();const c=i.body.getReader();try{for await(const e of async function*(e){const t=new TextDecoder("utf-8");let o="";for(;;){const{value:s,done:r}=await e.read();if(r)break;o+=t.decode(s,{stream:!0});const n=o.split("\n");o=n.pop()||"";let a="";for(const e of n)e.startsWith("data: ")?a=e.slice(6):""===e&&a&&(yield{data:a},a="")}if(o.startsWith("data: ")){const e=o.slice(6);e&&(yield{data:e})}}(c))try{if(!e.data){t("Received empty SSE event");continue}const o=JSON.parse(e.data);t(`SSE message received: ${JSON.stringify(o)}`),n(o)}catch(l){o(l),t(`Failed to parse SSE event data: ${e.data}`)}}finally{c.releaseLock()}};class h{async execute(r={}){t("Deploy flow started");if(!1===r.check)t("Skipping pre-deploy checks (--no-check)");else{t("Running pre-deploy checks");const o=new d;await o.run()||(console.error(e.red("Deploy aborted: checks failed.")),process.exit(1))}const l=await n();if(!l)return;if(!(await p(l.token,{ciMode:!0})))return;const h=`${s()}/business/v1/applications/deploy`;t(`GET ${h} (SSE)`);let g=0,w="",S=!1,$=0,b=!1;const k=a();let v=0,x=0,D=null;const E=(e,t)=>{const o=Math.round(e);k.text(`[${o}%] ${t}`)},j=()=>{T();const e=g,t=Date.now(),o=m*((f-e)/f);D=setInterval(()=>{const s=Date.now()-t;let r;if(x>t){const e=Date.now()-x,t=f-v,o=t*3030.3030303030305;r=Math.min(v+e/o*t,f)}else r=Math.min(e+s/o*(f-e),f);r>g&&(g=r,E(g,w))},200)},T=()=>{D&&(clearInterval(D),D=null)};let M=!1;const C=t=>{if(b=!0,"string"==typeof t.error)return T(),k.stop(),console.error(e.red(t.error)),S=!0,void(M=!0);if("string"==typeof t.message&&(w=t.message),"number"==typeof t.progress&&(v=t.progress,x=Date.now(),t.progress>g&&(g=t.progress)),"string"==typeof t.message||"number"==typeof t.progress)if(g>=100){T(),k.stop();const t=w||"Application is deployed";process.stdout.write(`${e.green(t)}\n`),S=!0}else E(g,w)};for(;$<=5;)try{return b?E(g,w):k.start("Connecting..."),j(),await y(h,l.token,C,()=>{b||(k.text(`[${Math.round(g)}%] Deployment in progress...`),w="Deployment in progress...")}),T(),k.stop(),t("SSE connection closed"),M&&process.exit(1),void(S&&await this.showDeployedUrl(l.token))}catch(R){if(T(),o(R),t(`SSE connection error: ${R}`),S)return k.stop(),void(M&&process.exit(1));if(i(R))return k.stop(),void console.log(e.yellow(c));R instanceof Error&&R.message.startsWith("HTTP")&&(k.stop(),console.error(e.red("Could not complete deployment. Check your connection and try again.")),process.exit(1)),$++,$>5&&(k.stop(),console.error(e.red("Deployment failed. Maximum reconnection attempts exceeded.")),process.exit(1));const s=Math.min(1e3*Math.pow(2,$-1),3e4);t(`Connection error. Reconnecting in ${s/1e3}s... (attempt ${$}/5)`),await u(s)}}async showDeployedUrl(s){try{const o=`${r()}/business/v1/applications`;t(`GET ${o} (for deployed URL)`);const n=await fetch(o,{headers:{Authorization:`Bearer ${s}`}});if(!n.ok)return;const a=await n.json().catch(()=>({})),i=l({subdomain:a.subdomain,appFullCustomDomain:a.appFullCustomDomain});i&&console.log(`Application is deployed to ${e.cyan(i)}`)}catch(n){o(n)}}}export{h as DeployCommand};
1
+ import e from"chalk";import{debug as t,debugError as o}from"../../lib/debug.js";import{getDeployerBase as s,getBusinessApiBase as r}from"../../lib/api.js";import{ensureLoggedIn as n}from"../../services/auth.js";import{createSpinner as a}from"../../lib/spinner.js";import{isUserInterrupt as i,INTERRUPTED_MESSAGE as c}from"../../lib/errors.js";import{getApplicationUrl as l}from"../../lib/app-url.js";import{ensureAgreements as p}from"../../services/agreements.js";const d=3e5,m=99,f=e=>new Promise(t=>setTimeout(t,e)),u=async(s,r,n,a)=>{const i=await fetch(s,{method:"GET",headers:{Authorization:`Bearer ${r}`,Accept:"text/event-stream"}});if(t(`SSE connection opened: ${i.status}`),!i.ok){const t=i.status;let o="Failed to start deployment.";if(401===t||403===t)o="Please run 'dashnex login' to authenticate.";else try{const e=await i.text(),t=JSON.parse(e);"string"==typeof t.error?o=t.error:"string"==typeof t.message&&(o=t.message)}catch{}throw console.error(e.red(o)),new Error(`HTTP ${t}: ${o}`)}if(!i.body)throw new Error("Response body is null");t("SSE connection established successfully"),a?.();const c=i.body.getReader();try{for await(const e of async function*(e){const t=new TextDecoder("utf-8");let o="";for(;;){const{value:s,done:r}=await e.read();if(r)break;o+=t.decode(s,{stream:!0});const n=o.split("\n");o=n.pop()||"";let a="";for(const e of n)e.startsWith("data: ")?a=e.slice(6):""===e&&a&&(yield{data:a},a="")}if(o.startsWith("data: ")){const e=o.slice(6);e&&(yield{data:e})}}(c))try{if(!e.data){t("Received empty SSE event");continue}const o=JSON.parse(e.data);t(`SSE message received: ${JSON.stringify(o)}`),n(o)}catch(l){o(l),t(`Failed to parse SSE event data: ${e.data}`)}}finally{c.releaseLock()}};class y{async execute(){t("Deploy flow started");const r=await n();if(!r)return;if(!(await p(r.token,{ciMode:!0})))return;const l=`${s()}/business/v1/applications/deploy`;t(`GET ${l} (SSE)`);let y=0,h="",g=!1,w=0,S=!1;const $=a();let b=0,v=0,x=null;const E=(e,t)=>{const o=Math.round(e);$.text(`[${o}%] ${t}`)},D=()=>{k();const e=y,t=Date.now(),o=d*((m-e)/m);x=setInterval(()=>{const s=Date.now()-t;let r;if(v>t){const e=Date.now()-v,t=m-b,o=t*3030.3030303030305;r=Math.min(b+e/o*t,m)}else r=Math.min(e+s/o*(m-e),m);r>y&&(y=r,E(y,h))},200)},k=()=>{x&&(clearInterval(x),x=null)};let T=!1;const j=t=>{if(S=!0,"string"==typeof t.error)return k(),$.stop(),console.error(e.red(t.error)),g=!0,void(T=!0);if("string"==typeof t.message&&(h=t.message),"number"==typeof t.progress&&(b=t.progress,v=Date.now(),t.progress>y&&(y=t.progress)),"string"==typeof t.message||"number"==typeof t.progress)if(y>=100){k(),$.stop();const t=h||"Application is deployed";process.stdout.write(`${e.green(t)}\n`),g=!0}else E(y,h)};for(;w<=5;)try{return S?E(y,h):$.start("Connecting..."),D(),await u(l,r.token,j,()=>{S||($.text(`[${Math.round(y)}%] Deployment in progress...`),h="Deployment in progress...")}),k(),$.stop(),t("SSE connection closed"),T&&process.exit(1),void(g&&await this.showDeployedUrl(r.token))}catch(M){if(k(),o(M),t(`SSE connection error: ${M}`),g)return $.stop(),void(T&&process.exit(1));if(i(M))return $.stop(),void console.log(e.yellow(c));M instanceof Error&&M.message.startsWith("HTTP")&&($.stop(),console.error(e.red("Could not complete deployment. Check your connection and try again.")),process.exit(1)),w++,w>5&&($.stop(),console.error(e.red("Deployment failed. Maximum reconnection attempts exceeded.")),process.exit(1));const s=Math.min(1e3*Math.pow(2,w-1),3e4);t(`Connection error. Reconnecting in ${s/1e3}s... (attempt ${w}/5)`),await f(s)}}async showDeployedUrl(s){try{const o=`${r()}/business/v1/applications`;t(`GET ${o} (for deployed URL)`);const n=await fetch(o,{headers:{Authorization:`Bearer ${s}`}});if(!n.ok)return;const a=await n.json().catch(()=>({})),i=l({subdomain:a.subdomain,appFullCustomDomain:a.appFullCustomDomain});i&&console.log(`Application is deployed to ${e.cyan(i)}`)}catch(n){o(n)}}}export{y as DeployCommand};
@@ -1 +1 @@
1
- import{CreateCommand as e}from"./create.js";import{PullCommand as o}from"./pull.js";import{PushCommand as p}from"./push.js";import{DeleteCommand as a}from"./delete.js";import{DeployCommand as i}from"./deploy.js";import{StatusCommand as t}from"./status.js";const s={name:"app",description:"Manage DashNex applications",handler:{execute:async()=>{}},options:[],subcommands:[{name:"create",description:"Create a new DashNex application",handler:new e,options:[{flags:"-t, --template <template>",description:"Template (name@branch-or-tag)",defaultValue:"webapp-base@live"},{flags:"--subdomain <subdomain>",description:"Subdomain (CI mode, skip prompts)"}]},{name:"pull",description:"Pull existing application to specified folder",handler:new o,options:[{flags:"-y, --yes",description:"Skip prompts and child commands (CI mode)"}]},{name:"push",description:"Push local application to DashNex",handler:new p,options:[{flags:"--deploy",description:"Auto-deploy after push (skip prompt)"},{flags:"--no-deploy",description:"Skip deploy prompt"}]},{name:"delete",description:"Delete application from DashNex",handler:new a,options:[{flags:"-y, --yes",description:"Skip confirmation prompt"}]},{name:"deploy",description:"Deploy application to DashNex",handler:new i,options:[{flags:"--no-check",description:"Skip pre-deploy checks"}]},{name:"status",description:"Show current application status",handler:new t,options:[]}]};export{s as default};
1
+ import{CreateCommand as e}from"./create.js";import{PullCommand as o}from"./pull.js";import{PushCommand as p}from"./push.js";import{DeleteCommand as a}from"./delete.js";import{DeployCommand as i}from"./deploy.js";import{StatusCommand as t}from"./status.js";const s={name:"app",description:"Manage DashNex applications",handler:{execute:async()=>{}},options:[],subcommands:[{name:"create",description:"Create a new DashNex application",handler:new e,options:[{flags:"-t, --template <template>",description:"Template (name@branch-or-tag)",defaultValue:"webapp-base@live"},{flags:"--subdomain <subdomain>",description:"Subdomain (CI mode, skip prompts)"}]},{name:"pull",description:"Pull existing application to specified folder",handler:new o,options:[{flags:"-y, --yes",description:"Skip prompts and child commands (CI mode)"}]},{name:"push",description:"Push local application to DashNex",handler:new p,options:[{flags:"--deploy",description:"Auto-deploy after push (skip prompt)"},{flags:"--no-deploy",description:"Skip deploy prompt"},{flags:"--no-check",description:"Skip pre-push checks"}]},{name:"delete",description:"Delete application from DashNex",handler:new a,options:[{flags:"-y, --yes",description:"Skip confirmation prompt"}]},{name:"deploy",description:"Deploy application to DashNex",handler:new i,options:[]},{name:"status",description:"Show current application status",handler:new t,options:[]}]};export{s as default};
@@ -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 a from"inquirer";import{debug as n,debugError as p}from"../../lib/debug.js";import{getBusinessApiBase as c}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";const u=[".dashnex",".git",".next",".wrangler"],g=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(u.some(e=>r===e||r.startsWith(`${e}/`)))continue;if(i.ignores(r))continue;const a=t.join(e,o.name);if(o.isDirectory()){const e=await g(a,i);s.push(...e)}else o.isFile()&&s.push(a)}return s};class w{async execute(w={}){n("Push flow started");const y=await l();if(!y)return;const j=process.cwd(),x=t.join(j,".gitignore"),v=r();if(v.add(u),await o.pathExists(x)){const e=await o.readFile(x,"utf8");v.add(e)}n("Building file list");const $=await g(j,v);n(`Including ${$.length} files`);const b=new s;for(const e of $){const o=t.relative(j,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`),z=d();try{z.start("Packaging application..."),b.writeZip(F),n(`Zip written to ${F}`);const t=`${c()}/business/v1/cli/push`;n(`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 p=new Headers;p.set("Authorization",`Bearer ${y.token}`),z.text("Uploading...");const l=await fetch(t,{method:"POST",headers:p,body:r});if(z.stop(),n(`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!==w.deploy)d=w.deploy,n(`Deploy decided via flag: ${d}`);else{d=(await a.prompt([{type:"confirm",name:"deploy",message:"Deploy the application?",default:!0}])).deploy,n(`User chose to deploy: ${d}`)}if(d){n("Running deploy flow");const e=new h;await e.execute()}}catch(D){if(z.stop(),p(D),D instanceof Error&&D.message.startsWith("EXIT:"))throw D;if(m(D))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(()=>{}),n("Temp zip removed")}}}export{w 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"],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 +1 @@
1
- const e="@dashnex/cli",a="0.5.41",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.43",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,8 +1,5 @@
1
1
  import { CliCommand } from '@dashnex/types';
2
- export interface DeployCommandOptions {
3
- check?: boolean;
4
- }
5
2
  export declare class DeployCommand implements CliCommand {
6
- execute(options?: DeployCommandOptions): Promise<void>;
3
+ execute(): Promise<void>;
7
4
  private showDeployedUrl;
8
5
  }
@@ -1,6 +1,7 @@
1
1
  import { CliCommand } from '@dashnex/types';
2
2
  export interface PushCommandOptions {
3
3
  deploy?: boolean;
4
+ check?: boolean;
4
5
  }
5
6
  export declare class PushCommand implements CliCommand {
6
7
  execute(options?: PushCommandOptions): Promise<void>;
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.41",
4
+ "version": "0.5.43",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "dotenv": "^17.3.1",
32
32
  "fs-extra": "^11.3.3",
33
33
  "ignore": "^7.0.5",
34
- "inquirer": "^13.2.5"
34
+ "inquirer": "^13.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@dashnex/types": "^0.5.14",
@@ -39,7 +39,7 @@
39
39
  "@types/fs-extra": "^11.0.4",
40
40
  "@types/inquirer": "^9.0.9",
41
41
  "@types/node": "^25.3.0",
42
- "eslint": "^9.39.2",
42
+ "eslint": "^9.39.3",
43
43
  "rollup-plugin-preserve-directives": "^0.4.0",
44
44
  "terser": "^5.46.0",
45
45
  "typescript": "^5.9.3",