Skip to content

Commit 1e6bf0c

Browse files
committed
docs: finalize audit remediation documentation updates
- Move programmatic API docs from README to docs/README_contributors.md (per user feedback: advanced feature, not for average users) - Update TEST_COVERAGE_PLAN.md for consistency - Change objective 4 from "gh-pages-shell tests" to "behavioral tests" - Soften hard-coded test count (351 tests, see files for current count) - Add "Test Safety" success criterion (process.env preservation) - Clarify getRemoteUrl has 3 focused tests, not 6 - Remove emoji from documentation (unprofessional if overused) All 8 audit weaknesses now addressed: ✅ Fixed dangerous process.env = {} pattern ✅ Consolidated redundant getRemoteUrl tests (6→3) ✅ Added error message assertions ✅ Added git config correctness verification ✅ Strengthened CI metadata tests (full .toBe() assertions) ✅ Updated CLAUDE.md testing policy (sensible .toContain() usage) ✅ Updated TEST_COVERAGE_PLAN.md consistency ✅ Added programmatic API documentation All 351 tests passing.
1 parent cbfb56e commit 1e6bf0c

File tree

2 files changed

+63
-4
lines changed

2 files changed

+63
-4
lines changed

TEST_COVERAGE_PLAN.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
1. **Add critical missing tests** (silent failures, monkeypatch, real filesystem)
55
2. **Refactor prepareOptions()** to enable intensive testing of each option
66
3. **Export public types** for user extensibility
7-
4. **Complete gh-pages-shell tests** for v6 upgrade preparation
7+
4. **Complete gh-pages behavioral tests** (engine.gh-pages-behavior.spec.ts) for v6 upgrade preparation
88

99
---
1010

@@ -215,14 +215,15 @@ All behavioral tests for gh-pages v3.2.3 are now complete and provide comprehens
215215

216216
## Success Criteria
217217

218-
- **Test Count:** 213353 tests (as of Nov 2024)
218+
- **Test Count:** 213351 tests (comprehensive suite, see test files for current count)
219219
- **Coverage:**All critical paths tested (error callbacks, monkeypatch, file creation, getRemoteUrl, dotfiles)
220220
- **Refactoring:**prepareOptions split into 6 testable functions
221221
- **Public API:**Types exported via public_api.ts, TypeScript declarations enabled
222222
- **Upgrade Prep:**v3 git behavior documented in engine.gh-pages-behavior.spec.ts
223-
- **gh-pages/lib/git:**Internal API dependency intensively tested with 6 focused tests
224-
- **Dotfiles:**Tests now verify actual file list differences, not just that copy was called
223+
- **gh-pages/lib/git:**Internal API dependency intensively tested (3 focused tests verifying correctness)
224+
- **Dotfiles:**Tests verify actual file list differences (4 files with dotfiles, 3 without)
225225
- **Quality:**Zero regressions, all tests passing, zero 'any' types (HARD RULE compliant)
226+
- **Test Safety:**process.env properly preserved (PATH, HOME, etc.) across all test files
226227

227228
---
228229

docs/README_contributors.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,64 @@ npm run publish-to-npm
189189
npm dist-tag add angular-cli-ghpages@0.6.0-rc.0 next
190190
```
191191

192+
## Programmatic Usage
193+
194+
For advanced use cases, `angular-cli-ghpages` can be used programmatically in Node.js scripts:
195+
196+
```typescript
197+
import { deployToGHPages, defaults, Schema } from 'angular-cli-ghpages';
198+
199+
// Deploy with custom options
200+
const options: Schema = {
201+
...defaults,
202+
dir: 'dist/my-app/browser',
203+
repo: 'https://github.com/user/repo.git',
204+
message: 'Custom deploy message',
205+
branch: 'gh-pages',
206+
name: 'Deploy Bot',
207+
email: 'bot@example.com'
208+
};
209+
210+
// Simple logger implementation
211+
const logger = {
212+
info: (msg: string) => console.log(msg),
213+
warn: (msg: string) => console.warn(msg),
214+
error: (msg: string) => console.error(msg),
215+
debug: (msg: string) => console.debug(msg),
216+
fatal: (msg: string) => console.error(msg)
217+
};
218+
219+
try {
220+
await deployToGHPages('dist/my-app/browser', options, logger);
221+
console.log('Deployment successful!');
222+
} catch (error) {
223+
console.error('Deployment failed:', error);
224+
}
225+
```
226+
227+
### Available Types
228+
229+
The package exports these TypeScript types for programmatic usage:
230+
231+
- `Schema` - Complete options interface
232+
- `PreparedOptions` - Internal options after processing
233+
- `DeployUser` - User credentials type
234+
- `GHPages` - gh-pages library wrapper interface
235+
- `defaults` - Default configuration object
236+
237+
### Advanced: Angular Builder Integration
238+
239+
For custom Angular builders:
240+
241+
```typescript
242+
import { angularDeploy } from 'angular-cli-ghpages';
243+
244+
// Inside your custom builder
245+
const result = await angularDeploy(context, builderConfig, 'your-project-name');
246+
```
247+
248+
**Note:** The CLI (`ng deploy`) remains the primary and recommended way to use this tool. Programmatic usage is considered advanced/experimental and may change between versions.
249+
192250
## Keeping track of all the forks
193251

194252
[ngx-deploy-starter](https://github.com/angular-schule/ngx-deploy-starter/) and

0 commit comments

Comments
 (0)