Skip to content

wp-now: download wordpress and sqlite in parallel - #417

Merged
sejas merged 2 commits into
WordPress:trunkfrom
Automattic:update/wp-now-parallel-downloads
May 24, 2023
Merged

sejas merged 2 commits into
WordPress:trunkfrom
Automattic:update/wp-now-parallel-downloads

Conversation

@sejas

@sejas sejas commented May 23, 2023

Copy link
Copy Markdown
Collaborator

What?

Optimize WordPress and SQLite downloads to be in parallel.
Optimization for wp-now and its tests.

Why?

An easy optimization to improve the developer experience.

Testing Instructions

  • Remove your ~/.wp-now folder
  • Run nx preview wp-now start --path=/path/to/wordpress-plugin-or-theme``
  • Observe WordPress and SQLite has been downloaded.
  • Observe the WordPress instance has started successfully
  • Run the tests npx nx test wp-now
  • Observe all of them pass.

@adamziel adamziel left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's a short and sweet PR so let's get this in, but this recreates a feature Blueprints already have. Let's just migrate wp-now setup to Blueprints instead. Async retrieval and progress reporting are already supported there. No need to build two competing implementations.

For example, this Blueprint would download three files in parallel, unzip them, and provide progress details on the entire operation so that you could render a CLI progress bar:

const blueprint = {
	steps: [
		{
			"step": "writeFile",
			"path": "/wordpress.zip",
			"data": {
				"resource": "url",
				"url": "... zip url ..."
			}
		},
		{
			"step": "writeFile",
			"path": "/sqlite-plugin.zip",
			"data": {
				"resource": "url",
				"url": "... zip url ..."
			}
		},
		{
			"step": "writeFile",
			"path": "/mu-plugins.zip",
			"data": {
				"resource": "url",
				"url": "... zip url ..."
			}
		},
		{
			"step": "unzip",
			"zipPath": "/wordpress.zip",
			"extractToPath": "/path/to/extract"
		},
		// ... unzip the rest ...
	]
};
const progressTracker = new ProgressTracker();
const compiled = compileBlueprint(blueprint, {
	progress: progressTracker
});
await runBlueprintSteps(compiled, php); 

Now, it could require an additional PR or two. For example, I'm not sure if fetch works out of the box in Node.js, but there's a good chance it would. Also, unzipping could be optimized to use the same Node.js stream-based library we use now.

@sejas

sejas commented May 24, 2023

Copy link
Copy Markdown
Collaborator Author

@sejas
sejas merged commit 043f677 into WordPress:trunk May 24, 2023
@sejas
sejas deleted the update/wp-now-parallel-downloads branch May 24, 2023 11:58
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.

2 participants