- Fix RegisterCommands call to match single-arg signature; register locales separately via i18n.RegisterLocales - Replace os.Stat/os.ReadDir with coreio.Local equivalents in detect.go, format.go, main.go, cmd_docblock.go - Add tests for languagesFromRules, IsExcludedDir, ScanFile edge cases - Coverage: pkg/lint 71.0% → 72.9%, pkg/detect 100%, pkg/php 68.7% Co-Authored-By: Virgil <virgil@lethean.io>
38 lines
888 B
Go
38 lines
888 B
Go
// Package detect identifies project types by examining filesystem markers.
|
|
package detect
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
coreio "forge.lthn.ai/core/go-io"
|
|
)
|
|
|
|
// ProjectType identifies a project's language/framework.
|
|
type ProjectType string
|
|
|
|
const (
|
|
Go ProjectType = "go"
|
|
PHP ProjectType = "php"
|
|
)
|
|
|
|
// IsGoProject returns true if dir contains a go.mod file.
|
|
func IsGoProject(dir string) bool {
|
|
return coreio.Local.Exists(filepath.Join(dir, "go.mod"))
|
|
}
|
|
|
|
// IsPHPProject returns true if dir contains a composer.json file.
|
|
func IsPHPProject(dir string) bool {
|
|
return coreio.Local.Exists(filepath.Join(dir, "composer.json"))
|
|
}
|
|
|
|
// DetectAll returns all detected project types in the directory.
|
|
func DetectAll(dir string) []ProjectType {
|
|
var types []ProjectType
|
|
if IsGoProject(dir) {
|
|
types = append(types, Go)
|
|
}
|
|
if IsPHPProject(dir) {
|
|
types = append(types, PHP)
|
|
}
|
|
return types
|
|
}
|