Skip to content

Add cPanel UAPI pull integration (v1 proof of concept)#2835

Closed
georgestephanis wants to merge 2 commits intoAutomattic:trunkfrom
georgestephanis:add-cpanel
Closed

Add cPanel UAPI pull integration (v1 proof of concept)#2835
georgestephanis wants to merge 2 commits intoAutomattic:trunkfrom
georgestephanis:add-cpanel

Conversation

@georgestephanis
Copy link

Related issues

  • Related to: cPanel hosting provider integration

How AI was used in this PR

This PR was built with Claude Code (AI pair programming). The architecture was designed collaboratively: explored the existing WP.com sync flow, documented it in SYNC_ARCHITECTURE.md, then planned the cPanel integration in CPANEL_INTEGRATION.md before implementation. All code was reviewed and iterated on for type safety and lint compliance.

Key AI contributions: UAPI client, Jetpack-format archive construction, Redux slice + IPC event bridge, RTK Query API, UI components. Human review recommended before merge especially on the cPanel API interaction patterns and the archive building logic.

Proposed Changes

  • New: cPanel UAPI pull flow — pull a remote WordPress site hosted on cPanel into a local Studio site
  • Connection setup — hostname, port (default 2083), username, API token (no OAuth), WordPress path, database name; credentials validated on connect via Fileman::list_files
  • Pull flow: compress wp-content on server → download archive → dump database via Mysql::dump_database_schema → build Jetpack-format tar.gz locally → stop local server → import via existing importBackup() → restart
  • Cancellation — AbortController registry, cancel button in UI, cancelCpanelPull IPC handler
  • Progress trackingcpanel-pull-progress IPC event → Redux slice → progress bar in UI (compressing → downloading → exporting-db → building-archive → importing → finished/failed/cancelled)
  • StorageconnectedCpanelSites array in appdata-v1.json with file locking
  • UI — "Connect cPanel site" button in Sync tab, credentials modal, connected site card with pull button/progress/cancel

Testing Instructions

Note: Requires a live cPanel hosting account with API tokens enabled.

  1. Build the app: npm start
  2. Open the Sync tab for any local site
  3. Click "Connect cPanel site"
  4. Enter your cPanel credentials (hostname without protocol, API token from cPanel → Security → Manage API Tokens, WordPress path e.g. public_html)
  5. Click Connect — should validate and show the connected site
  6. Click Pull — observe progress through compressing → downloading → importing stages
  7. Verify local site content matches remote after pull completes
  8. Test cancel: start a pull, click Cancel during downloading phase
  9. Test disconnect: click the disconnect option on a connected site

Without a live cPanel account: Review the architecture in CPANEL_INTEGRATION.md and SYNC_ARCHITECTURE.md for the design intent.

Architecture notes

See CPANEL_INTEGRATION.md (repo root) for full design doc including known roadblocks:

  • No native DB import via UAPI — push is deferred to v2 for this reason
  • File download uses undocumented cPanel URL (/download?skipencode=1) — stable in practice but not a formal UAPI endpoint
  • PHP upload size limits mean push would need chunking or SFTP

Pre-merge Checklist

  • TypeScript: npm run typecheck passes clean (0 errors)
  • ESLint: npx eslint --fix applied to all modified files (0 warnings)
  • Tested against a real cPanel account
  • i18n strings reviewed (all user-facing strings use __())

georgestephanis and others added 2 commits March 17, 2026 13:55
Add two new design documents: SYNC_ARCHITECTURE.md describes the Studio sync architecture (auth, site discovery, pull/push flows, state management, and extension points). CPANEL_INTEGRATION.md is a detailed implementation plan for adding cPanel UAPI as a new provider (v1 pull-only), covering connection setup, pull flow, Redux/ipc changes, UI components, and a list of affected files. It also documents critical roadblocks (no DB import UAPI, no documented binary download endpoint), recommended workarounds, and team questions about scope and credential storage.
Adds the ability to pull a remote WordPress site hosted on cPanel into a local Studio site. Connects via cPanel UAPI using hostname, username, and API token — no OAuth required.

Pull flow: compress wp-content on server → download archive → dump database via UAPI → build Jetpack-format tar.gz locally → stop local server → import via existing importBackup → restart.

New files:
- src/modules/cpanel/types.ts — CpanelSyncSite, CpanelPullStatusInfo types
- src/modules/cpanel/lib/cpanel-api.ts — UAPI client, file download, DB dump helpers
- src/modules/cpanel/lib/ipc-handlers.ts — IPC handlers for connect/disconnect/get/pull/cancel
- src/modules/cpanel/components/cpanel-credentials-modal.tsx — connection setup form
- src/modules/cpanel/components/cpanel-connected-site.tsx — pull UI with progress bar and cancel
- src/stores/cpanel/cpanel-connected-sites.ts — RTK Query API for connected sites
- src/stores/cpanel/cpanel-operations-slice.ts — Redux slice for pull state + IPC event bridge

Modified: storage-types (adds connectedCpanelSites), ipc-utils (cpanel-pull-progress event), ipc-handlers (re-exports), constants (IPC_VOID_HANDLERS), preload (IPC wiring), stores/index (reducer + middleware + error listener), modules/sync/index (Connect cPanel button + site rendering)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@georgestephanis
Copy link
Author

georgestephanis commented Mar 17, 2026

Apologies, this is something I'm tinkering with in a fork with Claude, didn't mean to open up a PR in the main project.

I'm trying to see what is and isn't possible to extend Studio in a fork to connect to existing hosting infastructures elsewhere -- both to enable migrations to Pressable/WPCOM (by pulling and deploying) but also to use for local development and testing of WordPress installations across a plethora of hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant