refactor version patching extension

This commit is contained in:
Dan Allen 2022-10-24 18:26:56 -06:00 committed by Rob Winch
parent 466b882d82
commit c7d14e0c02
1 changed files with 18 additions and 35 deletions

View File

@ -1,39 +1,22 @@
// https://gitlab.com/antora/antora/-/issues/132#note_712132072
'use strict' 'use strict'
module.exports.register = function () {
module.exports.register = function({ config }) { this.once('contentAggregated', ({ contentAggregate }) => {
this.on('contentAggregated', ({ contentAggregate }) => { contentAggregate.forEach((componentVersionBucket) => {
contentAggregate.forEach(aggregate => { if (componentVersionBucket.prerelease === 'true') componentVersionBucket.prerelease = true
if (aggregate.name === "" && aggregate.displayVersion === 5.6) { if (!componentVersionBucket.name && componentVersionBucket.displayVersion === '5.6') {
aggregate.name = "ROOT"; componentVersionBucket.name = 'ROOT'
aggregate.version = "5.6.0-RC1" componentVersionBucket.version = '5.6.0-RC1'
aggregate.startPage = "ROOT:index.adoc" delete componentVersionBucket.displayVersion
aggregate.displayVersion = `${aggregate.version}` componentVersionBucket.prerelease = true
aggregate.prerelease = true }
} else if (componentVersionBucket.version === '5.6.1') {
else if (aggregate.version === "5.6.1" && delete componentVersionBucket.prerelease
aggregate.prerelease == "-SNAPSHOT") { }
aggregate.version = "5.6.1" else if (typeof componentVersionBucket.prerelease === 'string' && componentVersionBucket.prerelease !== '-SNAPSHOT') {
aggregate.displayVersion = `${aggregate.version}` componentVersionBucket.version += componentVersionBucket.prerelease
aggregate.prerelease = true componentVersionBucket.prerelease = true
} }
else if (aggregate.prerelease && aggregate.prerelease != true) {
aggregate.version += aggregate.prerelease
aggregate.prerelease = true
}
})
}) })
} })
function out(args) {
console.log(JSON.stringify(args, no_data, 2));
}
function no_data(key, value) {
if (key == "data" || key == "files") {
return value ? "__data__" : value;
}
return value;
} }