import path from 'path' import { packageName } from './package' const basePath = process.cwd() export const salesAppCoreDir = path.resolve( require.resolve(packageName), '..', '..' ) export const getSalesAppMonorepoDir = (account: string) => { const fpsConfigFilePath = path.resolve(basePath, 'fsp.json') let config: any = null try { // eslint-disable-next-line node/global-require, @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports config = require(fpsConfigFilePath) } catch (error) { throw new Error(`Could not find fsp.json configuration file`) } const store = config?.stores?.[account] if (!store) { throw new Error( `Could not find store "${account}". Make sure the store is configured on fsp.json` ) } const monorepoPath = store['sales-app']?.path if (!monorepoPath) { throw new Error( `Could not find sales-app directory path for store "${account}". Make sure the sales-app is configured on fsp.json for the store "${account}"` ) } return path.join(process.cwd(), monorepoPath) } export const getTempDir = (monorepoDir: string) => { return path.join(monorepoDir, '.tmp') }