Merge branch 'single-stack-dev' of github.com:Budibase/budibase into feature/fs-removal

This commit is contained in:
mike12345567 2021-03-22 17:20:07 +00:00
commit 78eb00b39d
35 changed files with 507 additions and 207 deletions

View File

@ -1,16 +0,0 @@
version: "3"
services:
app-service:
build: ./server
volumes:
- ./server:/app
environment:
SELF_HOSTED: 1
PORT: 4002
worker-service:
build: ./worker
environment:
SELF_HOSTED: 1,
PORT: 4003

View File

@ -1 +0,0 @@
../../packages/server/

View File

@ -1 +0,0 @@
../../packages/worker/

View File

@ -0,0 +1,79 @@
version: "3"
# optional ports are specified throughout for more advanced use cases.
services:
minio-service:
container_name: budi-minio-dev
restart: always
image: minio/minio
volumes:
- minio_data:/data
ports:
- "${MINIO_PORT}:9000"
environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
MINIO_BROWSER: "off"
command: server /data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
proxy-service:
container_name: budi-envoy-dev
restart: always
image: envoyproxy/envoy:v1.16-latest
volumes:
- ./envoy.dev.yaml:/etc/envoy/envoy.yaml
ports:
- "${MAIN_PORT}:10000"
#- "9901:9901"
depends_on:
- minio-service
- couchdb-service
couchdb-service:
container_name: budi-couchdb-dev
restart: always
image: apache/couchdb:3.0
environment:
- COUCHDB_PASSWORD=${COUCH_DB_PASSWORD}
- COUCHDB_USER=${COUCH_DB_USER}
ports:
- "${COUCH_DB_PORT}:5984"
#- "4369:4369"
#- "9100:9100"
volumes:
- couchdb_data:/opt/couchdb/data
couch-init:
image: curlimages/curl
environment:
PUT_CALL: "curl -u ${COUCH_DB_USER}:${COUCH_DB_PASSWORD} -X PUT couchdb-service:5984"
depends_on:
- couchdb-service
command: ["sh","-c","sleep 10 && $${PUT_CALL}/_users && $${PUT_CALL}/_replicator; fg;"]
redis-service:
container_name: budi-redis-dev
restart: always
image: redis
environment:
- COUCHDB_PASSWORD=${COUCH_DB_PASSWORD}
- COUCHDB_USER=${COUCH_DB_USER}
ports:
- "${REDIS_PORT}:6379"
volumes:
- redis_data:/data
volumes:
couchdb_data:
driver: local
minio_data:
driver: local
redis_data:
driver: local

79
hosting/envoy.dev.yaml Normal file
View File

@ -0,0 +1,79 @@
static_resources:
listeners:
- name: main_listener
address:
socket_address: { address: 0.0.0.0, port_value: 10000 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress
codec_type: auto
route_config:
name: local_route
virtual_hosts:
- name: local_services
domains: ["*"]
routes:
- match: { prefix: "/db/" }
route:
cluster: couchdb-service
prefix_rewrite: "/"
- match: { prefix: "/cache/" }
route:
cluster: redis-service
prefix_rewrite: "/"
# minio is on the default route because this works
# best, minio + AWS SDK doesn't handle path proxy
- match: { prefix: "/" }
route:
cluster: minio-service
http_filters:
- name: envoy.filters.http.router
clusters:
- name: minio-service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: minio-service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: minio-service
port_value: 9000
- name: couchdb-service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: couchdb-service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: couchdb-service
port_value: 5984
- name: redis-service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: redis-service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: redis-service
port_value: 6379

View File

@ -18,4 +18,5 @@ APP_PORT=4002
WORKER_PORT=4003
MINIO_PORT=4004
COUCH_DB_PORT=4005
REDIS_PORT=6379
BUDIBASE_ENVIRONMENT=PRODUCTION

View File

@ -105,7 +105,9 @@ export const getBackendUiStore = () => {
state.datasources = state.datasources.filter(
existing => existing._id !== datasource._id
)
if (datasource._id === state.selectedDatasourceId) {
state.selectedDatasourceId = null
}
return state
})
},
@ -233,7 +235,9 @@ export const getBackendUiStore = () => {
state.tables = state.tables.filter(
existing => existing._id !== table._id
)
if (table._id === state.selectedTable._id) {
state.selectedTable = {}
}
return state
})
},

View File

@ -24,7 +24,7 @@
automation,
})
notifier.success("Automation deleted.")
$goto('../automate')
$goto("../automate")
}
</script>

View File

@ -22,9 +22,13 @@
}
async function deleteDatasource() {
const wasSelectedSource = $backendUiStore.selectedDatasourceId
await backendUiStore.actions.datasources.delete(datasource)
notifier.success("Datasource deleted")
// navigate to first index page if the source you are deleting is selected
if (wasSelectedSource === datasource._id) {
$goto('./datasource')
}
hideEditor()
}
</script>

