Move Python starter template to TypeScript AppHost and CLI template factory#15574
Move Python starter template to TypeScript AppHost and CLI template factory#15574
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15574Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15574" |
There was a problem hiding this comment.
Pull request overview
Migrates the Python starter template (aspire-py-starter) from the legacy dotnet new template pipeline to the embedded CLI template pipeline, switching the AppHost from C# to TypeScript to reduce required toolchains and align with the existing TS starter pattern.
Changes:
- Removed
aspire-py-starterfromDotNetTemplateFactory/ old project template assets and updated tests accordingly. - Added a new embedded CLI template tree for
py-starter(TypeScript AppHost + FastAPI backend + Vite React frontend). - Introduced
ConditionalBlockProcessor(with unit tests) and added a new CLI template factory implementation for the Python starter, including a--use-redis-cacheoption and conditional template processing.
Reviewed changes
Copilot reviewed 36 out of 57 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Templates.Tests/LocalhostTldHostnameTests.cs | Removes py-starter coverage from dotnet-template hostname tests since it’s no longer a dotnet template. |
| tests/Aspire.Cli.Tests/Templating/DotNetTemplateFactoryTests.cs | Updates expectations so py-starter is no longer returned by DotNetTemplateFactory. |
| tests/Aspire.Cli.Tests/Templating/ConditionalBlockProcessorTests.cs | Adds unit coverage for the new conditional block processing utility. |
| src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj | Stops packaging the old py-starter dotnet template content. |
| src/Aspire.Cli/Aspire.Cli.csproj | Embeds the new py-starter template resources into the CLI. |
| src/Aspire.Cli/Templating/DotNetTemplateFactory.cs | Removes py-starter from dotnet template enumeration and associated prompt logic. |
| src/Aspire.Cli/Templating/KnownTemplateId.cs | Adds a PythonStarter known template ID constant. |
| src/Aspire.Cli/Templating/ConditionalBlockProcessor.cs | Adds reusable conditional block marker processing for templates. |
| src/Aspire.Cli/Templating/CliTemplateFactory.cs | Registers the Python starter in CLI template definitions and adds --use-redis-cache option plumbing. |
| src/Aspire.Cli/Templating/CliTemplateFactory.PythonStarterTemplate.cs | Implements the new CLI template application logic, conditional Redis inclusion, and aspire.config.json mutation. |
| src/Aspire.Cli/Templating/Templates/py-starter/** | Adds the new embedded Python starter template content (AppHost + backend + frontend). |
| src/Aspire.ProjectTemplates/templates/aspire-py-starter/** | Deletes the legacy dotnet-template assets for the Python starter. |
Files not reviewed (1)
- src/Aspire.Cli/Templating/Templates/py-starter/package-lock.json: Language not supported
eb4b0e8 to
c190fc3
Compare
|
Re-running the failed jobs in the CI workflow for this pull request because 2 jobs were identified as retry-safe transient failures in the CI run attempt.
|
|
This should use python apphost right? #13947 |
It can, but the app has javascript, python and C#. We're not shipping the python apphost yet. I suspect that will be a bigger move than adding another TS apphost. |
|
/azp run |
dd71c5a to
7b8fc68
Compare
778a935 to
9650f92
Compare
Status: Blocked on bundle mode multi-package NuGet restoreThe template migration itself is complete and works locally (SDK mode). The E2E test currently only verifies template creation + SDK file generation. Blocker: Bundle mode (native AOT CLI) doesn't include integration assemblies in the generated TypeScript SDK when Evidence from CI workspace capture:
Once the bundle mode multi-package restore is fixed, the E2E test should be updated to include |
8450db4 to
9cb8071
Compare
Status UpdateRoot cause found: Fix: Aligned the E2E test with the TypeScript starter pattern — Previous status comment about bundle mode multi-package restore is now explained: it was never a NuGet restore bug — the config resolution was reading the wrong file. |
Status UpdateRoot cause found: aspire run from workspace root uses the root-level aspire.config.json (which has no packages section) instead of the project-level config. Filed as #15623. Fix: Aligned the E2E test with the TypeScript starter pattern — cd into the project directory before running aspire start/aspire stop. Also addressed all ConditionalBlockProcessor review feedback from JamesNK. Previous status comment about bundle mode multi-package restore is now explained: it was never a NuGet restore bug — the config resolution was reading the wrong file. |
maddymontaquila
left a comment
There was a problem hiding this comment.
changes requested
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
eff6bc8 to
ad4263e
Compare
…actory
Migrate the aspire-py-starter template from the legacy DotNetTemplateFactory
(C# AppHost, dotnet new) to the CliTemplateFactory (TypeScript AppHost,
embedded resources). This aligns the Python starter with the existing
TypeScript Express/React starter pattern.
Changes:
- Add py-starter embedded template with TypeScript AppHost using
addUvicornApp and addViteApp
- Add CliTemplateFactory.PythonStarterTemplate with Redis conditional support
- Add ConditionalBlockProcessor for reusable {{#condition}} block processing
- Remove old template from DotNetTemplateFactory and Aspire.ProjectTemplates
- Install uv in E2E Docker container for Python template support
- Fix AspireStartAsync sed pattern to match both http and https dashboard URLs
- Add workspace and log capture diagnostics for E2E test debugging
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ad4263e to
0a5943f
Compare
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23634991048 |
Description
Migrates the
aspire-py-startertemplate from the olddotnet newtemplate system (DotNetTemplateFactory with C# AppHost) to the new embedded CLI template system (CliTemplateFactory with TypeScript AppHost).Motivation: Narrowing down the toolchains required — by moving to a TypeScript AppHost, the Python starter no longer requires the .NET SDK/C# toolchain for the AppHost project, aligning it with the same pattern as
aspire-ts-starter.What changed
src/Aspire.Cli/Templating/Templates/py-starter/with a TypeScript AppHost usingaddUvicornApp, conditional Redis support via{{#redis}}/{{/redis}}block markers, and a Vite React frontendCliTemplateFactory.PythonStarterTemplate.cs— factory logic for the Python starter, including Redis conditional processing andaspire.config.jsonpackage injectionConditionalBlockProcessorutility class — extracted reusable conditional block processing with 29 unit tests covering comment styles, edge cases, multiple conditions, and realistic template scenariosAspire.ProjectTemplates(dotnet new aspire-py-starteris replaced byaspire new aspire-py-starter)aspire-py-startermoved fromDotNetTemplateFactorytoCliTemplateFactorywith--use-redis-cacheand--localhost-tldoptionsDotNetTemplateFactoryTestsupdated to expect py-starter not in dotnet templates; hostname tests removed for py-starterValidation
Aspire.CliandAspire.ProjectTemplates)ConditionalBlockProcessorTestspassDotNetTemplateFactoryTestspassNewCommandTestspass (confirmsaspire-py-starterlisted in CLI help)aspire new aspire-py-startergenerates correct output for both--use-redis-cache falseand--use-redis-cache truevariantsChecklist
aspire.devissue: