diff --git a/.cursor/rules/executing-commands.mdc b/.cursor/rules/executing-commands.mdc new file mode 100644 index 000000000..7bce08005 --- /dev/null +++ b/.cursor/rules/executing-commands.mdc @@ -0,0 +1,10 @@ +--- +description: how to run commands in the monorepo +globs: +alwaysApply: true +--- +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: + +``` +pnpm run test --filter @internal/run-engine +``` \ No newline at end of file diff --git a/.cursor/rules/repo.mdc b/.cursor/rules/repo.mdc new file mode 100644 index 000000000..5794da7fe --- /dev/null +++ b/.cursor/rules/repo.mdc @@ -0,0 +1,20 @@ +--- +description: understanding the structure of the monorepo +globs: +alwaysApply: true +--- +This is a pnpm 8.15.5 monorepo that uses turborepo [turbo.json](mdc:turbo.json). The following workspaces are relevant: + +- /apps/webapp is a remix app that is the main API and dashboard for trigger.dev +- /packages/trigger-sdk is the `@trigger.dev/sdk` main SDK package +- /packages/cli-v3 is the `trigger.dev` CLI package +- /packages/core is the `@trigger.dev/core` package that is shared across the SDK and other packages +- /packages/build defines the types and prebuilt build extensions for trigger.dev +- /packages/react-hooks defines some useful react hooks like our realtime hooks +- /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 +- /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 +- /docs is our trigger.dev/docs mintlify documentation site + +Other things in the monorepo to note: + +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. \ No newline at end of file diff --git a/.cursor/rules/webapp.mdc b/.cursor/rules/webapp.mdc new file mode 100644 index 000000000..f4f23d192 --- /dev/null +++ b/.cursor/rules/webapp.mdc @@ -0,0 +1,12 @@ +--- +description: Making updates to the main trigger.dev remix webapp +globs: apps/webapp/**/*.tsx,apps/webapp/**/*.ts +alwaysApply: false +--- + +# Your rule content + +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: + +- `@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) +- `@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) diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 000000000..6f9f00ff4 --- /dev/null +++ b/.cursorignore @@ -0,0 +1 @@ +# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) diff --git a/ai/references/tests.md b/ai/references/tests.md new file mode 100644 index 000000000..1c6d94389 --- /dev/null +++ b/ai/references/tests.md @@ -0,0 +1,36 @@ +## Running Tests + +We use vitest exclusively for testing. To execute tests for a particular workspace, run the following command: + +```bash +pnpm test --filter webapp +``` + +Prefer running tests on a single file: + +```bash +pnpm test --filter webapp/src/components/Button.test.ts +``` + +## Writing Tests + +We use vitest for testing. We almost NEVER mock anything. Start with a top-level "describe", and have multiple "it" statements inside of it. + +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. + +redisTest: + +```typescript +import { redisTest } from "@internal/testcontainers"; +import { createRedisClient } from "@internal/redis"; + +describe("redisTest", () => { + redisTest("should use redis", async ({ redisOptions }) => { + const redis = createRedisClient(redisOptions); + + await redis.set("test", "test"); + const result = await redis.get("test"); + expect(result).toEqual("test"); + }); +}); +```