Skip to content

Authoring powerups

This page will guide you through the process of creating your first powerup

The first step is to create the powerup package. This is done using the pup create command.

Terminal window
pup create hello-world \
--description="Creates a hello world script" \
--variables=name \
--type=single-use

This creates:

~/.powerups/installed/_internal/hello-world/
├── index.ts # the instructions file
├── package.json
├── tsconfig.json
├── .gitignore
└── scripts
└── create-github-repo.sh

By default the instructions file is mapped to index.ts, this is done in the package.json’s powerup/instructions property.

{
"name": "hello-world",
// ...
"powerup": {
"instructions": "index.ts" // <-- Here
}
}
import { defineInstructions, type Instructions } from "@liolocs/powerups-sdk";
const instructions: Instructions = {
name: "hello-world",
type: "single-use",
description: "Creates a hello world script",
variables: {
required: ["name"],
optional: [],
},
intent: [
"create a hello world script",
],
steps: [
{
type: "create",
name: "hello-world.ts",
template: "templates/hello-world.ts",
outputPath: "hello-world.ts",
},
],
};
export default defineInstructions(instructions, import.meta.url); // <-- Required

The defined steps in the file are executed when running pup use.

E.G. Running the command

Terminal window
pup use hello-world --name="world"

This will create a file called hello-world.ts in the root of the folder it is run from.

The template is the file that will be used to create the instructions file. It is a file that is rendered by the cli.

templates/hello-world.ts
export default function(variables: Record<string, string>): string {
const { name } = variables;
return `console.log("Hello ${name}!");`;
}

You must build the powerup before it can be used with the command:

Terminal window
pup build

This will run a verification on the instructions file and create a dist folder containing the necessary files for the powerup to be used.

Once the powerup is built you can use it by running the following command:

Terminal window
pup use hello-world --name=world

Once the powerup is built you can share by publishing it to npm or git.

To publish the powerup to npm run:

Terminal window
npm publish

You may use the conventional commits preset to generate the changelog.

Users will then be able to install the powerup by running:

Terminal window
pup install npm:hello-world

To publish the powerup to git simply push the package to a git repo.

You may run the following script to create a github repo using the gh cli and push the package to it.

Terminal window
./scripts/create-github-repo.sh

Users will then be able to install the powerup by running:

Terminal window
pup install git:github.com/<owner>/hello-world