Skip to content

ProjectDetector

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/parser-core/src/detector/project-detector.ts

ProjectDetector class

Detects project type, frameworks, package manager, and build tools by analyzing project structure and configuration files.

Methods

MethodSignatureReturns
detectdetect(rootDir: string)Promise<DetectedProject>
addFrameworkRuleaddFrameworkRule(rule: FrameworkRule)void
getFrameworkRulesgetFrameworkRules()FrameworkRule[]
hasFrameworkhasFramework(rootDir: string, frameworkName: string)Promise<boolean>
supportsParsersupportsParser(rootDir: string, parserName: string)Promise<boolean>

Where it refuses work

  • ProjectDetector stops the work with Error when !fs.existsSync(absoluteRootDir).
  • ProjectDetector stops the work with an early return when depth >= maxDepth, in 3 places.
  • ProjectDetector stops the work with an early return when !fs.existsSync(packageJsonPath).
  • ProjectDetector stops the work with an early return when fs.existsSync(path.join(rootDir, 'bun.lockb')).
  • ProjectDetector stops the work with an early return when fs.existsSync(path.join(rootDir, 'pnpm-lock.yaml')).
  • ProjectDetector stops the work with an early return when fs.existsSync(path.join(rootDir, 'yarn.lock')).

When something fails

  • ProjectDetector handles failure in 5 places: it discards it silently in 4, and turns it into a return value in 1.

Was this page helpful?

Download as PDF