appdetect

package
v0.0.0-...-c58b02f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package appdetect allows for detection of application projects.

Projects are detected based on criteria such as: 1. Presence of project files. 2. Source code language file extensions

To determine dependencies, a project file might also be read for dependent packages.

- `Detect()` to detect all projects under a root directory. - `DetectDirectory` to detect a project under a given directory.

Index

Constants

This section is empty.

Variables

View Source
var WebUIFrameworks = map[Dependency]struct{}{
	JsReact:   {},
	JsAngular: {},
	JsJQuery:  {},
	JsVite:    {},
}

Functions

func PyFastApiLaunch

func PyFastApiLaunch(projectPath string) (string, error)

PyFastApiLaunch returns the launch argument for a python FastAPI project to be served by a python web server. An empty string is returned if the project is not a FastAPI project. An error is returned only if the project path cannot be walked.

Types

type DatabaseDep

type DatabaseDep string

A type of database that is inferred through heuristics while scanning project information.

const (
	// Database dependencies
	DbPostgres  DatabaseDep = "postgres"
	DbMongo     DatabaseDep = "mongo"
	DbMySql     DatabaseDep = "mysql"
	DbSqlServer DatabaseDep = "sqlserver"
	DbRedis     DatabaseDep = "redis"
)

func (DatabaseDep) Display

func (db DatabaseDep) Display() string

type Dependency

type Dependency string
const (
	JsReact   Dependency = "react"
	JsAngular Dependency = "angular"
	JsJQuery  Dependency = "jquery"
	JsVite    Dependency = "vite"
	JsNext    Dependency = "next"

	PyFlask   Dependency = "flask"
	PyDjango  Dependency = "django"
	PyFastApi Dependency = "fastapi"
)

func (Dependency) Display

func (f Dependency) Display() string

func (Dependency) IsWebUIFramework

func (f Dependency) IsWebUIFramework() bool

func (Dependency) Language

func (f Dependency) Language() Language

type DetectDirectoryOption

type DetectDirectoryOption interface {
	// contains filtered or unexported methods
}

type DetectOption

type DetectOption interface {
	// contains filtered or unexported methods
}

func WithExcludePatterns

func WithExcludePatterns(patterns []string, overrideDefaults bool) DetectOption

type Docker

type Docker struct {
	Path string
}

type Language

type Language string
const (
	DotNet        Language = "dotnet"
	DotNetAppHost Language = "dotnet-apphost"
	Java          Language = "java"
	JavaScript    Language = "js"
	TypeScript    Language = "ts"
	Python        Language = "python"
)

func (Language) Display

func (pt Language) Display() string

type LanguageOption

type LanguageOption interface {
	DetectOption
	DetectDirectoryOption
}

func WithDotNet

func WithDotNet() LanguageOption

func WithJava

func WithJava() LanguageOption

func WithJavaScript

func WithJavaScript() LanguageOption

func WithPython

func WithPython() LanguageOption

func WithoutDotNet

func WithoutDotNet() LanguageOption

func WithoutJava

func WithoutJava() LanguageOption

func WithoutJavaScript

func WithoutJavaScript() LanguageOption

func WithoutPython

func WithoutPython() LanguageOption

type PackagesJson

type PackagesJson struct {
	Dependencies    map[string]string `json:"dependencies"`
	DevDependencies map[string]string `json:"devDependencies"`
}

type Project

type Project struct {
	// The language associated with the project.
	Language Language

	// Dependencies scanned in the project.
	Dependencies []Dependency

	// Experimental: Database dependencies inferred through heuristics while scanning dependencies in the project.
	DatabaseDeps []DatabaseDep

	// The path to the project directory.
	Path string

	// A short description of the detection rule applied.
	DetectionRule string

	// If true, the project uses Docker for packaging. This is inferred through the presence of a Dockerfile.
	Docker *Docker
}

func Detect

func Detect(ctx context.Context, root string, options ...DetectOption) ([]Project, error)

Detect detects projects located under a directory.

func DetectDirectory

func DetectDirectory(ctx context.Context, directory string, options ...DetectDirectoryOption) (*Project, error)

DetectDirectory detects the project located in a directory.

func (*Project) HasWebUIFramework

func (p *Project) HasWebUIFramework() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL