-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update wp-env docs to reflect current functionality of package #21809
Conversation
Size Change: +94 B (0%) Total Size: 845 kB
ℹ️ View Unchanged
|
packages/env/README.md
Outdated
|
||
```json | ||
"scripts": { | ||
"wp-env": "packages/env/bin/wp-env" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like we don't require this npm run wp-env start
without this works. This path is in the context of Gutenberg will not work externally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point about the path. I think this may be needed for more advanced usage to be able to add extra arguments to a command e.g.
npm run wp-env run composer run-script lint
but I haven't tested that. Possibly the path would have to change to the node_modules
folder, or maybe it does already work without further changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"scripts": {
"env:start": "wp-env start",
"env:stop": "wp-env stop",
"php:lint": "wp-env run composer run-script lint"
}
or
"scripts": {
"env": "wp-env",
}
npm run env start
npm run env stop
npm run env run composer run-script lint
this works fine without specifying the path to command.
the scripts will first resolve to project node_modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed that part now @ajitbohra, thanks for the feedback 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed that part now @ajitbohra, thanks for the feedback 👍
I think he meant to change "wp-env": "packages/env/bin/wp-env"
to "wp-env": "wp-env"
.
We still need that there otherwise npm run
won't resolve the command. In Gutenberg, we use a local path because we want to use the checked-out version of the package for development.
packages/env/README.md
Outdated
|
||
`wp-env` requires Docker to be installed. There are instructions available for installing Docker on [Windows 10 Pro](https://docs.docker.com/docker-for-windows/install/), [all other versions of Windows](https://docs.docker.com/toolbox/toolbox_install_windows/), [macOS](https://docs.docker.com/docker-for-mac/install/), and [Linux](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script). | ||
|
||
After confirming that Docker is installed, you can install `wp-env` globally like so: | ||
`wp-env` is also distributed through NPM (Node Package Manager), so Node.js and NPM are required. The latest LTS version of Node.js is used to develop `wp-env` and is recommended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We require Node because wp-env
is written in Node. Saying its because its distributed through NPM is kind of ambivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was an issue a couple weeks ago where a user ran wp-env but their node version was much older than what we support. I think this change is trying to clarify our supported node version for people consuming wp-env from outside the Gutenberg repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but the wording feels odd.
wp-env
is also distributed through NPM (Node Package Manager), so
That can be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can simplify, though for someone reading this on Github, it feels unusual to progress to the first commands that use NPM, without mentioning it as a prerequisite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still mentioning it right?
Thanks for all the feedback, I've made the suggested changes. |
$ npm i @wordpress/env --save-dev | ||
``` | ||
|
||
Then modify your package.json and add an extra command to npm `scripts` (https://docs.npmjs.com/misc/scripts): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still should be able to run npx wp-env
at this point. As soon as the binary is installed in node_modules/bin
it will be executed from there.
I'm using this trick to test @wordpress/create-block
locally:
npx wp-create-block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would work, but why assume they have npx
? Having a script is sort of the standard way of calling local packages.
Fixes #20923
Description
@ajitbohra mentioned on slack that some of the instructions in the wp-env README either didn't work or weren't clear enough.
This PR updates those docs:
wp-env
package, but it's published instead as@wordpress/env
.wp-env
globally. This update makes it clear thatwp-env
can also be used locally (as it's used in Gutenberg).wp-env
is intended to be used with the latest LTS version of Node.Types of changes
Documentation