Skip to content

Point CLI Reprint provisioning at the v1/v2-aware export endpoints (STU-1929) - #4375

Merged
gcsecsey merged 5 commits into
trunkfrom
gcsecsey/stu-1929-cli-reprint-v2-endpoints
Jul 31, 2026
Merged

Point CLI Reprint provisioning at the v1/v2-aware export endpoints (STU-1929)#4375
gcsecsey merged 5 commits into
trunkfrom
gcsecsey/stu-1929-cli-reprint-v2-endpoints

Conversation

@gcsecsey

@gcsecsey gcsecsey commented Jul 28, 2026

Copy link
Copy Markdown
Member

Related issues

How AI was used in this PR

I used Claude to investigate the issue, trace the pull-reprint provisioning flow, mirror the reference PHP client, and implement the changes and write the tests. I reviewed and validated the messaging and the logic myself.

Proposed Changes

In Automattic/jetpack#50369 we added new Jetpack-hosted export endpoints, which Reprint clients must probe for, and use these or fall back to the wpcomsh v1 endpoints.

This PR adds support for this:

  • Provisioning now probes the v2 enable-export endpoint once and falls back to v1 on a 404. The detected surface is decided in one place and drives both the secret rotation route and the importer query var (?reprint-api-jetpack for v2, ?reprint-api for v1), which is why the probe had to move ahead of URL construction and secret rotation.
  • Secret rotation accepts both the flat v2 (secret) and nested v1 (data.secret) response shapes.
  • v1 behavior is unchanged, since most sites stay on v1 until Add Reprint exporter outside wpcomsh jetpack#50369 ships.

Testing Instructions

Automated:

  • Run npm test -- apps/cli/lib/tests/api.test.ts apps/cli/commands/tests/pull-reprint.test.ts and confirm all pass. New cases cover the v2 probe succeeding, the v2 404 falling back to v1 (via an inner rest_no_route body and a direct 404), and both secret shapes.
  • Run npm run typecheck and confirm it is clean.

v2 end-to-end (needs Automattic/jetpack#50369 on the source site):

Build, then pull the v2 source into a fresh throwaway local site:

npm run cli:build
node apps/cli/dist/cli/main.mjs site create --path ~/Studio/reprint-v2-test --name reprint-v2-test
STUDIO_ENABLE_PULL_REPRINT=true node apps/cli/dist/cli/main.mjs pull-reprint --path ~/Studio/reprint-v2-test --url https://<your-v2-site> --verbose

Then confirm:

  • The verbose output shows [enableReprintExporter] Site <id> supports v2 export (enable-export returned 200), and the reprint command line streams from ...?reprint-api-jetpack.
  • The pull completes. Start the site with node apps/cli/dist/cli/main.mjs site start --path ~/Studio/reprint-v2-test and browse it to verify the source content arrived.

I tested with a staging Pressable site:

pull-reprint command local site
CleanShot 2026-07-29 at 12 00 28@2x CleanShot 2026-07-29 at 12 00 40@2x

@gcsecsey
gcsecsey requested review from Copilot and epeicher and removed request for Copilot July 29, 2026 10:45
@gcsecsey
gcsecsey marked this pull request as ready for review July 29, 2026 11:07

@epeicher epeicher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding functionality for the new endpoints @gcsecsey! I have tested with the new endpoints by using a Pressable site wth the Jetpack changes Automattic/jetpack#50369, and testing existing endpoints by using an existing Atomic site. Both pulls have worked as expected by using the current production reprint.phar. Changes also LGTM!

Pressable wp-admin Pressable site Local pulled wp-admin Local pulled site CLI command output Existing Atomic sit CLI output
Image Image Image Image Image Image

@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 23c4e8a vs trunk

app-size

Metric trunk 23c4e8a Diff Change
App Size (Mac) 1372.97 MB 1372.98 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 23c4e8a Diff Change
load 1066 ms 1067 ms +1 ms ⚪ 0.0%

site-startup

Metric trunk 23c4e8a Diff Change
siteCreation 6518 ms 6512 ms 6 ms ⚪ 0.0%
siteStartup 2361 ms 2367 ms +6 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

@gcsecsey
gcsecsey merged commit 9958077 into trunk Jul 31, 2026
13 checks passed
@gcsecsey
gcsecsey deleted the gcsecsey/stu-1929-cli-reprint-v2-endpoints branch July 31, 2026 14:10
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.

3 participants