pockethost 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # pockethost
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 40bbb3c: Improve tryFetch by accepting node-fetch params
8
+ - 12f029a: Add changeset maker
9
+ - b7277cf: Add public instance URL calculators and refactor HTTP protocol detection
10
+ - 45a8f45: Add internal app (remote control) support
11
+ - 55b43a1: Remove unneeded params from GetOrProvisionInstanceUrl filter
12
+ - 5be2c9e: Initial commit
13
+ - a236f3e: Added several more filters
14
+ - 35edc77: Enhancement: actions execute sequentially
15
+ - 879845a: Enhancement: unsubscribe from filters
16
+ - c473ed9: Added support for priorities in actions
17
+ - 795fcd7: New action: KillInstance
18
+ - c32b845: Added support for Settings filter whereby all settings are collected and displayed in DEBUG() mode
19
+ - cce72b3: New action: AfterPluginsLoaded
20
+ - 82dde2d: Enhancement: filters now have extensible data types
21
+
22
+ ### Patch Changes
23
+
24
+ - b55c585: Clean up dead code
25
+ - 0e4bf43: Updated commit parser deps
26
+ - f79b067: Added serve command details
27
+ - dd3ceaa: Added filter debugging
28
+ - 7931204: Fixed a bug where adding plugins was not saved correctly
29
+ - 6e14f57: Updated plugin authoring guide
30
+ - 7604930: Minor fix to GetOrProvisionInstanceUrl filter
31
+ - 52b70cb: Fixed bug where --extra-plugins was not defaulting to '' correctly
32
+ - Updated dependencies [c32b845]
33
+ - @pockethost/plugin-launcher-spawn@1.0.0
34
+ - @pockethost/plugin-auto-admin@1.0.0
35
+ - @pockethost/plugin-console-logger@1.0.0
36
+
37
+ ## 1.5.0
38
+
39
+ ### Minor Changes
40
+
41
+ - 5e9ed51: Added `--extra-plugins` global switch to temporarily load extra plugins from CLI
42
+ - 2376b0d: Add InstanceConfig filter, fix instance logger namespace, add core instance app lib
43
+ - 737b4b8: logSettings now exported from core
44
+ - 114b1d2: Add namespace() export to core Logger service
45
+
46
+ ### Patch Changes
47
+
48
+ - 211fba6: Plugin authoring docs update
49
+ - 675e634: Added docs and updated maildev with plugin hook guards
50
+ - 3daf7f5: Fix: [INFO] logging prefixes
51
+ - 139468f: Updated documentation
52
+ - 1e5321b: Fix: improve plugin loading order
53
+ - Updated dependencies [517f602]
54
+ - @pockethost/plugin-launcher-spawn@0.3.0
55
+ - @pockethost/plugin-console-logger@0.2.1
56
+ - @pockethost/plugin-auto-admin@0.1.1
57
+
3
58
  ## 1.4.0
4
59
 
5
60
  ### Minor Changes
