Skip to content

Make reprint.phar a dynamically downloaded dependency#3690

Merged
epeicher merged 13 commits into
trunkfrom
studio-5-studio-make-reprint-a-dynamically-updated-dependency
Jun 10, 2026
Merged

Make reprint.phar a dynamically downloaded dependency#3690
epeicher merged 13 commits into
trunkfrom
studio-5-studio-make-reprint-a-dynamically-updated-dependency

Conversation

@epeicher

@epeicher epeicher commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Implemented with Claude Code (Opus): updated the build-time download script, the runtime path resolution, and the tests, and removed the earlier runtime-download module. I reviewed the changes.

Proposed Changes

reprint.phar (the PHP archive behind the experimental pull-reprint migration) now ships as a fixed, pinned version bundled into every Studio build. A build-time step downloads it into wp-files/ using the same mechanism as WordPress, wp-cli, and the SQLite plugin (scripts/download-wp-server-files.ts), so it is part of the installer instead of being fetched or auto-updated at runtime.

The version is pinned to v0.8.1. Bumping it is a one-line change to a constant in the download script.

User impact:

  • Every Studio build embeds a known, fixed reprint version (reproducible, no surprise upstream changes).
  • No runtime network dependency for pull-reprint to obtain the phar.
  • The binary is not committed to the repo; it is downloaded at build / postinstall time and is gitignored.

This replaces the earlier runtime auto-download approach, which has been removed.

Testing Instructions

  1. Apply these changes and run npm ci.
  2. Confirm wp-files/reprint/reprint.phar is downloaded from the v0.8.1 release.
CleanShot 2026-06-09 at 16 26 37@2x
  1. Build the CLI: npm run cli:build. Confirm apps/cli/dist/cli/wp-files/reprint/reprint.phar exists and apps/cli/dist/cli/reprint.phar does not.
  2. Additionally, you can build the application and check that the reprint.phar is there by running npm run make and then checking ls -l apps/studio/out/Studio-darwin-arm64/Studio.app/Contents/Resources/cli/wp-files/reprint

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors? (apps/cli and the build script typecheck cleanly; no application console errors introduced.)

@epeicher epeicher marked this pull request as ready for review June 4, 2026 15:26
@epeicher epeicher requested a review from fredrikekelund June 4, 2026 15:26
@wpmobilebot

wpmobilebot commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing ad66936 vs trunk

app-size

Metric trunk ad66936 Diff Change
App Size (Mac) 1358.05 MB 1358.08 MB +0.03 MB ⚪ 0.0%

site-editor

Metric trunk ad66936 Diff Change
load 1663 ms 1629 ms 34 ms ⚪ 0.0%

site-startup

Metric trunk ad66936 Diff Change
siteCreation 9096 ms 9032 ms 64 ms 🟢 -0.7%
siteStartup 4421 ms 4481 ms +60 ms 🔴 1.4%

Results are median values from multiple test runs.

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

…-reprint-a-dynamically-updated-dependency

# Conflicts:
#	apps/cli/vite.config.base.ts
// refresh it on the shared dependency-update throttle (see `updateServerFiles` in `setup.ts`).
const REPRINT_REPO = 'adamziel/reprint'; // TODO: Review this if the repo is moved to the Automattic repository
const REPRINT_ASSET = 'reprint.phar';
const LATEST_RELEASE_URL = `https://api.github.com/repos/${ REPRINT_REPO }/releases/latest`;

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.

Should we use the tagged version link to ensure we intentionally use a specific version?

@fredrikekelund

Copy link
Copy Markdown
Contributor

Echoing @wojtekn's point above and relaying what @epeicher and I discussed in a huddle: we agreed to change this implementation so that every version of Studio ships a fixed version of reprint.

There should be a script that automatically extracts the PHAR from the latest reprint release and puts it in the wp-files directory, but this should happen at build time.

So, we should look to scripts/download-wp-server-files.ts more than apps/cli/lib/dependency-management. My bad for writing the issue description in a way that made it seem like this auto-update-at-runtime approach was preferable 🙇‍♂️

@wojtekn

wojtekn commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

There should be a script that automatically extracts the PHAR from the latest reprint release and puts it in the wp-files directory, but this should happen at build time.

The download part should be straightforward, e.g.: https://github.com/adamziel/reprint/releases/download/v0.8.1/reprint.phar

@epeicher

epeicher commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @wojtekn and @fredrikekelund for your comments. I have addressed them, so now reprint.phar is downloaded using a specific version during build time. This is ready for another review. The Unit Tests failure is unrelated and it's being fixed as part of #3740

@wojtekn wojtekn 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.

The code change looks good, and works correctly:

[reprint] Downloading reprint.phar (v0.8.1) ...
[reprint] Moving reprint.phar to destination ...
[reprint] Files extracted

Comment thread scripts/download-wp-server-files.ts Outdated

// reprint.phar ships bundled with every Studio build — downloaded here at build time, not at
// runtime. Pin a specific release so each build embeds a known, fixed version; bump this constant
// to upgrade. See https://github.com/adamziel/reprint/releases.

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.

The code below is self-explanatory, not sure if we need the comment.

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.

Agreed, removed as part of 6ef73f0

@epeicher epeicher enabled auto-merge (squash) June 10, 2026 14:53
@epeicher epeicher merged commit 6581c20 into trunk Jun 10, 2026
10 of 11 checks passed
@epeicher epeicher deleted the studio-5-studio-make-reprint-a-dynamically-updated-dependency branch June 10, 2026 15:42
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.

4 participants