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: Support for running a Blueprint on start #80

Closed
danielbachhuber opened this issue Jun 15, 2023 · 4 comments · Fixed by #82
Closed

wp-now: Support for running a Blueprint on start #80

danielbachhuber opened this issue Jun 15, 2023 · 4 comments · Fixed by #82
Assignees
Labels

Comments

@danielbachhuber
Copy link
Member

danielbachhuber commented Jun 15, 2023

Blueprints are an abstraction for configuring the WordPress install. Let's make it possible to run a Blueprint file when starting:

wp-now start --blueprint=blueprint.json

Done is:

  • wp-now start supports a --blueprint=<file> argument. We should support arbitrary file names, as long as they validate against the JSON Schema.
  • When a Blueprint is provided, wp-now start validates it against the JSON Schema first and throws an error if it doesn't validate.
  • If a valid Blueprint is provided, it's applied when wp-now start runs.
  • We have some amount of corresponding test coverage.
  • Our README.md is updated to document how Blueprints work, including examples for wp-now: Add support for custom URL's #78 and Ability to define WP_DEBUG and other constants in the wp-config.php #17
@danielbachhuber
Copy link
Member Author

examples for #78

For this particular scenario, what would be optimal is the ability to add the following to wp-config.php:

define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );

However, wp-now is currently defining these on its own, so they can't be defined again. We should figure out a more elegant solution here.

@adamziel
Copy link
Collaborator

JSON schema validation would be a very useful core feature. Btw, the Schema file is autogenerated in core from Typescript types.

As for the site url, Blueprints have a step called defineWpConfigConst that can be called multiple times with the same consts to override the previously defined values.

@adamziel
Copy link
Collaborator

Also there’s a DefineSiteUrlStep step

@sejas
Copy link
Collaborator

sejas commented Jun 20, 2023

examples for #78

For this particular scenario, what would be optimal is the ability to add the following to wp-config.php:

define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );

However, wp-now is currently defining these on its own, so they can't be defined again. We should figure out a more elegant solution here.

This approach worked well for localhost, but it failed with http/https protocols when proxying with ngrok.

	const configPath = '/wp-now-vfs/wp-config.php'
	php.mkdir(path.dirname(configPath));
	php.setPhpIniEntry('auto_prepend_file', configPath);
	php.writeFile(
		configPath,
		`<?php
			define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
			define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
			`
	);

@sejas sejas linked a pull request Jun 23, 2023 that will close this issue
@sejas sejas closed this as completed Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants