Add GSP project manifest and design layout
This commit is contained in:
@@ -28,26 +28,45 @@ func LoadProject(root string) (*Project, error) {
|
||||
ByID: map[string]*Unit{},
|
||||
Duplicates: map[string][]*Unit{},
|
||||
}
|
||||
manifest, err := loadManifest(absRoot)
|
||||
if err != nil {
|
||||
project.LoadIssues = append(project.LoadIssues, Issue{Level: "error", Code: "manifest_error", File: "gsp.manifest", Message: err.Error()})
|
||||
}
|
||||
project.Manifest = manifest
|
||||
|
||||
var files []string
|
||||
err = filepath.WalkDir(absRoot, func(path string, entry os.DirEntry, walkErr error) error {
|
||||
if walkErr != nil {
|
||||
project.LoadIssues = append(project.LoadIssues, Issue{Level: "error", Code: "walk_error", File: path, Message: walkErr.Error()})
|
||||
return nil
|
||||
for _, scanEntry := range project.Manifest.scanEntries() {
|
||||
scanPath := filepath.Join(absRoot, filepath.FromSlash(scanEntry))
|
||||
info, statErr := os.Stat(scanPath)
|
||||
if statErr != nil {
|
||||
project.LoadIssues = append(project.LoadIssues, Issue{Level: "warning", Code: "scan_missing", File: scanEntry, Message: "scan path does not exist"})
|
||||
continue
|
||||
}
|
||||
if entry.IsDir() {
|
||||
if ignoredDirs[entry.Name()] {
|
||||
return filepath.SkipDir
|
||||
if !info.IsDir() {
|
||||
if strings.EqualFold(filepath.Ext(scanPath), ".gsp") {
|
||||
files = append(files, scanPath)
|
||||
}
|
||||
continue
|
||||
}
|
||||
walkErr := filepath.WalkDir(scanPath, func(path string, entry os.DirEntry, walkErr error) error {
|
||||
if walkErr != nil {
|
||||
project.LoadIssues = append(project.LoadIssues, Issue{Level: "error", Code: "walk_error", File: path, Message: walkErr.Error()})
|
||||
return nil
|
||||
}
|
||||
if entry.IsDir() {
|
||||
if ignoredDirs[entry.Name()] {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if strings.EqualFold(filepath.Ext(entry.Name()), ".gsp") {
|
||||
files = append(files, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if walkErr != nil {
|
||||
return nil, walkErr
|
||||
}
|
||||
if strings.EqualFold(filepath.Ext(entry.Name()), ".gsp") {
|
||||
files = append(files, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sort.Strings(files)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user