switch to published partial build extension and remove local extension

This commit is contained in:
Dan Allen 2022-12-18 17:44:34 -07:00 committed by Marcus Hert Da Coregio
parent f500c0fbe0
commit 2fb91e6266
3 changed files with 4 additions and 60 deletions

View File

@ -1,12 +1,12 @@
antora: antora:
extensions: extensions:
- ./lib/antora/extensions/autoconfig-partial-build.js - '@springio/antora-extensions/partial-build-extension'
- ./lib/antora/extensions/inject-collector-config.js - ./lib/antora/extensions/inject-collector-config.js
- '@antora/collector-extension' - '@antora/collector-extension'
- ./lib/antora/extensions/version-fix.js - ./lib/antora/extensions/version-fix.js
- '@antora/atlas-extension' - '@antora/atlas-extension'
- '@opendevise/antora-release-line-extension' - '@opendevise/antora-release-line-extension'
- require: '@springio/asciidoctor-extensions/tabs-migration-antora-extension' - require: '@springio/antora-extensions/tabs-migration-extension'
# uncomment this option to save the migrated content to the worktree # uncomment this option to save the migrated content to the worktree
#save_result: true #save_result: true
unwrap_example_block: always unwrap_example_block: always

View File

@ -16,6 +16,7 @@ antora {
'@antora/collector-extension': '1.0.0-alpha.2', '@antora/collector-extension': '1.0.0-alpha.2',
'@asciidoctor/tabs': '1.0.0-alpha.11', '@asciidoctor/tabs': '1.0.0-alpha.11',
'@opendevise/antora-release-line-extension': '1.0.0-alpha.2', '@opendevise/antora-release-line-extension': '1.0.0-alpha.2',
'@springio/asciidoctor-extensions': '1.0.0-alpha.4', '@springio/antora-extensions': '1.0.0-alpha.2',
'@springio/asciidoctor-extensions': '1.0.0-alpha.7',
] ]
} }

View File

@ -1,57 +0,0 @@
'use strict'
const execFile = require('node:util').promisify(require('node:child_process').execFile)
const fsp = require('node:fs/promises')
const ospath = require('node:path')
module.exports.register = function () {
if (!process.env.BUILD_REFNAME) return
this.once('playbookBuilt', async ({ playbook }) => {
const { concat: get } = this.require('simple-get')
const asciidocAttrs = ((playbook.asciidoc ||= {}).attributes ||= {})
const siteManifestUrl = asciidocAttrs['primary-site-manifest-url'] || `${playbook.site.url}/site-manifest.json`
const siteManifestData = await (siteManifestUrl.startsWith('https://')
? download(get, siteManifestUrl)
: fsp.readFile(siteManifestUrl)
).then(JSON.parse)
let { BUILD_REFNAME: refname, BUILD_VERSION: version } = process.env
const isBranch = /[a-z]$/.test(refname)
if (!version) {
const repoUrl = await execFile('git', ['remote', 'get-url', 'origin']).then(({ stdout: output }) => output.trim())
const propertiesUrl = `${repoUrl.replace('github.com', 'raw.githubusercontent.com')}/${refname}/gradle.properties`
version = await download(get, propertiesUrl)
.then((contents) => contents.toString().split('\n').find((it) => it.startsWith('version='))?.slice(8))
}
if (isBranch && version.endsWith('-SNAPSHOT')) version = version.slice(0, -9)
const versionsInManifest = siteManifestData.components.ROOT.versions
if (!(version in versionsInManifest && isBranch === !!versionsInManifest[version].prerelease)) {
const category = require('path').basename(module.id, '.js')
await fsp.writeFile(ospath.join(playbook.dir, '.full-build'), '')
console.log(`version ${version} not previously built; reverting to full build`)
return
}
Object.assign(
playbook.content.sources[0],
isBranch ? { branches: [refname], tags: [] } : { branches: [], tags: [refname] }
)
Object.assign(
asciidocAttrs,
{ 'primary-site-url': '.', 'primary-site-manifest-url': siteManifestUrl }
)
this.updateVariables({ playbook })
})
}
function download (get, url) {
return new Promise((resolve, reject) =>
get({ url }, (err, response, contents) => {
if (err) reject(err)
if (response.statusCode !== 200) {
const message = `Response code ${response.statusCode} (${response.statusMessage})`
return reject(Object.assign(new Error(message), { name: 'HTTPError' }))
}
resolve(contents)
})
)
}