@dashnex/cli 0.5.45 → 0.5.46

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/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 t from"./package.json.js";import{isUserInterrupt as i,INTERRUPTED_MESSAGE as r}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(i(t))return void console.log(e.yellow(r));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(i(c))return void console.log(e.yellow(r));console.error(e.red(`❌ Command failed in ${n.name}:`),c),process.exit(1)}})}d.name(l).description(p).version(m).action(()=>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)),async function(){c.config({quiet:!0}),process.env.DASHNEX_CLI="1";let o=process.cwd();const t=s.dirname(a(import.meta.url)),i=s.resolve(t,"..");process.env.DEBUG&&(console.log(`CLI started from directory: ${o}`),console.log(`CLI package directory: ${i}`));const r=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 i=s.join(o,"package.json");if(!n.existsSync(i))return e;const r=JSON.parse(n.readFileSync(i,"utf8")),d={...r.dependencies,...r.devDependencies,...r.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=i.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||r.includes("@dashnex/cli")||r.push("@dashnex/cli"),process.env.DEBUG&&(console.log(`CLI package directory: ${i}`),console.log(`Is installed package: ${l}`),console.log(`CLI in dependencies: ${m}`),console.log(`Discovered modules: ${r.join(", ")}`));for(const a of r){let c=[];if("@dashnex/cli"===a&&(l||m))try{const o=s.join(i,"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)}().catch(o=>{i(o)&&(console.log(e.yellow(r)),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,{version:l,description:m}=t;async function p(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 f(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=>{f(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("dashnex").description(m).version(l).arguments("[command]").action(o=>{if(o){d.commands.map(o=>o.name()).includes(o)||(console.error(e.red("Invalid command")),process.exit(1))}!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(o=>{const n=` ${o.name().padEnd(20)} ${o.description()}`;e.push(n)})}),console.log(e.join("\n"))}(d)}),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(u){if(process.env.DEBUG){const o=u instanceof Error?u.message:String(u);console.log(e.yellow(`Failed to load @dashnex/cli commands: ${o}`))}}else c=await p(a,o);for(const o of c)f(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)f(d,o)}catch(u){process.env.DEBUG&&console.error(e.yellow("⚠ Failed to discover application commands"))}d.parse(process.argv)}().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{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
+ 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 +1 @@
1
- import o from"./version.js";import{LoginCommand as e}from"./login.js";import{LogoutCommand as i}from"./logout.js";import{WhoamiCommand as n}from"./whoami.js";import{InstallCommand as s}from"./install.js";import{DevCommand as r}from"./dev.js";import{CheckCommand as t}from"./check.js";import p from"./app/index.js";const a=[{name:"version",description:"Display the version of the CLI",handler:new o,options:[]},{name:"login",description:"Log in to your DashNex account",handler:new e,options:[{flags:"--email <email>",description:"Email address (skip prompt)"},{flags:"--password <password>",description:"Password (skip prompt)"},{flags:"--code <code>",description:"2FA code (skip prompt)"},{flags:"--business <id>",description:"Business ID to select (skip prompt)"}]},{name:"logout",description:"Log out and remove local credentials",handler:new i,options:[]},{name:"whoami",description:"Show current logged-in business and user",handler:new n,options:[]},p,{name:"install",description:"Install dependencies using pnpm or npm",handler:new s,options:[]},{name:"dev",description:"Run the development server",handler:new r,options:[]},{name:"check",description:"Run build-time validations",handler:new t,options:[]}];export{a as default};
1
+ import o from"./version.js";import{LoginCommand as s}from"./login.js";import{LogoutCommand as i}from"./logout.js";import{WhoamiCommand as e}from"./whoami.js";import n from"./app/index.js";const r=[{name:"version",description:"Display the version of the CLI",handler:new o,options:[]},{name:"login",description:"Log in to your DashNex account",handler:new s,options:[{flags:"--email <email>",description:"Email address (skip prompt)"},{flags:"--password <password>",description:"Password (skip prompt)"},{flags:"--code <code>",description:"2FA code (skip prompt)"},{flags:"--business <id>",description:"Business ID to select (skip prompt)"}]},{name:"logout",description:"Log out and remove local credentials",handler:new i,options:[]},{name:"whoami",description:"Show current logged-in business and user",handler:new e,options:[]},n];export{r as default};
@@ -1 +1 @@
1
- const e="@dashnex/cli",a="0.5.45",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.46",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.45",
4
+ "version": "0.5.46",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",