@dashnex/cli 0.5.50 → 0.5.52
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/commands/app/pull.js +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/install.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/services/agreements.js +1 -1
- package/dist/src/commands/dev.d.ts +8 -0
- package/dist/src/commands/install.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import t from"fs-extra";import o from"path";import r from"os";import{spawn as
|
|
1
|
+
import e from"chalk";import t from"fs-extra";import o from"path";import r from"os";import{spawn as i}from"child_process";import n 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";import{runInstallInDir as u}from"../install.js";import{runDevInDir as h}from"../dev.js";const g=async(t,r)=>{const{install:a}=await n.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!a){if(o.resolve(t)!==o.resolve(r)){const i=o.relative(r,t);console.log(e.cyan(`Run "cd ${i}" to change to the application folder.`))}return}try{const e=await u(t);if(0!==e)return void s(`install exited with code ${e}`)}catch(p){return l(p),void console.error(e.red(p instanceof Error?p.message:"Failed to run install."))}const{migrate:c}=await n.prompt([{type:"confirm",name:"migrate",message:"Create or update database?",default:!0}]);if(!c)return;s(`Running dashnex db migrate in ${t}`);try{const e=await((e,t)=>new Promise((o,r)=>{const n=i(t,{cwd:e,shell:!0,stdio:"inherit",env:void 0});n.on("error",e=>{l(e),r(e)}),n.on("close",e=>{o(null===e?0:e)})}))(t,"dashnex db migrate");if(0!==e)return void s(`dashnex db migrate exited with code ${e}`)}catch(p){return l(p),void console.error(e.red("Failed to run dashnex db migrate."))}const{dev:d}=await n.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(d)try{await h(t)}catch(p){l(p),console.error(e.red(p instanceof Error?p.message:"Failed to run dev server."))}};class w{async execute(i={}){s("Pull flow started");const u=await d();if(!u)return;const h=process.cwd();let w;if(i.folder)w=i.folder.trim()||".",s(`Folder argument provided: ${w}`);else{s("No folder argument, prompting user");const{folder:e}=await n.prompt([{type:"input",name:"folder",message:"Which folder to pull the application to?",default:"."}]);w=e.trim()||"."}const v=o.resolve(h,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(E){s(`Error reading folder: ${E}`)}if(x&&!i.yes){const{confirm:t}=await n.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`),j=p();j.start("Pulling application...");try{const r=await fetch($,{headers:{Authorization:`Bearer ${u.token}`}});if(s(`Response: ${r.status}`),!r.ok){j.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)}j.text("Downloading...");const n=Buffer.from(await r.arrayBuffer());await t.writeFile(b,n),s("Zip written to temp file"),j.text("Extracting...");new a(b).extractAllTo(v,!0),j.stop(),s("Extracted to target folder"),o.resolve(v)!==o.resolve(h)?(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,h))),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`)),i.yes?s("CI mode (--yes), skipping post-pull child commands"):await g(v,h)}catch(E){if(j.stop(),l(E),E instanceof Error&&E.message.startsWith("EXIT:"))throw E;if(m(E))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{w as PullCommand};
|
package/dist/commands/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as e}from"child_process";import
|
|
1
|
+
import{spawn as e}from"child_process";import t from"path";import r from"fs-extra";import s from"chalk";import{debug as o,debugError as n}from"../lib/debug.js";const i=["Using vars defined in \\.env"],a=(e,t)=>t.length>0&&t.some(t=>t.test(e)),c=(e,t)=>{let r="";return{write:s=>{const o="string"==typeof s?s:s.toString();r+=o;const n=r.split(/\r?\n/);r=n.pop()??"";for(const r of n)a(r,t)||e.write(r+"\n")},flush:()=>{r&&!a(r,t)&&e.write(r),r=""}}},p=async(s,a={})=>{const p=t.join(s,"dashnex.json"),l=t.join(s,"package.json");if(o(`Checking for dashnex.json at: ${p}`),!(await r.pathExists(p)))throw new Error("This is not a DashNex project.");if(o("dashnex.json found, checking for package.json"),!(await r.pathExists(l)))throw new Error("package.json is missing.");let d;o("package.json found, checking for dev script");try{d=await r.readJson(l)}catch(m){throw n(m),new Error("Failed to read package.json.")}if(!d.scripts||!d.scripts.dev)throw new Error('The "dev" script is missing from package.json. Please add a "dev" script to package.json.');o("dev script found, checking for npm availability");const h=await(async t=>new Promise(r=>{const s=e(`${t} --version`,{stdio:"ignore",shell:!0});s.on("error",()=>{r(!1)}),s.on("close",e=>{r(0===e)})}))("npm");if(o(`npm available: ${h}`),!h)throw new Error("npm is not available. Please install npm to continue.");const f=a.https?["--","--experimental-https"]:[];o(`npm available, executing: npm run dev in ${s}${a.https?" -- --experimental-https":""}`);return(async(t,r=[],s=process.cwd(),o=[])=>{const i=r.length?`${t} ${r.join(" ")}`:t,a=o.length>0;return new Promise((t,r)=>{const p=e(i,{stdio:a?["inherit","pipe","pipe"]:"inherit",cwd:s,shell:!0,env:{...process.env,NODE_ENV:"development"}});if(p.on("error",e=>{n(e),r(e)}),a&&p.stdout&&p.stderr){const e=c(process.stdout,o),r=c(process.stderr,o);p.stdout.on("data",t=>e.write(t)),p.stderr.on("data",e=>r.write(e)),p.on("close",s=>{e.flush(),r.flush(),t(null===s?0:s)})}else p.on("close",e=>{t(null===e?0:e)})})})("npm run dev",f,s,(()=>{const e=[];for(const t of i)try{e.push(new RegExp(t))}catch{o(`Invalid dev output filter pattern ignored: ${t}`)}return e})())};class l{async execute(e={}){o("Dev flow started");try{const t=await p(process.cwd(),e);process.exit(t)}catch(t){if(t instanceof Error&&t.message.startsWith("EXIT:"))throw t;n(t),t instanceof Error?console.error(s.red(t.message)):console.error(s.red("Failed to run npm run dev")),process.exit(1)}}}export{l as DevCommand,p as runDevInDir};
|
package/dist/commands/install.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as e}from"child_process";import
|
|
1
|
+
import{spawn as e}from"child_process";import r from"chalk";import{debug as o,debugError as s}from"../lib/debug.js";const n=async r=>new Promise(o=>{const s=e(`${r} --version`,{stdio:"ignore",shell:!0});s.on("error",()=>{o(!1)}),s.on("close",e=>{o(0===e)})}),t=async r=>{const t=await(async()=>await n("pnpm")?"pnpm":await n("npm")?"npm":null)();if(!t)throw new Error("Neither pnpm nor npm is available. Please install pnpm (recommended) or npm to continue.");return o(`Using package manager: ${t}`),o(`Executing: ${t} install in ${r}`),new Promise((o,n)=>{const a=[],c=[],i=e(`${t} install`,{stdio:["ignore","pipe","pipe"],cwd:r,shell:!0,env:{...process.env,NPM_CONFIG_LOGLEVEL:"error"}});i.stdout&&i.stdout.on("data",e=>a.push(e)),i.stderr&&i.stderr.on("data",e=>c.push(e)),i.on("error",e=>{s(e),n(e)}),i.on("close",e=>{const r=null===e?0:e;0!==r&&(a.length&&process.stdout.write(Buffer.concat(a)),c.length&&process.stderr.write(Buffer.concat(c))),o(r)})})};class a{async execute(){o("Install flow started");try{const e=await t(process.cwd());process.exit(e)}catch(e){s(e),e instanceof Error?console.error(r.red(e.message)):console.error(r.red("Failed to run install")),process.exit(1)}}}export{a as InstallCommand,t as runInstallInDir};
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="@dashnex/cli",a="0.5.
|
|
1
|
+
const e="@dashnex/cli",a="0.5.52",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
|
|
1
|
+
import e from"chalk";import t from"inquirer";import{debug as r,debugError as n}from"../lib/debug.js";import{getBusinessApiBase as s}from"../lib/api.js";const o=async t=>{const n=`${s()}/business/v1/agreements/payment-processing/status`;r(`GET ${n}`);const o=await fetch(n,{headers:{Authorization:`Bearer ${t}`}});if(r(`Payment agreement response: ${o.status}`),!o.ok)return!0;if((await o.json().catch(()=>({}))).hasAccepted)return!0;const a=`${await(async()=>"qa"===process.env.APPLICATION_ENV?"https://business.qa.dashnex.com":"https://business.dashnex.com")()}/money/agreement/`;return console.error(e.red(`You need to accept Master Payment Processing Agreement first by visiting this link: ${a}`)),!1},a=async(a,c={})=>{const i=c.ciMode??!1;if(!(await o(a)))return!1;const p=await(async(o,a)=>{const c=`${s()}/business/v1/tos/latest`;r(`GET ${c}`);const i=await fetch(c,{headers:{Authorization:`Bearer ${o}`}});if(r(`TOS latest response: ${i.status}`),i.ok)return!0;if(404!==i.status)return!0;const p=`${s()}/business/v1/tos/current`;r(`GET ${p}`);const l=await fetch(p,{headers:{Authorization:`Bearer ${o}`}});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(()=>({})),g=u.version??"unknown";if(u.text&&(console.log(e.dim("─".repeat(60))),console.log(e.bold(`Terms of Service ${g}`)),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(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()),console.log(e.dim("─".repeat(60)))),a)return console.log(e.yellow(`By proceeding you accept the Terms of Service ${g}.`)),!0;const{accept:m}=await t.prompt([{type:"confirm",name:"accept",message:`By creating an application you accept the Terms of Service ${g}. Continue?`,default:!0}]);if(!m)return console.log(e.yellow("Cancelled.")),!1;try{const e=`${s()}/business/v1/tos/${u.id}/accept`;r(`POST ${e}`),await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({})})}catch(h){n(h)}return!0})(a,i);return!!p};export{a as ensureAgreements};
|
|
@@ -2,6 +2,14 @@ import { CliCommand } from '@dashnex/types';
|
|
|
2
2
|
export interface DevCommandOptions {
|
|
3
3
|
https?: boolean;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Run dev server in the given directory. Single source of truth for dev logic.
|
|
7
|
+
* @param cwd - Directory (project root) to run dev in
|
|
8
|
+
* @param options - Dev options (e.g. https)
|
|
9
|
+
* @returns Exit code (0 = success)
|
|
10
|
+
* @throws When not a DashNex project, package.json missing, no dev script, or npm unavailable
|
|
11
|
+
*/
|
|
12
|
+
export declare const runDevInDir: (cwd: string, options?: DevCommandOptions) => Promise<number>;
|
|
5
13
|
export declare class DevCommand implements CliCommand {
|
|
6
14
|
execute(options?: DevCommandOptions): Promise<void>;
|
|
7
15
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { CliCommand } from '@dashnex/types';
|
|
2
|
+
/**
|
|
3
|
+
* Run install in the given directory. Single source of truth for install logic.
|
|
4
|
+
* @param cwd - Directory to run install in
|
|
5
|
+
* @returns Exit code (0 = success)
|
|
6
|
+
* @throws When no package manager (pnpm/npm) is available
|
|
7
|
+
*/
|
|
8
|
+
export declare const runInstallInDir: (cwd: string) => Promise<number>;
|
|
2
9
|
export declare class InstallCommand implements CliCommand {
|
|
3
10
|
execute(): Promise<void>;
|
|
4
11
|
}
|
package/package.json
CHANGED