m._id === $params.query
- )
+ const query = $backendUiStore.queries.find(m => m._id === $params.query)
if (query) {
backendUiStore.actions.queries.select(query)
}
diff --git a/packages/builder/src/pages/[application]/data/datasource/index.svelte b/packages/builder/src/pages/[application]/data/datasource/index.svelte
index b1c7708465..00b08fb7b7 100644
--- a/packages/builder/src/pages/[application]/data/datasource/index.svelte
+++ b/packages/builder/src/pages/[application]/data/datasource/index.svelte
@@ -1,22 +1,23 @@
-
- {#if $backendUiStore.tables.length === 0}
- Connect your first datasource to start building.
- {:else}Select a datasource to edit{/if}
-
-
\ No newline at end of file
+ onMount(async () => {
+ // navigate to first table in list, if not already selected
+ $backendUiStore.datasources.length > 0 &&
+ $goto(`../${$backendUiStore.datasources[0]._id}`)
+ })
+
+
+{#if $backendUiStore.tables.length === 0}
+ Connect your first datasource to start building.
+{:else}Select a datasource to edit{/if}
+
+
diff --git a/packages/builder/src/pages/[application]/data/table/index.svelte b/packages/builder/src/pages/[application]/data/table/index.svelte
index d1659257d4..134d9e510f 100644
--- a/packages/builder/src/pages/[application]/data/table/index.svelte
+++ b/packages/builder/src/pages/[application]/data/table/index.svelte
@@ -4,7 +4,8 @@
import { onMount } from "svelte"
onMount(async () => {
- $backendUiStore.tables.length > 0 && $goto(`../${$backendUiStore.tables[0]._id}`)
+ $backendUiStore.tables.length > 0 &&
+ $goto(`../${$backendUiStore.tables[0]._id}`)
})
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 5c58c80560..f369111372 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,9 +1,11 @@
{
- "name": "cli",
- "version": "0.8.7",
+ "name": "@budibase/cli",
+ "version": "0.8.10",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
- "bin": "src/index.js",
+ "bin": {
+ "budi": "src/index.js"
+ },
"author": "Budibase",
"license": "AGPL-3.0-or-later",
"scripts": {
diff --git a/packages/cli/src/constants.js b/packages/cli/src/constants.js
index a601909232..c8da56fa5c 100644
--- a/packages/cli/src/constants.js
+++ b/packages/cli/src/constants.js
@@ -2,3 +2,8 @@ exports.CommandWords = {
HOSTING: "hosting",
HELP: "help",
}
+
+exports.InitTypes = {
+ QUICK: "quick",
+ DIGITAL_OCEAN: "do",
+}
diff --git a/packages/cli/src/hosting/index.js b/packages/cli/src/hosting/index.js
index a8e77f49d7..710397f301 100644
--- a/packages/cli/src/hosting/index.js
+++ b/packages/cli/src/hosting/index.js
@@ -1,11 +1,18 @@
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 {
+ downloadFile,
+ logErrorToFile,
+ success,
+ info,
+ parseEnv,
+} = require("../utils")
const { confirmation } = require("../questions")
const fs = require("fs")
const compose = require("docker-compose")
-const envFile = require("./makeEnv")
+const makeEnv = require("./makeEnv")
+const axios = require("axios")
const BUDIBASE_SERVICES = ["app-service", "worker-service"]
const ERROR_FILE = "docker-error.log"
@@ -13,6 +20,7 @@ const FILE_URLS = [
"https://raw.githubusercontent.com/Budibase/budibase/master/hosting/docker-compose.yaml",
"https://raw.githubusercontent.com/Budibase/budibase/master/hosting/envoy.yaml",
]
+const DO_USER_DATA_URL = "http://169.254.169.254/metadata/v1/user-data"
async function downloadFiles() {
const promises = []
@@ -34,7 +42,7 @@ async function checkDockerConfigured() {
}
function checkInitComplete() {
- if (!fs.existsSync(envFile.filePath)) {
+ if (!fs.existsSync(makeEnv.filePath)) {
throw "Please run the hosting --init command before any other hosting command."
}
}
@@ -50,24 +58,41 @@ async function handleError(func) {
}
}
-async function init() {
+async function init(type) {
+ const isQuick = type === InitTypes.QUICK || type === InitTypes.DIGITAL_OCEAN
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 ? makeEnv.QUICK_CONFIG : {}
+ if (type === InitTypes.DIGITAL_OCEAN) {
+ try {
+ const output = await axios.get(DO_USER_DATA_URL)
+ const response = parseEnv(output.data)
+ for (let [key, value] of Object.entries(makeEnv.ConfigMap)) {
+ if (response[key]) {
+ config[value] = response[key]
+ }
+ }
+ } catch (err) {
+ // don't need to handle error, just don't do anything
+ }
+ }
+ await makeEnv.make(config)
}
async function start() {
await checkDockerConfigured()
checkInitComplete()
console.log(info("Starting services, this may take a moment."))
- const port = envFile.get("MAIN_PORT")
+ const port = makeEnv.get("MAIN_PORT")
await handleError(async () => {
await compose.upAll({ cwd: "./", log: false })
})
@@ -128,8 +153,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..318a72def1 100644
--- a/packages/cli/src/hosting/makeEnv.js
+++ b/packages/cli/src/hosting/makeEnv.js
@@ -26,19 +26,32 @@ APP_PORT=4002
WORKER_PORT=4003
MINIO_PORT=4004
COUCH_DB_PORT=4005
+REDIS_PORT=6379
BUDIBASE_ENVIRONMENT=PRODUCTION`
}
module.exports.filePath = FILE_PATH
+module.exports.ConfigMap = {
+ HOSTING_KEY: "key",
+ MAIN_PORT: "port",
+}
+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/index.js b/packages/cli/src/index.js
index 526f259fc4..6693446b39 100644
--- a/packages/cli/src/index.js
+++ b/packages/cli/src/index.js
@@ -1,3 +1,4 @@
+#!/usr/bin/env node
const { getCommands } = require("./options")
const { Command } = require("commander")
const { getHelpDescription } = require("./utils")
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
}
}
diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js
index 1605c277c0..05bb8d4991 100644
--- a/packages/cli/src/utils.js
+++ b/packages/cli/src/utils.js
@@ -44,3 +44,15 @@ exports.info = info => {
exports.logErrorToFile = (file, error) => {
fs.writeFileSync(path.resolve(`./${file}`), `Budiase Error\n${error}`)
}
+
+exports.parseEnv = env => {
+ const lines = env.toString().split("\n")
+ let result = {}
+ for (const line of lines) {
+ const match = line.match(/^([^=:#]+?)[=:](.*)/)
+ if (match) {
+ result[match[1].trim()] = match[2].trim()
+ }
+ }
+ return result
+}
diff --git a/packages/cli/yarn.lock b/packages/cli/yarn.lock
index c03030576c..298fb78061 100644
--- a/packages/cli/yarn.lock
+++ b/packages/cli/yarn.lock
@@ -15,30 +15,30 @@
integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==
"@babel/highlight@^7.10.4":
- version "7.12.13"
- resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.12.13.tgz#8ab538393e00370b26271b01fa08f7f27f2e795c"
- integrity sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww==
+ version "7.13.10"
+ resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.13.10.tgz#a8b2a66148f5b27d666b15d81774347a731d52d1"
+ integrity sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg==
dependencies:
"@babel/helper-validator-identifier" "^7.12.11"
chalk "^2.0.0"
js-tokens "^4.0.0"
"@babel/parser@^7.9.4":
- version "7.13.4"
- resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.4.tgz#340211b0da94a351a6f10e63671fa727333d13ab"
- integrity sha512-uvoOulWHhI+0+1f9L4BoozY7U5cIkZ9PgJqvb041d6vypgUmtVPG4vmGm4pSggjl8BELzvHyUeJSUyEMY6b+qA==
+ version "7.13.11"
+ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.11.tgz#f93ebfc99d21c1772afbbaa153f47e7ce2f50b88"
+ integrity sha512-PhuoqeHoO9fc4ffMEVk4qb/w/s2iOSWohvbHxLtxui0eBg3Lg5gN1U8wp1V1u61hOWkPQJJyJzGH6Y+grwkq8Q==
"@babel/runtime@^7.9.2":
- version "7.13.7"
- resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.7.tgz#d494e39d198ee9ca04f4dcb76d25d9d7a1dc961a"
- integrity sha512-h+ilqoX998mRVM5FtB5ijRuHUDVt5l3yfoOi2uh18Z/O3hvyaHQ39NpxVkCIG5yFs+mLq/ewFp8Bss6zmWv6ZA==
+ version "7.13.10"
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
+ integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
dependencies:
regenerator-runtime "^0.13.4"
-"@eslint/eslintrc@^0.3.0":
- version "0.3.0"
- resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.3.0.tgz#d736d6963d7003b6514e6324bec9c602ac340318"
- integrity sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg==
+"@eslint/eslintrc@^0.4.0":
+ version "0.4.0"
+ resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.0.tgz#99cc0a0584d72f1df38b900fb062ba995f395547"
+ integrity sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog==
dependencies:
ajv "^6.12.4"
debug "^4.1.1"
@@ -47,7 +47,6 @@
ignore "^4.0.6"
import-fresh "^3.2.1"
js-yaml "^3.13.1"
- lodash "^4.17.20"
minimatch "^3.0.4"
strip-json-comments "^3.1.1"
@@ -93,9 +92,9 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4:
uri-js "^4.2.2"
ajv@^7.0.2:
- version "7.1.1"
- resolved "https://registry.yarnpkg.com/ajv/-/ajv-7.1.1.tgz#1e6b37a454021fa9941713f38b952fc1c8d32a84"
- integrity sha512-ga/aqDYnUy/o7vbsRTFhhTsNeXiYb5JWDIcRIeZfwRNCefwjNTVYCGdGSUrEmiu3yDK3vFvNbgJxvrQW4JXrYQ==
+ version "7.2.1"
+ resolved "https://registry.yarnpkg.com/ajv/-/ajv-7.2.1.tgz#a5ac226171912447683524fa2f1248fcf8bac83d"
+ integrity sha512-+nu0HDv7kNSOua9apAVc979qd932rrZeb3WOvoiD31A/p1mIE5/9bN2027pE2rOPYEdS3UHzsvof4hY+lM9/WQ==
dependencies:
fast-deep-equal "^3.1.1"
json-schema-traverse "^1.0.0"
@@ -434,12 +433,12 @@ eslint-visitor-keys@^2.0.0:
integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==
eslint@^7.20.0:
- version "7.20.0"
- resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.20.0.tgz#db07c4ca4eda2e2316e7aa57ac7fc91ec550bdc7"
- integrity sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw==
+ version "7.22.0"
+ resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.22.0.tgz#07ecc61052fec63661a2cab6bd507127c07adc6f"
+ integrity sha512-3VawOtjSJUQiiqac8MQc+w457iGLfuNGLFn8JmF051tTKbh5/x/0vlcEj8OgDCaw7Ysa2Jn8paGshV7x2abKXg==
dependencies:
"@babel/code-frame" "7.12.11"
- "@eslint/eslintrc" "^0.3.0"
+ "@eslint/eslintrc" "^0.4.0"
ajv "^6.10.0"
chalk "^4.0.0"
cross-spawn "^7.0.2"
@@ -452,10 +451,10 @@ eslint@^7.20.0:
espree "^7.3.1"
esquery "^1.4.0"
esutils "^2.0.2"
- file-entry-cache "^6.0.0"
+ file-entry-cache "^6.0.1"
functional-red-black-tree "^1.0.1"
glob-parent "^5.0.0"
- globals "^12.1.0"
+ globals "^13.6.0"
ignore "^4.0.6"
import-fresh "^3.0.0"
imurmurhash "^0.1.4"
@@ -463,7 +462,7 @@ eslint@^7.20.0:
js-yaml "^3.13.1"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.4.1"
- lodash "^4.17.20"
+ lodash "^4.17.21"
minimatch "^3.0.4"
natural-compare "^1.4.0"
optionator "^0.9.1"
@@ -589,7 +588,7 @@ figures@^3.0.0:
dependencies:
escape-string-regexp "^1.0.5"
-file-entry-cache@^6.0.0:
+file-entry-cache@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027"
integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==
@@ -617,9 +616,9 @@ flatted@^3.1.0:
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
follow-redirects@^1.10.0:
- version "1.13.2"
- resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147"
- integrity sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA==
+ version "1.13.3"
+ resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.3.tgz#e5598ad50174c1bc4e872301e82ac2cd97f90267"
+ integrity sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==
forever-agent@~0.6.1:
version "0.6.1"
@@ -675,9 +674,9 @@ getpass@^0.1.1:
assert-plus "^1.0.0"
glob-parent@^5.0.0, glob-parent@^5.1.0:
- version "5.1.1"
- resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229"
- integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==
+ version "5.1.2"
+ resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
+ integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
dependencies:
is-glob "^4.0.1"
@@ -700,6 +699,13 @@ globals@^12.1.0:
dependencies:
type-fest "^0.8.1"
+globals@^13.6.0:
+ version "13.7.0"
+ resolved "https://registry.yarnpkg.com/globals/-/globals-13.7.0.tgz#aed3bcefd80ad3ec0f0be2cf0c895110c0591795"
+ integrity sha512-Aipsz6ZKRxa/xQkZhNg0qIWXT6x6rD46f6x/PCnBomlttdIyAPak4YD9jTmKpZ72uROSMU87qJtcgpgHaVchiA==
+ dependencies:
+ type-fest "^0.20.2"
+
globby@^11.0.0:
version "11.0.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.2.tgz#1af538b766a3b540ebfb58a32b2e2d5897321d83"
@@ -957,9 +963,9 @@ lodash@^4.17.20, lodash@^4.17.21:
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
lookpath@^1.1.0:
- version "1.1.0"
- resolved "https://registry.yarnpkg.com/lookpath/-/lookpath-1.1.0.tgz#932d68371a2f0b4a5644f03d6a2b4728edba96d2"
- integrity sha512-B9NM7XpVfkyWqfOBI/UW0kVhGw7pJztsduch+1wkbYDi90mYK6/InFul3lG0hYko/VEcVMARVBJ5daFRc5aKCw==
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/lookpath/-/lookpath-1.2.0.tgz#5fccf91497acec085e66d98cb12446c21fe665ae"
+ integrity sha512-cUl+R2bGJcSJiHLVKzGHRTYTBhudbHIgd7s63gfGHteaz0BBKEEz2yw2rgbxZAFze92KlbkiWzL1ylYOmqIPVA==
lru-cache@^6.0.0:
version "6.0.0"
@@ -1417,9 +1423,9 @@ stream-meter@^1.0.4:
readable-stream "^2.1.4"
string-width@^4.1.0, string-width@^4.2.0:
- version "4.2.1"
- resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.1.tgz#1933ce1f470973d224368009bd1316cad81d5f4f"
- integrity sha512-LL0OLyN6AnfV9xqGQpDBwedT2Rt63737LxvsRxbcwpa2aIeynBApG2Sm//F3TaLHIR1aJBN52DWklc06b94o5Q==
+ version "4.2.2"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
+ integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
@@ -1541,6 +1547,11 @@ type-fest@^0.11.0:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1"
integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==
+type-fest@^0.20.2:
+ version "0.20.2"
+ resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
+ integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
+
type-fest@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
@@ -1583,9 +1594,9 @@ uuid@^3.3.2:
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
v8-compile-cache@^2.0.3:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz#9471efa3ef9128d2f7c6a7ca39c4dd6b5055b132"
- integrity sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
+ integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
verror@1.10.0:
version "1.10.0"
diff --git a/packages/server/.gitignore b/packages/server/.gitignore
index 22397018be..b42fc06f06 100644
--- a/packages/server/.gitignore
+++ b/packages/server/.gitignore
@@ -1,6 +1,7 @@
node_modules/
myapps/
.env
+dev.env
/builder/*
!/builder/assets/
!/builder/pickr.min.js
diff --git a/packages/server/dev.env b/packages/server/dev.env
deleted file mode 100644
index 45e34f8be4..0000000000
--- a/packages/server/dev.env
+++ /dev/null
@@ -1 +0,0 @@
-PORT=4001
diff --git a/packages/server/package.json b/packages/server/package.json
index f62a21bd0b..a17da46c73 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -36,7 +36,10 @@
"test:integration": "jest --coverage --detectOpenHandles",
"test:watch": "jest --watch",
"run:docker": "node src/index",
- "dev:builder": "env-cmd -f dev.env nodemon src/index.js",
+ "dev:stack:up": "node scripts/dev/manage.js up",
+ "dev:stack:down": "node scripts/dev/manage.js down",
+ "dev:stack:nuke": "node scripts/dev/manage.js nuke",
+ "dev:builder": "npm run dev:stack:up && env-cmd -f dev.env nodemon src/index.js",
"electron": "electron src/electron.js",
"build:electron": "electron-builder --dir",
"publish:electron": "electron-builder -mwl --publish always",
diff --git a/packages/server/scripts/dev/manage.js b/packages/server/scripts/dev/manage.js
new file mode 100644
index 0000000000..f76b5ebd3d
--- /dev/null
+++ b/packages/server/scripts/dev/manage.js
@@ -0,0 +1,79 @@
+#!/usr/bin/env node
+const compose = require("docker-compose")
+const path = require("path")
+
+// This script wraps docker-compose allowing you to manage your dev infrastructure with simple commands.
+const CONFIG = {
+ cwd: path.resolve(process.cwd(), "../../hosting"),
+ config: "docker-compose.dev.yaml",
+ log: true,
+}
+
+const Commands = {
+ Up: "up",
+ Down: "down",
+ Nuke: "nuke",
+}
+
+const managementCommand = process.argv.slice(2)[0]
+
+if (
+ !managementCommand ||
+ !Object.values(Commands).some(command => managementCommand === command)
+) {
+ throw new Error(
+ "You must supply either an 'up' or 'down' commmand to manage the budibase dev env."
+ )
+}
+
+async function up() {
+ console.log("Spinning up your budibase dev environment... ๐งโจ")
+ try {
+ await compose.upAll(CONFIG)
+ } catch (err) {
+ console.log("Something went wrong:", err.message)
+ }
+}
+
+async function down() {
+ console.log("Spinning down your budibase dev environment... ๐")
+ try {
+ await compose.stop(CONFIG)
+ } catch (err) {
+ console.log("Something went wrong:", err.message)
+ }
+}
+
+async function nuke() {
+ console.log(
+ "Clearing down your budibase dev environment, including all containers and volumes... ๐ฅ"
+ )
+ try {
+ await compose.down(CONFIG)
+ } catch (err) {
+ console.log("Something went wrong:", err.message)
+ }
+}
+
+let command
+switch (managementCommand) {
+ case Commands.Up:
+ command = up
+ break
+ case Commands.Down:
+ command = down
+ break
+ case Commands.Nuke:
+ command = nuke
+ break
+ default:
+ command = up
+}
+
+command()
+ .then(() => {
+ console.log("Done! ๐")
+ })
+ .catch(() => {
+ console.log("Error while managing budibase dev environment.")
+ })
diff --git a/packages/server/scripts/initialise.js b/packages/server/scripts/initialise.js
index 485ebd56a0..bbba7a5c35 100644
--- a/packages/server/scripts/initialise.js
+++ b/packages/server/scripts/initialise.js
@@ -1,17 +1,17 @@
-const { join } = require("path")
-const { homedir } = require("os")
+// const { join } = require("path")
+// const { homedir } = require("os")
-const initialiseBudibase = require("../src/utilities/initialiseBudibase")
-const DIRECTORY = "~/.budibase"
+// // const initialiseBudibase = require("../src/utilities/initialiseBudibase")
+// // const DIRECTORY = "~/.budibase"
-function run() {
- let opts = {}
- let dir = DIRECTORY
- opts.quiet = true
- opts.dir = dir.startsWith("~") ? join(homedir(), dir.substring(1)) : dir
- return initialiseBudibase(opts)
-}
+// function run() {
+// let opts = {}
+// // let dir = DIRECTORY
+// opts.quiet = true
+// // opts.dir = dir.startsWith("~") ? join(homedir(), dir.substring(1)) : dir
+// return initialiseBudibase(opts)
+// }
-run().then(() => {
- console.log("Init complete.")
-})
+// run().then(() => {
+// console.log("Init complete.")
+// })
diff --git a/packages/server/src/db/client.js b/packages/server/src/db/client.js
index f6dea33a40..3645573e40 100644
--- a/packages/server/src/db/client.js
+++ b/packages/server/src/db/client.js
@@ -1,11 +1,10 @@
const PouchDB = require("pouchdb")
const replicationStream = require("pouchdb-replication-stream")
const allDbs = require("pouchdb-all-dbs")
-const { budibaseAppsDir } = require("../utilities/budibaseDir")
const find = require("pouchdb-find")
const env = require("../environment")
-const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/.data/`
+const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/"
const isInMemory = env.NODE_ENV === "jest"
PouchDB.plugin(replicationStream.plugin)
diff --git a/packages/server/src/utilities/initialiseBudibase.js b/packages/server/src/utilities/initialiseBudibase.js
index bdbd194eaa..990b180372 100644
--- a/packages/server/src/utilities/initialiseBudibase.js
+++ b/packages/server/src/utilities/initialiseBudibase.js
@@ -1,37 +1,37 @@
-const { existsSync, readFile, writeFile, ensureDir } = require("fs-extra")
-const { join, resolve } = require("./centralPath")
-const { processString } = require("@budibase/string-templates")
-const uuid = require("uuid")
+// const { existsSync, readFile, writeFile, ensureDir } = require("fs-extra")
+// const { join, resolve } = require("./centralPath")
+// const { processString } = require("@budibase/string-templates")
+// const uuid = require("uuid")
-module.exports = async opts => {
- await ensureDir(opts.dir)
- await setCouchDbUrl(opts)
+// module.exports = async opts => {
+// // await ensureDir(opts.dir)
+// await setCouchDbUrl(opts)
- // need an env file
- await createDevEnvFile(opts)
-}
+// // need an env file
+// await createDevEnvFile(opts)
+// }
-const setCouchDbUrl = async opts => {
- if (!opts.couchDbUrl) {
- const dataDir = join(opts.dir, ".data")
- await ensureDir(dataDir)
- opts.couchDbUrl =
- dataDir + (dataDir.endsWith("/") || dataDir.endsWith("\\") ? "" : "/")
- }
-}
+// const setCouchDbUrl = async opts => {
+// if (!opts.couchDbUrl) {
+// const dataDir = join(opts.dir, ".data")
+// await ensureDir(dataDir)
+// opts.couchDbUrl =
+// dataDir + (dataDir.endsWith("/") || dataDir.endsWith("\\") ? "" : "/")
+// }
+// }
-const createDevEnvFile = async opts => {
- const destConfigFile = join(opts.dir, "./.env")
- let createConfig = !existsSync(destConfigFile) || opts.quiet
- if (createConfig) {
- const template = await readFile(
- resolve(__dirname, "..", "..", ".env.template"),
- {
- encoding: "utf8",
- }
- )
- opts.cookieKey1 = opts.cookieKey1 || uuid.v4()
- const config = await processString(template, opts)
- await writeFile(destConfigFile, config, { flag: "w+" })
- }
-}
+// const createDevEnvFile = async opts => {
+// const destConfigFile = join(opts.dir, "./.env")
+// let createConfig = !existsSync(destConfigFile) || opts.quiet
+// if (createConfig) {
+// const template = await readFile(
+// resolve(__dirname, "..", "..", ".env.template"),
+// {
+// encoding: "utf8",
+// }
+// )
+// opts.cookieKey1 = opts.cookieKey1 || uuid.v4()
+// const config = await processString(template, opts)
+// await writeFile(destConfigFile, config, { flag: "w+" })
+// }
+// }
diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock
index 0035fd918b..599b64ca60 100644
--- a/packages/server/yarn.lock
+++ b/packages/server/yarn.lock
@@ -2700,13 +2700,6 @@ crc@^3.4.4:
dependencies:
buffer "^5.1.0"
-cross-env@^7.0.3:
- version "7.0.3"
- resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
- integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
- dependencies:
- cross-spawn "^7.0.1"
-
cross-spawn@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41"
@@ -2726,7 +2719,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"
-cross-spawn@^7.0.0, cross-spawn@^7.0.1:
+cross-spawn@^7.0.0:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
@@ -3068,6 +3061,11 @@ dmg-builder@22.9.1:
js-yaml "^3.14.0"
sanitize-filename "^1.6.3"
+docker-compose@^0.23.6:
+ version "0.23.6"
+ resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.23.6.tgz#bd21e17d599f17fcf7a4b5d607cff0358a9c378b"
+ integrity sha512-y3Q8MkwG862rNqkvEQG59/7Fi2/fzs3NYDCvqUAAD+z0WGs2qcJ9hRcn34hWgWv9ouPkFqe3Vwca0h+4bIIRWw==
+
doctrine@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961"
@@ -9465,9 +9463,9 @@ uc.micro@^1.0.1, uc.micro@^1.0.5:
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
uglify-js@^3.1.4:
- version "3.13.1"
- resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.13.1.tgz#2749d4b8b5b7d67460b4a418023ff73c3fefa60a"
- integrity sha512-EWhx3fHy3M9JbaeTnO+rEqzCe1wtyQClv6q3YWq0voOj4E+bMZBErVS1GAHPDiRGONYq34M1/d8KuQMgvi6Gjw==
+ version "3.13.2"
+ resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.13.2.tgz#fe10319861bccc8682bfe2e8151fbdd8aa921c44"
+ integrity sha512-SbMu4D2Vo95LMC/MetNaso1194M1htEA+JrqE9Hk+G2DhI+itfS9TRu9ZKeCahLDNa/J3n4MqUJ/fOHMzQpRWw==
unbox-primitive@^1.0.0:
version "1.0.0"
diff --git a/packages/worker/package.json b/packages/worker/package.json
index 1670fd729e..7d88654a88 100644
--- a/packages/worker/package.json
+++ b/packages/worker/package.json
@@ -33,6 +33,5 @@
"pouchdb": "^7.2.2",
"pouchdb-all-dbs": "^1.0.2",
"server-destroy": "^1.0.1"
- },
- "gitHead": "1b95326b20d1352d36305910259228b96a683dc7"
+ }
}
diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js
index 24bbb55092..83f030c846 100644
--- a/packages/worker/src/db/index.js
+++ b/packages/worker/src/db/index.js
@@ -1,12 +1,9 @@
const PouchDB = require("pouchdb")
const allDbs = require("pouchdb-all-dbs")
const env = require("../environment")
-const { join } = require("path")
-const { homedir } = require("os")
// level option is purely for testing (development)
-const COUCH_DB_URL =
- env.COUCH_DB_URL || `leveldb://${join(homedir(), ".budibase")}/.data/`
+const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/"
const Pouch = PouchDB.defaults({
prefix: COUCH_DB_URL,