refactor: use TemplateManager from App container#1669
Conversation
…tainer get Remove templateManager from CommandType interface, BasePromptSession constructor, PromptSession constructor, SchematicsPromptSession constructor. All commands and sessions now get templateManager from App.container.get(TEMPLATE_MANAGER). Clean up cli.ts by removing all manual templateManager assignments and TODO comment. Ensure ng-schematics entry points set TEMPLATE_MANAGER in container. Agent-Logs-Url: https://github.com/IgniteUI/igniteui-cli/sessions/34deef7a-062f-44fe-86f9-7eac03eabc8f Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com>
Replace all command.templateManager assignments and PromptSession(templateManager) constructor calls in tests with App.container.set(TEMPLATE_MANAGER, ...) and App.container.get(TEMPLATE_MANAGER) patterns. Fix container spy interactions where spyOn(App.container, 'get') needs to handle both TEMPLATE_MANAGER and other tokens via callFake. Agent-Logs-Url: https://github.com/IgniteUI/igniteui-cli/sessions/34deef7a-062f-44fe-86f9-7eac03eabc8f Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Merge origin/master into copilot/refactor-template-manager-usage. - Take master's updated describe strings, builder functions, and aliases - Convert new listAllFrameworks() function to use App container pattern - Convert new list-spec test to use App.container.set(TEMPLATE_MANAGER, ...) - Fix PromptSession() constructor call in cli.ts fallback handler Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com>
Merge conflicts resolved in commit
Build and tests pass (425 specs, 9 pre-existing failures, 0 new failures). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…mplate-manager-usage
There was a problem hiding this comment.
Pull request overview
This PR refactors the CLI and schematics codepaths to stop passing TemplateManager through constructors/properties and instead resolve it from the global App.container via the TEMPLATE_MANAGER token, aligning runtime behavior across CLI commands, prompt sessions, and Angular schematics.
Changes:
- Updated
BasePromptSession, CLIPromptSession, andSchematicsPromptSessionto resolve the template manager fromApp.containerrather than constructor injection. - Removed
templateManagerfrom theCommandTypeinterface and from command objects; updated commands to fetchApp.container.get(TEMPLATE_MANAGER)where needed. - Updated schematics entry points and unit tests to set
TEMPLATE_MANAGERin the container instead of mutating command/session properties.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/unit/upgrade-spec.ts | Updates upgrade command unit test to set template manager via App.container. |
| spec/unit/PromptSession-spec.ts | Updates prompt session tests to use container-provided template manager. |
| spec/unit/new-spec.ts | Updates new command tests to use container-resolved template manager. |
| spec/unit/list-spec.ts | Updates list command tests to use container-resolved template manager. |
| spec/unit/generate-spec.ts | Updates generate command tests to use container-resolved template manager. |
| spec/unit/add-spec.ts | Updates add command tests to use container-resolved template manager. |
| packages/ng-schematics/src/prompt/SchematicsPromptSession.ts | Removes constructor injection and relies on BasePromptSession container resolution. |
| packages/ng-schematics/src/ng-new/index.ts | Initializes TEMPLATE_MANAGER in the container before creating the prompt session. |
| packages/ng-schematics/src/component/index.ts | Initializes TEMPLATE_MANAGER in the container before prompt session usage. |
| packages/core/prompt/BasePromptSession.ts | Replaces ctor-injected template manager with a container-backed getter. |
| packages/core/packages/PackageManager.ts | Decouples core from CLI TemplateManager by accepting BaseTemplateManager. |
| packages/cli/lib/PromptSession.ts | Removes template-manager constructor param and stops assigning it into commands. |
| packages/cli/lib/commands/upgrade.ts | Resolves template manager from App.container instead of command.templateManager. |
| packages/cli/lib/commands/types.ts | Removes templateManager from CommandType. |
| packages/cli/lib/commands/start.ts | Drops now-invalid templateManager property from the command literal. |
| packages/cli/lib/commands/new.ts | Resolves template manager from App.container and removes fallback constructor injection into PromptSession. |
| packages/cli/lib/commands/mcp.ts | Drops now-invalid templateManager property from the command literal. |
| packages/cli/lib/commands/list.ts | Resolves template manager from App.container for framework/library access. |
| packages/cli/lib/commands/generate.ts | Resolves template manager from App.container for framework/library access. |
| packages/cli/lib/commands/build.ts | Resolves template manager from App.container for ensureIgniteUISource. |
| packages/cli/lib/commands/add.ts | Resolves template manager from App.container for framework/library access and config updates. |
| packages/cli/lib/cli.ts | Removes per-command template manager assignments; only sets TEMPLATE_MANAGER in the container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BasePromptSessionto get templateManager from App container instead of constructor paramPromptSession(CLI) to remove constructor param, get from containerSchematicsPromptSessionto remove constructor param, get from containertemplateManagerproperty fromCommandTypeinterface and all command objects (add, build, start, generate, list, upgrade, new, mcp)App.container.get(TEMPLATE_MANAGER)where they use itPackageManager.ensureIgniteUISourceto acceptBaseTemplateManagerand remove circular dependency onTemplateManagercli.ts: remove allxyz.templateManager = templateManagerassignments and TODO commentnpm run build✅npm run jasmine✅ (424 specs, 9 pre-existing failures, 0 new failures)Original prompt
This pull request was created from Copilot chat.