---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [discovery](../index.md) / WorkspaceTypeDetector

# Class: WorkspaceTypeDetector

Defined in: [packages/b2c-tooling-sdk/src/discovery/detector.ts:40](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/discovery/detector.ts#L40)

Detects the type of B2C Commerce project in a workspace.

WorkspaceTypeDetector analyzes a directory to determine what kind of
Commerce project it contains. Returns ALL matched project types to enable
union toolset selection for hybrid projects.

## Examples

```typescript
import { WorkspaceTypeDetector } from '@salesforce/b2c-tooling-sdk/discovery';

const detector = new WorkspaceTypeDetector('/path/to/project');
const result = await detector.detect();

console.log(`Project types: ${result.projectTypes.join(', ')}`);
console.log(`Matched patterns: ${result.matchedPatterns.join(', ')}`);
```

```typescript
const detector = new WorkspaceTypeDetector('/path/to/project', {
  additionalPatterns: [myCustomPattern],
  excludePatterns: ['sfra-cartridge'],
});
```

## Constructors

### Constructor

> **new WorkspaceTypeDetector**(`workspacePath`, `options`): `WorkspaceTypeDetector`

Defined in: [packages/b2c-tooling-sdk/src/discovery/detector.ts:50](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/discovery/detector.ts#L50)

Creates a new WorkspaceTypeDetector.

#### Parameters

##### workspacePath

`string`

Path to the workspace directory to analyze

##### options

[`DetectOptions`](../interfaces/DetectOptions.md) = `{}`

Detection options for customizing behavior

#### Returns

`WorkspaceTypeDetector`

## Methods

### detect()

> **detect**(): `Promise`\<[`DetectionResult`](../interfaces/DetectionResult.md)\>

Defined in: [packages/b2c-tooling-sdk/src/discovery/detector.ts:63](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/discovery/detector.ts#L63)

Performs workspace detection.

Runs all configured patterns against the workspace and returns
a consolidated result with all detected project types.

#### Returns

`Promise`\<[`DetectionResult`](../interfaces/DetectionResult.md)\>

Detection result with all project types and matched patterns