package/changesetx.ts ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env tsx
2
+ import { execSync } from 'child_process'
3
+ import { sync } from 'conventional-commits-parser'
4
+ import fs, { readFileSync } from 'fs'
5
+ import minimist from 'minimist'
6
+ import { dirname, join } from 'path'
7
+ import { fileURLToPath } from 'url'
8
+
9
+ const __dirname = dirname(fileURLToPath(import.meta.url))
10
+ const repoRootDir = join(__dirname, `../..`)
11
+
12
+ const argv = minimist(process.argv.slice(2))
13
+ const commitMessage = argv._[0]!
14
+ const { type, subject } = sync(commitMessage)
15
+ if (!type) {
16
+ console.log('Invalid commit message type')
17
+ process.exit(1)
18
+ }
19
+
20
+ function getStagedPackageNames(filePaths: string[]): string[] {
21
+ const packageNames = new Set<string>()
22
+
23
+ filePaths.forEach((filePath) => {
24
+ const packageName = getPackageName(filePath)
25
+ if (packageName) {
26
+ packageNames.add(packageName)
27
+ }
28
+ })
29
+
30
+ return Array.from(packageNames)
31
+ }
32
+
33
+ function getPackageName(filePath: string): string | null {
34
+ const packagePath = filePath.split('/').slice(0, 2).join('/')
35
+ const packageJsonPath = join(repoRootDir, `${packagePath}/package.json`)
36
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
37
+ try {
38
+ return packageJson.name
39
+ } catch (error) {
40
+ return null
41
+ }
42
+ }
43
+
44
+ function getStagedFileNames(): string[] {
45
+ const output = execSync('git diff --name-only --cached').toString()
46
+ const fileNames = output
47
+ .trim()
48
+ .split('\n')
49
+ .filter((fileName) => fileName.startsWith(`packages/`))
50
+ return fileNames
51
+ }
52
+
53
+ async function createChangesetFile() {
54
+ const fileNames = getStagedFileNames()
55
+ const packageNames = getStagedPackageNames(fileNames)
56
+
57
+ if (packageNames.length === 0) {
58
+ console.log('No packages staged for commit')
59
+ process.exit(0)
60
+ }
61
+ console.log('Staged packages:', packageNames)
62
+
63
+ const prefixMap = {
64
+ feat: 'minor',
65
+ enh: 'minor',
66
+ fix: 'patch',
67
+ docs: 'patch',
68
+ chore: 'patch',
69
+ } as const
70
+
71
+ if (!(type! in prefixMap)) {
72
+ console.log('Invalid prefix found in commit message')
73
+ process.exit(1)
74
+ }
75
+
76
+ const versionType = prefixMap[type as keyof typeof prefixMap]
77
+
78
+ const changesetFile = [
79
+ `---`,
80
+ ...packageNames.map((packageName) => `'${packageName}': ${versionType}`),
81
+ `---`,
82
+ ``,
83
+ subject,
84
+ ].join('\n')
85
+ return changesetFile
86
+ }
87
+
88
+ async function writeChangesetFile(changesetFile: string) {
89
+ const filePath = join(repoRootDir, `.changeset`, `${+new Date()}.md`)
90
+ try {
91
+ fs.writeFileSync(filePath, changesetFile)
92
+ console.log(`Changeset file written successfully at ${filePath}`)
93
+ execSync(`git add ${filePath}`)
94
+ console.log(`Changeset file added to git`)
95
+ } catch (error) {
96
+ console.error(`Error writing changeset file: ${error}`)
97
+ }
98
+ }
99
+
100
+ function commit() {
101
+ execSync(`git commit -m "${commitMessage}"`)
102
+ }
103
+
104
+ async function main() {
105
+ const changesetFile = await createChangesetFile()
106
+ await writeChangesetFile(changesetFile)
107
+ commit()
108
+ }
109
+
110
+ main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pockethost",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "author": {
5
5
  "name": "Ben Allfree",
6
6
  "url": "https://github.com/benallfree"
@@ -26,8 +26,10 @@
26
26
  "express-async-errors": "^3.1.1",
27
27
  "get-port": "^6.1.2",
28
28
  "http-proxy": "^1.18.1",
29
+ "immer": "^10.1.1",
29
30
  "json-stringify-safe": "^5.0.1",
30
31
  "listr2": "^8.2.3",
32
+ "minimist": "^1.2.8",
31
33
  "nanoid": "^5.0.2",
32
34
  "node-fetch": "^3.3.2",
33
35
  "pocketbase": "^0.21.3",
@@ -39,18 +41,22 @@
39
41
  "typescript": "^5.4.5",
40
42
  "update-notifier": "^7.0.0",
41
43
  "url-pattern": "^1.0.3",
42
- "@pockethost/plugin-console-logger": "^0.2.0",
43
- "@pockethost/plugin-auto-admin": "^0.1.0",
44
- "@pockethost/plugin-launcher-spawn": "^0.2.0"
44
+ "@pockethost/plugin-launcher-spawn": "^0.4.0",
45
+ "@pockethost/plugin-console-logger": "^0.3.0",
46
+ "@pockethost/plugin-auto-admin": "^0.2.0"
45
47
  },
46
48
  "devDependencies": {
49
+ "@types/conventional-commits-parser": "^5.0.0",
47
50
  "@types/express": "^4.17.21",
48
51
  "@types/http-proxy": "^1.17.13",
52
+ "@types/inquirer": "^9.0.7",
49
53
  "@types/json-stringify-safe": "^5.0.2",
54
+ "@types/minimist": "^1.2.5",
50
55
  "@types/node": "^20.8.10",
51
56
  "@types/semver": "^7.5.4",
52
57
  "@types/tmp": "^0.2.5",
53
- "@types/update-notifier": "^6.0.8"
58
+ "@types/update-notifier": "^6.0.8",
59
+ "conventional-commits-parser": "^5.0.0"
54
60
  },
