@joystick.js/cli-canary 0.0.0-canary.1656 → 0.0.0-canary.1657
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{exec as
|
|
1
|
+
import{exec as y,execSync as x}from"child_process";import l from"path";import{fileURLToPath as $}from"url";import c from"fs";import p from"os";import b from"tar";import D from"adm-zip";import{promisify as S}from"util";import{pipeline as E}from"stream";import P from"node-fetch";const j=S(E),z=$(import.meta.url),u=l.dirname(z),a=l.join(p.homedir(),".joystick","docker"),f=()=>l.join(a,p.platform()==="win32"?"docker.exe":"docker"),A=()=>{const r=f();try{return x(`"${r}" --version`,{stdio:"ignore"}),!0}catch{return console.warn("Warning: Docker is not installed or the binary is not accessible."),!1}},T=async()=>{const r=p.platform(),t=p.arch();let i,s;if(r==="linux"&&t==="x64")i="https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz",s="docker-latest.tgz";else if(r==="darwin"&&t==="x64")i="https://get.docker.com/builds/Darwin/x86_64/docker-latest.tgz",s="docker-latest.tgz";else if(r==="win32"&&t==="x64")i="https://get.docker.com/builds/Windows/x86_64/docker-latest.zip",s="docker-latest.zip";else throw new Error(`Unsupported platform or architecture: ${r} ${t}`);c.mkdirSync(a,{recursive:!0});const e=l.join(a,s);try{process.loader.print(`Downloading Docker binary from ${i}`);const o=await P(i);if(!o.ok)throw new Error(`Unexpected response ${o.statusText}`);await j(o.body,c.createWriteStream(e)),process.loader.print("Download completed"),r==="win32"?(process.loader.print("Extracting ZIP file"),new D(e).extractAllTo(a,!0)):(process.loader.print("Extracting TAR file"),await b.x({file:e,cwd:a,strip:1})),c.unlinkSync(e),r!=="win32"&&c.chmodSync(f(),"755"),process.loader.print(`Docker binaries downloaded and extracted to ${a}`)}catch(o){throw process.loader.print(`Error: ${o.message}`),c.existsSync(e)&&(process.loader.print("Cleaning up partial download"),c.unlinkSync(e)),new Error(`Failed to download or extract Docker binary: ${o.message}`)}},U=(r="",t="",{apt_deps:i=[],snap_deps:s=[],npm_deps:e=[]}={})=>new Promise(async(o,d)=>{if(!A()){process.loader.print("Push requires Docker to be installed on your machine. Downloading...");try{await T(),process.loader.print("Docker installed!")}catch(n){d(new Error(`Failed to download Docker binary: ${n.message}`));return}}process.loader.print("Building Docker image for deployment...");const w=f(),m=l.join(u,"Dockerfile");if(!c.existsSync(m)){d(new Error(`Dockerfile not found at ${m}`));return}const h=[`CUSTOM_APT_DEPS=${i.join(" ")}`,`CUSTOM_SNAP_DEPS=${s.join(" ")}`,`GLOBAL_NPM_PACKAGES=${e.join(" ")}`].map(n=>`--build-arg ${n}`).join(" "),_=`"${w}" build ${h} -t ${r} -f "${m}" "${t||u}"`;y(_,(n,g,k)=>{if(n){console.error(`Error building Docker image: ${n.message}`),d(n);return}k&&console.error(`Docker build stderr: ${k}`),process.loader.print(g),process.loader.print(`Successfully built Docker image: ${r}`),o()})});var R=U;export{R as default};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joystick.js/cli-canary",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-canary.
|
|
5
|
-
"canary_version": "0.0.0-canary.
|
|
4
|
+
"version": "0.0.0-canary.1657",
|
|
5
|
+
"canary_version": "0.0.0-canary.1656",
|
|
6
6
|
"description": "The CLI for Joystick.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"bin": {
|
|
@@ -37,17 +37,17 @@ const get_docker_binary = async () => {
|
|
|
37
37
|
let url;
|
|
38
38
|
let archive_name;
|
|
39
39
|
|
|
40
|
-
if (platform === 'linux') {
|
|
41
|
-
url =
|
|
42
|
-
archive_name = 'docker.tgz';
|
|
43
|
-
} else if (platform === 'darwin') {
|
|
44
|
-
url =
|
|
45
|
-
archive_name = 'docker.tgz';
|
|
46
|
-
} else if (platform === 'win32') {
|
|
47
|
-
url = 'https://
|
|
48
|
-
archive_name = 'docker.zip';
|
|
40
|
+
if (platform === 'linux' && arch === 'x64') {
|
|
41
|
+
url = 'https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz';
|
|
42
|
+
archive_name = 'docker-latest.tgz';
|
|
43
|
+
} else if (platform === 'darwin' && arch === 'x64') {
|
|
44
|
+
url = 'https://get.docker.com/builds/Darwin/x86_64/docker-latest.tgz';
|
|
45
|
+
archive_name = 'docker-latest.tgz';
|
|
46
|
+
} else if (platform === 'win32' && arch === 'x64') {
|
|
47
|
+
url = 'https://get.docker.com/builds/Windows/x86_64/docker-latest.zip';
|
|
48
|
+
archive_name = 'docker-latest.zip';
|
|
49
49
|
} else {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error(`Unsupported platform or architecture: ${platform} ${arch}`);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
fs.mkdirSync(joystick_docker_path, { recursive: true });
|