(options: CollectOptions)
| 24 | * @param options |
| 25 | */ |
| 26 | export async function collect(options: CollectOptions): Promise<Report> { |
| 27 | const { plugins, categories, persist = {}, cache } = options; |
| 28 | |
| 29 | const date = new Date().toISOString(); |
| 30 | const start = performance.now(); |
| 31 | const packageJson = createRequire(import.meta.url)( |
| 32 | '../../../package.json', |
| 33 | ) as typeof import('../../../package.json'); |
| 34 | |
| 35 | const commit = await getLatestCommit(); |
| 36 | logger.debug( |
| 37 | commit |
| 38 | ? `Found latest commit ${commit.hash} ("${commit.message}" by ${commit.author})` |
| 39 | : 'Latest commit not found', |
| 40 | ); |
| 41 | |
| 42 | logger.info( |
| 43 | `Collecting report from ${pluralizeToken('plugin', plugins.length)} ...`, |
| 44 | ); |
| 45 | const pluginOutputs = await executePlugins({ plugins, persist, cache }); |
| 46 | logger.info(ansis.green('Collected report ✓')); |
| 47 | |
| 48 | return { |
| 49 | commit, |
| 50 | packageName: packageJson.name, |
| 51 | version: packageJson.version, |
| 52 | date, |
| 53 | duration: calcDuration(start), |
| 54 | categories, |
| 55 | plugins: pluginOutputs, |
| 56 | }; |
| 57 | } |
no test coverage detected