Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .changeset/port-pr-1098.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@opennextjs/aws": patch
---

Ported PR #1098 from source repository

https://github.com/opennextjs/opennextjs-aws/pull/1098
5 changes: 5 additions & 0 deletions .changeset/stale-schools-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

Fix `findNextConfig` returning the incorrect result and also expand the return result to be an object with both the path and a new flag indicating whether the file is in TypeScript or not
136 changes: 136 additions & 0 deletions .claude/skills/port-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
name: port-pr
description: Port PRs from a GitHub repository. Use when you need to bring changes from a source repo. Invoke with /port-pr <github-pr-url>
argument-hint: <github-pr-url>
disable-model-invocation: true
---

# Port PR Skill

This skill enables porting PRs from a GitHub repository into this repository.

## Required Inputs

This skill receives arguments via `$ARGUMENTS`:

- `$ARGUMENTS`: GitHub PR URL (e.g., `https://github.com/owner/repo/pull/123`)

## Workflow

### 1. Extract PR Information

```bash
gh pr view <url> --json mergeCommit,title,body,headRepository
# Exclude lockfiles from diff - they should be regenerated via pnpm install
git diff <mergeCommit>^..<mergeCommit> -- . ':!pnpm-lock.yaml' ':!package-lock.json' ':!yarn.lock'
```

Run these commands in the source repository using `workdir` parameter.

**Important:** Never read or port lockfile changes (pnpm-lock.yaml, package-lock.json, yarn.lock). Always regenerate the lockfile by running `pnpm install` after updating package.json dependencies.

### 2. Analyze Changes

- Identify all files changed, added, and deleted
- Understand the purpose and scope of the change
- Note any dependencies or related changes

### 3. Map to Target Repository

- Find equivalent files in this repository
- Identify any structural differences between repos
- Note files that don't exist or have different paths

### 4. Ask for Guidance

Before implementing, ask the user for clarification when:

- A file doesn't exist in the target repo
- The code structure differs significantly between repos
- The feature/change may not apply to this repository
- There's ambiguity about how to adapt the changes

### 5. Implement Changes

Apply similar changes following this repository's conventions:

- Follow AGENTS.md guidelines (formatting, imports, naming)
- Maintain consistent code style with surrounding code
- Use explicit file extensions (`.js`) for local imports
- Use `node:` prefix for Node.js built-ins

### 6. Verification

After implementation, run:

```bash
pnpm code:checks
```

This runs formatting, linting, and TypeScript checks.

### 7. Run Unit Tests

After code checks pass, run only the unit tests from the tests-unit package:

```bash
pnpm --filter tests-unit test
```

**Important:** Do NOT run `pnpm test` (which runs all tests), `pnpm e2e:test`, or any full test suite. Only unit tests from the tests-unit package should be run during the porting process.

### 8. Ask for Package

Before creating the changeset, determine which package the changes apply to:

Ask the user: **"Which package should this changeset be for - `@opennextjs/aws` or `@opennextjs/cloudflare`?"**

Store the answer in `$PACKAGE_NAME` (e.g., "@opennextjs/cloudflare").

### 9. Create Changeset

Create a patch changeset with the link to the PR:

```bash
# Extract PR number from the URL (e.g., "123" from "https://github.com/owner/repo/pull/123")
PR_NUMBER=$(echo "$ARGUMENTS" | grep -oE '[0-9]+$')

# Create the changeset file with the PR link (use the package name from step 7)
echo "---
\"$PACKAGE_NAME\": patch
---

Ported PR #$PR_NUMBER from source repository

$ARGUMENTS" > .changeset/port-pr-$PR_NUMBER.md
```

### 10. Stage Changes and Prepare Commit

Stage the changeset file and prepare a commit message (but do not commit):

```bash
# Stage the changeset file
git add .changeset/port-pr-$PR_NUMBER.md

# Prepare the commit message with the PR link (stored for later)
echo "chore: port PR #$PR_NUMBER from source repository

$ARGUMENTS

Changeset: .changeset/port-pr-$PR_NUMBER.md" > /tmp/commit-message-port-pr-$PR_NUMBER.txt

# Display the prepared commit message
cat /tmp/commit-message-port-pr-$PR_NUMBER.txt
```

The changeset is staged and ready to commit. The commit message is saved at `/tmp/commit-message-port-pr-$PR_NUMBER.txt` for reference.

### 11. Summary

Provide a summary of:

- What was ported
- Any adaptations made
- Files modified/created
- Any remaining TODOs or follow-up items
165 changes: 165 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# AGENTS.md

Guidelines for AI coding agents working in this repository.

## Project Overview

This is a monorepo for OpenNext.js adapters, enabling Next.js deployment to various platforms (AWS Lambda, Cloudflare Workers, Node.js). The repository uses pnpm workspaces with multiple packages under `packages/` and example applications under `examples/` and `examples-cloudflare/`.

## Build/Lint/Test Commands

### Root-level commands (run from repository root)

```bash
# Install dependencies
pnpm install

# Build all packages
pnpm build

# Build only opennext packages
pnpm build:opennext

# Run linter
pnpm lint

# Fix linting issues
pnpm lint:fix

# Check formatting
pnpm fmt

# Fix formatting issues
pnpm fmt:fix

# TypeScript type checking (all packages)
pnpm ts:check

# Run all code checks (fmt + lint + ts:check)
pnpm code:checks

# Run all unit tests
pnpm test

# Run e2e tests
pnpm e2e:test
```

