Snapshot Import Protocol v1#1007
Conversation
| * the corresponding directories in Playground's documentRoot. | ||
| * | ||
| * Any files that Playground recognizes as "excluded from the export" | ||
| * Any files that Playground recognizes as "exceptd from the export" |
There was a problem hiding this comment.
| * Any files that Playground recognizes as "exceptd from the export" | |
| * Any files that Playground recognizes as "excepted from the export" |
@adamziel what are you unsure about here? |
|
I just had an epiphany. It doesn't make sense to have an import site Blueprint step:
I'll rework this PR to remove that step and put the WordPress initialization logic in
I struggled to draw clear boundaries that would make logic general and reusable in |
|
This is more complex than I initially imagined.
Let's imagine we have just wp-content + empty FS. We need to unzip it and then, backfill WordPress core. Which WP version? Let's assume the latest one for now. A list of cases to consider:
I'm leaning towards just giving up if the FS is already populated. Let the user make an explicit choice. Hey, you're about to overwrite some files, are you sure about that? If yes, the API consumer would remove all the files in the document root and resume. |
|
One more plot-twist – the OPFS root may be inside the |
That makes sense, we shouldn't rewrite the FS without users knowing. Otherwise, we can just delete everything and start building from scratch to keep the implementation simple.
When we add support for blueprint exports to PHP, let's add the blueprint.json file to the ZIP export in the Playground plugin. |
|
I no longer think this problem should be solved in TypeScript. Let's explore a canonical PHP implementation in the new Blueprints repository and use it to inform the work on the site transfer protocol. |
What is this PR doing?
🚧 This is still work in progress as I'm not sure about the
setSnapshotvslinkSnapshotsemantics. 🚧Consolidates site setup code paths between the web worker and the import step. With this PR, both support:
wp-config.phpandwp-contentinsideThis means the same file format can be passed to
?wp=https://mysite.com/wp.zipQuery Parameter,{"preferredVersions": { "wp": "https://mysite.com/wp.zip" } }Blueprint config, and theimportWordPressFilesBlueprint step. I'd like to rename the latter toimportSnapshot.I'd like this PR to be the first iteration of the Site Transfer Protocol in Playground. For now, it's built in JS. Eventually, it could be built in PHP.
Implementation details
With this PR, setting up a Playground snapshot works as follows.
"Setting the snapshot" stage:
.snapshotwp-config.phpis missing, backfill it.snapshot"Linking" stage:
The distinction is not as crisp as I'd like. My main intention was to harmonize this initialization code path in
worker-thread.tswhere the snapshot may be a fresh zip we're only setting up now, but it may also be a local directory with either vanilla WordPress or fully set-up Playground:cc @dmsnell @bgrgicak