From 87918fd55cf966d8031387a32449f352f9361676 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 18 Mar 2021 18:26:41 +0000 Subject: [PATCH 01/13] Updating the CLI to have a fast init method, this will make using it for DO much much easier. --- packages/cli/src/constants.js | 4 ++++ packages/cli/src/hosting/index.js | 26 +++++++++++++++----------- packages/cli/src/hosting/makeEnv.js | 24 ++++++++++++++++-------- packages/cli/src/structures/Command.js | 13 +++++-------- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/packages/cli/src/constants.js b/packages/cli/src/constants.js index a601909232..40c63d218d 100644 --- a/packages/cli/src/constants.js +++ b/packages/cli/src/constants.js @@ -2,3 +2,7 @@ exports.CommandWords = { HOSTING: "hosting", HELP: "help", } + +exports.InitTypes = { + QUICK: "quick", +} diff --git a/packages/cli/src/hosting/index.js b/packages/cli/src/hosting/index.js index a8e77f49d7..f5c2552c64 100644 --- a/packages/cli/src/hosting/index.js +++ b/packages/cli/src/hosting/index.js @@ -1,5 +1,5 @@ const Command = require("../structures/Command") -const { CommandWords } = require("../constants") +const { CommandWords, InitTypes } = require("../constants") const { lookpath } = require("lookpath") const { downloadFile, logErrorToFile, success, info } = require("../utils") const { confirmation } = require("../questions") @@ -50,17 +50,21 @@ async function handleError(func) { } } -async function init() { +async function init(info) { + const isQuick = info === InitTypes.QUICK await checkDockerConfigured() - const shouldContinue = await confirmation( - "This will create multiple files in current directory, should continue?" - ) - if (!shouldContinue) { - console.log("Stopping.") - return + if (!isQuick) { + const shouldContinue = await confirmation( + "This will create multiple files in current directory, should continue?" + ) + if (!shouldContinue) { + console.log("Stopping.") + return + } } await downloadFiles() - await envFile.make() + const config = isQuick ? envFile.QUICK_CONFIG : {} + await envFile.make(config) } async function start() { @@ -128,8 +132,8 @@ async function update() { const command = new Command(`${CommandWords.HOSTING}`) .addHelp("Controls self hosting on the Budibase platform.") .addSubOption( - "--init", - "Configure a self hosted platform in current directory.", + "--init [type]", + "Configure a self hosted platform in current directory, type can be unspecified or 'quick'.", init ) .addSubOption( diff --git a/packages/cli/src/hosting/makeEnv.js b/packages/cli/src/hosting/makeEnv.js index b7d3b9e849..b84e50eb6b 100644 --- a/packages/cli/src/hosting/makeEnv.js +++ b/packages/cli/src/hosting/makeEnv.js @@ -30,15 +30,23 @@ BUDIBASE_ENVIRONMENT=PRODUCTION` } module.exports.filePath = FILE_PATH +module.exports.QUICK_CONFIG = { + key: "budibase", + port: 10000, +} -module.exports.make = async () => { - const hostingKey = await string( - "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 - ) +module.exports.make = async (inputs = {}) => { + const hostingKey = + inputs.key || + (await string( + "Please input the password you'd like to use as your hosting key: " + )) + const hostingPort = + inputs.port || + (await number( + "Please enter the port on which you want your installation to run: ", + 10000 + )) const fileContents = getContents(hostingPort, hostingKey) fs.writeFileSync(FILE_PATH, fileContents) console.log( diff --git a/packages/cli/src/structures/Command.js b/packages/cli/src/structures/Command.js index 5ca0ce67ee..a8d24566be 100644 --- a/packages/cli/src/structures/Command.js +++ b/packages/cli/src/structures/Command.js @@ -13,8 +13,8 @@ class Command { return this } - addSubOption(command, help, func) { - this.opts.push({ command, help, func }) + addSubOption(command, help, func, extras = []) { + this.opts.push({ command, help, func, extras }) return this } @@ -37,13 +37,10 @@ class Command { command.action(async options => { try { let executed = false - if (thisCmd.func) { - await thisCmd.func(options) - executed = true - } for (let opt of thisCmd.opts) { - if (options[opt.command.replace("--", "")]) { - await opt.func(options) + const lookup = opt.command.split(" ")[0].replace("--", "") + if (options[lookup]) { + await opt.func(options[lookup]) executed = true } } From 60ab217386e4ef2ec97cad7c692eb4bd4d645631 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 18 Mar 2021 18:27:00 +0000 Subject: [PATCH 02/13] Formatting. --- .../EditAutomationPopover.svelte | 4 +- .../popovers/EditDatasourcePopover.svelte | 2 +- .../deploy/DeploymentHistory.svelte | 6 ++- .../automate/[automation]/index.svelte | 3 +- .../pages/[application]/automate/index.svelte | 23 ++++++----- .../pages/[application]/data/_layout.svelte | 9 ++-- .../[query]/_layout.svelte | 4 +- .../data/datasource/index.svelte | 41 ++++++++++--------- .../[application]/data/table/index.svelte | 3 +- 9 files changed, 50 insertions(+), 45 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte b/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte index a99a16e240..81c38e553b 100644 --- a/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/EditAutomationPopover.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte b/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte index c7842001d0..4cac41d63d 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte @@ -24,7 +24,7 @@ async function deleteDatasource() { await backendUiStore.actions.datasources.delete(datasource) notifier.success("Datasource deleted") - $goto('./datasource') + $goto("./datasource") hideEditor() } diff --git a/packages/builder/src/components/deploy/DeploymentHistory.svelte b/packages/builder/src/components/deploy/DeploymentHistory.svelte index c49abd433e..0933b1a676 100644 --- a/packages/builder/src/components/deploy/DeploymentHistory.svelte +++ b/packages/builder/src/components/deploy/DeploymentHistory.svelte @@ -119,11 +119,13 @@ {#if deployment.status.toLowerCase() === 'pending'} {/if} -
showErrorReasonModal(deployment.err)} class={`deployment-status ${deployment.status}`}> +
showErrorReasonModal(deployment.err)} + class={`deployment-status ${deployment.status}`}> {deployment.status} {#if deployment.status === DeploymentStatus.FAILURE} - + {/if}
diff --git a/packages/builder/src/pages/[application]/automate/[automation]/index.svelte b/packages/builder/src/pages/[application]/automate/[automation]/index.svelte index 031a72fad3..1a15ed48c6 100644 --- a/packages/builder/src/pages/[application]/automate/[automation]/index.svelte +++ b/packages/builder/src/pages/[application]/automate/[automation]/index.svelte @@ -1,6 +1,5 @@ - + - \ No newline at end of file diff --git a/packages/builder/src/pages/[application]/automate/index.svelte b/packages/builder/src/pages/[application]/automate/index.svelte index 98e5b80a18..f6568417a8 100644 --- a/packages/builder/src/pages/[application]/automate/index.svelte +++ b/packages/builder/src/pages/[application]/automate/index.svelte @@ -1,18 +1,19 @@ Create your first automation to get started @@ -23,4 +24,4 @@ color: var(--grey-5); margin-top: 2px; } - \ No newline at end of file + diff --git a/packages/builder/src/pages/[application]/data/_layout.svelte b/packages/builder/src/pages/[application]/data/_layout.svelte index 0674c93c88..5a31d7db92 100644 --- a/packages/builder/src/pages/[application]/data/_layout.svelte +++ b/packages/builder/src/pages/[application]/data/_layout.svelte @@ -17,11 +17,11 @@ }, ] - let tab = $isActive('./datasource') ? "datasource" : "table" + let tab = $isActive("./datasource") ? "datasource" : "table" function selectFirstTableOrSource({ detail }) { const type = detail.heading.key - if (type === 'datasource') { + if (type === "datasource") { $goto("./datasource") } else { $goto("./table") @@ -34,7 +34,10 @@