Skip to content

Commit cdeb72e

Browse files
author
Frank Martinez
committed
Merge branch 'pr/69'
2 parents 23602cf + 33eff84 commit cdeb72e

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
## OS X Resources
33
.DS_Store
4+
.vscode/
45

56
# Binaries
67
*.exe

api/build.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func optimizeImports(project common.AppProject) error {
221221
var unused []util.Import
222222
appImports.GetAllImports()
223223
for _, impDetails := range appImports.GetAllImportDetails() {
224-
if !impDetails.Used() {
224+
if !impDetails.Referenced() && impDetails.IsCoreContrib() {
225225
unused = append(unused, impDetails.Imp)
226226
}
227227
}

api/list.go

+18-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
type ListFilter int
1515

16-
1716
func ListContribs(project common.AppProject, jsonFormat bool, filter string) error {
1817

1918
ai, err := util.GetAppImports(filepath.Join(project.Dir(), fileFlogoJson), project.DepManager(), true)
@@ -90,32 +89,32 @@ func ListContribs(project common.AppProject, jsonFormat bool, filter string) err
9089

9190
func includeContrib(details *util.AppImportDetails, filter string) bool {
9291

93-
if !details.IsContrib() {
94-
return false
95-
}
92+
if details.IsCoreContrib() {
9693

97-
switch strings.ToLower(filter) {
98-
case "used":
99-
return details.Used()
100-
case "unused":
101-
return !details.Used()
102-
default:
103-
return true
94+
switch strings.ToLower(filter) {
95+
case "used":
96+
return details.Referenced()
97+
case "unused":
98+
return !details.Referenced()
99+
default:
100+
return true
101+
}
104102
}
103+
return false
104+
105105
}
106106

107107
type ContribSpec struct {
108-
Name string `json:"name"`
109-
Type string `json:"type"`
110-
Description string `json:"description"`
111-
Homepage string `json:"homepage"`
112-
Ref string `json:"ref"`
113-
Path string `json:"path"`
114-
Descriptor string `json:"descriptor"`
108+
Name string `json:"name"`
109+
Type string `json:"type"`
110+
Description string `json:"description"`
111+
Homepage string `json:"homepage"`
112+
Ref string `json:"ref"`
113+
Path string `json:"path"`
114+
Descriptor string `json:"descriptor"`
115115
IsLegacy interface{} `json:"isLegacy,omitempty"`
116116
}
117117

118-
119118
func ListOrphanedRefs(project common.AppProject, jsonFormat bool) error {
120119

121120
ai, err := util.GetAppImports(filepath.Join(project.Dir(), fileFlogoJson), project.DepManager(), true)

commands/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ var listCmd = &cobra.Command{
4242
os.Exit(1)
4343
}
4444
},
45-
}
45+
}

util/app.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,23 @@ type AppImportDetails struct {
2727
HasDirectRef bool // a direct reference exists for this import
2828
}
2929

30-
func (d *AppImportDetails) Used() bool {
30+
func (d *AppImportDetails) Referenced() bool {
3131
return d.HasAliasRef || d.HasDirectRef
3232
}
3333

34-
func (d *AppImportDetails) IsContrib() bool {
35-
return d.ContribDesc != nil
34+
func (d *AppImportDetails) IsCoreContrib() bool {
35+
36+
if d.ContribDesc == nil {
37+
return false
38+
}
39+
ct := d.ContribDesc.GetContribType()
40+
41+
switch ct {
42+
case "action", "trigger", "activity":
43+
return true
44+
default:
45+
return false
46+
}
3647
}
3748

3849
type AppImports struct {

0 commit comments

Comments
 (0)