@dashnex/cli 0.5.64 → 0.5.65

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,{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]"),a.option("--ci","Disable spinner (CI mode)"),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(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("dashnex").description(m).version(l).option("--ci","Disable spinner and interactive prompts (CI mode)").arguments("[command]").action(o=>{if(o){d.commands.map(o=>o.name()).includes(o)||(console.error(e.red("Invalid command")),console.log(e.green("Run `dashnex` to see available commands")),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",process.argv.includes("--ci")&&(process.env.DASHNEX_CI="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(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=>{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 n from"chalk";import e from"fs-extra";import s from"path";import{fileURLToPath as c}from"url";import{execSync as t}from"child_process";import a from"dotenv";import i from"./package.json.js";import{isUserInterrupt as r,INTERRUPTED_MESSAGE as d}from"./lib/errors.js";const l=new o,{version:m,description:p}=i;l.name("dashnex").description(p).version(m).option("--ci","Disable spinner and interactive prompts (CI mode)").arguments("[command]").action(o=>{if(o){l.commands.map(o=>o.name()).includes(o)||(console.error(n.red("Invalid command")),console.log(n.green("Run `dashnex` to see available commands")),process.exit(1))}!function(o){const n=[];n.push("Usage: dashnex [options] [command]"),n.push(""),n.push(o.description()),n.push(""),n.push("Options:"),o.options.forEach(o=>{const e=o.flags.padEnd(20);n.push(` ${e} ${o.description}`)}),n.push(""),n.push("Commands:"),o.commands.forEach(o=>{const e=` ${o.name().padEnd(20)} ${o.description()}`;n.push(e),o.commands.length>0&&o.commands.forEach(o=>{const e=` ${o.name().padEnd(20)} ${o.description()}`;n.push(e)})}),console.log(n.join("\n"))}(l)});let f=null;async function u(o,c){const t=[];try{const n=function(o,n){const c=s.join(n,"package.json");if(e.existsSync(c))try{if(JSON.parse(e.readFileSync(c,"utf8")).name===o)return n}catch{}const t=s.join(n,"node_modules",o);if(e.existsSync(t))return t;if(f){const n=s.join(f,o);if(e.existsSync(n))return n}return t}(o,c),a=s.join(n,"dist","commands","index.js");if(e.existsSync(a)){const o=await import(a);let n=[];o.default?n=Array.isArray(o.default)?o.default:[]:o.commands&&(n=Array.isArray(o.commands)?o.commands:[]),n.length>0&&t.push(...n)}}catch(a){if(process.env.DEBUG){const e=a instanceof Error?a.message:String(a);console.log(n.yellow(`Module ${o} has no commands or failed to load: ${e}`))}}return t}function h(o,e,s={}){const c=o.command(e.name).description(e.description);"pull"===e.name&&c.arguments("[folder]"),c.option("--ci","Disable spinner (CI mode)"),e.options&&e.options.forEach(o=>{void 0!==o.defaultValue?"number"==typeof o.defaultValue?c.option(o.flags,o.description,String(o.defaultValue)):c.option(o.flags,o.description,o.defaultValue):c.option(o.flags,o.description)}),e.subcommands&&e.subcommands.forEach(o=>{h(c,o,{...s,...e.options})});const t=e.subcommands&&e.subcommands.length>0;"pull"===e.name?c.action(async(o,c,t)=>{try{const n={...s,...c};o&&(n.folder=o),await e.handler.execute(n)}catch(a){if(r(a))return void console.log(n.yellow(d));console.error(n.red(`❌ Command failed in ${e.name}:`),a),process.exit(1)}}):t?c.action(async()=>{c.outputHelp()}):c.action(async(o,c)=>{try{const n={...s,...o};await e.handler.execute(n)}catch(t){if(r(t))return void console.log(n.yellow(d));console.error(n.red(`❌ Command failed in ${e.name}:`),t),process.exit(1)}})}(async function(){a.config({quiet:!0}),process.env.DASHNEX_CLI="1",function(){try{f=t("npm root -g",{encoding:"utf8"}).trim()}catch{f=null}}(),process.argv.includes("--ci")&&(process.env.DASHNEX_CI="1");let o=process.cwd();const i=s.dirname(c(import.meta.url)),r=s.resolve(i,"..");process.env.DEBUG&&(console.log(`CLI started from directory: ${o}`),console.log(`CLI package directory: ${r}`),console.log(`Global node_modules: ${f??"not found"}`));const d=await async function(o){try{const c=[],t=/* @__PURE__ */new Set,a=o=>{t.has(o)||(t.add(o),c.push(o))},i=s.join(o,"dashnex.json");if(e.existsSync(i)){const n=s.join(o,"package.json");if(e.existsSync(n)){const o=JSON.parse(e.readFileSync(n,"utf8"));o.name&&a(o.name)}}const r=s.join(o,"package.json");if(e.existsSync(r)){const n=JSON.parse(e.readFileSync(r,"utf8")),c={...n.dependencies,...n.devDependencies,...n.optionalDependencies};for(const[t]of Object.entries(c)){const n=s.join(o,"node_modules",t);e.existsSync(s.join(n,"dashnex.json"))&&a(t)}}if(f&&e.existsSync(f))try{const o=e.readdirSync(f);for(const n of o)if(n.startsWith("@")){const o=s.join(f,n);try{if(e.statSync(o).isDirectory()){const c=e.readdirSync(o);for(const o of c){const c=`${n}/${o}`,t=s.join(f,c);e.existsSync(s.join(t,"dashnex.json"))&&a(c)}}}catch{}}else{const o=s.join(f,n);e.existsSync(s.join(o,"dashnex.json"))&&a(n)}}catch(n){if(process.env.DEBUG){const o=n instanceof Error?n.message:String(n);console.log("⚠ Error scanning global node_modules:",o)}}return c}catch(n){if(process.env.DEBUG){const o=n instanceof Error?n.message:String(n);console.log("⚠ Error reading app package.json:",o)}return[]}}(o),m=r.includes("node_modules");let p=!1;try{const n=s.join(o,"package.json");if(await e.pathExists(n)){const o=JSON.parse(await e.readFile(n,"utf8"));p="@dashnex/cli"in{...o.dependencies,...o.devDependencies,...o.optionalDependencies}}}catch{}!m&&!p||d.includes("@dashnex/cli")||d.push("@dashnex/cli"),process.env.DEBUG&&(console.log(`CLI package directory: ${r}`),console.log(`Is installed package: ${m}`),console.log(`CLI in dependencies: ${p}`),console.log(`Discovered modules: ${d.join(", ")}`));for(const c of d){let t=[];if("@dashnex/cli"===c&&(m||p))try{const o=s.join(r,"dist","commands","index.js");if(process.env.DEBUG&&console.log(`Loading @dashnex/cli commands from: ${o}`),await e.pathExists(o)){const n=await import(o);n.default?t=Array.isArray(n.default)?n.default:[]:n.commands&&(t=Array.isArray(n.commands)?n.commands:[]),process.env.DEBUG&&console.log(`Loaded ${t.length} commands from @dashnex/cli`)}}catch(g){if(process.env.DEBUG){const o=g instanceof Error?g.message:String(g);console.log(n.yellow(`Failed to load @dashnex/cli commands: ${o}`))}}else t=await u(c,o);for(const o of t)h(l,o)}try{const{default:n}=await import(s.join(o,"dist","commands","index.js"));if(n&&Array.isArray(n))for(const o of n)h(l,o)}catch(g){process.env.DEBUG&&console.error(n.yellow("⚠ Failed to discover application commands"))}l.parse(process.argv)})().catch(o=>{r(o)&&(console.log(n.yellow(d)),process.exit(0)),console.error(n.red("❌ CLI failed:"),o),process.exit(1)});
@@ -1 +1 @@
1
- const e="@dashnex/cli",a="0.5.64",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.65",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.64",
4
+ "version": "0.5.65",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",