From d0a55087bf4977e37afd66a0ded07960c9c6f2f8 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Sat, 28 Oct 2023 17:46:16 +0700 Subject: [PATCH] Support tar upload --- package.json | 2 +- src/executor/runner.js | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 19716d3..a8986cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "domcloud-bridge", - "version": "0.30.0", + "version": "0.31.0", "description": "Deployment runner for DOM Cloud", "main": "app.js", "engines": { diff --git a/src/executor/runner.js b/src/executor/runner.js index 34faafd..ea3d13d 100644 --- a/src/executor/runner.js +++ b/src/executor/runner.js @@ -708,8 +708,10 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, return; } } - await sshExec(`export DOMAIN='${subdomain}'`, false); - await sshExec(`mkdir -p ${subdomaindata['Home directory']}/public_html && cd "$_"`); + if (config.source || config.commands) { + await sshExec(`export DOMAIN='${subdomain}'`, false); + await sshExec(`mkdir -p ${subdomaindata['Home directory']}/public_html && cd "$_"`); + } if (config.source) { if (typeof config.source === 'string') { config.source = { @@ -728,7 +730,7 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, if (source.url !== 'clear') { url = new URL(source.url); if (!source.type || !['clone', 'extract'].includes(source.type)) { - if (url.protocol == 'ssh' || url.pathname.endsWith('.git') || (url.hostname.match(/^(www\.)?(github|gitlab)\.com$/) && !url.pathname.endsWith('.zip'))) { + if (url.protocol == 'ssh' || url.pathname.endsWith('.git') || (url.hostname.match(/^(www\.)?(github|gitlab)\.com$/) && !url.pathname.endsWith('.zip') && !url.pathname.endsWith('.tar.gz'))) { source.type = 'clone'; } else { source.type = 'extract'; @@ -766,8 +768,13 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, source.directory = decodeURI(url.hash.substring(1)); url.hash = ''; } - executedCMD.push(`wget -O _.zip ` + escapeShell(url.toString())); - executedCMD.push(`unzip -q -o _.zip ; rm _.zip ; chmod -R 0750 *`); + if (url.pathname.endsWith('.tar.gz')) { + executedCMD.push(`wget -O _.tar.gz ` + escapeShell(url.toString())); + executedCMD.push(`tar –xvzf _.tar.gz ; rm _.tar.gz ; chmod -R 0750 *`); + } else { + executedCMD.push(`wget -O _.zip ` + escapeShell(url.toString())); + executedCMD.push(`unzip -q -o _.zip ; rm _.zip ; chmod -R 0750 *`); + } if (source.directory) { executedCMD.push(`mv ${escapeShell(source.directory)}/* .`); executedCMD.push(`rm -rf ${escapeShell(source.directory)}`);