import path from "path" ; import * as os from "os" ; export interface FileContent < T > { exists : boolean ; content : T | null ; } export interface Paths { value : ( ) => string ; customType : ( id : string ) => { value : ( ) => string ; model : ( ) => string ; mock : ( ) => string ; } ; library : ( libraryName : string ) => { value : ( ) => string ; slice : ( sliceName : string ) => { value : ( ) => string ; preview : ( filename : string ) => string ; stories : ( filename : string ) => string ; mocks : ( ) => string ; model : ( ) => string ; variation : ( variationId : string ) => { value : ( ) => string ; preview : ( filename : string ) => string ; } ; } ; } ; } const Paths = ( cwd , prefix ) : Paths => ( { value : ( ) => path . join ( cwd , prefix ) , customType : ( id ) => ( { value : ( ) => path . join ( Paths ( cwd , prefix ) . value ( ) ) , model : ( ) => path . join ( Paths ( cwd , prefix ) . value ( ) , id , "index.json" ) , mock : ( ) => path . join ( Paths ( cwd , prefix ) . value ( ) , id , "mocks.json" ) , } ) , library : ( libraryName ) => ( { value : ( ) => path . join ( Paths ( cwd , prefix ) . value ( ) , libraryName ) , slice : ( sliceName ) => ( { value : ( ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . value ( ) , sliceName ) , preview : ( filename = "preview.png" ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . slice ( sliceName ) . value ( ) , filename ) , stories : ( filename = "index.stories.js" ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . slice ( sliceName ) . value ( ) , filename ) , mocks : ( ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . slice ( sliceName ) . value ( ) , "mocks.json" ) , model : ( ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . slice ( sliceName ) . value ( ) , "model.json" ) , variation : ( variationId ) => ( { value : ( ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . slice ( sliceName ) . value ( ) , variationId ) , preview : ( filename = "preview.png" ) => path . join ( Paths ( cwd , prefix ) . library ( libraryName ) . slice ( sliceName ) . variation ( variationId ) . value ( ) , filename ) , } ) , } ) , } ) , } ) ; export const GeneratedPaths = ( cwd ) : Paths => Paths ( cwd , path . join ( ".slicemachine" , "assets" ) ) ; export const GeneratedCustomTypesPaths = ( cwd ) : Paths => Paths ( cwd , path . join ( ".slicemachine" , "assets" , "customtypes" ) ) ; export const CustomTypesPaths = ( cwd ) : Paths => Paths ( cwd , "customtypes" ) ; export const CustomPaths = ( cwd ) : Paths => Paths ( cwd , "" ) ; export const PackagePaths = ( cwd ) : Paths => Paths ( cwd , "node_modules" ) ; export const SMConfigPath = ( cwd ) : string => path . join ( cwd , "sm.json" ) ; export const PrismicConfigPath = ( dir = os . homedir ( ) ) : string => path . join ( dir , ".prismic" ) ; export const SliceTemplateConfigPath = ( cwd , customPathToTemplate ? ) : string => customPathToTemplate ? path . join ( cwd , customPathToTemplate ) : path . join ( cwd , "slice-template" ) ; export const JsonPackagePath = ( cwd ) : string => path . join ( cwd , "package.json" ) ; export const YarnLockPath = ( cwd ) : string => path . join ( cwd , "yarn.lock" ) ; export const MocksConfigPath = ( cwd ) : string => path . join ( cwd , ".slicemachine" , "mock-config.json" ) ;