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

Docs: Move DevEnv to own section for docs #23593

Merged
merged 12 commits into from
Jul 14, 2020
Merged

Docs: Move DevEnv to own section for docs #23593

merged 12 commits into from
Jul 14, 2020

Conversation

mkaz
Copy link
Member

@mkaz mkaz commented Jun 30, 2020

Description

This moves the Development Environment documentation out of the Create a Block tutorial and to its own section. This allows for easier linking from elsewhere. Plus allows for simplifying the Create a Block tutorial, with linking over the the DevEnv as a pre-requisitite.

It also gives a section to expand more on the Development Environment setup. I created it as its own directory so if we want to break each piece out—Node, WordPress Environment, and Code Editor—to its own page, there is space for it to grow.

This new development environment is related to the Contributors Getting Started Guide. The contributor guide docs are specific to contributing to Gutenberg, whereas the guide in this PR is specific to plugin developers extending the block editor.

See: #22831

How has this been tested?

Documentation, confirm links work and docs make sense.

View the rendered version on branch here

Types of changes

Documentation

@mkaz mkaz added the [Type] Developer Documentation Documentation for developers label Jun 30, 2020
@github-actions
Copy link

github-actions bot commented Jun 30, 2020

Size Change: 0 B

Total Size: 1.14 MB

ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.67 kB 0 B
build/api-fetch/index.js 3.39 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/index.js 115 kB 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.54 kB 0 B
build/block-library/editor.css 7.54 kB 0 B
build/block-library/index.js 130 kB 0 B
build/block-library/style-rtl.css 7.75 kB 0 B
build/block-library/style.css 7.76 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/blocks/index.js 48.2 kB 0 B
build/components/index.js 199 kB 0 B
build/components/style-rtl.css 15.9 kB 0 B
build/components/style.css 15.8 kB 0 B
build/compose/index.js 9.67 kB 0 B
build/core-data/index.js 11.4 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/index.js 10.8 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/index.js 304 kB 0 B
build/edit-post/style-rtl.css 5.59 kB 0 B
build/edit-post/style.css 5.58 kB 0 B
build/edit-site/index.js 16.6 kB 0 B
build/edit-site/style-rtl.css 3.03 kB 0 B
build/edit-site/style.css 3.03 kB 0 B
build/edit-widgets/index.js 9.35 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/index.js 45.1 kB 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/index.js 3.12 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/media-utils/index.js 5.32 kB 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/token-list/index.js 1.27 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

@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 2, 2020

Title: Docs: Move DevEnv to own section for docs
-->
Title: Docs: Move DevEnv to its own section in the docs.

"This moves the Development Environment documentation out of the Create a Block tutorial and to its own section. This allows for easier linking from elsewhere. Plus allows for simplifying the Create a Block tutorial, with linking over the the DevEnv as a pre-requisitite."
--->
This moves the Development Environment documentation out of the Create a Block tutorial. It brings greater freedom in linking to other documentation. DevEnv can also become a pre-requisitite for a simplified Create a Block tutorial.

"It also gives a section to expand more on the Development Environment setup. I created it as its own directory so if we want to break each piece out—Node, WordPress Environment, and Code Editor—to its own page, there is space for it to grow."
--->
We can also expand the Development Environment setup to include additional sections. (No need to include the second sentence. As we have already said that it can be expanded.)

"This new development environment is related to the Contributors Getting Started Guide. The contributor guide docs are specific to contributing to Gutenberg, whereas the guide in this PR is specific to plugin developers extending the block editor."
--->

EDIT Sunday 5th of July.

I find the above sentences very confusing.
I am rereading, and this is how I understand it.
We are creating a new documentation for development environment. Which will when finished be added to a new section here: https://developer.wordpress.org/block-editor/

We should add a new Creating a Development Environment as the first section under Developer Documentation.
https://developer.wordpress.org/block-editor/developers/
With a link to the new Development Environment section in the https://developer.wordpress.org/block-editor/contributors/develop/

Rephrasing the above sentences that you wrote.
We are updating the documentation for creating a development environment. This will be added to the Developer Documentation in the Block Editor handbook.

Btw there is no need to mention extending the block editor here in this PR. As it was already mentioned in the first sentence in this PR.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 5, 2020

Going through Development Environment docs.

"A development enviornment (typo) is a catch-all term for the setup on your computer to work."
-->
A development environment in this context is a catch-all term for developing with WordPress and Gutenberg.

"The script npx is installed with npm and is used to run packages not yet installed, we will use this to bootstrap a block."
-->
This is a pretty complex sentence and could be broken down + add some more details to it to make it easier to understand for a non developer.

