@@ -521,10 +521,6 @@ func (m *ScanModel) buildManifestListModel() *listModel {
521521 rootManifests , groups := m .manifestTreeGroups ()
522522 projectMerged := len (rootManifests ) == 1
523523 projectDetailLines := projectDetails (m , packageCount (m .graphValue ), packageCount (m .graphValue ))
524- if projectMerged {
525- projectDetailLines = append (projectDetailLines , "" )
526- projectDetailLines = append (projectDetailLines , manifestDetails (m .graphValue , m .manifests [rootManifests [0 ]])... )
527- }
528524 items = append (items , listItem {
529525 title : m .projectNodeTitle (groups ),
530526 subtitle : "project" ,
@@ -656,10 +652,6 @@ func (m *ScanModel) buildComponentsTreeListModel() *listModel {
656652 projectKey := "project"
657653 projectExpanded := expandedValue (m .componentExpanded , projectKey , true )
658654 projectDetailLines := projectDetails (m , filteredComponentCount , totalComponents )
659- if projectMerged {
660- projectDetailLines = append (projectDetailLines , "" )
661- projectDetailLines = append (projectDetailLines , manifestDetails (m .graphValue , m .manifests [rootManifests [0 ]])... )
662- }
663655 items = append (items , listItem {
664656 title : m .projectNodeTitle (groups ),
665657 subtitle : "project" ,
@@ -792,7 +784,7 @@ func (m *ScanModel) buildComponentsTreeListModel() *listModel {
792784 title : row .displayName ,
793785 subtitle : row .relationship ,
794786 badges : badges ,
795- details : componentDetails ( m . graphValue , m . registry , row , manifest ),
787+ details : m . rootNodeDetails ( row , manifest , attached ),
796788 key : row .id ,
797789 tree : treeLevelPrefix (ancestorsLast ) + treeConnector (last ),
798790 depth : depth ,
@@ -989,7 +981,7 @@ func (m *ScanModel) projectNodeTitle(groups []*manifestTreeGroup) string {
989981}
990982
991983func projectDetails (m * ScanModel , filteredComponents , totalComponents int ) []string {
992- return []string {
984+ lines := []string {
993985 render .Style ("Project" , render .Bold , render .Cyan ),
994986 "" ,
995987 render .Style (" Name: " , render .Dim ) + valueOrDash (m .project .Name ),
@@ -998,6 +990,54 @@ func projectDetails(m *ScanModel, filteredComponents, totalComponents int) []str
998990 render .Style (" Manifests: " , render .Dim ) + fmt .Sprintf ("%d" , len (m .manifests )),
999991 render .Style (" Components: " , render .Dim ) + fmt .Sprintf ("%d of %d" , filteredComponents , totalComponents ),
1000992 }
993+ if contents := m .projectContentsLines (); len (contents ) > 0 {
994+ lines = append (lines , "" , render .Style ("Manifests" , render .Bold , render .Cyan ))
995+ lines = append (lines , contents ... )
996+ }
997+ return lines
998+ }
999+
1000+ // projectContentsLines lists what the scan found inside the target: its
1001+ // manifests with the module and subproject nodes nested beneath the manifest
1002+ // that resolves them.
1003+ func (m * ScanModel ) projectContentsLines () []string {
1004+ rootManifests , groups := m .manifestTreeGroups ()
1005+ var lines []string
1006+ groupLine := func (group * manifestTreeGroup , indent string ) string {
1007+ name := group .label
1008+ suffix := ""
1009+ if len (group .manifests ) > 0 {
1010+ manifest := m .manifests [group .manifests [0 ]]
1011+ if rootName := m .manifestRootName (manifest ); rootName != "" && rootName != manifest .displayName {
1012+ name = rootName
1013+ }
1014+ suffix = " [" + manifest .id + "]"
1015+ }
1016+ return render .Style (indent , render .Dim ) + name + render .Style (" (" + string (group .kind )+ ")" + suffix , render .Dim )
1017+ }
1018+ attachedByManifest := map [int ][]* manifestTreeGroup {}
1019+ var unattached []* manifestTreeGroup
1020+ for _ , group := range groups {
1021+ if group .kind == output .ManifestNodeModule && group .attachedTo >= 0 {
1022+ attachedByManifest [group .attachedTo ] = append (attachedByManifest [group .attachedTo ], group )
1023+ continue
1024+ }
1025+ unattached = append (unattached , group )
1026+ }
1027+ for _ , index := range rootManifests {
1028+ manifest := m .manifests [index ]
1029+ lines = append (lines , render .Style (" " , render .Dim )+ manifest .id + render .Style (" (" + valueOrDash (manifest .packageManagers )+ ")" , render .Dim ))
1030+ for _ , group := range attachedByManifest [index ] {
1031+ lines = append (lines , groupLine (group , " " ))
1032+ }
1033+ }
1034+ for _ , group := range unattached {
1035+ lines = append (lines , groupLine (group , " " ))
1036+ for _ , child := range group .children {
1037+ lines = append (lines , groupLine (child , " " ))
1038+ }
1039+ }
1040+ return lines
10011041}
10021042
10031043func packageCount (graphValue * sdk.Graph ) int {
@@ -2715,9 +2755,6 @@ func manifestDetails(graphValue *sdk.Graph, row listPackageRow) []string {
27152755 render .Style (" Root (project package): " , render .Dim ) + packageDisplayName (rootPkg ),
27162756 render .Style (" Direct dependencies: " , render .Dim ) + fmt .Sprintf ("%d" , len (groups .direct )),
27172757 render .Style (" Transitive dependencies: " , render .Dim ) + fmt .Sprintf ("%d" , len (groups .transitive )),
2718- "" ,
2719- render .Style ("Press Enter to view components for this manifest." , render .Dim ),
2720- "" ,
27212758 }
27222759 return lines
27232760}
0 commit comments