Skip to content

feat(site): add openstaxToSite to --import-structure - #32

Merged
btopro merged 1 commit into
haxtheweb:mainfrom
SanikaA3:feat/2912-openstax-cli
Sep 24, 2026
Merged

btopro merged 1 commit into
haxtheweb:mainfrom
SanikaA3:feat/2912-openstax-cli

Conversation

@SanikaA3

Copy link
Copy Markdown
Contributor

Refs haxtheweb/issues#2912 — step 3 of 3 from the implementation plan. The converter and its dispatcher case merged in haxtheweb/haxcms-nodejs#40, which closed the issue, but steps 2 and 3 were never done. This is the CLI half; the dashboard half is haxtheweb/webcomponents#828.

What was missing

hax site --import-site https://openstax.org/details/books/college-success-concise \
  --import-structure openstaxToSite --name college-success --y --no-i

openstaxToSite had no entry in IMPORT_STRUCTURE_MAP, so the name fell through to the hidden-methodologies branch and the command silently did nothing — no import, no error.

What this does

  • src/lib/programs/site.js — maps openstaxToSite to the site/import/:platform dispatcher case openstax, the same in-process on-prem route call the other platform converters make, so no server and no external service are involved.
  • src/create.js — lists it in the --import-structure help for both commands. xlsxToSite was mapped but missing from that help, so it is listed now too.
  • src/docs/hax.1 — the same two additions in the man page.
  • IMPORT_STRUCTURE_MAP is exported so the wiring can be asserted from tests.

Tests

test/unit/site-imports.test.cjs (4 tests) pins the wiring:

  • every platform importer maps to its dispatcher platform, openstaxToSite included;
  • openstaxToSite resolves to the openstax case;
  • docxToSite and xlsxToSite keep their own action routes;
  • every mapped importer appears in both the --import-structure help and the man page — the drift that let the OpenStax importer ship unreachable and left xlsxToSite undocumented.
check result
npm run test:unit 132 passed, 0 failed (4 new)
npm run test:smoke 15 skipped, as on a clean checkout

Removing the map entry fails two of the new tests; removing the name from either the help text or the man page fails the drift test. (node_modules was absent in my checkout, so the suite needs npm ci before it runs at all.)

One dependency note

The CLI reaches the converter through the published @haxtheweb/haxcms-nodejs, and the version this repo installs today (26.8.1) predates the converter, so this path starts working once a release carrying haxtheweb/haxcms-nodejs#40 is out. The dashboard half has no such wait: it calls the running instance's own route.

🤖 Generated with Claude Code

Refs haxtheweb/issues#2912. Step 3 of the plan on that issue: the
converter and its dispatcher case merged in haxtheweb/haxcms-nodejs#40,
but `hax site --import-site <book> --import-structure openstaxToSite` had
no mapping, so the name fell through to the hidden-methodologies branch
and silently did nothing.

Maps openstaxToSite to the site/import/:platform dispatcher case
'openstax' - the same in-process on-prem route call the other platform
converters make - and lists it in the --import-structure help for both
commands and in the man page. xlsxToSite was mapped but absent from both
lists, so it is listed now too.

IMPORT_STRUCTURE_MAP is exported so the wiring can be asserted, and
test/unit/site-imports.test.cjs covers it: every platform importer maps to
its dispatcher platform, docx and xlsx keep their own action routes, and
every mapped importer appears in both the help text and the man page. That
last check is the drift that let the OpenStax importer ship unreachable.

The CLI path depends on a published haxcms-nodejs that carries the
converter; @haxtheweb/haxcms-nodejs 26.8.1, the version this repo
installs today, predates it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@SanikaA3
SanikaA3 requested a review from btopro as a code owner September 24, 2026 01:58
@btopro
btopro merged commit 734b36a into haxtheweb:main Sep 24, 2026
2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants