Skip to content

Commit

Permalink
Fix Windows related issues
Browse files Browse the repository at this point in the history
Fixes gh-2
  • Loading branch information
philwebb committed Mar 21, 2024
1 parent e40659e commit 7ae69ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
13 changes: 6 additions & 7 deletions packages/antora-zip-contents-collector-extension/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ function register ({ config, downloadLog }) {

async function uiLoaded ({ uiCatalog }) {
const layouts = uiCatalog.findByType('layout')
if (layouts.filter((file) => file.path === 'layouts/bare.hbs').length === 0) {
if (layouts.filter((file) => file.src.path === 'layouts/bare.hbs').length === 0) {
logger.trace("Adding 'bare' layout to UI catalog")
const file = new Vinyl({
path: 'layouts/bare.hbs',
contents: Buffer.from('{{{page.contents}}}'),
})
file.type = 'layout'
file.src = {path: 'layouts/bare.hbs'}

Check failure on line 108 in packages/antora-zip-contents-collector-extension/lib/index.js

View workflow job for this annotation

GitHub Actions / build

A space is required after '{'

Check failure on line 108 in packages/antora-zip-contents-collector-extension/lib/index.js

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'
uiCatalog.addFile(file)
}
}
Expand Down Expand Up @@ -362,9 +363,9 @@ function register ({ config, downloadLog }) {
let destination = include.module && ospath.join('modules', include.module)
destination = include.path && (destination ? ospath.join(destination, include.path) : include.path)
file = asAntoraFile(include, zipFile, file, destination)
logger.trace(`Adding ${file.path} to content aggregate`)
const existing = componentVersionBucket.files.find(({ path: candidate }) => candidate === file.path)
if (file.path === 'antora.yml' || file.path === 'modules/antora.yml') {
logger.trace(`Adding ${file.src.path} to content aggregate`)
const existing = componentVersionBucket.files.find(candidate => candidate.src.path === file.src.path)

Check failure on line 367 in packages/antora-zip-contents-collector-extension/lib/index.js

View workflow job for this annotation

GitHub Actions / build

Expected parentheses around arrow function argument
if (file.src.path === 'antora.yml' || file.src.path === 'modules/antora.yml') {
const generated = yaml.load(file.contents)
Object.assign(componentVersionBucket, generated)
if (!('prerelease' in generated)) delete componentVersionBucket.prerelease
Expand Down Expand Up @@ -407,11 +408,9 @@ function register ({ config, downloadLog }) {
const extname = ospath.extname(path)
const stem = basename.slice(0, basename.length - extname.length)
const mediaType = mimeTypes.lookup(extname) || fallbackMediaType
const result = Object.assign(file.clone(), {
return Object.assign(file.clone(), {
src: { origin: include.origin, path, basename, stem, extname, abspath: path, mediaType, zipFile, ...src },
})
result.path = path
return result
}

async function cleanupCollectorCacheDir (collectorCacheDir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand All @@ -116,7 +116,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand All @@ -142,7 +142,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand All @@ -165,8 +165,8 @@ describe('zip contents collector extension', () => {
httpPath: '/',
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(2)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/c1.adoc')
expect(contentAggregate[0].files[1].path).to.equal('modules/ROOT/pages/c2.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/c1.adoc')
expect(contentAggregate[0].files[1].src.path).to.equal('modules/ROOT/pages/c2.adoc')
},
})
})
Expand All @@ -188,7 +188,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand Down Expand Up @@ -264,7 +264,7 @@ describe('zip contents collector extension', () => {
httpPath: '/v1.2.3',
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(2)
const page = contentAggregate[0].files.find((it) => it.relative === 'modules/ROOT/pages/index.adoc')
const page = contentAggregate[0].files.find((it) => it.src.path === 'modules/ROOT/pages/index.adoc')
expect(page).to.be.exist()
},
})
Expand All @@ -284,7 +284,7 @@ describe('zip contents collector extension', () => {
httpPath: '/v1.2.3',
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(2)
const page = contentAggregate[0].files.find((it) => it.relative === 'modules/ROOT/pages/index.adoc')
const page = contentAggregate[0].files.find((it) => it.src.path === 'modules/ROOT/pages/index.adoc')
expect(page).to.be.exist()
},
})
Expand All @@ -304,7 +304,7 @@ describe('zip contents collector extension', () => {
httpPath: '/v1.2.3',
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(2)
const page = contentAggregate[0].files.find((it) => it.relative === 'modules/ROOT/pages/index.adoc')
const page = contentAggregate[0].files.find((it) => it.src.path === 'modules/ROOT/pages/index.adoc')
expect(page).to.be.exist()
},
})
Expand All @@ -325,7 +325,7 @@ describe('zip contents collector extension', () => {
httpPath: '/v1.2.3',
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(2)
const page = contentAggregate[0].files.find((it) => it.relative === 'modules/ROOT/pages/index.adoc')
const page = contentAggregate[0].files.find((it) => it.src.path === 'modules/ROOT/pages/index.adoc')
expect(page).to.be.exist()
},
})
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('zip contents collector extension', () => {
downloadLog,
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(2)
const page = contentAggregate[0].files.find((it) => it.relative === 'modules/ROOT/pages/index.adoc')
const page = contentAggregate[0].files.find((it) => it.src.path === 'modules/ROOT/pages/index.adoc')
expect(page).to.be.exist()
expect(downloadLog.length).to.equal(1)
expect(downloadLog[0].url).to.equal(`http://localhost:${httpServerPort}/release/v1.2.3/start-page.zip`)
Expand Down Expand Up @@ -418,7 +418,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand Down Expand Up @@ -447,7 +447,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('zip contents collector extension', () => {
times: 2,
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
expect(downloadLog.length).to.equal(2)
expect(downloadLog[0].statusCode).to.equal(200)
expect(downloadLog[1].statusCode).to.equal(304)
Expand All @@ -579,7 +579,7 @@ describe('zip contents collector extension', () => {
times: 2,
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
expect(downloadLog.length).to.equal(4)
expect(downloadLog[0].statusCode).to.equal(404)
expect(downloadLog[1].statusCode).to.equal(200)
Expand Down Expand Up @@ -610,7 +610,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand All @@ -632,7 +632,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand Down Expand Up @@ -662,7 +662,7 @@ describe('zip contents collector extension', () => {
This is the real deal.
`
expect(contentAggregate[0].files[0].contents.toString()).to.equal(expectedContents + '\n')
expect(contentAggregate[0].files[0].contents.toString().replace(/\r/g, '')).to.equal(expectedContents + '\n')
expect(contentAggregate[0].files[0].stat).to.not.equal(originalStat)
expect(contentAggregate[0].files[0].stat.size).to.not.equal(originalStat.size)
expect(contentAggregate[0].files[0].src).to.not.have.property('scanned')
Expand Down Expand Up @@ -690,13 +690,12 @@ describe('zip contents collector extension', () => {
expect(contentAggregate[0].files).to.have.lengthOf(0)
const files = contentCatalog.getFiles()
const src = files[0].src
expect(files.filter((file) => file.path === 'api/java/README')).to.have.lengthOf(1)
expect(files.filter((file) => file.path === 'api/java/javadoc.css')).to.have.lengthOf(1)
expect(files.filter((file) => file.path === 'api/java/javadoc.html')).to.have.lengthOf(1)
expect(files.filter((file) => file.src.path === 'api/java/README')).to.have.lengthOf(1)
expect(files.filter((file) => file.src.path === 'api/java/javadoc.css')).to.have.lengthOf(1)
expect(files.filter((file) => file.src.path === 'api/java/javadoc.html')).to.have.lengthOf(1)
expect(src.module).to.be.equal('ROOT')
expect(src.family).to.be.equal('page')
expect(src.component).to.be.equal('test')
expect(src.relative).to.be.equal('api/java/README')
},
})
})
Expand All @@ -719,13 +718,12 @@ describe('zip contents collector extension', () => {
expect(contentAggregate[0].files).to.have.lengthOf(0)
const files = contentCatalog.getFiles()
const src = files[0].src
expect(files.filter((file) => file.path === 'api/java/README')).to.have.lengthOf(1)
expect(files.filter((file) => file.path === 'api/java/javadoc.css')).to.have.lengthOf(1)
expect(files.filter((file) => file.path === 'api/java/javadoc.html')).to.have.lengthOf(1)
expect(files.filter((file) => file.src.path === 'api/java/README')).to.have.lengthOf(1)
expect(files.filter((file) => file.src.path === 'api/java/javadoc.css')).to.have.lengthOf(1)
expect(files.filter((file) => file.src.path === 'api/java/javadoc.html')).to.have.lengthOf(1)
expect(src.module).to.be.equal('mymodule')
expect(src.family).to.be.equal('page')
expect(src.component).to.be.equal('test')
expect(src.relative).to.be.equal('api/java/README')
},
})
})
Expand Down Expand Up @@ -794,7 +792,7 @@ describe('zip contents collector extension', () => {
after: ({ uiCatalog }) => {
const layouts = uiCatalog.findByType('layout')
expect(layouts).to.have.lengthOf(1)
expect(layouts[0].path).to.be.equal('layouts/bare.hbs')
expect(layouts[0].src.path).to.be.equal('layouts/bare.hbs')
},
})
})
Expand All @@ -816,12 +814,13 @@ describe('zip contents collector extension', () => {
contents: Buffer.from('test'),
})
file.type = 'layout'
file.src = {path: 'layouts/bare.hbs'}

Check failure on line 817 in packages/antora-zip-contents-collector-extension/test/zip-contents-collector-extension-test.js

View workflow job for this annotation

GitHub Actions / build

A space is required after '{'

Check failure on line 817 in packages/antora-zip-contents-collector-extension/test/zip-contents-collector-extension-test.js

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'
uiCatalog.addFile(file)
},
after: ({ uiCatalog }) => {
const layouts = uiCatalog.findByType('layout')
expect(layouts).to.have.lengthOf(1)
expect(layouts[0].path).to.be.equal('layouts/bare.hbs')
expect(layouts[0].src.path).to.be.equal('layouts/bare.hbs')
expect(layouts[0].contents.toString()).to.be.equal('test')
},
})
Expand All @@ -845,7 +844,7 @@ describe('zip contents collector extension', () => {
},
after: ({ contentAggregate }) => {
expect(contentAggregate[0].files).to.have.lengthOf(1)
expect(contentAggregate[0].files[0].path).to.equal('modules/ROOT/pages/index.adoc')
expect(contentAggregate[0].files[0].src.path).to.equal('modules/ROOT/pages/index.adoc')
},
})
})
Expand Down

0 comments on commit 7ae69ee

Please sign in to comment.