### Pocodex CLI Usage with Bun Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/notes.md Commands for managing Pocodex plugins using the Bun runtime, including installation, watching for changes, building, initializing, and updating plugins. ```Bun Shell bun add -D pocodex bunx pocodex watch bunx pocodex build bunx pocodex init bunx pocodex update ``` -------------------------------- ### Specify Files for Plugin Deployment (TypeScript) Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Explains how to define files that should be copied during plugin installation using the `files()` method. The example demonstrates importing a file (e.g., `config.txt`) and mapping it to a specific destination path within the plugin's deployed structure. ```typescript import configFile from './config.txt' export default definePlugin(() => { return { files() { return { 'config/config.txt': configFile, } }, } }) ``` -------------------------------- ### Start Development Server with Live Reloading Source: https://github.com/benallfree/pocodex/blob/main/docs/README.md This command serves your app in development mode, allowing you to see changes in real-time as you build and style your application. ```bash bunx dev ``` -------------------------------- ### Install PocketPages App with Tailwind CSS and DaisyUI Template Source: https://github.com/benallfree/pocodex/blob/main/docs/README.md This command sets up a new PocketPages project in the 'myapp' directory, pre-configured with Tailwind CSS and DaisyUI. ```bash bunx pocketpages new myapp --template=daisyui-docs ``` -------------------------------- ### Install degit Globally via npm Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md If the `degit` utility is not already installed, this command provides a way to install it globally using npm. `degit` is necessary for cloning the pocodex starter kit efficiently. ```bash npm install -g degit ``` -------------------------------- ### Install a Specific pocodex Plugin Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Installs a specified plugin into your PocketBase setup. Replace `` with the actual plugin name. Commands can be run directly or under the `pocodex` namespace. ```bash pocketbase install # or pocketbase pocodex install ``` -------------------------------- ### PocketBase CLI Plugin Management Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/notes.md Standard PocketBase CLI commands for managing plugins, such as installing, enabling, disabling, and uninstalling them within a PocketBase instance. ```Shell pocketbase install [plugin_name] pocketbase enable [plugin_name] pocketbase disable [plugin_name] pocketbase uninstall [plugin_name] ``` -------------------------------- ### Implement Plugin Lifecycle Methods with Dao Access Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md This example demonstrates how the `dao: daos.Dao` instance is passed as a parameter to plugin lifecycle methods like `install` and `uninstall`. This design allows plugin functions to perform database operations safely within the context of a transaction, ensuring data integrity. ```typescript export default definePlugin((config: PluginConfig) => { return { install(dao: daos.Dao) { // Perform installation logic using the dao instance }, uninstall(dao: daos.Dao) { // Perform uninstallation logic using the dao instance }, } }) ``` -------------------------------- ### Install pocodex CLI Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md This command initializes the pocodex CLI, setting up the necessary environment for plugin management. The `--trust` flag is used for trusting the installation. ```bash bunx pocodex init --trust ``` -------------------------------- ### Access PocketBase Binary Installed by PocketPages Source: https://github.com/benallfree/pocodex/blob/main/docs/README.md This command provides direct access to the PocketBase version installed by PocketPages, allowing you to perform low-level PocketBase operations when needed. ```bash bunx pocketbase ``` -------------------------------- ### Utilize Plugin Logging Utility (TypeScript) Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Shows how to integrate logging into a plugin using `config.log`. This example demonstrates calling `config.log.info()` within the `init()` method, providing a standard way to output informational messages during plugin lifecycle events. ```typescript export default definePlugin((config: PluginConfig) => { return { init() { config.log.info('Plugin initialized') }, } }) ``` -------------------------------- ### List Installed pocodex Plugins Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Shows a list of plugins currently installed in your PocketBase environment. Commands can be run directly or under the `pocodex` namespace for convenience. ```bash pocketbase list # or pocketbase pocodex list ``` -------------------------------- ### Clone pocodex Minimal Starter Kit using npx Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md As an alternative to global installation, this command uses `npx` to execute `degit` directly, cloning the pocodex minimal starter kit. This method avoids polluting the global npm package space. ```bash npx degit benallfree/pocodex/starters/minimal my-plugin ``` -------------------------------- ### APIDOC: Plugin Object Type Definition Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Defines the `Plugin` object type, which specifies the optional lifecycle methods and configurations for a pocodex plugin. These methods include `init`, `install`, `uninstall` for lifecycle management, `files` for file copying, and `migrations` for database schema changes. ```APIDOC export type Plugin = { init?(dao: daos.Dao): void install?(dao: daos.Dao): void uninstall?(dao: daos.Dao): void files?(): Record migrations?(): { [migrationName: string]: MigrationSet } } ``` -------------------------------- ### Define Plugin with Single File Copy using `files()` Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/files.md This example demonstrates how to use the `definePlugin` factory function and its `files()` method to specify a single file (`myfile.txt`) to be copied to a destination path upon plugin installation. It shows importing the file content and mapping it to a target path. ```typescript // src/plugin.ts import myFileContent from './assets/myfile.txt' export default definePlugin((api) => { return { // ...other plugin metadata files() { return { 'path/to/destination/myfile.txt': myFileContent, // Add more files as needed } }, } }) ``` -------------------------------- ### Start pocodex Development Server with Live Reload Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md This command initiates a PocketBase development server, which is configured to automatically reload the pocodex plugin whenever its source code is updated. This facilitates a smooth and efficient development workflow. ```bash bun run dev ``` -------------------------------- ### Publish pocodex Plugin to npm Registry Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md After building the plugin, this command publishes the package to the npm registry. This makes the pocodex plugin publicly available for installation and use by other developers. ```bash npm publish ``` -------------------------------- ### Install pocodex via npm, yarn, pnpm, or bun Source: https://github.com/benallfree/pocodex/blob/main/README.md These commands demonstrate how to install the pocodex package using various JavaScript package managers like npm, yarn, pnpm, and bun. Choose the command corresponding to your preferred package manager. ```bash npm i pocodex yarn add pocodex pnpm add pocodex bun add pocodex --trust ``` -------------------------------- ### Pocodex Settings Store API Reference Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/notes.md Overview of different storage mechanisms available within Pocodex plugins, including atomic persistent storage for simple settings and an in-memory cache for thread-safe temporary data. ```APIDOC store(key: string, updater: (current_value: any) => any): any Description: Provides simple, atomic, persistent storage for plugin settings. Usage: Ideal for small, non-migratable data that needs to persist across restarts. $app.store(): any Description: Accesses a non-atomic, thread-safe memory cache. Usage: Suitable for temporary, frequently accessed data that doesn't require strict atomicity or persistence across restarts. ``` -------------------------------- ### APIDOC: PluginConfig Type Definition Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Defines the `PluginConfig` type, an object passed to the `PluginFactory` during initialization. It provides essential utilities to the plugin, including `migrate` for database migrations, `log` for logging, and `store` for persistent key-value storage. ```APIDOC export type PluginConfig = { migrate: (up: MigrationFunction, down: MigrationFunction) => MigrationSet log: typeof log store: ( key: string, updater?: SettingsUpdater, creator?: SettingsCreator ) => T | null } ``` -------------------------------- ### Define Pocodex Plugin Structure in plugin.ts Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md This snippet shows the fundamental structure for a `plugin.ts` file. It demonstrates how to use `definePlugin` to default export a `PluginFactory`, which returns a `Plugin` object containing its methods and properties. ```typescript // src/plugin.ts export default definePlugin((config: PluginConfig) => { return { // Plugin methods and properties } }) ``` -------------------------------- ### Define Plugin with Multiple File Copies Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/files.md This example expands on the `files()` function usage, showing how to specify multiple files for copying. It demonstrates importing different content files (`config.txt`, `script.txt`) and mapping each to its respective destination path within the plugin's `files()` return object. ```typescript // src/plugin.ts import configContent from './assets/config.txt' import scriptContent from './assets/script.txt' export default definePlugin((api) => { return { // ...other plugin metadata files() { return { 'config/config.txt': configContent, 'scripts/init.txt': scriptContent, } }, } }) ``` -------------------------------- ### APIDOC: PluginFactory Type Definition Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Defines the `PluginFactory` type, which is a crucial part of the plugin API. This factory function is responsible for receiving a `PluginConfig` object and returning a `Plugin` instance, setting up the plugin's core functionality. ```APIDOC export type PluginFactory = (config: PluginConfig) => Plugin ``` -------------------------------- ### APIDOC: MigrationFunction and MigrationSet Types Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Defines the types used for database migrations within the plugin API. `MigrationFunction` specifies the signature for migration operations, while `MigrationSet` groups the `up` (apply) and `down` (revert) functions for a complete migration unit. ```APIDOC export type MigrationFunction = (db: dbx.Builder) => void export type MigrationSet = { up: MigrationFunction; down: MigrationFunction } ``` -------------------------------- ### Define Database Migrations for Plugin (TypeScript) Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Illustrates the process of defining database migrations within a Pocodex plugin using `config.migrate`. This function accepts `up` and `down` callbacks for applying and reverting schema changes, respectively. A `db` builder object is provided to execute migration commands. ```typescript export default definePlugin((config: PluginConfig) => { return { migrations() { return { create_users_table: config.migrate( (db) => { // Up migration: create table }, (db) => { // Down migration: drop table } ), } }, } }) ``` -------------------------------- ### Store Persistent Data Using config.store with Updater and Creator Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md This snippet illustrates the use of `config.store` for persistent key-value storage. It shows how to provide an `updater` function to modify the current value transactionally (as a mutable draft) and a `creator` function to supply a default value if the key does not yet exist. ```typescript config.store( 'myKey', (draft) => { // Modify the draft as needed draft.someProperty = 'newValue' }, () => ({ // Default value if the key doesn't exist someProperty: 'defaultValue', }) ) ``` -------------------------------- ### Retrieve Configuration Value from Store (TypeScript) Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/api.md Demonstrates how to access a value from the plugin's configuration store using `config.store('key')`. This method returns the current value associated with the key or `null` if it doesn't exist. It highlights that using mutator functions ensures atomic updates and data consistency. ```typescript const value = config.store('myKey') ``` -------------------------------- ### Serve App in Production Mode Source: https://github.com/benallfree/pocodex/blob/main/docs/README.md This command optimizes and serves your app in production mode, ready for deployment. ```bash bunx serve ``` -------------------------------- ### Clone pocodex Minimal Starter Kit with bunx degit Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md This command initializes a new pocodex plugin project by cloning the minimal starter kit from the official repository using `bunx degit`. Users should replace 'my-plugin' with their desired directory name for the new plugin. ```bash bunx degit benallfree/pocodex/starters/minimal my-plugin ``` -------------------------------- ### Access All PocketPages Commands and Tools Source: https://github.com/benallfree/pocodex/blob/main/docs/README.md This gives you access to various PocketPages utilities and commands for managing your application. ```bash bunx pocketpages ``` -------------------------------- ### Build pocodex Plugin for Production Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md This command compiles and bundles the pocodex plugin's source code into a production-ready build. It's a crucial step before publishing or deploying the plugin. ```bash bun run build ``` -------------------------------- ### List All Global pocodex Plugins Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Displays a list of all globally available plugins in the pocodex ecosystem. Commands can be run directly or under the `pocodex` namespace for flexibility. ```bash pocketbase list --global # or pocketbase pocodex list --global ``` -------------------------------- ### Search for pocodex Plugins by Keyword Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Searches for available plugins matching a given keyword. Replace `` with your search term. Commands can be run directly or under the `pocodex` namespace. ```bash pocketbase search # or pocketbase pocodex search ``` -------------------------------- ### Display PocketBase CLI help Source: https://github.com/benallfree/pocodex/blob/main/README.md This command executes the PocketBase CLI with the `--help` flag, which typically displays available commands, options, and general usage information for the PocketBase executable. ```bash pocketbase x --help ``` -------------------------------- ### Watch pocodex Plugin Source Files for Development Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/first-plugin.md During development, this command continuously monitors the plugin's source files for any changes. Upon detecting modifications, it automatically rebuilds the plugin, providing immediate feedback. ```bash bun run watch ``` -------------------------------- ### Importing File Content for Plugin Bundling Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/authoring/files.md This snippet illustrates the standard ES6 import syntax used to bring external file content (e.g., from a `.txt` file) directly into the TypeScript code. This is crucial for ensuring all necessary resources are bundled within the plugin for the isolated Goja execution environment. ```typescript import myFileContent from './assets/myfile.txt' ``` -------------------------------- ### Uninstall a pocodex Plugin Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Removes a specified plugin from your PocketBase environment. Replace `` with the actual plugin name. Commands can be run directly or under the `pocodex` namespace. ```bash pocketbase uninstall # or pocketbase pocodex uninstall ``` -------------------------------- ### Enable a Disabled pocodex Plugin Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Re-enables a plugin that was previously disabled without being uninstalled. Replace `` with the actual plugin name. Commands can be run directly or under the `pocodex` namespace. ```bash pocketbase enable # or pocketbase pocodex enable ``` -------------------------------- ### Disable a pocodex Plugin Source: https://github.com/benallfree/pocodex/blob/main/docs/pb_hooks/pages/(main)/docs/index.md Disables a specified plugin, making it inactive without removing its files. Replace `` with the actual plugin name. Commands can be run directly or under the `pocodex` namespace. ```bash pocketbase disable # or pocketbase pocodex disable ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.