@dashnex/cli 0.5.57 → 0.5.58
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 e from"chalk";import t from"fs-extra";import o from"path";import r from"os";import{spawn as i}from"child_process";import
|
|
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 a from"inquirer";import n 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:n}=await a.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!n){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=p();e.start("Installing dependencies...");try{const o=await u(t);if(e.stop(),0!==o)return void s(`install exited with code ${o}`)}catch(m){throw e.stop(),m}}catch(m){return l(m),void console.error(e.red(m instanceof Error?m.message:"Failed to run install."))}const{migrate:c}=await a.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=p();e.start("Creating or updating database...");try{const o=await((e,t)=>new Promise((o,r)=>{const a=i(t,{cwd:e,shell:!0,stdio:"inherit",env:void 0});a.on("error",e=>{l(e),r(e)}),a.on("close",e=>{o(null===e?0:e)})}))(t,"dashnex db migrate");if(e.stop(),0!==o)return void s(`dashnex db migrate exited with code ${o}`)}catch(m){throw e.stop(),m}}catch(m){return l(m),void console.error(e.red("Failed to run dashnex db migrate."))}const{dev:d}=await a.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(d)try{await h(t)}catch(m){l(m),console.error(e.red(m instanceof Error?m.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 a.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 a.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 a=Buffer.from(await r.arrayBuffer());await t.writeFile(b,a),s("Zip written to temp file"),j.text("Extracting...");new n(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/install.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as e}from"child_process";import r from"chalk";import{debug as
|
|
1
|
+
import{spawn as e}from"child_process";import r from"chalk";import{debug as s,debugError as o}from"../lib/debug.js";import{createSpinner as n}from"../lib/spinner.js";const t=async r=>new Promise(s=>{const o=e(`${r} --version`,{stdio:"ignore",shell:!0});o.on("error",()=>{s(!1)}),o.on("close",e=>{s(0===e)})}),i=async r=>{const n=await(async()=>await t("pnpm")?"pnpm":await t("npm")?"npm":null)();if(!n)throw new Error("Neither pnpm nor npm is available. Please install pnpm (recommended) or npm to continue.");return s(`Using package manager: ${n}`),s(`Executing: ${n} install in ${r}`),new Promise((s,t)=>{const i=[],a=[],c=e(`${n} install`,{stdio:["ignore","pipe","pipe"],cwd:r,shell:!0,env:{...process.env,NPM_CONFIG_LOGLEVEL:"error"}});c.stdout&&c.stdout.on("data",e=>i.push(e)),c.stderr&&c.stderr.on("data",e=>a.push(e)),c.on("error",e=>{o(e),t(e)}),c.on("close",e=>{const r=null===e?0:e;0!==r&&(i.length&&process.stdout.write(Buffer.concat(i)),a.length&&process.stderr.write(Buffer.concat(a))),s(r)})})};class a{async execute(){s("Install flow started");const e=n();e.start("Installing dependencies...");try{const r=await i(process.cwd());e.stop(),process.exit(r)}catch(t){e.stop(),o(t),t instanceof Error?console.error(r.red(t.message)):console.error(r.red("Failed to run install")),process.exit(1)}}}export{a as InstallCommand,i 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.58",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};
|
package/package.json
CHANGED