"Here are the quick instructions to install using nvm, ..."
-->
Here are the quick instructions on a Mac to install using nvm.


Run the following on the command-line to install nvm:
curl -o- https://github.com/raw/nvm-sh/nvm/v0.35.3/install.sh | bash

A message might show up:

Screen Shot 2020-07-05 at 15 00 59

In terminal it might say this:

=> xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. 
Choose an option in the dialog to download the command line developer tools.
Failed to clone nvm repo. Please report this!

Click Install to open the Mac Automatic Update, and the command line developer tools will be downloaded and installed.

Run the Node Version Manager install command line again:
curl -o- https://github.com/raw/nvm-sh/nvm/v0.35.3/install.sh | bash

This time there should be no error message as the Mac command line developer tools have been installed.

This is what I saw:

paaljoachimromdahl@Paals-MacBook-Pro ~ % curl -o- https://github.com/raw/nvm-sh/nvm/v0.35.3/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13527  100 13527    0     0  67635      0 --:--:-- --:--:-- --:--:-- 67635
=> Downloading nvm from git to '/Users/paaljoachimromdahl/.nvm'
=> Cloning into '/Users/paaljoachimromdahl/.nvm'...
remote: Enumerating objects: 290, done.
remote: Counting objects: 100% (290/290), done.
remote: Compressing objects: 100% (257/257), done.
remote: Total 290 (delta 35), reused 97 (delta 20), pack-reused 0
Receiving objects: 100% (290/290), 163.27 KiB | 320.00 KiB/s, done.
Resolving deltas: 100% (35/35), done.
=> Compressing and cleaning up git repository

=> Appending nvm source string to /Users/paaljoachimromdahl/.zshrc
=> Appending bash_completion source string to /Users/paaljoachimromdahl/.zshrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

After installing nvm, you now need to install the latest version of node, run:
nvm install --lts

This is the message I received:

paaljoachimromdahl@Paals-MacBook-Pro ~ % nvm install --lts
zsh: command not found: nvm
paaljoachimromdahl@Paals-MacBook-Pro ~ %

If there is an error running the above command line code on the Mac then you might need to create the required file zshrc. To do so type touch ~/.zshrc
It is fine to run if the file already exists. Note, ~/ is a shortcut to your home directory.

This is what I noticed in terminal after having also tried to install nvm.

paaljoachimromdahl@Paals-MacBook-Pro ~ % nvm install --lts
zsh: command not found: nvm
paaljoachimromdahl@Paals-MacBook-Pro ~ % touch ~/.zshrc
paaljoachimromdahl@Paals-MacBook-Pro ~ % nvm install --lts
zsh: command not found: nvm
paaljoachimromdahl@Paals-MacBook-Pro ~ % node -v
zsh: command not found: node
paaljoachimromdahl@Paals-MacBook-Pro ~ % npm -v
zsh: command not found: npm
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

So here it stopped up, and I am not certain where to go from here.
I am running a fresh reformated Macbook Pro running OSX Catalina.


NB!!!
The above error message is seen if one does not quit and restarts terminal.
We need add additional information about restarting terminal.

Continuing....
After having quit and restarted terminal I once again wrote:
nvm install --lts

This is what I saw:

