@joystick.js/cli-canary 0.0.0-canary.1655 → 0.0.0-canary.1656
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 g,execSync as $}from"child_process";import l from"path";import{fileURLToPath as b}from"url";import n from"fs";import p from"os";import D from"tar";import x 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=b(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 $(`"${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(),s=p.arch();let t,c;if(r==="linux")t=`https://download.docker.com/linux/static/stable/${s}/docker-24.0.7.tgz`,c="docker.tgz";else if(r==="darwin")t=`https://download.docker.com/mac/static/stable/${s}/docker-24.0.7.tgz`,c="docker.tgz";else if(r==="win32")t="https://download.docker.com/win/static/stable/x86_64/docker-24.0.7.zip",c="docker.zip";else throw new Error("Unsupported operating system");n.mkdirSync(a,{recursive:!0});const o=l.join(a,c);try{process.loader.print(`Downloading Docker binary from ${t}`);const e=await P(t);if(!e.ok)throw new Error(`Unexpected response ${e.statusText}`);await j(e.body,n.createWriteStream(o)),process.loader.print("Download completed"),r==="win32"?(process.loader.print("Extracting ZIP file"),new x(o).extractAllTo(a,!0)):(process.loader.print("Extracting TAR file"),await D.x({file:o,cwd:a,strip:1})),n.unlinkSync(o),r!=="win32"&&n.chmodSync(f(),"755"),process.loader.print(`Docker binaries downloaded and extracted to ${a}`)}catch(e){throw process.loader.print(`Error: ${e.message}`),n.existsSync(o)&&(process.loader.print("Cleaning up partial download"),n.unlinkSync(o)),new Error(`Failed to download or extract Docker binary: ${e.message}`)}},U=(r="",s="",{apt_deps:t=[],snap_deps:c=[],npm_deps:o=[]}={})=>new Promise(async(e,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(i){d(new Error(`Failed to download Docker binary: ${i.message}`));return}}process.loader.print("Building Docker image for deployment...");const w=f(),m=l.join(u,"Dockerfile");if(!n.existsSync(m)){d(new Error(`Dockerfile not found at ${m}`));return}const h=[`CUSTOM_APT_DEPS=${t.join(" ")}`,`CUSTOM_SNAP_DEPS=${c.join(" ")}`,`GLOBAL_NPM_PACKAGES=${o.join(" ")}`].map(i=>`--build-arg ${i}`).join(" "),_=`"${w}" build ${h} -t ${r} -f "${m}" "${s||u}"`;g(_,(i,y,k)=>{if(i){console.error(`Error building Docker image: ${i.message}`),d(i);return}k&&console.error(`Docker build stderr: ${k}`),process.loader.print(y),process.loader.print(`Successfully built Docker image: ${r}`),e()})});var W=U;export{W as default};
|
|
@@ -5,4 +5,4 @@ ${n+1===r?.errors?.length?"":`
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
`:""}${e}`,{level:"danger",docs:{push_config:"https://cheatcode.co/docs/push/config",deployment:"https://cheatcode.co/docs/push/subscription"}[o]}),process.exit(0)},u=async()=>{const o=await l();return o||(c(data?.error?.message,{level:"danger",docs:"https://cheatcode.co/docs/push/cli#authentication"}),process.exit(0))},T=(o="")=>(c(`settings.${o}.json must contain a push config object. Add this following the docs link below and try again.`,{level:"danger",docs:"https://cheatcode.co/docs/push/config"}),process.exit(0)),g=async(o={},t={})=>{process.loader=new _,process.loader.print("Starting deployment...");const r=await u(),e=t?.environment||"production",s=(await a({environment:e}))?.config?.push||{},h=d(t?.push_server),i={domain:"example.com",status:"undeployed",deployment_secret:"abc123"};if(!0){i?.status==="undeployed"&&console.log(`
|
|
8
|
-
`);const w=new Date().toISOString();await p({type:"directory",environment:e,encrypt_build:!0,encryption_key:i?.deployment_secret,silence_confirmation:!0}),await f(i?.domain
|
|
8
|
+
`);const w=new Date().toISOString();await p({type:"directory",environment:e,encrypt_build:!0,encryption_key:i?.deployment_secret,silence_confirmation:!0}),await f(`${i?.domain}:latest`,process.cwd())}};var U=g;export{U 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.1656",
|
|
5
|
+
"canary_version": "0.0.0-canary.1655",
|
|
6
6
|
"description": "The CLI for Joystick.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"bin": {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { exec, execSync } from 'child_process';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
import https from 'https';
|
|
5
4
|
import fs from 'fs';
|
|
6
5
|
import os from 'os';
|
|
7
6
|
import tar from 'tar';
|
|
8
7
|
import AdmZip from 'adm-zip';
|
|
8
|
+
import { promisify } from 'util';
|
|
9
|
+
import { pipeline } from 'stream';
|
|
10
|
+
import fetch from 'node-fetch';
|
|
11
|
+
|
|
12
|
+
const streamPipeline = promisify(pipeline);
|
|
9
13
|
|
|
10
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
15
|
const __dirname = path.dirname(__filename);
|
|
@@ -27,20 +31,6 @@ const check_docker_installation = () => {
|
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
const download_file = (url, dest) => {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
const file = fs.createWriteStream(dest);
|
|
33
|
-
https.get(url, (response) => {
|
|
34
|
-
response.pipe(file);
|
|
35
|
-
file.on('finish', () => {
|
|
36
|
-
file.close(resolve);
|
|
37
|
-
});
|
|
38
|
-
}).on('error', (error) => {
|
|
39
|
-
fs.unlink(dest, () => reject(error));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
34
|
const get_docker_binary = async () => {
|
|
45
35
|
const platform = os.platform();
|
|
46
36
|
const arch = os.arch();
|
|
@@ -62,27 +52,43 @@ const get_docker_binary = async () => {
|
|
|
62
52
|
|
|
63
53
|
fs.mkdirSync(joystick_docker_path, { recursive: true });
|
|
64
54
|
const archive_path = path.join(joystick_docker_path, archive_name);
|
|
65
|
-
await download_file(url, archive_path);
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
await
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
try {
|
|
57
|
+
process.loader.print(`Downloading Docker binary from ${url}`);
|
|
58
|
+
const response = await fetch(url);
|
|
59
|
+
if (!response.ok) throw new Error(`Unexpected response ${response.statusText}`);
|
|
60
|
+
await streamPipeline(response.body, fs.createWriteStream(archive_path));
|
|
61
|
+
process.loader.print('Download completed');
|
|
62
|
+
|
|
63
|
+
if (platform === 'win32') {
|
|
64
|
+
process.loader.print('Extracting ZIP file');
|
|
65
|
+
const zip = new AdmZip(archive_path);
|
|
66
|
+
zip.extractAllTo(joystick_docker_path, true);
|
|
67
|
+
} else {
|
|
68
|
+
process.loader.print('Extracting TAR file');
|
|
69
|
+
await tar.x({
|
|
70
|
+
file: archive_path,
|
|
71
|
+
cwd: joystick_docker_path,
|
|
72
|
+
strip: 1
|
|
73
|
+
});
|
|
74
|
+
}
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
fs.unlinkSync(archive_path);
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
// Make the docker binary executable on Unix-like systems
|
|
79
|
+
if (platform !== 'win32') {
|
|
80
|
+
fs.chmodSync(get_docker_binary_path(), '755');
|
|
81
|
+
}
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
process.loader.print(`Docker binaries downloaded and extracted to ${joystick_docker_path}`);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
process.loader.print(`Error: ${error.message}`);
|
|
86
|
+
if (fs.existsSync(archive_path)) {
|
|
87
|
+
process.loader.print('Cleaning up partial download');
|
|
88
|
+
fs.unlinkSync(archive_path);
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`Failed to download or extract Docker binary: ${error.message}`);
|
|
91
|
+
}
|
|
86
92
|
};
|
|
87
93
|
|
|
88
94
|
const build_docker_image = (
|