1import * as _ from 'lodash-es' 7export const devpcOnlyFolderName = '/devpconlyF/' 9export const dependencyFilter = (path: string) => !_.includes(path, devpcOnlyFolderName) 11export const isImportLine = (line: string) => ( 12 _.includes(line, 'import(') || 13 _.startsWith(line, 'import {') || 14 _.startsWith(line, 'import type {') 17const doesLineImportDev = (line: string) => { 18 if (!isImportLine(line)) return false 19 const idx = line.indexOf(devpcOnlyFolderName) 20 if (idx == -1) return false 21 const commentIdx = line.indexOf('//') 22 if (commentIdx == -1) return true 23 return idx < commentIdx 26export const filterDevOnlyPaths = async (pathsA: absFileDirPath[]) => { 27 const checkPathsA = _.filter(pathsA, isPtCodeFileExt) as absFileDirPath[] 29 const pathsThatImportDevDecA = _.chain(await allPromCalls(checkPathsA, async (path) => { 31 const matchingLinesA = _.chain(linesA).filter(doesLineImportDev).value() 32 if (matchingLinesA.length == 0) return 33 return {path, matchingLinesA, newContents: _.difference(linesA, matchingLinesA).join("\n")} 36 const pathsThatDontImportDevA = _.difference(pathsA, _.map(pathsThatImportDevDecA, 'path')) 38 return {pathsThatImportDevDecA, pathsThatDontImportDevA}