dashnex 0.5.73 → 0.5.75
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 +1 -1
- package/dist/commands/app/create.js +1 -1
- package/dist/commands/app/deploy.js +1 -1
- package/dist/commands/app/index.js +1 -1
- package/dist/commands/app/pull.js +1 -1
- package/dist/commands/app/push.js +1 -1
- package/dist/commands/dev.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/dist/src/commands/app/create.d.ts +1 -0
- package/dist/src/commands/app/deploy.d.ts +4 -1
- package/package.json +1 -1
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 i from"chalk";import c from"fs-extra";import t from"path";import{fileURLToPath as a}from"url";import{execSync as r}from"child_process";import d from"dotenv";var l=new s,{version:m,description:p}=o;l.name("dashnex").description(p).version(m).option("--ci","Disable spinner and interactive prompts (CI mode)").arguments("[command...]").action(o=>{if(o&&o.length>0){const n=o[0];if(!l.commands.map(o=>o.name()).includes(n)){console.error(i.red(`Unknown command: ${n}`));const o=process.cwd(),e=c.existsSync(t.join(o,"dashnex.json")),s=c.existsSync(t.join(o,"node_modules"));["build","router","bindings","env","db"].includes(n)?e&&!s?console.log(i.yellow(`\`${n}\` is provided by installed modules. Run \`dashnex install\` first.`)):e?console.log(i.green("Run `dashnex` to see available commands.")):console.log(i.yellow(`\`${n}\` must be run inside a DashNex application folder (containing dashnex.json).`)):console.log(i.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)});var f=null;async function u(o,n){const e=[];try{const s=function(o,n){const e=t.join(n,"package.json");if(c.existsSync(e))try{const s=JSON.parse(c.readFileSync(e,"utf8"));if(s.name===o)return n;const i={...s.dependencies,...s.devDependencies}[o];if(i&&(i.startsWith("link:")||i.startsWith("file:"))){const o=t.resolve(n,i.replace(/^(link:|file:)/,""));if(c.existsSync(o))return o}}catch{}const s=t.join(n,"node_modules",o);if(c.existsSync(s))return c.realpathSync(s);if(f){const n=t.join(f,o);if(c.existsSync(n))return n}return s}(o,n),i=[t.join(s,"dist","commands","index.js"),t.join(s,"src","commands","index.ts"),t.join(s,"src","commands","index.js")].find(o=>c.existsSync(o));if(i){const o=await import(i);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(i.yellow(`Module ${o} has no commands or failed to load: ${n}`))}}return e}function h(o,s,c={}){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=>{h(t,o,{...c,...s.options})});const a=s.subcommands&&s.subcommands.length>0;"pull"===s.name?t.action(async(o,t,a)=>{try{const n={...c,...t};o&&(n.folder=o),await s.handler.execute(n)}catch(r){if(e(r))return void console.log(i.yellow(n));console.error(i.red(`❌ Command failed in ${s.name}:`),r),process.exit(1)}}):a?t.action(async()=>{t.outputHelp()}):t.action(async(o,t)=>{try{const n={...c,...o};await s.handler.execute(n)}catch(a){if(e(a))return void console.log(i.yellow(n));console.error(i.red(`❌ Command failed in ${s.name}:`),a),process.exit(1)}})}(async function(){d.config({quiet:!0}),process.env.DASHNEX_CLI="1",function(){try{f=r("npm root -g",{encoding:"utf8"}).trim()}catch{f=null}}(),process.argv.includes("--ci")&&(process.env.DASHNEX_CI="1");let o=process.cwd();const n=t.dirname(a(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: ${f??"not found"}`));const s=await async function(o){try{const e=[],s=/* @__PURE__ */new Set,i=o=>{s.has(o)||(s.add(o),e.push(o))},a=t.join(o,"dashnex.json");if(c.existsSync(a)){const n=t.join(o,"package.json");if(c.existsSync(n)){const o=JSON.parse(c.readFileSync(n,"utf8"));o.name&&i(o.name)}}const r=t.join(o,"package.json");if(c.existsSync(r)){const n=JSON.parse(c.readFileSync(r,"utf8")),e={...n.dependencies,...n.devDependencies,...n.optionalDependencies};for(const[s,a]of Object.entries(e)){if("string"==typeof a&&(a.startsWith("link:")||a.startsWith("file:"))){const n=t.resolve(o,a.replace(/^(link:|file:)/,""));if(c.existsSync(t.join(n,"dashnex.json"))){i(s);continue}}const n=t.join(o,"node_modules",s);c.existsSync(t.join(n,"dashnex.json"))&&i(s)}}if(f&&c.existsSync(f))try{const o=c.readdirSync(f);for(const n of o)if(n.startsWith("@")){const o=t.join(f,n);try{if(c.statSync(o).isDirectory()){const e=c.readdirSync(o);for(const o of e){const e=`${n}/${o}`,s=t.join(f,e);c.existsSync(t.join(s,"dashnex.json"))&&i(e)}}}catch{}}else{const o=t.join(f,n);c.existsSync(t.join(o,"dashnex.json"))&&i(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),m=e.includes("node_modules");let p=!1;try{const n=t.join(o,"package.json");if(await c.pathExists(n)){const o=JSON.parse(await c.readFile(n,"utf8"));p="@dashnex/cli"in{...o.dependencies,...o.devDependencies,...o.optionalDependencies}}}catch{}!m&&!p||s.includes("@dashnex/cli")||s.push("@dashnex/cli"),process.env.DEBUG&&(console.log(`CLI package directory: ${e}`),console.log(`Is installed package: ${m}`),console.log(`CLI in dependencies: ${p}`),console.log(`Discovered modules: ${s.join(", ")}`));for(const a of s){let n=[];if("@dashnex/cli"===a&&(m||p))try{const o=t.join(e,"dist","commands","index.js");if(process.env.DEBUG&&console.log(`Loading @dashnex/cli commands from: ${o}`),await c.pathExists(o)){const e=await import(o);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(g){if(process.env.DEBUG){const o=g instanceof Error?g.message:String(g);console.log(i.yellow(`Failed to load @dashnex/cli commands: ${o}`))}}else n=await u(a,o);for(const o of n)h(l,o)}try{const{default:n}=await import(t.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(i.yellow("⚠ Failed to discover application commands"))}l.parse(process.argv)})().catch(o=>{e(o)&&(console.log(i.yellow(n)),process.exit(0)),console.error(i.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 o,debugError as s}from"../../lib/debug.js";import{getBusinessApiBase as a}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as r}from"../../lib/spinner.js";import{PullCommand as n}from"./pull.js";import{ensureAgreements as l}from"../../services/agreements.js";import c from"chalk";import p from"inquirer";var u=e=>Array.isArray(e.message)&&e.message.length>0?e.message.join("\n"):"string"==typeof e.message?e.message:"string"==typeof e.error?e.error:void 0,d=e=>new Promise(t=>setTimeout(t,e)),m=class{async pollApplicationCreated(e,t,a=5e3,i=6e4){const r=Date.now();let n=0;for(;Date.now()-r<i;){n++,o(`Polling application status (attempt ${n})...`);try{const s=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(o(`Poll response: ${s.status}`),200===s.status){const e=await s.json();if(o(`Poll response body status: ${e.status}`),"creating"!==e.status)return o(`Application status is "${e.status}", creation complete`),{ready:!0,status:e.status};o('Application status is still "creating", continuing to poll...')}}catch(l){s(l),o(`Poll attempt ${n} failed with network error`)}await d(a)}return{ready:!1}}async execute(d={}){o("Create flow started");const m=await i();if(!m)return;o("Auth valid, checking if business already has application");const h=r(),f=`${a()}/business/v1/applications`;o(`GET ${f}`),h.start("Checking application status...");try{const e=await fetch(f,{headers:{Authorization:`Bearer ${m.token}`}});h.stop(),o(`Applications response: ${e.status}`),o(`Applications response body: ${await e.text()}`),404!==e.status&&(console.error(c.red("Business already has an application. Run 'dashnex app pull' to pull the existing one.")),process.exit(1))}catch(C){if(h.stop(),s(C),C instanceof Error&&C.message.startsWith("EXIT:"))throw C;if(t(C))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)}o("No existing application, checking agreements");const g=void 0!==d.subdomain;if(!(await l(m.token,{ciMode:g})))return;let y;o("Agreements checked, proceeding to subdomain prompt");const b=e=>`${a()}/business/v1/applications/check-subdomain?subdomain=${encodeURIComponent(e)}`;let
|
|
1
|
+
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as o,debugError as s}from"../../lib/debug.js";import{getBusinessApiBase as a}from"../../lib/api.js";import{ensureLoggedIn as i}from"../../services/auth.js";import{createSpinner as r}from"../../lib/spinner.js";import{PullCommand as n}from"./pull.js";import{ensureAgreements as l}from"../../services/agreements.js";import c from"chalk";import p from"inquirer";var u=e=>Array.isArray(e.message)&&e.message.length>0?e.message.join("\n"):"string"==typeof e.message?e.message:"string"==typeof e.error?e.error:void 0,d=e=>new Promise(t=>setTimeout(t,e)),m=class{async pollApplicationCreated(e,t,a=5e3,i=6e4){const r=Date.now();let n=0;for(;Date.now()-r<i;){n++,o(`Polling application status (attempt ${n})...`);try{const s=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(o(`Poll response: ${s.status}`),200===s.status){const e=await s.json();if(o(`Poll response body status: ${e.status}`),"creating"!==e.status)return o(`Application status is "${e.status}", creation complete`),{ready:!0,status:e.status};o('Application status is still "creating", continuing to poll...')}}catch(l){s(l),o(`Poll attempt ${n} failed with network error`)}await d(a)}return{ready:!1}}async execute(d={}){o("Create flow started");const m=await i();if(!m)return;o("Auth valid, checking if business already has application");const h=r(),f=`${a()}/business/v1/applications`;o(`GET ${f}`),h.start("Checking application status...");try{const e=await fetch(f,{headers:{Authorization:`Bearer ${m.token}`}});h.stop(),o(`Applications response: ${e.status}`),o(`Applications response body: ${await e.text()}`),404!==e.status&&(console.error(c.red("Business already has an application. Run 'dashnex app pull' to pull the existing one.")),process.exit(1))}catch(C){if(h.stop(),s(C),C instanceof Error&&C.message.startsWith("EXIT:"))throw C;if(t(C))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)}o("No existing application, checking agreements");const g=void 0!==d.subdomain;if(!(await l(m.token,{ciMode:g})))return;let y;o("Agreements checked, proceeding to subdomain prompt");const b=e=>`${a()}/business/v1/applications/check-subdomain?subdomain=${encodeURIComponent(e)}`;let w=d.subdomain?.trim();for(;;){if(w)y=w,w=void 0,o(`Subdomain provided via flag: ${y}`);else{if(g)return console.error(c.red("Subdomain is not available.")),void process.exit(1);{const{sub:e}=await p.prompt([{type:"input",name:"sub",message:"Pick your subdomain:",validate:e=>!!e.trim()||"Subdomain is required"}]);y=e.trim()}}o(`Checking subdomain: ${y}`);const a=b(y);o(`GET ${a}`),h.start("Checking subdomain...");try{const e=await fetch(a,{headers:{Authorization:`Bearer ${m.token}`}});h.stop(),o(`Check subdomain response: ${e.status}`);const t=await e.text();if(o(`Check subdomain response body: ${t}`),!e.ok){const s=e.headers.get("content-type")??"";let a="Failed to check subdomain availability.";if(401!==e.status&&403!==e.status||(a="Please run 'dashnex login' to authenticate.",console.error(c.red(a)),process.exit(1)),s.includes("application/json")){const e=JSON.parse(t);o(`Check subdomain error body: ${JSON.stringify(e)}`);const s=u(e);s&&(a=s)}console.error(c.red(a));continue}const s=JSON.parse(t);if(o(`Check subdomain parsed body: ${JSON.stringify(s)}`),s.available){o(`Subdomain ${y} is available`);break}console.error(c.red("Subdomain is not available. Please choose a different one."))}catch(C){if(h.stop(),s(C),C instanceof Error&&C.message.startsWith("EXIT:"))throw C;if(t(C))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)}}const $=`${a()}/business/v1/cli/create`;o(`POST ${$}`);const k={subdomain:y};d.template&&(k.template=d.template,o(`Template: ${d.template}`));const x=JSON.stringify(k);o(`Create request body: ${x}`),h.start("Creating application...");try{const i=await fetch($,{method:"POST",headers:{Authorization:`Bearer ${m.token}`,"Content-Type":"application/json"},body:x});h.stop(),o(`Create response: ${i.status}`);const r=await i.text();if(o(`Create response body: ${r}`),503===i.status){o("Create returned 503, polling for application creation..."),h.start("Waiting for application to be ready...");const e=`${a()}/business/v1/applications`,t=await this.pollApplicationCreated(e,m.token);h.stop(),t.ready||(console.error(c.red("Application creation is taking longer than expected. Try again later or run 'dashnex app pull' to check.")),process.exit(1)),"failed"===t.status&&(console.error(c.red("Application creation failed. Please try again.")),process.exit(1)),o("Application found after polling")}else if(!i.ok){const e=i.headers.get("content-type")??"";let t="Failed to create application.";if(401===i.status||403===i.status)t="Please run 'dashnex login' to authenticate.";else if(e.includes("application/json")){const e=JSON.parse(r);o(`Create error body parsed: ${JSON.stringify(e)}`);const s=u(e);s&&(t=s)}console.error(c.red(t)),process.exit(1)}let l;if(o("Application created successfully"),!0===d.pull?(l=!0,o("--pull flag set, pulling without prompting")):!1===d.pull?(l=!1,o("--no-pull flag set, skipping pull")):g?(l=!1,o("CI mode (--subdomain), skipping pull")):(l=(await p.prompt([{type:"confirm",name:"pull",message:"Pull the application locally?",default:!0}])).pull,o(`User chose to pull: ${l}`)),l){o("Running pull flow");try{await(new n).execute()}catch(C){if(s(C),C instanceof Error&&C.message.startsWith("EXIT:"))throw C;if(t(C))return void console.log(c.yellow(e));console.error(c.red("Failed to pull application."))}}else console.log(c.green("Application is created successfully. Run 'dashnex app pull' to pull it to your computer or 'dashnex app deploy' to deploy it to the cloud."))}catch(C){if(h.stop(),s(C),C instanceof Error&&C.message.startsWith("EXIT:"))throw C;if(t(C))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)}}};export{m as CreateCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as o,debugError as
|
|
1
|
+
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as t}from"../../lib/errors.js";import{debug as o,debugError as r}from"../../lib/debug.js";import{getBusinessApiBase as s,getDeployerBase as n}from"../../lib/api.js";import{ensureLoggedIn as a}from"../../services/auth.js";import{createSpinner as i}from"../../lib/spinner.js";import{CheckCommand as c}from"../check.js";import{ensureAgreements as p}from"../../services/agreements.js";import{getApplicationUrl as l}from"../../lib/app-url.js";import d from"chalk";var m=3e5,f=99,u=e=>new Promise(t=>setTimeout(t,e)),y=async(e,t,s,n)=>{const a=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"text/event-stream"}});if(o(`SSE connection opened: ${a.status}`),!a.ok){const e=a.status;let t="Failed to start deployment.";if(401===e||403===e)t="Please run 'dashnex login' to authenticate.";else try{const e=await a.text(),o=JSON.parse(e);"string"==typeof o.error?t=o.error:"string"==typeof o.message&&(t=o.message)}catch{}throw console.error(d.red(t)),new Error(`HTTP ${e}: ${t}`)}if(!a.body)throw new Error("Response body is null");o("SSE connection established successfully"),n?.();const i=a.body.getReader();try{for await(const e of async function*(e){const t=new TextDecoder("utf-8");let o="";for(;;){const{value:r,done:s}=await e.read();if(s)break;o+=t.decode(r,{stream:!0});const n=o.split("\n");o=n.pop()||"";let a="";for(const e of n)e.startsWith("data: ")?a=e.slice(6):""===e&&a&&(yield{data:a},a="")}if(o.startsWith("data: ")){const e=o.slice(6);e&&(yield{data:e})}}(i))try{if(!e.data){o("Received empty SSE event");continue}const t=JSON.parse(e.data);o(`SSE message received: ${JSON.stringify(t)}`),s(t)}catch(c){r(c),o(`Failed to parse SSE event data: ${e.data}`)}}finally{i.releaseLock()}},h=class{async execute(s={}){o("Deploy flow started");const l=await a();if(!l)return;if(!1!==s.check?(o("Running pre-deploy checks"),await(new c).run(!1)||(console.error(d.red("Deploy aborted: checks failed. Re-run with --no-check to skip.")),process.exit(1))):o("Skipping pre-deploy checks (--no-check)"),!(await p(l.token,{ciMode:!0})))return;const h=`${n()}/business/v1/applications/deploy`;o(`GET ${h} (SSE)`);let g=0,w="",S=!1,b=0,k=!1;const $=i();let v=0,x=0,D=null;const E=(e,t)=>{const o=Math.round(e);$.text(`[${o}%] ${t}`)},j=()=>{T();const e=g,t=Date.now(),o=m*((f-e)/f);D=setInterval(()=>{const r=Date.now()-t;let s;if(x>t){const e=Date.now()-x,t=f-v,o=3030.3030303030305*t;s=Math.min(v+e/o*t,f)}else s=Math.min(e+r/o*(f-e),f);s>g&&(g=s,E(g,w))},200)},T=()=>{D&&(clearInterval(D),D=null)};let M=!1;const R=e=>{if(k=!0,"string"==typeof e.error)return T(),$.stop(),console.error(d.red(e.error)),S=!0,void(M=!0);"string"==typeof e.message&&(w=e.message),"number"==typeof e.progress&&(v=e.progress,x=Date.now(),e.progress>g&&(g=e.progress)),"string"!=typeof e.message&&"number"!=typeof e.progress||(g>=100?(T(),$.stop(),S=!0):E(g,w))};for(;b<=5;)try{return k?E(g,w):$.start("Connecting..."),j(),await y(h,l.token,R,()=>{k||($.text(`[${Math.round(g)}%] Deployment in progress...`),w="Deployment in progress...")}),T(),$.stop(),o("SSE connection closed"),M&&process.exit(1),void(S&&await this.showDeployedUrl(l.token))}catch(C){if(T(),r(C),o(`SSE connection error: ${C}`),S)return $.stop(),void(M&&process.exit(1));if(t(C))return $.stop(),void console.log(d.yellow(e));C instanceof Error&&C.message.startsWith("HTTP")&&($.stop(),console.error(d.red("Could not complete deployment. Check your connection and try again.")),process.exit(1)),b++,b>5&&($.stop(),console.error(d.red("Deployment failed. Maximum reconnection attempts exceeded.")),process.exit(1));const s=Math.min(1e3*Math.pow(2,b-1),3e4);o(`Connection error. Reconnecting in ${s/1e3}s... (attempt ${b}/5)`),await u(s)}}async showDeployedUrl(e){try{const t=`${s()}/business/v1/applications`;o(`GET ${t} (for deployed URL)`);const r=await fetch(t,{headers:{Authorization:`Bearer ${e}`}});if(!r.ok)return;const n=await r.json().catch(()=>({})),a=l({subdomain:n.subdomain,appFullCustomDomain:n.appFullCustomDomain});a&&console.log(`Application is deployed to ${d.cyan(a)}`)}catch(t){r(t)}}};export{h as DeployCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PullCommand as e}from"./pull.js";import{CreateCommand as
|
|
1
|
+
import{PullCommand as e}from"./pull.js";import{CreateCommand as p}from"./create.js";import{DeployCommand as o}from"./deploy.js";import{PushCommand as i}from"./push.js";import{DeleteCommand as s}from"./delete.js";import{StatusCommand as a}from"./status.js";var t={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 p,options:[{flags:"-t, --template <template>",description:"Template (name@branch-or-tag)",defaultValue:"webapp-base@live"},{flags:"--subdomain <subdomain>",description:"Subdomain (CI mode, skip prompts)"},{flags:"--pull",description:"Auto-pull after creation (skip prompt)"},{flags:"--no-pull",description:"Skip the pull prompt and show the success message"}]},{name:"pull",description:"Pull existing application to specified folder",handler:new e,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 s,options:[{flags:"-y, --yes",description:"Skip confirmation prompt"}]},{name:"deploy",description:"Deploy application to DashNex",handler:new o,options:[{flags:"--no-check",description:"Skip pre-deploy checks"}]},{name:"status",description:"Show current application status",handler:new a,options:[]}]};export{t as default};
|
|
@@ -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
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as o}from"../../lib/errors.js";import{debug as t,debugError as i}from"../../lib/debug.js";import{getBusinessApiBase as s}from"../../lib/api.js";import{ensureLoggedIn as r}from"../../services/auth.js";import{createSpinner as n}from"../../lib/spinner.js";import{CheckCommand as a}from"../check.js";import{DeployCommand as c}from"./deploy.js";import p from"chalk";import l from"fs-extra";import d from"path";import m from"inquirer";import
|
|
1
|
+
import{INTERRUPTED_MESSAGE as e,isUserInterrupt as o}from"../../lib/errors.js";import{debug as t,debugError as i}from"../../lib/debug.js";import{getBusinessApiBase as s}from"../../lib/api.js";import{ensureLoggedIn as r}from"../../services/auth.js";import{createSpinner as n}from"../../lib/spinner.js";import{CheckCommand as a}from"../check.js";import{DeployCommand as c}from"./deploy.js";import p from"chalk";import l from"fs-extra";import d from"path";import m from"inquirer";import h from"os";import f from"adm-zip";import u from"ignore";var w=[".dashnex",".git",".vinext",".wrangler","wrangler.jsonc"],g=async(e,o)=>{const t=[],i=await l.readdir(e,{withFileTypes:!0});for(const s of i){const i=d.relative(process.cwd(),d.join(e,s.name)).split(d.sep).join("/");if(w.some(e=>i===e||i.startsWith(`${e}/`)||i.endsWith(`/${e}`)))continue;if(o.ignores(i))continue;const r=d.join(e,s.name);if(s.isDirectory()){const e=await g(r,o);t.push(...e)}else s.isFile()&&t.push(r)}return t},y=class{async execute(y={}){t("Push flow started"),!1!==y.check?(t("Running pre-push checks"),await(new a).run(!1)||(console.error(p.red("Push aborted: checks failed. Re-run with --no-check to skip.")),process.exit(1))):t("Skipping pre-push checks (--no-check)");const j=await r();if(!j)return;const k=process.cwd(),v=d.join(k,".gitignore"),x=u();if(x.add(w),await l.pathExists(v)){const e=await l.readFile(v,"utf8");x.add(e)}t("Building file list");const $=await g(k,x);t(`Including ${$.length} files`);const b=new f;for(const e of $){const o=d.relative(k,e).split(d.sep).join("/"),t="."===d.dirname(o)?"":d.dirname(o),i=d.basename(o);b.addLocalFile(e,t,i)}const F=d.join(h.tmpdir(),`dashnex-push-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),P=n();try{P.start("Packaging application..."),b.writeZip(F),t(`Zip written to ${F}`);const e=`${s()}/business/v1/cli/push`;t(`POST ${e}`);const o=await l.readFile(F),i=new Blob([o],{type:"application/zip"}),r=new FormData;r.append("file",i,"archive.zip");const n=new Headers;n.set("Authorization",`Bearer ${j.token}`),P.text("Uploading...");const a=await fetch(e,{method:"POST",headers:n,body:r});if(P.stop(),t(`Response: ${a.status}`),!a.ok){const e=a.headers.get("content-type")??"";let o="Failed to push application.";if(401===a.status||403===a.status)o="Please run 'dashnex login' to authenticate.";else if(e.includes("application/json")){const e="string"==typeof(z=await a.json().catch(()=>({}))).error?z.error:"string"==typeof z.message?z.message:void 0;e&&(o=e)}console.error(p.red(o)),process.exit(1)}let d;console.log(p.green("Application pushed successfully.")),void 0!==y.deploy?(d=y.deploy,t(`Deploy decided via flag: ${d}`)):(d=(await m.prompt([{type:"confirm",name:"deploy",message:"Deploy the application?",default:!0}])).deploy,t(`User chose to deploy: ${d}`)),d&&(t("Running deploy flow"),await(new c).execute())}catch(D){if(P.stop(),i(D),D instanceof Error&&D.message.startsWith("EXIT:"))throw D;if(o(D))return void console.log(p.yellow(e));console.error(p.red("Could not reach DashNex API. Check your connection and try again.")),process.exit(1)}finally{await l.remove(F).catch(()=>{}),t("Temp zip removed")}var z}};export{y as PushCommand};
|
package/dist/commands/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{debug as e,debugError as r}from"../lib/debug.js";import t from"chalk";import n from"fs-extra";import o from"path";import{spawn as s}from"child_process";var i=["Using vars defined in \\.env","\\(node:\\d+\\) MaxListenersExceededWarning:","\\(Use `node --trace-warnings","\\[WARNING\\].*You have defined bindings to the following internal Durable Objects","You have defined bindings to the following internal Durable Objects",'\\{"name":".+","class_name":".+"\\}',"These will not work in local development, but they should work in production","If you want to develop these locally, you can define your DO in a separate Worker","For detailed instructions, refer to the Durable Objects section here:","developers.cloudflare.com/workers/wrangler/api#supported-bindings","workerd/server/server\\.c\\+\\+.*warning:.*DurableObjectNamespace"],a=(e,r)=>r.length>0&&r.some(r=>r.test(e)),c=(r,t)=>{let n="";return{write:o=>{const s="string"==typeof o?o:o.toString();n+=s;const i=n.split(/\r?\n/);n=i.pop()??"";for(const n of i){const o=n.trim();o?a(o,t)?e(`Filtered: ${o}`):r.write(n+"\n"):e("Filtered: <empty line>")}},flush:()=>{const o=n.trim();if(o){if(a(o,t))return e(`Filtered: ${o}`),void(n="");r.write(n),n=""}else n=""}}},l=async(t,a={})=>{const l=o.join(t,"dashnex.json"),d=o.join(t,"package.json");if(e(`Checking for dashnex.json at: ${l}`),!(await n.pathExists(l)))throw new Error("Run this command in a DashNex Web application folder.");if(e("dashnex.json found, checking for package.json"),!(await n.pathExists(d)))throw new Error("package.json is missing.");let p;e("package.json found, checking for dev script");try{p=await n.readJson(d)}catch(u){throw r(u),new Error("Failed to read package.json.")}if(!p.scripts||!p.scripts.dev)throw new Error('The "dev" script is missing from package.json. Please add a "dev" script to package.json.');e("dev script found, checking for npm availability");const h=await(async e=>new Promise(r=>{const t=s(`${e} --version`,{stdio:"ignore",shell:!0});t.on("error",()=>{r(!1)}),t.on("close",e=>{r(0===e)})}))("npm");if(e(`npm available: ${h}`),!h)throw new Error("npm is not available. Please install npm to continue.");const f=a.https?["--","--experimental-https"]:[];return e(`npm available, executing: npm run dev in ${t}${a.https?" -- --experimental-https":""}`),(async(e,t=[],n=process.cwd(),o=[])=>{const i=t.length?`${e} ${t.join(" ")}`:e,a=o.length>0;return new Promise((e,t)=>{const l=s(i,{stdio:a?["inherit","pipe","pipe"]:"inherit",cwd:n,shell:!0,env:{...process.env,NODE_ENV:"development"}});if(l.on("error",e=>{r(e),t(e)}),a&&l.stdout&&l.stderr){const r=c(process.stdout,o),t=c(process.stderr,o);l.stdout.on("data",e=>r.write(e)),l.stderr.on("data",e=>t.write(e)),l.on("close",n=>{r.flush(),t.flush(),e(null===n?0:n)})}else l.on("close",r=>{e(null===r?0:r)})})})("npm run dev",f,t,(()=>{const r=[];for(const t of i)try{r.push(new RegExp(t))}catch{e(`Invalid dev output filter pattern ignored: ${t}`)}return r})())},d=class{async execute(n={}){e("Dev flow started");try{const e=await l(process.cwd(),n);process.exit(e)}catch(o){if(o instanceof Error&&o.message.startsWith("EXIT:"))throw o;r(o),o instanceof Error?console.error(t.red(o.message)):console.error(t.red("Failed to run npm run dev")),process.exit(1)}}};export{d as DevCommand,l as runDevInDir};
|
|
1
|
+
import{debug as e,debugError as r}from"../lib/debug.js";import t from"chalk";import n from"fs-extra";import o from"path";import{spawn as s}from"child_process";var i=["Using vars defined in \\.env","\\(node:\\d+\\) MaxListenersExceededWarning:","\\(Use `node --trace-warnings","\\[WARNING\\].*You have defined bindings to the following internal Durable Objects","You have defined bindings to the following internal Durable Objects",'\\{"name":".+","class_name":".+"\\}',"These will not work in local development, but they should work in production","If you want to develop these locally, you can define your DO in a separate Worker","For detailed instructions, refer to the Durable Objects section here:","developers.cloudflare.com/workers/wrangler/api#supported-bindings","workerd/server/server\\.c\\+\\+.*warning:.*DurableObjectNamespace"],a=(e,r)=>r.length>0&&r.some(r=>r.test(e)),c=(r,t)=>{let n="";return{write:o=>{const s="string"==typeof o?o:o.toString();n+=s;const i=n.split(/\r?\n/);n=i.pop()??"";for(const n of i){const o=n.trim();o?a(o,t)?e(`Filtered: ${o}`):r.write(n+"\n"):e("Filtered: <empty line>")}},flush:()=>{const o=n.trim();if(o){if(a(o,t))return e(`Filtered: ${o}`),void(n="");r.write(n),n=""}else n=""}}},l=async(t,a={})=>{const l=o.join(t,"dashnex.json"),d=o.join(t,"package.json");if(e(`Checking for dashnex.json at: ${l}`),!(await n.pathExists(l)))throw new Error("Run this command in a DashNex Web application folder.");if(e("dashnex.json found, checking for package.json"),!(await n.pathExists(d)))throw new Error("package.json is missing.");let p;e("package.json found, checking for dev script");try{p=await n.readJson(d)}catch(u){throw r(u),new Error("Failed to read package.json.")}if(!p.scripts||!p.scripts.dev)throw new Error('The "dev" script is missing from package.json. Please add a "dev" script to package.json.');e("dev script found, checking for npm availability");const h=await(async e=>new Promise(r=>{const t=s(`${e} --version`,{stdio:"ignore",shell:!0});t.on("error",()=>{r(!1)}),t.on("close",e=>{r(0===e)})}))("npm");if(e(`npm available: ${h}`),!h)throw new Error("npm is not available. Please install npm to continue.");const f=a.https?["--","--experimental-https"]:[];return e(`npm available, executing: npm run dev in ${t}${a.https?" -- --experimental-https":""}`),(async(e,t=[],n=process.cwd(),o=[])=>{const i=t.length?`${e} ${t.join(" ")}`:e,a=o.length>0;return new Promise((e,t)=>{const l=s(i,{stdio:a?["inherit","pipe","pipe"]:"inherit",cwd:n,shell:!0,env:{...process.env,NODE_ENV:"development",FORCE_COLOR:"1"}});if(l.on("error",e=>{r(e),t(e)}),a&&l.stdout&&l.stderr){const r=c(process.stdout,o),t=c(process.stderr,o);l.stdout.on("data",e=>r.write(e)),l.stderr.on("data",e=>t.write(e)),l.on("close",n=>{r.flush(),t.flush(),e(null===n?0:n)})}else l.on("close",r=>{e(null===r?0:r)})})})("npm run dev",f,t,(()=>{const r=[];for(const t of i)try{r.push(new RegExp(t))}catch{e(`Invalid dev output filter pattern ignored: ${t}`)}return r})())},d=class{async execute(n={}){e("Dev flow started");try{const e=await l(process.cwd(),n);process.exit(e)}catch(o){if(o instanceof Error&&o.message.startsWith("EXIT:"))throw o;r(o),o instanceof Error?console.error(t.red(o.message)):console.error(t.red("Failed to run npm run dev")),process.exit(1)}}};export{d as DevCommand,l as runDevInDir};
|
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.75",description:"Command-line interface for DashNex framework",homepage:"https://dashnex.io",type:"module",bin:{dashnex:"bin/dashnex"},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};
|
|
@@ -2,6 +2,7 @@ import { CliCommand } from '@dashnex/types';
|
|
|
2
2
|
export interface CreateCommandOptions {
|
|
3
3
|
template?: string;
|
|
4
4
|
subdomain?: string;
|
|
5
|
+
pull?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare class CreateCommand implements CliCommand {
|
|
7
8
|
pollApplicationCreated(applicationsUrl: string, token: string, interval?: number, timeout?: number): Promise<{
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { CliCommand } from '@dashnex/types';
|
|
2
|
+
export interface DeployCommandOptions {
|
|
3
|
+
check?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare class DeployCommand implements CliCommand {
|
|
3
|
-
execute(): Promise<void>;
|
|
6
|
+
execute(options?: DeployCommandOptions): Promise<void>;
|
|
4
7
|
private showDeployedUrl;
|
|
5
8
|
}
|
package/package.json
CHANGED