feat(pockethost): new action PluginsLoaded

This commit is contained in:
Ben Allfree 2024-06-29 14:15:40 -07:00
parent 52b70cbe76
commit cce72b35e2
4 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
'pockethost': minor
---
New action: AfterPluginsLoaded

View File

@ -133,6 +133,10 @@ onServeAction(async ({ only }) => {
| InstanceLog | A log action | logLevel, currentLogLevel, args | [example](https://github.com/pockethost/pockethost/blob/e6355c1aea2484ffba9d95110faa2af40e922855/packages/plugin-launcher-spawn/src/index.ts#L147) | 1.3.0 | | InstanceLog | A log action | logLevel, currentLogLevel, args | [example](https://github.com/pockethost/pockethost/blob/e6355c1aea2484ffba9d95110faa2af40e922855/packages/plugin-launcher-spawn/src/index.ts#L147) | 1.3.0 |
| Serve | The `pockethost serve` command has been called | only[] | | 1.4.0 | | Serve | The `pockethost serve` command has been called | only[] | | 1.4.0 |
#### AfterPluginsLoaded (since 1.6.0)
Fired after all plugins have been loaded. This is a good time to perform initialization that may depend upon other plugins.
### Core Filters ### Core Filters
#### ServerSlugs (since 1.4.0) #### ServerSlugs (since 1.4.0)

View File

@ -10,6 +10,7 @@ import {
DEBUG, DEBUG,
LogLevelName, LogLevelName,
LoggerService, LoggerService,
doAfterPluginsLoadedAction,
doCliCommandsFilter, doCliCommandsFilter,
loadPlugins, loadPlugins,
} from '../common' } from '../common'
@ -45,6 +46,8 @@ export const main = async () => {
await loadPlugins([pockethost, ...uniq(PH_PLUGINS()), ...extraPlugins]) await loadPlugins([pockethost, ...uniq(PH_PLUGINS()), ...extraPlugins])
await doAfterPluginsLoadedAction()
program program
.name('pockethost') .name('pockethost')
.description('Multitenant PocketBase hosting') .description('Multitenant PocketBase hosting')

View File

@ -4,6 +4,7 @@ import { DEBUG } from '../debug'
import { InstanceFields } from '../schema' import { InstanceFields } from '../schema'
enum CoreActions { enum CoreActions {
AfterPluginsLoaded = 'core_after_plugins_loaded',
Init = 'core_init', Init = 'core_init',
Serve = 'core_serve', Serve = 'core_serve',
AppMounted = 'core_on_app_mount', AppMounted = 'core_on_app_mount',
@ -70,6 +71,9 @@ export function createCustomAction(actionName: CoreActions) {
] as const ] as const
} }
export const [doAfterPluginsLoadedAction, onAfterPluginsLoadedAction] =
createCustomAction(CoreActions.AfterPluginsLoaded)
export const [doRequestErrorAction, onRequestErrorAction] = export const [doRequestErrorAction, onRequestErrorAction] =
createCustomActionWithContext<{ createCustomActionWithContext<{
err: Error err: Error