feat(pockethost): --extra-plugins

This commit is contained in:
Ben Allfree 2024-06-27 07:20:26 -07:00
parent 31e0e8885c
commit 5e9ed51be3
3 changed files with 18 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
'pockethost': minor
---
Added `--extra-plugins` global switch to temporarily load extra plugins from CLI

View File

@ -3,12 +3,17 @@ import {
LoggerService,
doServeAction,
doServeSlugsFilter,
loadPlugins,
} from '../../../common'
type Options = {
isolate: boolean
type GlobalOptions = {
extraPlugins: string[]
}
type Options = {
only: string[]
} & GlobalOptions
export const ServeCommand = async () => {
const serveSlugs = await doServeSlugsFilter([])
@ -24,12 +29,15 @@ export const ServeCommand = async () => {
.filter((s) => serveSlugs.includes(s)),
serveSlugs,
)
.action(async (options: Options) => {
.action(async (unused: Options, cmd: Command) => {
const logger = LoggerService().create(`ServeCommand`)
const { dbg, error, info, warn } = logger
info(`Starting`)
await doServeAction({ only: serveSlugs })
const { only, extraPlugins } = cmd.optsWithGlobals<Options>()
await loadPlugins(extraPlugins)
dbg(`CLI:`, cmd.optsWithGlobals())
await doServeAction({ only })
})
return cmd
}

View File

@ -35,6 +35,7 @@ export const main = async () => {
.name('pockethost')
.description('Multitenant PocketBase hosting')
.version(version)
.option(`-e, --extra-plugins <plugins...>`, `Extra plugins to load`, [])
const commands = await doCliCommandsFilter([
await ServeCommand(),