# core/factories/step.factory.ts

> 16 lines of code and 3 definitions.

Tree: Bane's Lab Build Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-factories-step-factory-ts
Source text: https://banes-lab.com/source/build-scripts/core/factories/step.factory.ts.txt

Listed in [core/factories](https://banes-lab.com/api/source/build-scripts/core/factories.md), after [core/factories/server.factory.ts](https://banes-lab.com/source/build-scripts/core/factories/server.factory.ts.md) and before [core/factories/walk.factory.ts](https://banes-lab.com/source/build-scripts/core/factories/walk.factory.ts.md).

## Definitions

- `defineStep` (lexical_declaration, line 6, exported)
- `EVERY_MODE` (lexical_declaration, line 4)
- `step` (lexical_declaration, line 7, exported)

## Contained in

- [core/factories](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-factories.md)

## Uses

- [core/registries/step.registry.ts](https://banes-lab.com/source/build-scripts/core/registries/step.registry.ts.md)

## Linked from

- [core/registries](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-registries.md)

## Source

```typescript
import type { SiteMode, SiteStep, StepSpec } from "#types/site.types";
import { registerStep } from "#core/registries/step.registry";

const EVERY_MODE: readonly SiteMode[] = ["build", "serve"];

export const defineStep = function defineStep(spec: StepSpec): SiteStep {
    const step: SiteStep = {
        cache: spec.cache,
        gives: spec.gives ?? [spec.name],
        modes: spec.modes ?? EVERY_MODE,
        name: spec.name,
        needs: spec.needs ?? [],
        phase: spec.phase,
        run: spec.run,
    };
    registerStep(step);
    return step;
};
```
