@hyperfrontend/ project-scope§
Comprehensive project analysis, technology stack detection, and transactional virtual file system for Node.js tooling.
What is @hyperfrontend/project-scope?
@hyperfrontend/project-scope provides intelligent codebase analysis for JavaScript/TypeScript projects. It uses multi-signal heuristics to classify project types, detect frameworks and build tools, discover entry points, and map dependency graphs - all with confidence scoring and explainable evidence. The library also includes a virtual file system (VFS) for safe, atomic file modifications.
Designed for tooling authors building code generators, IDE extensions, CI/CD pipelines, and monorepo tooling. Built-in NX workspace detection reads nx.json, workspace.json, and project.json so tooling can adapt to NX-shaped repos with zero runtime peer dependencies.
Key Features
Detect application, library, e2e, tool, or plugin with confidence scoring and evidence tracking
Identify 20+ frameworks (React, Vue, Angular, Svelte), build tools (Vite, Webpack, esbuild), and testing frameworks (Jest, Vitest, Cypress)
Transaction-aware file operations with atomic commit/rollback
Detect NX, Turborepo, Lerna, pnpm/npm/Yarn workspaces; read project configurations
Build internal import graphs from source code with root/leaf node identification
Find application entries from package.json exports, bin fields, and convention patterns
Command-line access to all features with JSON/YAML output
Zero Runtime Dependencies
All dependencies bundled for minimal footprint
Why Use @hyperfrontend/project-scope?
Accurate Framework Detection for Code Generators
Simple package.json parsing misses meta-frameworks, optional dependencies, and configuration-based setups. A project with next installed might be Next.js, but could also be a library that exports Next.js components. This library's multi-signal heuristics analyze dependencies, directory structure (pages/, app/), and config files (next.config.js) together, returning confidence-scored results. Your generator knows with certainty whether to scaffold Next.js pages or React components.
Safe File Modifications with Rollback
Code generators that write directly to disk risk leaving projects in broken states when errors occur mid-generation. The VFS buffers all changes in memory - write 50 files, validate the result, then commitChanges() atomically or rollbackChanges() to discard everything. Path traversal attacks are blocked at the VFS layer, making generators safe to run on untrusted input.
Adaptive Tooling in Heterogeneous Monorepos
Monorepos contain React apps, Vue libraries, Node.js services, and Cypress suites - each requiring different lint rules, build configs, and CI pipelines. Use detectAll() per project to get technology detection with version info, then conditionally apply configurations. Cached results (30-60s TTL) ensure repeated analysis during builds stays fast.
IDE Extensions Without Manual Configuration
IDE features that adapt to frameworks typically require users to configure their project type manually. This library provides runtime detection - determine React vs Vue for component snippets, identify Jest vs Vitest for test runners, detect Vite vs Webpack for build task integration. The CLI enables integration with shell-based tooling and editor extensions.
Migration Planning with Evidence
Modernizing legacy codebases requires understanding current technology stack before planning migrations. analyzeProject() detects legacy frameworks (jQuery, AngularJS, Backbone), maps internal dependency graphs, and provides confidence-scored evidence for each detection. Generate reports that explain why each technology was detected, enabling data-driven migration decisions.
Installation
npm install @hyperfrontend/project-scope
Requirements
- Node.js: 18.0.0 or higher
- npm: 8.0.0 or higher
Note: This library is designed for Node.js environments only (no browser support). All file system operations use synchronous Node.js APIs.
Quick Start
Project Analysis
import { analyzeProject, detectAll } from '@hyperfrontend/project-scope'
// Full project analysis
const analysis = analyzeProject('./my-project')
console.log(analysis.projectType) // 'library' | 'application' | 'e2e' | 'tool'
console.log(analysis.frameworks.map((f) => `${f.name} (${f.confidence}%)`))
// Technology stack detection
const tech = detectAll('./my-project')
console.log(
'Frontend:',
tech.frontendFrameworks.map((f) => f.name)
)
console.log(
'Build:',
tech.buildTools.map((t) => t.name)
)
console.log(
'Testing:',
tech.testingFrameworks.map((t) => t.name)
)
Virtual File System
import { createTree, commitChanges, rollbackChanges } from '@hyperfrontend/project-scope'
const tree = createTree('./my-project')
tree.write('src/new-file.ts', 'export const hello = "world"')
tree.rename('src/old.ts', 'src/renamed.ts')
tree.delete('src/deprecated.ts')
commitChanges(tree) // Atomic commit, or rollbackChanges(tree) to discard
CLI
The package declares no bin, so nothing is installed onto your PATH. The commands are reached by calling run() with the argument list yourself, from a script or from your own tool's binary:
import { run } from '@hyperfrontend/project-scope'
run(['analyze', './my-project', '--format', 'json'])
run(['config', './my-project', '--type', 'typescript,eslint'])
const result = run(['tree', './my-project', '--depth', '3'])
process.exit(result.exitCode)
API Overview
The surface answers three questions about a directory on disk, and which one you are asking decides what you reach for.
What is this repository? analyzeProject(dir) answers the whole question in one call and returns an
AnalysisResult: project type, workspace type, frameworks,
build tools, testing frameworks, entry points, config files and a dependency summary, all in one object. Nothing is installed, built or executed to
produce it.
Each detection carries a confidence from 0 to 100 and the evidence that earned it, and that number is the useful part: a repository with a Svelte
dependency but no SvelteKit routing scores SvelteKit at 20, which is the signal a tool needs to ask rather than assume. When the whole report is more
than you want, detectProjectType classifies the
project alone and detectAll runs only the technology detectors.
Results are memoised for 30 to 60 seconds, so a loop over a monorepo does not re-read the same package twice.
Where are its pieces? discoverEntryPoints works
out what the project actually starts from, reading exports, main and bin off the manifest and scoring convention and framework paths beside them, and
buildDependencyGraph follows first-party imports
through the source to a graph with its roots and leaves marked. Root and workspace finders walk upwards from any nested path, so a tool handed one
file can still locate the repository it belongs to.
How do I change it safely? createTree(dir) returns a Tree that
buffers every write, delete, rename and permission change in memory; exists() and read() see those pending changes, so the tree reads as though the
edits had already landed. Committing is a free function rather than a method: commitChanges(tree) applies the batch to disk and reports what it did,
commitChanges(tree, { dryRun: true }) reports the same without touching anything, and rollbackChanges(tree) discards it. Paths that escape the root
are rejected before any of that.
Subpath imports narrow the surface rather than adding to it. /heuristics is the inference layer above, /tech is the detector catalogue (with
/tech/frontend, /tech/build, /tech/testing and their siblings splitting it by category), /project reads package manifests, config files and
repository roots, /nx reads nx.json and project.json for Nx-shaped repos, /vfs is the transactional tree, /models is types only, and /core
holds the filesystem, path, encoding and platform primitives everything else is built from. /cli is the command layer: the package declares no bin,
so run(argv) is how analyze, config, deps and tree are invoked,
from your own binary rather than from a shell.
Every export, option and return type is in the API reference.
Compatibility
Runs on
- Node.js>=18.0.0supported
- Browsersnot supported
- Web Workersnot supported
/cli parses arguments with util.parseArgs, so it needs Node.js 18.3+; every other entry runs on 18.0.
Ships as
- ESMTree-shakeable
- CJSNode and older bundlers
Architecture Highlights§
Detector results are cached per function for 30 to 60 seconds, so back-to-back analyses of the same project return the same answer: pass skipCache for a fresh read, or call clearAllCaches() to drop every cache at once. The virtual file system buffers writes, deletes, and renames in memory until commitChanges(), rejects paths that escape the tree, and validates symlinks before following them, so nothing reaches disk until you say so.
The architecture guide covers the module layers, the analysis pipeline, and the caching and security models.
API Reference§
Module Structure
30 modules · 933 total exports
Project analysis toolkit with CLI commands, tech stack detection, and workspace utilities.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String to add BOM to |
Returns
stringExample
Adding UTF-8 BOM to content
const content = 'Hello World'
const withBom = addBom(content)
// => '\ufeffHello World'Parameters
| Name | Type | Description |
|---|---|---|
§options | AnalyzeCommandOptions | Configuration for the analyze operation |
Returns
CommandResultExamples
Basic analysis of current directory
const result = analyzeCommand({ depth: 'basic' })
if (result.exitCode === 0) {
console.log(result.output)
// => "Project Type: Library\nWorkspace: NX Monorepo\n..."
}JSON output with filters
const result = analyzeCommand({
path: './apps/frontend',
format: 'json',
depth: 'deep',
exclude: ['node_modules', 'dist'],
})
// => { exitCode: 0, output: '{"type":"application",...}' }This is the main entry point for comprehensive project analysis. It orchestrates all detection modules and returns a unified result.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Path to project directory |
§options? | AnalyzeOptions | Analysis options |
Returns
AnalysisResultExample
Basic project analysis
const result = analyzeProject('./my-project')
console.log(result.projectType) // 'application' | 'library' | ...
console.log(result.frameworks) // [{ id: 'react', name: 'React', ... }]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Angular framework
const result = angularDetector('/path/to/angular-app', {
dependencies: { '@angular/core': '^17.0.0', '@angular/cli': '^17.0.0' }
})
// => {
// id: 'angular',
// name: 'Angular',
// category: 'frontend',
// version: '17.0.0',
// confidence: 85,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@angular/core' },
// { type: 'package.json', field: 'dependencies.@angular/cli' }
// ]
// }angularJSDetector( projectPath: string, packageJson?: PackageJson): LegacyFrameworkDetection
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting AngularJS framework
const result = angularJSDetector('/path/to/project', {
dependencies: { angular: '^1.8.0', 'angular-route': '^1.8.0' },
})
// => { id: 'angularjs', name: 'AngularJS', confidence: 85, version: '1.8.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Astro framework
const result = astroDetector('/path/to/astro-project', {
dependencies: { 'astro': '^4.0.0' }
})
// => {
// id: 'astro',
// name: 'Astro',
// category: 'meta-framework',
// version: '4.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.astro' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Babel compiler
const result = babelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@babel/core': '^7.23.0', '@babel/preset-env': '^7.23.0' }
})
// => {
// id: 'babel',
// name: 'Babel',
// version: '7.23.0',
// confidence: 60,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@babel/core' },
// { type: 'package.json', field: 'dependencies (@babel packages)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting Backbone.js framework
const result = backboneDetector('/path/to/project', {
dependencies: { backbone: '^1.4.0', underscore: '^1.13.0' },
})
// => { id: 'backbone', name: 'Backbone.js', confidence: 85, version: '1.4.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Biome linter
const result = biomeDetector('/path/to/project', {
devDependencies: { '@biomejs/biome': '^1.5.0' },
})
// => { id: 'biome', name: 'Biome', confidence: 70, version: '1.5.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§content | Buffer | Buffer to convert |
§encoding? | BufferEncoding | Optional encoding override (auto-detected if not provided) |
Returns
stringExample
Converting file buffer to string with auto-detection
const fileBuffer = readFileSync('./config.json')
const content = bufferToString(fileBuffer)
// => '{"key": "value"}'Analyzes imports/exports in source files to build a graph of internal dependencies.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Absolute path to project root |
§options? | BuildGraphOptions | Configuration for graph building |
Returns
DependencyGraphExample
Building a dependency graph
import { buildDependencyGraph } from '@hyperfrontend/project-scope'
const graph = buildDependencyGraph('./my-lib')
console.log('Root files:', graph.roots) // Files not imported by anything
console.log('Leaf files:', graph.leaves) // Files that don't import anything
console.log('Total nodes:', graph.nodes.size)
// Examine a specific node's dependencies
const node = graph.nodes.get('src/utils/helper.ts')
console.log('Depends on:', node?.dependencies)
console.log('Used by:', node?.dependents)buildSimpleProjectGraph( workspacePath: string, projects?: Map< string, NxProjectConfig>): NxProjectGraph
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace root path |
§projects? | Map< | Existing configuration map to skip auto-discovery |
Returns
NxProjectGraphExample
Building a simple project graph
import { buildSimpleProjectGraph } from '@hyperfrontend/project-scope'
const graph = buildSimpleProjectGraph('/workspace')
console.log('Projects:', Object.keys(graph.nodes))
console.log('Dependencies:', graph.dependencies['my-app'])Useful for testing or when a global state reset is needed. This clears all caches created via
createCache().Example
Clearing caches in tests
// In tests
afterEach(() => {
clearAllCaches()
})Useful for testing or when the project files have changed.
Example
Clearing the config detection cache
import { clearConfigDetectionCache } from '@hyperfrontend/project-scope'
// Reset cache after modifying config files
clearConfigDetectionCache()Useful for testing or when the project files have changed.
Example
Clearing the entry point cache
import { clearEntryPointCache } from '@hyperfrontend/project-scope'
// Reset cache before re-analyzing after file changes
clearEntryPointCache()Useful for testing or when the project files have changed.
Example
Clearing the framework cache
import { clearFrameworkIdentificationCache } from '@hyperfrontend/project-scope'
// Reset cache before re-identifying frameworks
clearFrameworkIdentificationCache()Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | Virtual file system tree with pending modifications |
§options? | CommitOptions | Configuration for dry-run and verbosity |
Returns
CommitResultExample
Committing changes to disk
import { createTree, commitChanges } from '@hyperfrontend/project-scope'
const tree = createTree('./my-project')
tree.write('src/new-file.ts', 'export const hello = "world"')
// Preview changes without writing
const preview = commitChanges(tree, { dryRun: true })
console.log('Would create:', preview.created, 'files')
// Actually commit changes
const result = commitChanges(tree)
console.log('Created:', result.created, 'Updated:', result.updated)Parameters
| Name | Type | Description |
|---|---|---|
§options | ConfigCommandOptions | Configuration command options |
Returns
CommandResultExamples
Detect all configs in a project
const result = configCommand({ path: './my-project' })
if (result.exitCode === 0) {
console.log(result.output)
// => "TypeScript: tsconfig.json\nLinting: eslint.config.js\n..."
}Filter by type with contents
const result = configCommand({
path: './my-project',
type: 'tsconfig',
showContents: true,
format: 'json',
})
// => { exitCode: 0, output: '[{"type":"tsconfig","path":"tsconfig.json",...}]' }The cache provides a simple key-value store with:
- Optional TTL (time-to-live) for automatic expiration
- Optional maxSize for limiting cache size with FIFO eviction
- Lazy expiration (entries are checked on access)
Parameters
| Name | Type | Description |
|---|---|---|
§options? | CacheOptions | Cache configuration options |
Returns
Cache< K, V>Example
Creating caches with different options
// Basic cache
const cache = createCache<string, number>()
cache.set('answer', 42)
cache.get('answer') // 42
// Cache with TTL (expires after 60 seconds)
const ttlCache = createCache<string, object>({ ttl: 60000 })
// Cache with max size (evicts oldest when full)
const lruCache = createCache<string, object>({ maxSize: 100 })
// Combined options
const configCache = createCache<string, object>({
ttl: 30000,
maxSize: 50
})createConfigError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a configuration error
throw createConfigError(
'Invalid port number',
'CONFIG_INVALID_PORT',
{ configFile: './app.config.json', value: -1 }
)Parameters
Example
Creating directories
// Create nested directories
createDirectory('./output/reports/2024')
// Create single directory without parents
createDirectory('./logs', { recursive: false })createFileSystemError( message: string, code: FileSystemErrorCode, context: FileSystemErrorContext): Error
Parameters
| Name | Type | Description |
|---|---|---|
§message | string | The error message describing what went wrong |
§code | FileSystemErrorCode | The category code for this type of filesystem failure |
§context | FileSystemErrorContext | Additional context including path, operation, and cause |
Returns
ErrorExample
Creating a file system error
throw createFileSystemError(
'Cannot read file',
'FS_READ_ERROR',
{ path: './missing.txt', operation: 'read' }
)createFsError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a filesystem error
throw createFsError(
'Configuration file not found',
'ENOENT',
{ path: './missing.json', operation: 'read' }
)Supports transactional modifications - all changes are buffered in memory and can be committed atomically or rolled back.
Parameters
| Name | Type | Description |
|---|---|---|
§root | string | Absolute path to the workspace root directory |
§options? | CreateTreeOptions | Configuration for verbose logging |
Returns
TreeExample
Creating and using a file system tree
import { createFsTree, commitChanges } from '@hyperfrontend/project-scope'
const tree = createFsTree('/workspace')
tree.write('src/new-file.ts', 'export const value = 42')
tree.delete('old-file.ts')
commitChanges(tree) // Atomically apply all changes to diskcreateParseError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a parse error
throw createParseError(
'Invalid JSON syntax',
'JSON_PARSE_ERROR',
{ file: './config.json', line: 42, column: 15 }
)createStructuredError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a structured error with context
import { createStructuredError } from '@hyperfrontend/project-scope'
throw createStructuredError(
'Configuration file not found',
'CONFIG_NOT_FOUND',
{ path: './config.json', searched: ['./config.json', './settings.json'] }
)Parameters
| Name | Type | Description |
|---|---|---|
§root | string | Root directory path |
§options? | CreateTreeOptions | Tree creation options |
Returns
TreeExample
Creating a virtual tree
import { createTree } from '@hyperfrontend/project-scope'
const tree = createTree('./my-project')
// Read files from tree
const content = tree.read('src/index.ts', 'utf-8')
// Make changes (buffered in memory)
tree.write('src/new-file.ts', 'export const x = 1')
// List pending changes
console.log(tree.listChanges())Convenience alias for createTree.
Parameters
| Name | Type | Description |
|---|---|---|
§root | string | Root directory path |
§options? | CreateTreeOptions | Tree creation options |
Returns
TreeExample
Creating a tree from disk
import { createTreeFromDisk } from '@hyperfrontend/project-scope'
const tree = createTreeFromDisk('/path/to/project', { verbose: true })
const files = tree.children('/src')createValidationError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a validation error
throw createValidationError(
'Email format is invalid',
'INVALID_EMAIL',
{ field: 'email', value: 'not-an-email' }
)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Cypress testing framework
import { cypressDetector } from '@hyperfrontend/project-scope'
const result = cypressDetector('./my-project')
if (result) {
console.log(`Cypress ${result.version} detected (${result.confidence}% confidence)`)
// => "Cypress 13.6.0 detected (95% confidence)"
}Parameters
| Name | Type | Description |
|---|---|---|
§options | DepsCommandOptions | Parsed command options |
Returns
CommandResultExamples
List all dependencies
const result = depsCommand({ path: './my-project' })
if (result.exitCode === 0) {
console.log(result.output)
// => "Dependencies\n============\nProduction (3):\n react ^18.2.0\n..."
}Filter to dev dependencies as JSON
const result = depsCommand({
path: './my-project',
type: 'development',
format: 'json',
})
// => { exitCode: 0, output: '{"devDependencies":{"typescript":"^5.0.0",...}}' }detectBackendFrameworks( projectPath: string, packageJson?: PackageJson): BackendDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetection[ ]Example
Detecting multiple backend frameworks
const pkg = {
dependencies: { '@nestjs/core': '^10.0.0', '@nestjs/common': '^10.0.0' },
devDependencies: { express: '^4.18.0' },
}
const results = detectBackendFrameworks('/path/to/project', pkg)
// => [
// { id: 'nestjs', name: 'NestJS', confidence: 85, ... },
// { id: 'express', name: 'Express', confidence: 80, ... },
// ]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetection[ ]Example
Detecting multiple build tools
const tools = detectBuildTools('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'@babel/core': '^7.23.0'
}
})
// => [
// { id: 'vite', name: 'Vite', version: '5.0.0', confidence: 70, ... },
// { id: 'babel', name: 'Babel', version: '7.23.0', confidence: 50, ... }
// ]Returns
booleanExample
Detecting case sensitivity
if (detectCaseSensitivity()) {
// Linux: 'File.ts' and 'file.ts' are different files
} else {
// Windows/macOS: treat as same file
}detectConfigs( rootPath: string, types?: ConfigType[ ], options?: DetectConfigOptions): DetectedConfig[ ]
Results are cached for 30 seconds per project path and options to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§rootPath | string | Project root directory |
§types? | ConfigType[ | Optional array of config types to check (defaults to all) |
§options? | DetectConfigOptions | Detection options |
Returns
DetectedConfig[ ]Example
Detecting configuration files
import { detectConfigs } from '@hyperfrontend/project-scope'
// Detect all config files
const configs = detectConfigs('./my-project')
for (const config of configs) {
console.log(`${config.type}: ${config.path}`)
}
// Output:
// typescript: tsconfig.json
// eslint: eslint.config.js
// jest: jest.config.ts
// Detect specific config types only
const tsConfigs = detectConfigs('./my-project', ['typescript', 'eslint'])Returns
BufferEncodingExample
Detecting encoding from buffer
const buffer = readFileSync('./data.txt')
const encoding = detectEncoding(buffer)
const content = buffer.toString(encoding)Returns
EncodingInfoExample
Detecting encoding and BOM info
const buffer = readFileSync('./document.txt')
const info = detectEncodingInfo(buffer)
if (info.type === 'text') {
console.log(`Encoding: ${info.encoding}, BOM: ${info.hasBom}`)
}detectFrontendFrameworks( projectPath: string, packageJson?: PackageJson): FrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetection[ ]Example
Detecting multiple frontend frameworks
const frameworks = detectFrontendFrameworks('/path/to/nextjs-app', {
dependencies: { 'react': '^18.0.0', 'next': '^14.0.0' }
})
// => [
// { id: 'nextjs', name: 'Next.js', category: 'meta-framework', confidence: 70, ... },
// { id: 'react', name: 'React', category: 'frontend', confidence: 60, ... }
// ]detectLegacyFrameworks( projectPath: string, packageJson?: PackageJson): LegacyFrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetection[ ]Example
Detecting legacy frameworks
const results = detectLegacyFrameworks('/path/to/project', {
dependencies: { jquery: '^3.6.0', backbone: '^1.4.0' },
})
// => [{ id: 'jquery', confidence: 80 }, { id: 'backbone', confidence: 70 }]Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to analyze |
Returns
DetectedLineEndingExample
Detecting line ending style
const ending = detectLineEnding('line1\nline2\n')
// => 'lf'
const mixed = detectLineEnding('line1\r\nline2\nline3')
// => 'mixed'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetection[ ]Example
Detecting multiple linting tools
const results = detectLintingTools('/path/to/project', {
devDependencies: { eslint: '^8.0.0', prettier: '^3.0.0' },
})
// => [{ id: 'eslint', confidence: 50 }, { id: 'prettier', confidence: 50 }]Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetection[ ]Example
Detecting monorepo tools
const detections = detectMonorepoTools('/path/to/project')
// => [
// { id: 'nx', name: 'NX', confidence: 90, configPath: 'nx.json', detectedFrom: [...] },
// { id: 'npm-workspaces', name: 'npm Workspaces', confidence: 80, ... }
// ]Returns
PlatformInfoExample
Detecting current platform
const platform = detectPlatform()
if (platform.isWindows) {
// Windows-specific handling
}detectProjectType( projectPath: string, options?: DetectProjectTypeOptions): ProjectTypeDetection
Uses multiple heuristics including:
- Package name patterns
- Exports/main/module fields
- Binary (bin) field
- Entry point patterns
- Testing framework presence
- Directory structure
- Framework detection
- NX project type field
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | DetectProjectTypeOptions | Detection options |
Returns
ProjectTypeDetectionExample
Detecting project type
import { detectProjectType } from '@hyperfrontend/project-scope'
const result = detectProjectType('./my-lib')
console.log(result.type) // 'library' | 'application' | 'e2e' | 'tool' | 'plugin'
console.log(result.confidence) // 85
console.log(result.evidence) // [{ factor: 'exports', confidence: 20, ... }]detectTestingFrameworks( projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetection[ ]Example
Detecting multiple testing frameworks
import { detectTestingFrameworks } from '@hyperfrontend/project-scope'
const frameworks = detectTestingFrameworks('./my-project')
// => [
// { id: 'jest', name: 'Jest', type: 'unit', confidence: 95, ... },
// { id: 'cypress', name: 'Cypress', type: 'e2e', confidence: 85, ... }
// ]
// Results are sorted by confidence (highest first)
const primary = frameworks[0]?.name ?? 'None'
console.log(`Primary testing framework: ${primary}`)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetection[ ]Example
Detecting all type systems
import { detectTypeSystems } from '@hyperfrontend/project-scope'
const typeSystems = detectTypeSystems('./my-project')
// => [
// { id: 'typescript', name: 'TypeScript', version: '5.3.0', strictMode: true, confidence: 95, ... },
// { id: 'jsdoc', name: 'JSDoc', confidence: 40, ... }
// ]
const primary = typeSystems[0]?.name ?? 'None'
console.log(`Primary type system: ${primary}`)discoverEntryPoints( projectPath: string, options?: DiscoverEntryPointsOptions): EntryPointInfo[ ]
Analyzes package.json fields (main, module, bin, exports), convention-based patterns, and framework-specific entries.
Results are cached for 60 seconds per project path and options to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | DiscoverEntryPointsOptions | Discovery options |
Returns
EntryPointInfo[ ]Example
Discovering project entry points
import { discoverEntryPoints } from '@hyperfrontend/project-scope'
const entryPoints = discoverEntryPoints('./my-app')
for (const entry of entryPoints) {
console.log(`${entry.path} (${entry.type}) - ${entry.confidence}% confidence`)
}
// Output:
// src/index.ts (main) - 100% confidence
// src/cli.ts (cli) - 85% confidenceParameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace root path |
Returns
Map< string, NxProjectConfig>Example
Discovering all NX projects
import { discoverNxProjects } from '@hyperfrontend/project-scope'
const projects = discoverNxProjects('/workspace')
for (const [name, config] of projects) {
console.log(`${name}: ${config.projectType} at ${config.root}`)
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting Ember.js framework
const result = emberDetector('/path/to/project', {
dependencies: { 'ember-source': '^4.0.0' },
devDependencies: { 'ember-cli': '^4.0.0' },
})
// => { id: 'ember', name: 'Ember.js', confidence: 90, version: '4.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Directory path to ensure exists |
Example
Ensuring directory exists
ensureDir('./output/reports')
// Directory now exists (created if missing)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to process |
Returns
stringExample
Ensuring trailing slash
ensureTrailingSlash('src/components')
// => 'src/components/'
ensureTrailingSlash('already/has/')
// => 'already/has/'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting esbuild bundler
const result = esbuildDetector('/path/to/project', {
name: 'my-lib',
devDependencies: { 'esbuild': '^0.19.0' },
scripts: { 'build': 'esbuild src/index.ts --bundle --outfile=dist/index.js' }
})
// => {
// id: 'esbuild',
// name: 'esbuild',
// version: '0.19.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.esbuild' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting ESLint linter
const result = eslintDetector('/path/to/project', {
devDependencies: { eslint: '^8.50.0', '@typescript-eslint/parser': '^6.0.0' },
scripts: { lint: 'eslint src/' },
})
// => { id: 'eslint', name: 'ESLint', confidence: 65, version: '8.50.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path exists
if (exists('./config.json')) {
const config = readJsonFile('./config.json')
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Express framework
const pkg = {
dependencies: { express: '^4.18.2', cors: '^2.8.5' },
devDependencies: { '@types/express': '^4.17.17' },
}
const result = expressDetector('/path/to/project', pkg)
// => {
// id: 'express',
// name: 'Express',
// version: '4.18.2',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.express' },
// { type: 'package.json', field: 'dependencies.@types/express' },
// { type: 'package.json', field: 'dependencies (express middleware)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Fastify framework
const pkg = {
dependencies: { fastify: '^4.24.0', '@fastify/cors': '^8.4.0' },
}
const result = fastifyDetector('/path/to/project', pkg)
// => {
// id: 'fastify',
// name: 'Fastify',
// version: '4.24.0',
// confidence: 95,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.fastify' },
// { type: 'package.json', field: 'dependencies (fastify plugins)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§graph | DependencyGraph | Dependency graph |
Returns
CircularDependency[ ]Example
Finding circular dependencies
import { buildDependencyGraph, findCircularDependencies } from '@hyperfrontend/project-scope'
const graph = buildDependencyGraph('/workspace')
const cycles = findCircularDependencies(graph)
cycles.forEach(c => console.log(`Cycle: ${c.cycle.join(' -> ')}`))Parameters
| Name | Type | Description |
|---|---|---|
§rootPath | string | Project root directory |
§type | ConfigType | Config type to find |
Returns
stringExample
Finding a specific config file
import { findConfigFile } from '@hyperfrontend/project-scope'
const tsConfig = findConfigFile('/project', 'typescript')
// => '/project/tsconfig.json'
const eslint = findConfigFile('/project', 'eslint')
// => '/project/.eslintrc.js' or null if not foundfindDirectories( startPath: string, patterns: string | string[ ], options?: FindOptions): string[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin the search |
§patterns | string | string[ | Glob patterns to filter directories (supports wildcards) |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding directories by pattern
import { findDirectories } from '@hyperfrontend/project-scope'
const componentDirs = findDirectories('./src', 'components')
// => ['features/auth/components', 'features/dashboard/components']Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin the search |
§patterns | string | string[ | Glob patterns (e.g., '.ts', '/.json') to filter files |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding files by pattern
import { findFiles } from '@hyperfrontend/project-scope'
// Find all TypeScript files
const tsFiles = findFiles('./src', '\*\*/*.ts')
// Find multiple file types
const configFiles = findFiles('./', ['\*.json', '\*.yaml', '\*.yml'])
// Limit results and get absolute paths
const first10 = findFiles('./src', '\*\*/*.ts', {
maxResults: 10,
absolutePaths: true
})Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | In-memory virtual file system representation |
§patterns | string | string[ | Glob patterns (e.g., '.ts', '/.json') to filter files |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding files in a virtual tree
import { createTree, findFilesInTree } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
const tsFiles = findFilesInTree(tree, '**/*.ts', { maxDepth: 3 })
// => ['src/index.ts', 'src/utils/helpers.ts']Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding Git repository root
import { findGitRoot } from '@hyperfrontend/project-scope'
const gitRoot = findGitRoot('./src/deep/nested/file.ts')
// => '/path/to/repository'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding nearest package.json
import { findNearestPackageJson } from '@hyperfrontend/project-scope'
const pkgDir = findNearestPackageJson('./src/deep/nested/file.ts')
// => '/path/to/project'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path to search from |
Returns
stringExample
Finding NX workspace root
import { findNxWorkspaceRoot } from '@hyperfrontend/project-scope'
const root = findNxWorkspaceRoot('./libs/my-lib/src')
if (root) {
console.log('Workspace root:', root) // e.g., '/home/user/my-monorepo'
}Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding project root
import { findProjectRoot } from '@hyperfrontend/project-scope'
// Find project root from current directory
const root = findProjectRoot(process.cwd())
if (root) {
console.log('Project root:', root)
}
// Find root from a deeply nested file
const root2 = findProjectRoot('./libs/my-lib/src/utils/helper.ts')Parameters
Returns
stringExample
Finding root by marker files
import { findRootDirectory } from '@hyperfrontend/project-scope'
// Find monorepo root by looking for nx.json or lerna.json
const root = findRootDirectory('./libs/my-lib', ['nx.json', 'lerna.json'])
// => '/path/to/monorepo'Parameters
Returns
stringExample
Finding directory with specific config
// Find directory with a specific config
const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
existsSync(join(dir, '.eslintrc.js'))
)Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding workspace root
import { findWorkspaceRoot } from '@hyperfrontend/project-scope'
const root = findWorkspaceRoot('./libs/my-lib')
if (root) {
console.log('Monorepo root:', root) // e.g., '/home/user/my-monorepo'
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting Flow type system
import { flowDetector } from '@hyperfrontend/project-scope'
const result = flowDetector('./my-project')
if (result) {
console.log(`Flow ${result.version} with config: ${result.configPath}`)
// => "Flow 0.232.0 with config: .flowconfig"
}Returns
stringExample
Formatting a unified diff
const formatted = formatUnifiedDiff(diff)
console.log(formatted)
// --- a/src/app.ts
// +++ b/src/app.ts
// @@ -1,3 +1,3 @@
// const x = 1;
// -const y = 2;
// +const y = 3;
// const z = 4;Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Gatsby framework
const result = gatsbyDetector('/path/to/gatsby-blog', {
dependencies: {
'gatsby': '^5.0.0',
'gatsby-plugin-image': '^3.0.0',
'gatsby-source-filesystem': '^5.0.0'
}
})
// => {
// id: 'gatsby',
// name: 'Gatsby',
// category: 'meta-framework',
// version: '5.0.0',
// confidence: 75,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.gatsby' },
// { type: 'package.json', field: 'dependencies (gatsby plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | Tree to generate diffs for |
§options | DiffOptions | Diff options(default: {}) |
Returns
FileDiff[ ]Example
Generating diffs for all changes
const tree = createTree('/workspace')
tree.write('new.txt', 'hello')
tree.delete('old.txt')
const diffs = generateAllDiffs(tree)
for (const diff of diffs) {
console.log(formatUnifiedDiff(diff))
}Parameters
| Name | Type | Description |
|---|---|---|
§change | FileChange | File change to diff |
§options | DiffOptions | Configuration for diff generation including context lines(default: {}) |
Returns
FileDiffExample
Generating a diff for a file change
const change: FileChange = {
path: 'src/app.ts',
type: 'UPDATE',
originalContent: Buffer.from('const x = 1;\n'),
content: Buffer.from('const x = 2;\n'),
}
const diff = generateDiff(change)
// { path: 'src/app.ts', additions: 1, deletions: 1, lines: [...] }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting all merged dependencies
import { getAllDependencies } from '@hyperfrontend/project-scope'
const allDeps = getAllDependencies(packageJson)
if ('typescript' in allDeps) {
console.log('TypeScript version:', allDeps['typescript'])
}Parameters
Returns
stringExample
Getting basename
getBasename('src/components/Button.tsx')
// => 'Button.tsx'
getBasename('src/components/Button.tsx', '.tsx')
// => 'Button'Primarily used for testing.
Returns
numberExample
Getting the number of active caches
const count = getCacheCount()
// => 3 (number of active caches)Parameters
| Name | Type | Description |
|---|---|---|
§types | ConfigType[ | Array of config types to get patterns for |
Returns
string[ ]Example
Retrieving config patterns by type
import { getConfigPatternsByType } from '@hyperfrontend/project-scope'
const patterns = getConfigPatternsByType(['typescript', 'eslint'])
// => ['tsconfig.json', 'tsconfig.*.json', '.eslintrc', '.eslintrc.js', ...]Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
AllDependenciesExample
Extracting all dependencies
import { getDependencies } from '@hyperfrontend/project-scope'
const deps = getDependencies(packageJson)
console.log('Runtime:', Object.keys(deps.dependencies))
console.log('Dev:', Object.keys(deps.devDependencies))Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json content |
§name | string | Name of the dependency to look up |
Returns
stringExample
Getting dependency version
import { getDependencyVersion } from '@hyperfrontend/project-scope'
const version = getDependencyVersion(packageJson, 'react')
// => '^18.2.0' or nullParameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting development dependencies
import { getDevDependencies } from '@hyperfrontend/project-scope'
const devDeps = getDevDependencies(packageJson)
// => { 'jest': '^29.0.0', 'typescript': '^5.0.0' }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract directory from |
Returns
stringExample
Getting directory name
getDirname('src/components/Button.tsx')
// => 'src/components'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract extension from |
Returns
stringExample
Getting file extension
getExtension('src/utils/helpers.ts')
// => '.ts'
getExtension('package.json')
// => '.json'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract name from |
Returns
stringExample
Getting filename without extension
getFileNameWithoutExtension('src/utils/helpers.ts')
// => 'helpers'Parameters
Returns
FileStatsExample
Getting file statistics
const stats = getFileStat('./package.json')
if (stats) {
console.log(`Size: ${stats.size} bytes`)
console.log(`Modified: ${stats.modified}`)
}Returns
"
" | "
"Example
Getting platform line ending
const eol = getLineEnding()
const lines = ['line1', 'line2', 'line3']
const content = lines.join(eol)Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace root path |
Returns
NxWorkspaceInfoExample
Getting NX workspace information
import { getNxWorkspaceInfo } from '@hyperfrontend/project-scope'
const info = getNxWorkspaceInfo('/path/to/monorepo')
if (info) {
console.log('NX version:', info.version)
console.log('Apps dir:', info.workspaceLayout.appsDir)
}Returns
"\" | "/"Example
Getting platform path separator
const sep = getPathSeparator()
const fullPath = ['src', 'utils', 'helpers.ts'].join(sep)Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting peer dependencies
import { getPeerDependencies } from '@hyperfrontend/project-scope'
const peerDeps = getPeerDependencies(packageJson)
// => { 'react': '^18.0.0', 'react-dom': '^18.0.0' }Returns
PlatformInfoExample
Getting platform information
const info = getPlatformInfo()
console.log(info.os) // => 'linux'
console.log(info.pathSeparator) // => '/'
console.log(info.lineEnding) // => '\n'Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting production dependencies
import { getProductionDependencies } from '@hyperfrontend/project-scope'
const prodDeps = getProductionDependencies(packageJson)
// => { 'express': '^4.18.0', 'lodash': '^4.17.21' }Parameters
Returns
NxProjectConfigExample
Getting project configuration
import { getProjectConfig } from '@hyperfrontend/project-scope'
const config = getProjectConfig('./libs/my-lib', '/workspace')
// => { name: 'my-lib', root: 'libs/my-lib', projectType: 'library' }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory |
Returns
ProjectDependenciesExample
Getting project dependencies
import { getProjectDependencies } from '@hyperfrontend/project-scope'
const deps = getProjectDependencies('/path/to/project')
console.log('Runtime:', deps.runtime) // ['express', 'lodash']
console.log('Dev:', deps.development) // ['jest', 'typescript']
console.log('Total:', deps.total) // 15Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
string[ ]Example
Getting workspace patterns
import { getWorkspaces } from '@hyperfrontend/project-scope'
const patterns = getWorkspaces(packageJson)
// => ['packages/*', 'apps/*']Returns
booleanExample
Checking if buffer has BOM
const buffer = readFileSync('./file.txt')
if (hasBom(buffer)) {
// Strip BOM before processing
}hasDependency( packageJson: PackageJson, name: string, depTypes?: ( "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies")[ ]): boolean
Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json content |
§name | string | Name of the dependency to check |
§depTypes? | ( | Optional array of dependency types to check (defaults to all) |
Returns
booleanExample
Checking for a dependency
import { hasDependency } from '@hyperfrontend/project-scope'
// Check any dependency type
hasDependency(packageJson, 'lodash')
// Check only production dependencies
hasDependency(packageJson, 'lodash', ['dependencies'])Parameters
Returns
booleanExample
Checking installed packages
import { hasInstalledPackage } from '@hyperfrontend/project-scope'
if (hasInstalledPackage('/project', 'typescript')) {
console.log('TypeScript is installed')
}Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
booleanExample
Checking for workspaces
import { hasWorkspaces } from '@hyperfrontend/project-scope'
if (hasWorkspaces(packageJson)) {
console.log('This is a monorepo')
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Hono framework
const pkg = {
dependencies: { hono: '^3.11.0', '@hono/node-server': '^1.3.0' },
}
const result = honoDetector('/path/to/project', pkg)
// => {
// id: 'hono',
// name: 'Hono',
// version: '3.11.0',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.hono' },
// { type: 'package.json', field: 'dependencies (@hono adapters)' },
// ],
// }identifyFrameworks( projectPath: string, options?: IdentifyFrameworksOptions): FrameworkIdentification
Runs all technology detectors and aggregates results into a comprehensive framework identification with confidence scoring.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | IdentifyFrameworksOptions | Identification options |
Returns
FrameworkIdentificationExample
Identifying all frameworks in project
import { identifyFrameworks } from '@hyperfrontend/project-scope'
const result = identifyFrameworks('./my-react-app')
console.log(result.summary) // 'React + Next.js with Jest'
console.log(result.primary?.name) // 'React'
console.log(result.stack.frontend) // ['react', 'nextjs']
console.log(result.stack.testing) // ['jest']Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking absolute path
isAbsolute('/workspace/src/index.ts')
// => true
isAbsolute('./src/index.ts')
// => falseReturns
booleanExample
Checking case sensitivity
const caseSensitive = isCaseSensitiveFs()
// => true on Linux, false on Windows/macOSParameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Path to check |
Returns
booleanExample
Checking if path is a directory
if (isDirectory('./src')) {
// Path exists and is a directory
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path is a file
if (isFile('./package.json')) {
// Path exists and is a regular file
}Parameters
| Name | Type | Description |
|---|---|---|
§path | string | Directory path to check |
Returns
booleanExample
Checking for NX project
import { isNxProject } from '@hyperfrontend/project-scope'
if (isNxProject('./libs/my-lib')) {
console.log('This is an NX project')
}Parameters
| Name | Type | Description |
|---|---|---|
§path | string | Directory path to check |
Returns
booleanExample
Checking for NX workspace
import { isNxWorkspace } from '@hyperfrontend/project-scope'
if (isNxWorkspace('./my-project')) {
console.log('This is an NX monorepo')
}Parameters
| Name | Type | Description |
|---|---|---|
§linkPath | string | Path to check |
Returns
booleanExample
Checking if path is a symlink
if (isSymlink('./node_modules/.bin/tsc')) {
// Path is a symbolic link
}Returns
booleanExample
Checking if content is text
const buffer = readFileSync('./unknown-file')
if (isTextFile(buffer)) {
const content = buffer.toString('utf-8')
}Returns
booleanExample
Checking for Windows
if (isWindows()) {
// Use Windows-specific paths or commands
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Jest testing framework
import { jestDetector } from '@hyperfrontend/project-scope'
const result = jestDetector('./my-project')
if (result) {
console.log(`Jest ${result.version} detected`)
console.log('Sources:', result.detectedFrom.map(s => s.type))
// => "Sources: ['package.json', 'config-file']"
}Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[ | Path segments to join |
Returns
stringExample
Joining path segments
const fullPath = join('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx' (or 'src\\components\\Button.tsx' on Windows)Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[ | Path segments to join |
Returns
stringExample
Joining path segments
joinPath('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[ | Path segments to join |
Returns
stringExample
Joining paths with forward slashes
const configPath = joinPosix('config', 'settings', 'app.json')
// => 'config/settings/app.json'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting jQuery library
const result = jqueryDetector('/path/to/project', {
dependencies: { jquery: '^3.6.0', 'jquery-ui': '^1.13.0' },
})
// => { id: 'jquery', name: 'jQuery', confidence: 90, version: '3.6.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting JSDoc type annotations
import { jsdocDetector } from '@hyperfrontend/project-scope'
const result = jsdocDetector('./my-project')
if (result) {
console.log('JSDoc types detected')
console.log('Sources:', result.detectedFrom.map(s => s.path ?? s.field))
// => "Sources: ['jsconfig.json', 'src/utils.js (JSDoc annotations)']"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Koa framework
const pkg = {
dependencies: { koa: '^2.14.2', 'koa-router': '^12.0.0' },
devDependencies: { '@types/koa': '^2.13.9' },
}
const result = koaDetector('/path/to/project', pkg)
// => {
// id: 'koa',
// name: 'Koa',
// version: '2.14.2',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.koa' },
// { type: 'package.json', field: 'dependencies.@types/koa' },
// { type: 'package.json', field: 'dependencies (koa middleware)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Lerna monorepo
// Project with lerna.json config file
const result = lernaDetector('/path/to/lerna-project')
// => {
// id: 'lerna',
// name: 'Lerna',
// confidence: 80,
// configPath: 'lerna.json',
// detectedFrom: [{ type: 'config-file', path: 'lerna.json' }]
// }Parameters
Returns
stringExample
Finding project root by marker files
// Find project root by looking for common marker files
const projectRoot = locateByMarkers('./src/components', [
'package.json',
'nx.json',
'tsconfig.base.json'
])
// => '/workspace/my-project'Returns
booleanExample
Checking path against multiple patterns
const ignorePatterns = ['*.log', 'node_modules/**', '*.tmp']
const shouldIgnore = matchesAnyPattern('debug.log', ignorePatterns)
// => trueReturns
booleanExample
Exact path matching
matchesExact('package.json', 'package.json')
// => true
matchesExact('src/package.json', 'package.json')
// => falseSupported patterns:
- matches any characters except /
- * matches any characters including /
- ? matches exactly one character except /
- {a,b,c} matches any of the alternatives
Parameters
Returns
booleanExample
Matching paths against glob patterns
import { matchGlobPattern } from '@hyperfrontend/project-scope'
matchGlobPattern('src/utils/helper.ts', '\*\*/*.ts') // true
matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
matchGlobPattern('config.json', '\*.{json,yaml}') // true
matchGlobPattern('src/index.ts', 'src/\*.ts') // trueThe memoized function caches results based on the first argument (key). If additional arguments are needed, use the options.keyFn parameter.
Parameters
| Name | Type | Description |
|---|---|---|
§fn | ( | Function to memoize |
§options? | CacheOptions | Cache options for the underlying cache |
Returns
MemoizedFunction< K, V>Example
Memoizing an expensive function
// Memoize a detection function
const detectTechStackMemo = memoize(
(path: string) => expensiveDetection(path),
{ ttl: 60000 }
)
const result1 = detectTechStackMemo('/path/to/project')
const result2 = detectTechStackMemo('/path/to/project') // Returns cached
// Clear the cache
detectTechStackMemo.cache.clear()Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Mocha testing framework
import { mochaDetector } from '@hyperfrontend/project-scope'
const result = mochaDetector('./my-project')
if (result) {
console.log(`Mocha ${result.version} detected (${result.confidence}%)`)
// => "Mocha 10.2.0 detected (95%)"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting NestJS framework
// Project with nest-cli.json and NestJS packages
const pkg = {
dependencies: {
'@nestjs/core': '^10.2.0',
'@nestjs/common': '^10.2.0',
'@nestjs/platform-express': '^10.2.0',
},
}
const result = nestDetector('/path/to/nest-project', pkg)
// => {
// id: 'nestjs',
// name: 'NestJS',
// version: '10.2.0',
// configPath: 'nest-cli.json', // if present
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@nestjs/core' },
// { type: 'package.json', field: 'dependencies.@nestjs/common' },
// { type: 'config-file', path: 'nest-cli.json' },
// { type: 'package.json', field: 'dependencies (@nestjs packages)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Next.js framework
const result = nextjsDetector('/path/to/nextjs-app', {
dependencies: { 'next': '^14.0.0', 'react': '^18.0.0' }
})
// => {
// id: 'nextjs',
// name: 'Next.js',
// category: 'meta-framework',
// version: '14.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.next' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to normalize |
§style | LineEndingStyle | Target line ending style ('lf', 'crlf', or 'auto' for platform default)(default: 'lf') |
Returns
stringExample
Normalizing line endings
// Normalize to Unix line endings
const normalized = normalizeLineEndings('line1\r\nline2\r\n', 'lf')
// => 'line1\nline2\n'
// Use platform default
const platformNormalized = normalizeLineEndings(content, 'auto')Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to normalize |
Returns
stringExample
Normalizing path separators
const path = normalizePath('src\\components\\Button.tsx')
// => 'src/components/Button.tsx'. and .. segments for cross-platform configuration.Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to forward slashes
const path = normalizeToForwardSlashes('./src/../lib/utils')
// => 'lib/utils'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to native separators
const path = normalizeToNative('src/components/Button.tsx')
// => 'src\\components\\Button.tsx' on Windows
// => 'src/components/Button.tsx' on UnixParameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting npm workspaces
// Project with workspaces in package.json and package-lock.json
const result = npmWorkspacesDetector('/path/to/npm-project')
// => {
// id: 'npm-workspaces',
// name: 'npm Workspaces',
// confidence: 90,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'package-lock.json' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Nuxt framework
const result = nuxtDetector('/path/to/nuxt-app', {
dependencies: { 'nuxt': '^3.0.0', 'vue': '^3.0.0' }
})
// => {
// id: 'nuxt',
// name: 'Nuxt',
// category: 'meta-framework',
// version: '3.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.nuxt' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting NX workspace
// Project with nx.json and apps/libs directories
const result = nxDetector('/path/to/nx-workspace')
// => {
// id: 'nx',
// name: 'NX',
// confidence: 100,
// configPath: 'nx.json',
// version: '17.0.0',
// workspaceLayout: { appsDir: 'apps', libsDir: 'libs' },
// detectedFrom: [
// { type: 'config-file', path: 'nx.json' },
// { type: 'package.json', field: 'dependencies.nx' },
// { type: 'directory', path: 'apps/ or libs/' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to calculate offset for |
Returns
stringExample
Calculating offset from root
offsetFromRoot('libs/utils/src')
// => '../../../'
offsetFromRoot('apps')
// => '../'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Parcel bundler
const result = parcelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'parcel': '^2.10.0' },
scripts: { 'dev': 'parcel src/index.html', 'build': 'parcel build src/index.html' }
})
// => {
// id: 'parcel',
// name: 'Parcel',
// version: '2.10.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.parcel' },
// { type: 'package.json', field: 'scripts.dev' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to config file |
§type? | ConfigType | Optional config type (auto-detected if not provided) |
Returns
ParsedConfigExample
Parsing a configuration file
import { parseConfig } from '@hyperfrontend/project-scope'
const tsConfig = parseConfig('/project/tsconfig.json')
const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint')parseJsonConfig( filePath: string, content: string, type?: ConfigType, format: "json" | "jsonc"): ParsedConfig
Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to the JSON configuration file |
§content | string | Raw file content to parse |
§type? | ConfigType | Category of configuration (e.g., typescript, eslint) |
§format | "json" | "jsonc" | Whether to strip comments (jsonc) or parse strictly (json)(default: 'json') |
Returns
ParsedConfigExample
Parsing JSON configuration
import { parseJsonConfig } from '@hyperfrontend/project-scope'
const config = parseJsonConfig(
'tsconfig.json',
'{ "extends": "./base.json", "compilerOptions": {} }',
'typescript'
)
// => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to parse |
Returns
ParsedPathExample
Parsing path components
const parsed = parsePath('/workspace/src/index.ts')
// => { root: '/', dir: '/workspace/src', base: 'index.ts', ext: '.ts', name: 'index' }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to the YAML configuration file |
§content | string | Raw file content to parse |
§type? | ConfigType | Category of configuration (e.g., github-actions, docker-compose) |
Returns
ParsedConfigExample
Parsing YAML configuration
import { parseYamlConfig } from '@hyperfrontend/project-scope'
const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions')
// => { type: 'github-actions', path: '...', format: 'yaml', data: {...} }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to split |
Returns
string[ ]Example
Splitting path into segments
pathSegments('src/components/Button.tsx')
// => ['src', 'components', 'Button.tsx']Returns
booleanExample
Comparing paths
// On case-insensitive filesystem (Windows/macOS)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => true
// On case-sensitive filesystem (Linux)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => falseplaywrightDetector( projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Playwright testing framework
import { playwrightDetector } from '@hyperfrontend/project-scope'
const result = playwrightDetector('./my-project')
if (result) {
console.log(`Playwright ${result.version} (${result.type} tests)`)
// => "Playwright 1.42.0 (e2e tests)"
}Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
Returns
MonorepoDetectionExample
Detecting pnpm workspaces
// Project with pnpm-workspace.yaml
const result = pnpmWorkspacesDetector('/path/to/pnpm-project')
// => {
// id: 'pnpm-workspaces',
// name: 'pnpm Workspaces',
// confidence: 100,
// configPath: 'pnpm-workspace.yaml',
// detectedFrom: [
// { type: 'config-file', path: 'pnpm-workspace.yaml' },
// { type: 'lockfile', path: 'pnpm-lock.yaml' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Prettier formatter
const result = prettierDetector('/path/to/project', {
devDependencies: { prettier: '^3.0.0' },
scripts: { format: 'prettier --write .' },
})
// => { id: 'prettier', name: 'Prettier', confidence: 55, version: '3.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Qwik framework
const result = qwikDetector('/path/to/qwik-app', {
dependencies: {
'@builder.io/qwik': '^1.0.0',
'@builder.io/qwik-city': '^1.0.0'
}
})
// => {
// id: 'qwik',
// name: 'Qwik',
// category: 'frontend',
// version: '1.0.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@builder.io/qwik' },
// { type: 'package.json', field: 'dependencies.@builder.io/qwik-city' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting React library
const result = reactDetector('/path/to/react-app', {
dependencies: { 'react': '^18.0.0', 'react-dom': '^18.0.0' }
})
// => {
// id: 'react',
// name: 'React',
// category: 'frontend',
// version: '18.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.react' },
// { type: 'package.json', field: 'dependencies.react-dom' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Absolute or relative path to the directory |
Returns
DirectoryEntry[ ]Example
Listing directory contents
import { readDirectory } from '@hyperfrontend/project-scope'
const entries = readDirectory('./src')
for (const entry of entries) {
console.log(entry.name, entry.isFile ? 'file' : 'directory')
}Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Root directory path to start traversal |
§options? | RecursiveOptions | Configuration for depth limit, hidden files, and symlinks |
Returns
DirectoryEntry[ ]Example
Recursive directory listing with options
import { readDirectoryRecursive } from '@hyperfrontend/project-scope'
// List all files up to 3 levels deep
const entries = readDirectoryRecursive('./src', { maxDepth: 3 })
// Include hidden files
const allEntries = readDirectoryRecursive('./project', { includeHidden: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
Returns
BufferExample
Reading file as buffer
const buffer = readFileBuffer('./image.png')
console.log(buffer.length) // File size in bytesParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
§encoding | BufferEncoding | File encoding (default: utf-8)(default: 'utf-8') |
Returns
stringExample
Reading file contents
import { readFileContent } from '@hyperfrontend/project-scope'
const content = readFileContent('./package.json')
console.log(content) // JSON stringParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
§encoding | BufferEncoding | File encoding (default: utf-8)(default: 'utf-8') |
Returns
stringExample
Reading file if it exists
const content = readFileIfExists('./optional-config.json')
if (content) {
// File existed, use content
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
§options? | ReadJsonFileOptions< | Parse options |
Returns
TExample
Reading JSON file
import { readJsonFile } from '@hyperfrontend/project-scope'
// Read with type inference
interface Config { port: number }
const config = readJsonFile<Config>('./config.json')
// Read with default fallback
const settings = readJsonFile('./settings.json', { default: {} })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
Returns
TExample
Reading JSON file if it exists
interface UserSettings { theme: string }
const settings = readJsonFileIfExists<UserSettings>('./user-settings.json')
const theme = settings?.theme ?? 'default'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path or path to package.json |
Returns
PackageJsonExample
Reading package.json
import { readPackageJson } from '@hyperfrontend/project-scope'
const pkg = readPackageJson('/path/to/project')
console.log(pkg.name, pkg.version)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path or path to package.json |
Returns
PackageJsonExample
Reading package.json if it exists
import { readPackageJsonIfExists } from '@hyperfrontend/project-scope'
const pkg = readPackageJsonIfExists('/path/to/project')
if (pkg) {
console.log('Found:', pkg.name)
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
Returns
NxProjectConfigExample
Reading NX project.json
import { readProjectJson } from '@hyperfrontend/project-scope'
const config = readProjectJson('./libs/my-lib')
if (config) {
console.log('Project:', config.name, 'Type:', config.projectType)
}Returns
stringExample
Computing relative path
relativePath('/workspace/src/utils', '/workspace/lib/helpers')
// => '../../lib/helpers'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Remix framework
const result = remixDetector('/path/to/remix-app', {
dependencies: {
'@remix-run/react': '^2.0.0',
'@remix-run/node': '^2.0.0'
}
})
// => {
// id: 'remix',
// name: 'Remix',
// category: 'meta-framework',
// version: '2.0.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@remix-run/react' },
// { type: 'package.json', field: 'dependencies.@remix-run/*' }
// ]
// }Parameters
Example
Removing directories
// Remove directory and all contents
removeDirectory('./temp', { recursive: true })
// Safe removal (no error if missing)
removeDirectory('./cache', { recursive: true, force: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path that may have trailing slashes |
Returns
stringExample
Removing trailing slashes
removeTrailingSlash('src/components/')
// => 'src/components'
removeTrailingSlash('path\\to\\dir\\')
// => 'path\\to\\dir'Parameters
Returns
stringExample
Resolving from workspace root
const configPath = resolveFromWorkspace('/workspace', 'config', 'app.json')
// => '/workspace/config/app.json'Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[ | Path segments to resolve |
Returns
stringExample
Resolving to absolute path
const absPath = resolvePath('src', 'components', 'Button.tsx')
// => '/workspace/project/src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to resolve |
Returns
stringExample
Resolving symlinks
const realPath = resolveRealPath('./node_modules/.bin/tsc')
// => '/workspace/node_modules/typescript/bin/tsc'Example
Rolling back pending changes
import { createTree, rollbackChanges } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
tree.write('new-file.ts', 'content')
// Decide to abort - discard all pending changes
rollbackChanges(tree)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Rollup bundler
const result = rollupDetector('/path/to/project', {
name: 'my-lib',
devDependencies: {
'rollup': '^4.0.0',
'@rollup/plugin-node-resolve': '^15.0.0',
'@rollup/plugin-commonjs': '^25.0.0'
}
})
// => {
// id: 'rollup',
// name: 'Rollup',
// version: '4.0.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.rollup' },
// { type: 'package.json', field: 'dependencies (rollup plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§args | string[ | Command line arguments (typically process.argv.slice(2)) |
Returns
CommandResultExample
Running analysis via CLI
import { run } from '@hyperfrontend/project-scope'
// Analyze current directory
const result = run(['analyze'])
// Analyze specific project with JSON output
const result2 = run(['analyze', './my-project', '--format', 'json'])
// Show dependency tree
const result3 = run(['deps', '--type', 'production'])
process.exit(result.exitCode)Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Rush monorepo
// Project with rush.json config file
const result = rushDetector('/path/to/rush-project')
// => {
// id: 'rush',
// name: 'Rush',
// confidence: 90,
// configPath: 'rush.json',
// detectedFrom: [{ type: 'config-file', path: 'rush.json' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Solid.js framework
const result = solidDetector('/path/to/solid-app', {
dependencies: { 'solid-js': '^1.8.0', 'vite-plugin-solid': '^2.0.0' }
})
// => {
// id: 'solid',
// name: 'Solid',
// category: 'frontend',
// version: '1.8.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.solid-js' },
// { type: 'package.json', field: 'dependencies.vite-plugin-solid' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String that may have BOM |
Returns
stringExample
Stripping BOM from a string
const withBom = '\ufeffHello World'
const clean = stripBom(withBom)
// => 'Hello World'Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Stylelint linter
const result = stylelintDetector('/path/to/project', {
devDependencies: { stylelint: '^15.0.0', 'stylelint-config-standard': '^30.0.0' },
})
// => { id: 'stylelint', name: 'Stylelint', confidence: 65, version: '15.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Svelte framework
const result = svelteDetector('/path/to/svelte-app', {
devDependencies: { 'svelte': '^4.0.0' }
})
// => {
// id: 'svelte',
// name: 'Svelte',
// category: 'frontend',
// version: '4.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.svelte' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting SvelteKit framework
const result = sveltekitDetector('/path/to/sveltekit-app', {
devDependencies: { '@sveltejs/kit': '^2.0.0', 'svelte': '^4.0.0' }
})
// => {
// id: 'sveltekit',
// name: 'SvelteKit',
// category: 'meta-framework',
// version: '2.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.@sveltejs/kit' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting SWC compiler
const result = swcDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@swc/core': '^1.3.0', '@swc/cli': '^0.1.0' }
})
// => {
// id: 'swc',
// name: 'SWC',
// version: '1.3.0',
// confidence: 70,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@swc/core' },
// { type: 'package.json', field: 'dependencies.@swc/cli' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Buffer< | Buffer or string content |
§sourceEncoding | BufferEncoding | Source encoding (auto-detected if not provided)(default: 'utf-8') |
Returns
stringExample
Converting a buffer to UTF-8 string
const buffer = Buffer.from('Hello', 'utf-8')
const text = toUtf8(buffer)
// => 'Hello'Parameters
Returns
stringExample
Finding directory containing README
// Find first directory containing a README
const readmeDir = traverseUpward('./src/utils', (dir) =>
existsSync(join(dir, 'README.md'))
)
// => '/project' or nullParameters
| Name | Type | Description |
|---|---|---|
§options | TreeCommandOptions | Configuration for the tree operation |
Returns
CommandResultExamples
Basic tree of current directory
const result = treeCommand({ depth: 2 })
if (result.exitCode === 0) {
console.log(result.output)
// => "src/\n├── index.ts\n├── lib/\n│ └── utils.ts\n..."
}Directories only with metadata
const result = treeCommand({
path: './project',
dirsOnly: true,
showSize: true,
ignore: ['node_modules', '.git'],
format: 'json',
})
// => { exitCode: 0, output: '[{"name":"src","isDirectory":true,...}]' }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Turborepo monorepo
// Project with turbo.json and turbo dependency
const result = turborepoDetector('/path/to/turbo-project')
// => {
// id: 'turborepo',
// name: 'Turborepo',
// confidence: 95,
// configPath: 'turbo.json',
// version: '2.0.0',
// detectedFrom: [
// { type: 'config-file', path: 'turbo.json' },
// { type: 'package.json', field: 'dependencies.turbo' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting TypeScript
import { typescriptDetector } from '@hyperfrontend/project-scope'
const result = typescriptDetector('./my-project')
if (result) {
console.log(`TypeScript ${result.version}`)
console.log(`Strict mode: ${result.strictMode ?? 'unknown'}`)
// => "TypeScript 5.3.0"
// => "Strict mode: true"
}Useful for cleanup in tests or when a cache is no longer needed.
Returns
booleanExample
Unregistering a cache from the registry
const myCache = createCache<string, number>({ name: 'temp-cache' })
const wasRemoved = unregisterCache(myCache)
// => trueParameters
Returns
booleanExample
Checking for a specific framework
import { usesFramework } from '@hyperfrontend/project-scope'
if (usesFramework('/path/to/project', 'react', 70)) {
console.log('Project uses React with high confidence')
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Vite build tool
const result = viteDetector('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'vitest': '^1.0.0'
}
})
// => {
// id: 'vite',
// name: 'Vite',
// version: '5.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vite' },
// { type: 'package.json', field: 'dependencies.vitest' },
// { type: 'package.json', field: 'dependencies (vite plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Vitest testing framework
import { vitestDetector } from '@hyperfrontend/project-scope'
const result = vitestDetector('./my-project')
if (result) {
console.log(`Vitest ${result.version} detected`)
console.log('Config:', result.configPath)
// => "Config: vitest.config.ts"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Vue.js framework
const result = vueDetector('/path/to/vue-app', {
dependencies: { 'vue': '^3.0.0', '@vue/cli-service': '^5.0.0' }
})
// => {
// id: 'vue',
// name: 'Vue',
// category: 'frontend',
// version: '3.0.0',
// confidence: 85,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vue' },
// { type: 'package.json', field: 'dependencies.@vue/cli-service' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin traversal |
§visitor | WalkVisitor | Callback function invoked for each file system entry |
§options? | WalkOptions | Configuration for traversal behavior |
Example
Walking a directory tree
import { walkDirectory } from '@hyperfrontend/project-scope'
const tsFiles: string[] = []
walkDirectory('./src', (entry) => {
if (entry.isFile && entry.name.endsWith('.ts')) {
tsFiles.push(entry.relativePath)
}
}, { maxDepth: 5, respectGitignore: true })Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | In-memory virtual file system representation |
§startPath | string | Root path within the tree to begin traversal |
§visitor | WalkVisitor | Callback function invoked for each tree entry |
§options? | WalkOptions | Configuration for traversal behavior |
Example
Walking a virtual tree
import { createTree, walkTree } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
walkTree(tree, 'src', (entry) => {
if (entry.isDirectory) {
console.log('Dir:', entry.relativePath)
return 'skip' // Don't recurse into this directory
}
})Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Webpack bundler
const result = webpackDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'webpack': '^5.89.0', 'webpack-cli': '^5.1.0' },
scripts: { 'build': 'webpack --mode production' }
})
// => {
// id: 'webpack',
// name: 'Webpack',
// version: '5.89.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.webpack' },
// { type: 'package.json', field: 'dependencies.webpack-cli' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target file |
§content | Buffer | Buffer containing binary data to write |
§options? | WriteFileOptions | Optional write configuration (mode) |
Example
Writing binary buffer to file
const imageBuffer = Buffer.from([0x89, 0x50, 0x4e, 0x47])
writeFileBuffer('./output/image.png', imageBuffer)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target file |
§content | string | String content to write to the file |
§options? | WriteFileOptions | Optional write configuration (encoding, mode) |
Example
Writing text content to file
import { writeFileContent } from '@hyperfrontend/project-scope'
// Write a simple text file
writeFileContent('./output/data.txt', 'Hello, World!')
// Write with custom encoding
writeFileContent('./output/data.txt', 'Content', { encoding: 'utf-8' })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target JSON file |
§data | T | Object or value to serialize as JSON |
§options? | WriteJsonOptions | Optional write configuration (indent, encoding, mode) |
Example
Writing JSON data to file
import { writeJsonFile } from '@hyperfrontend/project-scope'
// Write object to JSON file
writeJsonFile('./config.json', { port: 3000, debug: true })
// Write with custom indentation
writeJsonFile('./config.json', data, { indent: 4 })yarnWorkspacesDetector( workspacePath: string, packageJson?: PackageJson): MonorepoDetection
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting yarn workspaces
// Project with workspaces in package.json and yarn.lock
const result = yarnWorkspacesDetector('/path/to/yarn-project')
// => {
// id: 'yarn-workspaces',
// name: 'Yarn Workspaces',
// confidence: 100,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'yarn.lock' },
// { type: 'config-file', path: '.yarnrc.yml' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§namespace | string | Logger namespace (e.g., 'project-scope', 'analyze') |
§options | ScopedLoggerOptions | Logger configuration options(default: {}) |
Returns
ScopedLoggerExample
Creating a scoped logger
const logger = createScopedLogger('project-scope')
logger.setLogLevel('debug')
// Basic logging
logger.info('Starting analysis', { path: './project' })
// Sensitive data is automatically redacted
logger.debug('Config loaded', { apiKey: 'secret123' })
// Output: [project-scope] Config loaded {"apiKey":"[REDACTED]"}detectAll( projectPath: string, packageJsonOrOptions?: PackageJson | DetectAllOptions): AllDetections
Results are cached for 60 seconds per project path to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Path to project directory |
§packageJsonOrOptions? | PackageJson | DetectAllOptions | Optional pre-loaded package.json or options object |
Returns
AllDetectionsExample
Running all tech detectors
import { detectAll } from '@hyperfrontend/project-scope'
const detections = detectAll('./my-project')
// Check frontend frameworks
for (const fw of detections.frontendFrameworks) {
console.log(`${fw.name} v${fw.version} (${fw.confidence}% confidence)`)
}
// Check build tools
console.log('Build tools:', detections.buildTools.map(t => t.name))
// Check testing frameworks
console.log('Testing:', detections.testingFrameworks.map(t => t.name))Returns
LogLevelExample
Getting current log level
setGlobalLogLevel('debug')
const level = getGlobalLogLevel()
// => 'debug'Example
Resetting the global log level
setGlobalLogLevel('debug')
// ... perform debugging ...
resetGlobalLogLevel()
// Global override removed, loggers use individual levelsParameters
| Name | Type | Description |
|---|---|---|
§obj | unknown | Object to sanitize |
Returns
unknownExample
Sanitizing sensitive data
const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
const safe = sanitize(config)
// => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }Example
Enabling debug logging globally
import { setGlobalLogLevel } from '@hyperfrontend/project-scope/core'
// Enable debug logging for all project-scope modules
setGlobalLogLevel('debug')◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
format?:"json" | "yaml" | "js" | "ts" | "jsonc" | "ini" | "dotenv" | "text"Primary format (optional - auto-detected from file extension if not provided)Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
legacyFrameworks:LegacyFrameworkDetection[ ]Detected legacy frameworks (AngularJS, Backbone, Ember, jQuery)Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type ConfigType = "package.json" | "package-lock.json" | "pnpm-lock.yaml" | "yarn.lock" | ".npmrc" | "tsconfig" | "nx" | "project.json" | "workspace.json" | "turbo" | "lerna" | "webpack" | "rollup" | "vite" | "esbuild" | "babel" | "swc" | "jest" | "vitest" | "cypress" | "playwright" | "next" | "angular" | "nuxt" | "svelte" | "astro" | "eslint" | "prettier" | "env" | ".gitignore" | ".gitattributes"type DependencyMap = Record< string, string>type DetectedLineEnding = "lf" | "crlf" | "mixed" | "none"type EncodingInfo = TextEncodingInfo | BinaryEncodingInfotype EntryPointSource = PackageJsonEntrySource | ConventionEntrySource | FrameworkEntrySource | ConfigEntrySourcetype EntryPointType = "main" | "app" | "server" | "cli" | "test"type FileSystemErrorCode = "FS_NOT_FOUND" | "FS_READ_ERROR" | "FS_WRITE_ERROR" | "FS_PARSE_ERROR" | "FS_NOT_A_DIRECTORY"type LineEndingStyle = "lf" | "crlf" | "auto"type LogLevel = "none" | "error" | "warn" | "log" | "info" | "debug"type OutputFormat = "text" | "json" | "yaml"type WalkVisitor = ( entry: WalkEntry) => WalkVisitorResulttype WalkVisitorResult = void | "skip" | "stop"type ProjectType = "application" | "library" | "e2e" | "tool" | "plugin" | "unknown"type WorkspaceType = "nx" | "turborepo" | "lerna" | "pnpm" | "npm" | "yarn" | "standalone" | "unknown"● Variables
CLI commands for project analysis including analyze, config, deps, and tree commands.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§options | AnalyzeCommandOptions | Configuration for the analyze operation |
Returns
CommandResultExamples
Basic analysis of current directory
const result = analyzeCommand({ depth: 'basic' })
if (result.exitCode === 0) {
console.log(result.output)
// => "Project Type: Library\nWorkspace: NX Monorepo\n..."
}JSON output with filters
const result = analyzeCommand({
path: './apps/frontend',
format: 'json',
depth: 'deep',
exclude: ['node_modules', 'dist'],
})
// => { exitCode: 0, output: '{"type":"application",...}' }Parameters
| Name | Type | Description |
|---|---|---|
§options | ConfigCommandOptions | Configuration command options |
Returns
CommandResultExamples
Detect all configs in a project
const result = configCommand({ path: './my-project' })
if (result.exitCode === 0) {
console.log(result.output)
// => "TypeScript: tsconfig.json\nLinting: eslint.config.js\n..."
}Filter by type with contents
const result = configCommand({
path: './my-project',
type: 'tsconfig',
showContents: true,
format: 'json',
})
// => { exitCode: 0, output: '[{"type":"tsconfig","path":"tsconfig.json",...}]' }Parameters
| Name | Type | Description |
|---|---|---|
§options | DepsCommandOptions | Parsed command options |
Returns
CommandResultExamples
List all dependencies
const result = depsCommand({ path: './my-project' })
if (result.exitCode === 0) {
console.log(result.output)
// => "Dependencies\n============\nProduction (3):\n react ^18.2.0\n..."
}Filter to dev dependencies as JSON
const result = depsCommand({
path: './my-project',
type: 'development',
format: 'json',
})
// => { exitCode: 0, output: '{"devDependencies":{"typescript":"^5.0.0",...}}' }Parameters
| Name | Type | Description |
|---|---|---|
§args | string[ | Command line arguments (typically process.argv.slice(2)) |
Returns
CommandResultExample
Running analysis via CLI
import { run } from '@hyperfrontend/project-scope'
// Analyze current directory
const result = run(['analyze'])
// Analyze specific project with JSON output
const result2 = run(['analyze', './my-project', '--format', 'json'])
// Show dependency tree
const result3 = run(['deps', '--type', 'production'])
process.exit(result.exitCode)Parameters
| Name | Type | Description |
|---|---|---|
§options | TreeCommandOptions | Configuration for the tree operation |
Returns
CommandResultExamples
Basic tree of current directory
const result = treeCommand({ depth: 2 })
if (result.exitCode === 0) {
console.log(result.output)
// => "src/\n├── index.ts\n├── lib/\n│ └── utils.ts\n..."
}Directories only with metadata
const result = treeCommand({
path: './project',
dirsOnly: true,
showSize: true,
ignore: ['node_modules', '.git'],
format: 'json',
})
// => { exitCode: 0, output: '[{"name":"src","isDirectory":true,...}]' }◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type OutputFormat = "text" | "json" | "yaml"● Variables
Core utilities for filesystem, path manipulation, platform detection, and encoding.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String to add BOM to |
Returns
stringExample
Adding UTF-8 BOM to content
const content = 'Hello World'
const withBom = addBom(content)
// => '\ufeffHello World'Parameters
| Name | Type | Description |
|---|---|---|
§content | Buffer | Buffer to convert |
§encoding? | BufferEncoding | Optional encoding override (auto-detected if not provided) |
Returns
stringExample
Converting file buffer to string with auto-detection
const fileBuffer = readFileSync('./config.json')
const content = bufferToString(fileBuffer)
// => '{"key": "value"}'Useful for testing or when a global state reset is needed. This clears all caches created via
createCache().Example
Clearing caches in tests
// In tests
afterEach(() => {
clearAllCaches()
})The cache provides a simple key-value store with:
- Optional TTL (time-to-live) for automatic expiration
- Optional maxSize for limiting cache size with FIFO eviction
- Lazy expiration (entries are checked on access)
Parameters
| Name | Type | Description |
|---|---|---|
§options? | CacheOptions | Cache configuration options |
Returns
Cache< K, V>Example
Creating caches with different options
// Basic cache
const cache = createCache<string, number>()
cache.set('answer', 42)
cache.get('answer') // 42
// Cache with TTL (expires after 60 seconds)
const ttlCache = createCache<string, object>({ ttl: 60000 })
// Cache with max size (evicts oldest when full)
const lruCache = createCache<string, object>({ maxSize: 100 })
// Combined options
const configCache = createCache<string, object>({
ttl: 30000,
maxSize: 50
})createConfigError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a configuration error
throw createConfigError(
'Invalid port number',
'CONFIG_INVALID_PORT',
{ configFile: './app.config.json', value: -1 }
)Parameters
Example
Creating directories
// Create nested directories
createDirectory('./output/reports/2024')
// Create single directory without parents
createDirectory('./logs', { recursive: false })createFileSystemError( message: string, code: FileSystemErrorCode, context: FileSystemErrorContext): Error
Parameters
| Name | Type | Description |
|---|---|---|
§message | string | The error message describing what went wrong |
§code | FileSystemErrorCode | The category code for this type of filesystem failure |
§context | FileSystemErrorContext | Additional context including path, operation, and cause |
Returns
ErrorExample
Creating a file system error
throw createFileSystemError(
'Cannot read file',
'FS_READ_ERROR',
{ path: './missing.txt', operation: 'read' }
)createFsError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a filesystem error
throw createFsError(
'Configuration file not found',
'ENOENT',
{ path: './missing.json', operation: 'read' }
)createParseError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a parse error
throw createParseError(
'Invalid JSON syntax',
'JSON_PARSE_ERROR',
{ file: './config.json', line: 42, column: 15 }
)Parameters
| Name | Type | Description |
|---|---|---|
§namespace | string | Logger namespace (e.g., 'project-scope', 'analyze') |
§options | ScopedLoggerOptions | Logger configuration options(default: {}) |
Returns
ScopedLoggerExample
Creating a scoped logger
const logger = createScopedLogger('project-scope')
logger.setLogLevel('debug')
// Basic logging
logger.info('Starting analysis', { path: './project' })
// Sensitive data is automatically redacted
logger.debug('Config loaded', { apiKey: 'secret123' })
// Output: [project-scope] Config loaded {"apiKey":"[REDACTED]"}createStructuredError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a structured error with context
import { createStructuredError } from '@hyperfrontend/project-scope'
throw createStructuredError(
'Configuration file not found',
'CONFIG_NOT_FOUND',
{ path: './config.json', searched: ['./config.json', './settings.json'] }
)createValidationError( message: string, code: string, context?: Record< string, unknown>): StructuredError
Parameters
Returns
StructuredErrorExample
Creating a validation error
throw createValidationError(
'Email format is invalid',
'INVALID_EMAIL',
{ field: 'email', value: 'not-an-email' }
)Returns
booleanExample
Detecting case sensitivity
if (detectCaseSensitivity()) {
// Linux: 'File.ts' and 'file.ts' are different files
} else {
// Windows/macOS: treat as same file
}Returns
BufferEncodingExample
Detecting encoding from buffer
const buffer = readFileSync('./data.txt')
const encoding = detectEncoding(buffer)
const content = buffer.toString(encoding)Returns
EncodingInfoExample
Detecting encoding and BOM info
const buffer = readFileSync('./document.txt')
const info = detectEncodingInfo(buffer)
if (info.type === 'text') {
console.log(`Encoding: ${info.encoding}, BOM: ${info.hasBom}`)
}Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to analyze |
Returns
DetectedLineEndingExample
Detecting line ending style
const ending = detectLineEnding('line1\nline2\n')
// => 'lf'
const mixed = detectLineEnding('line1\r\nline2\nline3')
// => 'mixed'Returns
PlatformInfoExample
Detecting current platform
const platform = detectPlatform()
if (platform.isWindows) {
// Windows-specific handling
}Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Directory path to ensure exists |
Example
Ensuring directory exists
ensureDir('./output/reports')
// Directory now exists (created if missing)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to process |
Returns
stringExample
Ensuring trailing slash
ensureTrailingSlash('src/components')
// => 'src/components/'
ensureTrailingSlash('already/has/')
// => 'already/has/'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path exists
if (exists('./config.json')) {
const config = readJsonFile('./config.json')
}Parameters
Returns
stringExample
Finding directory with specific config
// Find directory with a specific config
const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
existsSync(join(dir, '.eslintrc.js'))
)Parameters
Returns
stringExample
Getting basename
getBasename('src/components/Button.tsx')
// => 'Button.tsx'
getBasename('src/components/Button.tsx', '.tsx')
// => 'Button'Primarily used for testing.
Returns
numberExample
Getting the number of active caches
const count = getCacheCount()
// => 3 (number of active caches)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract directory from |
Returns
stringExample
Getting directory name
getDirname('src/components/Button.tsx')
// => 'src/components'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract extension from |
Returns
stringExample
Getting file extension
getExtension('src/utils/helpers.ts')
// => '.ts'
getExtension('package.json')
// => '.json'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract name from |
Returns
stringExample
Getting filename without extension
getFileNameWithoutExtension('src/utils/helpers.ts')
// => 'helpers'Parameters
Returns
FileStatsExample
Getting file statistics
const stats = getFileStat('./package.json')
if (stats) {
console.log(`Size: ${stats.size} bytes`)
console.log(`Modified: ${stats.modified}`)
}Returns
LogLevelExample
Getting current log level
setGlobalLogLevel('debug')
const level = getGlobalLogLevel()
// => 'debug'Returns
"
" | "
"Example
Getting platform line ending
const eol = getLineEnding()
const lines = ['line1', 'line2', 'line3']
const content = lines.join(eol)Returns
"\" | "/"Example
Getting platform path separator
const sep = getPathSeparator()
const fullPath = ['src', 'utils', 'helpers.ts'].join(sep)Returns
PlatformInfoExample
Getting platform information
const info = getPlatformInfo()
console.log(info.os) // => 'linux'
console.log(info.pathSeparator) // => '/'
console.log(info.lineEnding) // => '\n'Returns
booleanExample
Checking if buffer has BOM
const buffer = readFileSync('./file.txt')
if (hasBom(buffer)) {
// Strip BOM before processing
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking absolute path
isAbsolute('/workspace/src/index.ts')
// => true
isAbsolute('./src/index.ts')
// => falseReturns
booleanExample
Checking case sensitivity
const caseSensitive = isCaseSensitiveFs()
// => true on Linux, false on Windows/macOSParameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Path to check |
Returns
booleanExample
Checking if path is a directory
if (isDirectory('./src')) {
// Path exists and is a directory
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path is a file
if (isFile('./package.json')) {
// Path exists and is a regular file
}Parameters
| Name | Type | Description |
|---|---|---|
§linkPath | string | Path to check |
Returns
booleanExample
Checking if path is a symlink
if (isSymlink('./node_modules/.bin/tsc')) {
// Path is a symbolic link
}Returns
booleanExample
Checking if content is text
const buffer = readFileSync('./unknown-file')
if (isTextFile(buffer)) {
const content = buffer.toString('utf-8')
}Returns
booleanExample
Checking for Windows
if (isWindows()) {
// Use Windows-specific paths or commands
}Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[ | Path segments to join |
Returns
stringExample
Joining path segments
const fullPath = join('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx' (or 'src\\components\\Button.tsx' on Windows)Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[ | Path segments to join |
Returns
stringExample
Joining path segments
joinPath('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[ | Path segments to join |
Returns
stringExample
Joining paths with forward slashes
const configPath = joinPosix('config', 'settings', 'app.json')
// => 'config/settings/app.json'Parameters
Returns
stringExample
Finding project root by marker files
// Find project root by looking for common marker files
const projectRoot = locateByMarkers('./src/components', [
'package.json',
'nx.json',
'tsconfig.base.json'
])
// => '/workspace/my-project'Returns
booleanExample
Checking path against multiple patterns
const ignorePatterns = ['*.log', 'node_modules/**', '*.tmp']
const shouldIgnore = matchesAnyPattern('debug.log', ignorePatterns)
// => trueReturns
booleanExample
Exact path matching
matchesExact('package.json', 'package.json')
// => true
matchesExact('src/package.json', 'package.json')
// => falseSupported patterns:
- matches any characters except /
- * matches any characters including /
- ? matches exactly one character except /
- {a,b,c} matches any of the alternatives
Parameters
Returns
booleanExample
Matching paths against glob patterns
import { matchGlobPattern } from '@hyperfrontend/project-scope'
matchGlobPattern('src/utils/helper.ts', '\*\*/*.ts') // true
matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
matchGlobPattern('config.json', '\*.{json,yaml}') // true
matchGlobPattern('src/index.ts', 'src/\*.ts') // trueThe memoized function caches results based on the first argument (key). If additional arguments are needed, use the options.keyFn parameter.
Parameters
| Name | Type | Description |
|---|---|---|
§fn | ( | Function to memoize |
§options? | CacheOptions | Cache options for the underlying cache |
Returns
MemoizedFunction< K, V>Example
Memoizing an expensive function
// Memoize a detection function
const detectTechStackMemo = memoize(
(path: string) => expensiveDetection(path),
{ ttl: 60000 }
)
const result1 = detectTechStackMemo('/path/to/project')
const result2 = detectTechStackMemo('/path/to/project') // Returns cached
// Clear the cache
detectTechStackMemo.cache.clear()Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to normalize |
§style | LineEndingStyle | Target line ending style ('lf', 'crlf', or 'auto' for platform default)(default: 'lf') |
Returns
stringExample
Normalizing line endings
// Normalize to Unix line endings
const normalized = normalizeLineEndings('line1\r\nline2\r\n', 'lf')
// => 'line1\nline2\n'
// Use platform default
const platformNormalized = normalizeLineEndings(content, 'auto')Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to normalize |
Returns
stringExample
Normalizing path separators
const path = normalizePath('src\\components\\Button.tsx')
// => 'src/components/Button.tsx'. and .. segments for cross-platform configuration.Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to forward slashes
const path = normalizeToForwardSlashes('./src/../lib/utils')
// => 'lib/utils'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to native separators
const path = normalizeToNative('src/components/Button.tsx')
// => 'src\\components\\Button.tsx' on Windows
// => 'src/components/Button.tsx' on UnixParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to calculate offset for |
Returns
stringExample
Calculating offset from root
offsetFromRoot('libs/utils/src')
// => '../../../'
offsetFromRoot('apps')
// => '../'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to parse |
Returns
ParsedPathExample
Parsing path components
const parsed = parsePath('/workspace/src/index.ts')
// => { root: '/', dir: '/workspace/src', base: 'index.ts', ext: '.ts', name: 'index' }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to split |
Returns
string[ ]Example
Splitting path into segments
pathSegments('src/components/Button.tsx')
// => ['src', 'components', 'Button.tsx']Returns
booleanExample
Comparing paths
// On case-insensitive filesystem (Windows/macOS)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => true
// On case-sensitive filesystem (Linux)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => falseParameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Absolute or relative path to the directory |
Returns
DirectoryEntry[ ]Example
Listing directory contents
import { readDirectory } from '@hyperfrontend/project-scope'
const entries = readDirectory('./src')
for (const entry of entries) {
console.log(entry.name, entry.isFile ? 'file' : 'directory')
}Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Root directory path to start traversal |
§options? | RecursiveOptions | Configuration for depth limit, hidden files, and symlinks |
Returns
DirectoryEntry[ ]Example
Recursive directory listing with options
import { readDirectoryRecursive } from '@hyperfrontend/project-scope'
// List all files up to 3 levels deep
const entries = readDirectoryRecursive('./src', { maxDepth: 3 })
// Include hidden files
const allEntries = readDirectoryRecursive('./project', { includeHidden: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
Returns
BufferExample
Reading file as buffer
const buffer = readFileBuffer('./image.png')
console.log(buffer.length) // File size in bytesParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
§encoding | BufferEncoding | File encoding (default: utf-8)(default: 'utf-8') |
Returns
stringExample
Reading file contents
import { readFileContent } from '@hyperfrontend/project-scope'
const content = readFileContent('./package.json')
console.log(content) // JSON stringParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
§encoding | BufferEncoding | File encoding (default: utf-8)(default: 'utf-8') |
Returns
stringExample
Reading file if it exists
const content = readFileIfExists('./optional-config.json')
if (content) {
// File existed, use content
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
§options? | ReadJsonFileOptions< | Parse options |
Returns
TExample
Reading JSON file
import { readJsonFile } from '@hyperfrontend/project-scope'
// Read with type inference
interface Config { port: number }
const config = readJsonFile<Config>('./config.json')
// Read with default fallback
const settings = readJsonFile('./settings.json', { default: {} })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
Returns
TExample
Reading JSON file if it exists
interface UserSettings { theme: string }
const settings = readJsonFileIfExists<UserSettings>('./user-settings.json')
const theme = settings?.theme ?? 'default'Returns
stringExample
Computing relative path
relativePath('/workspace/src/utils', '/workspace/lib/helpers')
// => '../../lib/helpers'Parameters
Example
Removing directories
// Remove directory and all contents
removeDirectory('./temp', { recursive: true })
// Safe removal (no error if missing)
removeDirectory('./cache', { recursive: true, force: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path that may have trailing slashes |
Returns
stringExample
Removing trailing slashes
removeTrailingSlash('src/components/')
// => 'src/components'
removeTrailingSlash('path\\to\\dir\\')
// => 'path\\to\\dir'Example
Resetting the global log level
setGlobalLogLevel('debug')
// ... perform debugging ...
resetGlobalLogLevel()
// Global override removed, loggers use individual levelsParameters
Returns
stringExample
Resolving from workspace root
const configPath = resolveFromWorkspace('/workspace', 'config', 'app.json')
// => '/workspace/config/app.json'Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[ | Path segments to resolve |
Returns
stringExample
Resolving to absolute path
const absPath = resolvePath('src', 'components', 'Button.tsx')
// => '/workspace/project/src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to resolve |
Returns
stringExample
Resolving symlinks
const realPath = resolveRealPath('./node_modules/.bin/tsc')
// => '/workspace/node_modules/typescript/bin/tsc'Parameters
| Name | Type | Description |
|---|---|---|
§obj | unknown | Object to sanitize |
Returns
unknownExample
Sanitizing sensitive data
const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
const safe = sanitize(config)
// => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }Example
Enabling debug logging globally
import { setGlobalLogLevel } from '@hyperfrontend/project-scope/core'
// Enable debug logging for all project-scope modules
setGlobalLogLevel('debug')Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String that may have BOM |
Returns
stringExample
Stripping BOM from a string
const withBom = '\ufeffHello World'
const clean = stripBom(withBom)
// => 'Hello World'Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Buffer< | Buffer or string content |
§sourceEncoding | BufferEncoding | Source encoding (auto-detected if not provided)(default: 'utf-8') |
Returns
stringExample
Converting a buffer to UTF-8 string
const buffer = Buffer.from('Hello', 'utf-8')
const text = toUtf8(buffer)
// => 'Hello'Parameters
Returns
stringExample
Finding directory containing README
// Find first directory containing a README
const readmeDir = traverseUpward('./src/utils', (dir) =>
existsSync(join(dir, 'README.md'))
)
// => '/project' or nullUseful for cleanup in tests or when a cache is no longer needed.
Returns
booleanExample
Unregistering a cache from the registry
const myCache = createCache<string, number>({ name: 'temp-cache' })
const wasRemoved = unregisterCache(myCache)
// => trueParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target file |
§content | Buffer | Buffer containing binary data to write |
§options? | WriteFileOptions | Optional write configuration (mode) |
Example
Writing binary buffer to file
const imageBuffer = Buffer.from([0x89, 0x50, 0x4e, 0x47])
writeFileBuffer('./output/image.png', imageBuffer)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target file |
§content | string | String content to write to the file |
§options? | WriteFileOptions | Optional write configuration (encoding, mode) |
Example
Writing text content to file
import { writeFileContent } from '@hyperfrontend/project-scope'
// Write a simple text file
writeFileContent('./output/data.txt', 'Hello, World!')
// Write with custom encoding
writeFileContent('./output/data.txt', 'Content', { encoding: 'utf-8' })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target JSON file |
§data | T | Object or value to serialize as JSON |
§options? | WriteJsonOptions | Optional write configuration (indent, encoding, mode) |
Example
Writing JSON data to file
import { writeJsonFile } from '@hyperfrontend/project-scope'
// Write object to JSON file
writeJsonFile('./config.json', { port: 3000, debug: true })
// Write with custom indentation
writeJsonFile('./config.json', data, { indent: 4 })◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type DetectedLineEnding = "lf" | "crlf" | "mixed" | "none"type EncodingInfo = TextEncodingInfo | BinaryEncodingInfotype FileSystemErrorCode = "FS_NOT_FOUND" | "FS_READ_ERROR" | "FS_WRITE_ERROR" | "FS_PARSE_ERROR" | "FS_NOT_A_DIRECTORY"type LineEndingStyle = "lf" | "crlf" | "auto"type LogLevel = "none" | "error" | "warn" | "log" | "info" | "debug"● Variables
File encoding detection with BOM handling, binary detection, and UTF-8 conversion.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String to add BOM to |
Returns
stringExample
Adding UTF-8 BOM to content
const content = 'Hello World'
const withBom = addBom(content)
// => '\ufeffHello World'Parameters
| Name | Type | Description |
|---|---|---|
§content | Buffer | Buffer to convert |
§encoding? | BufferEncoding | Optional encoding override (auto-detected if not provided) |
Returns
stringExample
Converting file buffer to string with auto-detection
const fileBuffer = readFileSync('./config.json')
const content = bufferToString(fileBuffer)
// => '{"key": "value"}'Returns
BufferEncodingExample
Detecting encoding from buffer
const buffer = readFileSync('./data.txt')
const encoding = detectEncoding(buffer)
const content = buffer.toString(encoding)Returns
EncodingInfoExample
Detecting encoding and BOM info
const buffer = readFileSync('./document.txt')
const info = detectEncodingInfo(buffer)
if (info.type === 'text') {
console.log(`Encoding: ${info.encoding}, BOM: ${info.hasBom}`)
}Returns
booleanExample
Checking if buffer has BOM
const buffer = readFileSync('./file.txt')
if (hasBom(buffer)) {
// Strip BOM before processing
}Returns
booleanExample
Checking if content is text
const buffer = readFileSync('./unknown-file')
if (isTextFile(buffer)) {
const content = buffer.toString('utf-8')
}Parameters
| Name | Type | Description |
|---|---|---|
§content | string | String that may have BOM |
Returns
stringExample
Stripping BOM from a string
const withBom = '\ufeffHello World'
const clean = stripBom(withBom)
// => 'Hello World'Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Buffer< | Buffer or string content |
§sourceEncoding | BufferEncoding | Source encoding (auto-detected if not provided)(default: 'utf-8') |
Returns
stringExample
Converting a buffer to UTF-8 string
const buffer = Buffer.from('Hello', 'utf-8')
const text = toUtf8(buffer)
// => 'Hello'◆ Types
type EncodingInfo = TextEncodingInfo | BinaryEncodingInfo● Variables
Filesystem operations for reading/writing files, directory traversal, and stat checks.
ƒ Functions
Parameters
Example
Creating directories
// Create nested directories
createDirectory('./output/reports/2024')
// Create single directory without parents
createDirectory('./logs', { recursive: false })createFileSystemError( message: string, code: FileSystemErrorCode, context: FileSystemErrorContext): Error
Parameters
| Name | Type | Description |
|---|---|---|
§message | string | The error message describing what went wrong |
§code | FileSystemErrorCode | The category code for this type of filesystem failure |
§context | FileSystemErrorContext | Additional context including path, operation, and cause |
Returns
ErrorExample
Creating a file system error
throw createFileSystemError(
'Cannot read file',
'FS_READ_ERROR',
{ path: './missing.txt', operation: 'read' }
)Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Directory path to ensure exists |
Example
Ensuring directory exists
ensureDir('./output/reports')
// Directory now exists (created if missing)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path exists
if (exists('./config.json')) {
const config = readJsonFile('./config.json')
}Parameters
Returns
stringExample
Finding directory with specific config
// Find directory with a specific config
const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
existsSync(join(dir, '.eslintrc.js'))
)Parameters
Returns
FileStatsExample
Getting file statistics
const stats = getFileStat('./package.json')
if (stats) {
console.log(`Size: ${stats.size} bytes`)
console.log(`Modified: ${stats.modified}`)
}Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Path to check |
Returns
booleanExample
Checking if path is a directory
if (isDirectory('./src')) {
// Path exists and is a directory
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking if path is a file
if (isFile('./package.json')) {
// Path exists and is a regular file
}Parameters
| Name | Type | Description |
|---|---|---|
§linkPath | string | Path to check |
Returns
booleanExample
Checking if path is a symlink
if (isSymlink('./node_modules/.bin/tsc')) {
// Path is a symbolic link
}Parameters
Returns
stringExample
Finding project root by marker files
// Find project root by looking for common marker files
const projectRoot = locateByMarkers('./src/components', [
'package.json',
'nx.json',
'tsconfig.base.json'
])
// => '/workspace/my-project'Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Absolute or relative path to the directory |
Returns
DirectoryEntry[ ]Example
Listing directory contents
import { readDirectory } from '@hyperfrontend/project-scope'
const entries = readDirectory('./src')
for (const entry of entries) {
console.log(entry.name, entry.isFile ? 'file' : 'directory')
}Parameters
| Name | Type | Description |
|---|---|---|
§dirPath | string | Root directory path to start traversal |
§options? | RecursiveOptions | Configuration for depth limit, hidden files, and symlinks |
Returns
DirectoryEntry[ ]Example
Recursive directory listing with options
import { readDirectoryRecursive } from '@hyperfrontend/project-scope'
// List all files up to 3 levels deep
const entries = readDirectoryRecursive('./src', { maxDepth: 3 })
// Include hidden files
const allEntries = readDirectoryRecursive('./project', { includeHidden: true })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
Returns
BufferExample
Reading file as buffer
const buffer = readFileBuffer('./image.png')
console.log(buffer.length) // File size in bytesParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
§encoding | BufferEncoding | File encoding (default: utf-8)(default: 'utf-8') |
Returns
stringExample
Reading file contents
import { readFileContent } from '@hyperfrontend/project-scope'
const content = readFileContent('./package.json')
console.log(content) // JSON stringParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to file |
§encoding | BufferEncoding | File encoding (default: utf-8)(default: 'utf-8') |
Returns
stringExample
Reading file if it exists
const content = readFileIfExists('./optional-config.json')
if (content) {
// File existed, use content
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
§options? | ReadJsonFileOptions< | Parse options |
Returns
TExample
Reading JSON file
import { readJsonFile } from '@hyperfrontend/project-scope'
// Read with type inference
interface Config { port: number }
const config = readJsonFile<Config>('./config.json')
// Read with default fallback
const settings = readJsonFile('./settings.json', { default: {} })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to JSON file |
Returns
TExample
Reading JSON file if it exists
interface UserSettings { theme: string }
const settings = readJsonFileIfExists<UserSettings>('./user-settings.json')
const theme = settings?.theme ?? 'default'Parameters
Example
Removing directories
// Remove directory and all contents
removeDirectory('./temp', { recursive: true })
// Safe removal (no error if missing)
removeDirectory('./cache', { recursive: true, force: true })Parameters
Returns
stringExample
Finding directory containing README
// Find first directory containing a README
const readmeDir = traverseUpward('./src/utils', (dir) =>
existsSync(join(dir, 'README.md'))
)
// => '/project' or nullParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target file |
§content | Buffer | Buffer containing binary data to write |
§options? | WriteFileOptions | Optional write configuration (mode) |
Example
Writing binary buffer to file
const imageBuffer = Buffer.from([0x89, 0x50, 0x4e, 0x47])
writeFileBuffer('./output/image.png', imageBuffer)Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target file |
§content | string | String content to write to the file |
§options? | WriteFileOptions | Optional write configuration (encoding, mode) |
Example
Writing text content to file
import { writeFileContent } from '@hyperfrontend/project-scope'
// Write a simple text file
writeFileContent('./output/data.txt', 'Hello, World!')
// Write with custom encoding
writeFileContent('./output/data.txt', 'Content', { encoding: 'utf-8' })Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Absolute or relative path to the target JSON file |
§data | T | Object or value to serialize as JSON |
§options? | WriteJsonOptions | Optional write configuration (indent, encoding, mode) |
Example
Writing JSON data to file
import { writeJsonFile } from '@hyperfrontend/project-scope'
// Write object to JSON file
writeJsonFile('./config.json', { port: 3000, debug: true })
// Write with custom indentation
writeJsonFile('./config.json', data, { indent: 4 })◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type FileSystemErrorCode = "FS_NOT_FOUND" | "FS_READ_ERROR" | "FS_WRITE_ERROR" | "FS_PARSE_ERROR" | "FS_NOT_A_DIRECTORY"Scoped logger factory with a per-call-site log level.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§namespace | string | Logger namespace (e.g., 'project-scope', 'analyze') |
§options | ScopedLoggerOptions | Logger configuration options(default: {}) |
Returns
ScopedLoggerExample
Creating a scoped logger
const logger = createScopedLogger('project-scope')
logger.setLogLevel('debug')
// Basic logging
logger.info('Starting analysis', { path: './project' })
// Sensitive data is automatically redacted
logger.debug('Config loaded', { apiKey: 'secret123' })
// Output: [project-scope] Config loaded {"apiKey":"[REDACTED]"}Returns
LogLevelExample
Getting current log level
setGlobalLogLevel('debug')
const level = getGlobalLogLevel()
// => 'debug'Example
Resetting the global log level
setGlobalLogLevel('debug')
// ... perform debugging ...
resetGlobalLogLevel()
// Global override removed, loggers use individual levelsParameters
| Name | Type | Description |
|---|---|---|
§obj | unknown | Object to sanitize |
Returns
unknownExample
Sanitizing sensitive data
const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
const safe = sanitize(config)
// => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }Example
Enabling debug logging globally
import { setGlobalLogLevel } from '@hyperfrontend/project-scope/core'
// Enable debug logging for all project-scope modules
setGlobalLogLevel('debug')◈ Interfaces
Properties
Properties
◆ Types
type LogLevel = "none" | "error" | "warn" | "log" | "info" | "debug"● Variables
Path manipulation utilities for joining, normalization, resolution, and segment extraction.
ƒ Functions
candidate resolves to a location inside root. The lexical check runs first and rejects
.. traversal and absolute escapes with no filesystem access at all, so a hostile path is never stat-ed. Only a path that is already lexically contained is then resolved through symlinks, so an in-tree link cannot tunnel outside the root, and that realpath touches only paths the caller would legitimately read anyway.Parameters
Returns
booleanExample
Confining a resolved import target
isWithinRoot('/project', '/project/src/index.ts') // true
isWithinRoot('/project', '/project/../etc/passwd') // falseParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to process |
Returns
stringExample
Ensuring trailing slash
ensureTrailingSlash('src/components')
// => 'src/components/'
ensureTrailingSlash('already/has/')
// => 'already/has/'Parameters
Returns
stringExample
Getting basename
getBasename('src/components/Button.tsx')
// => 'Button.tsx'
getBasename('src/components/Button.tsx', '.tsx')
// => 'Button'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract directory from |
Returns
stringExample
Getting directory name
getDirname('src/components/Button.tsx')
// => 'src/components'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract extension from |
Returns
stringExample
Getting file extension
getExtension('src/utils/helpers.ts')
// => '.ts'
getExtension('package.json')
// => '.json'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to extract name from |
Returns
stringExample
Getting filename without extension
getFileNameWithoutExtension('src/utils/helpers.ts')
// => 'helpers'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to check |
Returns
booleanExample
Checking absolute path
isAbsolute('/workspace/src/index.ts')
// => true
isAbsolute('./src/index.ts')
// => falseParameters
| Name | Type | Description |
|---|---|---|
§...paths | string[ | Path segments to join |
Returns
stringExample
Joining path segments
const fullPath = join('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx' (or 'src\\components\\Button.tsx' on Windows)Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[ | Path segments to join |
Returns
stringExample
Joining path segments
joinPath('src', 'components', 'Button.tsx')
// => 'src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§...paths | string[ | Path segments to join |
Returns
stringExample
Joining paths with forward slashes
const configPath = joinPosix('config', 'settings', 'app.json')
// => 'config/settings/app.json'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to normalize |
Returns
stringExample
Normalizing path separators
const path = normalizePath('src\\components\\Button.tsx')
// => 'src/components/Button.tsx'. and .. segments for cross-platform configuration.Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to forward slashes
const path = normalizeToForwardSlashes('./src/../lib/utils')
// => 'lib/utils'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | The input path to convert |
Returns
stringExample
Converting to native separators
const path = normalizeToNative('src/components/Button.tsx')
// => 'src\\components\\Button.tsx' on Windows
// => 'src/components/Button.tsx' on UnixParameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to calculate offset for |
Returns
stringExample
Calculating offset from root
offsetFromRoot('libs/utils/src')
// => '../../../'
offsetFromRoot('apps')
// => '../'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to parse |
Returns
ParsedPathExample
Parsing path components
const parsed = parsePath('/workspace/src/index.ts')
// => { root: '/', dir: '/workspace/src', base: 'index.ts', ext: '.ts', name: 'index' }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to split |
Returns
string[ ]Example
Splitting path into segments
pathSegments('src/components/Button.tsx')
// => ['src', 'components', 'Button.tsx']Returns
stringExample
Computing relative path
relativePath('/workspace/src/utils', '/workspace/lib/helpers')
// => '../../lib/helpers'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path that may have trailing slashes |
Returns
stringExample
Removing trailing slashes
removeTrailingSlash('src/components/')
// => 'src/components'
removeTrailingSlash('path\\to\\dir\\')
// => 'path\\to\\dir'Parameters
Returns
stringExample
Resolving from workspace root
const configPath = resolveFromWorkspace('/workspace', 'config', 'app.json')
// => '/workspace/config/app.json'Parameters
| Name | Type | Description |
|---|---|---|
§...segments | string[ | Path segments to resolve |
Returns
stringExample
Resolving to absolute path
const absPath = resolvePath('src', 'components', 'Button.tsx')
// => '/workspace/project/src/components/Button.tsx'Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to resolve |
Returns
stringExample
Resolving symlinks
const realPath = resolveRealPath('./node_modules/.bin/tsc')
// => '/workspace/node_modules/typescript/bin/tsc'Platform detection for OS type, filesystem case sensitivity, and line ending handling.
ƒ Functions
Returns
booleanExample
Detecting case sensitivity
if (detectCaseSensitivity()) {
// Linux: 'File.ts' and 'file.ts' are different files
} else {
// Windows/macOS: treat as same file
}Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to analyze |
Returns
DetectedLineEndingExample
Detecting line ending style
const ending = detectLineEnding('line1\nline2\n')
// => 'lf'
const mixed = detectLineEnding('line1\r\nline2\nline3')
// => 'mixed'Returns
PlatformInfoExample
Detecting current platform
const platform = detectPlatform()
if (platform.isWindows) {
// Windows-specific handling
}Returns
"
" | "
"Example
Getting platform line ending
const eol = getLineEnding()
const lines = ['line1', 'line2', 'line3']
const content = lines.join(eol)Returns
"\" | "/"Example
Getting platform path separator
const sep = getPathSeparator()
const fullPath = ['src', 'utils', 'helpers.ts'].join(sep)Returns
PlatformInfoExample
Getting platform information
const info = getPlatformInfo()
console.log(info.os) // => 'linux'
console.log(info.pathSeparator) // => '/'
console.log(info.lineEnding) // => '\n'Returns
booleanExample
Checking case sensitivity
const caseSensitive = isCaseSensitiveFs()
// => true on Linux, false on Windows/macOSReturns
booleanExample
Checking for Windows
if (isWindows()) {
// Use Windows-specific paths or commands
}Parameters
| Name | Type | Description |
|---|---|---|
§content | string | Content to normalize |
§style | LineEndingStyle | Target line ending style ('lf', 'crlf', or 'auto' for platform default)(default: 'lf') |
Returns
stringExample
Normalizing line endings
// Normalize to Unix line endings
const normalized = normalizeLineEndings('line1\r\nline2\r\n', 'lf')
// => 'line1\nline2\n'
// Use platform default
const platformNormalized = normalizeLineEndings(content, 'auto')Returns
booleanExample
Comparing paths
// On case-insensitive filesystem (Windows/macOS)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => true
// On case-sensitive filesystem (Linux)
pathsEqual('src/App.tsx', 'src/app.tsx')
// => false◈ Interfaces
Properties
◆ Types
type DetectedLineEnding = "lf" | "crlf" | "mixed" | "none"type LineEndingStyle = "lf" | "crlf" | "auto"● Variables
Project heuristics for type detection, framework identification, entry points, and dependency analysis.
ƒ Functions
Analyzes imports/exports in source files to build a graph of internal dependencies.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Absolute path to project root |
§options? | BuildGraphOptions | Configuration for graph building |
Returns
DependencyGraphExample
Building a dependency graph
import { buildDependencyGraph } from '@hyperfrontend/project-scope'
const graph = buildDependencyGraph('./my-lib')
console.log('Root files:', graph.roots) // Files not imported by anything
console.log('Leaf files:', graph.leaves) // Files that don't import anything
console.log('Total nodes:', graph.nodes.size)
// Examine a specific node's dependencies
const node = graph.nodes.get('src/utils/helper.ts')
console.log('Depends on:', node?.dependencies)
console.log('Used by:', node?.dependents)Useful for testing or when the project files have changed.
Example
Clearing the entry point cache
import { clearEntryPointCache } from '@hyperfrontend/project-scope'
// Reset cache before re-analyzing after file changes
clearEntryPointCache()Useful for testing or when the project files have changed.
Example
Clearing the framework cache
import { clearFrameworkIdentificationCache } from '@hyperfrontend/project-scope'
// Reset cache before re-identifying frameworks
clearFrameworkIdentificationCache()detectProjectType( projectPath: string, options?: DetectProjectTypeOptions): ProjectTypeDetection
Uses multiple heuristics including:
- Package name patterns
- Exports/main/module fields
- Binary (bin) field
- Entry point patterns
- Testing framework presence
- Directory structure
- Framework detection
- NX project type field
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | DetectProjectTypeOptions | Detection options |
Returns
ProjectTypeDetectionExample
Detecting project type
import { detectProjectType } from '@hyperfrontend/project-scope'
const result = detectProjectType('./my-lib')
console.log(result.type) // 'library' | 'application' | 'e2e' | 'tool' | 'plugin'
console.log(result.confidence) // 85
console.log(result.evidence) // [{ factor: 'exports', confidence: 20, ... }]discoverEntryPoints( projectPath: string, options?: DiscoverEntryPointsOptions): EntryPointInfo[ ]
Analyzes package.json fields (main, module, bin, exports), convention-based patterns, and framework-specific entries.
Results are cached for 60 seconds per project path and options to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | DiscoverEntryPointsOptions | Discovery options |
Returns
EntryPointInfo[ ]Example
Discovering project entry points
import { discoverEntryPoints } from '@hyperfrontend/project-scope'
const entryPoints = discoverEntryPoints('./my-app')
for (const entry of entryPoints) {
console.log(`${entry.path} (${entry.type}) - ${entry.confidence}% confidence`)
}
// Output:
// src/index.ts (main) - 100% confidence
// src/cli.ts (cli) - 85% confidenceParameters
| Name | Type | Description |
|---|---|---|
§graph | DependencyGraph | Dependency graph |
Returns
CircularDependency[ ]Example
Finding circular dependencies
import { buildDependencyGraph, findCircularDependencies } from '@hyperfrontend/project-scope'
const graph = buildDependencyGraph('/workspace')
const cycles = findCircularDependencies(graph)
cycles.forEach(c => console.log(`Cycle: ${c.cycle.join(' -> ')}`))Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory |
Returns
ProjectDependenciesExample
Getting project dependencies
import { getProjectDependencies } from '@hyperfrontend/project-scope'
const deps = getProjectDependencies('/path/to/project')
console.log('Runtime:', deps.runtime) // ['express', 'lodash']
console.log('Dev:', deps.development) // ['jest', 'typescript']
console.log('Total:', deps.total) // 15identifyFrameworks( projectPath: string, options?: IdentifyFrameworksOptions): FrameworkIdentification
Runs all technology detectors and aggregates results into a comprehensive framework identification with confidence scoring.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | IdentifyFrameworksOptions | Identification options |
Returns
FrameworkIdentificationExample
Identifying all frameworks in project
import { identifyFrameworks } from '@hyperfrontend/project-scope'
const result = identifyFrameworks('./my-react-app')
console.log(result.summary) // 'React + Next.js with Jest'
console.log(result.primary?.name) // 'React'
console.log(result.stack.frontend) // ['react', 'nextjs']
console.log(result.stack.testing) // ['jest']Parameters
Returns
booleanExample
Checking for a specific framework
import { usesFramework } from '@hyperfrontend/project-scope'
if (usesFramework('/path/to/project', 'react', 70)) {
console.log('Project uses React with high confidence')
}◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type EntryPointSource = PackageJsonEntrySource | ConventionEntrySource | FrameworkEntrySource | ConfigEntrySourcetype EntryPointType = "main" | "app" | "server" | "cli" | "test"● Variables
Dependency graph building and circular dependency detection for project analysis.
ƒ Functions
Analyzes imports/exports in source files to build a graph of internal dependencies.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Absolute path to project root |
§options? | BuildGraphOptions | Configuration for graph building |
Returns
DependencyGraphExample
Building a dependency graph
import { buildDependencyGraph } from '@hyperfrontend/project-scope'
const graph = buildDependencyGraph('./my-lib')
console.log('Root files:', graph.roots) // Files not imported by anything
console.log('Leaf files:', graph.leaves) // Files that don't import anything
console.log('Total nodes:', graph.nodes.size)
// Examine a specific node's dependencies
const node = graph.nodes.get('src/utils/helper.ts')
console.log('Depends on:', node?.dependencies)
console.log('Used by:', node?.dependents)Parameters
| Name | Type | Description |
|---|---|---|
§graph | DependencyGraph | Dependency graph |
Returns
CircularDependency[ ]Example
Finding circular dependencies
import { buildDependencyGraph, findCircularDependencies } from '@hyperfrontend/project-scope'
const graph = buildDependencyGraph('/workspace')
const cycles = findCircularDependencies(graph)
cycles.forEach(c => console.log(`Cycle: ${c.cycle.join(' -> ')}`))Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory |
Returns
ProjectDependenciesExample
Getting project dependencies
import { getProjectDependencies } from '@hyperfrontend/project-scope'
const deps = getProjectDependencies('/path/to/project')
console.log('Runtime:', deps.runtime) // ['express', 'lodash']
console.log('Dev:', deps.development) // ['jest', 'typescript']
console.log('Total:', deps.total) // 15◈ Interfaces
Properties
Entry point discovery with configurable patterns for detecting main files and module boundaries.
ƒ Functions
Useful for testing or when the project files have changed.
Example
Clearing the entry point cache
import { clearEntryPointCache } from '@hyperfrontend/project-scope'
// Reset cache before re-analyzing after file changes
clearEntryPointCache()discoverEntryPoints( projectPath: string, options?: DiscoverEntryPointsOptions): EntryPointInfo[ ]
Analyzes package.json fields (main, module, bin, exports), convention-based patterns, and framework-specific entries.
Results are cached for 60 seconds per project path and options to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | DiscoverEntryPointsOptions | Discovery options |
Returns
EntryPointInfo[ ]Example
Discovering project entry points
import { discoverEntryPoints } from '@hyperfrontend/project-scope'
const entryPoints = discoverEntryPoints('./my-app')
for (const entry of entryPoints) {
console.log(`${entry.path} (${entry.type}) - ${entry.confidence}% confidence`)
}
// Output:
// src/index.ts (main) - 100% confidence
// src/cli.ts (cli) - 85% confidence◈ Interfaces
Properties
Properties
◆ Types
type EntryPointSource = PackageJsonEntrySource | ConventionEntrySource | FrameworkEntrySource | ConfigEntrySourcetype EntryPointType = "main" | "app" | "server" | "cli" | "test"● Variables
Framework identification with confidence scoring and stack summary for detected technologies.
ƒ Functions
Useful for testing or when the project files have changed.
Example
Clearing the framework cache
import { clearFrameworkIdentificationCache } from '@hyperfrontend/project-scope'
// Reset cache before re-identifying frameworks
clearFrameworkIdentificationCache()identifyFrameworks( projectPath: string, options?: IdentifyFrameworksOptions): FrameworkIdentification
Runs all technology detectors and aggregates results into a comprehensive framework identification with confidence scoring.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | IdentifyFrameworksOptions | Identification options |
Returns
FrameworkIdentificationExample
Identifying all frameworks in project
import { identifyFrameworks } from '@hyperfrontend/project-scope'
const result = identifyFrameworks('./my-react-app')
console.log(result.summary) // 'React + Next.js with Jest'
console.log(result.primary?.name) // 'React'
console.log(result.stack.frontend) // ['react', 'nextjs']
console.log(result.stack.testing) // ['jest']Parameters
Returns
booleanExample
Checking for a specific framework
import { usesFramework } from '@hyperfrontend/project-scope'
if (usesFramework('/path/to/project', 'react', 70)) {
console.log('Project uses React with high confidence')
}◈ Interfaces
Properties
Properties
Project type detection (application, library, e2e, tool, plugin) with evidence-based classification.
ƒ Functions
detectProjectType( projectPath: string, options?: DetectProjectTypeOptions): ProjectTypeDetection
Uses multiple heuristics including:
- Package name patterns
- Exports/main/module fields
- Binary (bin) field
- Entry point patterns
- Testing framework presence
- Directory structure
- Framework detection
- NX project type field
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§options? | DetectProjectTypeOptions | Detection options |
Returns
ProjectTypeDetectionExample
Detecting project type
import { detectProjectType } from '@hyperfrontend/project-scope'
const result = detectProjectType('./my-lib')
console.log(result.type) // 'library' | 'application' | 'e2e' | 'tool' | 'plugin'
console.log(result.confidence) // 85
console.log(result.evidence) // [{ factor: 'exports', confidence: 20, ... }]◈ Interfaces
Properties
Properties
Properties
Type definitions for project analysis including ProjectType, WorkspaceType, and AnalysisResult.
◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type ProjectType = "application" | "library" | "e2e" | "tool" | "plugin" | "unknown"type WorkspaceType = "nx" | "turborepo" | "lerna" | "pnpm" | "npm" | "yarn" | "standalone" | "unknown"Nx workspace detection and project configuration reading.
ƒ Functions
buildSimpleProjectGraph( workspacePath: string, projects?: Map< string, NxProjectConfig>): NxProjectGraph
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace root path |
§projects? | Map< | Existing configuration map to skip auto-discovery |
Returns
NxProjectGraphExample
Building a simple project graph
import { buildSimpleProjectGraph } from '@hyperfrontend/project-scope'
const graph = buildSimpleProjectGraph('/workspace')
console.log('Projects:', Object.keys(graph.nodes))
console.log('Dependencies:', graph.dependencies['my-app'])Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace root path |
Returns
Map< string, NxProjectConfig>Example
Discovering all NX projects
import { discoverNxProjects } from '@hyperfrontend/project-scope'
const projects = discoverNxProjects('/workspace')
for (const [name, config] of projects) {
console.log(`${name}: ${config.projectType} at ${config.root}`)
}Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path to search from |
Returns
stringExample
Finding NX workspace root
import { findNxWorkspaceRoot } from '@hyperfrontend/project-scope'
const root = findNxWorkspaceRoot('./libs/my-lib/src')
if (root) {
console.log('Workspace root:', root) // e.g., '/home/user/my-monorepo'
}Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace root path |
Returns
NxWorkspaceInfoExample
Getting NX workspace information
import { getNxWorkspaceInfo } from '@hyperfrontend/project-scope'
const info = getNxWorkspaceInfo('/path/to/monorepo')
if (info) {
console.log('NX version:', info.version)
console.log('Apps dir:', info.workspaceLayout.appsDir)
}Parameters
Returns
NxProjectConfigExample
Getting project configuration
import { getProjectConfig } from '@hyperfrontend/project-scope'
const config = getProjectConfig('./libs/my-lib', '/workspace')
// => { name: 'my-lib', root: 'libs/my-lib', projectType: 'library' }Parameters
| Name | Type | Description |
|---|---|---|
§path | string | Directory path to check |
Returns
booleanExample
Checking for NX project
import { isNxProject } from '@hyperfrontend/project-scope'
if (isNxProject('./libs/my-lib')) {
console.log('This is an NX project')
}Parameters
| Name | Type | Description |
|---|---|---|
§path | string | Directory path to check |
Returns
booleanExample
Checking for NX workspace
import { isNxWorkspace } from '@hyperfrontend/project-scope'
if (isNxWorkspace('./my-project')) {
console.log('This is an NX monorepo')
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
Returns
NxProjectConfigExample
Reading NX project.json
import { readProjectJson } from '@hyperfrontend/project-scope'
const config = readProjectJson('./libs/my-lib')
if (config) {
console.log('Project:', config.name, 'Type:', config.projectType)
}◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
● Variables
Project utilities for file traversal, config detection, package.json operations, and root finding.
ƒ Functions
Useful for testing or when the project files have changed.
Example
Clearing the config detection cache
import { clearConfigDetectionCache } from '@hyperfrontend/project-scope'
// Reset cache after modifying config files
clearConfigDetectionCache()detectConfigs( rootPath: string, types?: ConfigType[ ], options?: DetectConfigOptions): DetectedConfig[ ]
Results are cached for 30 seconds per project path and options to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§rootPath | string | Project root directory |
§types? | ConfigType[ | Optional array of config types to check (defaults to all) |
§options? | DetectConfigOptions | Detection options |
Returns
DetectedConfig[ ]Example
Detecting configuration files
import { detectConfigs } from '@hyperfrontend/project-scope'
// Detect all config files
const configs = detectConfigs('./my-project')
for (const config of configs) {
console.log(`${config.type}: ${config.path}`)
}
// Output:
// typescript: tsconfig.json
// eslint: eslint.config.js
// jest: jest.config.ts
// Detect specific config types only
const tsConfigs = detectConfigs('./my-project', ['typescript', 'eslint'])Parameters
| Name | Type | Description |
|---|---|---|
§rootPath | string | Project root directory |
§type | ConfigType | Config type to find |
Returns
stringExample
Finding a specific config file
import { findConfigFile } from '@hyperfrontend/project-scope'
const tsConfig = findConfigFile('/project', 'typescript')
// => '/project/tsconfig.json'
const eslint = findConfigFile('/project', 'eslint')
// => '/project/.eslintrc.js' or null if not foundfindDirectories( startPath: string, patterns: string | string[ ], options?: FindOptions): string[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin the search |
§patterns | string | string[ | Glob patterns to filter directories (supports wildcards) |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding directories by pattern
import { findDirectories } from '@hyperfrontend/project-scope'
const componentDirs = findDirectories('./src', 'components')
// => ['features/auth/components', 'features/dashboard/components']Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin the search |
§patterns | string | string[ | Glob patterns (e.g., '.ts', '/.json') to filter files |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding files by pattern
import { findFiles } from '@hyperfrontend/project-scope'
// Find all TypeScript files
const tsFiles = findFiles('./src', '\*\*/*.ts')
// Find multiple file types
const configFiles = findFiles('./', ['\*.json', '\*.yaml', '\*.yml'])
// Limit results and get absolute paths
const first10 = findFiles('./src', '\*\*/*.ts', {
maxResults: 10,
absolutePaths: true
})Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | In-memory virtual file system representation |
§patterns | string | string[ | Glob patterns (e.g., '.ts', '/.json') to filter files |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding files in a virtual tree
import { createTree, findFilesInTree } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
const tsFiles = findFilesInTree(tree, '**/*.ts', { maxDepth: 3 })
// => ['src/index.ts', 'src/utils/helpers.ts']Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding Git repository root
import { findGitRoot } from '@hyperfrontend/project-scope'
const gitRoot = findGitRoot('./src/deep/nested/file.ts')
// => '/path/to/repository'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding nearest package.json
import { findNearestPackageJson } from '@hyperfrontend/project-scope'
const pkgDir = findNearestPackageJson('./src/deep/nested/file.ts')
// => '/path/to/project'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding project root
import { findProjectRoot } from '@hyperfrontend/project-scope'
// Find project root from current directory
const root = findProjectRoot(process.cwd())
if (root) {
console.log('Project root:', root)
}
// Find root from a deeply nested file
const root2 = findProjectRoot('./libs/my-lib/src/utils/helper.ts')Parameters
Returns
stringExample
Finding root by marker files
import { findRootDirectory } from '@hyperfrontend/project-scope'
// Find monorepo root by looking for nx.json or lerna.json
const root = findRootDirectory('./libs/my-lib', ['nx.json', 'lerna.json'])
// => '/path/to/monorepo'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding workspace root
import { findWorkspaceRoot } from '@hyperfrontend/project-scope'
const root = findWorkspaceRoot('./libs/my-lib')
if (root) {
console.log('Monorepo root:', root) // e.g., '/home/user/my-monorepo'
}Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting all merged dependencies
import { getAllDependencies } from '@hyperfrontend/project-scope'
const allDeps = getAllDependencies(packageJson)
if ('typescript' in allDeps) {
console.log('TypeScript version:', allDeps['typescript'])
}Parameters
| Name | Type | Description |
|---|---|---|
§types | ConfigType[ | Array of config types to get patterns for |
Returns
string[ ]Example
Retrieving config patterns by type
import { getConfigPatternsByType } from '@hyperfrontend/project-scope'
const patterns = getConfigPatternsByType(['typescript', 'eslint'])
// => ['tsconfig.json', 'tsconfig.*.json', '.eslintrc', '.eslintrc.js', ...]Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
AllDependenciesExample
Extracting all dependencies
import { getDependencies } from '@hyperfrontend/project-scope'
const deps = getDependencies(packageJson)
console.log('Runtime:', Object.keys(deps.dependencies))
console.log('Dev:', Object.keys(deps.devDependencies))Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json content |
§name | string | Name of the dependency to look up |
Returns
stringExample
Getting dependency version
import { getDependencyVersion } from '@hyperfrontend/project-scope'
const version = getDependencyVersion(packageJson, 'react')
// => '^18.2.0' or nullParameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting development dependencies
import { getDevDependencies } from '@hyperfrontend/project-scope'
const devDeps = getDevDependencies(packageJson)
// => { 'jest': '^29.0.0', 'typescript': '^5.0.0' }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting peer dependencies
import { getPeerDependencies } from '@hyperfrontend/project-scope'
const peerDeps = getPeerDependencies(packageJson)
// => { 'react': '^18.0.0', 'react-dom': '^18.0.0' }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting production dependencies
import { getProductionDependencies } from '@hyperfrontend/project-scope'
const prodDeps = getProductionDependencies(packageJson)
// => { 'express': '^4.18.0', 'lodash': '^4.17.21' }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
string[ ]Example
Getting workspace patterns
import { getWorkspaces } from '@hyperfrontend/project-scope'
const patterns = getWorkspaces(packageJson)
// => ['packages/*', 'apps/*']hasDependency( packageJson: PackageJson, name: string, depTypes?: ( "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies")[ ]): boolean
Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json content |
§name | string | Name of the dependency to check |
§depTypes? | ( | Optional array of dependency types to check (defaults to all) |
Returns
booleanExample
Checking for a dependency
import { hasDependency } from '@hyperfrontend/project-scope'
// Check any dependency type
hasDependency(packageJson, 'lodash')
// Check only production dependencies
hasDependency(packageJson, 'lodash', ['dependencies'])Parameters
Returns
booleanExample
Checking installed packages
import { hasInstalledPackage } from '@hyperfrontend/project-scope'
if (hasInstalledPackage('/project', 'typescript')) {
console.log('TypeScript is installed')
}Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
booleanExample
Checking for workspaces
import { hasWorkspaces } from '@hyperfrontend/project-scope'
if (hasWorkspaces(packageJson)) {
console.log('This is a monorepo')
}Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to config file |
§type? | ConfigType | Optional config type (auto-detected if not provided) |
Returns
ParsedConfigExample
Parsing a configuration file
import { parseConfig } from '@hyperfrontend/project-scope'
const tsConfig = parseConfig('/project/tsconfig.json')
const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint')parseJsonConfig( filePath: string, content: string, type?: ConfigType, format: "json" | "jsonc"): ParsedConfig
Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to the JSON configuration file |
§content | string | Raw file content to parse |
§type? | ConfigType | Category of configuration (e.g., typescript, eslint) |
§format | "json" | "jsonc" | Whether to strip comments (jsonc) or parse strictly (json)(default: 'json') |
Returns
ParsedConfigExample
Parsing JSON configuration
import { parseJsonConfig } from '@hyperfrontend/project-scope'
const config = parseJsonConfig(
'tsconfig.json',
'{ "extends": "./base.json", "compilerOptions": {} }',
'typescript'
)
// => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to the YAML configuration file |
§content | string | Raw file content to parse |
§type? | ConfigType | Category of configuration (e.g., github-actions, docker-compose) |
Returns
ParsedConfigExample
Parsing YAML configuration
import { parseYamlConfig } from '@hyperfrontend/project-scope'
const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions')
// => { type: 'github-actions', path: '...', format: 'yaml', data: {...} }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path or path to package.json |
Returns
PackageJsonExample
Reading package.json
import { readPackageJson } from '@hyperfrontend/project-scope'
const pkg = readPackageJson('/path/to/project')
console.log(pkg.name, pkg.version)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path or path to package.json |
Returns
PackageJsonExample
Reading package.json if it exists
import { readPackageJsonIfExists } from '@hyperfrontend/project-scope'
const pkg = readPackageJsonIfExists('/path/to/project')
if (pkg) {
console.log('Found:', pkg.name)
}Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin traversal |
§visitor | WalkVisitor | Callback function invoked for each file system entry |
§options? | WalkOptions | Configuration for traversal behavior |
Example
Walking a directory tree
import { walkDirectory } from '@hyperfrontend/project-scope'
const tsFiles: string[] = []
walkDirectory('./src', (entry) => {
if (entry.isFile && entry.name.endsWith('.ts')) {
tsFiles.push(entry.relativePath)
}
}, { maxDepth: 5, respectGitignore: true })Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | In-memory virtual file system representation |
§startPath | string | Root path within the tree to begin traversal |
§visitor | WalkVisitor | Callback function invoked for each tree entry |
§options? | WalkOptions | Configuration for traversal behavior |
Example
Walking a virtual tree
import { createTree, walkTree } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
walkTree(tree, 'src', (entry) => {
if (entry.isDirectory) {
console.log('Dir:', entry.relativePath)
return 'skip' // Don't recurse into this directory
}
})◈ Interfaces
Properties
Properties
format?:"json" | "yaml" | "js" | "ts" | "jsonc" | "ini" | "dotenv" | "text"Primary format (optional - auto-detected from file extension if not provided)Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
type ConfigType = "package.json" | "package-lock.json" | "pnpm-lock.yaml" | "yarn.lock" | ".npmrc" | "tsconfig" | "nx" | "project.json" | "workspace.json" | "turbo" | "lerna" | "webpack" | "rollup" | "vite" | "esbuild" | "babel" | "swc" | "jest" | "vitest" | "cypress" | "playwright" | "next" | "angular" | "nuxt" | "svelte" | "astro" | "eslint" | "prettier" | "env" | ".gitignore" | ".gitattributes"type DependencyMap = Record< string, string>type WalkVisitor = ( entry: WalkEntry) => WalkVisitorResulttype WalkVisitorResult = void | "skip" | "stop"● Variables
Configuration file detection and parsing for various config types with pattern matching.
ƒ Functions
Useful for testing or when the project files have changed.
Example
Clearing the config detection cache
import { clearConfigDetectionCache } from '@hyperfrontend/project-scope'
// Reset cache after modifying config files
clearConfigDetectionCache()detectConfigs( rootPath: string, types?: ConfigType[ ], options?: DetectConfigOptions): DetectedConfig[ ]
Results are cached for 30 seconds per project path and options to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§rootPath | string | Project root directory |
§types? | ConfigType[ | Optional array of config types to check (defaults to all) |
§options? | DetectConfigOptions | Detection options |
Returns
DetectedConfig[ ]Example
Detecting configuration files
import { detectConfigs } from '@hyperfrontend/project-scope'
// Detect all config files
const configs = detectConfigs('./my-project')
for (const config of configs) {
console.log(`${config.type}: ${config.path}`)
}
// Output:
// typescript: tsconfig.json
// eslint: eslint.config.js
// jest: jest.config.ts
// Detect specific config types only
const tsConfigs = detectConfigs('./my-project', ['typescript', 'eslint'])Parameters
| Name | Type | Description |
|---|---|---|
§rootPath | string | Project root directory |
§type | ConfigType | Config type to find |
Returns
stringExample
Finding a specific config file
import { findConfigFile } from '@hyperfrontend/project-scope'
const tsConfig = findConfigFile('/project', 'typescript')
// => '/project/tsconfig.json'
const eslint = findConfigFile('/project', 'eslint')
// => '/project/.eslintrc.js' or null if not foundParameters
| Name | Type | Description |
|---|---|---|
§types | ConfigType[ | Array of config types to get patterns for |
Returns
string[ ]Example
Retrieving config patterns by type
import { getConfigPatternsByType } from '@hyperfrontend/project-scope'
const patterns = getConfigPatternsByType(['typescript', 'eslint'])
// => ['tsconfig.json', 'tsconfig.*.json', '.eslintrc', '.eslintrc.js', ...]Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to config file |
§type? | ConfigType | Optional config type (auto-detected if not provided) |
Returns
ParsedConfigExample
Parsing a configuration file
import { parseConfig } from '@hyperfrontend/project-scope'
const tsConfig = parseConfig('/project/tsconfig.json')
const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint')parseJsonConfig( filePath: string, content: string, type?: ConfigType, format: "json" | "jsonc"): ParsedConfig
Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to the JSON configuration file |
§content | string | Raw file content to parse |
§type? | ConfigType | Category of configuration (e.g., typescript, eslint) |
§format | "json" | "jsonc" | Whether to strip comments (jsonc) or parse strictly (json)(default: 'json') |
Returns
ParsedConfigExample
Parsing JSON configuration
import { parseJsonConfig } from '@hyperfrontend/project-scope'
const config = parseJsonConfig(
'tsconfig.json',
'{ "extends": "./base.json", "compilerOptions": {} }',
'typescript'
)
// => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] }Parameters
| Name | Type | Description |
|---|---|---|
§filePath | string | Path to the YAML configuration file |
§content | string | Raw file content to parse |
§type? | ConfigType | Category of configuration (e.g., github-actions, docker-compose) |
Returns
ParsedConfigExample
Parsing YAML configuration
import { parseYamlConfig } from '@hyperfrontend/project-scope'
const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions')
// => { type: 'github-actions', path: '...', format: 'yaml', data: {...} }◈ Interfaces
Properties
format?:"json" | "yaml" | "js" | "ts" | "jsonc" | "ini" | "dotenv" | "text"Primary format (optional - auto-detected from file extension if not provided)Properties
Properties
Properties
◆ Types
type ConfigType = "package.json" | "package-lock.json" | "pnpm-lock.yaml" | "yarn.lock" | ".npmrc" | "tsconfig" | "nx" | "project.json" | "workspace.json" | "turbo" | "lerna" | "webpack" | "rollup" | "vite" | "esbuild" | "babel" | "swc" | "jest" | "vitest" | "cypress" | "playwright" | "next" | "angular" | "nuxt" | "svelte" | "astro" | "eslint" | "prettier" | "env" | ".gitignore" | ".gitattributes"● Variables
Package.json reading and dependency inspection utilities with version checks.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding nearest package.json
import { findNearestPackageJson } from '@hyperfrontend/project-scope'
const pkgDir = findNearestPackageJson('./src/deep/nested/file.ts')
// => '/path/to/project'Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting all merged dependencies
import { getAllDependencies } from '@hyperfrontend/project-scope'
const allDeps = getAllDependencies(packageJson)
if ('typescript' in allDeps) {
console.log('TypeScript version:', allDeps['typescript'])
}Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
AllDependenciesExample
Extracting all dependencies
import { getDependencies } from '@hyperfrontend/project-scope'
const deps = getDependencies(packageJson)
console.log('Runtime:', Object.keys(deps.dependencies))
console.log('Dev:', Object.keys(deps.devDependencies))Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json content |
§name | string | Name of the dependency to look up |
Returns
stringExample
Getting dependency version
import { getDependencyVersion } from '@hyperfrontend/project-scope'
const version = getDependencyVersion(packageJson, 'react')
// => '^18.2.0' or nullParameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting development dependencies
import { getDevDependencies } from '@hyperfrontend/project-scope'
const devDeps = getDevDependencies(packageJson)
// => { 'jest': '^29.0.0', 'typescript': '^5.0.0' }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting peer dependencies
import { getPeerDependencies } from '@hyperfrontend/project-scope'
const peerDeps = getPeerDependencies(packageJson)
// => { 'react': '^18.0.0', 'react-dom': '^18.0.0' }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
DependencyMapExample
Getting production dependencies
import { getProductionDependencies } from '@hyperfrontend/project-scope'
const prodDeps = getProductionDependencies(packageJson)
// => { 'express': '^4.18.0', 'lodash': '^4.17.21' }Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
string[ ]Example
Getting workspace patterns
import { getWorkspaces } from '@hyperfrontend/project-scope'
const patterns = getWorkspaces(packageJson)
// => ['packages/*', 'apps/*']hasDependency( packageJson: PackageJson, name: string, depTypes?: ( "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies")[ ]): boolean
Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json content |
§name | string | Name of the dependency to check |
§depTypes? | ( | Optional array of dependency types to check (defaults to all) |
Returns
booleanExample
Checking for a dependency
import { hasDependency } from '@hyperfrontend/project-scope'
// Check any dependency type
hasDependency(packageJson, 'lodash')
// Check only production dependencies
hasDependency(packageJson, 'lodash', ['dependencies'])Parameters
Returns
booleanExample
Checking installed packages
import { hasInstalledPackage } from '@hyperfrontend/project-scope'
if (hasInstalledPackage('/project', 'typescript')) {
console.log('TypeScript is installed')
}Parameters
| Name | Type | Description |
|---|---|---|
§packageJson | PackageJson | Parsed package.json |
Returns
booleanExample
Checking for workspaces
import { hasWorkspaces } from '@hyperfrontend/project-scope'
if (hasWorkspaces(packageJson)) {
console.log('This is a monorepo')
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path or path to package.json |
Returns
PackageJsonExample
Reading package.json
import { readPackageJson } from '@hyperfrontend/project-scope'
const pkg = readPackageJson('/path/to/project')
console.log(pkg.name, pkg.version)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path or path to package.json |
Returns
PackageJsonExample
Reading package.json if it exists
import { readPackageJsonIfExists } from '@hyperfrontend/project-scope'
const pkg = readPackageJsonIfExists('/path/to/project')
if (pkg) {
console.log('Found:', pkg.name)
}◈ Interfaces
Properties
Properties
◆ Types
type DependencyMap = Record< string, string>Root directory detection using marker files for git root, project root, and workspace root.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding Git repository root
import { findGitRoot } from '@hyperfrontend/project-scope'
const gitRoot = findGitRoot('./src/deep/nested/file.ts')
// => '/path/to/repository'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding project root
import { findProjectRoot } from '@hyperfrontend/project-scope'
// Find project root from current directory
const root = findProjectRoot(process.cwd())
if (root) {
console.log('Project root:', root)
}
// Find root from a deeply nested file
const root2 = findProjectRoot('./libs/my-lib/src/utils/helper.ts')Parameters
Returns
stringExample
Finding root by marker files
import { findRootDirectory } from '@hyperfrontend/project-scope'
// Find monorepo root by looking for nx.json or lerna.json
const root = findRootDirectory('./libs/my-lib', ['nx.json', 'lerna.json'])
// => '/path/to/monorepo'Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Starting path |
Returns
stringExample
Finding workspace root
import { findWorkspaceRoot } from '@hyperfrontend/project-scope'
const root = findWorkspaceRoot('./libs/my-lib')
if (root) {
console.log('Monorepo root:', root) // e.g., '/home/user/my-monorepo'
}● Variables
Directory walking and file search utilities with visitor patterns for recursive exploration.
ƒ Functions
findDirectories( startPath: string, patterns: string | string[ ], options?: FindOptions): string[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin the search |
§patterns | string | string[ | Glob patterns to filter directories (supports wildcards) |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding directories by pattern
import { findDirectories } from '@hyperfrontend/project-scope'
const componentDirs = findDirectories('./src', 'components')
// => ['features/auth/components', 'features/dashboard/components']Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin the search |
§patterns | string | string[ | Glob patterns (e.g., '.ts', '/.json') to filter files |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding files by pattern
import { findFiles } from '@hyperfrontend/project-scope'
// Find all TypeScript files
const tsFiles = findFiles('./src', '\*\*/*.ts')
// Find multiple file types
const configFiles = findFiles('./', ['\*.json', '\*.yaml', '\*.yml'])
// Limit results and get absolute paths
const first10 = findFiles('./src', '\*\*/*.ts', {
maxResults: 10,
absolutePaths: true
})Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | In-memory virtual file system representation |
§patterns | string | string[ | Glob patterns (e.g., '.ts', '/.json') to filter files |
§options? | FindOptions | Configuration for search behavior |
Returns
string[ ]Example
Finding files in a virtual tree
import { createTree, findFilesInTree } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
const tsFiles = findFilesInTree(tree, '**/*.ts', { maxDepth: 3 })
// => ['src/index.ts', 'src/utils/helpers.ts']Parameters
| Name | Type | Description |
|---|---|---|
§startPath | string | Root directory to begin traversal |
§visitor | WalkVisitor | Callback function invoked for each file system entry |
§options? | WalkOptions | Configuration for traversal behavior |
Example
Walking a directory tree
import { walkDirectory } from '@hyperfrontend/project-scope'
const tsFiles: string[] = []
walkDirectory('./src', (entry) => {
if (entry.isFile && entry.name.endsWith('.ts')) {
tsFiles.push(entry.relativePath)
}
}, { maxDepth: 5, respectGitignore: true })Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | In-memory virtual file system representation |
§startPath | string | Root path within the tree to begin traversal |
§visitor | WalkVisitor | Callback function invoked for each tree entry |
§options? | WalkOptions | Configuration for traversal behavior |
Example
Walking a virtual tree
import { createTree, walkTree } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
walkTree(tree, 'src', (entry) => {
if (entry.isDirectory) {
console.log('Dir:', entry.relativePath)
return 'skip' // Don't recurse into this directory
}
})◈ Interfaces
Properties
Properties
◆ Types
type WalkVisitor = ( entry: WalkEntry) => WalkVisitorResulttype WalkVisitorResult = void | "skip" | "stop"Tech stack detection for frontend, backend, build tools, testing, linting, and monorepo tools.
ƒ Functions
Useful for testing or when the project files have changed.
Example
Clearing the tech detection cache
import { detectAll, clearTechDetectionCache } from '@hyperfrontend/project-scope'
// Initial detection (cached)
const first = detectAll('./my-project')
// After modifying package.json, clear cache to re-detect
clearTechDetectionCache()
const fresh = detectAll('./my-project')detectAll( projectPath: string, packageJsonOrOptions?: PackageJson | DetectAllOptions): AllDetections
Results are cached for 60 seconds per project path to avoid redundant file system operations on repeated calls.
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Path to project directory |
§packageJsonOrOptions? | PackageJson | DetectAllOptions | Optional pre-loaded package.json or options object |
Returns
AllDetectionsExample
Running all tech detectors
import { detectAll } from '@hyperfrontend/project-scope'
const detections = detectAll('./my-project')
// Check frontend frameworks
for (const fw of detections.frontendFrameworks) {
console.log(`${fw.name} v${fw.version} (${fw.confidence}% confidence)`)
}
// Check build tools
console.log('Build tools:', detections.buildTools.map(t => t.name))
// Check testing frameworks
console.log('Testing:', detections.testingFrameworks.map(t => t.name))Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Angular framework
const result = angularDetector('/path/to/angular-app', {
dependencies: { '@angular/core': '^17.0.0', '@angular/cli': '^17.0.0' }
})
// => {
// id: 'angular',
// name: 'Angular',
// category: 'frontend',
// version: '17.0.0',
// confidence: 85,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@angular/core' },
// { type: 'package.json', field: 'dependencies.@angular/cli' }
// ]
// }angularJSDetector( projectPath: string, packageJson?: PackageJson): LegacyFrameworkDetection
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting AngularJS framework
const result = angularJSDetector('/path/to/project', {
dependencies: { angular: '^1.8.0', 'angular-route': '^1.8.0' },
})
// => { id: 'angularjs', name: 'AngularJS', confidence: 85, version: '1.8.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Astro framework
const result = astroDetector('/path/to/astro-project', {
dependencies: { 'astro': '^4.0.0' }
})
// => {
// id: 'astro',
// name: 'Astro',
// category: 'meta-framework',
// version: '4.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.astro' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Babel compiler
const result = babelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@babel/core': '^7.23.0', '@babel/preset-env': '^7.23.0' }
})
// => {
// id: 'babel',
// name: 'Babel',
// version: '7.23.0',
// confidence: 60,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@babel/core' },
// { type: 'package.json', field: 'dependencies (@babel packages)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting Backbone.js framework
const result = backboneDetector('/path/to/project', {
dependencies: { backbone: '^1.4.0', underscore: '^1.13.0' },
})
// => { id: 'backbone', name: 'Backbone.js', confidence: 85, version: '1.4.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Biome linter
const result = biomeDetector('/path/to/project', {
devDependencies: { '@biomejs/biome': '^1.5.0' },
})
// => { id: 'biome', name: 'Biome', confidence: 70, version: '1.5.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Cypress testing framework
import { cypressDetector } from '@hyperfrontend/project-scope'
const result = cypressDetector('./my-project')
if (result) {
console.log(`Cypress ${result.version} detected (${result.confidence}% confidence)`)
// => "Cypress 13.6.0 detected (95% confidence)"
}detectBackendFrameworks( projectPath: string, packageJson?: PackageJson): BackendDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetection[ ]Example
Detecting multiple backend frameworks
const pkg = {
dependencies: { '@nestjs/core': '^10.0.0', '@nestjs/common': '^10.0.0' },
devDependencies: { express: '^4.18.0' },
}
const results = detectBackendFrameworks('/path/to/project', pkg)
// => [
// { id: 'nestjs', name: 'NestJS', confidence: 85, ... },
// { id: 'express', name: 'Express', confidence: 80, ... },
// ]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetection[ ]Example
Detecting multiple build tools
const tools = detectBuildTools('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'@babel/core': '^7.23.0'
}
})
// => [
// { id: 'vite', name: 'Vite', version: '5.0.0', confidence: 70, ... },
// { id: 'babel', name: 'Babel', version: '7.23.0', confidence: 50, ... }
// ]detectFrontendFrameworks( projectPath: string, packageJson?: PackageJson): FrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetection[ ]Example
Detecting multiple frontend frameworks
const frameworks = detectFrontendFrameworks('/path/to/nextjs-app', {
dependencies: { 'react': '^18.0.0', 'next': '^14.0.0' }
})
// => [
// { id: 'nextjs', name: 'Next.js', category: 'meta-framework', confidence: 70, ... },
// { id: 'react', name: 'React', category: 'frontend', confidence: 60, ... }
// ]detectLegacyFrameworks( projectPath: string, packageJson?: PackageJson): LegacyFrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetection[ ]Example
Detecting legacy frameworks
const results = detectLegacyFrameworks('/path/to/project', {
dependencies: { jquery: '^3.6.0', backbone: '^1.4.0' },
})
// => [{ id: 'jquery', confidence: 80 }, { id: 'backbone', confidence: 70 }]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetection[ ]Example
Detecting multiple linting tools
const results = detectLintingTools('/path/to/project', {
devDependencies: { eslint: '^8.0.0', prettier: '^3.0.0' },
})
// => [{ id: 'eslint', confidence: 50 }, { id: 'prettier', confidence: 50 }]Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetection[ ]Example
Detecting monorepo tools
const detections = detectMonorepoTools('/path/to/project')
// => [
// { id: 'nx', name: 'NX', confidence: 90, configPath: 'nx.json', detectedFrom: [...] },
// { id: 'npm-workspaces', name: 'npm Workspaces', confidence: 80, ... }
// ]detectTestingFrameworks( projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetection[ ]Example
Detecting multiple testing frameworks
import { detectTestingFrameworks } from '@hyperfrontend/project-scope'
const frameworks = detectTestingFrameworks('./my-project')
// => [
// { id: 'jest', name: 'Jest', type: 'unit', confidence: 95, ... },
// { id: 'cypress', name: 'Cypress', type: 'e2e', confidence: 85, ... }
// ]
// Results are sorted by confidence (highest first)
const primary = frameworks[0]?.name ?? 'None'
console.log(`Primary testing framework: ${primary}`)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetection[ ]Example
Detecting all type systems
import { detectTypeSystems } from '@hyperfrontend/project-scope'
const typeSystems = detectTypeSystems('./my-project')
// => [
// { id: 'typescript', name: 'TypeScript', version: '5.3.0', strictMode: true, confidence: 95, ... },
// { id: 'jsdoc', name: 'JSDoc', confidence: 40, ... }
// ]
const primary = typeSystems[0]?.name ?? 'None'
console.log(`Primary type system: ${primary}`)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting Ember.js framework
const result = emberDetector('/path/to/project', {
dependencies: { 'ember-source': '^4.0.0' },
devDependencies: { 'ember-cli': '^4.0.0' },
})
// => { id: 'ember', name: 'Ember.js', confidence: 90, version: '4.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting esbuild bundler
const result = esbuildDetector('/path/to/project', {
name: 'my-lib',
devDependencies: { 'esbuild': '^0.19.0' },
scripts: { 'build': 'esbuild src/index.ts --bundle --outfile=dist/index.js' }
})
// => {
// id: 'esbuild',
// name: 'esbuild',
// version: '0.19.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.esbuild' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting ESLint linter
const result = eslintDetector('/path/to/project', {
devDependencies: { eslint: '^8.50.0', '@typescript-eslint/parser': '^6.0.0' },
scripts: { lint: 'eslint src/' },
})
// => { id: 'eslint', name: 'ESLint', confidence: 65, version: '8.50.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Express framework
const pkg = {
dependencies: { express: '^4.18.2', cors: '^2.8.5' },
devDependencies: { '@types/express': '^4.17.17' },
}
const result = expressDetector('/path/to/project', pkg)
// => {
// id: 'express',
// name: 'Express',
// version: '4.18.2',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.express' },
// { type: 'package.json', field: 'dependencies.@types/express' },
// { type: 'package.json', field: 'dependencies (express middleware)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Fastify framework
const pkg = {
dependencies: { fastify: '^4.24.0', '@fastify/cors': '^8.4.0' },
}
const result = fastifyDetector('/path/to/project', pkg)
// => {
// id: 'fastify',
// name: 'Fastify',
// version: '4.24.0',
// confidence: 95,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.fastify' },
// { type: 'package.json', field: 'dependencies (fastify plugins)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting Flow type system
import { flowDetector } from '@hyperfrontend/project-scope'
const result = flowDetector('./my-project')
if (result) {
console.log(`Flow ${result.version} with config: ${result.configPath}`)
// => "Flow 0.232.0 with config: .flowconfig"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Gatsby framework
const result = gatsbyDetector('/path/to/gatsby-blog', {
dependencies: {
'gatsby': '^5.0.0',
'gatsby-plugin-image': '^3.0.0',
'gatsby-source-filesystem': '^5.0.0'
}
})
// => {
// id: 'gatsby',
// name: 'Gatsby',
// category: 'meta-framework',
// version: '5.0.0',
// confidence: 75,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.gatsby' },
// { type: 'package.json', field: 'dependencies (gatsby plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Hono framework
const pkg = {
dependencies: { hono: '^3.11.0', '@hono/node-server': '^1.3.0' },
}
const result = honoDetector('/path/to/project', pkg)
// => {
// id: 'hono',
// name: 'Hono',
// version: '3.11.0',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.hono' },
// { type: 'package.json', field: 'dependencies (@hono adapters)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Jest testing framework
import { jestDetector } from '@hyperfrontend/project-scope'
const result = jestDetector('./my-project')
if (result) {
console.log(`Jest ${result.version} detected`)
console.log('Sources:', result.detectedFrom.map(s => s.type))
// => "Sources: ['package.json', 'config-file']"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting jQuery library
const result = jqueryDetector('/path/to/project', {
dependencies: { jquery: '^3.6.0', 'jquery-ui': '^1.13.0' },
})
// => { id: 'jquery', name: 'jQuery', confidence: 90, version: '3.6.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting JSDoc type annotations
import { jsdocDetector } from '@hyperfrontend/project-scope'
const result = jsdocDetector('./my-project')
if (result) {
console.log('JSDoc types detected')
console.log('Sources:', result.detectedFrom.map(s => s.path ?? s.field))
// => "Sources: ['jsconfig.json', 'src/utils.js (JSDoc annotations)']"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Koa framework
const pkg = {
dependencies: { koa: '^2.14.2', 'koa-router': '^12.0.0' },
devDependencies: { '@types/koa': '^2.13.9' },
}
const result = koaDetector('/path/to/project', pkg)
// => {
// id: 'koa',
// name: 'Koa',
// version: '2.14.2',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.koa' },
// { type: 'package.json', field: 'dependencies.@types/koa' },
// { type: 'package.json', field: 'dependencies (koa middleware)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Lerna monorepo
// Project with lerna.json config file
const result = lernaDetector('/path/to/lerna-project')
// => {
// id: 'lerna',
// name: 'Lerna',
// confidence: 80,
// configPath: 'lerna.json',
// detectedFrom: [{ type: 'config-file', path: 'lerna.json' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Mocha testing framework
import { mochaDetector } from '@hyperfrontend/project-scope'
const result = mochaDetector('./my-project')
if (result) {
console.log(`Mocha ${result.version} detected (${result.confidence}%)`)
// => "Mocha 10.2.0 detected (95%)"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting NestJS framework
// Project with nest-cli.json and NestJS packages
const pkg = {
dependencies: {
'@nestjs/core': '^10.2.0',
'@nestjs/common': '^10.2.0',
'@nestjs/platform-express': '^10.2.0',
},
}
const result = nestDetector('/path/to/nest-project', pkg)
// => {
// id: 'nestjs',
// name: 'NestJS',
// version: '10.2.0',
// configPath: 'nest-cli.json', // if present
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@nestjs/core' },
// { type: 'package.json', field: 'dependencies.@nestjs/common' },
// { type: 'config-file', path: 'nest-cli.json' },
// { type: 'package.json', field: 'dependencies (@nestjs packages)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Next.js framework
const result = nextjsDetector('/path/to/nextjs-app', {
dependencies: { 'next': '^14.0.0', 'react': '^18.0.0' }
})
// => {
// id: 'nextjs',
// name: 'Next.js',
// category: 'meta-framework',
// version: '14.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.next' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting npm workspaces
// Project with workspaces in package.json and package-lock.json
const result = npmWorkspacesDetector('/path/to/npm-project')
// => {
// id: 'npm-workspaces',
// name: 'npm Workspaces',
// confidence: 90,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'package-lock.json' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Nuxt framework
const result = nuxtDetector('/path/to/nuxt-app', {
dependencies: { 'nuxt': '^3.0.0', 'vue': '^3.0.0' }
})
// => {
// id: 'nuxt',
// name: 'Nuxt',
// category: 'meta-framework',
// version: '3.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.nuxt' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting NX workspace
// Project with nx.json and apps/libs directories
const result = nxDetector('/path/to/nx-workspace')
// => {
// id: 'nx',
// name: 'NX',
// confidence: 100,
// configPath: 'nx.json',
// version: '17.0.0',
// workspaceLayout: { appsDir: 'apps', libsDir: 'libs' },
// detectedFrom: [
// { type: 'config-file', path: 'nx.json' },
// { type: 'package.json', field: 'dependencies.nx' },
// { type: 'directory', path: 'apps/ or libs/' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Parcel bundler
const result = parcelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'parcel': '^2.10.0' },
scripts: { 'dev': 'parcel src/index.html', 'build': 'parcel build src/index.html' }
})
// => {
// id: 'parcel',
// name: 'Parcel',
// version: '2.10.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.parcel' },
// { type: 'package.json', field: 'scripts.dev' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }playwrightDetector( projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Playwright testing framework
import { playwrightDetector } from '@hyperfrontend/project-scope'
const result = playwrightDetector('./my-project')
if (result) {
console.log(`Playwright ${result.version} (${result.type} tests)`)
// => "Playwright 1.42.0 (e2e tests)"
}Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
Returns
MonorepoDetectionExample
Detecting pnpm workspaces
// Project with pnpm-workspace.yaml
const result = pnpmWorkspacesDetector('/path/to/pnpm-project')
// => {
// id: 'pnpm-workspaces',
// name: 'pnpm Workspaces',
// confidence: 100,
// configPath: 'pnpm-workspace.yaml',
// detectedFrom: [
// { type: 'config-file', path: 'pnpm-workspace.yaml' },
// { type: 'lockfile', path: 'pnpm-lock.yaml' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Prettier formatter
const result = prettierDetector('/path/to/project', {
devDependencies: { prettier: '^3.0.0' },
scripts: { format: 'prettier --write .' },
})
// => { id: 'prettier', name: 'Prettier', confidence: 55, version: '3.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Qwik framework
const result = qwikDetector('/path/to/qwik-app', {
dependencies: {
'@builder.io/qwik': '^1.0.0',
'@builder.io/qwik-city': '^1.0.0'
}
})
// => {
// id: 'qwik',
// name: 'Qwik',
// category: 'frontend',
// version: '1.0.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@builder.io/qwik' },
// { type: 'package.json', field: 'dependencies.@builder.io/qwik-city' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting React library
const result = reactDetector('/path/to/react-app', {
dependencies: { 'react': '^18.0.0', 'react-dom': '^18.0.0' }
})
// => {
// id: 'react',
// name: 'React',
// category: 'frontend',
// version: '18.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.react' },
// { type: 'package.json', field: 'dependencies.react-dom' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Remix framework
const result = remixDetector('/path/to/remix-app', {
dependencies: {
'@remix-run/react': '^2.0.0',
'@remix-run/node': '^2.0.0'
}
})
// => {
// id: 'remix',
// name: 'Remix',
// category: 'meta-framework',
// version: '2.0.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@remix-run/react' },
// { type: 'package.json', field: 'dependencies.@remix-run/*' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Rollup bundler
const result = rollupDetector('/path/to/project', {
name: 'my-lib',
devDependencies: {
'rollup': '^4.0.0',
'@rollup/plugin-node-resolve': '^15.0.0',
'@rollup/plugin-commonjs': '^25.0.0'
}
})
// => {
// id: 'rollup',
// name: 'Rollup',
// version: '4.0.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.rollup' },
// { type: 'package.json', field: 'dependencies (rollup plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Rush monorepo
// Project with rush.json config file
const result = rushDetector('/path/to/rush-project')
// => {
// id: 'rush',
// name: 'Rush',
// confidence: 90,
// configPath: 'rush.json',
// detectedFrom: [{ type: 'config-file', path: 'rush.json' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Solid.js framework
const result = solidDetector('/path/to/solid-app', {
dependencies: { 'solid-js': '^1.8.0', 'vite-plugin-solid': '^2.0.0' }
})
// => {
// id: 'solid',
// name: 'Solid',
// category: 'frontend',
// version: '1.8.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.solid-js' },
// { type: 'package.json', field: 'dependencies.vite-plugin-solid' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Stylelint linter
const result = stylelintDetector('/path/to/project', {
devDependencies: { stylelint: '^15.0.0', 'stylelint-config-standard': '^30.0.0' },
})
// => { id: 'stylelint', name: 'Stylelint', confidence: 65, version: '15.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Svelte framework
const result = svelteDetector('/path/to/svelte-app', {
devDependencies: { 'svelte': '^4.0.0' }
})
// => {
// id: 'svelte',
// name: 'Svelte',
// category: 'frontend',
// version: '4.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.svelte' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting SvelteKit framework
const result = sveltekitDetector('/path/to/sveltekit-app', {
devDependencies: { '@sveltejs/kit': '^2.0.0', 'svelte': '^4.0.0' }
})
// => {
// id: 'sveltekit',
// name: 'SvelteKit',
// category: 'meta-framework',
// version: '2.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.@sveltejs/kit' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting SWC compiler
const result = swcDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@swc/core': '^1.3.0', '@swc/cli': '^0.1.0' }
})
// => {
// id: 'swc',
// name: 'SWC',
// version: '1.3.0',
// confidence: 70,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@swc/core' },
// { type: 'package.json', field: 'dependencies.@swc/cli' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Turborepo monorepo
// Project with turbo.json and turbo dependency
const result = turborepoDetector('/path/to/turbo-project')
// => {
// id: 'turborepo',
// name: 'Turborepo',
// confidence: 95,
// configPath: 'turbo.json',
// version: '2.0.0',
// detectedFrom: [
// { type: 'config-file', path: 'turbo.json' },
// { type: 'package.json', field: 'dependencies.turbo' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting TypeScript
import { typescriptDetector } from '@hyperfrontend/project-scope'
const result = typescriptDetector('./my-project')
if (result) {
console.log(`TypeScript ${result.version}`)
console.log(`Strict mode: ${result.strictMode ?? 'unknown'}`)
// => "TypeScript 5.3.0"
// => "Strict mode: true"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Vite build tool
const result = viteDetector('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'vitest': '^1.0.0'
}
})
// => {
// id: 'vite',
// name: 'Vite',
// version: '5.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vite' },
// { type: 'package.json', field: 'dependencies.vitest' },
// { type: 'package.json', field: 'dependencies (vite plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Vitest testing framework
import { vitestDetector } from '@hyperfrontend/project-scope'
const result = vitestDetector('./my-project')
if (result) {
console.log(`Vitest ${result.version} detected`)
console.log('Config:', result.configPath)
// => "Config: vitest.config.ts"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Vue.js framework
const result = vueDetector('/path/to/vue-app', {
dependencies: { 'vue': '^3.0.0', '@vue/cli-service': '^5.0.0' }
})
// => {
// id: 'vue',
// name: 'Vue',
// category: 'frontend',
// version: '3.0.0',
// confidence: 85,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vue' },
// { type: 'package.json', field: 'dependencies.@vue/cli-service' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Webpack bundler
const result = webpackDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'webpack': '^5.89.0', 'webpack-cli': '^5.1.0' },
scripts: { 'build': 'webpack --mode production' }
})
// => {
// id: 'webpack',
// name: 'Webpack',
// version: '5.89.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.webpack' },
// { type: 'package.json', field: 'dependencies.webpack-cli' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }yarnWorkspacesDetector( workspacePath: string, packageJson?: PackageJson): MonorepoDetection
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting yarn workspaces
// Project with workspaces in package.json and yarn.lock
const result = yarnWorkspacesDetector('/path/to/yarn-project')
// => {
// id: 'yarn-workspaces',
// name: 'Yarn Workspaces',
// confidence: 100,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'yarn.lock' },
// { type: 'config-file', path: '.yarnrc.yml' }
// ]
// }◈ Interfaces
Properties
legacyFrameworks:LegacyFrameworkDetection[ ]Detected legacy frameworks (AngularJS, Backbone, Ember, jQuery)Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
● Variables
Backend framework detection for Express, NestJS, Fastify, Koa, and Hono.
ƒ Functions
detectBackendFrameworks( projectPath: string, packageJson?: PackageJson): BackendDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetection[ ]Example
Detecting multiple backend frameworks
const pkg = {
dependencies: { '@nestjs/core': '^10.0.0', '@nestjs/common': '^10.0.0' },
devDependencies: { express: '^4.18.0' },
}
const results = detectBackendFrameworks('/path/to/project', pkg)
// => [
// { id: 'nestjs', name: 'NestJS', confidence: 85, ... },
// { id: 'express', name: 'Express', confidence: 80, ... },
// ]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Express framework
const pkg = {
dependencies: { express: '^4.18.2', cors: '^2.8.5' },
devDependencies: { '@types/express': '^4.17.17' },
}
const result = expressDetector('/path/to/project', pkg)
// => {
// id: 'express',
// name: 'Express',
// version: '4.18.2',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.express' },
// { type: 'package.json', field: 'dependencies.@types/express' },
// { type: 'package.json', field: 'dependencies (express middleware)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Fastify framework
const pkg = {
dependencies: { fastify: '^4.24.0', '@fastify/cors': '^8.4.0' },
}
const result = fastifyDetector('/path/to/project', pkg)
// => {
// id: 'fastify',
// name: 'Fastify',
// version: '4.24.0',
// confidence: 95,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.fastify' },
// { type: 'package.json', field: 'dependencies (fastify plugins)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Hono framework
const pkg = {
dependencies: { hono: '^3.11.0', '@hono/node-server': '^1.3.0' },
}
const result = honoDetector('/path/to/project', pkg)
// => {
// id: 'hono',
// name: 'Hono',
// version: '3.11.0',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.hono' },
// { type: 'package.json', field: 'dependencies (@hono adapters)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting Koa framework
const pkg = {
dependencies: { koa: '^2.14.2', 'koa-router': '^12.0.0' },
devDependencies: { '@types/koa': '^2.13.9' },
}
const result = koaDetector('/path/to/project', pkg)
// => {
// id: 'koa',
// name: 'Koa',
// version: '2.14.2',
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.koa' },
// { type: 'package.json', field: 'dependencies.@types/koa' },
// { type: 'package.json', field: 'dependencies (koa middleware)' },
// ],
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BackendDetectionExample
Detecting NestJS framework
// Project with nest-cli.json and NestJS packages
const pkg = {
dependencies: {
'@nestjs/core': '^10.2.0',
'@nestjs/common': '^10.2.0',
'@nestjs/platform-express': '^10.2.0',
},
}
const result = nestDetector('/path/to/nest-project', pkg)
// => {
// id: 'nestjs',
// name: 'NestJS',
// version: '10.2.0',
// configPath: 'nest-cli.json', // if present
// confidence: 100,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@nestjs/core' },
// { type: 'package.json', field: 'dependencies.@nestjs/common' },
// { type: 'config-file', path: 'nest-cli.json' },
// { type: 'package.json', field: 'dependencies (@nestjs packages)' },
// ],
// }◈ Interfaces
Properties
● Variables
Build tool detection for Webpack, Vite, Rollup, esbuild, Babel, SWC, and Parcel.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Babel compiler
const result = babelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@babel/core': '^7.23.0', '@babel/preset-env': '^7.23.0' }
})
// => {
// id: 'babel',
// name: 'Babel',
// version: '7.23.0',
// confidence: 60,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@babel/core' },
// { type: 'package.json', field: 'dependencies (@babel packages)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetection[ ]Example
Detecting multiple build tools
const tools = detectBuildTools('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'@babel/core': '^7.23.0'
}
})
// => [
// { id: 'vite', name: 'Vite', version: '5.0.0', confidence: 70, ... },
// { id: 'babel', name: 'Babel', version: '7.23.0', confidence: 50, ... }
// ]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting esbuild bundler
const result = esbuildDetector('/path/to/project', {
name: 'my-lib',
devDependencies: { 'esbuild': '^0.19.0' },
scripts: { 'build': 'esbuild src/index.ts --bundle --outfile=dist/index.js' }
})
// => {
// id: 'esbuild',
// name: 'esbuild',
// version: '0.19.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.esbuild' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Parcel bundler
const result = parcelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'parcel': '^2.10.0' },
scripts: { 'dev': 'parcel src/index.html', 'build': 'parcel build src/index.html' }
})
// => {
// id: 'parcel',
// name: 'Parcel',
// version: '2.10.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.parcel' },
// { type: 'package.json', field: 'scripts.dev' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Rollup bundler
const result = rollupDetector('/path/to/project', {
name: 'my-lib',
devDependencies: {
'rollup': '^4.0.0',
'@rollup/plugin-node-resolve': '^15.0.0',
'@rollup/plugin-commonjs': '^25.0.0'
}
})
// => {
// id: 'rollup',
// name: 'Rollup',
// version: '4.0.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.rollup' },
// { type: 'package.json', field: 'dependencies (rollup plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting SWC compiler
const result = swcDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@swc/core': '^1.3.0', '@swc/cli': '^0.1.0' }
})
// => {
// id: 'swc',
// name: 'SWC',
// version: '1.3.0',
// confidence: 70,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@swc/core' },
// { type: 'package.json', field: 'dependencies.@swc/cli' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Vite build tool
const result = viteDetector('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'vitest': '^1.0.0'
}
})
// => {
// id: 'vite',
// name: 'Vite',
// version: '5.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vite' },
// { type: 'package.json', field: 'dependencies.vitest' },
// { type: 'package.json', field: 'dependencies (vite plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
BuildToolDetectionExample
Detecting Webpack bundler
const result = webpackDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'webpack': '^5.89.0', 'webpack-cli': '^5.1.0' },
scripts: { 'build': 'webpack --mode production' }
})
// => {
// id: 'webpack',
// name: 'Webpack',
// version: '5.89.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.webpack' },
// { type: 'package.json', field: 'dependencies.webpack-cli' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }◈ Interfaces
Properties
● Variables
Frontend framework detection for React, Next.js, Vue, Angular, Svelte, Solid, Qwik, and more.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Angular framework
const result = angularDetector('/path/to/angular-app', {
dependencies: { '@angular/core': '^17.0.0', '@angular/cli': '^17.0.0' }
})
// => {
// id: 'angular',
// name: 'Angular',
// category: 'frontend',
// version: '17.0.0',
// confidence: 85,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@angular/core' },
// { type: 'package.json', field: 'dependencies.@angular/cli' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Astro framework
const result = astroDetector('/path/to/astro-project', {
dependencies: { 'astro': '^4.0.0' }
})
// => {
// id: 'astro',
// name: 'Astro',
// category: 'meta-framework',
// version: '4.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.astro' }]
// }detectFrontendFrameworks( projectPath: string, packageJson?: PackageJson): FrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetection[ ]Example
Detecting multiple frontend frameworks
const frameworks = detectFrontendFrameworks('/path/to/nextjs-app', {
dependencies: { 'react': '^18.0.0', 'next': '^14.0.0' }
})
// => [
// { id: 'nextjs', name: 'Next.js', category: 'meta-framework', confidence: 70, ... },
// { id: 'react', name: 'React', category: 'frontend', confidence: 60, ... }
// ]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Gatsby framework
const result = gatsbyDetector('/path/to/gatsby-blog', {
dependencies: {
'gatsby': '^5.0.0',
'gatsby-plugin-image': '^3.0.0',
'gatsby-source-filesystem': '^5.0.0'
}
})
// => {
// id: 'gatsby',
// name: 'Gatsby',
// category: 'meta-framework',
// version: '5.0.0',
// confidence: 75,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.gatsby' },
// { type: 'package.json', field: 'dependencies (gatsby plugins)' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Next.js framework
const result = nextjsDetector('/path/to/nextjs-app', {
dependencies: { 'next': '^14.0.0', 'react': '^18.0.0' }
})
// => {
// id: 'nextjs',
// name: 'Next.js',
// category: 'meta-framework',
// version: '14.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.next' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Nuxt framework
const result = nuxtDetector('/path/to/nuxt-app', {
dependencies: { 'nuxt': '^3.0.0', 'vue': '^3.0.0' }
})
// => {
// id: 'nuxt',
// name: 'Nuxt',
// category: 'meta-framework',
// version: '3.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.nuxt' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Qwik framework
const result = qwikDetector('/path/to/qwik-app', {
dependencies: {
'@builder.io/qwik': '^1.0.0',
'@builder.io/qwik-city': '^1.0.0'
}
})
// => {
// id: 'qwik',
// name: 'Qwik',
// category: 'frontend',
// version: '1.0.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@builder.io/qwik' },
// { type: 'package.json', field: 'dependencies.@builder.io/qwik-city' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting React library
const result = reactDetector('/path/to/react-app', {
dependencies: { 'react': '^18.0.0', 'react-dom': '^18.0.0' }
})
// => {
// id: 'react',
// name: 'React',
// category: 'frontend',
// version: '18.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.react' },
// { type: 'package.json', field: 'dependencies.react-dom' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Remix framework
const result = remixDetector('/path/to/remix-app', {
dependencies: {
'@remix-run/react': '^2.0.0',
'@remix-run/node': '^2.0.0'
}
})
// => {
// id: 'remix',
// name: 'Remix',
// category: 'meta-framework',
// version: '2.0.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@remix-run/react' },
// { type: 'package.json', field: 'dependencies.@remix-run/*' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Solid.js framework
const result = solidDetector('/path/to/solid-app', {
dependencies: { 'solid-js': '^1.8.0', 'vite-plugin-solid': '^2.0.0' }
})
// => {
// id: 'solid',
// name: 'Solid',
// category: 'frontend',
// version: '1.8.0',
// confidence: 90,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.solid-js' },
// { type: 'package.json', field: 'dependencies.vite-plugin-solid' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Svelte framework
const result = svelteDetector('/path/to/svelte-app', {
devDependencies: { 'svelte': '^4.0.0' }
})
// => {
// id: 'svelte',
// name: 'Svelte',
// category: 'frontend',
// version: '4.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.svelte' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting SvelteKit framework
const result = sveltekitDetector('/path/to/sveltekit-app', {
devDependencies: { '@sveltejs/kit': '^2.0.0', 'svelte': '^4.0.0' }
})
// => {
// id: 'sveltekit',
// name: 'SvelteKit',
// category: 'meta-framework',
// version: '2.0.0',
// confidence: 70,
// detectedFrom: [{ type: 'package.json', field: 'dependencies.@sveltejs/kit' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
FrameworkDetectionExample
Detecting Vue.js framework
const result = vueDetector('/path/to/vue-app', {
dependencies: { 'vue': '^3.0.0', '@vue/cli-service': '^5.0.0' }
})
// => {
// id: 'vue',
// name: 'Vue',
// category: 'frontend',
// version: '3.0.0',
// confidence: 85,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vue' },
// { type: 'package.json', field: 'dependencies.@vue/cli-service' }
// ]
// }◈ Interfaces
Properties
Properties
● Variables
Legacy framework detection for AngularJS, Backbone, Ember, and jQuery.
ƒ Functions
angularJSDetector( projectPath: string, packageJson?: PackageJson): LegacyFrameworkDetection
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting AngularJS framework
const result = angularJSDetector('/path/to/project', {
dependencies: { angular: '^1.8.0', 'angular-route': '^1.8.0' },
})
// => { id: 'angularjs', name: 'AngularJS', confidence: 85, version: '1.8.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting Backbone.js framework
const result = backboneDetector('/path/to/project', {
dependencies: { backbone: '^1.4.0', underscore: '^1.13.0' },
})
// => { id: 'backbone', name: 'Backbone.js', confidence: 85, version: '1.4.0', ... }detectLegacyFrameworks( projectPath: string, packageJson?: PackageJson): LegacyFrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetection[ ]Example
Detecting legacy frameworks
const results = detectLegacyFrameworks('/path/to/project', {
dependencies: { jquery: '^3.6.0', backbone: '^1.4.0' },
})
// => [{ id: 'jquery', confidence: 80 }, { id: 'backbone', confidence: 70 }]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting Ember.js framework
const result = emberDetector('/path/to/project', {
dependencies: { 'ember-source': '^4.0.0' },
devDependencies: { 'ember-cli': '^4.0.0' },
})
// => { id: 'ember', name: 'Ember.js', confidence: 90, version: '4.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LegacyFrameworkDetectionExample
Detecting jQuery library
const result = jqueryDetector('/path/to/project', {
dependencies: { jquery: '^3.6.0', 'jquery-ui': '^1.13.0' },
})
// => { id: 'jquery', name: 'jQuery', confidence: 90, version: '3.6.0', ... }◈ Interfaces
Properties
Properties
● Variables
Linting tool detection for ESLint, Prettier, Stylelint, and Biome.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Biome linter
const result = biomeDetector('/path/to/project', {
devDependencies: { '@biomejs/biome': '^1.5.0' },
})
// => { id: 'biome', name: 'Biome', confidence: 70, version: '1.5.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetection[ ]Example
Detecting multiple linting tools
const results = detectLintingTools('/path/to/project', {
devDependencies: { eslint: '^8.0.0', prettier: '^3.0.0' },
})
// => [{ id: 'eslint', confidence: 50 }, { id: 'prettier', confidence: 50 }]Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting ESLint linter
const result = eslintDetector('/path/to/project', {
devDependencies: { eslint: '^8.50.0', '@typescript-eslint/parser': '^6.0.0' },
scripts: { lint: 'eslint src/' },
})
// => { id: 'eslint', name: 'ESLint', confidence: 65, version: '8.50.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Prettier formatter
const result = prettierDetector('/path/to/project', {
devDependencies: { prettier: '^3.0.0' },
scripts: { format: 'prettier --write .' },
})
// => { id: 'prettier', name: 'Prettier', confidence: 55, version: '3.0.0', ... }Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
LintingToolDetectionExample
Detecting Stylelint linter
const result = stylelintDetector('/path/to/project', {
devDependencies: { stylelint: '^15.0.0', 'stylelint-config-standard': '^30.0.0' },
})
// => { id: 'stylelint', name: 'Stylelint', confidence: 65, version: '15.0.0', ... }◈ Interfaces
Properties
Properties
● Variables
Monorepo tool detection for Nx, Turborepo, Lerna, Rush, and pnpm/npm/yarn workspaces.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetection[ ]Example
Detecting monorepo tools
const detections = detectMonorepoTools('/path/to/project')
// => [
// { id: 'nx', name: 'NX', confidence: 90, configPath: 'nx.json', detectedFrom: [...] },
// { id: 'npm-workspaces', name: 'npm Workspaces', confidence: 80, ... }
// ]Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Lerna monorepo
// Project with lerna.json config file
const result = lernaDetector('/path/to/lerna-project')
// => {
// id: 'lerna',
// name: 'Lerna',
// confidence: 80,
// configPath: 'lerna.json',
// detectedFrom: [{ type: 'config-file', path: 'lerna.json' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting npm workspaces
// Project with workspaces in package.json and package-lock.json
const result = npmWorkspacesDetector('/path/to/npm-project')
// => {
// id: 'npm-workspaces',
// name: 'npm Workspaces',
// confidence: 90,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'package-lock.json' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting NX workspace
// Project with nx.json and apps/libs directories
const result = nxDetector('/path/to/nx-workspace')
// => {
// id: 'nx',
// name: 'NX',
// confidence: 100,
// configPath: 'nx.json',
// version: '17.0.0',
// workspaceLayout: { appsDir: 'apps', libsDir: 'libs' },
// detectedFrom: [
// { type: 'config-file', path: 'nx.json' },
// { type: 'package.json', field: 'dependencies.nx' },
// { type: 'directory', path: 'apps/ or libs/' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
Returns
MonorepoDetectionExample
Detecting pnpm workspaces
// Project with pnpm-workspace.yaml
const result = pnpmWorkspacesDetector('/path/to/pnpm-project')
// => {
// id: 'pnpm-workspaces',
// name: 'pnpm Workspaces',
// confidence: 100,
// configPath: 'pnpm-workspace.yaml',
// detectedFrom: [
// { type: 'config-file', path: 'pnpm-workspace.yaml' },
// { type: 'lockfile', path: 'pnpm-lock.yaml' }
// ]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Rush monorepo
// Project with rush.json config file
const result = rushDetector('/path/to/rush-project')
// => {
// id: 'rush',
// name: 'Rush',
// confidence: 90,
// configPath: 'rush.json',
// detectedFrom: [{ type: 'config-file', path: 'rush.json' }]
// }Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting Turborepo monorepo
// Project with turbo.json and turbo dependency
const result = turborepoDetector('/path/to/turbo-project')
// => {
// id: 'turborepo',
// name: 'Turborepo',
// confidence: 95,
// configPath: 'turbo.json',
// version: '2.0.0',
// detectedFrom: [
// { type: 'config-file', path: 'turbo.json' },
// { type: 'package.json', field: 'dependencies.turbo' }
// ]
// }yarnWorkspacesDetector( workspacePath: string, packageJson?: PackageJson): MonorepoDetection
Parameters
| Name | Type | Description |
|---|---|---|
§workspacePath | string | Workspace directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
MonorepoDetectionExample
Detecting yarn workspaces
// Project with workspaces in package.json and yarn.lock
const result = yarnWorkspacesDetector('/path/to/yarn-project')
// => {
// id: 'yarn-workspaces',
// name: 'Yarn Workspaces',
// confidence: 100,
// configPath: 'package.json',
// detectedFrom: [
// { type: 'package.json', field: 'workspaces' },
// { type: 'lockfile', path: 'yarn.lock' },
// { type: 'config-file', path: '.yarnrc.yml' }
// ]
// }◈ Interfaces
Properties
Properties
● Variables
Testing framework detection for Jest, Vitest, Mocha, Cypress, and Playwright.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Cypress testing framework
import { cypressDetector } from '@hyperfrontend/project-scope'
const result = cypressDetector('./my-project')
if (result) {
console.log(`Cypress ${result.version} detected (${result.confidence}% confidence)`)
// => "Cypress 13.6.0 detected (95% confidence)"
}detectTestingFrameworks( projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection[ ]
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetection[ ]Example
Detecting multiple testing frameworks
import { detectTestingFrameworks } from '@hyperfrontend/project-scope'
const frameworks = detectTestingFrameworks('./my-project')
// => [
// { id: 'jest', name: 'Jest', type: 'unit', confidence: 95, ... },
// { id: 'cypress', name: 'Cypress', type: 'e2e', confidence: 85, ... }
// ]
// Results are sorted by confidence (highest first)
const primary = frameworks[0]?.name ?? 'None'
console.log(`Primary testing framework: ${primary}`)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Jest testing framework
import { jestDetector } from '@hyperfrontend/project-scope'
const result = jestDetector('./my-project')
if (result) {
console.log(`Jest ${result.version} detected`)
console.log('Sources:', result.detectedFrom.map(s => s.type))
// => "Sources: ['package.json', 'config-file']"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Mocha testing framework
import { mochaDetector } from '@hyperfrontend/project-scope'
const result = mochaDetector('./my-project')
if (result) {
console.log(`Mocha ${result.version} detected (${result.confidence}%)`)
// => "Mocha 10.2.0 detected (95%)"
}playwrightDetector( projectPath: string, packageJson?: PackageJson): TestingFrameworkDetection
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Playwright testing framework
import { playwrightDetector } from '@hyperfrontend/project-scope'
const result = playwrightDetector('./my-project')
if (result) {
console.log(`Playwright ${result.version} (${result.type} tests)`)
// => "Playwright 1.42.0 (e2e tests)"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TestingFrameworkDetectionExample
Detecting Vitest testing framework
import { vitestDetector } from '@hyperfrontend/project-scope'
const result = vitestDetector('./my-project')
if (result) {
console.log(`Vitest ${result.version} detected`)
console.log('Config:', result.configPath)
// => "Config: vitest.config.ts"
}◈ Interfaces
Properties
Properties
● Variables
Type system detection for TypeScript, Flow, and JSDoc typing.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetection[ ]Example
Detecting all type systems
import { detectTypeSystems } from '@hyperfrontend/project-scope'
const typeSystems = detectTypeSystems('./my-project')
// => [
// { id: 'typescript', name: 'TypeScript', version: '5.3.0', strictMode: true, confidence: 95, ... },
// { id: 'jsdoc', name: 'JSDoc', confidence: 40, ... }
// ]
const primary = typeSystems[0]?.name ?? 'None'
console.log(`Primary type system: ${primary}`)Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting Flow type system
import { flowDetector } from '@hyperfrontend/project-scope'
const result = flowDetector('./my-project')
if (result) {
console.log(`Flow ${result.version} with config: ${result.configPath}`)
// => "Flow 0.232.0 with config: .flowconfig"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting JSDoc type annotations
import { jsdocDetector } from '@hyperfrontend/project-scope'
const result = jsdocDetector('./my-project')
if (result) {
console.log('JSDoc types detected')
console.log('Sources:', result.detectedFrom.map(s => s.path ?? s.field))
// => "Sources: ['jsconfig.json', 'src/utils.js (JSDoc annotations)']"
}Parameters
| Name | Type | Description |
|---|---|---|
§projectPath | string | Project directory path |
§packageJson? | PackageJson | Optional pre-loaded package.json |
Returns
TypeSystemDetectionExample
Detecting TypeScript
import { typescriptDetector } from '@hyperfrontend/project-scope'
const result = typescriptDetector('./my-project')
if (result) {
console.log(`TypeScript ${result.version}`)
console.log(`Strict mode: ${result.strictMode ?? 'unknown'}`)
// => "TypeScript 5.3.0"
// => "Strict mode: true"
}◈ Interfaces
Properties
● Variables
Virtual filesystem with transactional tree operations, diff generation, and commit/rollback support.
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | Virtual file system tree with pending modifications |
§options? | CommitOptions | Configuration for dry-run and verbosity |
Returns
CommitResultExample
Committing changes to disk
import { createTree, commitChanges } from '@hyperfrontend/project-scope'
const tree = createTree('./my-project')
tree.write('src/new-file.ts', 'export const hello = "world"')
// Preview changes without writing
const preview = commitChanges(tree, { dryRun: true })
console.log('Would create:', preview.created, 'files')
// Actually commit changes
const result = commitChanges(tree)
console.log('Created:', result.created, 'Updated:', result.updated)Supports transactional modifications - all changes are buffered in memory and can be committed atomically or rolled back.
Parameters
| Name | Type | Description |
|---|---|---|
§root | string | Absolute path to the workspace root directory |
§options? | CreateTreeOptions | Configuration for verbose logging |
Returns
TreeExample
Creating and using a file system tree
import { createFsTree, commitChanges } from '@hyperfrontend/project-scope'
const tree = createFsTree('/workspace')
tree.write('src/new-file.ts', 'export const value = 42')
tree.delete('old-file.ts')
commitChanges(tree) // Atomically apply all changes to diskParameters
| Name | Type | Description |
|---|---|---|
§root | string | Root directory path |
§options? | CreateTreeOptions | Tree creation options |
Returns
TreeExample
Creating a virtual tree
import { createTree } from '@hyperfrontend/project-scope'
const tree = createTree('./my-project')
// Read files from tree
const content = tree.read('src/index.ts', 'utf-8')
// Make changes (buffered in memory)
tree.write('src/new-file.ts', 'export const x = 1')
// List pending changes
console.log(tree.listChanges())Convenience alias for createTree.
Parameters
| Name | Type | Description |
|---|---|---|
§root | string | Root directory path |
§options? | CreateTreeOptions | Tree creation options |
Returns
TreeExample
Creating a tree from disk
import { createTreeFromDisk } from '@hyperfrontend/project-scope'
const tree = createTreeFromDisk('/path/to/project', { verbose: true })
const files = tree.children('/src')Returns
stringExample
Formatting a unified diff
const formatted = formatUnifiedDiff(diff)
console.log(formatted)
// --- a/src/app.ts
// +++ b/src/app.ts
// @@ -1,3 +1,3 @@
// const x = 1;
// -const y = 2;
// +const y = 3;
// const z = 4;Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | Tree to generate diffs for |
§options | DiffOptions | Diff options(default: {}) |
Returns
FileDiff[ ]Example
Generating diffs for all changes
const tree = createTree('/workspace')
tree.write('new.txt', 'hello')
tree.delete('old.txt')
const diffs = generateAllDiffs(tree)
for (const diff of diffs) {
console.log(formatUnifiedDiff(diff))
}Parameters
| Name | Type | Description |
|---|---|---|
§change | FileChange | File change to diff |
§options | DiffOptions | Configuration for diff generation including context lines(default: {}) |
Returns
FileDiffExample
Generating a diff for a file change
const change: FileChange = {
path: 'src/app.ts',
type: 'UPDATE',
originalContent: Buffer.from('const x = 1;\n'),
content: Buffer.from('const x = 2;\n'),
}
const diff = generateDiff(change)
// { path: 'src/app.ts', additions: 1, deletions: 1, lines: [...] }Example
Rolling back pending changes
import { createTree, rollbackChanges } from '@hyperfrontend/project-scope'
const tree = createTree('/workspace')
tree.write('new-file.ts', 'content')
// Decide to abort - discard all pending changes
rollbackChanges(tree)◈ Interfaces
Properties
Properties
Properties
Properties
Properties
Properties
Properties
Properties
◆ Types
● Variables
Related reading§
- Architecture
Architecture
How @hyperfrontend/project-scope is put together, and why.
- How-to
How to read another tool's config file
My tool needs to read a project's tsconfig, bundler, or environment configuration, and every attempt turns into a list of seven candidate filenames per tool plus a JSON.parse that throws on the comments TypeScript allows.
- Package
@hyperfrontend/nexus
Works seamlessly with @hyperfrontend/nexus for cross-window communication tooling
- Package
@hyperfrontend/cryptography
Looking for cryptographic utilities? See @hyperfrontend/cryptography
- Getting started
Getting Started
Set HyperFrontend up and embed a first feature.
- Architecture
Architecture Guide
How the packages fit together.

