-
Notifications
You must be signed in to change notification settings - Fork 7
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
Blueprints v2 Specification #6
Comments
Why do you think we need a top level "wp"? |
given that we already have a JSON format, and we're talking about creating these from PHP, have we given more thought to a function interface? (new Blueprints())
-> withPHP( '8.2' )
-> withWP( 'latest' )
-> wpConfig( array(
'WP_DEBUG' => true
) )
-> withPlugins( 'gutenberg', 'mathml-block' )
-> addContent(
'./theme-unit-test-data.xml',
'./accessbilitiy-testing-content.xml'
)
-> runPHP( <<<PHP
<?php
add_filter( 'wp_init', function() {
echo 'Hello, world';
}
PHP) this deals with the multi-line input problem, and provides an interface that gives auto-complete and inline documentation if we build the blueprints class properly. |
This is what I'm doing for the debugger now. It seems cleaner than messing with php.ini files.
I wouldn't bother with this now. It's ok for some steps to only work in some environments. It's ok if the code skips these steps. We just need to be clear in docs about which environments are supported.
The root dir should be a runtime option. All other paths could be relative so there would be no need for a reference.
Would it be better if we kept the context of a step inside a single place when possible? This example could be written like this.
|
Just my first instinct to distinguish between the different section. I think you're right, though. It is a WordPress tool, everything inside |
I noticed that for wp-env, we have |
It's the same for Blueprints, you can either specify |
Another thing that wp-env has is the concept of a separate testing environment, which can accept a lot of the config options. The main purpose of that is to have a separate database and server you can run local e2e tests against, but it does add complexity to the config. |
@noahtallen I've always wondered whether that multiple environment concept was necessary. It adds complexity to the config but also adds some burden on the user as you never know which environment you're using. One simple solution to that use-case would have been two config files and you provide the desired config file to the CLI. Would that solve all of these use-cases you think? |
I always thought it was relatively clear which environment you use -- after all, the CLI lets you know about the separate ports, and the main 8888 port is almost always used. But wp-env's roots were zero config, and at the time, I think it still had the second environment. So it was mostly a behind-the-scenes feature that helped support e2e tests in Gutenberg. As more config options were added over the years, the more complicated it got. (I think -- part of wp-env was developed before I started working on it) But I think the second config file would practically work ok if we were starting from scratch. You'd probably still be running e2e tests via the |
I like the idea of Blueprints and would love to see it integrated within wp-env. But from my opinion it needs just a bit of documentation. Why not just using This effort needs more or less no new code (only documentation) and is portable across operating systems. I see Blueprints as an extension to the current On the other side : If Blueprints should also target But I would not add the Blueprints to |
I love the separation between those different actions because, it gets at something I've been mentally struggling for a while. How do I change a blueprint without losing the current state? In different terms: How can I change the blueprint from inside the site itself? Some actions are non-destructive - like installing plugins, adding a PHP file, etc. I would imagine it would split the blueprint handling into 2 parts:
That way, that second plugin can function independently as a "WordPress driver" for all those sites that do have a host, but could use some automation. I could also imagine that the set of actions assuming you already have a a site is more interesting for folks than the set of hosting-related actions. |
That's a super interesting idea @artpi. I like it! Each step could correspond to a local REST API call or a PHP function call, and that would mark a clear path to how Blueprints could eventually be merged into WordPress core. I'll still try to think of some steps where that model wouldn't work. So far, though, I couldn't find any. This would split the Blueprint library into the two parts that you've outlined:
A few questions to explore:
I don't follow @artpi, what do you mean by changing the Blueprint? Would you want WordPress to go back into your original Edit: Hmm, I'm having second thoughts. Intertwining site setup manipulation with a code relying on that setup generates a new class of possible errors. Say we're running a Blueprint via a REST API request. That Blueprint changes some files, site options, and invalidates caches. Then, in the original REST API request, WordPress calls get_option |
+1 @lgersman, I would love that too. I wouldn't tightly couple the two, as Blueprints have a ton of value outside of |
My vote is: "Right here"... (relative) One of the biggest struggles I had when working with How this works in the various modes of
It's an important distinction to make. We can work on that, a good first step would be easily knowing where the filesystem is and how you should intend to work with files in this Playground instance. Appreciate the diligence on the spec!! |
I currently love the JSON syntax because it has no dependencies. Even if using it inside PHP, I don't have to worry about pulling external libraries. Additionally, its easy to work on in https://playground.wordpress.net/builder/builder.html I would also love a tool that would let me convert existing JSON to the PHP syntax if I am ready to make the switch |
The previous, TypeScript-powered, Blueprint schema only makes sense in the browser, not in a portable PHP library. Let's design one that does.
The existing Blueprints should keep working as much as possible. The library could detect an outdated syntax and rewrite it to the new one behind the scenes.
Converging with wp-env
wp-env
has its own config format.Let's converge wp-env and Blueprints. This could mean either:
wp-env
with Blueprints using Docker as a backend as both solve the same problemcc @youknowriad @noahtallen
Runtime setup options
The following Blueprint options are for setting up the PHP.wasm runtime. They make sense in Playground and Docker where we need to set up the runtime, but not in native PHP where the runtime is already provided:
An alternative syntax would make that apparent and allow for environment-specific overrides. Here's one idea:
The Native PHP driver could log a message saying that PHP setup instructions are unsupported and were ignored. Optionally, it could verify if the requested PHP version and extensions match.
Open questions
How should PHP.ini setup be defined and how should it work? Should we do an mu-plugin with
ini_set()
?Client setup
The following Blueprint options only make sense in the browser where we control the client:
What should they do when building a site using the native PHP CLI. Perhaps they could start a server, open a web browser, and open
/wp-admin/
in a logged in state? Controlling the browser isn't trivial, so presumably there would be a special, one-time, magic login link with a?redirect=
query arg or so. If so, we could express it as follows:What if we cannot start the server or open the browser, though? For example, we're building in a headless mode. Should the runtime ignore those options? Should it issue a warning? Should these options be runtime-specific?
WordPress setup
The following Blueprint options are responsible for setting up WordPress:
They could be bundled under a single top-level key as follows:
Open questions
blueprint --target=./build
? How should that directory be referenced in steps likewriteFile
orrunPHP
? Using special syntax like%DOCROOT%
?Shorthand properties
The step-by-step syntax is overly verbose for most developers, let's make it shorter.
The verbose syntax must remain available as it's the only way to enable reproducible, reliable builds. Some developers may need to correct site options or import content after plugin A was activated but before plugin B was installed and Blueprints should empower them. However, most the developers will never run into nuances like that.
Let's design a schema that's convenient for most use-cases, yet powerful enough to handle nuanced setups.
Here's what it could look like:
Metadata
WordPress.org could have a Blueprints community space on WordPress.org for folks to share and collaborate on WordPress setups. Similarly to plugins metadata, Blueprints would need to carry some meta information as well.
Here's what a top-level
meta
key could look like:Which other fields would be required? Do we need to separate contributors and authors? Should each contributor be able to provide their own website URL?
It could be validated using the JSON Schema below. Note the main Blueprints library could simply ignore the
meta
key. The validation would happen exclusively during the submission process to the community space.What new features would be useful?
openURL
sectioncc @bgrgicak @dmsnell @mtias @tellyworth @danielbachhuber
The text was updated successfully, but these errors were encountered: