1
0
Fork 0
mirror of synced 2024-07-09 00:06:05 +12:00
budibase/packages/server/scripts/dev/manage.js

71 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-03-23 06:05:00 +13:00
#!/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",
}
async function up() {
console.log("Spinning up your budibase dev environment... 🔧✨")
2021-03-24 00:01:33 +13:00
await compose.upAll(CONFIG)
2021-03-23 06:05:00 +13:00
}
async function down() {
console.log("Spinning down your budibase dev environment... 🌇")
2021-03-24 00:01:33 +13:00
await compose.stop(CONFIG)
2021-03-23 06:05:00 +13:00
}
async function nuke() {
console.log(
"Clearing down your budibase dev environment, including all containers and volumes... 💥"
)
2021-03-24 00:01:33 +13:00
await compose.down(CONFIG)
2021-03-23 06:05:00 +13:00
}
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', 'down' or 'nuke' commmand to manage the budibase development environment."
)
}
2021-03-23 06:05:00 +13:00
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! 🎉")
})
2021-03-24 00:01:33 +13:00
.catch(err => {
console.error(
"Something went wrong while managing budibase dev environment:",
err.message
)
2021-03-23 06:05:00 +13:00
})