@zibby/cli 0.1.32 → 0.1.33
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import i from"os";import a from"path";import{existsSync as m,readFileSync as
|
|
1
|
+
import i from"os";import a from"path";import{existsSync as m,readFileSync as S,readdirSync as h,createWriteStream as g,mkdirSync as x,rmSync as I,unlinkSync as Z}from"fs";import{execFileSync as b}from"child_process";import{createInterface as v}from"readline";import l from"chalk";const A=process.env.ZIBBY_STUDIO_CDN||"https://dl.zibby.app",n=a.join(i.homedir(),".zibby","studio");function w(){const t=i.platform(),o=i.arch();if(t==="darwin"&&o==="arm64")return{archive:"Zibby Studio-mac-arm64.zip",label:"macOS (Apple Silicon)"};if(t==="darwin")return{archive:"Zibby Studio-mac-x64.zip",label:"macOS (Intel)"};if(t==="win32"&&o==="arm64")return{archive:"Zibby Studio-win-arm64.zip",label:"Windows (ARM)"};if(t==="win32")return{archive:"Zibby Studio-win-x64.zip",label:"Windows (x64)"};if(t==="linux"&&o==="arm64")return{archive:"Zibby Studio-arm64.AppImage",label:"Linux (ARM64)"};if(t==="linux")return{archive:"Zibby Studio-1.0.0.AppImage",label:"Linux (x64)"};throw new Error(`Unsupported platform: ${t} ${o}`)}function $(){const{archive:t}=w();return`${A}/download/latest/${encodeURIComponent(t)}`}function z(t){const o=v({input:process.stdin,output:process.stdout});return new Promise(e=>{o.question(t,u=>{o.close(),e(u.trim().toLowerCase())})})}async function C(){const{label:t}=w();console.log(""),console.log(l.cyan(" Zibby Studio is not installed.")),console.log(l.gray(` Platform: ${t}`)),console.log("");const o=await z(l.white(" Download and install Zibby Studio? (Y/n): "));return o&&o!=="y"&&o!=="yes"?(console.log(l.yellow(`
|
|
2
2
|
Skipped.
|
|
3
3
|
`)),!1):(await D(),!0)}async function D(){const t=$(),o=decodeURIComponent(a.basename(t));console.log(l.cyan(`
|
|
4
|
-
\u{1F4E6} Downloading Zibby Studio...`));try{const e=await fetch(t);if(!e.ok)throw new Error(`Download failed: ${e.status} ${e.statusText}`);const u=parseInt(e.headers.get("content-length")||"0",10),
|
|
4
|
+
\u{1F4E6} Downloading Zibby Studio...`));try{const e=await fetch(t);if(!e.ok)throw new Error(`Download failed: ${e.status} ${e.statusText}`);const u=parseInt(e.headers.get("content-length")||"0",10),c=a.join(i.tmpdir(),o);let f=0;const p=g(c);for await(const r of e.body)if(f+=r.length,p.write(r),u>0){const s=(f/u*100).toFixed(1),d=(f/1024/1024).toFixed(1),y=(u/1024/1024).toFixed(1);process.stdout.write(`\r \u{1F4E5} ${s}% (${d}MB / ${y}MB)`)}if(await new Promise((r,s)=>{p.on("finish",r),p.on("error",s),p.end()}),console.log(""),m(n)&&I(n,{recursive:!0,force:!0}),x(n,{recursive:!0}),console.log(l.cyan(" \u{1F4C2} Installing...")),c.endsWith(".zip"))if(i.platform()==="darwin"||i.platform()==="linux"){if(b("unzip",["-oq",c,"-d",n]),i.platform()==="darwin")try{b("xattr",["-rd","com.apple.quarantine",n])}catch{}}else{const r=(await import("adm-zip")).default;new r(c).extractAllTo(n,!0)}else if(c.endsWith(".AppImage")){const{copyFileSync:r,chmodSync:s}=await import("fs"),d=a.join(n,o);r(c,d),s(d,493)}try{Z(c)}catch{}return console.log(l.green(` \u2705 Zibby Studio installed!
|
|
5
5
|
`)),!0}catch(e){throw console.log(l.red(`
|
|
6
6
|
\u274C Installation failed: ${e.message}
|
|
7
|
-
`)),e}}function M(){const t=k();return!!(t&&m(t))}function k(){if(i.platform()==="darwin")return a.join(n,"Zibby Studio.app");if(i.platform()==="win32")return a.join(n,"Zibby Studio.exe");if(i.platform()==="linux"){if(!m(n))return null;const t=
|
|
7
|
+
`)),e}}function M(){const t=k();return!!(t&&m(t))}function k(){if(i.platform()==="darwin")return a.join(n,"Zibby Studio.app");if(i.platform()==="win32")return a.join(n,"Zibby Studio.exe");if(i.platform()==="linux"){if(!m(n))return null;const t=h(n).find(o=>o.endsWith(".AppImage"));return t?a.join(n,t):null}return null}function O(){const t=a.join(n,"version.txt");return m(t)?S(t,"utf-8").trim():"unknown"}export{k as getStudioAppPath,O as getStudioVersion,D as installStudio,M as isStudioInstalled,C as promptAndInstallStudio};
|