paaljoachimromdahl@Paals-MacBook-Pro ~ % nvm install --lts
Installing latest LTS version.
Downloading and installing node v12.18.2...
Downloading https://nodejs.org/dist/v12.18.2/node-v12.18.2-darwin-x64.tar.gz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v12.18.2 (npm v6.14.5)
Creating default alias: default -> lts/* (-> v12.18.2)
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

Checking to see if node and npm have been installed.

paaljoachimromdahl@Paals-MacBook-Pro ~ % node -v
v12.18.2
paaljoachimromdahl@Paals-MacBook-Pro ~ % npm -v
6.14.5
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

"After confirming that the prerequisites are installed, install wp-env globally from the command-line using:
npm -g install @wordpress/env"
--->

Screen Shot 2020-07-05 at 16 03 54

Rephrasing the above sentence: After you have installed Docker go ahead and install wp-env globally from the command-line using:
npm -g install @wordpress/env

This is what I saw in terminal:

paaljoachimromdahl@Paals-MacBook-Pro ~ % npm -g install @wordpress/env
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/Users/paaljoachimromdahl/.nvm/versions/node/v12.18.2/bin/wp-env -> /Users/paaljoachimromdahl/.nvm/versions/node/v12.18.2/lib/node_modules/@wordpress/env/bin/wp-env

> nodegit@0.26.5 install /Users/paaljoachimromdahl/.nvm/versions/node/v12.18.2/lib/node_modules/@wordpress/env/node_modules/nodegit
> node lifecycleScripts/preinstall && node lifecycleScripts/install

[nodegit] Running pre-install script
[nodegit] Running install script
node-pre-gyp
WARN Using request for node-pre-gyp https download
[nodegit] Success: "/Users/paaljoachimromdahl/.nvm/versions/node/v12.18.2/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release/nodegit.node" is installed via remote
[nodegit] Completed installation successfully.

> nodegit@0.26.5 postinstall /Users/paaljoachimromdahl/.nvm/versions/node/v12.18.2/lib/node_modules/@wordpress/env/node_modules/nodegit
> node lifecycleScripts/postinstall

+ @wordpress/env@1.6.0
added 274 packages from 237 contributors in 30.248s
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

To confirm it is installed and available, run:
wp-env --version

paaljoachimromdahl@Paals-MacBook-Pro ~ % wp-env --version
1.6.0

It looks like wp-env made a WordPress local site, but where is it located?
It would be good to open up the local WordPress site that I believe was created.
More information about the local WordPress site should be added before going to Alternatives section.

If I need to remove nvm and Docker to start again how do I do so?
Should there be a trouble shooting section?


Alternatives

A couple of alternatives that might be easier, since they do not require Docker install and setup.
---->
A couple of alternatives that might be easier, since they do not require setting up nvm and Docker.

Plugin step.
Here: This will be used in the next Plugin step. To confirm it is installed and available, run:
and
here: Next Section: WordPress Plugin
The above contain broken links.

@mkaz
Copy link
Member Author

mkaz commented Jul 6, 2020

@paaljoachim Thanks for the feedback, I need to go through each still but for future reference, Github has a suggestion and review tool that allows submitting feedback in context with the lines of code.

See this Github documentation for more info

Using the suggestion tool makes line edits, spelling and also associates your name with the change.

@mkaz
Copy link
Member Author

mkaz commented Jul 6, 2020

@paaljoachim Thanks for the feedback, I updated the docs addressing your points. I modified slightly so it includes instructions for additional environments besides the Mac.

Also, to note the alternative environment is only for Docker, the headings have it under that section. Node is still required and there is no alternative, only different methods to installing which are already linked to above.

We will need a place to work and tools for creating a block, this is often referred to as the development environment. The three main pieces needed for our development environment are:
The development environment setup guide is for setting up your local development environment for JavaScript development; creating plugins and tools for extending WordPress and the block editor.

A development environment is a catch-all term for the setup on your computer to work. The three main pieces needed for our development environment are:

1. Node/NPM Development Tools
2. WordPress Development Site
3. Code Editor

Copy link
Contributor

Choose a reason for hiding this comment

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

The short guide.

In terminal - Mac, Windows or Linux.
Install nvm:
curl -o- https://github.com/raw/nvm-sh/nvm/v0.35.3/install.sh | bash
Quit and restart terminal.
Install node:
nvm install --lts

Download and install Docker. Startup Docker (?) ...

In terminal.
npm -g install @wordpress/env
Check to see it has been installed:
wp-env --version

Do something (?)
Then in terminal:
wp-env start

You should now have a local development environment in place. If something does not work then check the uninstall guide to remove and start over. - @mkaz and @noahtallen it would be good to have a section for uninstalling all that we have installed. To start over if needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

The do something step is from the Create a Block tutorial, on generating the plugin directory see wp-plugin.md.

npx @wordpress/create-block gutenpride
cd gutenpride
wp-env start

The create block script creates a plugin directory, you run the wp-env start from within that directory.

Copy link
Member

Choose a reason for hiding this comment

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

you can uninstall wp-env like so:

  • run wp-env destroy to destroy the local environment data for a specific projest
  • run npm uninstall -g @wordpress/env will uninstall the npm package, but will not remove any environment data

Copy link
Contributor

Choose a reason for hiding this comment

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

The do something step is confusing as we are having nice and logical steps on what to do in terminal to setup a local WordPress development. I expect the do something step will then create the local WordPress development site which we can then easily access. I am saying the same thing just below. We should not refer to another tutorial as that information can come later.

Copy link
Contributor

@paaljoachim paaljoachim Jul 10, 2020

Choose a reason for hiding this comment

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

Thanks Noah! Btw how do we test to see that all of it is actually uninstalled?
Having uninstall information (as you added) and checking to see that it is uninstalled would be helpful.

Copy link
Member

Choose a reason for hiding this comment

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

If it is actually uninstalled, then wp-env start will result in an error like "command not found". Additionally, if you destroyed your environment, the command docker ps -a, which shows a list of local environments, will not display environments associated with the local environment that was deleted.

Verifying that the environment was properly uninstalled is kind of complicated because you have to understand how Docker works and how wp-env works under the hood, since several different things are cleaned up when you run wp-env destroy

Copy link
Contributor

@paaljoachim paaljoachim Jul 13, 2020

Choose a reason for hiding this comment

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

I am thinking as long as one gets the error messages one is supposed to get then that would be the confirmatation that it is uninstalled.

```

The `wp-env` script is used to create a Docker WordPress environment, to use start from your plugin directory—if you are following the create block tutorial, this would be in the generated directory.

Copy link
Contributor

@paaljoachim paaljoachim Jul 9, 2020

Choose a reason for hiding this comment

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

It is confusing going from working in terminal to suddenly mentioning the plugin directory.
Where is the plugin directory? We need a step that goes from checking the wp-env to locating the plugin directory and then running wp-env start. This needs clarification.

"...if you are following the create block tutorial, this would be in the generated directory."
This seems out of context. As the context is setting up a local dev environment to be used with creating a plugin and/or contributing to Gutenberg.

(I added a similar comment in the below solved comment thread, but as it got hidden I am adding it again here.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure setting up a dev environment with no context makes much sense. There is a reason you are setting up an environment, the most likely is for developing a plugin or theme. If you are following the create a block tutorial it provides the context in that tutorial here.

Otherwise, you might of come to this page wanting to setup an environment to create a plugin, so you would have that in mind already.

Copy link
Contributor

Choose a reason for hiding this comment

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

We has this introduction:
"The development environment setup guide is for setting up your local development environment for JavaScript development; creating plugins and tools for extending WordPress and the block editor."

This is how I understand it:
Setup a local WordPress development site for creating own plugin and/or contributing to WordPress/Gutenberg. (That is the context.)

"If you are following the create a block tutorial it provides the context in that tutorial here."
As the doc we are working on right now is the very first tutorial for setting up a local dev site I find it confusing that someone would be following the next tutorial in the series so to speak. As the tutorial we have now would be a prerequisite for the block tutorial. Having a side path to tutorial 2 seems strange at this stage.


* Check out the [Notices Tutorial](/docs/designers-developers/developers/tutorials/notices/README.md) to learn how to display informational UI at the top of the editor.
- See the [Meta Boxes Tutorial](/docs/designers-developers/developers/tutorials/metabox/readme.md) for new ways of extending the editor storing and using post meta data.
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to this PR, but can we move Meta Boxes Tutorial further? :)

mkaz and others added 7 commits July 9, 2020 09:31
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
Adds an additional link in JS tutorial to the new development
environment section, with regards to installing using nvm.

Plus includes a bit of markdown linting.
@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 10, 2020

I think there are some misunderstandings going on right now. I am kinda saying the same thing over and over again in my direct file comments.

I am still stuck at

paaljoachimromdahl@Paals-MacBook-Pro ~ % wp-env start
✖ No .wp-env.json file found at '/Users/paaljoachimromdahl/.wp-env.json' and could not determine if '/Users/paaljoachimromdahl' is a WordPress installation, a plugin, or a theme.
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

I have mentioned these things in various ways...
I need the next logical step to move onward in this step by step tutorial.
One minded focus in a step and then one can have some additional information as long as it goes along with the steps in a logical way. If it creates confusion like it does for me at present time, then rethink the placement and the information.
As in should the information be rephrased and perhaps added later on in the tutorial?
Can the information be cut out? Would the current step loose anything?

This documentation is about as I see it creating a foundation for a user to develop their own plugin and/or contribute to WordPress/Gutenberg. At the end of the tutorial options for going to Create A Block, Contribute to WordPress Core and/or Gutenberg should be added. As the base foundation for developing with WordPress is in place.

I just had to add the above comment as a comment directly to this issue, as I feel that comments in the file can get a bit lost.

Ps after we have landed this tutorial and I have a working local WordPress development setup then I can move on to testing out how to contribute to Gutenberg tutorial and the Create a Block tutorial. As I am the first test person so to speak who does not know a lot about coding who is going through this. A designer who wants to get into coding.

@mkaz
Copy link
Member Author

mkaz commented Jul 10, 2020

This page is a supplemental page to the Create a Bloc tutorial, it was moved out so we can link to it from other tutorials and expand on it the section with additional info that any other tutorial can reference.

The command you are trying to run must be run from a plugins directory. The error message says this also.
It looks like you have the environment setup, it just needs to be started from a plugins directory.

I'll update the instructions but once you have wp-env installed and confirmed you can do:

npx @wordpress/create-block gutenpride
cd gutenpride
wp-env start

Copy link
Contributor

@paaljoachim paaljoachim left a comment

Choose a reason for hiding this comment

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

This is a good version/iteration number 2. Let's continue onward with version/iteration 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants