UNPKG

@pagopa/dx-cli

Version:

A CLI useful to manage DX tools.

33 lines (32 loc) 1.17 kB
import { ok } from "neverthrow"; import { z } from "zod/v4"; const WorkspaceName = z.string().min(1).brand(); export const workspaceSchema = z.object({ name: WorkspaceName, path: z.string(), }); export const checkWorkspaces = async (dependencies, monorepoDir) => { const { repositoryReader } = dependencies; const checkName = "Workspaces"; const workspacesResult = await repositoryReader.getWorkspaces(monorepoDir); if (workspacesResult.isErr()) { return ok({ checkName, errorMessage: "Something is wrong with the workspaces configuration. If you need help, please contact the DevEx team.", isValid: false, }); } const { length: workspaceNumber } = workspacesResult.value; if (workspaceNumber === 0) { return ok({ checkName, errorMessage: "No workspace configuration found. Make sure to configure workspaces in pnpm-workspace.yaml.", isValid: false, }); } return ok({ checkName, isValid: true, successMessage: `Found ${workspaceNumber} workspace${workspaceNumber === 1 ? "" : "s"}`, }); };