@el-j/magic-helix-plugins 4.0.0-beta.1 → 4.0.0-beta.3
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/dist/architecture/codeowners.md +123 -0
- package/dist/architecture/monorepo.md +146 -0
- package/dist/architecture/nx.md +122 -0
- package/dist/architecture/turborepo.md +114 -0
- package/dist/ci/github-actions.md +268 -0
- package/dist/ci/gitlab-ci.md +330 -0
- package/dist/containers/docker-multistage.md +120 -0
- package/dist/containers/kubernetes-deploy.md +210 -0
- package/dist/cpp/index.cjs +79 -0
- package/dist/cpp/index.mjs +209 -0
- package/dist/csharp/index.cjs +2 -2
- package/dist/csharp/{index.js → index.mjs} +17 -11
- package/dist/csharp/templates/framework-aspnetcore.md +205 -0
- package/dist/csharp/templates/framework-blazor.md +271 -0
- package/dist/csharp/templates/lang-csharp.md +162 -0
- package/dist/devops/docker-compose.md +111 -0
- package/dist/devops/docker-dockerfile.md +94 -0
- package/dist/devops/github-actions.md +160 -0
- package/dist/devops/gitlab-ci.md +210 -0
- package/dist/generic/lang-typescript.md +57 -0
- package/dist/generic/state-redux.md +21 -0
- package/dist/generic/state-rxjs.md +6 -0
- package/dist/generic/style-mui.md +23 -0
- package/dist/generic/style-tailwind.md +76 -0
- package/dist/generic/test-cypress.md +21 -0
- package/dist/generic/test-jest.md +20 -0
- package/dist/generic/test-playwright.md +21 -0
- package/dist/generic/test-vitest.md +131 -0
- package/dist/go/index.cjs +3 -3
- package/dist/go/{index.js → index.mjs} +18 -15
- package/dist/go/templates/lang-go.md +571 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +24 -0
- package/dist/java/index.cjs +2 -2
- package/dist/java/{index.js → index.mjs} +25 -19
- package/dist/java/templates/build-gradle.md +102 -0
- package/dist/java/templates/build-maven.md +86 -0
- package/dist/java/templates/framework-spring-boot.md +179 -0
- package/dist/java/templates/lang-java.md +78 -0
- package/dist/java/templates/lang-kotlin.md +88 -0
- package/dist/meta/magic-helix-meta.md +213 -0
- package/dist/meta/meta-debug.md +459 -0
- package/dist/meta/meta-implement.md +450 -0
- package/dist/meta/meta-roadmap.md +265 -0
- package/dist/nodejs/templates/angular-core.md +19 -0
- package/dist/nodejs/templates/lang-typescript.md +57 -0
- package/dist/nodejs/templates/nestjs-core.md +7 -0
- package/dist/nodejs/templates/react-core.md +677 -0
- package/dist/nodejs/templates/react-zustand.md +7 -0
- package/dist/nodejs/templates/state-redux.md +21 -0
- package/dist/nodejs/templates/state-rxjs.md +6 -0
- package/dist/nodejs/templates/style-primevue.md +6 -0
- package/dist/nodejs/templates/style-quasar.md +22 -0
- package/dist/nodejs/templates/style-tailwind.md +76 -0
- package/dist/nodejs/templates/test-cypress.md +21 -0
- package/dist/nodejs/templates/test-jest.md +20 -0
- package/dist/nodejs/templates/test-playwright.md +21 -0
- package/dist/nodejs/templates/test-vitest.md +131 -0
- package/dist/nodejs/templates/vue-core.md +108 -0
- package/dist/nodejs/templates/vue-pinia.md +5 -0
- package/dist/patterns/architecture/clean-architecture.md +469 -0
- package/dist/patterns/architecture/dependency-injection.md +517 -0
- package/dist/patterns/architecture/domain-driven-design.md +621 -0
- package/dist/patterns/architecture/layered-architecture.md +382 -0
- package/dist/patterns/architecture/repository-pattern.md +408 -0
- package/dist/patterns/domain-expertise/nextjs-rules.md +115 -0
- package/dist/patterns/domain-expertise/react-patterns.md +181 -0
- package/dist/patterns/domain-expertise/server-components.md +212 -0
- package/dist/patterns/domain-expertise/shadcn-ui.md +52 -0
- package/dist/patterns/domain-expertise/tailwind-patterns.md +52 -0
- package/dist/patterns/environment/container-awareness.md +17 -0
- package/dist/patterns/environment/ide-features.md +17 -0
- package/dist/patterns/environment/os-commands.md +17 -0
- package/dist/patterns/organization/heading-hierarchy.md +103 -0
- package/dist/patterns/organization/sequential-workflows.md +102 -0
- package/dist/patterns/organization/xml-rule-groups.md +64 -0
- package/dist/patterns/reasoning/agent-loop.md +151 -0
- package/dist/patterns/reasoning/confirmation-gates.md +141 -0
- package/dist/patterns/reasoning/dependency-analysis.md +132 -0
- package/dist/patterns/reasoning/one-tool-per-iteration.md +152 -0
- package/dist/patterns/reasoning/preview-before-action.md +194 -0
- package/dist/patterns/reasoning/reflection-checkpoints.md +166 -0
- package/dist/patterns/reasoning/result-verification.md +157 -0
- package/dist/patterns/reasoning/subtask-breakdown.md +131 -0
- package/dist/patterns/reasoning/thinking-tags.md +100 -0
- package/dist/patterns/role-definition/capability-declarations.md +72 -0
- package/dist/patterns/role-definition/expert-identity.md +45 -0
- package/dist/patterns/role-definition/scope-boundaries.md +61 -0
- package/dist/patterns/safety/code-safety-rules.md +17 -0
- package/dist/patterns/safety/credential-handling.md +17 -0
- package/dist/patterns/safety/destructive-warnings.md +17 -0
- package/dist/patterns/safety/refusal-messages.md +17 -0
- package/dist/patterns/tone/adaptive-tone.md +17 -0
- package/dist/patterns/tone/concise-communication.md +17 -0
- package/dist/patterns/tone/forbidden-phrases.md +17 -0
- package/dist/patterns/tool-guidelines/function-schemas.md +143 -0
- package/dist/patterns/tool-guidelines/parameter-examples.md +137 -0
- package/dist/patterns/tool-guidelines/usage-policies.md +105 -0
- package/dist/php/index.cjs +2 -2
- package/dist/php/{index.js → index.mjs} +12 -6
- package/dist/php/templates/framework-laravel.md +112 -0
- package/dist/php/templates/lang-php.md +94 -0
- package/dist/python/index.cjs +4 -4
- package/dist/python/{index.js → index.mjs} +10 -7
- package/dist/python/templates/lang-python.md +508 -0
- package/dist/ruby/index.cjs +2 -2
- package/dist/ruby/{index.js → index.mjs} +16 -10
- package/dist/ruby/templates/framework-rails.md +309 -0
- package/dist/ruby/templates/framework-sinatra.md +227 -0
- package/dist/ruby/templates/lang-ruby.md +216 -0
- package/dist/rust/index.cjs +3 -3
- package/dist/rust/{index.js → index.mjs} +24 -18
- package/dist/rust/templates/lang-rust.md +89 -0
- package/dist/swift/index.cjs +32 -0
- package/dist/swift/index.mjs +112 -0
- package/dist/swift/templates/framework-vapor.md +352 -0
- package/dist/swift/templates/lang-swift.md +291 -0
- package/package.json +31 -21
- package/dist/index.js +0 -20
- /package/dist/nodejs/{index.js → index.mjs} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# CODEOWNERS Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This project uses CODEOWNERS file to define code ownership and automate review requests.
|
|
5
|
+
|
|
6
|
+
## File Location
|
|
7
|
+
- `.github/CODEOWNERS` (recommended)
|
|
8
|
+
- `CODEOWNERS` (root)
|
|
9
|
+
- `docs/CODEOWNERS`
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
```
|
|
13
|
+
# Comments start with #
|
|
14
|
+
# Each line: pattern followed by owners
|
|
15
|
+
|
|
16
|
+
# Default owners for everything
|
|
17
|
+
* @org/default-team
|
|
18
|
+
|
|
19
|
+
# Specific directories
|
|
20
|
+
/docs/ @org/docs-team @user1
|
|
21
|
+
/src/api/ @org/backend-team
|
|
22
|
+
/src/ui/ @org/frontend-team
|
|
23
|
+
|
|
24
|
+
# Specific files
|
|
25
|
+
package.json @org/platform-team
|
|
26
|
+
Dockerfile @org/devops-team
|
|
27
|
+
|
|
28
|
+
# Wildcards
|
|
29
|
+
*.md @org/docs-team
|
|
30
|
+
**/*.test.ts @org/qa-team
|
|
31
|
+
|
|
32
|
+
# Multiple owners
|
|
33
|
+
/src/auth/ @org/security-team @org/backend-team
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Pattern Matching
|
|
37
|
+
- `*`: Matches any files
|
|
38
|
+
- `**`: Matches directories recursively
|
|
39
|
+
- `?`: Matches single character
|
|
40
|
+
- `[abc]`: Matches a, b, or c
|
|
41
|
+
- Last matching pattern takes precedence
|
|
42
|
+
|
|
43
|
+
## Owner Types
|
|
44
|
+
- Individual users: `@username`
|
|
45
|
+
- Teams: `@org/team-name`
|
|
46
|
+
- Email addresses: `user@example.com`
|
|
47
|
+
|
|
48
|
+
## Best Practices
|
|
49
|
+
- Define default owners at the top
|
|
50
|
+
- Be specific with critical paths
|
|
51
|
+
- Assign multiple owners for coverage
|
|
52
|
+
- Keep teams small and focused
|
|
53
|
+
- Document ownership rationale
|
|
54
|
+
- Review and update regularly
|
|
55
|
+
|
|
56
|
+
## Review Requirements
|
|
57
|
+
- Owners are automatically requested for reviews
|
|
58
|
+
- Can require approval from code owners (branch protection)
|
|
59
|
+
- Blocks merge without owner approval
|
|
60
|
+
|
|
61
|
+
## Responsibilities
|
|
62
|
+
- Code owners should:
|
|
63
|
+
- Review PRs affecting their code
|
|
64
|
+
- Maintain code quality
|
|
65
|
+
- Update documentation
|
|
66
|
+
- Mentor contributors
|
|
67
|
+
- Keep ownership updated
|
|
68
|
+
|
|
69
|
+
## Common Patterns
|
|
70
|
+
```
|
|
71
|
+
# Backend API
|
|
72
|
+
/src/api/**/*.ts @org/backend-team
|
|
73
|
+
|
|
74
|
+
# Frontend Components
|
|
75
|
+
/src/components/**/*.tsx @org/frontend-team
|
|
76
|
+
|
|
77
|
+
# Infrastructure
|
|
78
|
+
/infrastructure/ @org/devops-team
|
|
79
|
+
/.github/workflows/ @org/devops-team
|
|
80
|
+
|
|
81
|
+
# Documentation
|
|
82
|
+
/docs/ @org/docs-team
|
|
83
|
+
*.md @org/docs-team
|
|
84
|
+
|
|
85
|
+
# Configuration
|
|
86
|
+
*.config.js @org/platform-team
|
|
87
|
+
package.json @org/platform-team
|
|
88
|
+
|
|
89
|
+
# Database
|
|
90
|
+
/migrations/ @org/backend-team @org/dba-team
|
|
91
|
+
|
|
92
|
+
# Security
|
|
93
|
+
/src/auth/ @org/security-team
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Branch Protection
|
|
97
|
+
- Enable "Require review from Code Owners"
|
|
98
|
+
- Set minimum number of approvals
|
|
99
|
+
- Dismiss stale reviews on push
|
|
100
|
+
|
|
101
|
+
## Notifications
|
|
102
|
+
- Owners receive review requests
|
|
103
|
+
- Configure notification preferences
|
|
104
|
+
- Use team mentions for broader awareness
|
|
105
|
+
|
|
106
|
+
## Troubleshooting
|
|
107
|
+
- Validate CODEOWNERS syntax
|
|
108
|
+
- Check team membership
|
|
109
|
+
- Verify file patterns match
|
|
110
|
+
- Test with specific files
|
|
111
|
+
|
|
112
|
+
## Integration
|
|
113
|
+
- Works with pull requests
|
|
114
|
+
- Integrates with branch protection
|
|
115
|
+
- Appears in PR sidebar
|
|
116
|
+
- Can be queried via API
|
|
117
|
+
|
|
118
|
+
## Maintenance
|
|
119
|
+
- Review quarterly
|
|
120
|
+
- Update for new teams/members
|
|
121
|
+
- Remove inactive owners
|
|
122
|
+
- Refactor for restructuring
|
|
123
|
+
- Document in team wiki
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Monorepo Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This project uses a monorepo structure to manage multiple packages/applications in a single repository.
|
|
5
|
+
|
|
6
|
+
## Structure
|
|
7
|
+
```
|
|
8
|
+
project-root/
|
|
9
|
+
├── packages/
|
|
10
|
+
│ ├── package-a/
|
|
11
|
+
│ ├── package-b/
|
|
12
|
+
│ └── shared/
|
|
13
|
+
├── apps/
|
|
14
|
+
│ ├── web/
|
|
15
|
+
│ └── mobile/
|
|
16
|
+
├── package.json (workspace root)
|
|
17
|
+
└── turbo.json or nx.json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Workspace Commands
|
|
21
|
+
- Install all dependencies: `npm install` (at root)
|
|
22
|
+
- Run script in workspace: `npm run <script> --workspace=<package-name>`
|
|
23
|
+
- Run script in all workspaces: `npm run <script> --workspaces`
|
|
24
|
+
- Add dependency to workspace: `npm install <pkg> --workspace=<name>`
|
|
25
|
+
|
|
26
|
+
## Benefits
|
|
27
|
+
- Code sharing between packages
|
|
28
|
+
- Atomic changes across multiple packages
|
|
29
|
+
- Unified versioning and releases
|
|
30
|
+
- Shared tooling and configuration
|
|
31
|
+
- Single source of truth
|
|
32
|
+
|
|
33
|
+
## Package Dependencies
|
|
34
|
+
- Reference workspace packages: `"package-a": "*"` or `"workspace:*"`
|
|
35
|
+
- Changes in dependencies trigger downstream rebuilds
|
|
36
|
+
- Use semver for external dependencies
|
|
37
|
+
|
|
38
|
+
## Build Orchestration
|
|
39
|
+
- Define build order based on dependencies
|
|
40
|
+
- Use `turbo` or `nx` for caching and parallelization
|
|
41
|
+
- Run only affected packages on changes
|
|
42
|
+
|
|
43
|
+
## Common Tools
|
|
44
|
+
|
|
45
|
+
### Turborepo
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"pipeline": {
|
|
49
|
+
"build": {
|
|
50
|
+
"dependsOn": ["^build"],
|
|
51
|
+
"outputs": ["dist/**"]
|
|
52
|
+
},
|
|
53
|
+
"test": {
|
|
54
|
+
"dependsOn": ["build"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Nx
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"tasksRunnerOptions": {
|
|
64
|
+
"default": {
|
|
65
|
+
"runner": "@nrwl/workspace/tasks-runners/default",
|
|
66
|
+
"options": {
|
|
67
|
+
"cacheableOperations": ["build", "test"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Best Practices
|
|
75
|
+
- Keep packages focused and small
|
|
76
|
+
- Use consistent naming conventions
|
|
77
|
+
- Share common configuration files
|
|
78
|
+
- Version packages independently or together
|
|
79
|
+
- Document package purposes in README
|
|
80
|
+
- Use path mappings for imports
|
|
81
|
+
- Hoist dependencies when possible
|
|
82
|
+
|
|
83
|
+
## Scripts Management
|
|
84
|
+
- Define common scripts at root
|
|
85
|
+
- Delegate to workspace-specific scripts
|
|
86
|
+
- Use parallel execution for independent tasks
|
|
87
|
+
- Run affected packages only
|
|
88
|
+
|
|
89
|
+
## Testing
|
|
90
|
+
- Run tests from root: `npm test --workspaces`
|
|
91
|
+
- Run tests for specific package: `npm test --workspace=<name>`
|
|
92
|
+
- Use shared test configuration
|
|
93
|
+
- Test cross-package integration
|
|
94
|
+
|
|
95
|
+
## Versioning
|
|
96
|
+
- **Independent**: Each package has own version
|
|
97
|
+
- **Fixed**: All packages share same version
|
|
98
|
+
- Use changesets for version management
|
|
99
|
+
- Document breaking changes
|
|
100
|
+
|
|
101
|
+
## Publishing
|
|
102
|
+
- Publish packages independently
|
|
103
|
+
- Use automated versioning tools
|
|
104
|
+
- Test before publishing
|
|
105
|
+
- Update changelogs
|
|
106
|
+
|
|
107
|
+
## TypeScript Configuration
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"references": [
|
|
111
|
+
{ "path": "./packages/package-a" },
|
|
112
|
+
{ "path": "./packages/package-b" }
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Import Paths
|
|
118
|
+
- Use path aliases: `@company/package-name`
|
|
119
|
+
- Configure in `tsconfig.json` paths
|
|
120
|
+
- Set up module resolution
|
|
121
|
+
|
|
122
|
+
## Challenges & Solutions
|
|
123
|
+
- **Problem**: Dependency hell
|
|
124
|
+
- **Solution**: Use workspaces, hoist dependencies
|
|
125
|
+
- **Problem**: Slow builds
|
|
126
|
+
- **Solution**: Use caching (turbo/nx), build affected only
|
|
127
|
+
- **Problem**: Complex tooling
|
|
128
|
+
- **Solution**: Share configs, document setup
|
|
129
|
+
|
|
130
|
+
## CI/CD
|
|
131
|
+
- Build only affected packages
|
|
132
|
+
- Cache build outputs
|
|
133
|
+
- Run tasks in parallel
|
|
134
|
+
- Use matrix builds for packages
|
|
135
|
+
|
|
136
|
+
## Performance
|
|
137
|
+
- Enable caching for build outputs
|
|
138
|
+
- Use incremental builds
|
|
139
|
+
- Parallelize independent tasks
|
|
140
|
+
- Skip unchanged packages
|
|
141
|
+
|
|
142
|
+
## Documentation
|
|
143
|
+
- Maintain root-level README
|
|
144
|
+
- Document each package purpose
|
|
145
|
+
- Explain workspace structure
|
|
146
|
+
- Provide contribution guidelines
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Nx Monorepo Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This monorepo uses Nx for build orchestration, code generation, and project management.
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
- Run target: `nx run <project>:<target>`
|
|
8
|
+
- Run for all projects: `nx run-many --target=build --all`
|
|
9
|
+
- Run affected: `nx affected --target=build`
|
|
10
|
+
- Show dependency graph: `nx graph`
|
|
11
|
+
- Generate code: `nx generate @nx/react:component`
|
|
12
|
+
|
|
13
|
+
## Project Configuration
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"name": "my-app",
|
|
17
|
+
"targets": {
|
|
18
|
+
"build": {
|
|
19
|
+
"executor": "@nx/webpack:webpack",
|
|
20
|
+
"outputs": ["{workspaceRoot}/dist/apps/my-app"],
|
|
21
|
+
"options": {
|
|
22
|
+
"outputPath": "dist/apps/my-app"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Affected Commands
|
|
30
|
+
- Build affected: `nx affected:build`
|
|
31
|
+
- Test affected: `nx affected:test`
|
|
32
|
+
- Lint affected: `nx affected:lint`
|
|
33
|
+
- Based on git diff from base branch
|
|
34
|
+
|
|
35
|
+
## Caching
|
|
36
|
+
- Nx caches task outputs automatically
|
|
37
|
+
- Cache key based on inputs
|
|
38
|
+
- Restore from cache for unchanged code
|
|
39
|
+
- Configure cacheable operations
|
|
40
|
+
|
|
41
|
+
## Generators
|
|
42
|
+
- Generate applications: `nx g @nx/react:app`
|
|
43
|
+
- Generate libraries: `nx g @nx/js:lib`
|
|
44
|
+
- Custom generators for consistency
|
|
45
|
+
- Automated code scaffolding
|
|
46
|
+
|
|
47
|
+
## Project Graph
|
|
48
|
+
- Visualize dependencies: `nx graph`
|
|
49
|
+
- See affected projects
|
|
50
|
+
- Understand project relationships
|
|
51
|
+
- Detect circular dependencies
|
|
52
|
+
|
|
53
|
+
## Configuration Files
|
|
54
|
+
- `nx.json`: Nx configuration
|
|
55
|
+
- `workspace.json` or `project.json`: Project config
|
|
56
|
+
- `.nxignore`: Files to ignore
|
|
57
|
+
|
|
58
|
+
## Task Pipeline
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"targetDefaults": {
|
|
62
|
+
"build": {
|
|
63
|
+
"dependsOn": ["^build"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Plugins
|
|
70
|
+
- Framework-specific plugins: React, Angular, Next.js
|
|
71
|
+
- Tool-specific plugins: Jest, Cypress, ESLint
|
|
72
|
+
- Custom plugins for specific needs
|
|
73
|
+
|
|
74
|
+
## Workspace Libraries
|
|
75
|
+
- Organize code into libraries
|
|
76
|
+
- Enforce module boundaries
|
|
77
|
+
- Share code between apps
|
|
78
|
+
- Use tags for constraints
|
|
79
|
+
|
|
80
|
+
## Best Practices
|
|
81
|
+
- Use affected commands in CI
|
|
82
|
+
- Organize libs by scope and type
|
|
83
|
+
- Set up import restrictions
|
|
84
|
+
- Use generators for consistency
|
|
85
|
+
- Enable computation caching
|
|
86
|
+
- Configure remote caching for teams
|
|
87
|
+
|
|
88
|
+
## CI/CD Integration
|
|
89
|
+
```yaml
|
|
90
|
+
- name: Nx Cache
|
|
91
|
+
uses: actions/cache@v4
|
|
92
|
+
with:
|
|
93
|
+
path: node_modules/.cache/nx
|
|
94
|
+
key: nx-${{ github.sha }}
|
|
95
|
+
restore-keys: nx-
|
|
96
|
+
|
|
97
|
+
- name: Build affected
|
|
98
|
+
run: nx affected --target=build --base=origin/main
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Performance
|
|
102
|
+
- Parallel execution of independent tasks
|
|
103
|
+
- Computation caching
|
|
104
|
+
- Remote caching with Nx Cloud
|
|
105
|
+
- Affected-only builds in CI
|
|
106
|
+
|
|
107
|
+
## Module Boundaries
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"@nx/enforce-module-boundaries": [
|
|
111
|
+
"error",
|
|
112
|
+
{
|
|
113
|
+
"depConstraints": [
|
|
114
|
+
{
|
|
115
|
+
"sourceTag": "scope:shared",
|
|
116
|
+
"onlyDependOnLibsWithTags": ["scope:shared"]
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Turborepo Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This monorepo uses Turborepo for build orchestration and caching.
|
|
5
|
+
|
|
6
|
+
## Configuration
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"$schema": "https://turbo.build/schema.json",
|
|
10
|
+
"pipeline": {
|
|
11
|
+
"build": {
|
|
12
|
+
"dependsOn": ["^build"],
|
|
13
|
+
"outputs": ["dist/**", ".next/**"]
|
|
14
|
+
},
|
|
15
|
+
"test": {
|
|
16
|
+
"dependsOn": ["build"],
|
|
17
|
+
"outputs": []
|
|
18
|
+
},
|
|
19
|
+
"lint": {
|
|
20
|
+
"outputs": []
|
|
21
|
+
},
|
|
22
|
+
"dev": {
|
|
23
|
+
"cache": false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
- Run task across all workspaces: `turbo run build`
|
|
31
|
+
- Run task in specific workspace: `turbo run build --filter=package-name`
|
|
32
|
+
- Run with no cache: `turbo run build --force`
|
|
33
|
+
- Clear cache: `turbo run build --no-cache`
|
|
34
|
+
- Dry run: `turbo run build --dry-run`
|
|
35
|
+
|
|
36
|
+
## Pipeline Configuration
|
|
37
|
+
- `dependsOn`: Task dependencies
|
|
38
|
+
- `^dependsOn`: Dependencies from workspace dependencies
|
|
39
|
+
- `outputs`: Files to cache
|
|
40
|
+
- `cache`: Enable/disable caching
|
|
41
|
+
- `inputs`: Files that affect cache validity
|
|
42
|
+
|
|
43
|
+
## Caching
|
|
44
|
+
- Turborepo caches task outputs
|
|
45
|
+
- Cache key based on inputs (files, env vars)
|
|
46
|
+
- Shared cache across team (remote caching)
|
|
47
|
+
- Restore from cache for unchanged code
|
|
48
|
+
|
|
49
|
+
## Filtering
|
|
50
|
+
- By package: `--filter=package-name`
|
|
51
|
+
- By directory: `--filter=./apps/*`
|
|
52
|
+
- By dependency: `--filter=...package-name`
|
|
53
|
+
- By changed files: `--filter=[HEAD^1]`
|
|
54
|
+
|
|
55
|
+
## Remote Caching
|
|
56
|
+
```bash
|
|
57
|
+
# Enable remote cache
|
|
58
|
+
turbo login
|
|
59
|
+
turbo link
|
|
60
|
+
|
|
61
|
+
# Or use Vercel
|
|
62
|
+
vercel link
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Environment Variables
|
|
66
|
+
- Automatically included in cache key
|
|
67
|
+
- Prefix with `TURBO_` for Turbo-specific vars
|
|
68
|
+
- Use `.env` files for local development
|
|
69
|
+
|
|
70
|
+
## Performance
|
|
71
|
+
- Tasks run in parallel when possible
|
|
72
|
+
- Skips cached tasks
|
|
73
|
+
- Shows cache hit ratio
|
|
74
|
+
- Optimizes based on dependencies
|
|
75
|
+
|
|
76
|
+
## Best Practices
|
|
77
|
+
- Define clear task dependencies
|
|
78
|
+
- Specify all outputs for caching
|
|
79
|
+
- Use `^` for workspace dependencies
|
|
80
|
+
- Enable remote caching for teams
|
|
81
|
+
- Run affected tasks only in CI
|
|
82
|
+
- Keep pipeline config simple
|
|
83
|
+
|
|
84
|
+
## Monorepo Commands
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "turbo run build",
|
|
89
|
+
"dev": "turbo run dev --parallel",
|
|
90
|
+
"test": "turbo run test",
|
|
91
|
+
"lint": "turbo run lint"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## CI/CD Integration
|
|
97
|
+
```yaml
|
|
98
|
+
# GitHub Actions
|
|
99
|
+
- name: Setup Turborepo cache
|
|
100
|
+
uses: actions/cache@v4
|
|
101
|
+
with:
|
|
102
|
+
path: .turbo
|
|
103
|
+
key: turbo-${{ github.sha }}
|
|
104
|
+
restore-keys: turbo-
|
|
105
|
+
|
|
106
|
+
- name: Build
|
|
107
|
+
run: turbo run build
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Debugging
|
|
111
|
+
- Use `--dry-run` to see execution plan
|
|
112
|
+
- Check `.turbo/runs/*.json` for logs
|
|
113
|
+
- Enable verbose output: `--verbose`
|
|
114
|
+
- View graph: `turbo run build --graph`
|