From 5bbbc7f41c22447cd44c4d8bac1c8ee3f8358b40 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Mon, 9 May 2022 16:13:47 -0500 Subject: [PATCH] Add downloadStorkToml helper and script --- helpers/api/static.js | 28 ++++++++++++++++++++++++++++ scripts/download-stork-toml.js | 9 +++++++++ 2 files changed, 37 insertions(+) create mode 100644 helpers/api/static.js create mode 100644 scripts/download-stork-toml.js diff --git a/helpers/api/static.js b/helpers/api/static.js new file mode 100644 index 0000000..2809a6e --- /dev/null +++ b/helpers/api/static.js @@ -0,0 +1,28 @@ +import axios from 'axios' +import 'dotenv/config' + +import { + storkVersion, + storkExecutableName, + storkExecutablePath, + storkTomlPath, +} from '~/helpers/stork/config.js' + +export async function downloadStorkToml () { + const apiUrl = new URL( process.env.PUBLIC_API_DOMAIN ) + + apiUrl.pathname = storkTomlPath.replace('/static', '') + + console.log('apiUrl', apiUrl) + + // await axios( apiUrl.toString() ) + + + axios({ + method: "get", + url: apiUrl.toString(), + responseType: "stream" + }).then(function (response) { + response.data.pipe(fs.createWriteStream( storkTomlPath )) + }) +} diff --git a/scripts/download-stork-toml.js b/scripts/download-stork-toml.js new file mode 100644 index 0000000..6ca1321 --- /dev/null +++ b/scripts/download-stork-toml.js @@ -0,0 +1,9 @@ +import { + downloadStorkToml +} from '~/helpers/api/static.js' + +;(async () => { + await downloadStorkToml() + + process.exit() +})()