Skip to content

Commit

Permalink
Compatibility with Asciidoctor.js 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Oct 12, 2023
1 parent e383df7 commit d7ad3fb
Show file tree
Hide file tree
Showing 19 changed files with 49,672 additions and 7,418 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
os:
- ubuntu-latest
node-version:
- 12.x
- 14.x
- 16
- 18
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
1,226 changes: 538 additions & 688 deletions dist/index.cjs

Large diffs are not rendered by default.

1,228 changes: 539 additions & 689 deletions dist/index.esm.js

Large diffs are not rendered by default.

1,232 changes: 541 additions & 691 deletions dist/index.umd.js

Large diffs are not rendered by default.

7,578 changes: 2,297 additions & 5,281 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@asciidoctor/docbook-converter",
"version": "3.0.0-alpha.1",
"description": "DocBook converter for Asciidoctor.js",
"type": "module",
"main": "dist/index.cjs",
"browser": "dist/index.umd.js",
"module": "dist/index.esm.js",
Expand All @@ -14,8 +15,8 @@
"build": "node tasks/build.js && rollup -c",
"test": "npm run test:node && npm run test:browser",
"test:node": "mocha",
"test:browser": "node test/browser/run.js index.esm.html && node test/browser/run.js index.umd.html",
"lint": "standard test/**.js tasks/**.js"
"test:browser": "node test/browser/run.cjs index.esm.html && npx rollup -c test/browser/rollup.config.js && node test/browser/run.cjs index.umd.html",
"lint": "standard test/**.cjs tasks/**.js"
},
"repository": {
"type": "git",
Expand All @@ -42,22 +43,22 @@
},
"homepage": "https://github.com/asciidoctor/asciidoctor-docbook.js",
"devDependencies": {
"@asciidoctor/core": "^2.0.0-rc.1",
"@asciidoctor/core": "~3.0",
"bestikk-download": "1.0.0",
"bestikk-fs": "1.0.0",
"bestikk-log": "0.1.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"mocha": "9.2.2",
"mock-http-server": "^1.4.2",
"opal-compiler": "^1.0.13",
"portfinder": "^1.0.26",
"chai": "~4.3",
"dirty-chai": "2.0.1",
"mocha": "~10.2",
"mock-http-server": "1.4.5",
"opal-compiler": "3.0.0",
"portfinder": "1.0.32",
"puppeteer": "^13.0.0",
"rollup": "^2.18.0",
"standard": "^16.0.3"
"rollup": "3.21.6",
"standard": "~17.0"
},
"peerDependencies": {
"@asciidoctor/core": "^2.0.0-rc.1"
"@asciidoctor/core": ">= 3.0 < 4.0"
},
"standard": {
"env": {
Expand Down
2 changes: 1 addition & 1 deletion tasks/build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Builder = require('./builder.js')
import Builder from './builder.js'
const builder = new Builder()

;(async () => {
Expand Down
19 changes: 9 additions & 10 deletions tasks/builder.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'use strict'
const fs = require('fs')
const log = require('bestikk-log')
const bfs = require('bestikk-fs')
const Download = require('bestikk-download')
const OpalBuilder = require('opal-compiler').Builder

import fs from 'node:fs'
import log from 'bestikk-log'
import bfs from 'bestikk-fs'
import Download from 'bestikk-download'
import { Builder as OpalBuilder } from 'opal-compiler'

const concat = (message, files, destination) => {
log.debug(message)
bfs.concatSync(files, destination)
}

const templateFile = function (templateFile, context, outputFile) {
const template = fs.readFileSync(templateFile, 'utf8')
const template = fs.readFileSync(templateFile, { encoding: 'utf8' })
const lines = template.split('\n')
lines.forEach(function (line, index, result) {
if (line in context) {
Expand Down Expand Up @@ -62,9 +63,9 @@ const compile = () => {
fs.writeFileSync(`build/asciidoctor-${module}.js`, opalBuilder.build(`asciidoctor/converter/${module}`).toString(), 'utf8')
}

class Builder {
export default class Builder {
constructor () {
this.asciidoctorCoreVersion = '2.0.10'
this.asciidoctorCoreVersion = '2.0.20'
this.download = new Download({})
}

Expand Down Expand Up @@ -99,5 +100,3 @@ class Builder {
await bfs.untar('build/asciidoctor.tar.gz', 'asciidoctor', 'build')
}
}

module.exports = Builder
File renamed without changes.
3 changes: 1 addition & 2 deletions test/browser/index.esm.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<script src="../../node_modules/mocha/mocha.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<script src="../../node_modules/dirty-chai/lib/dirty-chai.js"></script>
<script src="../../node_modules/@asciidoctor/core/dist/browser/asciidoctor.js"></script>
<script src="../shared/spec.js"></script>
<script src="../shared/spec.cjs"></script>
<script type="module" src="spec.esm.js"></script>
</body>
</html>
Expand Down
3 changes: 1 addition & 2 deletions test/browser/index.umd.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
<script src="../../node_modules/mocha/mocha.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<script src="../../node_modules/dirty-chai/lib/dirty-chai.js"></script>
<script src="../../node_modules/@asciidoctor/core/dist/browser/asciidoctor.js"></script>
<script src="../../dist/index.umd.js"></script>
<script src="../shared/spec.js"></script>
<script src="../shared/spec.cjs"></script>
<script src="spec.umd.js"></script>
</body>
</html>
Expand Down
6 changes: 3 additions & 3 deletions test/browser/mock-server.js → test/browser/mock-server.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

const fs = require('fs')
const childProcess = require('child_process')
const fs = require('node:fs')
const childProcess = require('node:child_process')

class MockServer {
constructor (listener) {
// we need to use "fork" to spawn a new Node.js process otherwise we will create a deadlock.
this.childProcess = childProcess.fork(`${__dirname}/bin/mock-server.js`)
this.childProcess = childProcess.fork(`${__dirname}/bin/mock-server.cjs`)
if (listener) {
this.childProcess.on('message', listener)
}
Expand Down
13 changes: 13 additions & 0 deletions test/browser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as url from 'node:url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

export default [
{
input: `${__dirname}/spec.esm.js`,
output: {
file: `${__dirname}/spec.umd.js`,
name: 'AsciidoctorDocBookSpec',
format: 'umd'
}
},
]
4 changes: 2 additions & 2 deletions test/browser/run.js → test/browser/run.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env node, es6 */
const puppeteer = require('puppeteer')
const MockServer = require('./mock-server.js')
const util = require('./util.js')
const MockServer = require('./mock-server.cjs')
const util = require('./util.cjs')

// puppeteer options
const opts = {
Expand Down
4 changes: 3 additions & 1 deletion test/browser/spec.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* global AsciidoctorBrowserSpec, mocha, mochaOpts, testOpts */

import Asciidoctor from '../../node_modules/@asciidoctor/core/dist/browser/asciidoctor.js'
import AsciidoctorDocBook from '../../dist/index.esm.js'

(async () => {
Expand All @@ -15,7 +17,7 @@ import AsciidoctorDocBook from '../../dist/index.esm.js'
reporter: reporter
})

const asciidoctor = globalThis.Asciidoctor()
const asciidoctor = Asciidoctor()
AsciidoctorDocBook.register()

const expect = chai.expect
Expand Down
Loading

0 comments on commit d7ad3fb

Please sign in to comment.