dashnex 0.5.71 → 0.5.72
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/package.js +1 -1
- package/package.json +1 -1
|
@@ -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 i}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 i}from"../../lib/api.js";import{ensureLoggedIn as a}from"../../services/auth.js";import{createSpinner as n}from"../../lib/spinner.js";import{runDevInDir as s}from"../dev.js";import{runInstallInDir as l}from"../install.js";import c from"chalk";import p from"fs-extra";import d 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:i}=await m.prompt([{type:"confirm",name:"install",message:"Install dependencies?",default:!0}]);if(!i){if(d.resolve(e)!==d.resolve(t)){const r=d.relative(t,e);console.log(c.cyan(`Run "cd ${r}" to change to the application folder.`))}return}try{const t=n();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:a}=await m.prompt([{type:"confirm",name:"migrate",message:"Create or update database?",default:!0}]);if(!a)return;r(`Running dashnex db migrate in ${e}`);try{const t=n();t.start("Creating or updating database...");try{const i=await((e,t,r)=>new Promise((i,a)=>{const n=f(t,{cwd:e,shell:!0,stdio:"inherit",env:r?{...process.env,...r}:void 0});n.on("error",e=>{o(e),a(e)}),n.on("close",e=>{i(null===e?0:e)})}))(e,"dashnex db migrate");if(t.stop(),0!==i)return void r(`dashnex db migrate exited with code ${i}`)}catch(u){throw t.stop(),u}}catch(u){return o(u),void console.error(c.red("Failed to run dashnex db migrate."))}const{dev:p}=await m.prompt([{type:"confirm",name:"dev",message:"Run development server?",default:!0}]);if(p)try{await s(e)}catch(u){o(u),console.error(c.red(u instanceof Error?u.message:"Failed to run dev server."))}},w=async(e,t)=>{let o;try{o=await p.lstat(e)}catch{return"new"}if(o.isDirectory())return r(`Target path is a directory where a file is expected: ${e}`),"different";if(o.size!==t.length)return"different";const i=await p.readFile(e);return 0===Buffer.compare(i,t)?"identical":"different"},y=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)=>d.resolve(e)===d.resolve(t)?"Application is successfully pulled.":`Application is successfully pulled into ${d.relative(t,e)}.`,$=class{async execute(s={}){r("Pull flow started");const l=await a();if(!l)return;const f=process.cwd();let $;if(s.folder)$=s.folder.trim()||".",r(`Folder argument provided: ${$}`);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:"."}]);$=e.trim()||"."}const x=d.resolve(f,$);r(`Target folder resolved: ${x}`),await p.ensureDir(x),r(`Target folder ensured: ${x}`);const k=`${i()}/business/v1/cli/pull`;r(`GET ${k}`);const E=d.join(u.tmpdir(),`dashnex-pull-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`),b=n();b.start("Pulling application...");try{const e=await fetch(k,{headers:{Authorization:`Bearer ${l.token}`}});if(r(`Response: ${e.status}`),!e.ok){b.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(j=await e.json().catch(()=>({}))).error?j.error:"string"==typeof j.message?j.message:void 0;t&&(r=t)}console.error(c.red(r)),process.exit(1)}b.text("Downloading...");const t=Buffer.from(await e.arrayBuffer());await p.writeFile(E,t),r("Zip written to temp file"),b.text("Extracting...");const i=new h(E).getEntries().filter(e=>!e.isDirectory);r(`Zip has ${i.length} file entries`);let a=s.yes?"all":"prompt",n=!1,m=0,u=0,$=0,D=0,F=0;const P=async(e,t,r)=>{try{return await p.ensureDir(d.dirname(e)),await p.writeFile(e,t),r&&await p.chmod(e,r),!0}catch(i){return o(i),!1}};for(const o of i){const e=o.getData(),t=d.join(x,o.entryName),i=d.relative(x,t)||o.entryName,s=(o.header.attr??0)>>16&4095,l=await w(t,e);if(r(`Entry ${o.entryName}: ${l}`),"identical"===l){D+=1;continue}if("new"===l){b.stop();const r=await P(t,e,s);b.start("Extracting..."),r?m+=1:F+=1;continue}let p=!1;if("all"===a)p=!0;else if("none"===a)p=!1;else{b.stop(),n||(console.log(c.dim("Y = yes (default), n = skip, a = overwrite all, s = skip all")),n=!0);const e=await y(i);r(`Entry ${o.entryName}: user chose ${e}`),"yes"===e?p=!0:"no"===e?p=!1:"all"===e?(a="all",p=!0):(a="none",p=!1),b.start("Extracting...")}if(p){b.stop();const r=await P(t,e,s);b.start("Extracting..."),r?u+=1:F+=1}else $+=1}b.stop(),r(`Pull summary: ${m} new, ${u} overwritten, ${$} skipped, ${D} unchanged, ${F} failed`);const B=[`${m} new`,`${u} overwritten`,`${$} skipped`,`${D} unchanged`];F>0&&B.push(`${F} failed`),console.log(c.cyan(`Pulled: ${B.join(", ")}`)),d.resolve(x)!==d.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))),F>0&&(console.error(c.red(`${F} file(s) failed to write. See DEBUG output for details.`)),process.exit(1)),s.yes?r("CI mode (--yes), skipping post-pull child commands"):await g(x,f)}catch(D){if(b.stop(),o(D),D instanceof Error&&D.message.startsWith("EXIT:"))throw D;if(t(D))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 p.remove(E).catch(()=>{}),r("Temp zip removed")}var j}};export{$ as PullCommand};
|
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.72",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};
|
package/package.json
CHANGED