### Running single tests

```bash
# Run a specific test file in the cloudflare package
pnpm --filter @opennextjs/cloudflare vitest run path/to/test.spec.ts

# Run tests matching a pattern in the tests-unit package
pnpm --filter tests-unit vitest run --testNamePattern="test name pattern"

# Run a single test file with vitest directly
cd packages/tests-unit && pnpm vitest run tests/core/routing/matcher.test.ts

# Run tests in watch mode
pnpm --filter tests-unit vitest

# Run tests in a specific package
pnpm --filter @opennextjs/cloudflare test
```

### Package-specific commands

```bash
# Build a specific package
pnpm --filter @opennextjs/cloudflare build

# Type check a specific package
pnpm --filter @opennextjs/cloudflare ts:check
```

## Code Style Guidelines

### Imports

- Use explicit file extensions (`.js`) for local imports: `import { foo } from "./bar.js"`
- Use Node.js built-in imports with `node:` prefix: `import fs from "node:fs"`
- Group imports logically: built-ins first, then external packages, then local modules
- Use workspace protocol for internal packages: `"@opennextjs/aws": "workspace:*"`

### TypeScript

- TypeScript strict mode is enabled via `@tsconfig/strictest`
- Use explicit type annotations for function parameters and return types
- Prefer `type` for object types, `interface` for extensible types
- Use `import type` for type-only imports
- Avoid `any` - use `unknown` or specific types; if unavoidable, add `// oxlint-disable @typescript-eslint/no-explicit-any` comment
- Target ES2022 for compilation

### Formatting

- Tabs for indentation (check .editorconfig if present)
- Double quotes for strings
- Trailing commas in objects/arrays
- Semicolons are required

### Naming Conventions

- camelCase for variables and functions
- PascalCase for types, interfaces, and classes
- SCREAMING_SNAKE_CASE for constants
- kebab-case for file names: `my-component.ts`, `use-cache.ts`
- `.spec.ts` suffix for test files (unit tests use vitest)
- `.test.ts` suffix for test files in tests-unit package

### Error Handling

- Throw descriptive `Error` objects with context
- Use typed errors when specific error handling is needed
- Log errors with console.error/console.log for CLI commands
- Handle async errors with try/catch or .catch()

### File Organization

- Source code in `src/` directory
- Test files co-located with source (`.spec.ts`) or in separate tests directory (`.test.ts`)
- Export public API through `index.ts` files
- Use barrel exports: `export * from "./module.js"`
- Configuration files at package root

### Testing

- Use vitest for unit tests
- Use `describe`/`test`/`expect` from vitest
- Test file naming: `*.spec.ts` for co-located tests, `*.test.ts` for tests-unit package
- Mock external dependencies with `vi.mock()` and `vi.fn()`
- Run tests in Node.js environment (not jsdom) by default

### Comments and Documentation

- Use JSDoc comments for public APIs
- Document complex logic with inline comments
- Use `// TODO(username)` or `// TODO: description` for TODOs
- Keep comments concise and relevant

## Package Manager

This project uses **pnpm** exclusively. Do not use npm or yarn commands.

```bash
# Add a dependency to a specific package
pnpm --filter <package-name> add <dependency>

# Add a dev dependency
pnpm --filter <package-name> add -D <dependency>

# Run a script in a specific package
pnpm --filter <package-name> <script-name>
```

## Pre-commit Checks

Before committing, ensure:

1. `pnpm fmt:fix` - Code is properly formatted
2. `pnpm lint:fix` - No linting errors
3. `pnpm ts:check` - TypeScript compiles without errors
4. `pnpm test` - All tests pass

Run `pnpm code:checks` to verify all checks pass.
2 changes: 1 addition & 1 deletion packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@ast-grep/napi": "0.40.0",
"@ast-grep/napi": "0.40.5",
"@dotenvx/dotenvx": "catalog:",
"@opennextjs/aws": "workspace:*",
"cloudflare": "^4.4.1",
Expand Down
12 changes: 6 additions & 6 deletions packages/open-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
"ts:check": "tsc --noEmit"
},
"dependencies": {
"@ast-grep/napi": "^0.40.0",
"@aws-sdk/client-cloudfront": "3.398.0",
"@aws-sdk/client-dynamodb": "^3.398.0",
"@aws-sdk/client-lambda": "^3.398.0",
"@aws-sdk/client-s3": "^3.398.0",
"@aws-sdk/client-sqs": "^3.398.0",
"@ast-grep/napi": "^0.40.5",
"@aws-sdk/client-cloudfront": "3.984.0",
"@aws-sdk/client-dynamodb": "3.984.0",
"@aws-sdk/client-lambda": "3.984.0",
"@aws-sdk/client-s3": "3.984.0",
"@aws-sdk/client-sqs": "3.984.0",
"@node-minify/core": "^8.0.6",
"@node-minify/terser": "^8.0.6",
"@tsconfig/node18": "^1.0.3",
Expand Down
Loading
Loading