3import * as _ from 'lodash-es' 14export const getDeployEpA = async (): Promise<string[]> => { 15 const {importMetaUrl, deployEp: deployEpArg} = getAppCfg() 21type GetEpsPathsOpts = EpScopeCfg & { onlyPages?: boolean } 22type GetEpsPathsResult = { epA: string[], pathsA: string[] } 24export const getEpsPaths = async ({inclDeploy, inclDocker, onlyPages = false, feOnly = false}: GetEpsPathsOpts): Promise<GetEpsPathsResult> => { 25 const {appPath, usesExplicitEpPtPaths, epPtPathsA: explicitEpPtPathsA} = getAppCfg() 27 // feOnly: client-side detection 29 if (usesExplicitEpPtPaths) return { epA: [], pathsA: [] } 31 const pagesOnly = _.filter(pagePathsA, p => _.includes(p, '/pages/') || _.includes(p, '/app/')) 32 const apiRoutes = _.filter(pagesOnly, p => _.includes(p, '/api/') || _.endsWith(p, '/route.js')) 33 const clientPages = _.difference(pagesOnly, apiRoutes) 35 const publicPaths = _.filter(pagePathsA, p => _.includes(p, '/public/')) 36 const pathsA = _.uniq([...clientPages, ...Array.from(clientPaths), ...publicPaths]) 37 return { epA: clientPages, pathsA } 40 // Resolve docker entry points (only difference between ep types) 41 const dockerEpPtPathsA = usesExplicitEpPtPaths ? explicitEpPtPathsA : await nextAppPaths() 42 throwIf(() => inclDocker && !dockerEpPtPathsA?.length, {appPath, usesExplicitEpPtPaths, explicitEpPtPathsA}) 44 if (onlyPages && inclDocker === undefined) inclDocker = true 46 let epA: string[] = [] 47 if (inclDocker) epA = _.union(epA, dockerEpPtPathsA) 48 if (inclDeploy) epA = _.union(epA, await getDeployEpA()) 51 throwIf(() => !inclDocker || inclDeploy, {inclDocker, inclDeploy}) 52 epA = _.filter(epA, ep => _.includes(ep, '/pages/')) 55 const pathsA = await epToPathA({epA}) 56 return { epA, pathsA } 59export const epToPathA = async ({epA}: {epA: string[]}) => { 60 const madgeResult = await ptMadge(epA) as Record<string, string[]> 61 return _.uniq(_.union(_.flatten(Object.values(madgeResult)), epA)).filter(isPtCodeFileExt) 64export const getRakeEpsPaths = async (epCfgOpts?: {defaultEpScope?: EpScope}): Promise<GetEpsPathsResult> => {