single stack dev setup complete
This commit is contained in:
parent
306d29d870
commit
f3302770b3
|
@ -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",
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env node
|
||||
const compose = require("docker-compose")
|
||||
const path = require("path")
|
||||
const readline = require("readline")
|
||||
|
||||
// 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.")
|
||||
})
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue