Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lucky-runs-projects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

New CLI commands: `projects create/get/rename/delete`, `runs list/get/replay/cancel`, and `env set`
63 changes: 63 additions & 0 deletions docs/cli-env-commands.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: "CLI env set command"
sidebarTitle: "env set"
description: "Use the env set command to create or update an environment variable."
---

import CommonOptions from "/snippets/cli-options-common.mdx";
import ConfigFileOptions from "/snippets/cli-options-config-file.mdx";
import ProjectRefOptions from "/snippets/cli-options-project-ref.mdx";
import BranchOptions from "/snippets/cli-options-branch.mdx";

Sets an environment variable on your project, creating it if it doesn't exist and overwriting the
value if it does.

<CodeGroup>

```bash npm
npx trigger.dev@latest env set MY_VAR my-value
```

```bash pnpm
pnpm dlx trigger.dev@latest env set MY_VAR my-value
```

```bash yarn
yarn dlx trigger.dev@latest env set MY_VAR my-value
```

</CodeGroup>

## Arguments

```
npx trigger.dev@latest env set <name> <value>
```

<ParamField body="Name" type="<name>">
The name of the environment variable.
</ParamField>

<ParamField body="Value" type="<value>">
The value to set.
</ParamField>

## Options

<ParamField body="Secret" type="--secret">
Store the value as a secret, so it can't be read back.
</ParamField>

<ParamField body="Environment" type="--env | -e">
The environment to set the variable in: `prod`, `staging` or `preview`. Defaults to `prod`.
</ParamField>

<ConfigFileOptions />
<ProjectRefOptions />
<BranchOptions />

### Common options

These options are available on most commands.

<CommonOptions />
74 changes: 74 additions & 0 deletions docs/cli-projects-commands.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: "CLI projects commands"
sidebarTitle: "projects"
description: "Use these commands to create, inspect, rename and delete your Trigger.dev projects."
---

import CommonOptions from "/snippets/cli-options-common.mdx";

These commands act on the organizations and projects your account can access, so run
[`login`](/cli-login-commands) first.

## projects create

Creates a project. You are prompted for the organization and name when the options are omitted.

<CodeGroup>

```bash npm
npx trigger.dev@latest projects create
```

```bash pnpm
pnpm dlx trigger.dev@latest projects create
```

```bash yarn
yarn dlx trigger.dev@latest projects create
```

</CodeGroup>

<ParamField body="Organization" type="--org | -o">
The organization slug or ID to create the project in.
</ParamField>

<ParamField body="Name" type="--name | -n">
The name of the new project.
</ParamField>

## projects get

Prints the name, ref, slug, organization, default runtime and region of a project.

```bash
npx trigger.dev@latest projects get proj_abc123
```

## projects rename

Renames a project. The project ref does not change.

```bash
npx trigger.dev@latest projects rename proj_abc123 "My new name"
```

## projects delete

Deletes a project and everything in it. You are asked to confirm first.

```bash
npx trigger.dev@latest projects delete proj_abc123
```

<ParamField body="Skip confirmation" type="--yes | -y">
Delete without the confirmation prompt. Required in non-interactive environments such as CI.
</ParamField>

## Options

### Common options

These options are available on most commands.

<CommonOptions />
90 changes: 90 additions & 0 deletions docs/cli-runs-commands.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: "CLI runs commands"
sidebarTitle: "runs"
description: "Use these commands to list, inspect, replay and cancel runs from your terminal."
---

import CommonOptions from "/snippets/cli-options-common.mdx";
import ConfigFileOptions from "/snippets/cli-options-config-file.mdx";
import ProjectRefOptions from "/snippets/cli-options-project-ref.mdx";
import BranchOptions from "/snippets/cli-options-branch.mdx";

## runs list

Lists runs, newest first, in a table of ID, task, status, version, created time and duration.

<CodeGroup>

```bash npm
npx trigger.dev@latest runs list
```

```bash pnpm
pnpm dlx trigger.dev@latest runs list
```

```bash yarn
yarn dlx trigger.dev@latest runs list
```