55
61
  "scripts": {
56
62
  "check-types": "tsc --noEmit ",
package/readme.md CHANGED
@@ -10,21 +10,75 @@ Extend PocketHost with its Plugin ecosystem. Start with the bare-bones dev serve
10
10
 
11
11
  ---
12
12
 
13
+ <!-- @import "[TOC]" {cmd="toc" depthFrom=2 depthTo=2 orderedList=false} -->
14
+
15
+ <!-- code_chunk_output -->
16
+
17
+ - [Quickstart](#quickstart)
18
+ - [Introduction](#introduction)
19
+ - [The magic `serve` command](#the-magic-serve-command)
20
+ - [Configuration](#configuration)
21
+ - [Plugins Directory](#plugins-directory)
22
+ - [Writing Plugins](#writing-plugins)
23
+ - [Support](#support)
24
+
25
+ <!-- /code_chunk_output -->
26
+
27
+ ---
28
+
13
29
  ## Quickstart
14
30
 
15
31
  ```
16
32
  npx pockethost serve
17
33
  ```
18
34
 
35
+ ## Introduction
36
+
37
+ PocketHost is a multitenant PocketBase hosting system. With it, you can run multiple instances of PocketBase on different subdomains, all on the same server.
38
+
39
+ Use PocketHost for development or production purposes.
40
+
41
+ PocketHost can be easily extended using its thoughtful plugin architecture. By choosing additional plugins, PocketHost's features can be extended according to your exact needs. You can even write your own plugins.
42
+
43
+ ## The magic `serve` command
44
+
45
+ `pockethost serve` is a special command that can be decorated with plugins. Plugins can respond to the `serve` command by running their own services.
46
+
47
+ By convention, plugins that have some kind of `serve` functionality such as running a server, will make it available in two ways.
48
+
49
+ The first way runs ONLY the plugin's `serve` functionality:
50
+
51
+ ```bash
52
+ pockethost <plugin-name> serve
53
+ ```
54
+
55
+ The second way runs ALL `serve` functionality from ALL plugins:
56
+
57
+ ```bash
58
+ pockethost serve
59
+ ```
60
+
61
+ The exact plugins can also be narrowed:
62
+
63
+ ```bash
64
+ pockethost serve --only=plugin1,plugin2,plugin3
65
+ ```
66
+
67
+ See the plugin authoring guide for more information on how to make a plugin that responds to both methods.
68
+
19
69
  ## Configuration
20
70
 
21
- PocketHost supports configuration by environment variable. All PocketHost environment variables begin with `PH_`.
71
+ PocketHost supports configuration by environment variable, `.env` file, and also built-in settings via `pockethost config`.
72
+
73
+ All PocketHost variables begin with `PH_`.
22
74
 
23
75
  PocketHost will search the current directory for an `.env` when it loads. Anything in `.env` will be merged with and override any `<PH_HOME>/.env` that may exist.
24
76
 
25
- Use `pockethost config` to set global defaults stored in `<PH_HOME>/.env`.
77
+ Use `pockethost config` to list and set global defaults.
26
78
 
27
- ### Variables
79
+ ### Core Variables
80
+
81
+ See `pockethost config ls` for a full list of variables. Plugin variables will also be listed for loaded plugins.
28
82
 
29
83
  | Name | Default | Discussion |
30
84
  | -------------- | -------------------------- | ----------------------------------------------------------------------------- |
@@ -42,28 +96,32 @@ Use `pockethost config` to set global defaults stored in `<PH_HOME>/.env`.
42
96
  - `@pockethost/plugin-launcher-spawn`
43
97
  - `@pockethost/plugin-auto-admin`
44
98
 
45
- ## Plugins
99
+ ## Plugins Directory
100
+
101
+ PocketHost uses an action/filter architecture to support a growing list plugins. Some plugins have a CLI component, whereas others add purely programmatic support to alter how PocketHost works.
46
102
 
47
- PocketHost uses a hook architecture and features a growing list plugins. Some plugins have a CLI component, whereas others add purely programmatic support to alter how PocketHost works:
103
+ ### Core plugins
48
104
 
49
- Current plugins:
105
+ These plugins are maintained by the PocketHost project.
50
106
 
51
- | name | description |
52
- | --------------------- | ------------------------------------------------------------------------------------------------- |
53
- | plugin-console-logger | Routes log messages to the console |
54
- | plugin-auto-admin | Auto-creates a default admin account on instance launch |
55
- | plugin-launcher-spawn | Launches PocketBase instances via `spawn()` on the local machine. PocketHost uses this by default |
107
+ | Name | Description |
108
+ | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
109
+ | `@pockethost/plugin-console-logger` | Routes log messages to the console |
110
+ | `@pockethost/plugin-auto-admin` | Auto-creates a default admin account on instance launch |
111
+ | `@pockethost/plugin-launcher-spawn` | Launches PocketBase instances via `spawn()` on the local machine. PocketHost uses this by default |
112
+ | `@pockethost/plugin-cloudflare-request-logger` | Log additional data when running behind Cloudflare |
113
+ | `@pockethost/plugin-ftp-server` | Used to provide secure FTPS access to PocketBase instance data. This FTP server can run along-side a PocketHost server. |
56
114
 
57
115
  Coming soon:
58
116
  | name | description |
59
117
  | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
60
- | plugin-ftp-server | Used to provide secure FTPS access to PocketBase instance data. This FTP server can run along-side a PocketHost server. |
61
118
  | plugin-launcher-docker | Launches PocketBase instances via Docker. This is useful for running untrusted PocketBase code and instances. pockethost.io uses this. |
62
119
  | plugin-waf | A Web Application Firewall |
63
- | plugin-waf-enforce-ssl | Enforce SSL at the
64
- WAF
120
+ | plugin-waf-enforce-ssl | Enforce SSL at the WAF
121
+
122
+ ## Writing Plugins
65
123
 
66
- See the [Plugin Authoring Guide](https://github.com/pockethost/pockethost/blob/master/packages/pockethost/plugin-guide.md) for details about what hooks and filters are available.
124
+ See the [Plugin Authoring Guide](https://github.com/pockethost/pockethost/blob/master/packages/pockethost/plugin-guide.md) for details about how to write your own plugins.
67
125
 
68
126
  ## Support
69
127
 
@@ -1,20 +1,5 @@
1
- import { forEach, keys, omit } from '@s-libs/micro-dash'
2
1
  import { Command } from 'commander'
3
- import { parse } from 'dotenv'
4
- import { existsSync, readFileSync, writeFileSync } from 'fs'
5
- import { info } from '../..'
6
- import { PH_HOME, isSettingKey, settings } from '../../../constants'
7
-
8
- const envFile = () => {
9
- const envFile = PH_HOME(`.env`)
10
- if (!existsSync(envFile)) {
11
- writeFileSync(envFile, '')
12
- }
13
- return envFile
14
- }
15
-
16
- const _parse = () =>
17
- parse(readFileSync(envFile(), { encoding: 'utf8' }).toString())
2
+ import { listConfig, setConfig, unsetConfig } from '../../../core'
18
3
 
19
4
  export const ConfigCommand = () => {
20
5
  const cmd = new Command(`config`)
@@ -24,76 +9,20 @@ export const ConfigCommand = () => {
24
9
  .argument(`<name>`, `Config name`)
25
10
  .argument(`<value>`, `Config value`)
26
11
  .description(`Set a config value`)
27
- .action((name, value) => {
28
- if (!isSettingKey(name))
29
- throw new Error(`Invalid setting name ${name}`)
30
-
31
- if (value === '=') throw new Error(`Invalid value ${value}`)
32
-
33
- const values = _parse()
34
- values[name] = value
35
- writeFileSync(
36
- envFile(),
37
- Object.entries(values)
38
- .map(([k, v]) => `${k}=${v}`)
39
- .join('\n'),
40
- )
41
- info(`Set ${name}=${value}`)
42
- info(`Written to ${envFile()}`)
43
- }),
12
+ .action(setConfig),
44
13
  )
45
14
 
46
15
  .addCommand(
47
16
  new Command(`unset`)
48
17
  .argument(`<name>`, `Config name`)
49
18
  .description(`Unset a config value`)
50
- .action((name) => {
51
- if (!isSettingKey(name))
52
- throw new Error(`Invalid setting name ${name}`)
53
-
54
- const values = _parse()
55
- delete values[name]
56
- writeFileSync(
57
- envFile(),
58
- Object.entries(values)
59
- .map(([k, v]) => `${k}=${v}`)
60
- .join('\n'),
61
- )
62
- info(`Unset ${name}`)
63
- info(`Written to ${envFile()}`)
64
- }),
19
+ .action(unsetConfig),
65
20
  )
66
21
  .addCommand(
67
22
  new Command(`list`)
68
23
  .description(`List all config values`)
69
24
  .alias(`ls`)
70
- .action(() => {
71
- const values = _parse()
72
-
73
- if (keys(values).length > 0) {
74
- info()
75
- info(`Config values from ${envFile()}:`)
76
- forEach(values, (v, k) => {
77
- info(`\t${k}=${v}`)
78
- })
79
- info()
80
- } else {
81
- info(`No config values found in ${envFile()}`)
82
- }
83
-
84
- const defaults = omit(settings, keys(values) as any)
85
- if (keys(defaults).length > 0) {
86
- info(`Default values:`)
87
- forEach(settings, (v, k) => {
88
- if (k in values) return
89
- info(`\t${k}=${v}`)
90
- })
91
- } else {
92
- info(
93
- `No default values because all values are defined in ${envFile()}`,
94
- )
95
- }
96
- }),
25
+ .action(listConfig),
97
26
  )
98
27
  return cmd
99
28
  }
@@ -1,22 +1,10 @@
1
- import { uniq } from '@s-libs/micro-dash'
2
1
  import { Command } from 'commander'
3
- import { parse } from 'dotenv'
4
- import { existsSync, readFileSync, writeFileSync } from 'fs'
2
+ import { readFileSync } from 'fs'
5
3
  import { error, info } from '../..'
6
- import { PH_HOME, PH_PLUGINS, PH_PROJECT_DIR } from '../../../constants'
4
+ import { PH_PLUGINS, PH_PROJECT_DIR } from '../../../constants'
5
+ import { appendConfig, filterConfig } from '../../../core'
7
6
  import { getCompatibleVersions, getPackageJson, removePackage } from './util'
8
7
 
9
- const envFile = () => {
10
- const envFile = PH_HOME(`.env`)
11
- if (!existsSync(envFile)) {
12
- writeFileSync(envFile, '')
13
- }
14
- return envFile
15
- }
16
-
17
- const _parse = () =>
18
- parse(readFileSync(envFile(), { encoding: 'utf8' }).toString())
19
-
20
8
  export const PluginCommand = () => {
21
9
  const cmd = new Command(`plugin`)
22
10
  .description(`Manage PocketHost plugins`)
@@ -33,22 +21,7 @@ export const PluginCommand = () => {
33
21
  const { version } = pkg
34
22
  await getCompatibleVersions(`pockethost`, version, [name])
35
23
 
36
- const values = _parse()
37
- values[`PH_PLUGINS`] = uniq([
38
- ...(values[`PH_PLUGINS`]
39
- ?.split(/,/)
40
- .map((v) => v.trim())
41
- .filter((v) => !!v) || []),
42
- name,
43
- ]).join(`,`)
44
- writeFileSync(
45
- envFile(),
46
- Object.entries(values)
47
- .map(([k, v]) => `${k}=${v}`)
48
- .join('\n'),
49
- )
50
- info(`Installed ${name}`)
51
- info(`Written to ${envFile()}`)
24
+ appendConfig(`PH_PLUGINS`, name)
52
25
  } catch (e) {
53
26
  error(`${e}`)
54
27
  }
@@ -81,21 +54,7 @@ export const PluginCommand = () => {
81
54
  .action(async (name) => {
82
55
  try {
83
56
  await removePackage(name)
84
- const values = _parse()
85
- values[`PH_PLUGINS`] = uniq([
86
- ...(values[`PH_PLUGINS`]
87
- ?.split(/,/)
88
- .map((v) => v.trim())
89
- .filter((v) => v !== name) || []),
90
- ]).join(`,`)
91
- writeFileSync(
92
- envFile(),
93
- Object.entries(values)
94
- .map(([k, v]) => `${k}=${v}`)
95
- .join('\n'),
96
- )
97
- info(`Removed ${name}`)
98
- info(`Written to ${envFile()}`)
57
+ filterConfig(`PH_PLUGINS`, name)
99
58
  } catch (e) {
100
59
  error(`${e}`)
101
60
  }
@@ -6,7 +6,7 @@ import {
6
6
  } from '../../../common'
7
7
 
8
8
  type Options = {
9
- isolate: boolean
9
+ only: string[]
10
10
  }
11
11
 
12
12
  export const ServeCommand = async () => {
@@ -24,12 +24,13 @@ export const ServeCommand = async () => {
24
24
  .filter((s) => serveSlugs.includes(s)),
25
25
  serveSlugs,
26
26
  )
27
- .action(async (options: Options) => {
27
+ .action(async (options: Options, cmd: Command) => {
28
28
  const logger = LoggerService().create(`ServeCommand`)
29
29
  const { dbg, error, info, warn } = logger
30
30
  info(`Starting`)
31
31
 
32
- await doServeAction({ only: serveSlugs })
32
+ const { only } = options
33
+ await doServeAction({ only })
33
34
  })
34
35
  return cmd
35
36
  }
package/src/cli/index.ts CHANGED
@@ -3,16 +3,18 @@
3
3
  import { uniq } from '@s-libs/micro-dash'
4
4
  import { program } from 'commander'
5
5
  import { readFileSync } from 'fs'
6
+ import minimist from 'minimist'
6
7
  import updateNotifier from 'update-notifier'
7
8
  import { PH_PLUGINS, PH_PROJECT_DIR } from '../../core'
8
9
  import {
9
10
  DEBUG,
10
11
  LogLevelName,
11
12
  LoggerService,
13
+ doAfterPluginsLoadedAction,
12
14
  doCliCommandsFilter,
13
15
  loadPlugins,
14
16
  } from '../common'
15
- import { pockethost } from '../server'
17
+ import { pockethost } from '../plugin'
16
18
  import { ConfigCommand } from './commands/ConfigCommand'
17
19
  import { PluginCommand } from './commands/PluginCommand'
18
20
  import { ServeCommand } from './commands/ServeCommand'
@@ -21,9 +23,11 @@ export const { dbg, info, error } = LoggerService({
21
23
  level: DEBUG() ? LogLevelName.Debug : LogLevelName.Info,
22
24
  })
23
25
 
24
- export const main = async () => {
25
- await loadPlugins([pockethost, ...uniq(PH_PLUGINS())])
26
+ export type GlobalOptions = {
27
+ extraPlugins: string[]
28
+ }
26
29
 
30
+ export const main = async () => {
27
31
  const pkg = await JSON.parse(
28
32
  readFileSync(PH_PROJECT_DIR(`package.json`), 'utf8').toString(),
29
33
  )
@@ -31,10 +35,24 @@ export const main = async () => {
31
35
 
32
36
  const { version } = pkg
33
37
 
38
+ const argv = minimist<{ e: string }>(process.argv.slice(2), {
39
+ alias: { e: 'extra-plugins' },
40
+ default: { e: '' },
41
+ })
42
+ const extraPlugins = argv.e
43
+ .split(/,/)
44
+ .map((s) => s.trim())
45
+ .filter((v) => !!v)
46
+
47
+ await loadPlugins([pockethost, ...uniq(PH_PLUGINS()), ...extraPlugins])
48
+
49
+ await doAfterPluginsLoadedAction()
50
+
34
51
  program
35
52
  .name('pockethost')
36
53
  .description('Multitenant PocketBase hosting')
37
54
  .version(version)
55
+ .option(`-e, --extra-plugins <plugins...>`, `Extra plugins to load`, [])
38
56
 
39
57
  const commands = await doCliCommandsFilter([
40
58
  await ServeCommand(),
@@ -53,6 +53,12 @@ export const LogLevels = {
53
53
  [LogLevelName.Abort]: 6,
54
54
  } as const
55
55
 
56
+ export const namespace = (...names: string[]) =>
57
+ names
58
+ .filter((v) => !!v)
59
+ .map((p) => `[${p}]`)
60
+ .join(' ')
61
+
56
62
  export const createLogger = (config: Partial<LoggerConfig>) => {
57
63
  const _config = mergeConfig<LoggerConfig>(
58
64
  {
@@ -67,11 +73,7 @@ export const createLogger = (config: Partial<LoggerConfig>) => {
67
73
  _config.level = level
68
74
  }
69
75
 
70
- const _pfx = (s: string) =>
71
- [s, ...pfx]
72
- .filter((v) => !!v)
73
- .map((p) => `[${p}]`)
74
- .join(' ')
76
+ const _pfx = (s: string) => namespace(s, ...pfx)
75
77
 
76
78
  const _log = (levelIn: LogLevelName, ...args: any[]) => {
77
79
  doLogAction({
@@ -96,7 +98,7 @@ export const createLogger = (config: Partial<LoggerConfig>) => {
96
98
  const info = (...args: any[]) => {
97
99
  const _args = (() => {
98
100
  if (isLevelGt(LogLevelName.Info, _config.level)) {
99
- return [chalk.gray(`INFO`), ...args]
101
+ return [_pfx(chalk.gray(`INFO`)), ...args]
100
102
  }
101
103
  return [...args]
102
104
  })()