Files
zeekay 7844a60aff refactor(pack): modernize to github.com/hanzoai/pack and remove upstream branding
- Migrate module path to github.com/hanzoai/pack across all Go packages
- Remove legacy upstream docs and competitor brand references
- Modernize LLM.md and mise.toml for pristine Hanzo Pack builder
2026-09-04 00:40:42 -07:00

49 lines
1.1 KiB
Go

package node
import (
"regexp"
"strings"
"github.com/hanzoai/pack/core/generate"
)
const (
DefaultNextOutputDirectory = "out"
DefaultNextStartCommand = "next start"
)
var nextConfigFiles = []string{
"next.config.js",
"next.config.mjs",
"next.config.ts",
}
func (p *NodeProvider) isNextSPA(ctx *generate.GenerateContext) bool {
if !p.isNext() {
return false
}
configFileContents := p.getNextConfigFileContents(ctx)
hasExportOutput := strings.Contains(configFileContents, "output: 'export'") || strings.Contains(configFileContents, "output: \"export\"")
return hasExportOutput
}
func (p *NodeProvider) getNextOutputDirectory(ctx *generate.GenerateContext) string {
configFileContents := p.getNextConfigFileContents(ctx)
if configFileContents != "" {
distDirRegex := regexp.MustCompile(`distDir:\s*['"](.+?)['"]`)
matches := distDirRegex.FindStringSubmatch(configFileContents)
if len(matches) > 1 {
return matches[1]
}
}
return DefaultNextOutputDirectory
}
func (p *NodeProvider) getNextConfigFileContents(ctx *generate.GenerateContext) string {
_, contents, _ := ctx.App.ReadFirstFileOf(nextConfigFiles...)
return contents
}