Plan: Migrate PhaseHooksService from GitHubService to PlatformProvider#
Summary#
Replace direct GitHubService injection in PhaseHooksService with the PlatformProvider interface (from #345), making phase hooks platform-agnostic. This is a Wave 2 consumer migration in the multi-tenant initiative.
Files#
| File | Action | Description |
|---|---|---|
src/hooks/phase-hooks.service.ts | modify | Swap GitHubService injection for @Inject(PLATFORM_PROVIDER) PlatformProvider; replace all this.github.* calls with this.platform.*; use optional chaining on setProjectItemStatus |
src/hooks/phase-hooks.module.ts | modify | Replace GitHubModule import with PlatformModule |
src/hooks/phase-hooks.service.spec.ts | modify | Replace GitHubService mock with PLATFORM_PROVIDER token mock using the PlatformProvider interface type |
Steps#
- Update
phase-hooks.service.tsconstructor injection — Replaceprivate readonly github: GitHubServicewith@Inject(PLATFORM_PROVIDER) private readonly platform: PlatformProvider. RemoveGitHubServiceimport, addPlatformProviderandPLATFORM_PROVIDERimports from the platform module. - Replace all
this.github.*call sites — Rename everythis.github.addLabel,removeLabel,postComment,mergePR,closePR,closeIssue,getCheckStatus,getReviewStatustothis.platform.*. Changethis.github.setProjectItemStatus(...)tothis.platform.setProjectItemStatus?.(...)with optional chaining. - Update
phase-hooks.module.ts— ReplaceGitHubModuleimport withPlatformModule. RemoveGitHubModuleimport statement. - Update
phase-hooks.service.spec.ts— Change the mock provider from{ provide: GitHubService, useValue: {...} }to{ provide: PLATFORM_PROVIDER, useValue: {...} }. Update the mock retrieval frommodule.get(GitHubService)tomodule.get(PLATFORM_PROVIDER). Update the type annotation fromjest.Mocked<GitHubService>tojest.Mocked<PlatformProvider>.
Verification#
tsc --noEmitpasses with no errorsnpm run lintpasses with zero warningsnpm run test -- --testPathPattern=phase-hooks— all existing tests pass with PlatformProvider mock
Risks#
- Blocked by #345:
PlatformProviderinterface andPlatformModulemust land onrc/multi-tenantfirst. Do not merge this PR until #345 is merged. setProjectItemStatusoptional chaining: IfPlatformProvidertypessetProjectItemStatusas required (not optional), the?.syntax may need adjustment to match the interface definition.