Tegami

Plugins

Extend Tegami with plugins.

Introduction

Plugins hook into Tegami's lifecycle, such as package discovery, versioning, publishing, and CLI commands.

You can add other plugins from config:

import { tegami } from "tegami";

const paper = tegami({
  plugins: [
    {
      name: "my-plugin",
      async init() {
        console.log("init");
      },
    },
  ],
});

Prop

Type

Publish tasks

Publishing runs on a task graph: plugins create tasks from the publishTasks hook, and Tegami runs them concurrently according to their wait / optionalWait relationships.

Task instances are single-use and each package can have at most one PackagePublishTask in a publish graph. Tegami creates a fresh graph for every publish or status check.

  • link(): wire cross-plugin dependencies in a phase once every task exists.
  • status(): report whether its work is already done from a previous run.
import { tegami, PublishTask, PackagePublishTask, type PublishTaskContext } from "tegami";

class AnnounceTask extends PublishTask<void> {
  name = "announce";

  link({ plan }: PublishTaskContext) {
    // run after every package publish
    for (const t of plan.tasks) {
      if (t instanceof PackagePublishTask) this.wait.push(t);
    }
  }

  run() {
    // failed tasks don't block dependents, inspect their outcome with `getResult()`
    for (const task of this.wait) {
      if (task.getResult()?.status === "failed") return;
    }

    console.log("Release published");
  }
}

const paper = tegami({
  plugins: [
    {
      name: "announce",
      publishTasks() {
        return new AnnounceTask();
      },
    },
  ],
});

The package publish task should extend PackagePublishTask; Tegami handles the hook calls and package dependencies automatically.

Built-in plugins

Tegami enables npm support automatically. Configure it through the top-level npm option:

PluginRole
npmDiscover npm/pnpm/yarn workspace packages
const paper = tegami({
  npm: {
    updateLockFile: true,
  },
});

Other plugins are opt-in, add them to the plugins array:

PluginRole
CargoDiscover Cargo workspace packages and publish to crates.io
pipDiscover Python workspace packages and publish to PyPI (@tegami/pip)
DartDiscover Dart pub workspaces and publish to pub.dev (@tegami/dart)
ZigDiscover Zig packages from build.zig.zon (@tegami/zig)
RubyDiscover Ruby gems and publish to RubyGems (@tegami/gem)
ComposerDiscover Composer packages and tag releases for Packagist (@tegami/composer)
NuGetDiscover .NET projects and publish to NuGet (@tegami/nuget)
ElixirDiscover Mix projects and publish to Hex (@tegami/hex)
MavenDiscover Maven modules and publish to Maven Central (@tegami/maven)
GradleDiscover Gradle projects and publish to Maven Central (@tegami/gradle)
SwiftDiscover Swift packages and publish via git tags (@tegami/swift)
GoDiscover Go modules and publish via git tags
gitCreate git tags after publishing
GitHubVersion Packages PRs and GitHub releases
GitLabVersion Packages MRs and GitLab releases
import { cargo } from "tegami/plugins/cargo";
import { github } from "tegami/plugins/github";

const paper = tegami({
  plugins: [cargo(), github({ repo: "your-org/your-repo" })],
});

On this page