feat(migrate): WP REST source + shortcodes + URL rewriting + role mapping - #477
Merged
Conversation
tayebmokni
enabled auto-merge (squash)
May 25, 2026 22:28
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
force-pushed
the
feat/migrate-wprest-shortcodes-urls
branch
from
May 26, 2026 17:32
8dbb900 to
af82f85
Compare
Merged
6 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #163, #174, #192, #199.
WP migration extensions:
🤖 Generated with Claude Code