allow bb home folder to bem anywhere
This commit is contained in:
parent
6fac98074d
commit
a004aa5838
|
@ -3,6 +3,7 @@ const { resolve } = require("path")
|
|||
|
||||
module.exports = ({ dir }) => {
|
||||
dir = xPlatHomeDir(dir)
|
||||
process.env.BUDIBASE_DIR = resolve(dir)
|
||||
require("dotenv").config({ path: resolve(dir, ".env") })
|
||||
require("@budibase/server/src/app")
|
||||
console.log(`Budibase Builder running on port ${process.env.PORT}..`)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
const CouchDB = require("../../db")
|
||||
const { homedir } = require("os")
|
||||
const { resolve, join } = require("path")
|
||||
const {
|
||||
budibaseTempDir,
|
||||
budibaseAppsDir,
|
||||
} = require("../../utilities/budibaseDir")
|
||||
|
||||
const isDev = process.env.NODE_ENV !== "production"
|
||||
|
||||
|
@ -11,14 +14,13 @@ exports.fetchAppComponentDefinitions = async function(ctx) {
|
|||
const componentDefinitions = app.componentLibraries.reduce(
|
||||
(acc, componentLibrary) => {
|
||||
let appDirectory = resolve(
|
||||
homedir(),
|
||||
".budibase",
|
||||
budibaseAppsDir(),
|
||||
ctx.params.appId,
|
||||
"node_modules"
|
||||
)
|
||||
|
||||
if (isDev) {
|
||||
appDirectory = "/tmp/.budibase"
|
||||
appDirectory = budibaseTempDir()
|
||||
}
|
||||
|
||||
const componentJson = require(join(
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
const send = require("koa-send")
|
||||
const { resolve, join } = require("path")
|
||||
const { homedir } = require("os")
|
||||
const {
|
||||
budibaseAppsDir,
|
||||
budibaseTempDir,
|
||||
} = require("../../utilities/budibaseDir")
|
||||
|
||||
exports.serveBuilder = async function(ctx) {
|
||||
let builderPath = resolve(process.cwd(), "builder")
|
||||
|
@ -12,8 +15,7 @@ exports.serveApp = async function(ctx) {
|
|||
// TODO: update homedir stuff to wherever budi is run
|
||||
// default to homedir
|
||||
const appPath = resolve(
|
||||
homedir(),
|
||||
".budibase",
|
||||
budibaseAppsDir(),
|
||||
ctx.params.appId,
|
||||
"public",
|
||||
ctx.isAuthenticated ? "main" : "unauthenticated"
|
||||
|
@ -26,8 +28,7 @@ exports.serveComponentLibrary = async function(ctx) {
|
|||
// TODO: update homedir stuff to wherever budi is run
|
||||
// default to homedir
|
||||
let componentLibraryPath = resolve(
|
||||
homedir(),
|
||||
".budibase",
|
||||
budibaseAppsDir(),
|
||||
ctx.params.appId,
|
||||
"node_modules",
|
||||
decodeURI(ctx.query.library),
|
||||
|
@ -36,8 +37,7 @@ exports.serveComponentLibrary = async function(ctx) {
|
|||
|
||||
if (ctx.isDev) {
|
||||
componentLibraryPath = join(
|
||||
"/tmp",
|
||||
".budibase",
|
||||
budibaseTempDir(),
|
||||
decodeURI(ctx.query.library),
|
||||
"dist"
|
||||
)
|
||||
|
|
|
@ -2,8 +2,7 @@ const Router = require("@koa/router")
|
|||
const authenticated = require("../middleware/authenticated")
|
||||
const compress = require("koa-compress")
|
||||
const zlib = require("zlib")
|
||||
const { resolve } = require("path")
|
||||
const { homedir } = require("os")
|
||||
const { budibaseAppsDir } = require("../utilities/budibaseDir")
|
||||
const {
|
||||
authRoutes,
|
||||
pageRoutes,
|
||||
|
@ -34,7 +33,7 @@ router
|
|||
)
|
||||
.use(async (ctx, next) => {
|
||||
ctx.config = {
|
||||
latestPackagesFolder: resolve(homedir(), ".budibase"),
|
||||
latestPackagesFolder: budibaseAppsDir(),
|
||||
jwtSecret: process.env.JWT_SECRET,
|
||||
}
|
||||
ctx.isDev = process.env.NODE_ENV !== "production"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const Router = require("@koa/router")
|
||||
const controller = require("../controllers/static")
|
||||
const { budibaseTempDir } = require("../../utilities/budibaseDir")
|
||||
|
||||
const router = Router()
|
||||
|
||||
|
@ -9,7 +10,7 @@ router
|
|||
|
||||
// Serving the client library from your local dir in dev
|
||||
if (ctx.isDev && ctx.file.startsWith("budibase-client")) {
|
||||
ctx.devPath = "/tmp/.budibase"
|
||||
ctx.devPath = budibaseTempDir()
|
||||
}
|
||||
|
||||
await next()
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
const PouchDB = require("pouchdb")
|
||||
const allDbs = require("pouchdb-all-dbs")
|
||||
const os = require("os")
|
||||
const path = require("path")
|
||||
const { budibaseAppsDir } = require("../utilities/budibaseDir")
|
||||
|
||||
const BUDIBASE_DIR = path.join(os.homedir(), ".budibase")
|
||||
|
||||
const COUCH_DB_URL = process.env.COUCH_DB_URL || `leveldb://${BUDIBASE_DIR}/`
|
||||
const COUCH_DB_URL = process.env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/`
|
||||
|
||||
const Pouch = PouchDB.defaults({
|
||||
prefix: COUCH_DB_URL,
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
const { join } = require("path")
|
||||
const { homedir } = require("os")
|
||||
|
||||
const path = join(homedir(), ".budibase", ".env")
|
||||
require("dotenv").config({ path })
|
||||
const server = require("./app")
|
||||
|
||||
server.on("listening", () => {
|
||||
console.log(`Budibase Server listening on port ${process.env.PORT}`)
|
||||
})
|
|
@ -0,0 +1,10 @@
|
|||
const { join } = require("path")
|
||||
const { homedir, tmpdir } = require("os")
|
||||
|
||||
module.exports.budibaseAppsDir = function() {
|
||||
return process.env.BUDIBASE_DIR || join(homedir(), ".budibase")
|
||||
}
|
||||
|
||||
module.exports.budibaseTempDir = function() {
|
||||
return join(tmpdir(), ".budibase")
|
||||
}
|
|
@ -10,8 +10,10 @@
|
|||
const fs = require("fs")
|
||||
const { resolve } = require("path")
|
||||
const rimraf = require("rimraf");
|
||||
|
||||
const devDir = "/tmp/.budibase"
|
||||
const {
|
||||
budibaseTempDir,
|
||||
} = require("../packages/server/src/utilities/budibaseDir")
|
||||
const devDir = budibaseTempDir()
|
||||
|
||||
rimraf.sync(devDir);
|
||||
fs.mkdirSync(`${devDir}/@budibase`, { recursive: true })
|
||||
|
|
Loading…
Reference in New Issue