@zimezone/z-command 1.0.1 → 1.1.1
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/README.md +57 -38
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts +1 -7
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +101 -23
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts +11 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +88 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/platforms.d.ts +21 -0
- package/dist/platforms.d.ts.map +1 -0
- package/dist/platforms.js +137 -0
- package/dist/platforms.js.map +1 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +13 -5
- package/templates/agents/api-documenter.agent.md +161 -0
- package/templates/agents/architect-review.agent.md +146 -0
- package/templates/agents/arm-cortex-expert.agent.md +288 -0
- package/templates/agents/backend-architect.agent.md +309 -0
- package/templates/agents/backend-security-coder.agent.md +152 -0
- package/templates/agents/bash-pro.agent.md +285 -0
- package/templates/agents/c-pro.agent.md +35 -0
- package/templates/agents/c4-code.agent.md +320 -0
- package/templates/agents/c4-component.agent.md +227 -0
- package/templates/agents/c4-container.agent.md +248 -0
- package/templates/agents/c4-context.agent.md +235 -0
- package/templates/agents/conductor-validator.agent.md +245 -0
- package/templates/agents/csharp-pro.agent.md +38 -0
- package/templates/agents/customer-support.agent.md +148 -0
- package/templates/agents/database-admin.agent.md +142 -0
- package/templates/agents/database-architect.agent.md +238 -0
- package/templates/agents/database-optimizer.agent.md +144 -0
- package/templates/agents/debugger.agent.md +30 -0
- package/templates/agents/deployment-engineer.agent.md +0 -0
- package/templates/agents/devops-troubleshooter.agent.md +138 -0
- package/templates/agents/django-pro.agent.md +159 -0
- package/templates/agents/docs-architect.agent.md +77 -0
- package/templates/agents/dotnet-architect.agent.md +175 -0
- package/templates/agents/dx-optimizer.agent.md +63 -0
- package/templates/agents/elixir-pro.agent.md +38 -0
- package/templates/agents/error-detective.agent.md +32 -0
- package/templates/agents/event-sourcing-architect.agent.md +42 -0
- package/templates/agents/fastapi-pro.agent.md +171 -0
- package/templates/agents/firmware-analyst.agent.md +330 -0
- package/templates/agents/frontend-security-coder.agent.md +149 -0
- package/templates/agents/haskell-pro.agent.md +37 -0
- package/templates/agents/hr-pro.agent.md +105 -0
- package/templates/agents/incident-responder.agent.md +190 -0
- package/templates/agents/ios-developer.agent.md +198 -0
- package/templates/agents/java-pro.agent.md +156 -0
- package/templates/agents/javascript-pro.agent.md +35 -0
- package/templates/agents/julia-pro.agent.md +187 -0
- package/templates/agents/legal-advisor.agent.md +49 -0
- package/templates/agents/malware-analyst.agent.md +272 -0
- package/templates/agents/mermaid-expert.agent.md +39 -0
- package/templates/agents/minecraft-bukkit-pro.agent.md +104 -0
- package/templates/agents/mobile-security-coder.agent.md +163 -0
- package/templates/agents/monorepo-architect.agent.md +44 -0
- package/templates/agents/observability-engineer.agent.md +228 -0
- package/templates/agents/performance-engineer.agent.md +167 -0
- package/templates/agents/php-pro.agent.md +43 -0
- package/templates/agents/posix-shell-pro.agent.md +284 -0
- package/templates/agents/quant-analyst.agent.md +32 -0
- package/templates/agents/reference-builder.agent.md +167 -0
- package/templates/agents/reverse-engineer.agent.md +202 -0
- package/templates/agents/risk-manager.agent.md +41 -0
- package/templates/agents/ruby-pro.agent.md +35 -0
- package/templates/agents/rust-pro.agent.md +156 -0
- package/templates/agents/sales-automator.agent.md +35 -0
- package/templates/agents/scala-pro.agent.md +60 -0
- package/templates/agents/search-specialist.agent.md +59 -0
- package/templates/agents/security-auditor.agent.md +138 -0
- package/templates/agents/seo-authority-builder.agent.md +116 -0
- package/templates/agents/seo-cannibalization-detector.agent.md +103 -0
- package/templates/agents/seo-content-auditor.agent.md +63 -0
- package/templates/agents/seo-content-planner.agent.md +88 -0
- package/templates/agents/seo-content-refresher.agent.md +98 -0
- package/templates/agents/seo-content-writer.agent.md +76 -0
- package/templates/agents/seo-keyword-strategist.agent.md +75 -0
- package/templates/agents/seo-meta-optimizer.agent.md +72 -0
- package/templates/agents/seo-snippet-hunter.agent.md +94 -0
- package/templates/agents/seo-structure-architect.agent.md +88 -0
- package/templates/agents/service-mesh-expert.agent.md +41 -0
- package/templates/agents/sql-pro.agent.md +146 -0
- package/templates/agents/tdd-orchestrator.agent.md +183 -0
- package/templates/agents/temporal-python-pro.agent.md +349 -0
- package/templates/agents/terraform-specialist.agent.md +137 -0
- package/templates/agents/test-automator.agent.md +203 -0
- package/templates/agents/threat-modeling-expert.agent.md +44 -0
- package/templates/agents/tutorial-engineer.agent.md +118 -0
- package/templates/agents/ui-ux-designer.agent.md +188 -0
- package/templates/agents/ui-visual-validator.agent.md +192 -0
- package/templates/agents/vector-database-engineer.agent.md +43 -0
- package/templates/skills/angular-migration/SKILL.md +410 -0
- package/templates/skills/api-design-principles/SKILL.md +528 -0
- package/templates/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/templates/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/templates/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/templates/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/templates/skills/architecture-decision-records/SKILL.md +428 -0
- package/templates/skills/architecture-patterns/SKILL.md +494 -0
- package/templates/skills/async-python-patterns/SKILL.md +694 -0
- package/templates/skills/auth-implementation-patterns/SKILL.md +634 -0
- package/templates/skills/changelog-automation/SKILL.md +552 -0
- package/templates/skills/code-review-excellence/SKILL.md +520 -0
- package/templates/skills/competitive-landscape/SKILL.md +479 -0
- package/templates/skills/context-driven-development/SKILL.md +385 -0
- package/templates/skills/cost-optimization/SKILL.md +274 -0
- package/templates/skills/cqrs-implementation/SKILL.md +554 -0
- package/templates/skills/data-quality-frameworks/SKILL.md +587 -0
- package/templates/skills/data-storytelling/SKILL.md +453 -0
- package/templates/skills/database-migration/SKILL.md +424 -0
- package/templates/skills/dbt-transformation-patterns/SKILL.md +561 -0
- package/templates/skills/debugging-strategies/SKILL.md +527 -0
- package/templates/skills/defi-protocol-templates/SKILL.md +454 -0
- package/templates/skills/dependency-upgrade/SKILL.md +409 -0
- package/templates/skills/deployment-pipeline-design/SKILL.md +359 -0
- package/templates/skills/distributed-tracing/SKILL.md +438 -0
- package/templates/skills/dotnet-backend-patterns/SKILL.md +815 -0
- package/templates/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
- package/templates/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
- package/templates/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
- package/templates/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
- package/templates/skills/e2e-testing-patterns/SKILL.md +547 -0
- package/templates/skills/employment-contract-templates/SKILL.md +507 -0
- package/templates/skills/error-handling-patterns/SKILL.md +636 -0
- package/templates/skills/event-store-design/SKILL.md +437 -0
- package/templates/skills/fastapi-templates/SKILL.md +567 -0
- package/templates/skills/git-advanced-workflows/SKILL.md +400 -0
- package/templates/skills/github-actions-templates/SKILL.md +333 -0
- package/templates/skills/go-concurrency-patterns/SKILL.md +655 -0
- package/templates/skills/grafana-dashboards/SKILL.md +369 -0
- package/templates/skills/helm-chart-scaffolding/SKILL.md +544 -0
- package/templates/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/templates/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/templates/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/templates/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/templates/skills/javascript-testing-patterns/SKILL.md +1025 -0
- package/templates/skills/langchain-architecture/SKILL.md +338 -0
- package/templates/skills/llm-evaluation/SKILL.md +471 -0
- package/templates/skills/microservices-patterns/SKILL.md +595 -0
- package/templates/skills/modern-javascript-patterns/SKILL.md +911 -0
- package/templates/skills/monorepo-management/SKILL.md +622 -0
- package/templates/skills/nextjs-app-router-patterns/SKILL.md +544 -0
- package/templates/skills/nodejs-backend-patterns/SKILL.md +1020 -0
- package/templates/skills/nx-workspace-patterns/SKILL.md +452 -0
- package/templates/skills/openapi-spec-generation/SKILL.md +1028 -0
- package/templates/skills/paypal-integration/SKILL.md +467 -0
- package/templates/skills/pci-compliance/SKILL.md +466 -0
- package/templates/skills/postgresql/SKILL.md +204 -0
- package/templates/skills/projection-patterns/SKILL.md +490 -0
- package/templates/skills/prometheus-configuration/SKILL.md +392 -0
- package/templates/skills/prompt-engineering-patterns/SKILL.md +201 -0
- package/templates/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
- package/templates/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
- package/templates/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
- package/templates/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
- package/templates/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
- package/templates/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
- package/templates/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
- package/templates/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/templates/skills/python-packaging/SKILL.md +870 -0
- package/templates/skills/python-performance-optimization/SKILL.md +869 -0
- package/templates/skills/python-testing-patterns/SKILL.md +907 -0
- package/templates/skills/rag-implementation/SKILL.md +403 -0
- package/templates/skills/react-modernization/SKILL.md +513 -0
- package/templates/skills/react-native-architecture/SKILL.md +671 -0
- package/templates/skills/react-state-management/SKILL.md +429 -0
- package/templates/skills/risk-metrics-calculation/SKILL.md +555 -0
- package/templates/skills/rust-async-patterns/SKILL.md +517 -0
- package/templates/skills/secrets-management/SKILL.md +346 -0
- package/templates/skills/security-requirement-extraction/SKILL.md +677 -0
- package/templates/skills/shellcheck-configuration/SKILL.md +454 -0
- package/templates/skills/similarity-search-patterns/SKILL.md +558 -0
- package/templates/skills/slo-implementation/SKILL.md +329 -0
- package/templates/skills/sql-optimization-patterns/SKILL.md +493 -0
- package/templates/skills/stripe-integration/SKILL.md +442 -0
- package/templates/skills/tailwind-design-system/SKILL.md +666 -0
- package/templates/skills/temporal-python-testing/SKILL.md +158 -0
- package/templates/skills/temporal-python-testing/resources/integration-testing.md +455 -0
- package/templates/skills/temporal-python-testing/resources/local-setup.md +553 -0
- package/templates/skills/temporal-python-testing/resources/replay-testing.md +462 -0
- package/templates/skills/temporal-python-testing/resources/unit-testing.md +328 -0
- package/templates/skills/terraform-module-library/SKILL.md +249 -0
- package/templates/skills/terraform-module-library/references/aws-modules.md +63 -0
- package/templates/skills/threat-mitigation-mapping/SKILL.md +745 -0
- package/templates/skills/track-management/SKILL.md +593 -0
- package/templates/skills/typescript-advanced-types/SKILL.md +717 -0
- package/templates/skills/ui-ux-pro-max/SKILL.md +352 -0
- package/templates/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/templates/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/templates/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/templates/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/templates/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/templates/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/templates/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/templates/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/templates/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/templates/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/templates/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/templates/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/templates/skills/ui-ux-pro-max/scripts/core.py +258 -0
- package/templates/skills/ui-ux-pro-max/scripts/design_system.py +547 -0
- package/templates/skills/ui-ux-pro-max/scripts/search.py +76 -0
- package/templates/skills/uv-package-manager/SKILL.md +831 -0
- package/templates/skills/vector-index-tuning/SKILL.md +521 -0
- package/templates/skills/wcag-audit-patterns/SKILL.md +555 -0
- package/templates/skills/workflow-orchestration-patterns/SKILL.md +316 -0
- package/templates/skills/workflow-patterns/SKILL.md +623 -0
- package/templates/agents/game-developer.agent.md +0 -57
- package/templates/agents/kubernetes-specialist.agent.md +0 -56
- package/templates/agents/market-researcher.agent.md +0 -47
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nx-workspace-patterns
|
|
3
|
+
description: Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Nx Workspace Patterns
|
|
7
|
+
|
|
8
|
+
Production patterns for Nx monorepo management.
|
|
9
|
+
|
|
10
|
+
## When to Use This Skill
|
|
11
|
+
|
|
12
|
+
- Setting up new Nx workspaces
|
|
13
|
+
- Configuring project boundaries
|
|
14
|
+
- Optimizing CI with affected commands
|
|
15
|
+
- Implementing remote caching
|
|
16
|
+
- Managing dependencies between projects
|
|
17
|
+
- Migrating to Nx
|
|
18
|
+
|
|
19
|
+
## Core Concepts
|
|
20
|
+
|
|
21
|
+
### 1. Nx Architecture
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
workspace/
|
|
25
|
+
├── apps/ # Deployable applications
|
|
26
|
+
│ ├── web/
|
|
27
|
+
│ └── api/
|
|
28
|
+
├── libs/ # Shared libraries
|
|
29
|
+
│ ├── shared/
|
|
30
|
+
│ │ ├── ui/
|
|
31
|
+
│ │ └── utils/
|
|
32
|
+
│ └── feature/
|
|
33
|
+
│ ├── auth/
|
|
34
|
+
│ └── dashboard/
|
|
35
|
+
├── tools/ # Custom executors/generators
|
|
36
|
+
├── nx.json # Nx configuration
|
|
37
|
+
└── workspace.json # Project configuration
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Library Types
|
|
41
|
+
|
|
42
|
+
| Type | Purpose | Example |
|
|
43
|
+
|------|---------|---------|
|
|
44
|
+
| **feature** | Smart components, business logic | `feature-auth` |
|
|
45
|
+
| **ui** | Presentational components | `ui-buttons` |
|
|
46
|
+
| **data-access** | API calls, state management | `data-access-users` |
|
|
47
|
+
| **util** | Pure functions, helpers | `util-formatting` |
|
|
48
|
+
| **shell** | App bootstrapping | `shell-web` |
|
|
49
|
+
|
|
50
|
+
## Templates
|
|
51
|
+
|
|
52
|
+
### Template 1: nx.json Configuration
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
|
57
|
+
"npmScope": "myorg",
|
|
58
|
+
"affected": {
|
|
59
|
+
"defaultBase": "main"
|
|
60
|
+
},
|
|
61
|
+
"tasksRunnerOptions": {
|
|
62
|
+
"default": {
|
|
63
|
+
"runner": "nx/tasks-runners/default",
|
|
64
|
+
"options": {
|
|
65
|
+
"cacheableOperations": [
|
|
66
|
+
"build",
|
|
67
|
+
"lint",
|
|
68
|
+
"test",
|
|
69
|
+
"e2e",
|
|
70
|
+
"build-storybook"
|
|
71
|
+
],
|
|
72
|
+
"parallel": 3
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"targetDefaults": {
|
|
77
|
+
"build": {
|
|
78
|
+
"dependsOn": ["^build"],
|
|
79
|
+
"inputs": ["production", "^production"],
|
|
80
|
+
"cache": true
|
|
81
|
+
},
|
|
82
|
+
"test": {
|
|
83
|
+
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
|
|
84
|
+
"cache": true
|
|
85
|
+
},
|
|
86
|
+
"lint": {
|
|
87
|
+
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
|
|
88
|
+
"cache": true
|
|
89
|
+
},
|
|
90
|
+
"e2e": {
|
|
91
|
+
"inputs": ["default", "^production"],
|
|
92
|
+
"cache": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"namedInputs": {
|
|
96
|
+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
|
97
|
+
"production": [
|
|
98
|
+
"default",
|
|
99
|
+
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
|
|
100
|
+
"!{projectRoot}/tsconfig.spec.json",
|
|
101
|
+
"!{projectRoot}/jest.config.[jt]s",
|
|
102
|
+
"!{projectRoot}/.eslintrc.json"
|
|
103
|
+
],
|
|
104
|
+
"sharedGlobals": [
|
|
105
|
+
"{workspaceRoot}/babel.config.json",
|
|
106
|
+
"{workspaceRoot}/tsconfig.base.json"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"generators": {
|
|
110
|
+
"@nx/react": {
|
|
111
|
+
"application": {
|
|
112
|
+
"style": "css",
|
|
113
|
+
"linter": "eslint",
|
|
114
|
+
"bundler": "webpack"
|
|
115
|
+
},
|
|
116
|
+
"library": {
|
|
117
|
+
"style": "css",
|
|
118
|
+
"linter": "eslint"
|
|
119
|
+
},
|
|
120
|
+
"component": {
|
|
121
|
+
"style": "css"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Template 2: Project Configuration
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
// apps/web/project.json
|
|
132
|
+
{
|
|
133
|
+
"name": "web",
|
|
134
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
135
|
+
"sourceRoot": "apps/web/src",
|
|
136
|
+
"projectType": "application",
|
|
137
|
+
"tags": ["type:app", "scope:web"],
|
|
138
|
+
"targets": {
|
|
139
|
+
"build": {
|
|
140
|
+
"executor": "@nx/webpack:webpack",
|
|
141
|
+
"outputs": ["{options.outputPath}"],
|
|
142
|
+
"defaultConfiguration": "production",
|
|
143
|
+
"options": {
|
|
144
|
+
"compiler": "babel",
|
|
145
|
+
"outputPath": "dist/apps/web",
|
|
146
|
+
"index": "apps/web/src/index.html",
|
|
147
|
+
"main": "apps/web/src/main.tsx",
|
|
148
|
+
"tsConfig": "apps/web/tsconfig.app.json",
|
|
149
|
+
"assets": ["apps/web/src/assets"],
|
|
150
|
+
"styles": ["apps/web/src/styles.css"]
|
|
151
|
+
},
|
|
152
|
+
"configurations": {
|
|
153
|
+
"development": {
|
|
154
|
+
"extractLicenses": false,
|
|
155
|
+
"optimization": false,
|
|
156
|
+
"sourceMap": true
|
|
157
|
+
},
|
|
158
|
+
"production": {
|
|
159
|
+
"optimization": true,
|
|
160
|
+
"outputHashing": "all",
|
|
161
|
+
"sourceMap": false,
|
|
162
|
+
"extractLicenses": true
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"serve": {
|
|
167
|
+
"executor": "@nx/webpack:dev-server",
|
|
168
|
+
"defaultConfiguration": "development",
|
|
169
|
+
"options": {
|
|
170
|
+
"buildTarget": "web:build"
|
|
171
|
+
},
|
|
172
|
+
"configurations": {
|
|
173
|
+
"development": {
|
|
174
|
+
"buildTarget": "web:build:development"
|
|
175
|
+
},
|
|
176
|
+
"production": {
|
|
177
|
+
"buildTarget": "web:build:production"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"test": {
|
|
182
|
+
"executor": "@nx/jest:jest",
|
|
183
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
184
|
+
"options": {
|
|
185
|
+
"jestConfig": "apps/web/jest.config.ts",
|
|
186
|
+
"passWithNoTests": true
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"lint": {
|
|
190
|
+
"executor": "@nx/eslint:lint",
|
|
191
|
+
"outputs": ["{options.outputFile}"],
|
|
192
|
+
"options": {
|
|
193
|
+
"lintFilePatterns": ["apps/web/**/*.{ts,tsx,js,jsx}"]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Template 3: Module Boundary Rules
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
// .eslintrc.json
|
|
204
|
+
{
|
|
205
|
+
"root": true,
|
|
206
|
+
"ignorePatterns": ["**/*"],
|
|
207
|
+
"plugins": ["@nx"],
|
|
208
|
+
"overrides": [
|
|
209
|
+
{
|
|
210
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
211
|
+
"rules": {
|
|
212
|
+
"@nx/enforce-module-boundaries": [
|
|
213
|
+
"error",
|
|
214
|
+
{
|
|
215
|
+
"enforceBuildableLibDependency": true,
|
|
216
|
+
"allow": [],
|
|
217
|
+
"depConstraints": [
|
|
218
|
+
{
|
|
219
|
+
"sourceTag": "type:app",
|
|
220
|
+
"onlyDependOnLibsWithTags": [
|
|
221
|
+
"type:feature",
|
|
222
|
+
"type:ui",
|
|
223
|
+
"type:data-access",
|
|
224
|
+
"type:util"
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"sourceTag": "type:feature",
|
|
229
|
+
"onlyDependOnLibsWithTags": [
|
|
230
|
+
"type:ui",
|
|
231
|
+
"type:data-access",
|
|
232
|
+
"type:util"
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"sourceTag": "type:ui",
|
|
237
|
+
"onlyDependOnLibsWithTags": ["type:ui", "type:util"]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"sourceTag": "type:data-access",
|
|
241
|
+
"onlyDependOnLibsWithTags": ["type:data-access", "type:util"]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"sourceTag": "type:util",
|
|
245
|
+
"onlyDependOnLibsWithTags": ["type:util"]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"sourceTag": "scope:web",
|
|
249
|
+
"onlyDependOnLibsWithTags": ["scope:web", "scope:shared"]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"sourceTag": "scope:api",
|
|
253
|
+
"onlyDependOnLibsWithTags": ["scope:api", "scope:shared"]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"sourceTag": "scope:shared",
|
|
257
|
+
"onlyDependOnLibsWithTags": ["scope:shared"]
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Template 4: Custom Generator
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
// tools/generators/feature-lib/index.ts
|
|
272
|
+
import {
|
|
273
|
+
Tree,
|
|
274
|
+
formatFiles,
|
|
275
|
+
generateFiles,
|
|
276
|
+
joinPathFragments,
|
|
277
|
+
names,
|
|
278
|
+
readProjectConfiguration,
|
|
279
|
+
} from '@nx/devkit';
|
|
280
|
+
import { libraryGenerator } from '@nx/react';
|
|
281
|
+
|
|
282
|
+
interface FeatureLibraryGeneratorSchema {
|
|
283
|
+
name: string;
|
|
284
|
+
scope: string;
|
|
285
|
+
directory?: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export default async function featureLibraryGenerator(
|
|
289
|
+
tree: Tree,
|
|
290
|
+
options: FeatureLibraryGeneratorSchema
|
|
291
|
+
) {
|
|
292
|
+
const { name, scope, directory } = options;
|
|
293
|
+
const projectDirectory = directory
|
|
294
|
+
? `${directory}/${name}`
|
|
295
|
+
: `libs/${scope}/feature-${name}`;
|
|
296
|
+
|
|
297
|
+
// Generate base library
|
|
298
|
+
await libraryGenerator(tree, {
|
|
299
|
+
name: `feature-${name}`,
|
|
300
|
+
directory: projectDirectory,
|
|
301
|
+
tags: `type:feature,scope:${scope}`,
|
|
302
|
+
style: 'css',
|
|
303
|
+
skipTsConfig: false,
|
|
304
|
+
skipFormat: true,
|
|
305
|
+
unitTestRunner: 'jest',
|
|
306
|
+
linter: 'eslint',
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Add custom files
|
|
310
|
+
const projectConfig = readProjectConfiguration(tree, `${scope}-feature-${name}`);
|
|
311
|
+
const projectNames = names(name);
|
|
312
|
+
|
|
313
|
+
generateFiles(
|
|
314
|
+
tree,
|
|
315
|
+
joinPathFragments(__dirname, 'files'),
|
|
316
|
+
projectConfig.sourceRoot,
|
|
317
|
+
{
|
|
318
|
+
...projectNames,
|
|
319
|
+
scope,
|
|
320
|
+
tmpl: '',
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
await formatFiles(tree);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Template 5: CI Configuration with Affected
|
|
329
|
+
|
|
330
|
+
```yaml
|
|
331
|
+
# .github/workflows/ci.yml
|
|
332
|
+
name: CI
|
|
333
|
+
|
|
334
|
+
on:
|
|
335
|
+
push:
|
|
336
|
+
branches: [main]
|
|
337
|
+
pull_request:
|
|
338
|
+
branches: [main]
|
|
339
|
+
|
|
340
|
+
env:
|
|
341
|
+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
|
342
|
+
|
|
343
|
+
jobs:
|
|
344
|
+
main:
|
|
345
|
+
runs-on: ubuntu-latest
|
|
346
|
+
steps:
|
|
347
|
+
- uses: actions/checkout@v4
|
|
348
|
+
with:
|
|
349
|
+
fetch-depth: 0
|
|
350
|
+
|
|
351
|
+
- uses: actions/setup-node@v4
|
|
352
|
+
with:
|
|
353
|
+
node-version: 20
|
|
354
|
+
cache: 'npm'
|
|
355
|
+
|
|
356
|
+
- name: Install dependencies
|
|
357
|
+
run: npm ci
|
|
358
|
+
|
|
359
|
+
- name: Derive SHAs for affected commands
|
|
360
|
+
uses: nrwl/nx-set-shas@v4
|
|
361
|
+
|
|
362
|
+
- name: Run affected lint
|
|
363
|
+
run: npx nx affected -t lint --parallel=3
|
|
364
|
+
|
|
365
|
+
- name: Run affected test
|
|
366
|
+
run: npx nx affected -t test --parallel=3 --configuration=ci
|
|
367
|
+
|
|
368
|
+
- name: Run affected build
|
|
369
|
+
run: npx nx affected -t build --parallel=3
|
|
370
|
+
|
|
371
|
+
- name: Run affected e2e
|
|
372
|
+
run: npx nx affected -t e2e --parallel=1
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Template 6: Remote Caching Setup
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
// nx.json with Nx Cloud
|
|
379
|
+
{
|
|
380
|
+
"tasksRunnerOptions": {
|
|
381
|
+
"default": {
|
|
382
|
+
"runner": "nx-cloud",
|
|
383
|
+
"options": {
|
|
384
|
+
"cacheableOperations": ["build", "lint", "test", "e2e"],
|
|
385
|
+
"accessToken": "your-nx-cloud-token",
|
|
386
|
+
"parallel": 3,
|
|
387
|
+
"cacheDirectory": ".nx/cache"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
"nxCloudAccessToken": "your-nx-cloud-token"
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Self-hosted cache with S3
|
|
395
|
+
{
|
|
396
|
+
"tasksRunnerOptions": {
|
|
397
|
+
"default": {
|
|
398
|
+
"runner": "@nx-aws-cache/nx-aws-cache",
|
|
399
|
+
"options": {
|
|
400
|
+
"cacheableOperations": ["build", "lint", "test"],
|
|
401
|
+
"awsRegion": "us-east-1",
|
|
402
|
+
"awsBucket": "my-nx-cache-bucket",
|
|
403
|
+
"awsProfile": "default"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Common Commands
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
# Generate new library
|
|
414
|
+
nx g @nx/react:lib feature-auth --directory=libs/web --tags=type:feature,scope:web
|
|
415
|
+
|
|
416
|
+
# Run affected tests
|
|
417
|
+
nx affected -t test --base=main
|
|
418
|
+
|
|
419
|
+
# View dependency graph
|
|
420
|
+
nx graph
|
|
421
|
+
|
|
422
|
+
# Run specific project
|
|
423
|
+
nx build web --configuration=production
|
|
424
|
+
|
|
425
|
+
# Reset cache
|
|
426
|
+
nx reset
|
|
427
|
+
|
|
428
|
+
# Run migrations
|
|
429
|
+
nx migrate latest
|
|
430
|
+
nx migrate --run-migrations
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
## Best Practices
|
|
434
|
+
|
|
435
|
+
### Do's
|
|
436
|
+
- **Use tags consistently** - Enforce with module boundaries
|
|
437
|
+
- **Enable caching early** - Significant CI savings
|
|
438
|
+
- **Keep libs focused** - Single responsibility
|
|
439
|
+
- **Use generators** - Ensure consistency
|
|
440
|
+
- **Document boundaries** - Help new developers
|
|
441
|
+
|
|
442
|
+
### Don'ts
|
|
443
|
+
- **Don't create circular deps** - Graph should be acyclic
|
|
444
|
+
- **Don't skip affected** - Test only what changed
|
|
445
|
+
- **Don't ignore boundaries** - Tech debt accumulates
|
|
446
|
+
- **Don't over-granularize** - Balance lib count
|
|
447
|
+
|
|
448
|
+
## Resources
|
|
449
|
+
|
|
450
|
+
- [Nx Documentation](https://nx.dev/getting-started/intro)
|
|
451
|
+
- [Module Boundaries](https://nx.dev/core-features/enforce-module-boundaries)
|
|
452
|
+
- [Nx Cloud](https://nx.app/)
|