wip(backend): Started work on v3 backend
This commit is contained in:
parent
94f0ca0e0b
commit
88d9b2a1e9
67 changed files with 1375 additions and 2842 deletions
47
sites/backend/scripts/rmdb.mjs
Normal file
47
sites/backend/scripts/rmdb.mjs
Normal file
|
@ -0,0 +1,47 @@
|
|||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import prompts from 'prompts'
|
||||
import chalk from 'chalk'
|
||||
import { banner } from '../../../scripts/banner.mjs'
|
||||
import dotenv from 'dotenv'
|
||||
dotenv.config()
|
||||
|
||||
|
||||
const rmdb = async () => {
|
||||
// Say hi
|
||||
console.log(banner + '\n')
|
||||
|
||||
console.log(`
|
||||
🚨 This will ${chalk.yellow('remove your database')}
|
||||
⚠️ There is ${chalk.bold('no way back')} from this - proceed with caution
|
||||
`)
|
||||
|
||||
const answer = await prompts([{
|
||||
type: 'confirm',
|
||||
name: 'confirms',
|
||||
message: 'Are you sure you want to completely remove your FreeSewing database?',
|
||||
initial: false
|
||||
}])
|
||||
|
||||
if (answer.confirms) {
|
||||
console.log()
|
||||
// Nuke it from orbit
|
||||
const db = process.env.API_DB_URL.slice(6)
|
||||
fs.access(db, fs.constants.W_OK, err => {
|
||||
if (err) console.log(` ⛔ Cannot remove ${chalk.green(db)} 🤔`)
|
||||
else {
|
||||
fs.unlinkSync(db)
|
||||
console.log(` 🔥 Removed ${chalk.red(db)} 😬`)
|
||||
}
|
||||
console.log()
|
||||
})
|
||||
} else {
|
||||
console.log()
|
||||
console.log(chalk.green(' 😅 Not removing database - Phew'))
|
||||
console.log()
|
||||
}
|
||||
}
|
||||
|
||||
rmdb()
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue