Skip to content

Commit

Permalink
Update the component-version counting extension
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattel committed Feb 4, 2025
1 parent 4e892c8 commit 724c9fc
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions ext-antora/comp-version.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
'use strict'

// Extension to print the component, version and number of files that will be processed

/**
* Print a table of Component - Version - Number of Files + total.
* Only the number of files in the modules directory are counted
* Version 1.1.0
*
* ┌─────────┬────────┬─────────┬───────┐
* │ (index) │ Name │ Version │ Files │
* ├─────────┼────────┼─────────┼───────┤
* │ 0 │ 'ROOT' │ '~' │ 14 │
* │ 3 │ │ │ 14 │
* └─────────┴────────┴─────────┴───────┘
*/

module.exports.register = function () {
this.once('contentAggregated', ({ contentAggregate }) => {
console.log('\nProcessing the following components, versions and number of files\n')
var total_files = 0
const component_table = []
contentAggregate.forEach((bucket) => {
component_table.push ({Name: bucket.name, Version: bucket.version || '~', Files: bucket.files.length})
total_files += parseInt(bucket.files.length)
var count = 0
bucket.files.forEach((file) => {
if (file.src.path.startsWith('modules')) {
count += 1
}
})
component_table.push ({Name: bucket.name, Version: bucket.version || '~', Files: count})
total_files += count
})
component_table.length++
component_table.length++
component_table.push ({Files: total_files})
console.table(component_table)
console.log() // do not delete, else we get a double empty line
Expand Down

0 comments on commit 724c9fc

Please sign in to comment.