dashnex 0.5.74 → 0.5.76
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/bin/dashnex +10 -2
- package/dist/cli.js +1 -1
- package/dist/commands/app/pull.js +1 -1
- package/dist/commands/install.js +1 -1
- package/dist/commands/secrets/delete.js +1 -1
- package/dist/commands/secrets/set.js +1 -1
- package/dist/package.js +1 -1
- package/package.json +4 -1
package/bin/dashnex
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const MIN_NODE_MAJOR = 22
|
|
4
|
+
const current = process.versions.node
|
|
5
|
+
const currentMajor = Number.parseInt(current.split('.')[0], 10)
|
|
6
|
+
if (!Number.isFinite(currentMajor) || currentMajor < MIN_NODE_MAJOR) {
|
|
7
|
+
console.error(`dashnex requires Node.js >= ${MIN_NODE_MAJOR}. You are running Node ${current}.`)
|
|
8
|
+
console.error('Upgrade Node: https://nodejs.org/')
|
|
9
|
+
process.exit(1)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
await import('../dist/cli.js')
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import o from"./package.js";import{INTERRUPTED_MESSAGE as n,isUserInterrupt as e}from"./lib/errors.js";import{Command as s}from"commander";import
|
|
2
|
+
import o from"./package.js";import{INTERRUPTED_MESSAGE as n,isUserInterrupt as e}from"./lib/errors.js";import{Command as s}from"commander";import c from"chalk";import i from"fs-extra";import t from"path";import{fileURLToPath as r,pathToFileURL as a}from"url";import{execSync as d}from"child_process";import l from"dotenv";var m=new s,{version:p,description:f}=o;m.name("dashnex").description(f).version(p).option("--ci","Disable spinner and interactive prompts (CI mode)").arguments("[command...]").action(o=>{if(o&&o.length>0){const n=o[0];if(!m.commands.map(o=>o.name()).includes(n)){console.error(c.red(`Unknown command: ${n}`));const o=process.cwd(),e=i.existsSync(t.join(o,"dashnex.json")),s=i.existsSync(t.join(o,"node_modules"));["build","router","bindings","env","db"].includes(n)?e&&!s?console.log(c.yellow(`\`${n}\` is provided by installed modules. Run \`dashnex install\` first.`)):e?console.log(c.green("Run `dashnex` to see available commands.")):console.log(c.yellow(`\`${n}\` must be run inside a DashNex application folder (containing dashnex.json).`)):console.log(c.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"))}(m)});var u=null;async function h(o,n){const e=[];try{const s=function(o,n){const e=t.join(n,"package.json");if(i.existsSync(e))try{const s=JSON.parse(i.readFileSync(e,"utf8"));if(s.name===o)return n;const c={...s.dependencies,...s.devDependencies}[o];if(c&&(c.startsWith("link:")||c.startsWith("file:"))){const o=t.resolve(n,c.replace(/^(link:|file:)/,""));if(i.existsSync(o))return o}}catch{}const s=t.join(n,"node_modules",o);if(i.existsSync(s))return i.realpathSync(s);if(u){const n=t.join(u,o);if(i.existsSync(n))return n}return s}(o,n),c=[t.join(s,"dist","commands","index.js"),t.join(s,"src","commands","index.ts"),t.join(s,"src","commands","index.js")].find(o=>i.existsSync(o));if(c){const o=await import(a(c).href);let n=[];o.default?n=Array.isArray(o.default)?o.default:[]:o.commands&&(n=Array.isArray(o.commands)?o.commands:[]),n.length>0&&e.push(...n)}}catch(s){if(process.env.DEBUG){const n=s instanceof Error?s.message:String(s);console.log(c.yellow(`Module ${o} has no commands or failed to load: ${n}`))}}return e}function y(o,s,i={}){const t=o.command(s.name).description(s.description);"pull"===s.name&&t.arguments("[folder]"),t.option("--ci","Disable spinner (CI mode)"),s.options&&s.options.forEach(o=>{void 0!==o.defaultValue?"number"==typeof o.defaultValue?t.option(o.flags,o.description,String(o.defaultValue)):t.option(o.flags,o.description,o.defaultValue):t.option(o.flags,o.description)}),s.subcommands&&s.subcommands.forEach(o=>{y(t,o,{...i,...s.options})});const r=s.subcommands&&s.subcommands.length>0;"pull"===s.name?t.action(async(o,t,r)=>{try{const n={...i,...t};o&&(n.folder=o),await s.handler.execute(n)}catch(a){if(e(a))return void console.log(c.yellow(n));console.error(c.red(`❌ Command failed in ${s.name}:`),a),process.exit(1)}}):r?t.action(async()=>{t.outputHelp()}):t.action(async(o,t)=>{try{const n={...i,...o};await s.handler.execute(n)}catch(r){if(e(r))return void console.log(c.yellow(n));console.error(c.red(`❌ Command failed in ${s.name}:`),r),process.exit(1)}})}(async function(){l.config({quiet:!0}),process.env.DASHNEX_CLI="1",function(){try{u=d("npm root -g",{encoding:"utf8"}).trim()}catch{u=null}}(),process.argv.includes("--ci")&&(process.env.DASHNEX_CI="1");let o=process.cwd();const n=t.dirname(r(import.meta.url)),e=t.resolve(n,"..");process.env.DEBUG&&(console.log(`CLI started from directory: ${o}`),console.log(`CLI package directory: ${e}`),console.log(`Global node_modules: ${u??"not found"}`));const s=await async function(o){try{const e=[],s=/* @__PURE__ */new Set,c=o=>{s.has(o)||(s.add(o),e.push(o))},r=t.join(o,"dashnex.json");if(i.existsSync(r)){const n=t.join(o,"package.json");if(i.existsSync(n)){const o=JSON.parse(i.readFileSync(n,"utf8"));o.name&&c(o.name)}}const a=t.join(o,"package.json");if(i.existsSync(a)){const n=JSON.parse(i.readFileSync(a,"utf8")),e={...n.dependencies,...n.devDependencies,...n.optionalDependencies};for(const[s,r]of Object.entries(e)){if("string"==typeof r&&(r.startsWith("link:")||r.startsWith("file:"))){const n=t.resolve(o,r.replace(/^(link:|file:)/,""));if(i.existsSync(t.join(n,"dashnex.json"))){c(s);continue}}const n=t.join(o,"node_modules",s);i.existsSync(t.join(n,"dashnex.json"))&&c(s)}}if(u&&i.existsSync(u))try{const o=i.readdirSync(u);for(const n of o)if(n.startsWith("@")){const o=t.join(u,n);try{if(i.statSync(o).isDirectory()){const e=i.readdirSync(o);for(const o of e){const e=`${n}/${o}`,s=t.join(u,e);i.existsSync(t.join(s,"dashnex.json"))&&c(e)}}}catch{}}else{const o=t.join(u,n);i.existsSync(t.join(o,"dashnex.json"))&&c(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 e}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);s.includes("@dashnex/cli")||s.push("@dashnex/cli"),process.env.DEBUG&&(console.log(`CLI package directory: ${e}`),console.log(`Discovered modules: ${s.join(", ")}`));for(const r of s){let n=[];if("@dashnex/cli"===r)try{const o=t.join(e,"dist","commands","index.js");if(process.env.DEBUG&&console.log(`Loading @dashnex/cli commands from: ${o}`),await i.pathExists(o)){const e=await import(a(o).href);e.default?n=Array.isArray(e.default)?e.default:[]:e.commands&&(n=Array.isArray(e.commands)?e.commands:[]),process.env.DEBUG&&console.log(`Loaded ${n.length} commands from @dashnex/cli`)}}catch(p){if(process.env.DEBUG){const o=p instanceof Error?p.message:String(p);console.log(c.yellow(`Failed to load @dashnex/cli commands: ${o}`))}}else n=await h(r,o);for(const o of n)y(m,o)}try{const{default:n}=await import(a(t.join(o,"dist","commands","index.js")).href);if(n&&Array.isArray(n))for(const o of n)y(m,o)}catch(p){process.env.DEBUG&&console.error(c.yellow("⚠ Failed to discover application commands"))}m.parse(process.argv)})().catch(o=>{e(o)&&(console.log(c.yellow(n)),process.exit(0)),console.error(c.red("❌ CLI failed:"),o),process.exit(1)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as r,debugError as o}from"../../lib/debug.js";import{getBusinessApiBase as n}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as a}from"../../lib/spinner.js";import{runDevInDir as s}from"../dev.js";import{runInstallInDir as l}from"../install.js";import c from"chalk";import d from"fs-extra";import p from"path";import{spawn as f}from"child_process";import m from"inquirer";import u from"os";import h from"adm-zip";var g=async(e,t)=>{const{install:n}=await m.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!n){if(p.resolve(e)!==p.resolve(t)){const r=p.relative(t,e);console.log(c.cyan(`Run "cd ${r}" to change to the application folder.`))}return}try{const t=a();t.start("Installing dependencies...");try{const o=await l(e);if(t.stop(),0!==o)return void r(`install exited with code ${o}`)}catch(u){throw t.stop(),u}}catch(u){return o(u),void console.error(c.red(u instanceof Error?u.message:"Failed to run install."))}const{migrate:i}=await m.prompt([{type:"confirm",name:"migrate",message:"Create or update database?",default:!0}]);if(!i)return;r(`Running dashnex db migrate in ${e}`);try{const t=a();t.start("Creating or updating database...");try{const n=await((e,t,r)=>{const n=`${p.join(e,"node_modules",".bin")}${p.delimiter}${process.env.PATH??""}`,i={...process.env,PATH:n};return new Promise((n,a)=>{const s=f(t,{cwd:e,shell:!0,stdio:"inherit",env:r?{...i,...r}:i});s.on("error",e=>{o(e),a(e)}),s.on("close",e=>{n(null===e?0:e)})})})(e,"dashnex db migrate");if(t.stop(),0!==n)return void r(`dashnex db migrate exited with code ${n}`)}catch(u){throw t.stop(),u}}catch(u){return o(u),void console.error(c.red("Failed to run dashnex db migrate."))}const{dev:d}=await m.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(d)try{await s(e)}catch(u){o(u),console.error(c.red(u instanceof Error?u.message:"Failed to run dev server."))}},y=(e,t)=>{if(e.length!==t.length)return`local ${e.length} bytes, zip ${t.length} bytes`;const r=e.length;for(let o=0;o<r;o+=1)if(e[o]!==t[o]){return`size ${r} matches; first diff at byte ${o} (local=0x${e[o].toString(16).padStart(2,"0")} zip=0x${t[o].toString(16).padStart(2,"0")})`}return`size ${r} matches; no byte difference (unexpected)`},w=async(e,t)=>{let r;try{r=await d.lstat(e)}catch{return{kind:"new"}}if(r.isDirectory())return{kind:"different",reason:"target is a directory"};if(r.size!==t.length)return{kind:"different",reason:`local ${r.size} bytes, zip ${t.length} bytes`};const o=await d.readFile(e);return 0===Buffer.compare(o,t)?{kind:"identical"}:{kind:"different",reason:y(o,t)}},$=async e=>{const{choice:t}=await m.prompt([{type:"expand",name:"choice",message:`Overwrite ${e}?`,default:"y",choices:[{key:"y",name:"yes (overwrite this file)",value:"yes"},{key:"n",name:"no (keep local version)",value:"no"},{key:"a",name:"overwrite all remaining differing files",value:"all"},{key:"s",name:"skip all remaining differing files",value:"skip"}]}]);return t},v=(e,t)=>p.resolve(e)===p.resolve(t)?"Application is successfully pulled.":`Application is successfully pulled into ${p.relative(t,e)}.`,x=class{async execute(s={}){r("Pull flow started");const l=await i();if(!l)return;const f=process.cwd();let y;if(s.folder)y=s.folder.trim()||".",r(`Folder argument provided: ${y}`);else{r("No folder argument, prompting user");const{folder:e}=await m.prompt([{type:"input",name:"folder",message:"Which folder to pull the application to?",default:"."}]);y=e.trim()||"."}const x=p.resolve(f,y);r(`Target folder resolved: ${x}`);try{const e=await d.lstat(x).catch(()=>null);e&&!e.isDirectory()&&(console.error(c.red(`Cannot pull into ${x}: path exists and is not a directory.`)),process.exit(1)),await d.ensureDir(x),r(`Target folder ensured: ${x}`)}catch(z){o(z);const e=z instanceof Error?z.message:"Unknown error";console.error(c.red(`Cannot create folder ${x}: ${e}`)),process.exit(1)}const k=`${n()}/business/v1/cli/pull`;r(`GET ${k}`);const b=p.join(u.tmpdir(),`dashnex-pull-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),j=a();j.start("Pulling application...");try{const e=await fetch(k,{headers:{Authorization:`Bearer ${l.token}`}});if(r(`Response: ${e.status}`),!e.ok){j.stop();const t=e.headers.get("content-type")??"";let r="Failed to pull application.";if(401===e.status||403===e.status)r="Please run 'dashnex login' to authenticate.";else if(404===e.status)r="Business has no application. Run 'dashnex app create' to create one.";else if(t.includes("application/json")){const t="string"==typeof(E=await e.json().catch(()=>({}))).error?E.error:"string"==typeof E.message?E.message:void 0;t&&(r=t)}console.error(c.red(r)),process.exit(1)}j.text("Downloading...");const t=Buffer.from(await e.arrayBuffer());await d.writeFile(b,t),r("Zip written to temp file"),j.text("Extracting...");const n=new h(b).getEntries().filter(e=>!e.isDirectory);r(`Zip has ${n.length} file entries`);
|
|
1
|
+
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as r,debugError as o}from"../../lib/debug.js";import{getBusinessApiBase as n}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as a}from"../../lib/spinner.js";import{runDevInDir as s}from"../dev.js";import{runInstallInDir as l}from"../install.js";import c from"chalk";import d from"fs-extra";import p from"path";import{spawn as f}from"child_process";import m from"inquirer";import u from"os";import h from"adm-zip";var g=async(e,t)=>{const{install:n}=await m.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!n){if(p.resolve(e)!==p.resolve(t)){const r=p.relative(t,e);console.log(c.cyan(`Run "cd ${r}" to change to the application folder.`))}return}try{const t=a();t.start("Installing dependencies...");try{const o=await l(e);if(t.stop(),0!==o)return void r(`install exited with code ${o}`)}catch(u){throw t.stop(),u}}catch(u){return o(u),void console.error(c.red(u instanceof Error?u.message:"Failed to run install."))}const{migrate:i}=await m.prompt([{type:"confirm",name:"migrate",message:"Create or update database?",default:!0}]);if(!i)return;r(`Running dashnex db migrate in ${e}`);try{const t=a();t.start("Creating or updating database...");try{const n=await((e,t,r)=>{const n=`${p.join(e,"node_modules",".bin")}${p.delimiter}${process.env.PATH??""}`,i={...process.env,PATH:n};return new Promise((n,a)=>{const s=f(t,{cwd:e,shell:!0,stdio:"inherit",env:r?{...i,...r}:i});s.on("error",e=>{o(e),a(e)}),s.on("close",e=>{n(null===e?0:e)})})})(e,"dashnex db migrate");if(t.stop(),0!==n)return void r(`dashnex db migrate exited with code ${n}`)}catch(u){throw t.stop(),u}}catch(u){return o(u),void console.error(c.red("Failed to run dashnex db migrate."))}const{dev:d}=await m.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(d)try{await s(e)}catch(u){o(u),console.error(c.red(u instanceof Error?u.message:"Failed to run dev server."))}},y=(e,t)=>{if(e.length!==t.length)return`local ${e.length} bytes, zip ${t.length} bytes`;const r=e.length;for(let o=0;o<r;o+=1)if(e[o]!==t[o]){return`size ${r} matches; first diff at byte ${o} (local=0x${e[o].toString(16).padStart(2,"0")} zip=0x${t[o].toString(16).padStart(2,"0")})`}return`size ${r} matches; no byte difference (unexpected)`},w=async(e,t)=>{let r;try{r=await d.lstat(e)}catch{return{kind:"new"}}if(r.isDirectory())return{kind:"different",reason:"target is a directory"};if(r.size!==t.length)return{kind:"different",reason:`local ${r.size} bytes, zip ${t.length} bytes`};const o=await d.readFile(e);return 0===Buffer.compare(o,t)?{kind:"identical"}:{kind:"different",reason:y(o,t)}},$=async e=>{const{choice:t}=await m.prompt([{type:"expand",name:"choice",message:`Overwrite ${e}?`,default:"y",choices:[{key:"y",name:"yes (overwrite this file)",value:"yes"},{key:"n",name:"no (keep local version)",value:"no"},{key:"a",name:"overwrite all remaining differing files",value:"all"},{key:"s",name:"skip all remaining differing files",value:"skip"}]}]);return t},v=(e,t)=>p.resolve(e)===p.resolve(t)?"Application is successfully pulled.":`Application is successfully pulled into ${p.relative(t,e)}.`,x=class{async execute(s={}){r("Pull flow started");const l=await i();if(!l)return;const f=process.cwd();let y;if(s.folder)y=s.folder.trim()||".",r(`Folder argument provided: ${y}`);else{r("No folder argument, prompting user");const{folder:e}=await m.prompt([{type:"input",name:"folder",message:"Which folder to pull the application to?",default:"."}]);y=e.trim()||"."}const x=p.resolve(f,y);r(`Target folder resolved: ${x}`);try{const e=await d.lstat(x).catch(()=>null);e&&!e.isDirectory()&&(console.error(c.red(`Cannot pull into ${x}: path exists and is not a directory.`)),process.exit(1)),await d.ensureDir(x),r(`Target folder ensured: ${x}`)}catch(z){o(z);const e=z instanceof Error?z.message:"Unknown error";console.error(c.red(`Cannot create folder ${x}: ${e}`)),process.exit(1)}const k=`${n()}/business/v1/cli/pull`;r(`GET ${k}`);const b=p.join(u.tmpdir(),`dashnex-pull-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),j=a();j.start("Pulling application...");try{const e=await fetch(k,{headers:{Authorization:`Bearer ${l.token}`}});if(r(`Response: ${e.status}`),!e.ok){j.stop();const t=e.headers.get("content-type")??"";let r="Failed to pull application.";if(401===e.status||403===e.status)r="Please run 'dashnex login' to authenticate.";else if(404===e.status)r="Business has no application. Run 'dashnex app create' to create one.";else if(t.includes("application/json")){const t="string"==typeof(E=await e.json().catch(()=>({}))).error?E.error:"string"==typeof E.message?E.message:void 0;t&&(r=t)}console.error(c.red(r)),process.exit(1)}j.text("Downloading...");const t=Buffer.from(await e.arrayBuffer());await d.writeFile(b,t),r("Zip written to temp file"),j.text("Extracting...");const n=new h(b).getEntries().filter(e=>!e.isDirectory);r(`Zip has ${n.length} file entries`);const i=s.yes||"1"===process.env.DASHNEX_CI;let a=i?"all":"prompt",m=!1,u=0,y=0,D=0,P=0,C=0;const F=async(e,t,r)=>{try{return await d.ensureDir(p.dirname(e)),await d.writeFile(e,t),r&&await d.chmod(e,r),!0}catch(z){return o(z),!1}};for(const o of n){const e=o.getData(),t=p.join(x,o.entryName),n=p.relative(x,t)||o.entryName,i=(o.header.attr??0)>>16&4095,s=await w(t,e);if(r(`Entry ${o.entryName}: ${s.kind}${s.reason?` (${s.reason})`:""}`),"identical"===s.kind){P+=1;continue}if("new"===s.kind){await F(t,e,i)?u+=1:C+=1;continue}let l=!1;if("all"===a)l=!0;else if("none"===a)l=!1;else{j.stop(),m||(console.log(c.dim("Y = yes (default), n = skip, a = overwrite all, s = skip all, h = help")),m=!0);const e=await $(n);r(`Entry ${o.entryName}: user chose ${e}`),"yes"===e?l=!0:"no"===e?l=!1:"all"===e?(a="all",l=!0):(a="none",l=!1),j.start("Extracting...")}l?await F(t,e,i)?y+=1:C+=1:D+=1}j.stop(),r(`Pull summary: ${u} new, ${y} overwritten, ${D} skipped, ${P} unchanged, ${C} failed`);const N=[`${u} new`,`${y} overwritten`,`${D} skipped`,`${P} unchanged`];C>0&&N.push(`${C} failed`),console.log(c.cyan(`Pulled: ${N.join(", ")}`)),p.resolve(x)!==p.resolve(f)?(console.log(c.green(v(x,f))),process.chdir(x),r(`Changed working directory to ${x}`)):console.log(c.green(v(x,f))),C>0&&(console.error(c.red(`${C} file(s) failed to write. See DEBUG output for details.`)),process.exit(1)),i?r("Non-interactive mode (--yes or --ci), skipping post-pull child commands"):await g(x,f)}catch(z){if(j.stop(),o(z),z instanceof Error&&z.message.startsWith("EXIT:"))throw z;if(t(z))return void console.log(c.yellow(e));console.error(c.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}finally{await d.remove(b).catch(()=>{}),r("Temp zip removed")}var E}};export{x as PullCommand};
|
package/dist/commands/install.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{debug as e,debugError as o}from"../lib/debug.js";import{createSpinner as
|
|
1
|
+
import{debug as e,debugError as o}from"../lib/debug.js";import{createSpinner as s}from"../lib/spinner.js";import r from"chalk";import n from"fs-extra";import t from"path";import{spawn as i}from"child_process";var a=async e=>new Promise(o=>{const s=i(`${e} --version`,{stdio:"ignore",shell:!0});s.on("error",()=>{o(!1)}),s.on("close",e=>{o(0===e)})}),c=async s=>{const r=await(async()=>await a("pnpm")?"pnpm":await a("npm")?"npm":null)();if(!r)throw new Error("Neither pnpm nor npm is available. Please install pnpm (recommended) or npm to continue.");const n=`${r} ${["install"].join(" ")}`;return e(`Using package manager: ${r}`),e(`Executing: ${n} in ${s}`),new Promise((e,r)=>{const t=[],a=[],c=i(n,{stdio:["ignore","pipe","pipe"],cwd:s,shell:!0,env:{...process.env,NPM_CONFIG_LOGLEVEL:"error"}});c.stdout&&c.stdout.on("data",e=>t.push(e)),c.stderr&&c.stderr.on("data",e=>a.push(e)),c.on("error",e=>{o(e),r(e)}),c.on("close",o=>{const s=null===o?0:o;0!==s&&(t.length&&process.stdout.write(Buffer.concat(t)),a.length&&process.stderr.write(Buffer.concat(a))),e(s)})})},p=class{async execute(){e("Install flow started");const i=t.join(process.cwd(),"dashnex.json");await n.pathExists(i)||(console.error(r.red("Run this command in a DashNex Web application folder.")),process.exit(1));const a=process.cwd(),p=s();p.start("Installing dependencies...");try{const e=await c(a);p.stop(),0!==e&&process.exit(e),console.log(r.green("Dependencies installed.")),process.exit(0)}catch(l){p.stop(),o(l),l instanceof Error?console.error(r.red(l.message)):console.error(r.red("Failed to run install")),process.exit(1)}}};export{p as InstallCommand,c as runInstallInDir};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as r,debugError as o}from"../../lib/debug.js";import{getBusinessApiBase as s}from"../../lib/api.js";import{ensureLoggedIn as
|
|
1
|
+
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as r,debugError as o}from"../../lib/debug.js";import{getBusinessApiBase as s}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as n}from"../../lib/spinner.js";import a from"chalk";import c from"inquirer";var l=class{async execute(l={}){r("Secrets delete flow started");let{name:m}=l;const d="1"===process.env.DASHNEX_CI;m||(d&&(console.error(a.red("--name is required in CI mode (--ci).")),process.exit(1)),m=(await c.prompt([{type:"input",name:"name",message:"Secret name:",validate:e=>""!==e.trim()||"Name is required"}])).name.trim());const p=await i();if(!p)return;const u=`${s()}/business/v1/cli/secrets/${encodeURIComponent(m)}`;r(`DELETE ${u}`);const f=n();f.start(`Deleting secret '${m}'...`);try{const e=await fetch(u,{method:"DELETE",headers:{Authorization:`Bearer ${p.token}`}});if(f.stop(),r(`Response: ${e.status}`),!e.ok){let t="Failed to delete secret.";401===e.status||403===e.status?t="Please run 'dashnex login' to authenticate.":404===e.status?t=`Secret '${m}' not found.`:502===e.status&&(t="Error deleting secret. Make sure your application is deployed."),console.error(a.red(t)),process.exit(1)}r(`Secret '${m}' deleted successfully`),console.log(a.green(`Secret '${m}' deleted.`))}catch(h){if(f.stop(),o(h),h instanceof Error&&h.message.startsWith("EXIT:"))throw h;if(t(h))return void console.log(a.yellow(e));console.error(a.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}};export{l as DeleteSecretCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as
|
|
1
|
+
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as s}from"../../lib/errors.js";import{debug as t,debugError as r}from"../../lib/debug.js";import{getBusinessApiBase as o}from"../../lib/api.js";import{ensureLoggedIn as a}from"../../services/auth.js";import{createSpinner as i}from"../../lib/spinner.js";import n from"chalk";import c from"inquirer";var l=class{async execute(l={}){t("Secrets set flow started");let{name:u,value:m}=l;const p="1"===process.env.DASHNEX_CI;u||(p&&(console.error(n.red("--name is required in CI mode (--ci).")),process.exit(1)),u=(await c.prompt([{type:"input",name:"name",message:"Secret name:",validate:e=>""!==e.trim()||"Name is required"}])).name.trim()),m||(p&&(console.error(n.red("--value is required in CI mode (--ci).")),process.exit(1)),m=(await c.prompt([{type:"password",name:"value",message:`Enter value for ${u}:`,mask:"*",validate:e=>""!==e||"Value is required"}])).value);const d=await a();if(!d)return;const f=`${o()}/business/v1/cli/secrets`;t(`PUT ${f}`);const h=i();h.start(`Setting secret '${u}'...`);try{const e=await fetch(f,{method:"PUT",headers:{Authorization:`Bearer ${d.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:u,value:m})});if(h.stop(),t(`Response: ${e.status}`),!e.ok){let s="Failed to set secret.";401===e.status||403===e.status?s="Please run 'dashnex login' to authenticate.":400===e.status?s="Missing or empty name / value.":404===e.status?s="Business has no application.":502===e.status&&(s="Error setting secret. Make sure your application is deployed."),console.error(n.red(s)),process.exit(1)}t(`Secret '${u}' set successfully`),console.log(n.green(`Secret '${u}' set successfully.`))}catch(y){if(h.stop(),r(y),y instanceof Error&&y.message.startsWith("EXIT:"))throw y;if(s(y))return void console.log(n.yellow(e));console.error(n.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}};export{l as SetSecretCommand};
|
package/dist/package.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={$schema:"https://json.schemastore.org/package",name:"@dashnex/cli",version:"0.5.
|
|
1
|
+
var e={$schema:"https://json.schemastore.org/package",name:"@dashnex/cli",version:"0.5.76",description:"Command-line interface for DashNex framework",homepage:"https://dashnex.io",type:"module",bin:{dashnex:"bin/dashnex"},engines:{node:">=22"},exports:{".":{types:"./dist/server.d.ts",default:"./dist/server.js"},"./client":{types:"./dist/client.d.ts",default:"./dist/client.js"}},scripts:{build:"vite build",dev:"vite build --watch --mode development",test:"vitest run"},keywords:["dashnex","cli"],author:"Dashnex Team",license:"UNLICENSED",dependencies:{"adm-zip":"^0.5.17",chalk:"^5.6.2",commander:"^14.0.3",dotenv:"^17.4.2","fs-extra":"^11.3.4",ignore:"^7.0.5",inquirer:"^13.4.1"},devDependencies:{"@dashnex/types":"^1.0.2","@types/adm-zip":"^0.5.8","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.9","@types/node":"^25.6.0",eslint:"^9.39.4","rollup-plugin-preserve-directives":"^0.4.0",terser:"^5.46.1",typescript:"^5.9.3",vite:"^8.0.8","vite-plugin-dts":"5.0.0-beta.6",vitest:"^4.1.4"},publishConfig:{registry:"https://npm.dashnex.com/"},files:["dist","bin"]};export{e as default};
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "dashnex",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.76",
|
|
5
5
|
"description": "Command-line interface for DashNex framework",
|
|
6
6
|
"homepage": "https://dashnex.io",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
9
|
"dashnex": "bin/dashnex"
|
|
10
10
|
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22"
|
|
13
|
+
},
|
|
11
14
|
"exports": {
|
|
12
15
|
".": {
|
|
13
16
|
"types": "./dist/server.d.ts",
|