1import * as _ from 'lodash-es'2import { chalkCyan, chalkGray, chalkGreen, chalkMagenta, chalkYellow } from '../../serverF/libChalkF.mts'3import { epScopes, getEpScopeOptA, printEpScopeHint } from '../dockerF/getEpCfgF.mts'4import { epScopeColors, fileClrFromEpSets, legendScopes, simpleLegendScopes } from '../dockerF/scopesF.mts'5import type { EpScopeSets } from '../dockerF/scopesF.mts'6import { getEpsPaths, getRakeEpsPaths } from '../codeStatsF/deployPathsF.mts'7import { getPkgJsonPtPathsA } from '../pnpmF/recPkgJsonsPathAF.mts'8import { getAppCfg } from '../k8sF/ctxF/appCfgCtxF.mts'9import { assertNonEmpty } from '../../sharedF/assertsF/assertNonEmptyF.mts'10import { scopeCli } from '../cliF/cliSchemaSetsF.mts'11import type { PtAction } from '../ctxF/availActionsCtxF.mts'12import type { EpScope } from '../dockerF/scopesF.mts'14const colorFns: Record<string, (s: string) => string> = { green: chalkGreen, gray: chalkGray, yellow: chalkYellow, cyan: chalkCyan, magenta: chalkMagenta }16export const getEpScopeSets = async (): Promise<EpScopeSets> => {17 const [{pathsA: pubfejsPaths}, {pathsA: dockerjsPaths}, {pathsA: deployjsPaths}] = await Promise.all([18 getEpsPaths({inclDocker: true, feOnly: true}),19 getEpsPaths({inclDocker: true}),20 getEpsPaths({inclDeploy: true}),21 ])22 return {23 pubfejsSet: new Set(pubfejsPaths),24 dockerjsSet: new Set(dockerjsPaths),25 deployjsSet: new Set(deployjsPaths),26 }27}29export const colorPathByEpScope = (path: string, sets: EpScopeSets) => {30 const clr = fileClrFromEpSets(path, sets)31 return colorFns[clr](path)32}34export const epScopeLegend = () => {36 const scopes = usesExplicitEpPtPaths ? simpleLegendScopes : legendScopes37 const parts = scopes.map((s) => `${colorFns[epScopeColors[s]](epScopeColors[s])}=${s}`)38 return parts.join(' ')39}44 const {pathsA} = await getRakeEpsPaths({defaultEpScope: epScopes.dockerjs})45 assertNonEmpty(pathsA, {appPath, usesExplicitEpPtPaths})47 const pkgJsonPtPathsA: string[] = !usesExplicitEpPtPaths && appPath48 ? await getPkgJsonPtPathsA({appPath}) as unknown as string[]49 : []50 const allPathsA = [...pathsA, ...pkgJsonPtPathsA]52 const epScopeSets = await getEpScopeSets()53 const coloredPathsA = allPathsA.map((p) => colorPathByEpScope(p, epScopeSets))54 console.log(coloredPathsA.join("\n"))55 console.log('')56 console.log(epScopeLegend())57 printEpScopeHint({defaultEpScope: epScopes.dockerjs})58}59lscode.needsLazyDocker = true60lscode.cliSchema = scopeCli61lscode.cliDescript = {62 cliDefaultOpt: epScopes.dockerjs,63 cliOptA: getEpScopeOptA,64 cliSupportsEpScopes: true,65 cliExplain: 'list all file paths in scope'66}