@dashnex/cli 0.5.27 → 0.5.32
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 +18 -2
- package/dist/commands/app/create.js +1 -1
- package/dist/commands/app/index.js +1 -1
- package/dist/commands/app/pull.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/commands/app/create.d.ts +0 -1
- package/dist/src/commands/app/pull.d.ts +0 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,6 @@ dashnex <command> [options]
|
|
|
24
24
|
| `login` | Log in to your DashNex account |
|
|
25
25
|
| `logout` | Log out and remove local credentials |
|
|
26
26
|
| `whoami` | Show current logged-in business and user |
|
|
27
|
-
| `select` | Switch to a different business |
|
|
28
27
|
| `app create` | Create a new DashNex application |
|
|
29
28
|
| `app pull` | Pull existing application to specified folder |
|
|
30
29
|
| `app push` | Push local application to DashNex |
|
|
@@ -36,4 +35,21 @@ dashnex <command> [options]
|
|
|
36
35
|
|
|
37
36
|
### Options
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
**login**:
|
|
39
|
+
- `--email <email>` — Email address
|
|
40
|
+
- `--password <password>` — Password
|
|
41
|
+
- `--code <code>` — 2FA code
|
|
42
|
+
- `--business <id>` — Business ID to select
|
|
43
|
+
|
|
44
|
+
**app create**:
|
|
45
|
+
- `--subdomain <subdomain>` — Subdomain
|
|
46
|
+
- `-t, --template <template>` — Template, optional (name@branch-or-tag)
|
|
47
|
+
|
|
48
|
+
**app pull**:
|
|
49
|
+
- `-y, --yes` — Skip prompts and child commands
|
|
50
|
+
|
|
51
|
+
**app push**:
|
|
52
|
+
- `--deploy` / `--no-deploy` — Auto-deploy or skip deploy after push
|
|
53
|
+
|
|
54
|
+
**app delete**:
|
|
55
|
+
- `-y, --yes` — Skip confirmation prompt
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"inquirer";import t from"chalk";import{debug as o,debugError as s}from"../../lib/debug.js";import{getBusinessApiBase as a}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as r}from"../../lib/spinner.js";import{isUserInterrupt as n,INTERRUPTED_MESSAGE as l}from"../../lib/errors.js";import{PullCommand as c}from"./pull.js";const p=e=>Array.isArray(e.message)&&e.message.length>0?e.message.join("\n"):"string"==typeof e.message?e.message:"string"==typeof e.error?e.error:void 0,u=e=>new Promise(t=>setTimeout(t,e));class d{async pollApplicationCreated(e,t,a=5e3,i=6e4){const r=Date.now();let n=0;for(;Date.now()-r<i;){n++,o(`Polling application status (attempt ${n})...`);try{const s=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(o(`Poll response: ${s.status}`),200===s.status){const e=await s.json();if(o(`Poll response body status: ${e.status}`),"creating"!==e.status)return o(`Application status is "${e.status}", creation complete`),{ready:!0,status:e.status};o('Application status is still "creating", continuing to poll...')}}catch(l){s(l),o(`Poll attempt ${n} failed with network error`)}await u(a)}return{ready:!1}}async execute(u={}){o("Create flow started");const d=await i();if(!d)return;o("Auth valid, checking if business already has application");const h=r(),m=`${a()}/business/v1/applications`;o(`GET ${m}`),h.start("Checking application status...");try{const e=await fetch(m,{headers:{Authorization:`Bearer ${d.token}`}});h.stop(),o(`Applications response: ${e.status}`);const s=await e.text();o(`Applications response body: ${s}`),404!==e.status&&(console.error(t.red("Business already has an application. Run 'dashnex app pull' to pull the existing one.")),process.exit(1))}catch(
|
|
1
|
+
import e from"inquirer";import t from"chalk";import{debug as o,debugError as s}from"../../lib/debug.js";import{getBusinessApiBase as a}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as r}from"../../lib/spinner.js";import{isUserInterrupt as n,INTERRUPTED_MESSAGE as l}from"../../lib/errors.js";import{PullCommand as c}from"./pull.js";const p=e=>Array.isArray(e.message)&&e.message.length>0?e.message.join("\n"):"string"==typeof e.message?e.message:"string"==typeof e.error?e.error:void 0,u=e=>new Promise(t=>setTimeout(t,e));class d{async pollApplicationCreated(e,t,a=5e3,i=6e4){const r=Date.now();let n=0;for(;Date.now()-r<i;){n++,o(`Polling application status (attempt ${n})...`);try{const s=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(o(`Poll response: ${s.status}`),200===s.status){const e=await s.json();if(o(`Poll response body status: ${e.status}`),"creating"!==e.status)return o(`Application status is "${e.status}", creation complete`),{ready:!0,status:e.status};o('Application status is still "creating", continuing to poll...')}}catch(l){s(l),o(`Poll attempt ${n} failed with network error`)}await u(a)}return{ready:!1}}async execute(u={}){o("Create flow started");const d=await i();if(!d)return;o("Auth valid, checking if business already has application");const h=r(),m=`${a()}/business/v1/applications`;o(`GET ${m}`),h.start("Checking application status...");try{const e=await fetch(m,{headers:{Authorization:`Bearer ${d.token}`}});h.stop(),o(`Applications response: ${e.status}`);const s=await e.text();o(`Applications response body: ${s}`),404!==e.status&&(console.error(t.red("Business already has an application. Run 'dashnex app pull' to pull the existing one.")),process.exit(1))}catch(k){if(h.stop(),s(k),k instanceof Error&&k.message.startsWith("EXIT:"))throw k;if(n(k))return void console.log(t.yellow(l));console.error(t.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}let f;o("No existing application, proceeding to subdomain prompt");const g=e=>`${a()}/business/v1/applications/check-subdomain?subdomain=${encodeURIComponent(e)}`,y=void 0!==u.subdomain;let b=u.subdomain?.trim();for(;;){if(b)f=b,b=void 0,o(`Subdomain provided via flag: ${f}`);else{if(y)return console.error(t.red("Subdomain is not available.")),void process.exit(1);{const{sub:t}=await e.prompt([{type:"input",name:"sub",message:"Pick your subdomain:",validate:e=>!!e.trim()||"Subdomain is required"}]);f=t.trim()}}o(`Checking subdomain: ${f}`);const a=g(f);o(`GET ${a}`),h.start("Checking subdomain...");try{const e=await fetch(a,{headers:{Authorization:`Bearer ${d.token}`}});h.stop(),o(`Check subdomain response: ${e.status}`);const s=await e.text();if(o(`Check subdomain response body: ${s}`),!e.ok){const a=e.headers.get("content-type")??"";let i="Failed to check subdomain availability.";if(401!==e.status&&403!==e.status||(i="Please run 'dashnex login' to authenticate.",console.error(t.red(i)),process.exit(1)),a.includes("application/json")){const e=JSON.parse(s);o(`Check subdomain error body: ${JSON.stringify(e)}`);const t=p(e);t&&(i=t)}console.error(t.red(i));continue}const i=JSON.parse(s);if(o(`Check subdomain parsed body: ${JSON.stringify(i)}`),i.available){o(`Subdomain ${f} is available`);break}console.error(t.red("Subdomain is not available. Please choose a different one."))}catch(k){if(h.stop(),s(k),k instanceof Error&&k.message.startsWith("EXIT:"))throw k;if(n(k))return void console.log(t.yellow(l));console.error(t.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}const w=`${a()}/business/v1/cli/create`;o(`POST ${w}`);const $={subdomain:f};u.template&&($.template=u.template,o(`Template: ${u.template}`));const x=JSON.stringify($);o(`Create request body: ${x}`),h.start("Creating application...");try{const i=await fetch(w,{method:"POST",headers:{Authorization:`Bearer ${d.token}`,"Content-Type":"application/json"},body:x});h.stop(),o(`Create response: ${i.status}`);const r=await i.text();if(o(`Create response body: ${r}`),503===i.status){o("Create returned 503, polling for application creation..."),console.log(t.yellow("Application is being created, please wait..."));const e=`${a()}/business/v1/applications`,s=await this.pollApplicationCreated(e,d.token);s.ready||(console.error(t.red("Application creation is taking longer than expected. Try again later or run 'dashnex app pull' to check.")),process.exit(1)),"failed"===s.status&&(console.error(t.red("Application creation failed. Please try again.")),process.exit(1)),o("Application found after polling")}else if(!i.ok){const e=i.headers.get("content-type")??"";let s="Failed to create application.";if(401===i.status||403===i.status)s="Please run 'dashnex login' to authenticate.";else if(e.includes("application/json")){const e=JSON.parse(r);o(`Create error body parsed: ${JSON.stringify(e)}`);const t=p(e);t&&(s=t)}console.error(t.red(s)),process.exit(1)}let u;if(o("Application created successfully"),y)u=!1,o("CI mode (--subdomain), skipping pull");else{u=(await e.prompt([{type:"confirm",name:"pull",message:"Pull the application locally?",default:!0}])).pull,o(`User chose to pull: ${u}`)}if(u){o("Running pull flow");try{const e=new c;await e.execute()}catch(k){if(s(k),k instanceof Error&&k.message.startsWith("EXIT:"))throw k;if(n(k))return void console.log(t.yellow(l));console.error(t.red("Failed to pull application."))}}else console.log(t.green("Application is created successfully. Run 'dashnex app pull' to pull it to your computer or 'dashnex app deploy' to deploy it to the cloud."))}catch(k){if(h.stop(),s(k),k instanceof Error&&k.message.startsWith("EXIT:"))throw k;if(n(k))return void console.log(t.yellow(l));console.error(t.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}}export{d as CreateCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CreateCommand as e}from"./create.js";import{PullCommand as
|
|
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 t}from"./deploy.js";import{StatusCommand as i}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 t,options:[]},{name:"status",description:"Show current application status",handler:new i,options:[]}]};export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import t from"fs-extra";import
|
|
1
|
+
import e from"chalk";import t from"fs-extra";import o from"path";import r from"os";import{spawn as i}from"child_process";import n from"inquirer";import s from"adm-zip";import{debug as a,debugError as l}from"../../lib/debug.js";import{getBusinessApiBase as c}from"../../lib/api.js";import{ensureLoggedIn as d}from"../../services/auth.js";import{createSpinner as p}from"../../lib/spinner.js";import{isUserInterrupt as m,INTERRUPTED_MESSAGE as f}from"../../lib/errors.js";const u=(e,t)=>new Promise((o,r)=>{const n=i(t,{cwd:e,shell:!0,stdio:"inherit"});n.on("error",e=>{l(e),r(e)}),n.on("close",e=>{o(null===e?0:e)})}),g=async(t,r)=>{const{install:s}=await n.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!s){if(o.resolve(t)!==o.resolve(r)){const i=o.relative(r,t);console.log(e.cyan(`Run "cd ${i}" to change to the application folder.`))}return}const c=await(async()=>{const e=e=>new Promise(t=>{const o=i(e,["--version"],{stdio:"ignore",shell:!0});o.on("error",()=>t(!1)),o.on("close",e=>t(0===e))});return await e("pnpm")?"pnpm":(await e("npm"),"npm")})();a(`Running ${c} install in ${t}`);try{const e=await u(t,`${c} install`);if(0!==e)return void a(`${c} install exited with code ${e}`)}catch(m){return l(m),void console.error(e.red(`Failed to run ${c} install.`))}const{migrate:d}=await n.prompt([{type:"confirm",name:"migrate",message:"Create local database?",default:!0}]);if(d){a(`Running dashnex db migrate in ${t}`);try{const e=await u(t,"dashnex db migrate");if(0!==e)return void a(`dashnex db migrate exited with code ${e}`)}catch(m){return l(m),void console.error(e.red("Failed to run dashnex db migrate."))}}const{dev:p}=await n.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(p){a(`Running npm run dev in ${t}`);try{await u(t,"npm run dev")}catch(m){l(m),console.error(e.red("Failed to run dev server."))}}},h='Application is successfully pulled. Run "npm install" or "pnpm install" to install dependencies and then "dashnex dev" to run it';class w{async execute(i={}){a("Pull flow started");const u=await d();if(!u)return;const w=process.cwd();let v;if(i.folder)v=i.folder.trim()||".",a(`Folder argument provided: ${v}`);else{a("No folder argument, prompting user");const{folder:e}=await n.prompt([{type:"input",name:"folder",message:"Which folder to pull the application to?",default:"."}]);v=e.trim()||"."}const y=o.resolve(w,v);a(`Target folder resolved: ${y}`);const x=await t.pathExists(y);let $=!1;if(x)try{$=(await t.readdir(y)).length>0,a(`Folder exists: ${x}, has files: ${$}`)}catch(R){a(`Error reading folder: ${R}`)}if($&&!i.yes){const{confirm:t}=await n.prompt([{type:"confirm",name:"confirm",message:"Existing files will be overwritten. Continue?",default:!0}]);if(!t)return a("User declined confirmation, exiting"),void console.log(e.yellow("Pull cancelled."));a("User confirmed overwrite")}await t.ensureDir(y),a(`Target folder ensured: ${y}`);const b=`${c()}/business/v1/cli/pull`;a(`GET ${b}`);const j=o.join(r.tmpdir(),`dashnex-pull-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),E=p();E.start("Pulling application...");try{const r=await fetch(b,{headers:{Authorization:`Bearer ${u.token}`}});if(a(`Response: ${r.status}`),!r.ok){E.stop();const t=r.headers.get("content-type")??"";let o="Failed to pull application.";if(401===r.status||403===r.status)o="Please run 'dashnex login' to authenticate.";else if(404===r.status)o="Business has no application. Run 'dashnex app create' to create one.";else if(t.includes("application/json")){const e=(e=>"string"==typeof e.error?e.error:"string"==typeof e.message?e.message:void 0)(await r.json().catch(()=>({})));e&&(o=e)}console.error(e.red(o)),process.exit(1)}E.text("Downloading...");const n=Buffer.from(await r.arrayBuffer());await t.writeFile(j,n),a("Zip written to temp file"),E.text("Extracting...");new s(j).extractAllTo(y,!0),E.stop(),a("Extracted to target folder"),o.resolve(y)!==o.resolve(w)?(console.log(e.green(((e,t)=>o.resolve(e)===o.resolve(t)?h:`Application is successfully pulled into ${o.relative(t,e)}.`)(y,w))),process.chdir(y),a(`Changed working directory to ${y}`)):console.log(e.green(h)),i.yes?a("CI mode (--yes), skipping post-pull child commands"):await g(y,w)}catch(R){if(E.stop(),l(R),R instanceof Error&&R.message.startsWith("EXIT:"))throw R;if(m(R))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 t.remove(j).catch(()=>{}),a("Temp zip removed")}}}export{w as PullCommand};
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="@dashnex/cli",a="0.5.
|
|
1
|
+
const e="@dashnex/cli",a="0.5.32",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};
|
|
@@ -2,7 +2,6 @@ import { CliCommand } from '@dashnex/types';
|
|
|
2
2
|
export interface CreateCommandOptions {
|
|
3
3
|
template?: string;
|
|
4
4
|
subdomain?: string;
|
|
5
|
-
pull?: boolean;
|
|
6
5
|
}
|
|
7
6
|
export declare class CreateCommand implements CliCommand {
|
|
8
7
|
pollApplicationCreated(applicationsUrl: string, token: string, interval?: number, timeout?: number): Promise<{
|
|
@@ -2,9 +2,6 @@ import { CliCommand } from '@dashnex/types';
|
|
|
2
2
|
export interface PullCommandOptions {
|
|
3
3
|
folder?: string;
|
|
4
4
|
yes?: boolean;
|
|
5
|
-
install?: boolean;
|
|
6
|
-
migrate?: boolean;
|
|
7
|
-
dev?: boolean;
|
|
8
5
|
}
|
|
9
6
|
export declare class PullCommand implements CliCommand {
|
|
10
7
|
execute(options?: PullCommandOptions): Promise<void>;
|
package/package.json
CHANGED