From 650ab9fd3a6c8508286c19bc290d88becb021890 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 19:17:17 +0000 Subject: [PATCH] feat(build): detect root frontend manifests --- pkg/build/discovery.go | 8 +++++--- pkg/build/discovery_test.go | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/build/discovery.go b/pkg/build/discovery.go index 5b52484..c7a0c03 100644 --- a/pkg/build/discovery.go +++ b/pkg/build/discovery.go @@ -239,7 +239,8 @@ type DiscoveryResult struct { Types []ProjectType // PrimaryStack is the best stack suggestion based on detected types. PrimaryStack string - // HasFrontend is true when frontend/package.json or subtree npm is found. + // HasFrontend is true when a root or frontend/ package.json/deno manifest is found, + // or when a nested frontend tree is detected. HasFrontend bool // HasSubtreeNpm is true when a nested package.json exists within depth 2. HasSubtreeNpm bool @@ -285,8 +286,9 @@ func DiscoverFull(fs io.Medium, dir string) (*DiscoveryResult, error) { // Subtree npm detection result.HasSubtreeNpm = HasSubtreeNpm(fs, dir) - // Frontend detection: frontend package managers or nested frontend manifests. - result.HasFrontend = hasFrontendManifest(fs, ax.Join(dir, "frontend")) || + // Frontend detection: root manifests, frontend/ manifests, or nested frontend trees. + result.HasFrontend = hasFrontendManifest(fs, dir) || + hasFrontendManifest(fs, ax.Join(dir, "frontend")) || hasSubtreeFrontendManifest(fs, dir) || result.HasSubtreeNpm diff --git a/pkg/build/discovery_test.go b/pkg/build/discovery_test.go index c6d51b5..9b46c1f 100644 --- a/pkg/build/discovery_test.go +++ b/pkg/build/discovery_test.go @@ -583,6 +583,18 @@ func TestDiscovery_DiscoverFull_Good(t *testing.T) { assert.True(t, result.HasFrontend) }) + t.Run("detects root package.json as frontend", func(t *testing.T) { + dir := t.TempDir() + require.NoError(t, ax.WriteFile(ax.Join(dir, "package.json"), []byte("{}"), 0644)) + + result, err := DiscoverFull(fs, dir) + require.NoError(t, err) + assert.Equal(t, []ProjectType{ProjectTypeNode}, result.Types) + assert.Equal(t, "node", result.PrimaryStack) + assert.True(t, result.HasFrontend) + assert.False(t, result.HasSubtreeNpm) + }) + t.Run("detects frontend deno manifest at project root", func(t *testing.T) { dir := t.TempDir() err := ax.WriteFile(ax.Join(dir, "go.mod"), []byte("{}"), 0644)