View File

@ -1,4 +1,5 @@
<script>
import { goto } from "@sveltech/routify"
import { backendUiStore, store, allScreens } from "builderStore"
import { notifier } from "builderStore/store/notifications"
import { DropdownMenu, Button, Input } from "@budibase/bbui"
@ -36,10 +37,14 @@
}
async function deleteTable() {
const wasSelectedTable = $backendUiStore.selectedTable
await backendUiStore.actions.tables.delete(table)
store.actions.screens.delete(templateScreens)
await backendUiStore.actions.tables.fetch()
notifier.success("Table deleted")
if (wasSelectedTable._id === table._id) {
$goto('./table')
}
hideEditor()
}

View File

@ -119,7 +119,9 @@
{#if deployment.status.toLowerCase() === 'pending'}
<Spinner size="10" />
{/if}
<div on:click={() => showErrorReasonModal(deployment.err)} class={`deployment-status ${deployment.status}`}>
<div
on:click={() => showErrorReasonModal(deployment.err)}
class={`deployment-status ${deployment.status}`}>
<span>
{deployment.status}
{#if deployment.status === DeploymentStatus.FAILURE}

View File

@ -3,4 +3,3 @@
</script>
<AutomationBuilder />

View File

@ -1,6 +1,6 @@
<script>
import { goto, leftover } from "@sveltech/routify"
import { onMount } from 'svelte'
import { onMount } from "svelte"
import { automationStore } from "builderStore"
onMount(async () => {
@ -8,7 +8,8 @@
if (
!$leftover &&
$automationStore.automations.length > 0 &&
(!$automationStore.selectedAutomation || !$automationStore.selectedAutomation?.automation?._id)
(!$automationStore.selectedAutomation ||
!$automationStore.selectedAutomation?.automation?._id)
) {
$goto(`../${$automationStore.automations[0]._id}`)
}

View File

@ -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 @@
<!-- routify:options index=0 -->
<div class="root">
<div class="nav">
<Switcher headings={tabs} bind:value={tab} on:change={selectFirstTableOrSource}>
<Switcher
headings={tabs}
bind:value={tab}
on:change={selectFirstTableOrSource}>
<div class="title">
<i
data-cy={`new-${tab}`}

View File

@ -3,9 +3,7 @@
import { backendUiStore } from "builderStore"
if ($params.query) {
const query = $backendUiStore.queries.find(
m => m._id === $params.query
)
const query = $backendUiStore.queries.find(m => m._id === $params.query)
if (query) {
backendUiStore.actions.queries.select(query)
}

View File

@ -5,7 +5,8 @@
onMount(async () => {
// navigate to first table in list, if not already selected
$backendUiStore.datasources.length > 0 && $goto(`../${$backendUiStore.datasources[0]._id}`)
$backendUiStore.datasources.length > 0 &&
$goto(`../${$backendUiStore.datasources[0]._id}`)
})
</script>

View File

@ -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}`)
})
</script>

View File

@ -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": {

View File

@ -2,3 +2,8 @@ exports.CommandWords = {
HOSTING: "hosting",
HELP: "help",
}
exports.InitTypes = {
QUICK: "quick",
DIGITAL_OCEAN: "do",
}

View File

@ -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,8 +58,10 @@ async function handleError(func) {
}
}
async function init() {
async function init(type) {
const isQuick = type === InitTypes.QUICK || type === InitTypes.DIGITAL_OCEAN
await checkDockerConfigured()
if (!isQuick) {
const shouldContinue = await confirmation(
"This will create multiple files in current directory, should continue?"
)
@ -59,15 +69,30 @@ async function init() {
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(

View File

@ -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(
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 = await number(
))
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(

View File

@ -1,3 +1,4 @@
#!/usr/bin/env node
const { getCommands } = require("./options")
const { Command } = require("commander")
const { getHelpDescription } = require("./utils")

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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"

View File

@ -1,6 +1,7 @@
node_modules/
myapps/
.env
dev.env
/builder/*
!/builder/assets/
!/builder/pickr.min.js

View File

@ -1 +0,0 @@
PORT=4001

View File

@ -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",

View File

@ -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.")
})

View File

@ -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.")
// })

View File

@ -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)

View File

@ -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+" })
// }
// }

View File

@ -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"

View File

@ -33,6 +33,5 @@
"pouchdb": "^7.2.2",
"pouchdb-all-dbs": "^1.0.2",
"server-destroy": "^1.0.1"
},
"gitHead": "1b95326b20d1352d36305910259228b96a683dc7"
}
}

View File

@ -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,