Skip to main content
Home

@pup/plugin@1.0.1
Built and signed on GitHub Actions

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
a year ago (1.0.1)

# @pup/plugin

Purpose:

The cornerstone for developing custom Pup plugins. Full documentation on creating plugins are available at https://pup.56k.guru/examples/plugins/readme/

Usage

Install the @pup/plugin and @pup/api-client packages within your plugin project:

deno add @pup/plugin @pup/api-client

Then, extend the provided base classes and implement the necessary interfaces to define your plugin's specific functionality.

Minimal example:

import { PupPluginImplementation } from "@pup/plugin";
import { PupRestClient } from "@pup/api-client";

export class PupPlugin extends PupPluginImplementation {
  private client: PupRestClient;

  constructor(
    config: PupPluginConfiguration,
    apiUrl: string,
    apiToken: string,
  ) {
    super(config, apiUrl, apiToken);

    // Setup the Pup rest client using the automatically supplied credentials
    this.client = new PupRestClient(apiUrl, apiToken);

    // Plugin identification metadata
    this.meta = {
      name: "My Custom Plugin",
      version: "1.0.0",
      api: "1.0.0", // The used version of @pup/plugin - for compatibility check
      repository: "https://github.com/my-user-or-org/my-pup-plugin",
    };
  }

  // Example usage of PupRestClient within your plugin:
  async fetchProcessData(): Promise<ApiProcessData[]> {
    const response = await this.client.getProcesses();

    if (response.status === 200) {
      return response.data;
    } else {
      throw new Error(`Failed to fetch process data: ${response.status}`);
    }
  }

  // ... other plugin logic here
}

License

This package is released under the MIT License. See LICENSE for details.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@pup/plugin

Import symbol

import * as plugin from "@pup/plugin";
or

Import directly with a jsr specifier

import * as plugin from "jsr:@pup/plugin";

Add Package

pnpm i jsr:@pup/plugin
or (using pnpm 10.8 or older)
pnpm dlx jsr add @pup/plugin

Import symbol

import * as plugin from "@pup/plugin";

Add Package

yarn add jsr:@pup/plugin
or (using Yarn 4.8 or older)
yarn dlx jsr add @pup/plugin

Import symbol

import * as plugin from "@pup/plugin";

Add Package

vlt install jsr:@pup/plugin

Import symbol

import * as plugin from "@pup/plugin";

Add Package

npx jsr add @pup/plugin

Import symbol

import * as plugin from "@pup/plugin";

Add Package

bunx jsr add @pup/plugin

Import symbol

import * as plugin from "@pup/plugin";