Skip to content

Commit 3dbd9ef

Browse files
authored
Sync AWS PRs and add coding guidelines (#25)
* Add SKILL.md for porting PRs and AGENTS.md for coding guidelines * update skill * Port opennextjs/opennextjs-aws#1118 as a test * Port opennextjs/opennextjs-aws#1117 * update skill * Port opennextjs/opennextjs-aws#1114 * Port PR opennextjs/opennextjs-aws#1107 * update skills * Port PR opennextjs/opennextjs-aws#1108 * Port PR opennextjs/opennextjs-aws#1104 * Port PR opennextjs/opennextjs-aws#1101 * Port PR opennextjs/opennextjs-aws#1098 * review
1 parent 606e853 commit 3dbd9ef

17 files changed

Lines changed: 2075 additions & 639 deletions

File tree

.changeset/port-pr-1098.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
Ported PR #1098 from source repository
6+
7+
https://github.com/opennextjs/opennextjs-aws/pull/1098

.changeset/stale-schools-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
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

.claude/skills/port-pr/SKILL.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
name: port-pr
3+
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>
4+
argument-hint: <github-pr-url>
5+
disable-model-invocation: true
6+
---
7+
8+
# Port PR Skill
9+
10+
This skill enables porting PRs from a GitHub repository into this repository.
11+
12+
## Required Inputs
13+
14+
This skill receives arguments via `$ARGUMENTS`:
15+
16+
- `$ARGUMENTS`: GitHub PR URL (e.g., `https://github.com/owner/repo/pull/123`)
17+
18+
## Workflow
19+
20+
### 1. Extract PR Information
21+
22+
```bash
23+
gh pr view <url> --json mergeCommit,title,body,headRepository
24+
# Exclude lockfiles from diff - they should be regenerated via pnpm install
25+
git diff <mergeCommit>^..<mergeCommit> -- . ':!pnpm-lock.yaml' ':!package-lock.json' ':!yarn.lock'
26+
```
27+
28+
Run these commands in the source repository using `workdir` parameter.
29+
30+
**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.
31+
32+
### 2. Analyze Changes
33+
34+
- Identify all files changed, added, and deleted
35+
- Understand the purpose and scope of the change
36+
- Note any dependencies or related changes
37+
38+
### 3. Map to Target Repository
39+
40+
- Find equivalent files in this repository
41+
- Identify any structural differences between repos
42+
- Note files that don't exist or have different paths
43+
44+
### 4. Ask for Guidance
45+
46+
Before implementing, ask the user for clarification when:
47+
48+
- A file doesn't exist in the target repo
49+
- The code structure differs significantly between repos
50+
- The feature/change may not apply to this repository
51+
- There's ambiguity about how to adapt the changes
52+
53+
### 5. Implement Changes
54+
55+
Apply similar changes following this repository's conventions:
56+
57+
- Follow AGENTS.md guidelines (formatting, imports, naming)
58+
- Maintain consistent code style with surrounding code
59+
- Use explicit file extensions (`.js`) for local imports
60+
- Use `node:` prefix for Node.js built-ins
61+
62+
### 6. Verification
63+
64+
After implementation, run:
65+
66+
```bash
67+
pnpm code:checks
68+
```
69+
70+
This runs formatting, linting, and TypeScript checks.
71+
72+
### 7. Run Unit Tests
73+
74+
After code checks pass, run only the unit tests from the tests-unit package:
75+
76+
```bash
77+
pnpm --filter tests-unit test
78+
```
79+
80+
**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.
81+
82+
### 8. Ask for Package
83+
84+
Before creating the changeset, determine which package the changes apply to:
85+
86+
Ask the user: **"Which package should this changeset be for - `@opennextjs/aws` or `@opennextjs/cloudflare`?"**
87+
88+
Store the answer in `$PACKAGE_NAME` (e.g., "@opennextjs/cloudflare").
89+
90+
### 9. Create Changeset
91+
92+
Create a patch changeset with the link to the PR:
93+
94+
```bash
95+
# Extract PR number from the URL (e.g., "123" from "https://github.com/owner/repo/pull/123")
96+
PR_NUMBER=$(echo "$ARGUMENTS" | grep -oE '[0-9]+$')
97+
98+
# Create the changeset file with the PR link (use the package name from step 7)
99+
echo "---
100+
\"$PACKAGE_NAME\": patch
101+
---
102+
103+
Ported PR #$PR_NUMBER from source repository
104+
105+
$ARGUMENTS" > .changeset/port-pr-$PR_NUMBER.md
106+
```
107+
108+
### 10. Stage Changes and Prepare Commit
109+
110+
Stage the changeset file and prepare a commit message (but do not commit):
111+
112+
```bash
113+
# Stage the changeset file
114+
git add .changeset/port-pr-$PR_NUMBER.md
115+
116+
# Prepare the commit message with the PR link (stored for later)
117+
echo "chore: port PR #$PR_NUMBER from source repository
118+
119+
$ARGUMENTS
120+
121+
Changeset: .changeset/port-pr-$PR_NUMBER.md" > /tmp/commit-message-port-pr-$PR_NUMBER.txt
122+
123+
# Display the prepared commit message
124+
cat /tmp/commit-message-port-pr-$PR_NUMBER.txt
125+
```
126+
127+
The changeset is staged and ready to commit. The commit message is saved at `/tmp/commit-message-port-pr-$PR_NUMBER.txt` for reference.
128+
129+
### 11. Summary
130+
131+
Provide a summary of:
132+
133+
- What was ported
134+
- Any adaptations made
135+
- Files modified/created
136+
- Any remaining TODOs or follow-up items

AGENTS.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# AGENTS.md
2+
3+
Guidelines for AI coding agents working in this repository.
4+
5+
## Project Overview
6+
7+
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/`.
8+
9+
## Build/Lint/Test Commands
10+
11+
### Root-level commands (run from repository root)
12+
13+
```bash
14+
# Install dependencies
15+
pnpm install
16+
17+
# Build all packages
18+
pnpm build
19+
20+
# Build only opennext packages
21+
pnpm build:opennext
22+
23+
# Run linter
24+
pnpm lint
25+
26+
# Fix linting issues
27+
pnpm lint:fix
28+
29+
# Check formatting
30+
pnpm fmt
31+
32+
# Fix formatting issues
33+
pnpm fmt:fix
34+
35+
# TypeScript type checking (all packages)
36+
pnpm ts:check
37+
38+
# Run all code checks (fmt + lint + ts:check)
39+
pnpm code:checks
40+
41+
# Run all unit tests
42+
pnpm test
43+
44+
# Run e2e tests
45+
pnpm e2e:test
46+
```
47+
48+
### Running single tests
49+
50+
```bash
51+
# Run a specific test file in the cloudflare package
52+
pnpm --filter @opennextjs/cloudflare vitest run path/to/test.spec.ts
53+
54+
# Run tests matching a pattern in the tests-unit package
55+
pnpm --filter tests-unit vitest run --testNamePattern="test name pattern"
56+
57+
# Run a single test file with vitest directly
58+
cd packages/tests-unit && pnpm vitest run tests/core/routing/matcher.test.ts
59+
60+
# Run tests in watch mode
61+
pnpm --filter tests-unit vitest
62+
63+
# Run tests in a specific package
64+
pnpm --filter @opennextjs/cloudflare test
65+
```
66+
67+
### Package-specific commands
68+
69+
```bash
70+
# Build a specific package
71+
pnpm --filter @opennextjs/cloudflare build
72+
73+
# Type check a specific package
74+
pnpm --filter @opennextjs/cloudflare ts:check
75+
```
76+
77+
## Code Style Guidelines
78+
79+
### Imports
80+
81+
- Use explicit file extensions (`.js`) for local imports: `import { foo } from "./bar.js"`
82+
- Use Node.js built-in imports with `node:` prefix: `import fs from "node:fs"`
83+
- Group imports logically: built-ins first, then external packages, then local modules
84+
- Use workspace protocol for internal packages: `"@opennextjs/aws": "workspace:*"`
85+
86+
### TypeScript
87+
88+
- TypeScript strict mode is enabled via `@tsconfig/strictest`
89+
- Use explicit type annotations for function parameters and return types
90+
- Prefer `type` for object types, `interface` for extensible types
91+
- Use `import type` for type-only imports
92+
- Avoid `any` - use `unknown` or specific types; if unavoidable, add `// oxlint-disable @typescript-eslint/no-explicit-any` comment
93+
- Target ES2022 for compilation
94+
95+
### Formatting
96+
97+
- Tabs for indentation (check .editorconfig if present)
98+
- Double quotes for strings
99+
- Trailing commas in objects/arrays
100+
- Semicolons are required
101+
102+
### Naming Conventions
103+
104+
- camelCase for variables and functions
105+
- PascalCase for types, interfaces, and classes
106+
- SCREAMING_SNAKE_CASE for constants
107+
- kebab-case for file names: `my-component.ts`, `use-cache.ts`
108+
- `.spec.ts` suffix for test files (unit tests use vitest)
109+
- `.test.ts` suffix for test files in tests-unit package
110+
111+
### Error Handling
112+
113+
- Throw descriptive `Error` objects with context
114+
- Use typed errors when specific error handling is needed
115+
- Log errors with console.error/console.log for CLI commands
116+
- Handle async errors with try/catch or .catch()
117+
118+
### File Organization
119+
120+
- Source code in `src/` directory
121+
- Test files co-located with source (`.spec.ts`) or in separate tests directory (`.test.ts`)
122+
- Export public API through `index.ts` files
123+
- Use barrel exports: `export * from "./module.js"`
124+
- Configuration files at package root
125+
126+
### Testing
127+
128+
- Use vitest for unit tests
129+
- Use `describe`/`test`/`expect` from vitest
130+
- Test file naming: `*.spec.ts` for co-located tests, `*.test.ts` for tests-unit package
131+
- Mock external dependencies with `vi.mock()` and `vi.fn()`
132+
- Run tests in Node.js environment (not jsdom) by default
133+
134+
### Comments and Documentation
135+
136+
- Use JSDoc comments for public APIs
137+
- Document complex logic with inline comments
138+
- Use `// TODO(username)` or `// TODO: description` for TODOs
139+
- Keep comments concise and relevant
140+
141+
## Package Manager
142+
143+
This project uses **pnpm** exclusively. Do not use npm or yarn commands.
144+
145+
```bash
146+
# Add a dependency to a specific package
147+
pnpm --filter <package-name> add <dependency>
148+
149+
# Add a dev dependency
150+
pnpm --filter <package-name> add -D <dependency>
151+
152+
# Run a script in a specific package
153+
pnpm --filter <package-name> <script-name>
154+
```
155+
156+
## Pre-commit Checks
157+
158+
Before committing, ensure:
159+
160+
1. `pnpm fmt:fix` - Code is properly formatted
161+
2. `pnpm lint:fix` - No linting errors
162+
3. `pnpm ts:check` - TypeScript compiles without errors
163+
4. `pnpm test` - All tests pass
164+
165+
Run `pnpm code:checks` to verify all checks pass.

packages/cloudflare/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"test:watch": "vitest"
5151
},
5252
"dependencies": {
53-
"@ast-grep/napi": "0.40.0",
53+
"@ast-grep/napi": "0.40.5",
5454
"@dotenvx/dotenvx": "catalog:",
5555
"@opennextjs/aws": "workspace:*",
5656
"cloudflare": "^4.4.1",

packages/open-next/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
"ts:check": "tsc --noEmit"
4747
},
4848
"dependencies": {
49-
"@ast-grep/napi": "^0.40.0",
50-
"@aws-sdk/client-cloudfront": "3.398.0",
51-
"@aws-sdk/client-dynamodb": "^3.398.0",
52-
"@aws-sdk/client-lambda": "^3.398.0",
53-
"@aws-sdk/client-s3": "^3.398.0",
54-
"@aws-sdk/client-sqs": "^3.398.0",
49+
"@ast-grep/napi": "^0.40.5",
50+
"@aws-sdk/client-cloudfront": "3.984.0",
51+
"@aws-sdk/client-dynamodb": "3.984.0",
52+
"@aws-sdk/client-lambda": "3.984.0",
53+
"@aws-sdk/client-s3": "3.984.0",
54+
"@aws-sdk/client-sqs": "3.984.0",
5555
"@node-minify/core": "^8.0.6",
5656
"@node-minify/terser": "^8.0.6",
5757
"@tsconfig/node18": "^1.0.3",

0 commit comments

Comments
 (0)