Skip to content

feat(migrate): WP REST source + shortcodes + URL rewriting + role mapping - #477

Merged
tayebmokni merged 4 commits into
mainfrom
feat/migrate-wprest-shortcodes-urls
May 26, 2026
Merged

feat(migrate): WP REST source + shortcodes + URL rewriting + role mapping#477
tayebmokni merged 4 commits into
mainfrom
feat/migrate-wprest-shortcodes-urls

Conversation

@tayebmokni

Copy link
Copy Markdown
Contributor

Closes #163, #174, #192, #199.

WP migration extensions:

  • packages/go/migrate/wprest: live WP REST API source with Application Passwords + pagination
  • packages/go/migrate/shortcode: parser + map/preserve/strip modes + 6 built-in translators
  • packages/go/migrate/urlrewrite: content URL rewriter for media references
  • RoleMapper in importer: built-in + custom + --role-map override

🤖 Generated with Claude Code

@tayebmokni
tayebmokni enabled auto-merge (squash) May 25, 2026 22:28
tib0o0o and others added 4 commits May 26, 2026 19:32
Add RoleMapper that translates WP role slugs to GoNext policy.Role:
- Built-in table for the 6 WP roles (super_admin → super_admin,
  administrator → admin, editor, author, contributor, subscriber)
- RegisterOverride / ParseOverrideFlag for --role-map old=new CLI flag
- Heuristic fallback by name fragment with operator-visible warnings
- Validates override targets against policy.BuiltinRoles

Closes #199.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
New package packages/go/migrate/shortcode:
- Single-pass scanner handling self-closing ([n /]) and enclosing
  ([n]inner[/n]) forms with same-name nesting via depth counting
- Attribute parser for "key=value", 'key=value', bare values, and
  positional values; bracket chars inside quoted values tolerated
- Registry with 6 built-in translators: caption, gallery, video,
  audio, embed, contact-form-7
- Three operator modes: ModeMap (translate via registry, fall back to
  preserve), ModePreserve (verbatim core/html), ModeStrip (drop tags,
  keep inner text)
- ParseMode CLI helper, per-mode counters in Result

Closes #174.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
New package packages/go/migrate/urlrewrite:
- Rewriter operates on raw HTML fragments (no DOM parse) using
  attribute-anchored regex so prose URLs aren't touched
- Handles src, href, poster, data-src on common media tags
- Splits and rewrites srcset entries independently, preserving
  descriptors
- Rewrites url(...) inside style="…" attrs, preserving the original
  quoting style
- Lookup falls back through: exact, lowercased, path-only against
  LegacyHosts, then optional NewBaseURL safety net
- Both string and []byte entry points; nil receiver safe

Closes #192.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
New package packages/go/migrate/wprest:
- Client targets /wp-json/wp/v2/ with per_page=100 + page-counter
  pagination via X-WP-TotalPages
- Application Passwords auth (HTTP Basic, spaces stripped from the
  WP-formatted token)
- FetchAuthors / FetchCategories / FetchTags / FetchPosts /
  FetchPages / FetchMedia each yield wxr.* records so the importer
  pipeline doesn't care which source it's reading from
- FetchAll convenience drains every endpoint in importer order
- WP error JSON ({code,message}) surfaced in returned errors
- Integration test against an httptest.Server replaying JSON
  fixtures in testdata/

Closes #163.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
@tayebmokni
tayebmokni force-pushed the feat/migrate-wprest-shortcodes-urls branch from 8dbb900 to af82f85 Compare May 26, 2026 17:32
@tayebmokni
tayebmokni merged commit cc34232 into main May 26, 2026
18 of 24 checks passed
@tayebmokni
tayebmokni deleted the feat/migrate-wprest-shortcodes-urls branch May 26, 2026 21:39
tayebmokni added a commit that referenced this pull request May 26, 2026
… migration verification (#487)

Closes #47, #139, #174, #192, #199, #231, #254.

## Summary

- **#47 Responsive image React helper** — new
`apps/web/src/components/responsive-image/` with `<ResponsiveImage src
alt sizes [sources|widths]>` using `<picture>` + `srcset`. Pairs with
the wire shape emitted by `packages/go/media/imageproc/srcset.go`
(PictureSource = { srcset, type }).
- **#139 Theme signing pipeline** — new
`.github/workflows/theme-publish.yml`; mirrors the plugin signing flow
from #130. On a `theme/<slug>/vX.Y.Z` tag push, zips the theme,
cosign-keyless-signs (Fulcio OIDC), attaches bundle + signature + cert
chain to the GitHub release.
- **#174 Shortcode handling** — verified shipped via #477.
`packages/go/migrate/shortcode/` provides the parser, map/preserve/strip
modes via `process.go`, and 6 built-in translators registered via
`RegisterDefaults()`.
- **#192 URL rewriting in migrated content** — verified shipped via
#477. `packages/go/migrate/urlrewrite/` provides the WP media URL
rewriter for post content.
- **#199 WP role mapping** — verified shipped via #477.
`packages/go/migrate/importer/roles.go` provides `RoleMapper` with WP
built-in slugs → GoNext Role values plus `--role-map` overrides.
- **#231 gonext migrate CLI subcommands** — verified `status`, `down N`,
`verify`, and `wp <wxr-file>` already shipped. Added the remaining
`gonext migrate to <version>` subcommand backed by
`packages/go/migrate.To` (under the same advisory lock used by
Run/Down/Status). Rejects target=0 — destructive intent must go through
`migrate down 0`.
- **#254 Refine CI workflow** — path-filter granularity was already in
place; added 2-shard go test matrix (modules deterministically
partitioned), per-shard atomic coverage profiles, and a new
`test-go-coverage` job that merges profiles and enforces an 80%
project-wide gate (advisory until the codebase catches up, same pattern
as `bundle-budget`).

## Test plan

- [x] `apps/web` typecheck passes
- [x] `vitest run responsive-image` — 12 / 12 pass
- [x] `go test ./migrate/` — pkgmigrate tests pass (To zero-target
validation included)
- [x] `go test ./cli/gonext/cmd/migrate/` — CLI tests pass
(to-subcommand validation included)
- [x] `python3 -c 'import yaml; yaml.safe_load(...)'` on both workflow
files
- [ ] CI runs both workflows on this PR

---------

Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
Co-authored-by: Tayeb Mokni <tayeb.mokni@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

WP REST API source (live WP, no DB access)

2 participants