@dashnex/cli 0.5.34 → 0.5.36

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
- const e="@dashnex/cli",a="0.5.34",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.36",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 +1 @@
1
- import e from"chalk";import t from"inquirer";import{debug as r,debugError as n}from"../lib/debug.js";import{getBusinessApiBase as o}from"../lib/api.js";import{getApplicationUrl as a}from"../lib/app-url.js";const s=async t=>{const n=`${o()}/business/v1/agreements/payment-processing/status`;r(`GET ${n}`);const s=await fetch(n,{headers:{Authorization:`Bearer ${t}`}});if(r(`Payment agreement response: ${s.status}`),!s.ok)return!0;if((await s.json().catch(()=>({}))).hasAccepted)return!0;const i=await(async e=>{try{const t=`${o()}/business/v1/applications`,r=await fetch(t,{headers:{Authorization:`Bearer ${e}`}});if(!r.ok)return null;const n=await r.json().catch(()=>({}));return a({subdomain:n.subdomain,appFullCustomDomain:n.appFullCustomDomain})}catch{return null}})(t),c=i?`${i}/money/agreement/`:"your business dashboard under Money > Agreement";return console.error(e.red(`You need to accept Master Payment Processing Agreement first by visiting this link: ${c}`)),!1},i=async(a,i={})=>{const c=i.ciMode??!1;if(!(await s(a)))return!1;const l=await(async(a,s)=>{const i=`${o()}/business/v1/tos/latest`;r(`GET ${i}`);const c=await fetch(i,{headers:{Authorization:`Bearer ${a}`}});if(r(`TOS latest response: ${c.status}`),c.ok)return!0;if(404!==c.status)return!0;const l=`${o()}/business/v1/tos/current`;r(`GET ${l}`);const p=await fetch(l,{headers:{Authorization:`Bearer ${a}`}});if(r(`TOS current response: ${p.status}`),!p.ok)return r("Could not fetch current TOS, skipping check"),!0;const u=await p.json().catch(()=>({})),m=u.version??"unknown";if(u.text&&(console.log(e.dim("─".repeat(60))),console.log(e.bold(`Terms of Service ${m}`)),console.log(e.dim("─".repeat(60))),console.log(u.text.replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/div>/gi,"\n").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&nbsp;/g," ").replace(/\n{3,}/g,"\n\n").trim()),console.log(e.dim("─".repeat(60)))),s)return console.log(e.yellow(`By proceeding you accept the Terms of Service ${m}.`)),!0;const{accept:g}=await t.prompt([{type:"confirm",name:"accept",message:`By creating an application you accept the Terms of Service ${m}. Continue?`,default:!0}]);if(!g)return console.log(e.yellow("Cancelled.")),!1;try{const e=`${o()}/business/v1/tos/${u.id}/accept`;r(`POST ${e}`),await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify({})})}catch(h){n(h)}return!0})(a,c);return!!l};export{i as ensureAgreements};
1
+ import e from"chalk";import t from"inquirer";import{debug as r,debugError as o}from"../lib/debug.js";import{getBusinessApiBase as n}from"../lib/api.js";import{getApplicationUrl as a}from"../lib/app-url.js";const s=async t=>{const o=`${n()}/business/v1/agreements/payment-processing/status`;r(`GET ${o}`);const s=await fetch(o,{headers:{Authorization:`Bearer ${t}`}});if(r(`Payment agreement response: ${s.status}`),!s.ok)return!0;if((await s.json().catch(()=>({}))).hasAccepted)return!0;const c=await(async e=>{try{const t=`${n()}/business/v1/applications`,r=await fetch(t,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const e=await r.json().catch(()=>({})),t=a({subdomain:e.subdomain,appFullCustomDomain:e.appFullCustomDomain});if(t)return t}}catch{}return"qa"===(process.env.APPLICATION_ENV??"")?"https://dashnex.dev":"https://dashnexcloud.com"})(t),i=`${c}/money/agreement/`;return console.error(e.red(`You need to accept Master Payment Processing Agreement first by visiting this link: ${i}`)),!1},c=async(a,c={})=>{const i=c.ciMode??!1;if(!(await s(a)))return!1;const p=await(async(a,s)=>{const c=`${n()}/business/v1/tos/latest`;r(`GET ${c}`);const i=await fetch(c,{headers:{Authorization:`Bearer ${a}`}});if(r(`TOS latest response: ${i.status}`),i.ok)return!0;if(404!==i.status)return!0;const p=`${n()}/business/v1/tos/current`;r(`GET ${p}`);const l=await fetch(p,{headers:{Authorization:`Bearer ${a}`}});if(r(`TOS current response: ${l.status}`),!l.ok)return r("Could not fetch current TOS, skipping check"),!0;const u=await l.json().catch(()=>({})),m=u.version??"unknown";if(u.text&&(console.log(e.dim("─".repeat(60))),console.log(e.bold(`Terms of Service ${m}`)),console.log(e.dim("─".repeat(60))),console.log(u.text.replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/div>/gi,"\n").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&nbsp;/g," ").replace(/\n{3,}/g,"\n\n").trim()),console.log(e.dim("─".repeat(60)))),s)return console.log(e.yellow(`By proceeding you accept the Terms of Service ${m}.`)),!0;const{accept:g}=await t.prompt([{type:"confirm",name:"accept",message:`By creating an application you accept the Terms of Service ${m}. Continue?`,default:!0}]);if(!g)return console.log(e.yellow("Cancelled.")),!1;try{const e=`${n()}/business/v1/tos/${u.id}/accept`;r(`POST ${e}`),await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify({})})}catch(h){o(h)}return!0})(a,i);return!!p};export{c as ensureAgreements};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dashnex/cli",
4
- "version": "0.5.34",
4
+ "version": "0.5.36",
5
5
  "description": "Command-line interface for DashNex framework",
6
6
  "homepage": "https://dashnex.io",
7
7
  "type": "module",