diff --git a/cmd/fn/main.go b/cmd/fn/main.go index 7a914f6f..63dc6346 100644 --- a/cmd/fn/main.go +++ b/cmd/fn/main.go @@ -127,6 +127,9 @@ func cmdIndex() { for _, e := range result.ValidationErrors { fmt.Fprintf(os.Stderr, " INVALID: %s\n", e) } + for _, w := range result.Warnings { + fmt.Fprintf(os.Stderr, " WARN: %s\n", w) + } for _, e := range result.Errors { fmt.Fprintf(os.Stderr, " ERROR: %s\n", e) } diff --git a/registry/indexer.go b/registry/indexer.go index fe7d3662..12bddafc 100644 --- a/registry/indexer.go +++ b/registry/indexer.go @@ -15,6 +15,7 @@ type IndexResult struct { Apps int Analysis int ValidationErrors []string + Warnings []string Errors []string } @@ -202,6 +203,30 @@ func Index(db *DB, root string) (*IndexResult, error) { result.Analysis++ } + // Post-insert: warn about file_path entries that don't exist on disk + for _, f := range functions { + if f.FilePath != "" { + abs := filepath.Join(root, f.FilePath) + if _, err := os.Stat(abs); err != nil { + result.Warnings = append(result.Warnings, fmt.Sprintf("%s: file_path %q not found", f.ID, f.FilePath)) + } + } + if f.TestFilePath != "" { + abs := filepath.Join(root, f.TestFilePath) + if _, err := os.Stat(abs); err != nil { + result.Warnings = append(result.Warnings, fmt.Sprintf("%s: test_file_path %q not found", f.ID, f.TestFilePath)) + } + } + } + for _, t := range types { + if t.FilePath != "" { + abs := filepath.Join(root, t.FilePath) + if _, err := os.Stat(abs); err != nil { + result.Warnings = append(result.Warnings, fmt.Sprintf("%s: file_path %q not found", t.ID, t.FilePath)) + } + } + } + return result, nil }