Skip to content

CLI: Add sync push/pull commands#2878

Open
bcotrim wants to merge 29 commits intoadd_cli_sync_and_import_operationsfrom
stu-1354-site-picker-sync
Open

CLI: Add sync push/pull commands#2878
bcotrim wants to merge 29 commits intoadd_cli_sync_and_import_operationsfrom
stu-1354-site-picker-sync

Conversation

@bcotrim
Copy link
Copy Markdown
Contributor

@bcotrim bcotrim commented Mar 23, 2026

Related issues

How AI was used in this PR

TBD

Proposed Changes

  • Extract Zod schemas for sync API responses into tools/common/types/sync.ts, shared between CLI and desktop — removes ~120 lines of duplicated schemas from wpcom-sites.ts and sync-operations-slice.ts
  • Add SYNC_EVENTS enum and schemas in tools/common/lib/cli-events.ts for CLI→Studio sync awareness (STARTED, PROGRESS, COMPLETED, FAILED)
  • Wire sync events through the existing CLI event pipeline: daemon socket → _events command → cli-events-subscriber → renderer IPC
  • Create apps/cli/lib/sync-api.ts with all wpcom sync API functions: fetchSyncableSites, initiateBackup, pollBackupStatus, tusUpload, initiateImport, pollImportStatus, downloadBackup
  • Create apps/cli/lib/sync-site-picker.ts — interactive site picker using @inquirer/prompts with sync support filtering (disabled items for unsupported sites)
  • Implement studio sync pull command (STU-1356): auth → fetch sites → interactive picker → initiate backup → poll status → download. Local import is stubbed as TODO pending the import/export module
  • Implement studio sync push command (STU-1355): auth → fetch sites → interactive picker → throws with "not yet implemented" since local export requires the export/import module
  • Register sync command group in CLI entry point with pull and push subcommands

Testing Instructions

  • Build CLI: npm run cli:build
  • Run node apps/cli/dist/cli/main.js sync --help — should show pull and push subcommands
  • Run node apps/cli/dist/cli/main.js sync pull --path <site-folder> — should prompt for auth if not logged in, then fetch sites and show interactive picker
  • Run node apps/cli/dist/cli/main.js sync push --path <site-folder> — should show picker then report "not yet implemented"
  • Verify npm run typecheck passes (pre-existing errors in ipc-handlers.ts are unrelated)
  • Verify desktop app still works: sync connect/pull/push in Studio desktop should be unaffected by the schema extraction

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim changed the title CLI: Add sync push/pull commands with interactive site picker CLI: Add sync push/pull commands Mar 24, 2026
@bcotrim bcotrim marked this pull request as ready for review March 26, 2026 18:09
@bcotrim bcotrim requested review from a team and fredrikekelund March 26, 2026 18:10
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 26, 2026

📊 Performance Test Results

Comparing 63f96ff vs trunk

app-size

Metric trunk 63f96ff Diff Change
App Size (Mac) 1273.60 MB 1273.82 MB +0.22 MB ⚪ 0.0%

site-editor

Metric trunk 63f96ff Diff Change
load 1828 ms 1843 ms +15 ms ⚪ 0.0%

site-startup

Metric trunk 63f96ff Diff Change
siteCreation 8178 ms 8178 ms 0 ms ⚪ 0.0%
siteStartup 4835 ms 4941 ms +106 ms 🔴 2.2%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

'Comma-separated sync options: all, sqls, uploads, plugins, themes, contents'
),
} )
.option( 'site', {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call it remote-site or something similar, to make the intention clear.
Let's remove the "skips..." part from the description

@bcotrim bcotrim changed the base branch from trunk to add_cli_sync_and_import_operations March 27, 2026 16:09
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.

3 participants