feat(build): support pwa type override

This commit is contained in:
Virgil 2026-04-01 17:49:22 +00:00
parent fd04157c2d
commit b8053c3225
3 changed files with 35 additions and 0 deletions

View file

@ -33,6 +33,12 @@ func runProjectBuild(ctx context.Context, buildType string, ciMode bool, targets
return coreerr.E("build.Run", "failed to get working directory", err)
}
// PWA builds use the dedicated local web-app pipeline rather than the
// project-type builder registry.
if buildType == "pwa" {
return runLocalPwaBuild(ctx, projectDir)
}
// Load configuration from .core/build.yaml (or defaults)
var buildConfig *build.BuildConfig
if configPath != "" {
@ -50,6 +56,10 @@ func runProjectBuild(ctx context.Context, buildType string, ciMode bool, targets
return coreerr.E("build.Run", "failed to load config", err)
}
if buildConfig.Build.Type == "pwa" {
return runLocalPwaBuild(ctx, projectDir)
}
if err := build.SetupBuildCache(filesystem, projectDir, buildConfig); err != nil {
return coreerr.E("build.Run", "failed to set up build cache", err)
}

View file

@ -162,3 +162,24 @@ func TestBuildCmd_selectOutputArtifacts_Good(t *testing.T) {
assert.Equal(t, rawArtifacts, selected)
})
}
func TestBuildCmd_runProjectBuild_PwaOverride_Good(t *testing.T) {
expectedWD, err := ax.Getwd()
require.NoError(t, err)
original := runLocalPwaBuild
t.Cleanup(func() {
runLocalPwaBuild = original
})
called := false
runLocalPwaBuild = func(ctx context.Context, projectDir string) error {
called = true
assert.Equal(t, expectedWD, projectDir)
return nil
}
err = runProjectBuild(context.Background(), "pwa", false, "", "", false, false, "", "", false, "", false, false, false)
require.NoError(t, err)
assert.True(t, called)
}

View file

@ -28,6 +28,10 @@ var (
errURLRequired = coreerr.E("buildcmd.Init", "the --url flag is required", nil)
)
// runLocalPwaBuild points at the local PWA build entrypoint.
// Tests replace this to avoid invoking the real build toolchain.
var runLocalPwaBuild = runBuild
// runPwaBuild downloads a PWA from URL and builds it.
func runPwaBuild(ctx context.Context, pwaURL string) error {
core.Print(nil, "%s %s", i18n.T("cmd.build.pwa.starting"), pwaURL)