1import logger from '../../Logger'; 2import { getListOfPackagesAsync } from '../../Packages'; 3import { Task } from '../../TasksRunner'; 4import { createParcelAsync } from '../helpers'; 5import { CommandOptions, Parcel, TaskArgs } from '../types'; 6 7/** 8 * Gets a list of public packages in the monorepo, downloads `npm view` result of them, 9 * creates their Changelog instance and fills in given parcels array (it's empty at the beginning). 10 */ 11export const prepareParcels = new Task<TaskArgs>( 12 { 13 name: 'prepareParcels', 14 }, 15 async (parcels: Parcel[], options: CommandOptions) => { 16 logger.info(' Gathering data about packages...'); 17 18 const { exclude, packageNames } = options; 19 const allPackages = await getListOfPackagesAsync(); 20 const filteredPackages = allPackages.filter((pkg) => { 21 const isPrivate = pkg.packageJson.private; 22 const isIncluded = packageNames.length === 0 || packageNames.includes(pkg.packageName); 23 const isExcluded = exclude.includes(pkg.packageName); 24 25 return !isPrivate && isIncluded && !isExcluded; 26 }); 27 28 parcels.push(...(await Promise.all(filteredPackages.map(createParcelAsync)))); 29 } 30); 31