Skip to content

refactor: migrate to Asciidoctor.js 4.0 - #485

Merged
ggrossetie merged 25 commits into
masterfrom
asciidoctor4
May 12, 2026
Merged

ggrossetie merged 25 commits into
masterfrom
asciidoctor4

Conversation

@ggrossetie

Copy link
Copy Markdown
Member

No description provided.

ggrossetie and others added 21 commits May 4, 2026 13:17
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Require @asciidoctor/core >= 4.0.0-alpha (named ESM exports, async API)
- Replace Opal/Ruby-style calls ($read, $resolve_subs, $title=, $assign_caption)
  with native JS equivalents (read, resolveSubs, block.title, assignCaption)
- Make block/macro process() callbacks async to match async reader.read() and applySubs()
- Replace LoggerManager from Opal global with named import from @asciidoctor/core
- Remove Antora adapter (Antora uses Asciidoctor 2, incompatible with v4)
- Remove @antora/site-generator-default, cheerio devDependencies
- Remove mkdirp dependency, replaced by fs.mkdirSync({ recursive: true })
- Remove rusha dependency, replaced by node:crypto createHash('sha1')
- Add node:crypto and node:fs/promises browser shims for Vitest
- Exclude preprocess.test.js from browser tests (uses convertFile, Node.js only)
- Replace assert.ok(x.includes(y)) with assertContains(x, y) across all test files
  for clearer failure messages showing actual vs expected content

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests requiring fs, convertFile, Docker containers, or worker_threads
are now under test/node/ to make environment requirements structurally
obvious. Shared tests (e.g. block-attributes.test.js) remain at the
test/ root and continue to run in both Node and browser environments.

Update vitest exclude from a per-file list to 'node/**', and extend
the test:node npm script to cover test/node/*.test.js.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ontainers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the synchronous XMLHttpRequest-based HTTP client with the native
fetch API, leveraging async/await support introduced in asciidoctor/core 4.

- Remove unxhr dependency
- Rewrite http-client.js using fetch (browser and Node.js 24+)
- Collapse browser-http.js and node-http.js into a single re-export
- Make KrokiClient.getImage() and getTextContent() async
- Make fetch.save(), node-fs.read() and all preprocess functions async
- Convert synchronous map() loops to sequential for...of with await
- Update tests: assertThrows → assertRejects, add async/await throughout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ation

- Drop Node 22, keep only Node 24 in CI matrix
- Upgrade checkout/setup-node actions to v6
- Switch Puppeteer system dep to Playwright Chromium
- Add extension registration test (moved from extension.test.js)
- Update browser shims (node-assert, node-fs, node-http, node-module,
  node-path, node-test, node-url, setup, mkdirp) for ESM compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unused ES5-style error constructors (UnsupportedFormatError, InvalidConfigurationError)
- Remove leftover unxhr stubs and externals from rollup config (replaced by native fetch)
- Replace deprecated String.prototype.substr with slice
- Remove outdated eslint-disable comments (project uses Biome)
- Apply Biome formatting and import ordering across src and test files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add resolveVfs() to node-fs.js to centralize the VFS-with-fs-fallback
  pattern that was duplicated 6 times across fetch.js, preprocess.js and
  antora-adapter.js
- Update the browser rollup stub for node-fs.js to expose resolveVfs
- Remove now-unused default fs imports from fetch.js and preprocess.js
- Simplify the role building in processKroki: format always has a value
  (defaults to 'svg'), so the inner if(format) branch was dead code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Now that both environments use native fetch, browser-http.js and
node-http.js were identical re-exports of http-client.js. Remove them
and import http-client.js directly everywhere.

- Delete src/http/browser-http.js and src/http/node-http.js
- Import http-client.js directly in asciidoctor-kroki.js and node-fs.js
- Drop the isBrowser() httpClient selection (single implementation now)
- Remove the node-http.js PATH_STUB from rollup config
- Update test imports accordingly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…block.test.js

Also fix .gitignore to cover nested node_modules/ (e.g. test/node_modules/).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace deprecated actions/create-release and actions/upload-release-asset
with a single gh release create call, and align package.sh output paths
(bin/ → dist/) with the updated workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace generic names like "converts a diagram to an image" or
"returns diagramText with inlined..." with names that describe the
specific behavior under test: what configuration is exercised, what
the observable outcome is, and what edge case is covered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le file

Move the tests that rely only on mock HTTP clients (kroki-http-method,
kroki-max-uri-length, adaptive mode logic) from test/node/kroki-client.test.js
to a new test/kroki-client.test.js so they run in both the Node.js and
browser test suites. Remove the duplicate test for the undefined method case.

The remaining test/node/kroki-client.test.js keeps only the two skipped
tests that require a real Kroki server via testcontainers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bump the Kroki container version from 0.28.0 to 0.30.1, update the
expected SVG fixtures to match, and remove the test.skip on the two
adaptive mode tests now that the regression is resolved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ggrossetie
ggrossetie force-pushed the asciidoctor4 branch 2 times, most recently from 40cedb1 to 91d41c9 Compare May 5, 2026 15:37
The Kroki server produces slightly different SVG output on macOS vs Linux.
Add chart-macos.svg and cars-repeated-charts-macos.svg fixtures and
select them when the test runs on darwin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ggrossetie and others added 3 commits May 5, 2026 17:52
…on Windows

preprocess.js uses path.posix throughout, which treats backslashes as
literal characters rather than path separators. On Windows, path.dirname
returned native backslash paths (e.g. D:\...\child), causing
path.posix.join to produce a path where the drive-letter segment is
mistakenly consumed by ".." resolution, leaving a relative path that
no longer points to the included file.

Normalizing backslashes to forward slashes in node-fs.js parse() ensures
that resource.dir is always posix-compatible, so relative !include
directives (e.g. !include ../../base.iuml) inside nested files are
resolved correctly on all platforms.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Docker/testcontainers is not available on Windows CI runners. Guard
globalSetup.js so the Kroki container is only started on non-Windows
platforms (krokiUrl is not provided otherwise). Exclude
browser/browser.integration.test.js from the Vitest browser run on
Windows since it depends on the injected krokiUrl.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd stub node:crypto for browser build

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ggrossetie
ggrossetie merged commit f4f8cb1 into master May 12, 2026
2 checks passed
@ggrossetie
ggrossetie deleted the asciidoctor4 branch May 13, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant