Merge pull request #438 from Budibase/beta-bugfixes

Beta bugfixes
This commit is contained in:
Martin McKeaveney 2020-07-13 19:05:29 +01:00 committed by GitHub
commit aefd6830b1
6 changed files with 45 additions and 34 deletions

View File

@ -1,13 +1,13 @@
const { xPlatHomeDir } = require("../../common")
const { resolve } = require("path")
module.exports = ({ dir }) => {
module.exports = async ({ dir }) => {
dir = xPlatHomeDir(dir)
process.env.BUDIBASE_DIR = resolve(dir)
require("dotenv").config({ path: resolve(dir, ".env") })
// dont make this a variable or top level require
// ti will cause environment module to be loaded prematurely
// it will cause environment module to be loaded prematurely
return require("@budibase/server/src/app")().then(server => {
server.on("close", () => console.log("Server Closed"))
console.log(`Budibase running on ${JSON.stringify(server.address())}`)

View File

@ -29,7 +29,7 @@
"initialise": "node ../cli/bin/budi init -q",
"run:docker": "node src/index",
"budi": "node ../cli/bin/budi",
"dev:builder": "nodemon ../cli/bin/budi run",
"dev:builder": "nodemon src/index.js",
"electron": "electron src/electron.js",
"build:electron": "electron-builder --dir",
"publish:electron": "electron-builder -mwl --publish always",
@ -81,7 +81,7 @@
"electron-builder-notarize": "^1.1.2",
"eslint": "^6.8.0",
"jest": "^24.8.0",
"nodemon": "^2.0.2",
"nodemon": "^2.0.4",
"pouchdb-adapter-memory": "^7.2.1",
"server-destroy": "^1.0.1",
"supertest": "^4.0.2"

View File

@ -1,4 +1,4 @@
const { app, BrowserWindow, shell } = require("electron")
const { app, BrowserWindow, shell, dialog } = require("electron")
const { join } = require("path")
const isDev = require("electron-is-dev")
const { autoUpdater } = require("electron-updater")
@ -10,16 +10,10 @@ const { budibaseAppsDir } = require("./utilities/budibaseDir")
const budibaseDir = budibaseAppsDir()
const envFile = join(budibaseDir, ".env")
if (!existsSync(envFile)) {
// assume not initialised
initialiseBudibase({ dir: budibaseDir }).then(() => {
startApp()
})
} else {
startApp()
}
function startApp() {
async function startApp() {
if (!existsSync(envFile)) {
await initialiseBudibase({ dir: budibaseDir })
}
// evict environment from cache, so it reloads when next asked
delete require.cache[require.resolve("./environment")]
require("dotenv").config({ path: envFile })
@ -71,3 +65,25 @@ function startApp() {
if (win === null) createWindow()
})
}
autoUpdater.on("update-downloaded", (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: "info",
buttons: ["Restart", "Later"],
title: "Budibase Update Available",
message: process.platform === "win32" ? releaseNotes : releaseName,
detail:
"A new version of the budibase builder has been downloaded. Restart the application to apply the updates.",
}
dialog.showMessageBox(dialogOpts).then(returnValue => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})
autoUpdater.on("error", message => {
console.error("There was a problem updating the application")
console.error(message)
})
startApp()

View File

@ -1,11 +1,17 @@
const { resolve } = require("path")
const { resolve, join } = require("path")
const { homedir } = require("os")
const { app } = require("electron")
async function runServer() {
const budibaseDir = "~/.budibase"
const homeDir = app ? app.getPath("home") : homedir()
process.env.BUDIBASE_DIR = resolve(budibaseDir)
const budibaseDir = join(homeDir, ".budibase")
process.env.BUDIBASE_DIR = budibaseDir
require("dotenv").config({ path: resolve(budibaseDir, ".env") })
const server = await require("./app")()
server.on("close", () => console.log("Server Closed"))
console.log(`Budibase running on ${JSON.stringify(server.address())}`)
}

View File

@ -48,18 +48,7 @@ const createClientDatabase = async opts => {
const clientDb = require("../db/clientDb")
if (!opts.clientId || opts.clientId === "new") {
// cannot be a top level require as it
// will cause environment module to be loaded prematurely
const CouchDB = require("../db/client")
const existing = await CouchDB.allDbs()
let i = 0
let isExisting = true
while (isExisting) {
i += 1
opts.clientId = i.toString()
isExisting = existing.includes(clientDb.name(opts.clientId))
}
opts.clientId = uuid.v4()
}
await clientDb.create(opts.clientId)

View File

@ -806,7 +806,6 @@ atomic-sleep@^1.0.0:
resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b"
integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==
aws-sdk@^2.706.0:
version "2.706.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.706.0.tgz#09f65e9a91ecac5a635daf934082abae30eca953"
@ -3995,9 +3994,10 @@ node-notifier@^5.4.2:
shellwords "^0.1.1"
which "^1.3.0"
nodemon@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.3.tgz#e9c64df8740ceaef1cb00e1f3da57c0a93ef3714"
nodemon@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.4.tgz#55b09319eb488d6394aa9818148c0c2d1c04c416"
integrity sha512-Ltced+hIfTmaS28Zjv1BM552oQ3dbwPqI4+zI0SLgq+wpJhSyqgYude/aZa/3i31VCQWMfXJVxvu86abcam3uQ==
dependencies:
chokidar "^3.2.2"
debug "^3.2.6"