mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
- 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
49 lines
1.1 KiB
Go
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
|
|
}
|