Skip to content

Commit

Permalink
Ignore name in zipped antora.yml if it is different
Browse files Browse the repository at this point in the history
Closes gh-10
  • Loading branch information
philwebb committed Apr 4, 2024
1 parent 921f44a commit 578649b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/antora-zip-contents-collector-extension/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ function register ({ config, downloadLog }) {
const existing = componentVersionBucket.files.find((candidate) => candidate.src.path === file.src.path)
if (file.src.path === 'antora.yml' || file.src.path === 'modules/antora.yml') {
const generated = yaml.load(file.contents)
if (generated.name && componentVersionBucket.name !== generated.name) {
delete generated.name
}
Object.assign(componentVersionBucket, generated)
if (!('prerelease' in generated)) delete componentVersionBucket.prerelease
} else if (existing) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: bad
version: 1.0.0
title: Test
asciidoc:
attributes:
url-api: https://api.example.org
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,31 @@ describe('zip contents collector extension', () => {
})
})

it('should not change name in component metadata if set in antora.yml', async () => {
const extensionConfig = () => ({
locations: [{ url: `http://localhost:${httpServerPort}/\${name}.zip` }],
})
const componentConfig = { include: ['component-desc-with-bad-name'] }
await runScenario({
repoName: 'test-at-root',
extensionConfig,
componentConfig,
zipFiles: ['component-desc-with-bad-name'],
httpPath: '/',
before: ({ contentAggregate }) => {
expect(contentAggregate).to.have.lengthOf(1)
const bucket = contentAggregate[0]
expect(bucket.version).to.equal('main')
expect(bucket.files).to.be.empty()
},
after: ({ contentAggregate }) => {
expect(contentAggregate).to.have.lengthOf(1)
const bucket = contentAggregate[0]
expect(bucket.name).to.equal('test')
},
})
})

it('should update component metadata from antora.yml file, if found in modules', async () => {
const extensionConfig = () => ({
locations: [{ url: `http://localhost:${httpServerPort}/\${name}.zip` }],
Expand Down

0 comments on commit 578649b

Please sign in to comment.