import path from "path" ; import { camelCase , upperFirst } from "lodash" ; import { DobPageController } from "./DobPageController" ; import { HomePageController } from "./HomePageController" ; import { PageController } from "./PageController" ; import { StartDatePageController } from "./StartDatePageController" ; import { StartPageController } from "./StartPageController" ; import { SummaryPageController } from "./SummaryPageController" ; import { PageControllerBase } from "./PageControllerBase" ; import { Page } from "@xgovformbuilder/model" ; const PageControllers = { DobPageController , HomePageController , PageController , StartDatePageController , StartPageController , SummaryPageController , PageControllerBase , } ; export const controllerNameFromPath = ( filePath ) => { const fileName = path . basename ( filePath ) . split ( "." ) [ 0 ] ; return `${ upperFirst ( camelCase ( fileName ) ) }PageController` ; } ; /**
 * Gets the class for the controller defined in a  Page export const getPageController = ( nameOrPath ) => { const isPath = ! ! path . extname ( nameOrPath ) ; const controllerName = isPath ? controllerNameFromPath ( nameOrPath ) : nameOrPath ; return PageControllers [ controllerName ] ; } ;