Skip to content

Commit 18f924d

Browse files
committed
feat: remove strict dependency on .shopware-extension.yml
1 parent c38cb22 commit 18f924d

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

main.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ func (d *PackageDetailsResponse) GetLatestVersion() *PackageVersion {
5454
}
5555

5656
type ShopwareExtensionMetadata struct {
57-
RepositoryUrl string `json:"repositoryUrl"`
58-
Ref string `json:"ref"`
59-
LatestCommitTime int `json:"latestCommitTime"`
57+
RepositoryUrl string `json:"repositoryUrl"`
58+
Ref string `json:"ref"`
59+
LatestCommitTime int `json:"latestCommitTime"`
60+
AdditionalMetadataExists bool `json:"additionalMetadataExists"`
6061
}
6162

6263
type ShopwareExtensionIndex struct {
@@ -122,11 +123,11 @@ func (c *GitHubClient) FetchLatestCommitTime(owner, repo string) (int, error) {
122123
return int(commitTime.Unix()), nil
123124
}
124125

125-
func (c *GitHubClient) GetMetadata(repositoryURL string) (bool, int) {
126+
func (c *GitHubClient) GetLatestCommitTime(repositoryURL string) (bool, *int) {
126127
parts := strings.Split(repositoryURL, "/")
127128
if len(parts) < 5 {
128129
log.Printf("Invalid GitHub URL: %s", repositoryURL)
129-
return false, 0
130+
return false, nil
130131
}
131132

132133
owner := parts[3]
@@ -135,7 +136,7 @@ func (c *GitHubClient) GetMetadata(repositoryURL string) (bool, int) {
135136
resp, err := c.FetchFile(owner, repo, ".shopware-extension.yml")
136137
if err != nil {
137138
log.Printf("Failed to fetch .shopware-extension.yml file for %s/%s: %v", owner, repo, err)
138-
return false, 0
139+
return false, nil
139140
}
140141
defer resp.Body.Close()
141142

@@ -147,9 +148,10 @@ func (c *GitHubClient) GetMetadata(repositoryURL string) (bool, int) {
147148
commitTime, err := c.FetchLatestCommitTime(owner, repo)
148149
if err != nil {
149150
log.Printf("Failed to fetch latest commit time for %s/%s: %v", owner, repo, err)
151+
return false, nil
150152
}
151153

152-
return exists, commitTime
154+
return exists, &commitTime
153155
}
154156

155157
func FetchPackageDetails(packageName string) (*PackageDetails, error) {
@@ -343,14 +345,15 @@ func ProcessPackage(packageName string) *PackageData {
343345
if latestVersion != nil {
344346
log.Printf("Package: %s, Repository: %s\n", packageName, latestVersion.Source.URL)
345347
if strings.Contains(latestVersion.Source.URL, "github.com") {
346-
extension, commitTime := githubClient.GetMetadata(latestVersion.Source.URL)
347-
if extension {
348+
exists, commitTime := githubClient.GetLatestCommitTime(latestVersion.Source.URL)
349+
if commitTime != nil {
348350
return &PackageData{
349351
PackageName: packageName,
350352
Metadata: &ShopwareExtensionMetadata{
351-
RepositoryUrl: latestVersion.Source.URL,
352-
Ref: packageDetails.URL,
353-
LatestCommitTime: commitTime,
353+
RepositoryUrl: latestVersion.Source.URL,
354+
Ref: packageDetails.URL,
355+
LatestCommitTime: *commitTime,
356+
AdditionalMetadataExists: exists,
354357
},
355358
}
356359
}

0 commit comments

Comments
 (0)