import { Rule , Tree } from '@angular-devkit/schematics' ; import { buildRelativePath } from '@schematics/angular/utility/find-module' ; import { getFileDirectoryPath } from '../../shared/path-helper' ; import { updatePublicAPI } from './update-public-api.rule' ; export function updateSubentryPublicAPI ( filePath ) { return ( tree ) => { const directoryPath = getFileDirectoryPath ( filePath ) ; const relativeFilePaths = getRelativePathsToFilesInDirectory ( tree , filePath ) ; return updatePublicAPI ( directoryPath , relativeFilePaths ) ; } ; } function getRelativePathsToFilesInDirectory ( tree , filePath ) { const relativeFilePaths = [ ] ; tree . getDir ( getFileDirectoryPath ( filePath ) ) . visit ( ( fileName ) => { if ( needsToBeExported ( fileName ) ) { relativeFilePaths . push ( buildRelativePath ( filePath , fileName ) ) ; } } ) ; return relativeFilePaths ; } function needsToBeExported ( fileName ) { return ( fileName . endsWith ( 'ts' ) && ! fileName . endsWith ( 'index.ts' ) && ! fileName . endsWith ( 'public-api.ts' ) ) ; }