mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-04 13:16:41 +00:00
feat(pockethost): mothership schema dump
This commit is contained in:
parent
21c663fe73
commit
d6e700bdd1
@ -0,0 +1,11 @@
|
||||
import { Command } from 'commander'
|
||||
import { schema } from './schema'
|
||||
|
||||
export const SchemaCommand = () => {
|
||||
const cmd = new Command(`schema`)
|
||||
.description(`Create snapshot of the current PocketHost mothership schema`)
|
||||
.action(async (options) => {
|
||||
await schema()
|
||||
})
|
||||
return cmd
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import { GobotOptions } from 'gobot'
|
||||
import {
|
||||
IS_DEV,
|
||||
LoggerService,
|
||||
MOTHERSHIP_DATA_ROOT,
|
||||
MOTHERSHIP_MIGRATIONS_DIR,
|
||||
MOTHERSHIP_SEMVER,
|
||||
} from '../../../../../core'
|
||||
import { GobotService } from '../../../../services/GobotService'
|
||||
|
||||
export async function schema() {
|
||||
const logger = LoggerService().create(`MothershipSchema`)
|
||||
const { dbg, error, info, warn } = logger
|
||||
info(`Starting`)
|
||||
|
||||
const options: Partial<GobotOptions> = {
|
||||
version: MOTHERSHIP_SEMVER(),
|
||||
}
|
||||
dbg(`gobot options`, options)
|
||||
const { gobot } = GobotService()
|
||||
const bot = await gobot(`pocketbase`, options)
|
||||
|
||||
const args = [
|
||||
`migrate`,
|
||||
`collections`,
|
||||
`--automigrate`,
|
||||
`0`,
|
||||
`--hooksDir`,
|
||||
`foo`,
|
||||
`--dir`,
|
||||
MOTHERSHIP_DATA_ROOT(`pb_data`),
|
||||
`--migrationsDir`,
|
||||
MOTHERSHIP_MIGRATIONS_DIR(),
|
||||
]
|
||||
if (IS_DEV()) {
|
||||
args.push(`--dev`)
|
||||
}
|
||||
dbg(`args`, args)
|
||||
bot.run(args)
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { Command } from 'commander'
|
||||
import { SchemaCommand } from './SchemaCommand'
|
||||
import { ServeCommand } from './ServeCommand'
|
||||
import { UpdateCommand } from './UpdateCommand'
|
||||
|
||||
type Options = {
|
||||
debug: boolean
|
||||
@ -10,6 +10,6 @@ export const MothershipCommand = () => {
|
||||
const cmd = new Command(`mothership`)
|
||||
.description(`Mothership commands`)
|
||||
.addCommand(ServeCommand())
|
||||
.addCommand(UpdateCommand())
|
||||
.addCommand(SchemaCommand())
|
||||
return cmd
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user