-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #423
- Loading branch information
Showing
8 changed files
with
140 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package appdetect | ||
|
||
import ( | ||
"context" | ||
"io/fs" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/BurntSushi/toml" | ||
) | ||
|
||
type rustDetector struct{} | ||
|
||
func (rd *rustDetector) Language() Language { | ||
return Rust | ||
} | ||
|
||
func (rd *rustDetector) DetectProject(ctx context.Context, path string, entries []fs.DirEntry) (*Project, error) { | ||
for _, entry := range entries { | ||
if strings.ToLower(entry.Name()) == "cargo.toml" { | ||
project := &Project{ | ||
Language: Rust, | ||
Path: path, | ||
DetectionRule: "Inferred by presence of: " + entry.Name(), | ||
} | ||
|
||
contents, err := os.ReadFile(filepath.Join(path, entry.Name())) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var cargoToml struct { | ||
Dependencies map[string]toml.Primitive `toml:"dependencies"` | ||
} | ||
err = toml.Unmarshal(contents, &cargoToml) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for k := range cargoToml.Dependencies { | ||
switch k { | ||
case string(RsActix): | ||
project.Dependencies = append(project.Dependencies, RsActix) | ||
case string(RsAxum): | ||
project.Dependencies = append(project.Dependencies, RsAxum) | ||
case string(RsYew): | ||
project.Dependencies = append(project.Dependencies, RsYew) | ||
} | ||
} | ||
|
||
return project, nil | ||
} | ||
} | ||
|
||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "testdata" | ||
version = "0.1.0" | ||
publish = false | ||
|
||
[dependencies] | ||
actix = "0.13.5" | ||
yew = "0.21.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters