From 0d8e60c62dc724e5b83d755b01f5d0f6c4f7e46d Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Sun, 24 Oct 2021 17:26:47 +0000 Subject: [PATCH] Download based on manifest.json --- index.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index f2be226..d3f29f6 100644 --- a/index.js +++ b/index.js @@ -59,11 +59,22 @@ async function dep() { console.log(`Downloading "https://deployer.org/deployer.phar".`) execa.commandSync('curl -LO https://deployer.org/deployer.phar') } else { - if (!/^v/.test(version)) { - version = 'v' + version + version = version.replace(/^v/, '') + let {stdout} = execa.commandSync(`curl -L https://deployer.org/manifest.json`) + let manifest = JSON.parse(stdout) + let url + for (let asset of manifest) { + if (asset.version === version) { + url = asset.url + break + } + } + if (url === null) { + console.error(`The version "${version}"" does not found in the "https://deployer.org/manifest.json" file."`) + } else { + console.log(`Downloading "${url}".`) + execa.commandSync(`curl -LO ${url}`) } - console.log(`Downloading "https://deployer.org/releases/${version}/deployer.phar".`) - execa.commandSync(`curl -LO https://deployer.org/releases/${version}/deployer.phar`) } execa.commandSync('sudo chmod +x deployer.phar') dep = 'deployer.phar'