forked from tsai/budibase
7 changed files with 710 additions and 13 deletions
@ -0,0 +1,42 @@ |
|||
#!/usr/bin/env node
|
|||
const path = require("path") |
|||
const fs = require("fs") |
|||
|
|||
async function init() { |
|||
const envFilePath = path.join(process.cwd(), ".env") |
|||
if (fs.existsSync(envFilePath)) { |
|||
return |
|||
} |
|||
const envFileJson = { |
|||
SELF_HOSTED: 1, |
|||
PORT: 4002, |
|||
MINIO_ACCESS_KEY: "budibase", |
|||
MINIO_SECRET_KEY: "budibase", |
|||
COUCH_DB_USER: "budibase", |
|||
COUCH_DB_PASSWORD: "budibase", |
|||
MINIO_URL: "http://localhost:10000/", |
|||
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", |
|||
} |
|||
let envFile = "" |
|||
Object.keys(envFileJson).forEach(key => { |
|||
envFile += `${key}=${envFileJson[key]}\n` |
|||
}) |
|||
fs.writeFileSync(envFilePath, envFile) |
|||
} |
|||
|
|||
// if more than init required use this to determine the command type
|
|||
//const managementCommand = process.argv.slice(2)[0]
|
|||
|
|||
// for now only one command
|
|||
let command = init |
|||
|
|||
command() |
|||
.then(() => { |
|||
console.log("Done! 🎉") |
|||
}) |
|||
.catch(err => { |
|||
console.error( |
|||
"Something went wrong while managing budibase dev worker:", |
|||
err.message |
|||
) |
|||
}) |
|||
@ -1,16 +1,28 @@ |
|||
function isDev() { |
|||
return process.env.NODE_ENV !== "production" |
|||
} |
|||
|
|||
let LOADED = false |
|||
if (!LOADED && isDev()) { |
|||
require("dotenv").config() |
|||
LOADED = true |
|||
} |
|||
|
|||
module.exports = { |
|||
SELF_HOSTED: process.env.SELF_HOSTED, |
|||
PORT: process.env.PORT, |
|||
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY, |
|||
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY, |
|||
RAW_MINIO_URL: process.env.RAW_MINIO_URL, |
|||
MINIO_PORT: process.env.MINIO_PORT, |
|||
MINIO_URL: process.env.MINIO_URL, |
|||
COUCH_DB_URL: process.env.COUCH_DB_URL, |
|||
LOG_LEVEL: process.env.LOG_LEVEL, |
|||
/* TODO: to remove - once deployment removed */ |
|||
SELF_HOST_KEY: process.env.SELF_HOST_KEY, |
|||
COUCH_DB_USERNAME: process.env.COUCH_DB_USERNAME, |
|||
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, |
|||
COUCH_DB_URL: process.env.COUCH_DB_URL, |
|||
_set(key, value) { |
|||
process.env[key] = value |
|||
module.exports[key] = value |
|||
}, |
|||
isDev, |
|||
} |
|||
|
|||
File diff suppressed because it is too large
Loading…
Reference in new issue