-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreacteol.go
61 lines (50 loc) · 1.4 KB
/
reacteol.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"cuddly-eureka-/conf/initialize"
"cuddly-eureka-/github"
"cuddly-eureka-/http"
"cuddly-eureka-/types"
"cuddly-eureka-/util"
"fmt"
)
type ReactEOL struct {
}
func getVersionFromPackageJson(g *github.GitHub, repoName, gitHubOwner string) (*string, bool) {
packageJson, err := g.GetPackageJSON(repoName, gitHubOwner)
if err != nil {
fmt.Printf("Warning: Failed to read package.json for %s\n", repoName)
return nil, false
}
version := util.GetVersionFromPackageJSON(packageJson, "react")
if version != nil {
return version, true
}
return nil, false
}
func (react *ReactEOL) Check(repoName string, opts ...*string) types.MaturityCheck {
app := initialize.GetAppConstants()
g := &github.GitHub{}
g = g.Init(app.GitHubToken)
eolDetails, eolErr := http.EOLProvider(http.EOLReact)
if eolErr != nil {
panic("Failed to find EOL details for " + http.EOLReact + " ")
}
var existingVersion *string
// 1 - Check package.json
versionFromPJ, foundVersionFromPJ := getVersionFromPackageJson(g, repoName, app.GitHubOwner)
if foundVersionFromPJ {
existingVersion = versionFromPJ
}
if existingVersion != nil {
eolValue := util.CheckEOL(*existingVersion, eolDetails)
return eolValue
}
return types.MaturityValue0
}
func (react *ReactEOL) Meta() types.MaturityMeta {
return types.MaturityMeta{
Type: types.MaturityTypeDependency,
Name: "Not EOL: React",
}
}
var Check ReactEOL