@antora/pdf-extension 1.0.0-beta.9 → 1.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,7 +21,9 @@ antora:
21
21
  # ...
22
22
  ```
23
23
 
24
- You can configure the behavior of the extension using the optional _antora-assembler.yml_ file.
24
+ You can configure the behavior of the extension using the optional configuration file, named _antora-assembler.yml_ by default.
25
+ When using more than one exporter extension, you likely want to use a dedicated configuration file named according to the export filetype (e.g., _antora-assembler-pdf.yml_).
26
+ The configuration file can be specified using the `config_file` key on the extension entry.
25
27
 
26
28
  ## Copyright and License
27
29
 
package/lib/converter.js CHANGED
@@ -3,29 +3,33 @@
3
3
  const fsp = require('node:fs/promises')
4
4
  const ospath = require('node:path')
5
5
 
6
- const DEFAULT_COMMAND = 'asciidoctor-pdf'
6
+ const DEFAULT_COMMAND = 'asciidoctor-pdf --sourcemap'
7
+ const PACKAGE_NAME = require('../package.json').name
7
8
 
8
- async function convert (runCommand, file, convertAttributes, buildConfig) {
9
- const { command, cwd = process.cwd(), stderr = 'print' } = buildConfig
10
- const args = convertAttributes.toArgs('-a', command).concat('-o', convertAttributes.outfile, '-')
11
- return runCommand(command, args, { parse: true, cwd, stdin: file.contents, stdout: 'print', stderr })
9
+ async function convert (file, conversionAttributes, buildConfig, { logCommand, runCommand }) {
10
+ const { command, cwd = process.cwd(), attributeOptionFlag, stderr = 'print' } = buildConfig
11
+ if (!command) return null
12
+ const outputOptionFlag = buildConfig.outputOptionFlag || (buildConfig.outputOptionFlag === false ? false : '-o')
13
+ const extraArgs = conversionAttributes.toArgs(attributeOptionFlag || '-a', outputOptionFlag)
14
+ const stdout = outputOptionFlag ? 'print' : 'buffer'
15
+ logCommand?.(command, extraArgs, file, conversionAttributes)
16
+ return runCommand(command, extraArgs.concat('-'), { parse: true, cwd, stdin: file.contents, stdout, stderr })
12
17
  }
13
18
 
14
- function getDefaultCommand (cwd) {
15
- return fsp.access(ospath.join(cwd, 'Gemfile.lock')).then(
16
- () => `bundle exec ${DEFAULT_COMMAND}`,
17
- () => DEFAULT_COMMAND
19
+ function getDefaultCommand (cwd, playbook) {
20
+ const defaultCommand = playbook?.runtime.stacktrace ? `${DEFAULT_COMMAND} --trace` : DEFAULT_COMMAND
21
+ const bundleLockfile = playbook?.env.BUNDLE_LOCKFILE ?? `${playbook?.env.BUNDLE_GEMFILE ?? 'Gemfile'}.lock`
22
+ return fsp.access(ospath.resolve(cwd, bundleLockfile)).then(
23
+ () => `bundle exec ${defaultCommand}`,
24
+ () => defaultCommand
18
25
  )
19
26
  }
20
27
 
21
28
  module.exports = {
22
- bind (thisArg, runCommand) {
23
- return Object.assign({}, this, { convert: convert.bind(thisArg, runCommand) })
24
- },
25
29
  convert,
26
30
  backend: 'pdf',
27
31
  getDefaultCommand,
28
32
  extname: '.pdf',
29
33
  mediaType: 'application/pdf',
30
- loggerName: require('../package.json').name,
34
+ loggerName: PACKAGE_NAME,
31
35
  }
package/lib/index.js CHANGED
@@ -1,15 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ const { configure: configureAssembler } = require('@antora/assembler')
3
4
  const converter = require('./converter')
4
- const runCommand = require('@antora/run-command-helper')
5
5
 
6
6
  module.exports.register = function ({ config }, providers) {
7
- requireAssembler(this).configure(this, converter.bind(this, runCommand), config, providers)
8
- }
9
-
10
- function requireAssembler (context, packageName = '@antora/assembler') {
11
- try {
12
- return context.require(packageName) // when installed with Antora
13
- } catch {}
14
- return require(packageName) // when installed separate from Antora, perhaps in project
7
+ configureAssembler(this, converter, config, providers)
15
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antora/pdf-extension",
3
- "version": "1.0.0-beta.9",
4
- "description": "An Antora extension that uses Assembler to merge pages into assembly files, export them to the PDF format, and publishe them with the site.",
3
+ "version": "1.0.0-rc.10",
4
+ "description": "An Antora extension that uses Assembler to merge pages into assembly files, export them to the PDF format, and publish them with the site.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
7
7
  "contributors": [
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "scripts": {
21
21
  "test": "node --test test/*-test.js",
22
- "prepublishOnly": "npx -y downdoc --prepublish",
23
- "postpublish": "npx -y downdoc --postpublish"
22
+ "prepublishOnly": "npx -y downdoc@latest --prepublish",
23
+ "postpublish": "npx -y downdoc@latest --postpublish"
24
24
  },
25
25
  "main": "lib/index.js",
26
26
  "exports": {
@@ -32,11 +32,10 @@
32
32
  "#package": "./package.json"
33
33
  },
34
34
  "dependencies": {
35
- "@antora/assembler": "1.0.0-beta.9",
36
- "@antora/run-command-helper": "~1.0"
35
+ "@antora/assembler": "1.0.0-rc.10"
37
36
  },
38
37
  "engines": {
39
- "node": ">=16.0.0"
38
+ "node": ">=20.0.0"
40
39
  },
41
40
  "files": [
42
41
  "lib/"