@dashnex/cli 0.5.47 → 0.5.48

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{CreateCommand as e}from"./create.js";import{PullCommand as o}from"./pull.js";import{PushCommand as p}from"./push.js";import{DeleteCommand as i}from"./delete.js";import{DeployCommand as n}from"./deploy.js";import{StatusCommand as t}from"./status.js";import{InstallCommand as s}from"../install.js";import{DevCommand as a}from"../dev.js";import{CheckCommand as r}from"../check.js";const l={name:"app",description:"Manage DashNex applications (should be executed in application folder)",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 i,options:[{flags:"-y, --yes",description:"Skip confirmation prompt"}]},{name:"deploy",description:"Deploy application to DashNex",handler:new n,options:[]},{name:"status",description:"Show current application status",handler:new t,options:[]},{name:"install",description:"Install dependencies using pnpm or npm",handler:new s,options:[]},{name:"dev",description:"Run the development server",handler:new a,options:[]},{name:"check",description:"Run build-time validations",handler:new r,options:[]}]};export{l as default};
1
+ import{CreateCommand as e}from"./create.js";import{PullCommand as o}from"./pull.js";import{PushCommand as i}from"./push.js";import{DeleteCommand as p}from"./delete.js";import{DeployCommand as n}from"./deploy.js";import{StatusCommand as t}from"./status.js";import{InstallCommand as s}from"../install.js";import{DevCommand as a}from"../dev.js";import{CheckCommand as r}from"../check.js";const l={name:"app",description:"Manage DashNex applications (should be executed in application folder)",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 i,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 p,options:[{flags:"-y, --yes",description:"Skip confirmation prompt"}]},{name:"deploy",description:"Deploy application to DashNex",handler:new n,options:[]},{name:"status",description:"Show current application status",handler:new t,options:[]},{name:"install",description:"Install dependencies using pnpm or npm",handler:new s,options:[]},{name:"dev",description:"Run the development server",handler:new a,options:[{flags:"--https",description:"Run dev server with HTTPS"}]},{name:"check",description:"Run build-time validations",handler:new r,options:[]}]};export{l as default};
@@ -1 +1 @@
1
- import e from"chalk";import t from"fs-extra";import o from"path";import r from"os";import{spawn as n}from"child_process";import i from"inquirer";import a from"adm-zip";import{debug as s,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 i=n(t,{cwd:e,shell:!0,stdio:"inherit"});i.on("error",e=>{l(e),r(e)}),i.on("close",e=>{o(null===e?0:e)})}),h=async(t,r)=>{const{install:a}=await i.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!a){if(o.resolve(t)!==o.resolve(r)){const n=o.relative(r,t);console.log(e.cyan(`Run "cd ${n}" to change to the application folder.`))}return}const c=await(async()=>{const e=e=>new Promise(t=>{const o=n(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")})();s(`Running ${c} install in ${t}`);try{const e=await u(t,`${c} install`);if(0!==e)return void s(`${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 i.prompt([{type:"confirm",name:"migrate",message:"Create database?",default:!0}]);if(!d)return;s(`Running dashnex db migrate in ${t}`);try{const e=await u(t,"dashnex db migrate");if(0!==e)return void s(`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 i.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(p){s(`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."))}}};class g{async execute(n={}){s("Pull flow started");const u=await d();if(!u)return;const g=process.cwd();let w;if(n.folder)w=n.folder.trim()||".",s(`Folder argument provided: ${w}`);else{s("No folder argument, prompting user");const{folder:e}=await i.prompt([{type:"input",name:"folder",message:"Which folder to pull the application to?",default:"."}]);w=e.trim()||"."}const v=o.resolve(g,w);s(`Target folder resolved: ${v}`);const y=await t.pathExists(v);let x=!1;if(y)try{x=(await t.readdir(v)).length>0,s(`Folder exists: ${y}, has files: ${x}`)}catch(j){s(`Error reading folder: ${j}`)}if(x&&!n.yes){const{confirm:t}=await i.prompt([{type:"confirm",name:"confirm",message:"Existing files will be overwritten. Continue?",default:!0}]);if(!t)return s("User declined confirmation, exiting"),void console.log(e.yellow("Pull cancelled."));s("User confirmed overwrite")}await t.ensureDir(v),s(`Target folder ensured: ${v}`);const $=`${c()}/business/v1/cli/pull`;s(`GET ${$}`);const b=o.join(r.tmpdir(),`dashnex-pull-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),R=p();R.start("Pulling application...");try{const r=await fetch($,{headers:{Authorization:`Bearer ${u.token}`}});if(s(`Response: ${r.status}`),!r.ok){R.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)}R.text("Downloading...");const i=Buffer.from(await r.arrayBuffer());await t.writeFile(b,i),s("Zip written to temp file"),R.text("Extracting...");new a(b).extractAllTo(v,!0),R.stop(),s("Extracted to target folder"),o.resolve(v)!==o.resolve(g)?(console.log(e.green(((e,t)=>o.resolve(e)===o.resolve(t)?`Application is successfully pulled. Run "cd ${e}" to change to the application folder and then "dashnex app install" to install dependencies and then "dashnex app dev" to run it`:`Application is successfully pulled into ${o.relative(t,e)}.`)(v,g))),process.chdir(v),s(`Changed working directory to ${v}`)):console.log(e.green(`Application is successfully pulled. Run "cd ${v}" to change to the application folder and then "dashnex app install" to install dependencies and then "dashnex app dev" to run it`)),n.yes?s("CI mode (--yes), skipping post-pull child commands"):await h(v,g)}catch(j){if(R.stop(),l(j),j instanceof Error&&j.message.startsWith("EXIT:"))throw j;if(m(j))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(b).catch(()=>{}),s("Temp zip removed")}}}export{g as PullCommand};
1
+ import e from"chalk";import t from"fs-extra";import o from"path";import r from"os";import{spawn as n}from"child_process";import i from"inquirer";import a from"adm-zip";import{debug as s,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 u}from"../../lib/errors.js";const f=(e,t,o)=>new Promise((r,i)=>{const a=n(t,{cwd:e,shell:!0,stdio:"inherit",env:o?{...process.env,...o}:void 0});a.on("error",e=>{l(e),i(e)}),a.on("close",e=>{r(null===e?0:e)})}),h=async(t,r)=>{const{install:a}=await i.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!a){if(o.resolve(t)!==o.resolve(r)){const n=o.relative(r,t);console.log(e.cyan(`Run "cd ${n}" to change to the application folder.`))}return}const c=await(async()=>{const e=e=>new Promise(t=>{const o=n(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")})();s(`Running ${c} install in ${t}`);try{const e=await f(t,`${c} install`,{NPM_CONFIG_LOGLEVEL:"error"});if(0!==e)return void s(`${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 i.prompt([{type:"confirm",name:"migrate",message:"Create or update database?",default:!0}]);if(!d)return;s(`Running dashnex db migrate in ${t}`);try{const e=await f(t,"dashnex db migrate");if(0!==e)return void s(`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 i.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(p){s(`Running npm run dev in ${t}`);try{await f(t,"npm run dev")}catch(m){l(m),console.error(e.red("Failed to run dev server."))}}};class g{async execute(n={}){s("Pull flow started");const f=await d();if(!f)return;const g=process.cwd();let w;if(n.folder)w=n.folder.trim()||".",s(`Folder argument provided: ${w}`);else{s("No folder argument, prompting user");const{folder:e}=await i.prompt([{type:"input",name:"folder",message:"Which folder to pull the application to?",default:"."}]);w=e.trim()||"."}const v=o.resolve(g,w);s(`Target folder resolved: ${v}`);const y=await t.pathExists(v);let x=!1;if(y)try{x=(await t.readdir(v)).length>0,s(`Folder exists: ${y}, has files: ${x}`)}catch(R){s(`Error reading folder: ${R}`)}if(x&&!n.yes){const{confirm:t}=await i.prompt([{type:"confirm",name:"confirm",message:"Existing files will be overwritten. Continue?",default:!0}]);if(!t)return s("User declined confirmation, exiting"),void console.log(e.yellow("Pull cancelled."));s("User confirmed overwrite")}await t.ensureDir(v),s(`Target folder ensured: ${v}`);const $=`${c()}/business/v1/cli/pull`;s(`GET ${$}`);const b=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($,{headers:{Authorization:`Bearer ${f.token}`}});if(s(`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 i=Buffer.from(await r.arrayBuffer());await t.writeFile(b,i),s("Zip written to temp file"),E.text("Extracting...");new a(b).extractAllTo(v,!0),E.stop(),s("Extracted to target folder"),o.resolve(v)!==o.resolve(g)?(console.log(e.green(((e,t)=>o.resolve(e)===o.resolve(t)?`Application is successfully pulled. Run "cd ${e}" to change to the application folder and then "dashnex app install" to install dependencies and then "dashnex app dev" to run it`:`Application is successfully pulled into ${o.relative(t,e)}.`)(v,g))),process.chdir(v),s(`Changed working directory to ${v}`)):console.log(e.green(`Application is successfully pulled. Run "cd ${v}" to change to the application folder and then "dashnex app install" to install dependencies and then "dashnex app dev" to run it`)),n.yes?s("CI mode (--yes), skipping post-pull child commands"):await h(v,g)}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(u));console.error(e.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}finally{await t.remove(b).catch(()=>{}),s("Temp zip removed")}}}export{g as PullCommand};
@@ -1 +1 @@
1
- import{spawn as e}from"child_process";import o from"path";import s from"fs-extra";import r from"chalk";import{debug as n,debugError as a}from"../lib/debug.js";class i{async execute(){n("Dev flow started");const i=process.cwd(),c=o.join(i,"dashnex.json"),t=o.join(i,"package.json");let p;n(`Checking for dashnex.json at: ${c}`),await s.pathExists(c)||(console.error(r.red("This is not a DashNex project.")),process.exit(1)),n("dashnex.json found, checking for package.json"),await s.pathExists(t)||(console.error(r.red("package.json is missing.")),process.exit(1)),n("package.json found, checking for dev script");try{p=await s.readJson(t)}catch(m){a(m),console.error(r.red("Failed to read package.json.")),process.exit(1)}p.scripts&&p.scripts.dev||(console.error(r.red('The "dev" script is missing from package.json. Please add a "dev" script to package.json.')),process.exit(1)),n("dev script found, checking for npm availability");const d=await(async o=>new Promise(s=>{const r=e(`${o} --version`,{stdio:"ignore",shell:!0});r.on("error",()=>{s(!1)}),r.on("close",e=>{s(0===e)})}))("npm");let l;n(`npm available: ${d}`),d||(console.error(r.red("npm is not available. Please install npm to continue.")),process.exit(1)),n("npm available, executing: npm run dev");try{l=await(async o=>new Promise((s,r)=>{const n=e(o,{stdio:"inherit",cwd:process.cwd(),shell:!0,env:{...process.env,NODE_ENV:"development"}});n.on("error",e=>{a(e),r(e)}),n.on("close",e=>{s(null===e?0:e)})}))("npm run dev")}catch(m){return a(m),m instanceof Error?console.error(r.red(`Failed to run npm run dev: ${m.message}`)):console.error(r.red("Failed to run npm run dev")),void process.exit(1)}process.exit(l)}}export{i as DevCommand};
1
+ import{spawn as e}from"child_process";import o from"path";import s from"fs-extra";import r from"chalk";import{debug as n,debugError as t}from"../lib/debug.js";class a{async execute(a={}){n("Dev flow started");const i=process.cwd(),c=o.join(i,"dashnex.json"),p=o.join(i,"package.json");let l;n(`Checking for dashnex.json at: ${c}`),await s.pathExists(c)||(console.error(r.red("This is not a DashNex project.")),process.exit(1)),n("dashnex.json found, checking for package.json"),await s.pathExists(p)||(console.error(r.red("package.json is missing.")),process.exit(1)),n("package.json found, checking for dev script");try{l=await s.readJson(p)}catch(v){t(v),console.error(r.red("Failed to read package.json.")),process.exit(1)}l.scripts&&l.scripts.dev||(console.error(r.red('The "dev" script is missing from package.json. Please add a "dev" script to package.json.')),process.exit(1)),n("dev script found, checking for npm availability");const d=await(async o=>new Promise(s=>{const r=e(`${o} --version`,{stdio:"ignore",shell:!0});r.on("error",()=>{s(!1)}),r.on("close",e=>{s(0===e)})}))("npm");n(`npm available: ${d}`),d||(console.error(r.red("npm is not available. Please install npm to continue.")),process.exit(1));const m=a.https?["--","--experimental-https"]:[];let h;n("npm available, executing: npm run dev"+(a.https?" -- --experimental-https":""));try{h=await(async(o,s=[])=>{const r=s.length?`${o} ${s.join(" ")}`:o;return new Promise((o,s)=>{const n=e(r,{stdio:"inherit",cwd:process.cwd(),shell:!0,env:{...process.env,NODE_ENV:"development"}});n.on("error",e=>{t(e),s(e)}),n.on("close",e=>{o(null===e?0:e)})})})("npm run dev",m)}catch(v){return t(v),v instanceof Error?console.error(r.red(`Failed to run npm run dev: ${v.message}`)):console.error(r.red("Failed to run npm run dev")),void process.exit(1)}process.exit(h)}}export{a as DevCommand};
@@ -1 +1 @@
1
- import{spawn as e}from"child_process";import n from"chalk";import{debug as o,debugError as r}from"../lib/debug.js";const s=async n=>new Promise(o=>{const r=e(`${n} --version`,{stdio:"ignore",shell:!0});r.on("error",()=>{o(!1)}),r.on("close",e=>{o(0===e)})});class t{async execute(){o("Install flow started");let t=null,a=null;o("Checking for pnpm availability");const l=await s("pnpm");if(o(`pnpm available: ${l}`),l)t="pnpm",a="pnpm";else{o("pnpm not available, checking for npm");const e=await s("npm");o(`npm available: ${e}`),e&&(t="npm",a="npm")}t&&a||(console.error(n.red("Neither pnpm nor npm is available. Please install pnpm (recommended) or npm to continue.")),process.exit(1)),o(`Using package manager: ${t}`),o(`Executing: ${a} install`);try{const n=await(async n=>new Promise((o,s)=>{const t=[],a=[],l=e(`${n} install`,{stdio:["ignore","pipe","pipe"],cwd:process.cwd(),shell:!0});l.stdout&&l.stdout.on("data",e=>t.push(e)),l.stderr&&l.stderr.on("data",e=>a.push(e)),l.on("error",e=>{r(e),s(e)}),l.on("close",e=>{const n=null===e?0:e;0!==n&&(t.length&&process.stdout.write(Buffer.concat(t)),a.length&&process.stderr.write(Buffer.concat(a))),o(n)})}))(a);process.exit(n)}catch(i){r(i),i instanceof Error?console.error(n.red(`Failed to run ${a} install: ${i.message}`)):console.error(n.red(`Failed to run ${a} install`)),process.exit(1)}}}export{t as InstallCommand};
1
+ import{spawn as e}from"child_process";import n from"chalk";import{debug as o,debugError as r}from"../lib/debug.js";const s=async n=>new Promise(o=>{const r=e(`${n} --version`,{stdio:"ignore",shell:!0});r.on("error",()=>{o(!1)}),r.on("close",e=>{o(0===e)})});class t{async execute(){o("Install flow started");let t=null,a=null;o("Checking for pnpm availability");const l=await s("pnpm");if(o(`pnpm available: ${l}`),l)t="pnpm",a="pnpm";else{o("pnpm not available, checking for npm");const e=await s("npm");o(`npm available: ${e}`),e&&(t="npm",a="npm")}t&&a||(console.error(n.red("Neither pnpm nor npm is available. Please install pnpm (recommended) or npm to continue.")),process.exit(1)),o(`Using package manager: ${t}`),o(`Executing: ${a} install`);try{const n=await(async n=>new Promise((o,s)=>{const t=[],a=[],l=e(`${n} install`,{stdio:["ignore","pipe","pipe"],cwd:process.cwd(),shell:!0,env:{...process.env,NPM_CONFIG_LOGLEVEL:"error"}});l.stdout&&l.stdout.on("data",e=>t.push(e)),l.stderr&&l.stderr.on("data",e=>a.push(e)),l.on("error",e=>{r(e),s(e)}),l.on("close",e=>{const n=null===e?0:e;0!==n&&(t.length&&process.stdout.write(Buffer.concat(t)),a.length&&process.stderr.write(Buffer.concat(a))),o(n)})}))(a);process.exit(n)}catch(i){r(i),i instanceof Error?console.error(n.red(`Failed to run ${a} install: ${i.message}`)):console.error(n.red(`Failed to run ${a} install`)),process.exit(1)}}}export{t as InstallCommand};
@@ -1 +1 @@
1
- const e="@dashnex/cli",a="0.5.47",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.48",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,4 +1,7 @@
1
1
  import { CliCommand } from '@dashnex/types';
2
+ export interface DevCommandOptions {
3
+ https?: boolean;
4
+ }
2
5
  export declare class DevCommand implements CliCommand {
3
- execute(): Promise<void>;
6
+ execute(options?: DevCommandOptions): Promise<void>;
4
7
  }
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.47",
4
+ "version": "0.5.48",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",