Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 24, 2023

Conversation

sejas
Copy link
Collaborator

@sejas sejas commented May 23, 2023

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.

Copy link
Collaborator

@adamziel adamziel left a comment

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
Copy link
Collaborator Author

sejas commented May 24, 2023

@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