-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `appdetect`, a package that detects application projects on the filesystem by scanning files and applying heuristics. This involves only static analysis of files. This will be used to analyze emitted metadata about the projects to feed `azure.yaml` and infra generation. Closes #2615
- Loading branch information
1 parent
e2fbcfe
commit 91f74f0
Showing
26 changed files
with
1,271 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,5 @@ pbnj | |
sethvargo | ||
stretchr | ||
theckman | ||
bmatcuk | ||
tonybaloney |
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 @@ | ||
appdetect |
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,55 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/azure/azure-dev/cli/azd/internal/appdetect" | ||
) | ||
|
||
var directory string | ||
var projectDirectory string | ||
|
||
func init() { | ||
flag.StringVar(&directory, "dir", "", "Directory containing projects to detect") | ||
flag.StringVar(&projectDirectory, "proj", "", "Specific project directory to detect") | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
if directory == "" && projectDirectory == "" { | ||
fmt.Println("must set one of 'proj', or 'dir'") | ||
os.Exit(1) | ||
} | ||
|
||
var projects []appdetect.Project | ||
var err error | ||
|
||
if directory != "" { | ||
projects, err = appdetect.Detect(directory) | ||
} | ||
|
||
if projectDirectory != "" { | ||
var project *appdetect.Project | ||
project, err = appdetect.DetectDirectory(projectDirectory) | ||
|
||
if err == nil && project != nil { | ||
projects = append(projects, *project) | ||
} | ||
} | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Println("Projects detected:") | ||
content, err := json.Marshal(projects) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf("%v\n", string(content)) | ||
} |
Oops, something went wrong.