Skip to content

Commit 9811259

Browse files
committed
Restructure some docs and update the cli commands
1 parent 684024b commit 9811259

File tree

7 files changed

+149
-83
lines changed

7 files changed

+149
-83
lines changed

docs/cli-init-commands.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ yarn dlx trigger.dev@latest init
2424

2525
## Options
2626

27+
<ParamField body="Javascript" type="--javascript">
28+
By default, the init command assumes you are using TypeScript. Use this flag to initialize a
29+
project that uses JavaScript.
30+
</ParamField>
31+
2732
<ParamField body="Project ref" type="--project-ref | -p">
2833
The project ref to use when initializing the project.
2934
</ParamField>
3035

3136
<ParamField body="Package tag" type="--tag | -t">
32-
The version of the `@trigger.dev/sdk` package to install. Defaults to `3.0.0-beta.56`.
37+
The version of the `@trigger.dev/sdk` package to install. Defaults to `latest`.
3338
</ParamField>
3439

3540
<ParamField body="Skip package install" type="--skip-package-install">

docs/mint.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@
7474
{
7575
"source": "/reattempting-replaying",
7676
"destination": "/replaying"
77+
},
78+
{
79+
"source": "/tasks-overview",
80+
"destination": "/tasks/overview"
81+
},
82+
{
83+
"source": "/tasks-scheduled",
84+
"destination": "/tasks/scheduled"
85+
},
86+
{
87+
"source": "/trigger-folder",
88+
"destination": "/config/config-file"
7789
}
7890
],
7991
"anchors": [
@@ -95,20 +107,21 @@
95107
"introduction",
96108
"quick-start",
97109
"how-it-works",
98-
"limits",
99-
"changelog",
100-
"roadmap"
110+
"limits"
101111
]
102112
},
103113
{
104114
"group": "Fundamentals",
105115
"pages": [
106-
"trigger-folder",
107-
"tasks-overview",
116+
{
117+
"group": "Tasks",
118+
"pages": [
119+
"tasks/overview",
120+
"tasks/scheduled"
121+
]
122+
},
108123
"triggering",
109124
"apikeys",
110-
"tasks-regular",
111-
"tasks-scheduled",
112125
{
113126
"group": "Configuration",
114127
"pages": [
@@ -249,7 +262,9 @@
249262
"pages": [
250263
"open-source-self-hosting",
251264
"open-source-contributing",
252-
"github-repo"
265+
"github-repo",
266+
"changelog",
267+
"roadmap"
253268
]
254269
},
255270
{

docs/snippets/cli-commands-deploy.mdx

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ yarn dlx trigger.dev@latest deploy
2424
It performs a few steps to deploy:
2525

2626
1. Optionally updates packages when running locally.
27-
2. Typechecks the code.
28-
3. Compiles and bundles the code.
29-
4. Checks that [environment variables](/deploy-environment-variables) are set.
30-
5. Deploys the code to the cloud.
31-
6. Registers the tasks as a new version in the environment (prod by default).
27+
2. Compiles and bundles the code.
28+
3. Deploys the code to the Trigger.dev instance.
29+
4. Registers the tasks as a new version in the environment (prod by default).
3230

3331
You can also setup [GitHub Actions](/github-actions) to deploy your tasks automatically.
3432

@@ -38,28 +36,33 @@ You can also setup [GitHub Actions](/github-actions) to deploy your tasks automa
3836
Defaults to `prod` but you can specify `staging`.
3937
</ParamField>
4038

41-
<ParamField body="Skip typecheck" type="--skip-typecheck">
42-
Skips the pre-build typecheck step.
39+
<ParamField body="Set config filename" type="--config | -c">
40+
The name of the config file, found where the command is run from. Defaults to `trigger.config.ts`.
41+
</ParamField>
42+
43+
<ParamField body="Env file" type="--env">
44+
Load environment variables from a file. This will only hydrate the `process.env` of the CLI
45+
process, not the tasks.
46+
</ParamField>
47+
48+
<ParamField body="Dry run" type="--dry-run">
49+
Create a deployable build but don't deploy it. Prints out the build path so you can inspect it.
4350
</ParamField>
4451

4552
<ParamField body="Skip update check" type="--skip-update-check">
4653
Skip checking for `@trigger.dev` package updates.
4754
</ParamField>
4855

49-
<ParamField body="Build platform" type="--build-platform">
50-
The platform to build the deployment image for. Defaults to `linux/amd64`.
56+
<ParamField body="Set the projectRef" type="--project-ref | -p">
57+
The project ref. Required if there is no config file.
5158
</ParamField>
5259

5360
<ParamField body="Log level" type="--log-level | -l">
5461
The log level to use (debug, info, log, warn, error, none). Defaults to `log`.
5562
</ParamField>
5663

57-
<ParamField body="Set config filename" type="--config | -c">
58-
The name of the config file, found where the command is run from. Defaults to `trigger.config.ts`.
59-
</ParamField>
60-
61-
<ParamField body="Set the projectRef" type="--project-ref | -p">
62-
The project ref. Required if there is no config file.
64+
<ParamField body="Skip syncing env vars" type="--skip-sync-env-vars">
65+
Turn off syncing environment variables with the Trigger.dev instance.
6366
</ParamField>
6467

6568
## Self-hosting
@@ -76,15 +79,32 @@ These options are typically used when [self-hosting](/open-source-self-hosting)
7679
default registry.
7780
</ParamField>
7881

82+
<ParamField body="Load image" type="--load-image">
83+
Loads the image into your local docker after building it.
84+
</ParamField>
85+
7986
<ParamField body="Registry" type="--registry">
80-
**This option is coming soon.** The registry to push the image to when using --self-hosted.
87+
Specify the registry to push the image to when using `--self-hosted`.
8188
</ParamField>
8289

8390
<ParamField body="Push image" type="--push">
84-
When using the --self-hosted flag, push the image to the default registry. (defaults to false when
85-
not using --registry)
91+
When using the --self-hosted flag, push the image to the registry.
8692
</ParamField>
8793

88-
<ParamField body="Tag the image" type="--tag">
89-
**This option is coming soon.** Specify the tag to use when pushing the image to the registry.
94+
<ParamField body="Namespace" type="--namepsace">
95+
The namespace to use when pushing the image to the registry. For example, if pushing to Docker
96+
Hub, the namespace is your Docker Hub username.
9097
</ParamField>
98+
99+
### Push to Docker Hub
100+
101+
An example of deploying to Docker Hub when using a self-hosted setup:
102+
103+
```bash
104+
npx trigger.dev@latest deploy \
105+
--self-hosted \
106+
--load-image \
107+
--push \
108+
--registry docker.io \
109+
--namespace mydockerhubusername
110+
```

docs/snippets/cli-commands-develop.mdx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ yarn dlx trigger.dev@latest dev
1818

1919
It will first perform an update check to prevent version mismatches, failed deploys, and other errors. You will always be prompted first.
2020

21-
You will see in the terminal that the server is running and listening for requests. When you run a task, you will see it in the terminal along with a link to view it in the dashboard.
21+
You will see in the terminal that the server is running and listening for tasks. When you run a task, you will see it in the terminal along with a link to view it in the dashboard.
2222

2323
It is worth noting that each task runs in a separate Node process. This means that if you have a long-running task, it will not block other tasks from running.
2424

@@ -32,28 +32,9 @@ It is worth noting that each task runs in a separate Node process. This means th
3232
The project ref. Required if there is no config file.
3333
</ParamField>
3434

35-
<ParamField body="Debugger" type="--debugger">
36-
You can use this flag to run the server in debug mode. This will allow you to attach a debugger to the server and debug your tasks.
37-
38-
<CodeGroup>
39-
40-
```bash npm
41-
npx trigger.dev@latest dev --debugger
42-
```
43-
44-
```bash pnpm
45-
pnpm dlx trigger.dev@latest dev --debugger
46-
```
47-
48-
```bash yarn
49-
yarn dlx trigger.dev@latest dev --debugger
50-
```
51-
52-
</CodeGroup>
53-
</ParamField>
54-
55-
<ParamField body="Debug OpenTelemetry" type="--debug-otel">
56-
Enable OpenTelemetry debugging.
35+
<ParamField body="Env file" type="--env">
36+
Pass a custom path to an env file. We automatically detect `.env`, `.env.local`,
37+
`.env.development`, and `.env.development.local` files.
5738
</ParamField>
5839

5940
<ParamField body="Skip update check" type="--skip-update-check">
@@ -73,10 +54,6 @@ yarn dlx trigger.dev@latest dev --debugger
7354
does not affect the log level of your trigger.dev tasks. Defaults to `log`.
7455
</ParamField>
7556

76-
<ParamField body="Skip telemetry" type="--skip-telemetry">
77-
Opt-out of sending telemetry data.
78-
</ParamField>
79-
8057
## Standard options
8158

8259
<ParamField body="Help" type="--help | -h">

docs/tasks-overview.mdx renamed to docs/tasks/overview.mdx

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: "Tasks: Overview"
3-
sidebarTitle: "Tasks"
3+
sidebarTitle: "Overview"
44
description: "Tasks are functions that can run for a long time and provide strong resilience to failure."
55
---
66

7-
There are different types of tasks including [regular tasks](/tasks-regular) and [scheduled tasks](/tasks-scheduled).
7+
There are different types of tasks including regular tasks and [scheduled tasks](/tasks/scheduled).
88

99
## Hello world task and how to trigger it
1010

@@ -265,6 +265,80 @@ You can define a function that will be called when an error is thrown in the `ru
265265

266266
Read more about `handleError` in our [Errors and Retrying guide](/errors-retrying).
267267

268+
## Example tasks
269+
270+
### A task that does an OpenAI call with retrying
271+
272+
Sometimes OpenAI calls can take a long time to complete, or they can fail. This task will retry if the API call fails completely or if the response is empty.
273+
274+
<OpenaiRetry />
275+
276+
### A Task that sends emails in a sequence with delays in between
277+
278+
This example uses Resend to send a sequence of emails over several days.
279+
280+
Each email is wrapped in `retry.onThrow`. This will retry the block of code if an error is thrown. This is useful when you don't want to retry the whole task, but just a part of it. The entire task will use the default retrying, so can also retry.
281+
282+
Additionally this task uses `wait.for` to wait for a certain amount of time before sending the next email. During the waiting time, the task will be paused and will not consume any resources.
283+
284+
```ts /trigger/email-sequence.ts
285+
import { Resend } from "resend";
286+
287+
const resend = new Resend(process.env.RESEND_ASP_KEY);
288+
289+
export const emailSequence = task({
290+
id: "email-sequence",
291+
run: async (payload: { userId: string; email: string; name: string }) => {
292+
console.log(`Start email sequence for user ${payload.userId}`, payload);
293+
294+
//send the first email immediately
295+
const firstEmailResult = await retry.onThrow(
296+
async ({ attempt }) => {
297+
const { data, error } = await resend.emails.send({
298+
299+
to: payload.email,
300+
subject: "Welcome to Trigger.dev",
301+
html: `<p>Hello ${payload.name},</p><p>Welcome to Trigger.dev</p>`,
302+
});
303+
304+
if (error) {
305+
//throwing an error will trigger a retry of this block
306+
throw error;
307+
}
308+
309+
return data;
310+
},
311+
{ maxAttempts: 3 }
312+
);
313+
314+
//then wait 3 days
315+
await wait.for({ days: 3 });
316+
317+
//send the second email
318+
const secondEmailResult = await retry.onThrow(
319+
async ({ attempt }) => {
320+
const { data, error } = await resend.emails.send({
321+
322+
to: payload.email,
323+
subject: "Some tips for you",
324+
html: `<p>Hello ${payload.name},</p><p>Here are some tips for you…</p>`,
325+
});
326+
327+
if (error) {
328+
//throwing an error will trigger a retry of this block
329+
throw error;
330+
}
331+
332+
return data;
333+
},
334+
{ maxAttempts: 3 }
335+
);
336+
337+
//etc...
338+
},
339+
});
340+
```
341+
268342
## Next steps
269343

270344
<CardGroup>
File renamed without changes.

docs/trigger-folder.mdx

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)