Skip to content

Commit 4bec7b3

Browse files
committed
docs: update CLAUDE.md with deprecation enforcement details
Add comprehensive documentation from audit remediation session: - Schema artifact sync process (schema.json → schema.d.ts → dist/) - Detailed deprecation handling policy with JSON Schema flags - Audit checklist for verifying deprecated options aren't promoted - Build process lifecycle (prebuild/build/postbuild) explanation - npm scripts compatibility (works with ignore-scripts=true) - Target precedence: internal vs user-facing documentation - Complete test file inventory with categorization - Test environment requirements and process.env preservation All new knowledge from the documentation honesty audit session.
1 parent 4bbfd76 commit 4bec7b3

File tree

1 file changed

+87
-10
lines changed

1 file changed

+87
-10
lines changed

CLAUDE.md

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ cd src
1919
npm run build
2020
```
2121
Compiles TypeScript to JavaScript and copies necessary files to `dist/`. The build process:
22-
1. Cleans the `dist` directory
23-
2. Generates TypeScript types from `deploy/schema.json`
24-
3. Compiles TypeScript using `tsconfig.build.json`
25-
4. Copies metadata files (builders.json, collection.json, etc.) to `dist/`
22+
1. **`prebuild`**: Cleans the `dist` directory and regenerates `deploy/schema.d.ts` from `deploy/schema.json`
23+
2. **`build`**: Compiles TypeScript using `tsconfig.build.json`
24+
3. **`postbuild`**: Copies metadata files (builders.json, collection.json, schema.json, etc.) to `dist/`
25+
26+
**Important:** After editing `deploy/schema.json`, you MUST run `npm run build` to regenerate `schema.d.ts` and sync `dist/deploy/schema.json`. The build artifacts are gitignored (as they should be), so they won't be committed.
27+
28+
**Schema Artifact Sync:**
29+
- `src/deploy/schema.json` - Source of truth (edit this)
30+
- `src/deploy/schema.d.ts` - Generated TypeScript types (auto-generated via `json-schema-to-typescript`)
31+
- `src/dist/deploy/schema.json` - Distributed schema (copied during build)
32+
33+
**npm scripts compatibility:** This project does NOT use lifecycle hooks (`prepare`, `postinstall`, etc.). All build steps are manual via `npm run <script>`. Safe to use with `ignore-scripts=true` in global `.npmrc` for security.
2634

2735
### Test
2836
```bash
@@ -135,12 +143,19 @@ actions.ts (deploy function)
135143

136144
**Important:** With Angular 17+, the build target resolution follows a strict precedence order. The builder evaluates targets in this order and uses the first one found:
137145

138-
**Precedence (highest to lowest):**
146+
**Internal Implementation Precedence (what the code actually does):**
139147
1. `prerenderTarget` - For SSG/prerendering builds (if specified, overrides all others)
140-
2. `browserTarget` - Legacy/alternative build target (if specified)
148+
2. `browserTarget` - **DEPRECATED** legacy option (if specified, takes precedence over buildTarget for backward compatibility)
141149
3. `buildTarget` - Standard build target (if specified)
142150
4. Default - `${project}:build:production`
143151

152+
**User-Facing Precedence (what we tell users in README.md):**
153+
1. `prerenderTarget` (if specified) — highest priority
154+
2. `buildTarget`
155+
3. Default: `${project}:build:production` if none specified
156+
157+
**Note:** `browserTarget` is deliberately HIDDEN from user-facing documentation per deprecation policy, even though it still works internally for backward compatibility.
158+
144159
**Implementation details:**
145160
- Static build target: `browserTarget || buildTarget || default` (see `src/deploy/builder.ts:23-26`)
146161
- Final target: `prerenderTarget || staticBuildTarget` (see `src/deploy/builder.ts:45-50`)
@@ -205,13 +220,49 @@ Angular CLI does NOT rename kebab-case to camelCase for boolean flags with "no"
205220
- **DO NOT promote deprecated options** in examples or main sections
206221
- Hide compatibility-only options from users: `browserTarget`, `noSilent`
207222
- Only show options users should actually use
223+
- When documenting target precedence, omit deprecated options entirely
208224

