From 6fa96981ae136c66442820199f3c56a2486316e6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 10 May 2021 13:18:05 +0100 Subject: [PATCH 1/3] Other minor fixes after doing some initial setup testing. --- hosting/scripts/setup.js | 58 +++++++++++++++++++ package.json | 1 + .../components/common/ConfigChecklist.svelte | 12 +--- packages/server/src/api/index.js | 3 + .../server/src/utilities/workerRequests.js | 4 +- 5 files changed, 66 insertions(+), 12 deletions(-) create mode 100755 hosting/scripts/setup.js diff --git a/hosting/scripts/setup.js b/hosting/scripts/setup.js new file mode 100755 index 0000000000..31fc9bec10 --- /dev/null +++ b/hosting/scripts/setup.js @@ -0,0 +1,58 @@ +#!/usr/bin/env node + +const os = require("os") +const exec = require("child_process").exec +const fs = require("fs") +const platform = os.platform() + +const windows = platform === "win32" +const mac = platform === "darwin" +const linux = platform === "linux" + +function execute(command) { + return new Promise(resolve => { + exec(command, (err, stdout) => resolve(linux ? !!stdout : true)) + }) +} + +async function commandExistsUnix (command) { + const unixCmd = `command -v ${command} 2>/dev/null && { echo >&1 ${command}; exit 0; }` + return execute(command) +} + +async function commandExistsWindows (command) { + if (/[\x00-\x1f<>:"|?*]/.test(command)) { + return false + } + return execute(`where ${command}`) +} + +function commandExists (command) { + return windows + ? commandExistsWindows(command) + : commandExistsUnix(command) +} + +async function init() { + const docker = commandExists("docker") + const dockerCompose = commandExists("docker-compose") + if (docker && dockerCompose) { + console.log("Docker installed - continuing.") + return + } + if (mac) { + console.log("Please install docker by visiting: https://docs.docker.com/docker-for-mac/install/") + } else if (windows) { + console.log("Please install docker by visiting: https://docs.docker.com/docker-for-windows/install/") + } else if (linux) { + console.log("Beginning automated linux installation.") + await execute(`./hosting/scripts/linux/get-docker.sh`) + await execute(`./hosting/scripts/linux/get-docker-compose.sh`) + } else { + console.error("Platform unknown - please look online for information about installing docker for our OS.") + } + console.log("Once installation complete please re-run the setup script.") + process.exit(-1) +} +init() + diff --git a/package.json b/package.json index 171f9510f3..ac03b4493e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "svelte": "^3.37.0" }, "scripts": { + "setup": "./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev", "bootstrap": "lerna link && lerna bootstrap", "build": "lerna run build", "initialise": "lerna run initialise", diff --git a/packages/builder/src/components/common/ConfigChecklist.svelte b/packages/builder/src/components/common/ConfigChecklist.svelte index 9652222ba2..b784656d23 100644 --- a/packages/builder/src/components/common/ConfigChecklist.svelte +++ b/packages/builder/src/components/common/ConfigChecklist.svelte @@ -1,22 +1,12 @@