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:
| Plugin | Role |
|---|---|
| npm | Discover npm/pnpm/yarn workspace packages |
const paper = tegami({
npm: {
updateLockFile: true,
},
});Other plugins are opt-in, add them to the plugins array:
| Plugin | Role |
|---|---|
| Cargo | Discover Cargo workspace packages and publish to crates.io |
| pip | Discover Python workspace packages and publish to PyPI (@tegami/pip) |
| Dart | Discover Dart pub workspaces and publish to pub.dev (@tegami/dart) |
| Zig | Discover Zig packages from build.zig.zon (@tegami/zig) |
| Ruby | Discover Ruby gems and publish to RubyGems (@tegami/gem) |
| Composer | Discover Composer packages and tag releases for Packagist (@tegami/composer) |
| NuGet | Discover .NET projects and publish to NuGet (@tegami/nuget) |
| Elixir | Discover Mix projects and publish to Hex (@tegami/hex) |
| Maven | Discover Maven modules and publish to Maven Central (@tegami/maven) |
| Gradle | Discover Gradle projects and publish to Maven Central (@tegami/gradle) |
| Swift | Discover Swift packages and publish via git tags (@tegami/swift) |
| Go | Discover Go modules and publish via git tags |
| git | Create git tags after publishing |
| GitHub | Version Packages PRs and GitHub releases |
| GitLab | Version 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" })],
});