dashnex 0.5.47 → 0.5.49

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 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
+ import o from"./version.js";import{LoginCommand as s}from"./login.js";import{LogoutCommand as e}from"./logout.js";import{WhoamiCommand as i}from"./whoami.js";import r from"./app/index.js";import n from"./secrets/index.js";const t=[{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 e,options:[]},{name:"whoami",description:"Show current logged-in business and user",handler:new i,options:[]},r,n];export{t as default};
@@ -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};
@@ -0,0 +1 @@
1
+ import e from"inquirer";import t from"chalk";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 a}from"../../lib/spinner.js";import{isUserInterrupt as n,INTERRUPTED_MESSAGE as c}from"../../lib/errors.js";class l{async execute(l={}){r("Secrets delete flow started");let{name:m}=l;if(!m){m=(await e.prompt([{type:"input",name:"name",message:"Secret name:",validate:e=>""!==e.trim()||"Name is required"}])).name.trim()}const d=await i();if(!d)return;const u=`${s()}/business/v1/cli/secrets/${encodeURIComponent(m)}`;r(`DELETE ${u}`);const p=a();p.start(`Deleting secret '${m}'...`);try{const e=await fetch(u,{method:"DELETE",headers:{Authorization:`Bearer ${d.token}`}});if(p.stop(),r(`Response: ${e.status}`),!e.ok){let r="Failed to delete secret.";401===e.status||403===e.status?r="Please run 'dashnex login' to authenticate.":404===e.status?r=`Secret '${m}' not found.`:502===e.status&&(r="Error deleting secret. Make sure your application is deployed."),console.error(t.red(r)),process.exit(1)}r(`Secret '${m}' deleted successfully`),console.log(t.green(`Secret '${m}' deleted.`))}catch(f){if(p.stop(),o(f),f instanceof Error&&f.message.startsWith("EXIT:"))throw f;if(n(f))return void console.log(t.yellow(c));console.error(t.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}}export{l as DeleteSecretCommand};
@@ -0,0 +1 @@
1
+ import{ListSecretsCommand as e}from"./list.js";import{SetSecretCommand as t}from"./set.js";import{DeleteSecretCommand as s}from"./delete.js";const n={name:"secrets",description:"Manage Cloudflare Worker secrets",handler:{execute:async()=>{}},options:[],subcommands:[{name:"list",description:"List all secret names bound to the worker",handler:new e,options:[]},{name:"set",description:"Create or update a secret",handler:new t,options:[{flags:"--name <name>",description:"Secret name"},{flags:"--value <value>",description:"Secret value"}]},{name:"delete",description:"Delete a secret",handler:new s,options:[{flags:"--name <name>",description:"Secret name"}]}]};export{n as default};
@@ -0,0 +1 @@
1
+ import e from"chalk";import{debug as s,debugError as o}from"../../lib/debug.js";import{getBusinessApiBase as t}from"../../lib/api.js";import{ensureLoggedIn as r}from"../../services/auth.js";import{createSpinner as n}from"../../lib/spinner.js";import{isUserInterrupt as i,INTERRUPTED_MESSAGE as a}from"../../lib/errors.js";class c{async execute(){s("Secrets list flow started");const c=await r();if(!c)return;const l=`${t()}/business/v1/cli/secrets`;s(`GET ${l}`);const h=n();h.start("Fetching secrets...");try{const o=await fetch(l,{headers:{Authorization:`Bearer ${c.token}`}});if(h.stop(),s(`Response: ${o.status}`),!o.ok){let s="Failed to fetch secrets.";401===o.status||403===o.status?s="Please run 'dashnex login' to authenticate.":404===o.status?s="Business has no application.":502===o.status&&(s="Error fetching secrets. Make sure your application is deployed."),console.error(e.red(s)),process.exit(1)}const t=(await o.json()).secrets??[];if(0===t.length)return void console.log(e.yellow("No secrets set."));console.log(e.bold(`\nSecrets (${t.length}):\n`)),t.forEach(({name:s})=>{console.log(` ${e.cyan(s)}`)}),console.log("")}catch(u){if(h.stop(),o(u),u instanceof Error&&u.message.startsWith("EXIT:"))throw u;if(i(u))return void console.log(e.yellow(a));console.error(e.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}}export{c as ListSecretsCommand};
@@ -0,0 +1 @@
1
+ import e from"inquirer";import t from"chalk";import{debug as s,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{isUserInterrupt as n,INTERRUPTED_MESSAGE as c}from"../../lib/errors.js";class l{async execute(l={}){s("Secrets set flow started");let{name:u,value:m}=l;if(!u){u=(await e.prompt([{type:"input",name:"name",message:"Secret name:",validate:e=>""!==e.trim()||"Name is required"}])).name.trim()}if(!m){m=(await e.prompt([{type:"password",name:"value",message:`Enter value for ${u}:`,mask:"*",validate:e=>""!==e||"Value is required"}])).value}const p=await a();if(!p)return;const f=`${o()}/business/v1/cli/secrets`;s(`PUT ${f}`);const d=i();d.start(`Setting secret '${u}'...`);try{const e=await fetch(f,{method:"PUT",headers:{Authorization:`Bearer ${p.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:u,value:m})});if(d.stop(),s(`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(t.red(s)),process.exit(1)}s(`Secret '${u}' set successfully`),console.log(t.green(`Secret '${u}' set successfully.`))}catch(h){if(d.stop(),r(h),h instanceof Error&&h.message.startsWith("EXIT:"))throw h;if(n(h))return void console.log(t.yellow(c));console.error(t.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}}}export{l as SetSecretCommand};
@@ -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.49",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
  }
@@ -0,0 +1,7 @@
1
+ import { CliCommand } from '@dashnex/types';
2
+ export interface DeleteSecretCommandOptions {
3
+ name?: string;
4
+ }
5
+ export declare class DeleteSecretCommand implements CliCommand {
6
+ execute(options?: DeleteSecretCommandOptions): Promise<void>;
7
+ }
@@ -0,0 +1,3 @@
1
+ import { CliCommandConfig } from '@dashnex/types';
2
+ declare const secretsCommand: CliCommandConfig;
3
+ export default secretsCommand;
@@ -0,0 +1,4 @@
1
+ import { CliCommand } from '@dashnex/types';
2
+ export declare class ListSecretsCommand implements CliCommand {
3
+ execute(): Promise<void>;
4
+ }
@@ -0,0 +1,8 @@
1
+ import { CliCommand } from '@dashnex/types';
2
+ export interface SetSecretCommandOptions {
3
+ name?: string;
4
+ value?: string;
5
+ }
6
+ export declare class SetSecretCommand implements CliCommand {
7
+ execute(options?: SetSecretCommandOptions): Promise<void>;
8
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "dashnex",
4
- "version": "0.5.47",
4
+ "version": "0.5.49",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",