create-claude-webapp 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/acceptance-test-generator.md +256 -0
- package/.claude/agents/auth-flow-designer.md +93 -0
- package/.claude/agents/code-reviewer.md +193 -0
- package/.claude/agents/code-verifier.md +194 -0
- package/.claude/agents/deployment-executor.md +90 -0
- package/.claude/agents/design-sync.md +226 -0
- package/.claude/agents/document-reviewer.md +304 -0
- package/.claude/agents/environment-validator.md +100 -0
- package/.claude/agents/integration-test-reviewer.md +196 -0
- package/.claude/agents/investigator.md +162 -0
- package/.claude/agents/prd-creator.md +220 -0
- package/.claude/agents/quality-fixer-frontend.md +323 -0
- package/.claude/agents/quality-fixer.md +280 -0
- package/.claude/agents/requirement-analyzer.md +149 -0
- package/.claude/agents/rls-policy-designer.md +86 -0
- package/.claude/agents/rule-advisor.md +123 -0
- package/.claude/agents/scope-discoverer.md +231 -0
- package/.claude/agents/solver.md +173 -0
- package/.claude/agents/supabase-migration-generator.md +85 -0
- package/.claude/agents/task-decomposer.md +246 -0
- package/.claude/agents/task-executor-frontend.md +264 -0
- package/.claude/agents/task-executor.md +261 -0
- package/.claude/agents/technical-designer-frontend.md +444 -0
- package/.claude/agents/technical-designer.md +370 -0
- package/.claude/agents/verifier.md +193 -0
- package/.claude/agents/work-planner.md +211 -0
- package/.claude/commands/add-integration-tests.md +116 -0
- package/.claude/commands/build.md +77 -0
- package/.claude/commands/db-migrate.md +96 -0
- package/.claude/commands/deploy.md +95 -0
- package/.claude/commands/design.md +75 -0
- package/.claude/commands/diagnose.md +202 -0
- package/.claude/commands/front-build.md +116 -0
- package/.claude/commands/front-design.md +61 -0
- package/.claude/commands/front-plan.md +53 -0
- package/.claude/commands/front-reverse-design.md +183 -0
- package/.claude/commands/front-review.md +89 -0
- package/.claude/commands/implement.md +80 -0
- package/.claude/commands/local-dev.md +94 -0
- package/.claude/commands/plan.md +61 -0
- package/.claude/commands/project-inject.md +76 -0
- package/.claude/commands/refine-skill.md +207 -0
- package/.claude/commands/reverse-engineer.md +301 -0
- package/.claude/commands/review.md +88 -0
- package/.claude/commands/setup-auth.md +68 -0
- package/.claude/commands/setup-supabase.md +66 -0
- package/.claude/commands/setup-vercel.md +71 -0
- package/.claude/commands/sync-skills.md +116 -0
- package/.claude/commands/task.md +13 -0
- package/.claude/skills/coding-standards/SKILL.md +246 -0
- package/.claude/skills/documentation-criteria/SKILL.md +184 -0
- package/.claude/skills/documentation-criteria/references/adr-template.md +64 -0
- package/.claude/skills/documentation-criteria/references/design-template.md +263 -0
- package/.claude/skills/documentation-criteria/references/plan-template.md +130 -0
- package/.claude/skills/documentation-criteria/references/prd-template.md +109 -0
- package/.claude/skills/documentation-criteria/references/task-template.md +38 -0
- package/.claude/skills/frontend/technical-spec/SKILL.md +147 -0
- package/.claude/skills/frontend/typescript-rules/SKILL.md +136 -0
- package/.claude/skills/frontend/typescript-testing/SKILL.md +129 -0
- package/.claude/skills/fullstack-integration/SKILL.md +466 -0
- package/.claude/skills/implementation-approach/SKILL.md +141 -0
- package/.claude/skills/integration-e2e-testing/SKILL.md +146 -0
- package/.claude/skills/interview/SKILL.md +345 -0
- package/.claude/skills/project-context/SKILL.md +53 -0
- package/.claude/skills/stack-auth/SKILL.md +519 -0
- package/.claude/skills/subagents-orchestration-guide/SKILL.md +218 -0
- package/.claude/skills/supabase/SKILL.md +289 -0
- package/.claude/skills/supabase-edge-functions/SKILL.md +386 -0
- package/.claude/skills/supabase-local/SKILL.md +328 -0
- package/.claude/skills/supabase-testing/SKILL.md +513 -0
- package/.claude/skills/task-analyzer/SKILL.md +131 -0
- package/.claude/skills/task-analyzer/references/skills-index.yaml +375 -0
- package/.claude/skills/technical-spec/SKILL.md +86 -0
- package/.claude/skills/typescript-rules/SKILL.md +121 -0
- package/.claude/skills/typescript-testing/SKILL.md +155 -0
- package/.claude/skills/vercel-deployment/SKILL.md +355 -0
- package/.claude/skills/vercel-edge/SKILL.md +407 -0
- package/README.md +4 -17
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typescript-testing
|
|
3
|
+
description: Applies Vitest test design and quality standards. Provides coverage requirements and mock usage guides. Use when writing unit tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript Testing Rules
|
|
7
|
+
|
|
8
|
+
## Test Framework
|
|
9
|
+
|
|
10
|
+
- **Vitest**: This project uses Vitest
|
|
11
|
+
- Test imports: `import { describe, it, expect, beforeEach, vi } from 'vitest'`
|
|
12
|
+
- Mock creation: Use `vi.mock()`
|
|
13
|
+
|
|
14
|
+
## Basic Testing Policy
|
|
15
|
+
|
|
16
|
+
### Quality Requirements
|
|
17
|
+
- **Coverage**: Unit test coverage must be 70% or higher
|
|
18
|
+
- **Independence**: Each test can run independently without depending on other tests
|
|
19
|
+
- **Reproducibility**: Tests are environment-independent and always return the same results
|
|
20
|
+
- **Readability**: Test code maintains the same quality as production code
|
|
21
|
+
|
|
22
|
+
### Coverage Requirements
|
|
23
|
+
**Mandatory**: Unit test coverage must be 70% or higher
|
|
24
|
+
**Metrics**: Statements, Branches, Functions, Lines
|
|
25
|
+
|
|
26
|
+
### Test Types and Scope
|
|
27
|
+
1. **Unit Tests**
|
|
28
|
+
- Verify behavior of individual functions or classes
|
|
29
|
+
- Mock all external dependencies
|
|
30
|
+
- Most numerous, implemented with fine granularity
|
|
31
|
+
|
|
32
|
+
2. **Integration Tests**
|
|
33
|
+
- Verify coordination between multiple components
|
|
34
|
+
- Use actual dependencies (DB, API, etc.)
|
|
35
|
+
- Verify major functional flows
|
|
36
|
+
|
|
37
|
+
3. **Cross-functional Verification in E2E Tests**
|
|
38
|
+
- Mandatory verification of impact on existing features when adding new features
|
|
39
|
+
- Cover integration points with "High" and "Medium" impact levels from Design Doc's "Integration Point Map"
|
|
40
|
+
- Verification pattern: Existing feature operation -> Enable new feature -> Verify continuity of existing features
|
|
41
|
+
- Success criteria: No change in response content, processing time within 5 seconds
|
|
42
|
+
- Designed for automatic execution in CI/CD pipelines
|
|
43
|
+
|
|
44
|
+
## Test Implementation Conventions
|
|
45
|
+
|
|
46
|
+
### Directory Structure
|
|
47
|
+
```
|
|
48
|
+
src/
|
|
49
|
+
└── application/
|
|
50
|
+
└── services/
|
|
51
|
+
├── __tests__/
|
|
52
|
+
│ ├── service.test.ts # Unit tests
|
|
53
|
+
│ └── service.int.test.ts # Integration tests
|
|
54
|
+
└── service.ts
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Naming Conventions
|
|
58
|
+
- Test files: `{target-file-name}.test.ts`
|
|
59
|
+
- Integration test files: `{target-file-name}.int.test.ts`
|
|
60
|
+
- Test suites: Names describing target features or situations
|
|
61
|
+
- Test cases: Names describing expected behavior
|
|
62
|
+
|
|
63
|
+
### Test Code Quality Rules
|
|
64
|
+
|
|
65
|
+
**Recommended: Keep all tests always active**
|
|
66
|
+
- Merit: Guarantees test suite completeness
|
|
67
|
+
- Practice: Fix problematic tests and activate them
|
|
68
|
+
|
|
69
|
+
**Avoid: test.skip() or commenting out**
|
|
70
|
+
- Reason: Creates test gaps and incomplete quality checks
|
|
71
|
+
- Solution: Completely delete unnecessary tests
|
|
72
|
+
|
|
73
|
+
## Test Quality Criteria
|
|
74
|
+
|
|
75
|
+
### Boundary and Error Case Coverage
|
|
76
|
+
Include boundary values and error cases alongside happy paths.
|
|
77
|
+
```typescript
|
|
78
|
+
it('returns 0 for empty array', () => expect(calc([])).toBe(0))
|
|
79
|
+
it('throws on negative price', () => expect(() => calc([{price: -1}])).toThrow())
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Literal Expected Values
|
|
83
|
+
Use literal values for assertions. Do not replicate implementation logic.
|
|
84
|
+
**Valid test**: Expected value != Mock return value (implementation transforms/processes data)
|
|
85
|
+
```typescript
|
|
86
|
+
expect(calcTax(100)).toBe(10) // not: 100 * TAX_RATE
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Result-Based Verification
|
|
90
|
+
Verify results, not invocation order or count.
|
|
91
|
+
```typescript
|
|
92
|
+
expect(mock).toHaveBeenCalledWith('a') // not: toHaveBeenNthCalledWith
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Meaningful Assertions
|
|
96
|
+
Each test must include at least one verification.
|
|
97
|
+
```typescript
|
|
98
|
+
it('creates user', async () => {
|
|
99
|
+
const user = await createUser({name: 'test'})
|
|
100
|
+
expect(user.id).toBeDefined()
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Appropriate Mock Scope
|
|
105
|
+
Mock only direct external I/O dependencies. Use real implementations for indirect dependencies.
|
|
106
|
+
```typescript
|
|
107
|
+
vi.mock('./database') // external I/O only
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Property-based Testing (fast-check)
|
|
111
|
+
Use fast-check when verifying invariants or properties.
|
|
112
|
+
```typescript
|
|
113
|
+
import fc from 'fast-check'
|
|
114
|
+
|
|
115
|
+
it('reverses twice equals original', () => {
|
|
116
|
+
fc.assert(fc.property(fc.array(fc.integer()), (arr) => {
|
|
117
|
+
return JSON.stringify(arr.reverse().reverse()) === JSON.stringify(arr)
|
|
118
|
+
}))
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Usage condition**: Use when Property annotations are assigned to ACs in Design Doc.
|
|
123
|
+
|
|
124
|
+
## Mock Type Safety Enforcement
|
|
125
|
+
|
|
126
|
+
### Minimal Type Definition Requirements
|
|
127
|
+
```typescript
|
|
128
|
+
// Only required parts
|
|
129
|
+
type TestRepo = Pick<Repository, 'find' | 'save'>
|
|
130
|
+
const mock: TestRepo = { find: vi.fn(), save: vi.fn() }
|
|
131
|
+
|
|
132
|
+
// Only when absolutely necessary, with clear justification
|
|
133
|
+
const sdkMock = {
|
|
134
|
+
call: vi.fn()
|
|
135
|
+
} as unknown as ExternalSDK // Complex external SDK type structure
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Basic Vitest Example
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
142
|
+
|
|
143
|
+
vi.mock('./userService', () => ({
|
|
144
|
+
getUserById: vi.fn(),
|
|
145
|
+
updateUser: vi.fn()
|
|
146
|
+
}))
|
|
147
|
+
|
|
148
|
+
describe('ComponentName', () => {
|
|
149
|
+
it('should follow AAA pattern', () => {
|
|
150
|
+
const input = 'test'
|
|
151
|
+
const result = someFunction(input)
|
|
152
|
+
expect(result).toBe('expected')
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
```
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vercel-deployment
|
|
3
|
+
description: Vercel configuration, environment variables, and deployments. Use when deploying to Vercel, configuring builds, or managing environment variables.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vercel Deployment
|
|
7
|
+
|
|
8
|
+
## Configuration
|
|
9
|
+
|
|
10
|
+
### vercel.json Structure
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"framework": "nextjs",
|
|
14
|
+
"buildCommand": "npm run build",
|
|
15
|
+
"installCommand": "npm install",
|
|
16
|
+
"outputDirectory": ".next",
|
|
17
|
+
"regions": ["iad1"],
|
|
18
|
+
"functions": {
|
|
19
|
+
"api/**/*.ts": {
|
|
20
|
+
"memory": 1024,
|
|
21
|
+
"maxDuration": 10
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"headers": [
|
|
25
|
+
{
|
|
26
|
+
"source": "/api/(.*)",
|
|
27
|
+
"headers": [
|
|
28
|
+
{ "key": "Cache-Control", "value": "no-store" }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"rewrites": [
|
|
33
|
+
{ "source": "/api/health", "destination": "/api/health-check" }
|
|
34
|
+
],
|
|
35
|
+
"redirects": [
|
|
36
|
+
{ "source": "/old-path", "destination": "/new-path", "permanent": true }
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Framework Detection
|
|
42
|
+
Vercel auto-detects frameworks. Override if needed:
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"framework": "nextjs" | "vite" | "remix" | "astro" | null
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Environment Variables
|
|
50
|
+
|
|
51
|
+
### Naming Conventions
|
|
52
|
+
|
|
53
|
+
| Prefix | Exposure | Use Case |
|
|
54
|
+
|--------|----------|----------|
|
|
55
|
+
| `NEXT_PUBLIC_` | Browser + Server | Public API URLs, feature flags |
|
|
56
|
+
| No prefix | Server only | API keys, secrets, database URLs |
|
|
57
|
+
|
|
58
|
+
### Setting Environment Variables
|
|
59
|
+
|
|
60
|
+
**Via CLI**
|
|
61
|
+
```bash
|
|
62
|
+
# Add to all environments
|
|
63
|
+
vercel env add MY_SECRET
|
|
64
|
+
|
|
65
|
+
# Add to specific environment
|
|
66
|
+
vercel env add MY_SECRET production
|
|
67
|
+
vercel env add MY_SECRET preview
|
|
68
|
+
vercel env add MY_SECRET development
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Via Project Settings**
|
|
72
|
+
1. Dashboard > Project > Settings > Environment Variables
|
|
73
|
+
2. Add variable name and value
|
|
74
|
+
3. Select environments (Production, Preview, Development)
|
|
75
|
+
|
|
76
|
+
### Required Variables for Supabase + Stack-auth
|
|
77
|
+
```env
|
|
78
|
+
# Public (browser-accessible)
|
|
79
|
+
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
|
|
80
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
|
|
81
|
+
NEXT_PUBLIC_STACK_AUTH_URL=https://api.stack-auth.com
|
|
82
|
+
NEXT_PUBLIC_STACK_AUTH_PROJECT_ID=your-project-id
|
|
83
|
+
|
|
84
|
+
# Server-only secrets
|
|
85
|
+
SUPABASE_SERVICE_ROLE_KEY=eyJ...
|
|
86
|
+
STACK_AUTH_SECRET_KEY=sk_...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Pulling Environment Variables Locally
|
|
90
|
+
```bash
|
|
91
|
+
# Link project first
|
|
92
|
+
vercel link
|
|
93
|
+
|
|
94
|
+
# Pull env vars to .env.local
|
|
95
|
+
vercel env pull .env.local
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Build Configuration
|
|
99
|
+
|
|
100
|
+
### Build Commands
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"buildCommand": "npm run build",
|
|
104
|
+
"installCommand": "npm ci",
|
|
105
|
+
"devCommand": "npm run dev"
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Build Output Settings
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"outputDirectory": ".next",
|
|
113
|
+
"cleanUrls": true,
|
|
114
|
+
"trailingSlash": false
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Root Directory (Monorepo)
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"rootDirectory": "apps/web"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Deployment Types
|
|
126
|
+
|
|
127
|
+
### Production Deployments
|
|
128
|
+
```bash
|
|
129
|
+
# Deploy to production
|
|
130
|
+
vercel --prod
|
|
131
|
+
|
|
132
|
+
# Or via git push to main branch
|
|
133
|
+
git push origin main
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Preview Deployments
|
|
137
|
+
- Automatic on PR creation
|
|
138
|
+
- Unique URL per deployment
|
|
139
|
+
- Comment on PR with preview link
|
|
140
|
+
|
|
141
|
+
### Manual Deployments
|
|
142
|
+
```bash
|
|
143
|
+
# Deploy current directory
|
|
144
|
+
vercel
|
|
145
|
+
|
|
146
|
+
# Deploy specific directory
|
|
147
|
+
vercel ./dist
|
|
148
|
+
|
|
149
|
+
# Deploy with specific name
|
|
150
|
+
vercel --name my-deployment
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Build Optimization
|
|
154
|
+
|
|
155
|
+
### Caching
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"build": {
|
|
159
|
+
"env": {
|
|
160
|
+
"VERCEL_CACHE_KEY": "v1"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Ignore Build Step
|
|
167
|
+
```bash
|
|
168
|
+
# vercel.json or package.json script
|
|
169
|
+
# Return exit code 0 to skip, 1 to build
|
|
170
|
+
|
|
171
|
+
# Example: Skip if only docs changed
|
|
172
|
+
git diff HEAD^ HEAD --quiet -- docs/
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Build Hooks
|
|
176
|
+
```bash
|
|
177
|
+
# Trigger build via webhook
|
|
178
|
+
curl -X POST https://api.vercel.com/v1/integrations/deploy/YOUR_DEPLOY_HOOK
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Function Configuration
|
|
182
|
+
|
|
183
|
+
### Serverless Functions
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"functions": {
|
|
187
|
+
"api/**/*.ts": {
|
|
188
|
+
"memory": 1024,
|
|
189
|
+
"maxDuration": 10
|
|
190
|
+
},
|
|
191
|
+
"api/heavy-task.ts": {
|
|
192
|
+
"memory": 3008,
|
|
193
|
+
"maxDuration": 60
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Memory and Duration Limits
|
|
200
|
+
|
|
201
|
+
| Plan | Max Memory | Max Duration |
|
|
202
|
+
|------|------------|--------------|
|
|
203
|
+
| Hobby | 1024 MB | 10s |
|
|
204
|
+
| Pro | 3008 MB | 60s |
|
|
205
|
+
| Enterprise | 3008 MB | 900s |
|
|
206
|
+
|
|
207
|
+
## Domain Configuration
|
|
208
|
+
|
|
209
|
+
### Adding Custom Domain
|
|
210
|
+
```bash
|
|
211
|
+
# Via CLI
|
|
212
|
+
vercel domains add example.com
|
|
213
|
+
|
|
214
|
+
# Verify DNS
|
|
215
|
+
vercel domains verify example.com
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### DNS Records
|
|
219
|
+
```
|
|
220
|
+
Type: A
|
|
221
|
+
Name: @
|
|
222
|
+
Value: 76.76.21.21
|
|
223
|
+
|
|
224
|
+
Type: CNAME
|
|
225
|
+
Name: www
|
|
226
|
+
Value: cname.vercel-dns.com
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Deployment Protection
|
|
230
|
+
|
|
231
|
+
### Password Protection (Preview)
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"headers": [
|
|
235
|
+
{
|
|
236
|
+
"source": "/(.*)",
|
|
237
|
+
"headers": [
|
|
238
|
+
{
|
|
239
|
+
"key": "x-vercel-protection-bypass",
|
|
240
|
+
"value": "{{VERCEL_AUTOMATION_BYPASS_SECRET}}"
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### IP Allowlisting
|
|
249
|
+
Configure in Dashboard > Project > Settings > Deployment Protection
|
|
250
|
+
|
|
251
|
+
## Monitoring and Logs
|
|
252
|
+
|
|
253
|
+
### Viewing Logs
|
|
254
|
+
```bash
|
|
255
|
+
# Real-time logs
|
|
256
|
+
vercel logs your-deployment-url
|
|
257
|
+
|
|
258
|
+
# Via Dashboard
|
|
259
|
+
# Project > Deployments > Select deployment > View Logs
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Speed Insights
|
|
263
|
+
```typescript
|
|
264
|
+
// Enable in next.config.js
|
|
265
|
+
const config = {
|
|
266
|
+
experimental: {
|
|
267
|
+
instrumentationHook: true,
|
|
268
|
+
},
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## CI/CD Integration
|
|
273
|
+
|
|
274
|
+
### GitHub Actions
|
|
275
|
+
```yaml
|
|
276
|
+
# .github/workflows/deploy.yml
|
|
277
|
+
name: Deploy to Vercel
|
|
278
|
+
|
|
279
|
+
on:
|
|
280
|
+
push:
|
|
281
|
+
branches: [main]
|
|
282
|
+
|
|
283
|
+
jobs:
|
|
284
|
+
deploy:
|
|
285
|
+
runs-on: ubuntu-latest
|
|
286
|
+
steps:
|
|
287
|
+
- uses: actions/checkout@v4
|
|
288
|
+
|
|
289
|
+
- name: Deploy to Vercel
|
|
290
|
+
uses: amondnet/vercel-action@v25
|
|
291
|
+
with:
|
|
292
|
+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
293
|
+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
|
|
294
|
+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
|
|
295
|
+
vercel-args: '--prod'
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Getting Credentials
|
|
299
|
+
```bash
|
|
300
|
+
# Get org ID and project ID
|
|
301
|
+
vercel link
|
|
302
|
+
# Check .vercel/project.json
|
|
303
|
+
|
|
304
|
+
# Create token
|
|
305
|
+
# Dashboard > Account Settings > Tokens
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Troubleshooting
|
|
309
|
+
|
|
310
|
+
### Common Build Errors
|
|
311
|
+
|
|
312
|
+
| Error | Cause | Solution |
|
|
313
|
+
|-------|-------|----------|
|
|
314
|
+
| `Module not found` | Missing dependency | Check package.json, run `npm install` |
|
|
315
|
+
| `Type error` | TypeScript error | Fix type errors before deploy |
|
|
316
|
+
| `Out of memory` | Build too large | Increase memory or optimize |
|
|
317
|
+
| `Build timeout` | Build too slow | Optimize build, use caching |
|
|
318
|
+
|
|
319
|
+
### Debug Build Locally
|
|
320
|
+
```bash
|
|
321
|
+
# Simulate Vercel build
|
|
322
|
+
vercel build
|
|
323
|
+
|
|
324
|
+
# Check output
|
|
325
|
+
ls -la .vercel/output/
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Rollback
|
|
329
|
+
```bash
|
|
330
|
+
# Via CLI
|
|
331
|
+
vercel rollback
|
|
332
|
+
|
|
333
|
+
# Or in Dashboard
|
|
334
|
+
# Project > Deployments > ... > Promote to Production
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Best Practices
|
|
338
|
+
|
|
339
|
+
### Security Checklist
|
|
340
|
+
- [ ] No secrets in `NEXT_PUBLIC_` variables
|
|
341
|
+
- [ ] Service role keys only on server
|
|
342
|
+
- [ ] Deployment protection enabled for preview
|
|
343
|
+
- [ ] Environment variables per environment
|
|
344
|
+
|
|
345
|
+
### Performance Checklist
|
|
346
|
+
- [ ] Enable caching headers for static assets
|
|
347
|
+
- [ ] Use Edge runtime where appropriate
|
|
348
|
+
- [ ] Minimize serverless function cold starts
|
|
349
|
+
- [ ] Configure appropriate regions
|
|
350
|
+
|
|
351
|
+
### Deployment Checklist
|
|
352
|
+
- [ ] Test preview deployment before production
|
|
353
|
+
- [ ] Verify environment variables are set
|
|
354
|
+
- [ ] Check build logs for warnings
|
|
355
|
+
- [ ] Monitor initial traffic after deploy
|