Formatting.

This commit is contained in:
mike12345567 2021-02-26 17:09:20 +00:00
parent 3669e59bc3
commit 9b33bbdb3a
5 changed files with 34 additions and 18 deletions

View File

@ -11,7 +11,7 @@ const BUDIBASE_SERVICES = ["app-service", "worker-service"]
const ERROR_FILE = "docker-error.log" const ERROR_FILE = "docker-error.log"
const FILE_URLS = [ const FILE_URLS = [
"https://raw.githubusercontent.com/Budibase/budibase/master/hosting/docker-compose.yaml", "https://raw.githubusercontent.com/Budibase/budibase/master/hosting/docker-compose.yaml",
"https://raw.githubusercontent.com/Budibase/budibase/master/hosting/envoy.yaml" "https://raw.githubusercontent.com/Budibase/budibase/master/hosting/envoy.yaml",
] ]
async function downloadFiles() { async function downloadFiles() {
@ -24,7 +24,8 @@ async function downloadFiles() {
} }
async function checkDockerConfigured() { async function checkDockerConfigured() {
const error = "docker/docker-compose has not been installed, please follow instructions at: https://docs.budibase.com/self-hosting/hosting-methods/docker-compose#installing-docker" const error =
"docker/docker-compose has not been installed, please follow instructions at: https://docs.budibase.com/self-hosting/hosting-methods/docker-compose#installing-docker"
const docker = await lookpath("docker") const docker = await lookpath("docker")
const compose = await lookpath("docker-compose") const compose = await lookpath("docker-compose")
if (!docker || !compose) { if (!docker || !compose) {
@ -51,7 +52,9 @@ async function handleError(func) {
async function init() { async function init() {
await checkDockerConfigured() await checkDockerConfigured()
const shouldContinue = await confirmation("This will create multiple files in current directory, should continue?") const shouldContinue = await confirmation(
"This will create multiple files in current directory, should continue?"
)
if (!shouldContinue) { if (!shouldContinue) {
console.log("Stopping.") console.log("Stopping.")
return return
@ -66,9 +69,13 @@ async function start() {
console.log(info("Starting services, this may take a moment.")) console.log(info("Starting services, this may take a moment."))
const port = envFile.get("MAIN_PORT") const port = envFile.get("MAIN_PORT")
await handleError(async () => { await handleError(async () => {
await compose.upAll({cwd: "./", log: false}) await compose.upAll({ cwd: "./", log: false })
}) })
console.log(success(`Services started, please go to http://localhost:${port} for next steps.`)) console.log(
success(
`Services started, please go to http://localhost:${port} for next steps.`
)
)
} }
async function status() { async function status() {
@ -94,7 +101,11 @@ async function stop() {
async function update() { async function update() {
await checkDockerConfigured() await checkDockerConfigured()
checkInitComplete() checkInitComplete()
if (await confirmation("Do you wish to update you docker-compose.yaml and envoy.yaml?")) { if (
await confirmation(
"Do you wish to update you docker-compose.yaml and envoy.yaml?"
)
) {
await downloadFiles() await downloadFiles()
} }
await handleError(async () => { await handleError(async () => {
@ -106,7 +117,7 @@ async function update() {
await compose.stop() await compose.stop()
} }
console.log(info("Beginning update, this may take a few minutes.")) console.log(info("Beginning update, this may take a few minutes."))
await compose.pullMany(BUDIBASE_SERVICES, {log: true}) await compose.pullMany(BUDIBASE_SERVICES, { log: true })
if (isUp) { if (isUp) {
console.log(success("Update complete, restarting services...")) console.log(success("Update complete, restarting services..."))
await start() await start()

View File

@ -32,11 +32,20 @@ BUDIBASE_ENVIRONMENT=PRODUCTION`
module.exports.filePath = FILE_PATH module.exports.filePath = FILE_PATH
module.exports.make = async () => { module.exports.make = async () => {
const hostingKey = await string("Please input the password you'd like to use as your hosting key: ") const hostingKey = await string(
const hostingPort = await number("Please enter the port on which you want your installation to run: ", 10000) "Please input the password you'd like to use as your hosting key: "
)
const hostingPort = await number(
"Please enter the port on which you want your installation to run: ",
10000
)
const fileContents = getContents(hostingPort, hostingKey) const fileContents = getContents(hostingPort, hostingKey)
fs.writeFileSync(FILE_PATH, fileContents) fs.writeFileSync(FILE_PATH, fileContents)
console.log(success("Configuration has been written successfully - please check .env file for more details.")) console.log(
success(
"Configuration has been written successfully - please check .env file for more details."
)
)
} }
module.exports.get = property => { module.exports.get = property => {

View File

@ -27,7 +27,7 @@ exports.number = async (question, defaultNumber) => {
type: "input", type: "input",
name: "number", name: "number",
message: question, message: question,
validate: (value) => { validate: value => {
let valid = !isNaN(parseFloat(value)) let valid = !isNaN(parseFloat(value))
return valid || "Please enter a number" return valid || "Please enter a number"
}, },

View File

@ -1,8 +1,4 @@
const { const { getSubHelpDescription, getHelpDescription, error } = require("../utils")
getSubHelpDescription,
getHelpDescription,
error,
} = require("../utils")
class Command { class Command {
constructor(command, func = null) { constructor(command, func = null) {

View File

@ -10,7 +10,7 @@ exports.downloadFile = async (url, filePath) => {
const response = await axios({ const response = await axios({
url, url,
method: "GET", method: "GET",
responseType: "stream" responseType: "stream",
}) })
response.data.pipe(writer) response.data.pipe(writer)