209225
**Where Deprecated Options Belong**:
210-
-`schema.json` with `"deprecated": true` flag
226+
-`schema.json` with `"deprecated": true` and `"x-deprecated": "message"` fields
211227
- ✅ CLAUDE.md (for contributors)
212228
- ✅ BREAKING CHANGES sections (when explaining migrations)
213-
- ❌ Configuration File examples
214-
- ❌ Main Deployment Options sections
229+
- ✅ Code comments explaining backward compatibility
230+
- ❌ Configuration File examples in README
231+
- ❌ Main Deployment Options sections in README
232+
- ❌ Precedence explanations in user-facing docs
233+
234+
**Schema Deprecation Flags:**
235+
- `"deprecated": true` - JSON Schema Draft 2019-09 standard flag (Angular CLI recognizes this)
236+
- `"x-deprecated": "message"` - Angular CLI custom extension for deprecation messages
237+
- `"description": "DEPRECATED: ..."` - Human-readable description prefix
238+
239+
**Example:**
240+
```json
241+
"browserTarget": {
242+
"type": "string",
243+
"deprecated": true,
244+
"x-deprecated": "Use buildTarget instead. Kept for backwards compatibility.",
245+
"description": "DEPRECATED: Use buildTarget instead. Legacy alias kept for backwards compatibility only."
246+
}
247+
```
248+
249+
**Auditing for Deprecated Option Mentions:**
250+
251+
Run these checks before releases:
252+
```bash
253+
# Check README for browserTarget mentions (should be zero in user-facing sections)
254+
grep -n "browserTarget" README.md
255+
256+
# Check README for noSilent mentions (should be zero)
257+
grep -n "noSilent" README.md
258+
259+
# Verify schema.json has deprecation flags
260+
grep -A3 "browserTarget" src/deploy/schema.json
261+
```
262+
263+
**Current deprecated options:**
264+
- `browserTarget` - Replaced by `buildTarget`, still works for compatibility
265+
- `noSilent` - No longer needed, parameter is ignored with warning
215266

216267
**Avoid Test Count Bragging**:
217268
- Don't include specific test counts in documentation
@@ -221,18 +272,44 @@ Angular CLI does NOT rename kebab-case to camelCase for boolean flags with "no"
221272
## Testing Strategy
222273

223274
Tests use Jest and are located alongside source files with `.spec.ts` extension:
275+
276+
**Deployment & Integration:**
224277
- `deploy/actions.spec.ts` - Deployment action tests
225-
- `engine/engine.spec.ts` - Core engine tests
278+
- `deploy/builder.spec.ts` - Builder integration tests
226279
- `ng-add.spec.ts` - Schematic tests
280+
281+
**Core Engine:**
282+
- `engine/engine.spec.ts` - Core engine tests (includes prepareOptions, monkeypatch, error handling)
283+
- `engine/engine.prepare-options-helpers.spec.ts` - Intensive tests for option preparation helpers (getRemoteUrl, token injection, CI metadata)
284+
- `engine/engine-filesystem.spec.ts` - Real filesystem tests (.nojekyll, CNAME, 404.html creation)
285+
- `engine/engine.gh-pages-behavior.spec.ts` - gh-pages v3.2.3 behavioral baseline (dotfiles, file lists)
286+
- `engine/engine.gh-pages-integration.spec.ts` - gh-pages option pass-through and API integration
287+
288+
**Parameter Testing:**
227289
- `parameter-tests/parameter-passthrough.spec.ts` - Parameter transformation tests
228290
- `parameter-tests/edge-cases.spec.ts` - Edge case and boundary tests
229291
- `parameter-tests/cli-e2e.spec.ts` - End-to-end standalone CLI testing
230292
- `parameter-tests/builder-integration.spec.ts` - Angular Builder integration tests
231293
- `parameter-tests/build-target.spec.ts` - Build target resolution matrix (buildTarget/browserTarget/prerenderTarget/noBuild)
294+
- `parameter-tests/builder-passthrough.spec.ts` - Builder option pass-through tests
295+
- `parameter-tests/pr-186-commander-defaults.spec.ts` - Commander v3 compatibility and default behavior
296+
297+
**Environment & Prerequisites:**
232298
- `test-prerequisites.spec.ts` - Environment validation (git availability, repository setup, origin remote)
233299

300+
**Public API:**
301+
- `public-api.spec.ts` - Public API exports validation
302+
303+
**Commander Fork (CLI parsing):**
304+
- `commander-fork/test/*.spec.ts` - Tests for commander v3 compatibility fork
305+
234306
Snapshot tests are stored in `__snapshots__/` directory.
235307

308+
**Test Environment Requirements:**
309+
- Tests must run from a git clone with `origin` remote configured
310+
- See `test-prerequisites.spec.ts` for validation details
311+
- All tests use `originalEnv` pattern to preserve and restore `process.env`
312+
236313
### Testing Philosophy: Explicit Assertions
237314

238315
**Prefer precise assertions with `.toBe()` for scalar values, but allow `.toContain()` where appropriate.**

0 commit comments

Comments
 (0)