Skip to content

Commit 7e512cc

Browse files
Merge pull request #123 from aligent/fix/MI-313-support-dry-run-flag
MI-313: Various bug fixes and improvements
2 parents 7eb3a37 + 8c49d66 commit 7e512cc

13 files changed

Lines changed: 2185 additions & 651 deletions

File tree

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ updates:
1515
update-types:
1616
- 'minor'
1717
- 'patch'
18+
- package-ecosystem: 'npm'
19+
directory: '/packages/nx-cdk/src/generators/helpers/configs/base-package'
20+
schedule:
21+
interval: 'monthly'
22+
open-pull-requests-limit: 5
23+
commit-message:
24+
prefix: 'TEMPLATE-UPDATE'
25+
groups:
26+
minor-and-patch:
27+
applies-to: version-updates
28+
patterns:
29+
- '*'
30+
update-types:
31+
- 'minor'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
nx-cdk: minor
3+
---
4+
5+
### Features
6+
7+
- - Support stateful resource default aspects in generated CDK application templates (MI-313)
8+
9+
### Bug Fixes
10+
11+
- Fix `--dry-run` support by routing all file I/O through the NX `Tree` instead of writing directly to disk (MI-313)
12+
- Fix git hook template: rename `pre-push` to `pre-commit` so the hook actually runs (MI-313)
13+
- Fix bugs in generated CDK application entry point template (MI-313)
14+
- Fix missing imports and clean up generated infra library and service templates (MI-313)
15+
- Remove redundant `enforceBuildableLibDependency` eslint flag from generated eslint config (MI-313)
16+
- Move tags from `App` level to `Stage` level so they propagate correctly across synthesis boundaries (MI-313)
17+
- Move base `package.json` to a static file instead of dynamic generation and fix CDK context config (MI-313)
18+
- Add dependabot rule for `package.json` template (MI-313)

CLAUDE.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# CLAUDE.md
2+
3+
## Working With Claude
4+
5+
Whenever the user says "No" or corrects an approach, update this file with the relevant rule so the same mistake is not repeated.
6+
7+
## Project Overview
8+
9+
Aligent's TypeScript monorepo for microservice development utilities. Managed by **Nx 22** with **npm workspaces**. Node.js v22 required (see `.nvmrc`).
10+
11+
## Packages
12+
13+
| Package | Purpose |
14+
|---------|---------|
15+
| `packages/appbuilder-util-lib` | Adobe App Builder utilities (logging, DB, files, state, auth) |
16+
| `packages/create-workspace` | CLI scaffolding tool for new Nx workspaces |
17+
| `packages/microservice-util-lib` | Core utilities (AWS SDK, OAuth, OpenAPI clients) |
18+
| `packages/nx-cdk` | Nx plugin with generators for AWS CDK projects |
19+
| `packages/nx-openapi` | Nx plugin with generators for OpenAPI client generation |
20+
21+
## Common Commands
22+
23+
```bash
24+
# Install dependencies
25+
npm install
26+
27+
# Build / Test / Lint / Type-check — affected packages only
28+
npm run build
29+
npm test
30+
npm run lint
31+
npm run check-types
32+
33+
# Run across all packages
34+
npm run build:all
35+
npm run test:all
36+
npm run lint:all
37+
npm run check-types:all
38+
39+
# Single package
40+
npx nx build @aligent/microservice-util-lib
41+
npx nx test @aligent/nx-cdk
42+
43+
# Preview generator changes without writing files
44+
npx nx g @tools/generators:package --dry-run
45+
npx nx g @aligent/nx-cdk:service --dry-run
46+
```
47+
48+
## Testing
49+
50+
- Framework: **Vitest** with v8 coverage provider
51+
- Coverage threshold: **80%** across branches, functions, lines, and statements
52+
- Tests live alongside source in `src/` or under `tests/`, matching `**/*.{test,spec}.ts`
53+
- Files prefixed with `/* v8 ignore start */` are excluded from coverage
54+
55+
## Code Style
56+
57+
- **4-space indentation** (2 for YAML/JSON — see `.editorconfig`)
58+
- **LF** line endings, **100-char** max line width
59+
- Linting via `@aligent/ts-code-standards` (ESLint + Prettier)
60+
- Run `npm run lint` before committing; pre-commit hooks are configured via `prepare`
61+
62+
### TypeScript
63+
64+
- **Never use the non-null assertion operator (`!`)**. Use explicit runtime checks instead so errors surface with a clear message rather than a runtime crash.
65+
66+
```ts
67+
// Bad
68+
const content = tree.read(path, 'utf-8')!;
69+
70+
// Good
71+
const content = tree.read(path, 'utf-8');
72+
if (content === null) {
73+
throw new Error(`Failed to read file: ${path}`);
74+
}
75+
```
76+
77+
## Architecture Notes
78+
79+
### NX Generators
80+
81+
Generators in `packages/nx-cdk` and `packages/nx-openapi` must route **all file I/O through the NX `Tree`** object — never use `fs` or third-party APIs (e.g. `ts-morph`'s `.save()`) to write directly to disk. This ensures `--dry-run` works correctly, as NX handles dry-run by not flushing the Tree.
82+
83+
- Use `tree.read()` / `tree.write()` / `tree.exists()` instead of `fs.*` / `existsSync`
84+
- When using `ts-morph` for AST manipulation, use `InMemoryFileSystemHost` and write the result back via `tree.write()`
85+
86+
### TypeScript Project References
87+
88+
The root `tsconfig.json` uses project references. When adding a new package or service, the reference must be added via `addTsConfigReference()` (which updates `tsconfig.json` through the Tree).
89+
90+
### Release Process
91+
92+
Independent versioning per package using **Nx Version Plans**.
93+
94+
1. Create a `releases/*` branch from `main`
95+
2. Run `npm run release-plan` to generate a version plan file in `.nx/version-plans/`
96+
3. Push — the `release` workflow bumps versions, removes the plan file, and opens a "Publish" PR
97+
4. Merge the Publish PR → `publish` workflow builds and publishes to npm
98+
99+
> Only one version plan file should exist at a time. Multiple plans produce unpredictable results.
100+
101+
## Branch Naming
102+
103+
- Features: `feat/MI-{issue}-{description}`
104+
- Fixes: `fix/MI-{issue}-{description}`
105+
- Releases: `releases/{package-name}-{version}`
106+
107+
## Local Registry Testing
108+
109+
```bash
110+
npx nx start-local-registry microservice-development-utilities
111+
npx nx release publish # publish to local Verdaccio registry
112+
npx nx stop-local-registry microservice-development-utilities
113+
```

0 commit comments

Comments
 (0)