# core/steps/site.step.ts

> 39 lines of code and 4 definitions.

Tree: Bane's Lab Deploy
Language: typescript
Layer: application
Canonical: https://banes-lab.com/anatomy/deploy#file-deploy-core-steps-site-step-ts
Source text: https://banes-lab.com/source/deploy/core/steps/site.step.ts.txt

Listed in [core/steps](https://banes-lab.com/api/source/deploy/core/steps.md), after [core/steps/setup.step.ts](https://banes-lab.com/source/deploy/core/steps/setup.step.ts.md).

## Definitions

- `buildSite` (lexical_declaration, line 29, exported)
- `validateSite` (lexical_declaration, line 17, exported)
- `findings` (lexical_declaration, line 22, exported)
- `ended` (lexical_declaration, line 34, exported)

## Contained in

- [core/steps](https://banes-lab.com/anatomy/deploy/folder-deploy-core-steps.md)

## Uses

- [configuration/strings/deployment.strings.ts](https://banes-lab.com/source/deploy/configuration/strings/deployment.strings.ts.md)

## Used by

- [runtime/entrypoints/deployment.entrypoint.ts](https://banes-lab.com/source/deploy/runtime/entrypoints/deployment.entrypoint.ts.md)

## Linked from

- [configuration/strings](https://banes-lab.com/anatomy/deploy/folder-deploy-configuration-strings.md)
- [runtime/entrypoints](https://banes-lab.com/anatomy/deploy/folder-deploy-runtime-entrypoints.md)

## Source

```typescript
import {
    BUILDING,
    BUILD_FAILED,
    BUILT,
    SITE_INVALID,
    SITE_VALID,
    VALIDATING_SITE,
    buildEnded,
} from "#configuration/strings/deployment.strings";
import type { ChildExit, Journal } from "#types/deployment.types";
import { absolutePath } from "@ssot/paths";
import { buildRelease } from "#core/adapters/release.adapter";
import { messageOf } from "#core/converters/failure.converter";
import { reportOf } from "@banes-lab/build-scripts/core/formatters/validation.formatter.ts";
import { validateDiscovery } from "@banes-lab/build-scripts/core/coordinators/validation.coordinator.ts";

export const validateSite = async function validateSite(
    journal: Journal,
    validate: typeof validateDiscovery = validateDiscovery,
): Promise<void> {
    journal.log(VALIDATING_SITE);
    const findings = await validate();
    if (findings.length > 0) {
        throw new Error(SITE_INVALID + reportOf(findings));
    }
    journal.mark(SITE_VALID);
};

export const buildSite = async function buildSite(
    journal: Journal,
    run: typeof buildRelease = buildRelease,
): Promise<void> {
    journal.log(BUILDING);
    const ended: ChildExit = await run(absolutePath("app.member")).catch((error: unknown) => {
        throw new Error(BUILD_FAILED + messageOf(error), { cause: error });
    });
    if (ended.code !== 0) {
        throw new Error(BUILD_FAILED + buildEnded(ended.code, ended.signal));
    }
    journal.mark(BUILT);
};
```
