Refactor build and topdata path resolution through project config
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/erf"
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/gff"
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/project"
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/topdata"
|
||||
)
|
||||
|
||||
type CompareResult struct {
|
||||
@@ -31,12 +30,12 @@ type resourceExpectation struct {
|
||||
}
|
||||
|
||||
func Compare(p *project.Project) (CompareResult, error) {
|
||||
modulePath := filepath.Join(p.BuildDir(), p.Config.Module.ResRef+".mod")
|
||||
modulePath := p.ModuleArchivePath()
|
||||
|
||||
var hakPaths []string
|
||||
if len(p.Inventory.AssetFiles) > 0 {
|
||||
var err error
|
||||
hakPaths, err = manifestHAKPaths(p.BuildDir())
|
||||
hakPaths, err = manifestHAKPaths(p)
|
||||
if err != nil {
|
||||
return CompareResult{}, err
|
||||
}
|
||||
@@ -294,8 +293,8 @@ func resourceKey(name, extension string) string {
|
||||
return strings.ToLower(name) + "." + strings.TrimPrefix(strings.ToLower(extension), ".")
|
||||
}
|
||||
|
||||
func manifestHAKPaths(buildDir string) ([]string, error) {
|
||||
manifestPath := filepath.Join(buildDir, "haks.json")
|
||||
func manifestHAKPaths(p *project.Project) ([]string, error) {
|
||||
manifestPath := p.HAKManifestPath()
|
||||
raw, err := os.ReadFile(manifestPath)
|
||||
if err == nil {
|
||||
var manifest BuildManifest
|
||||
@@ -304,7 +303,7 @@ func manifestHAKPaths(buildDir string) ([]string, error) {
|
||||
}
|
||||
paths := make([]string, 0, len(manifest.HAKs))
|
||||
for _, hak := range manifest.HAKs {
|
||||
paths = append(paths, filepath.Join(buildDir, hak.Name+".hak"))
|
||||
paths = append(paths, p.HAKArchivePath(hak.Name))
|
||||
}
|
||||
return paths, nil
|
||||
}
|
||||
@@ -312,14 +311,14 @@ func manifestHAKPaths(buildDir string) ([]string, error) {
|
||||
return nil, fmt.Errorf("read hak manifest: %w", err)
|
||||
}
|
||||
|
||||
legacy := filepath.Join(buildDir, "*.hak")
|
||||
legacy := filepath.Join(p.BuildDir(), "*.hak")
|
||||
paths, err := filepath.Glob(legacy)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("scan hak archives: %w", err)
|
||||
}
|
||||
filtered := make([]string, 0, len(paths))
|
||||
for _, path := range paths {
|
||||
if filepath.Base(path) == topdata.PackageHAKFileName {
|
||||
if filepath.Base(path) == p.TopDataPackageHAKName() {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, path)
|
||||
|
||||
Reference in New Issue
Block a user