Remove postinstall script in apps/cli by using new archiver strategy - #3784
Conversation
Call `glob` with the right options and then pass every file path to `Archiver.file`. Also, update archiver to v8.
📊 Performance Test ResultsComparing c546dc6 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
…-patch # Conflicts: # apps/cli/package.json
bcotrim
left a comment
There was a problem hiding this comment.
LGTM 👍
Note:
- An exported site is missing empty folders, unlike trunk.
I don't think it will have any impact, but wanted to flag to raise the flag. - I fixed unit tests and merge conflicts, feel free to adjust as you see necessary
epeicher
left a comment
There was a problem hiding this comment.
Thank you very much, @fredrikekelund. Removing the postinstall will be a great step! I have tested it, and I have found a couple of issues that I think should be fixed:
- The preview site does not include the symlink to a single file
- When exporting the site and importing it as a new site, I am getting the error in the screenshot below
| Original site | Preview site | Site created from the Exported site |
|---|---|---|
![]() |
![]() |
![]() |
Please let me know if you have any questions. In a nutshell, the symlink to folders seems to be working fine, but the symlink to single files does not seem to be working for me.
When a file symlink is passed to `Archive.file`, archiver will append an actual symlink to the archive instead of the targeted file. `Archiver.append` just appends the raw data, which is why I opted for it.
|
Kudos for the thorough testing, @epeicher 🙏 I pushed a fix for the file symlink issue. I'll run some more testing tomorrow morning before landing this. It looks like the "Site created from the Exported site" issue you found also came from the file symlink thing |
|
Confirmed that file symlinks are included properly in both types of exports with this new approach ✅ |
|
AI review raised a real potential issue: I've confirmed that the new approach works as expected, too ✅ |
There was a problem hiding this comment.
This change wasn't crucial to the core purpose of this PR, but it's how Vitest recommends mocking the fs module. We don't need to reimplement what memfs exports. The point of that module is to provide the same API as fs, just backed by a temporary file system.
There was a problem hiding this comment.
These changes are unrelated to the core purpose of this PR – they're just simplifications I was able to make from tweaking the fs mock.
| "@php-wasm/node": "3.1.36", | ||
| "@php-wasm/universal": "3.1.36", | ||
| "@php-wasm/util": "3.1.36", | ||
| "@php-wasm/node": "3.1.38", | ||
| "@php-wasm/universal": "3.1.38", | ||
| "@php-wasm/util": "3.1.38", | ||
| "@vscode/sudo-prompt": "^9.3.2", | ||
| "@wordpress/i18n": "^6.20.0", | ||
| "@wp-playground/blueprints": "3.1.36", | ||
| "@wp-playground/cli": "3.1.36", | ||
| "@wp-playground/common": "3.1.36", | ||
| "@wp-playground/storage": "3.1.36", | ||
| "@wp-playground/wordpress": "3.1.36", | ||
| "archiver": "^7.0.1", | ||
| "@wp-playground/blueprints": "3.1.38", | ||
| "@wp-playground/cli": "3.1.38", | ||
| "@wp-playground/common": "3.1.38", | ||
| "@wp-playground/storage": "3.1.38", | ||
| "@wp-playground/wordpress": "3.1.38", |
There was a problem hiding this comment.
These version changes are unrelated to the core purpose of this PR. #3829 mistakenly downgraded the Playground dependencies in apps/cli to 3.1.36, so I took the opportunity to reset them back to 3.1.38.
This is also what caused the change in installer size. Previously, we had different Playground dependency trees: one for 3.1.36 and another for 3.1.38
Primarily trying to reconcile the big jump in installer size that we saw recently ## Related issues <!-- Link a related issue to this PR. If the PR does not immediately resolve the issue, for example, it requires a separate deployment to production, avoid using the "Fixes" keyword and use "Related to" instead. --> N/A ## How AI was used in this PR <!-- Help reviewers understand what to look for and verify that you've reviewed the code yourself. --> N/A ## Proposed Changes <!-- Explain the intent of this PR: - What problem does it solve, or what need does it address? - How does it affect the user (new capability, fix, performance, accessibility, etc.)? - Note any user-visible behavior changes or trade-offs. Focus on the "why" and the user impact. Avoid listing modified files or describing implementation mechanics — the diff already shows that. --> #3829 bumped the installer size significantly. We discussed this just after that PR was merged, and I made an effort in #3784 to fix the problem. Turns out that didn't work, because the installer size is still huge. This PR fixes the problem by restoring the `--omit=dev` option in the `install:bundle` script that's used to package `apps/studio` dependencies when building the app. ## Testing Instructions <!-- Add as many details as possible to help others reproduce the issue and test the fix. "Before / After" screenshots can also be very helpful when the change is visual. --> See installer size results from performance metrics CI job ## Pre-merge Checklist <!-- Complete applicable items on this checklist **before** merging into trunk. Inapplicable items can be left unchecked. Both the PR author and reviewer are responsible for ensuring the checklist is completed. --> - [ ] Have you checked for TypeScript, React or other console errors?



Related issues
How AI was used in this PR
Claude was used to iteratively reach the desired state. I bounced around ideas for achieving the goals, iterated on ways to simplify the implementation, and relied on it heavily to simplify tests.
Proposed Changes
npm v12 will stop running
postinstallscripts by default. Thewp-studiopackage currently runs apostinstallscript to patch thearchivernpm module usingpatch-package.This PR removes the need for that patch by eliminating the use of
archiver.directory()and instead doing the globbing ourselves and callingarchiver.file()for each file in our list. The PR also removes thepatch-packagedependency and the actual patch.Moreover, I took the opportunity to update
archiverto v8, which is the latest version.Testing Instructions
Pre-merge Checklist