Create aspire restore command and polyglot playground tests#14753
Create aspire restore command and polyglot playground tests#14753sebastienros wants to merge 8 commits intorelease/13.2from
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14753Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14753" |
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22526918226 |
Fix CLI test failures caused by missing RestoreCommand DI registration in CliTestHelper.cs, which is needed since RootCommand now depends on it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new aspire restore CLI command to regenerate polyglot SDK code for non-.NET AppHost projects, and introduces validation that the generated TypeScript SDK remains compilable across playground samples.
Changes:
- Introduces
aspire restore(polyglot-only) and wires it into DI and the root command when polyglot support is enabled. - Updates polyglot project codegen flow to return success/failure from SDK regeneration and propagates that to callers.
- Adds E2E + CI/Docker validation to ensure TypeScript SDK generation works and TypeScript playground apps type-check with
tsc.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs | Registers RestoreCommand in the CLI test service collection. |
| tests/Aspire.Cli.EndToEnd.Tests/TypeScriptCodegenValidationTests.cs | New E2E test that creates a TS AppHost, adds integrations, runs aspire restore, and validates generated SDK files. |
| src/Aspire.Cli/Projects/GuestAppHostProject.cs | Makes SDK regeneration return bool and propagates failure to add/update flows. |
| src/Aspire.Cli/Program.cs | Registers RestoreCommand in the production DI container. |
| src/Aspire.Cli/Commands/RootCommand.cs | Adds restore subcommand under the polyglot feature flag gate. |
| src/Aspire.Cli/Commands/RestoreCommand.cs | New implementation of aspire restore for guest (non-.NET) AppHosts. |
| .github/workflows/polyglot-validation/test-typescript-playground.sh | New script to run aspire restore + tsc --noEmit across TS playground apps. |
| .github/workflows/polyglot-validation/Dockerfile.typescript | Updates TS validation container to run the new playground validation script. |
Comments suppressed due to low confidence (3)
src/Aspire.Cli/Commands/RestoreCommand.cs:46
RestoreCommandkeeps both the baseInteractionServiceproperty and a separate_interactionServicefield, then mixes the two. This is redundant and makes it harder to reason about which interaction service is being used (especially for extension-host scenarios). Consider removing the field and consistently usingInteractionService(or consistently using the injected field) throughout the command.
private readonly IProjectLocator _projectLocator;
private readonly IAppHostProjectFactory _projectFactory;
private readonly IInteractionService _interactionService;
private readonly ILogger<RestoreCommand> _logger;
private static readonly OptionWithLegacy<FileInfo?> s_appHostOption = new("--apphost", "--project", SharedCommandStrings.AppHostOptionDescription);
public RestoreCommand(
IProjectLocator projectLocator,
IAppHostProjectFactory projectFactory,
IFeatures features,
ICliUpdateNotifier updateNotifier,
CliExecutionContext executionContext,
IInteractionService interactionService,
ILogger<RestoreCommand> logger,
AspireCliTelemetry telemetry)
: base("restore", "Regenerate polyglot SDK code for a non-.NET AppHost project.", features, updateNotifier, executionContext, interactionService, telemetry)
{
_projectLocator = projectLocator;
_projectFactory = projectFactory;
_interactionService = interactionService;
_logger = logger;
src/Aspire.Cli/Commands/RestoreCommand.cs:84
RestoreCommanddepends on the concreteGuestAppHostProjecttype (and itsBuildAndGenerateSdkAsyncmethod) via a downcast. That makes the command harder to extend to other non-.NET AppHost project types and tightly couplesCommandsto an implementation detail. Consider introducing an interface/abstraction for “SDK restore/regeneration” (implemented by guest projects) and using that instead of the concrete cast.
var project = _projectFactory.TryGetProject(effectiveAppHostFile);
if (project is null)
{
InteractionService.DisplayError("Unrecognized app host type.");
return ExitCodeConstants.FailedToFindProject;
}
if (project is not GuestAppHostProject guestProject)
{
InteractionService.DisplayError("The restore command is only supported for polyglot (non-.NET) AppHost projects.");
return ExitCodeConstants.InvalidCommand;
}
src/Aspire.Cli/Commands/RestoreCommand.cs:92
- The
ShowStatusAsynccallback uses anasync () => await ...wrapper. SinceBuildAndGenerateSdkAsyncalready returns aTask<bool>, this extra async/await adds noise and can slightly obscure exception propagation; consider passing the task-returning delegate directly.
var success = await _interactionService.ShowStatusAsync(
":gear: Restoring polyglot SDK code...",
async () => await guestProject.BuildAndGenerateSdkAsync(directory, cancellationToken));
.github/workflows/polyglot-validation/test-typescript-playground.sh
Outdated
Show resolved
Hide resolved
Enable 'set -euo pipefail' and avoid piping npm install output through tail, which masked failures. Now captures output first, checks exit code, then displays the tail on success or more context on failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Lets decide what this will do for .NET as well. |
Create
aspire restorecommand to generate polyglot apps only, without requiring to either run it or add an integration.Then using it for the playground apps validation by generating and ensuring
tscsucceeds on it.