</CodeGroup>

<ParamField body="Limit" type="--limit">
The number of runs to list, up to 100. Defaults to 20.
</ParamField>

<ParamField body="Status" type="--status">
Only show runs with this status, e.g. `FAILED`.
</ParamField>

<ParamField body="Task" type="--task">
Only show runs for this task identifier.
</ParamField>

<ParamField body="Tag" type="--tag">
Only show runs with this tag.
</ParamField>

<ParamField body="Cursor" type="--cursor">
The pagination cursor printed at the end of the previous page.
</ParamField>

## runs get

Prints the status, version, tags, timings, duration, cost and error of a single run.

```bash
npx trigger.dev@latest runs get run_abc123
```

## runs replay

Triggers a new run with the same payload as an existing one, using the latest version of the task.

```bash
npx trigger.dev@latest runs replay run_abc123
```

## runs cancel

Cancels a run that has not finished yet.

```bash
npx trigger.dev@latest runs cancel run_abc123
```

## Options

<ParamField body="Environment" type="--env | -e">
The environment to use: `dev`, `prod`, `staging` or `preview`. Defaults to `prod`.
</ParamField>

<ConfigFileOptions />
<ProjectRefOptions />
<BranchOptions />

### Common options

These options are available on most commands.

<CommonOptions />
3 changes: 3 additions & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,15 @@
"pages": [
"cli-deploy-commands",
"cli-dev-commands",
"cli-env-commands",
"cli-init-commands",
"cli-list-profiles-commands",
"cli-login-commands",
"cli-logout-commands",
"cli-preview-archive",
"cli-projects-commands",
"cli-promote-commands",
"cli-runs-commands",
"cli-switch",
"cli-update-commands",
"cli-whoami-commands"
Expand Down
32 changes: 32 additions & 0 deletions packages/cli-v3/src/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ const MarkProjectInitializedResponseBody = z.object({
initializedAt: z.string().nullable(),
});

const RenameProjectResponseBody = z.object({
id: z.string(),
name: z.string(),
});

const DeleteProjectResponseBody = z.object({
id: z.string(),
});

export class CliApiClient {
private engineURL: string;
private source: "cli" | "mcp";
Expand Down Expand Up @@ -258,6 +267,29 @@ export class CliApiClient {
});
}

async renameProject(projectRef: string, body: { name: string }) {
if (!this.accessToken) {
throw new Error("renameProject: No access token");
}

return wrapZodFetch(RenameProjectResponseBody, `${this.apiURL}/api/v1/projects/${projectRef}`, {
method: "PATCH",
headers: this.getHeaders(),
body: JSON.stringify(body),
});
}

async deleteProject(projectRef: string) {
if (!this.accessToken) {
throw new Error("deleteProject: No access token");
}

return wrapZodFetch(DeleteProjectResponseBody, `${this.apiURL}/api/v1/projects/${projectRef}`, {
method: "DELETE",
headers: this.getHeaders(),
});
}

async getWorkerByTag(projectRef: string, envName: string, tagName: string = "current") {
if (!this.accessToken) {
throw new Error("getWorkerByTag: No access token");
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-v3/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { configureLogoutCommand } from "../commands/logout.js";
import { configurePreviewCommand } from "../commands/preview.js";
import { configureProjectsCommand } from "../commands/projects/index.js";
import { configurePromoteCommand } from "../commands/promote.js";
import { configureRunsCommand } from "../commands/runs/index.js";
import { configureSwitchProfilesCommand } from "../commands/switch.js";
import { configureUpdateCommand } from "../commands/update.js";
import { configureWhoamiCommand } from "../commands/whoami.js";
Expand Down Expand Up @@ -43,6 +44,7 @@ configureSwitchProfilesCommand(program);
configureUpdateCommand(program);
configurePreviewCommand(program);
configureProjectsCommand(program);
configureRunsCommand(program);
configureAnalyzeCommand(program);
configureMcpCommand(program);
configureReportCommand(program);
Expand Down
Loading
Loading