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

Allow wp-env to start without config #23913

Merged
merged 3 commits into from
Jul 14, 2020
Merged

Conversation

noahtallen
Copy link
Member

@noahtallen noahtallen commented Jul 13, 2020

Description

Previously, if you ran wp-env start without a config (or if it couldn't detect a plugin to mount), it would fail. I'm not convinced this is expected behavior. Why not just allow people to create an empty WordPress instance?

There are a few concerns I have with this:

  • The error message makes it clear that you need to cd to the correct location in case you accidentally ran wp-env start from somewhere random
  • If folks ran wp-env start from different directories on their machine, each instance would be different. (To be fair, it will error out when you have instances with the same port number.)

This was motivated by discussion around documentation for starting your local environment and how to start it if you did not have a local source. (#23593)

I think this was also the behavior at some point in the past (it didn't fail if it couldn't find a config)

Additionally, this fixes a crash which occurred if you did not set a WordPress source.

How has this been tested?

Locally with wp-env

Screenshots

Screen Shot 2020-07-13 at 3 00 09 PM

Types of changes

enhancement

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@noahtallen noahtallen added [Type] Build Tooling Issues or PRs related to build tooling [Tool] Env /packages/env labels Jul 13, 2020
@noahtallen noahtallen requested review from mkaz and epiqueras July 13, 2020 22:02
@noahtallen noahtallen self-assigned this Jul 13, 2020
if (
config.env.development.coreSource &&
hasSameCoreSource( [ config.env.development, config.env.tests ] )
) {
await copyCoreFiles(
Copy link
Member Author

Choose a reason for hiding this comment

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

this crashed when config.env.development was undefined

@github-actions
Copy link

github-actions bot commented Jul 13, 2020

Size Change: -109 B (0%)

Total Size: 1.14 MB

Filename Size Change
build/api-fetch/index.js 3.39 kB +1 B
build/block-editor/index.js 115 kB -86 B (0%)
build/blocks/index.js 48.2 kB +1 B
build/components/index.js 199 kB -41 B (0%)
build/compose/index.js 9.67 kB +1 B
build/core-data/index.js 11.5 kB +1 B
build/edit-navigation/index.js 10.8 kB +15 B (0%)
build/edit-post/index.js 304 kB -1 B
build/edit-widgets/index.js 9.35 kB -2 B (0%)
build/editor/index.js 45.1 kB +1 B
build/list-reusable-blocks/index.js 3.12 kB +1 B
build/media-utils/index.js 5.32 kB +2 B (0%)
build/token-list/index.js 1.27 kB -2 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.67 kB 0 B
build/autop/index.js 2.82 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 7.67 kB 0 B
build/block-directory/style-rtl.css 944 B 0 B
build/block-directory/style.css 945 B 0 B
build/block-editor/style-rtl.css 10.8 kB 0 B
build/block-editor/style.css 10.8 kB 0 B
build/block-library/editor-rtl.css 7.6 kB 0 B
build/block-library/editor.css 7.59 kB 0 B
build/block-library/index.js 132 kB 0 B
build/block-library/style-rtl.css 7.77 kB 0 B
build/block-library/style.css 7.77 kB 0 B
build/block-library/theme-rtl.css 728 B 0 B
build/block-library/theme.css 729 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/components/style-rtl.css 15.9 kB 0 B
build/components/style.css 15.8 kB 0 B
build/data-controls/index.js 1.29 kB 0 B
build/data/index.js 8.46 kB 0 B
build/date/index.js 5.38 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 3.23 kB 0 B
build/edit-navigation/style-rtl.css 1.08 kB 0 B
build/edit-navigation/style.css 1.08 kB 0 B
build/edit-post/style-rtl.css 5.6 kB 0 B
build/edit-post/style.css 5.6 kB 0 B
build/edit-site/index.js 16.8 kB 0 B
build/edit-site/style-rtl.css 3.04 kB 0 B
build/edit-site/style.css 3.04 kB 0 B
build/edit-widgets/style-rtl.css 2.45 kB 0 B
build/edit-widgets/style.css 2.45 kB 0 B
build/editor/editor-styles-rtl.css 537 B 0 B
build/editor/editor-styles.css 539 B 0 B
build/editor/style-rtl.css 3.78 kB 0 B
build/editor/style.css 3.78 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.72 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 709 B 0 B
build/keyboard-shortcuts/index.js 2.51 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.4 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 13.9 kB 0 B
build/server-side-render/index.js 2.71 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/warning/index.js 1.13 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

Copy link
Member

@mkaz mkaz left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! 👍

Do you think it'd be worthwhile to still echo something to the screen, so if it was done by mistake people would know? Could just be: "No .wp-env.json, plugin, or theme detected."

@noahtallen
Copy link
Member Author

so if it was done by mistake people would know

I think that would be valuable. What do you think about adding a prompt like "Would you like to create an empty WordPress instance?"

@mkaz
Copy link
Member

mkaz commented Jul 13, 2020

I'd prefer no prompt, and just start it with a message. If it was a mistake, it is easy to stop and go where you want to and start again.

I think prompting for empty will cause confusion, people may not know what empty means, plus it may not actually be empty if they've used it like this before.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 13, 2020

As I am following the steps in the development environment documentation I will be at the root prompt.
paaljoachimromdahl@Paals-MacBook-Pro ~ % wp-env start

It would be nice to get help with setting up a local WP site in the directory the users chooses. Using an example such as a "Sites" folder located inside the root folder. It could then be added to the development environment documentation, as a step to take before running wp-env start. As in cd into the existing or new folder to create a new local WP site.

@noahtallen
Copy link
Member Author

Screen Shot 2020-07-13 at 5 49 22 PM

Here is a warning message that displays when running wp-env start without any local config detected

It would be nice to get help with setting up a local WP site in the directory the users chooses

how do you think this should be integrated? Instead of showing a warning message, we could show a message pointing them to documentation and then not set up a WordPress instance

@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 14, 2020

Taking a step back...

In the WordPress Development Site section. https://github.com/WordPress/gutenberg/tree/docs/cab-devenv/docs/designers-developers/developers/tutorials/devenv
Is the following text:

After you have installed Docker, go ahead and install wp-env globally from the command-line using:

npm -g install @wordpress/env
To confirm it is installed and available, run:

wp-env --version

1.6.0

It seems that nothing is happening when one adds the npm -g install @wordpress/env
Here I would expect to create a new WP site. But perhaps it just creates the environment and no new site has been made.
We need additional details to what is happening in the above steps.


This is how I see it:

The wp-env package requires Docker to be installed.
Install Docker for your operating system by following the instructions for Windows 10 Pro, all other versions of Windows, macOS, or Linux.

We will now create a new WordPress site.
---> Instructions for creating a new WordPress site in a specific folder/directory. Use the sites directory/folder example. If the directory does not exist it will automatically be created for you.

-> command for setting up the new WP site.
A question saying: "Do you want a new WordPress site to be created in the (example) sites directory? Type YES or NO."

User types "YES" if it is the correct directory. The install process continues and a new local WP site is created in the "sites" directory. A message then says "A new WordPress site has been made in the sites directory/folder."

User types "NO" and it goes back to prompt.

After the local WP site has been made we then need help on how to access the newly created local WordPress site.
"To access your new WordPress site...."


Btw wp-env start should just start up the environment and not create/install it. As it is starting up the environment and there is no mention of installing.

@mkaz
Copy link
Member

mkaz commented Jul 14, 2020

how do you think this should be integrated? Instead of showing a warning message, we could show a message pointing them to documentation and then not set up a WordPress instance

@noahtallen I think what you have is good to go. Let the environment start up, there is a message there that gives them a warning if they might be in the wrong spot, but explains why. 👍

Also, a WordPress environment could be used just to run WP locally and not necessarily do plugin or theme development. So let's merge this one, and see what feedback we get.

@noahtallen
Copy link
Member Author

It seems that nothing is happening when one adds the npm -g install @wordpress/env

We should explain that the purpose of this step is to install a tool, not to install an environment. It installs wp-env, which is a tool for running WordPress environments. (This step is very familiar to web developers at many skill levels.)

Do you want a new WordPress site to be created in the (example) sites directory

I think this next section you describe is basically a guided "tutorial" to using wp-env. I personally don't think this should be part of the normal wp-env start flow, but I wonder if it would be useful to add in general? Perhaps wp-env tutorial...

Btw wp-env start should just start up the environment and not create/install it.

I definitely see where you're coming from on this! That said, I don't think this will happen. I think it's kind of a philosophical difference. wp-env is meant to be really "portable," so everywhere you run it, you get the environment you expect. Every time you start it, you get the same result (a local environment running with the latest options you set locally). That means creating an environment locally if hasn't been created yet.

I personally think this works out well and is simpler to use in general.

As it is starting up the environment and there is no mention of installing.

In #23809, we start showing a "configuring WordPress" message when the installation step happens, so that should help

So let's merge this one, and see what feedback we get.

Sounds good to me! We can of course continue working towards improvements after merging this.

@noahtallen noahtallen merged commit eb856ef into master Jul 14, 2020
@noahtallen noahtallen deleted the env/allow-start-without-config branch July 14, 2020 17:47
@github-actions github-actions bot added this to the Gutenberg 8.6 milestone Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Env /packages/env [Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants