Skip to content

Commit 70ff5de

Browse files
committed
WIP
1 parent 6cf86d5 commit 70ff5de

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

.cursor/rules/executing-commands.mdc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: how to run commands in the monorepo
3+
globs:
4+
alwaysApply: true
5+
---
6+
Almost all commands in the monorepo should be executed when `pnpm run ...` from the root of the monorepo. For example, running tests for the `@internal/run-engine` internal package:
7+
8+
```
9+
pnpm run test --filter @internal/run-engine
10+
```

.cursor/rules/repo.mdc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: understanding the structure of the monorepo
3+
globs:
4+
alwaysApply: true
5+
---
6+
This is a pnpm 8.15.5 monorepo that uses turborepo [turbo.json](mdc:turbo.json). The following workspaces are relevant:
7+
8+
- <root>/apps/webapp is a remix app that is the main API and dashboard for trigger.dev
9+
- <root>/packages/trigger-sdk is the `@trigger.dev/sdk` main SDK package
10+
- <root>/packages/cli-v3 is the `trigger.dev` CLI package
11+
- <root>/packages/core is the `@trigger.dev/core` package that is shared across the SDK and other packages
12+
- <root>/packages/build defines the types and prebuilt build extensions for trigger.dev
13+
- <root>/packages/react-hooks defines some useful react hooks like our realtime hooks
14+
- <root>/internal-packages/* are packages that are used internally only, not published, and usually they have a tsc build step and are used in the webapp
15+
- <root>/references/* are test workspaces that we use to write and test the system. Not quite e2e tests or automated, but just a useful place to help develop new features
16+
- <root>/docs is our trigger.dev/docs mintlify documentation site
17+
18+
Other things in the monorepo to note:
19+
20+
The [Dockerfile](mdc:docker/Dockerfile) is the one that creates the main trigger.dev published image, and the [docker-compose.yml](mdc:docker/docker-compose.yml) is the file we run locally to start postgresql, redis, and electric when we are doing local development. The [CONTRIBUTING.md](mdc:CONTRIBUTING.md) file defines the steps it takes for OSS contributors to start contributing.

.cursor/rules/webapp.mdc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: Making updates to the main trigger.dev remix webapp
3+
globs: apps/webapp/**/*.tsx,apps/webapp/**/*.ts
4+
alwaysApply: false
5+
---
6+
7+
# Your rule content
8+
9+
The main trigger.dev webapp, which powers it's API and dashboard and makes up the docker image that is produced as an OSS image, is a Remix 2.1.0 app that uses an express server, written in TypeScript. The following subsystems are either included in the webapp or are used by the webapp in another part of the monorepo:
10+
11+
- `@trigger.dev/database` exports a Prisma 5.4.1 client that is used extensively in the webapp to access a PostgreSQL instance. The schema file is [schema.prisma](mdc:internal-packages/database/prisma/schema.prisma)
12+
- `@trigger.dev/core` is a published package and is used to share code between the `@trigger.dev/sdk` and the webapp. It includes functionality but also a load of Zod schemas for data validation. When importing from `@trigger.dev/core` in the webapp, we never import the root `@trigger.dev/core` path, instead we favor one of the subpath exports that you can find in [package.json](mdc:packages/core/package.json)

.cursorignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)

ai/references/tests.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Running Tests
2+
3+
We use vitest exclusively for testing. To execute tests for a particular workspace, run the following command:
4+
5+
```bash
6+
pnpm test --filter webapp
7+
```
8+
9+
Prefer running tests on a single file:
10+
11+
```bash
12+
pnpm test --filter webapp/src/components/Button.test.ts
13+
```
14+
15+
## Writing Tests
16+
17+
We use vitest for testing. We almost NEVER mock anything. Start with a top-level "describe", and have multiple "it" statements inside of it.
18+
19+
When writing anything that needs redis or postgresql, we have some internal "testcontainers" that are used to spin up a local instance, redis, or both.
20+
21+
redisTest:
22+
23+
```typescript
24+
import { redisTest } from "@internal/testcontainers";
25+
import { createRedisClient } from "@internal/redis";
26+
27+
describe("redisTest", () => {
28+
redisTest("should use redis", async ({ redisOptions }) => {
29+
const redis = createRedisClient(redisOptions);
30+
31+
await redis.set("test", "test");
32+
const result = await redis.get("test");
33+
expect(result).toEqual("test");
34+
});
35+
});
36+
```

0 commit comments

Comments
 (0)