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: Create a Block tutorial #22831

Merged
merged 25 commits into from
Jun 25, 2020
Merged

Docs: Create a Block tutorial #22831

merged 25 commits into from
Jun 25, 2020

Conversation

mkaz
Copy link
Member

@mkaz mkaz commented Jun 2, 2020

Description

Creates a new "Create a Block" tutorial that uses the new create-block package and scripts. The tutorial walks through the entire setup from developer environment to a completed block that accepts a message and stylizes it.

Related: #22151

How has this been tested?

Go through tutorial, does it make sense? work?

Types of changes

Documentation. View on the branch here

Still to do

  • Finishing touches page - what additional may we want to add for finishing touches on the tutorial? How to submit to block directory?
  • Add to Table of Contents / Manifest
  • Screenshots, did we ever figure out where to store assets 😆

@mkaz mkaz added the [Type] Developer Documentation Documentation for developers label Jun 2, 2020
@mkaz mkaz self-assigned this Jun 2, 2020
@mkaz mkaz requested a review from gziolo June 2, 2020 14:30
@gziolo gziolo added the [Feature] Block Directory Related to the Block Directory, a repository of block plugins label Jun 2, 2020
@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 4, 2020

Feedback.
Mainly typos.

https://github.com/WordPress/gutenberg/tree/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block

enviornment x 2 (written twice) = environment
pacakage = package

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/devenv.md

This page is really well written! Flows well!

Code Editor

What about mentioning a few other code editors? As you said it is a personal choice but it is always good to list a few to choose from to inform the user of some alternatives.

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/wp-plugin.md

Nicely written!

It would be nice to link to Chrome developer tools in addition to Firefox. To mention both.

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/esnext-js.md

Nicely done!

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/block-anatomy.md

Well explained!

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/block-attributes.md

This was not clear for me. It could be broken down some more.
"We will add a message attribute that will be the variable to hold the user message. The following code defines a message attribute of type string with the value derived from the source, defined as the text of a div tag."

To me it felt that the page lacked some more details. It was nice that you linked to additional resources.

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/block-code.md

Works well!

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/author-experience.md

Works.

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/finishing.md

Anything else. Could be to add various components into the block.
As my understanding is that there are a lot of components one can put into the block to get the needed functionality.

Next up will be to test this out.
As I am mainly a visual person and have done very little code. I mostly could follow along. The real test will be to setup Local and etc and go through the tutorial.

@mkaz
Copy link
Member Author

mkaz commented Jun 4, 2020

@paaljoachim Thank you for the comprehensive set of feedback. I've addressed all the items you listed and refined the tutorial further. I appreciate you walking through it, and look forward to feedback as you test out implementing. Thank you.

@WordPress WordPress deleted a comment from github-actions bot Jun 4, 2020
@github-actions
Copy link

github-actions bot commented Jun 4, 2020

Size Change: +5.59 kB (0%)

Total Size: 1.13 MB

Filename Size Change
build/annotations/index.js 3.62 kB +1 B
build/api-fetch/index.js 3.4 kB -1 B
build/autop/index.js 2.82 kB -4 B (0%)
build/block-directory/index.js 7.37 kB +101 B (1%)
build/block-directory/style-rtl.css 941 B +4 B (0%)
build/block-directory/style.css 942 B +5 B (0%)
build/block-editor/index.js 109 kB +2.69 kB (2%)
build/block-editor/style-rtl.css 10.7 kB +12 B (0%)
build/block-editor/style.css 10.7 kB +7 B (0%)
build/block-library/editor-rtl.css 7.59 kB -267 B (3%)
build/block-library/editor.css 7.6 kB -266 B (3%)
build/block-library/index.js 130 kB +101 B (0%)
build/block-library/style-rtl.css 8.04 kB +31 B (0%)
build/block-library/style.css 8.04 kB +34 B (0%)
build/blocks/index.js 48.2 kB +15 B (0%)
build/components/index.js 197 kB +1.38 kB (0%)
build/components/style-rtl.css 15.8 kB -97 B (0%)
build/components/style.css 15.7 kB -95 B (0%)
build/compose/index.js 9.62 kB +18 B (0%)
build/data-controls/index.js 1.29 kB +2 B (0%)
build/data/index.js 8.44 kB -3 B (0%)
build/dom/index.js 3.19 kB +26 B (0%)
build/edit-navigation/index.js 9.87 kB +1.61 kB (16%) ⚠️
build/edit-navigation/style-rtl.css 1.02 kB -1 B
build/edit-navigation/style.css 1.02 kB -2 B (0%)
build/edit-post/index.js 303 kB +143 B (0%)
build/edit-post/style-rtl.css 5.51 kB +11 B (0%)
build/edit-post/style.css 5.5 kB +5 B (0%)
build/edit-site/index.js 16.6 kB +15 B (0%)
build/edit-site/style-rtl.css 3.02 kB -4 B (0%)
build/edit-site/style.css 3.02 kB -5 B (0%)
build/edit-widgets/index.js 9.32 kB -6 B (0%)
build/edit-widgets/style-rtl.css 2.42 kB -10 B (0%)
build/edit-widgets/style.css 2.42 kB -11 B (0%)
build/editor/editor-styles-rtl.css 537 B +69 B (12%) ⚠️
build/editor/editor-styles.css 539 B +70 B (12%) ⚠️
build/editor/index.js 44.8 kB -76 B (0%)
build/editor/style-rtl.css 3.83 kB +26 B (0%)
build/editor/style.css 3.83 kB +26 B (0%)
build/element/index.js 4.65 kB -1 B
build/format-library/index.js 7.73 kB +7 B (0%)
build/format-library/style-rtl.css 547 B +5 B (0%)
build/format-library/style.css 548 B +5 B (0%)
build/hooks/index.js 2.13 kB +2 B (0%)
build/is-shallow-equal/index.js 710 B -1 B
build/keyboard-shortcuts/index.js 2.51 kB +1 B
build/keycodes/index.js 1.94 kB +1 B
build/list-reusable-blocks/index.js 3.13 kB +4 B (0%)
build/list-reusable-blocks/style-rtl.css 450 B +4 B (0%)
build/list-reusable-blocks/style.css 451 B +4 B (0%)
build/notices/index.js 1.79 kB +3 B (0%)
build/nux/index.js 3.4 kB +2 B (0%)
build/nux/style-rtl.css 663 B +1 B
build/nux/style.css 660 B +3 B (0%)
build/plugins/index.js 2.56 kB -1 B
build/priority-queue/index.js 789 B +1 B
build/redux-routine/index.js 2.85 kB -2 B (0%)
build/rich-text/index.js 14 kB -1 B
build/server-side-render/index.js 2.68 kB -2 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/blob/index.js 620 B 0 B
build/block-library/theme-rtl.css 730 B 0 B
build/block-library/theme.css 732 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/core-data/index.js 11.4 kB 0 B
build/date/index.js 5.47 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/escape-html/index.js 733 B 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/media-utils/index.js 5.29 kB 0 B
build/primitives/index.js 1.5 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 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.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 4, 2020

Hi Marcus @mkaz

I looked at the adjusted documentation and noticed this typo under Additional Components.

You can visually browse the compoents (should be components) and what their implementation looks like using the Storybook tool published at https://wordpress.github.io/gutenberg

The documentation looks really good!
Awesome job! From one tutorial creator to another. I run easywebdesigntutorials.com (which I have not updated in a while and I am these days reworking the site into using Gutenberg. I am also in the process of updating tutorials.)

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

I reviewed two files only, but I plan to check other files in the upcoming days as well. I’m really excited about this new tutorial, so far it’s looking great. Ideally, it’s reviewed by several folks with little knowledge about building blocks to validate it’s helpful 😃

On the technical level, do you think we should update the default template of @wordpress/create-block to scaffold the final version of this tutorial?


## A Better Solution

Replacing the Placeholder and TextControl when it is selected or not is jarring and not an ideal situation for this block. This was mainly used to illustrate what can be done depending on your block. It is important to think about the author's experience using the block.
Copy link
Member

Choose a reason for hiding this comment

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

This could be rephrased a bit. My first reaction was: if it’s jarring why I even had to think about it. Can we start with thinking about the best experience, emphasis that placeholders are usually the way to go, it’s one of principles of blocks but here we can simplify it with CSS?

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 introduced the placeholder with how images and embeds handle it, which works well for images, but not for text. The goal was to show how people might think about the problem seeing other references.

I rephrase and we see if that is better.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 6, 2020

Going through this as a non developer.
Step by step.

There is a lot of confusion during the first step.

Development Tools

What does “bootstrap a block” mean?

The tools are used to take the JavaScript we are going to write, which is in a syntax that the browser can not run, and transpile it into a syntax it can.

Can instead become:

The tools are used to take the JavaScript we are going to write and transpile (transpile explaination ) it into a syntax the browser can run.

————

NB! All links need to open in a new tab! So one does not loose the tutorial in relation to clicking the links.

download Nodejs (link) ——> https://nodejs.org/en/download/ (download the installer for the operating system that you use.)

It also packaged for most package managers. = This means what?

I went ahead and downloaded the Nodejs and installed it before I read the recommendation about using Homebrew package tool for the Mac.

brew install nodejs = the js part is outside the code syntax.

I am confused about the Homebrew package tool part. Going to the Homebrew site:
It says Install Homebrew and this code:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

The documentation says:
“On Mac, I recommend using Homebrew package tool and install is: brew install nodejs”

I am confused about the two install methods one mentioned in the sentence right above here and one suggested on the Homebrew web site.

NPM usually comes bundled with the above installs. = That is confusing. The above speaks about downloading and installing, and now I read that the NPM also bundles the above installs.
Should I download the Nodejs or NPM which also contains it seems Nodejs?

However you install Nodejs… ?

I am not clear about the different methods used.

  1. Download from Nodejs.
  2. Homebrew package tool seems like another method. But I am not sure. It seems like this is connected with 1.
  3. Download and install NPM (I think). There is no link to where to download NPM.

I think that was the Development Tools page. I stopped up there, and will start again after the docs have been updated. Have a great weekend!

mkaz added 2 commits June 9, 2020 11:15
- Add clarification around TextControl use
- Fix classname back to root element
- Rephrase on how to better stylize text
- Simplify quick start, emphasize activation
- Add CLI prompts for questions
- Call out package managers is an alternative
- Be clear about what is needed per platform
@mkaz
Copy link
Member Author

mkaz commented Jun 9, 2020

@paaljoachim I think I addressed your concerns here. I called out that the package managers is an alternative to using the Node installer. I also specified clearly which platform what matches with.

Thanks for the feedback, keep it coming.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 9, 2020

Open links in a new tab?

https://github.com/WordPress/gutenberg/blob/add/docs-create-block/docs/designers-developers/developers/tutorials/create-block/devenv.md

Freeflowing thoughts as I understand the instructions.

"The tools are used to convert the JavaScript we are going to write into a format that browsers can run. This is called transpiling or the build step."

New:
If you are not already using a package manager then you will need to download one. The package manager contains Node and NPM.

On Mac, Homebrew (link) is a popular package manager. After having downloaded Homebrew follow our instructions on install. Open terminal and type: brew install nodejs

On Windows, Chocolatey (link) is a popular package manager. After having downloaded Chocolatey follow our instructions on install. Open terminal and type: choco install nodejs

On Linux, you should confirm NPM is also installed. In some systems it is bundled separately and you may need to explicitly install it. For example, on Ubuntu, or Debian systems you can install using: apt install nodejs npm

If you already have a package manager installed, you can download Nodejs (link) directly from the main website and install.


"Alternatively, if you use a package manager, a node package is avilable (typo) for most package managers."

"....otherwise step through whatever part of the tutorial you need."
Could be changed to:
".... otherwise step through the tutorial part you need.
Edit:
"... otherwise go to section of the tutorial you need."

@gziolo
Copy link
Member

gziolo commented Jun 10, 2020

Open links in a new tab?

I don’t think we use it in other places. Besides, it’s something you can do yourself with keyboard modifiers or with mouse interactions built into OS.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 22, 2020

Great Marcus!
I will start over again and go through it, and let you know how it goes.

It is slow going but the documentation is getting better for each revision!

@paaljoachim
Copy link
Contributor

Restarting the test. I installed Homebrew this time. Reinstalled Docker. I added this:
npm -g install @wordpress/env to terminal and received the same permission error as before.

My guess was that the original Nodejs install affected the wp-env, so I looked for ways to remove nodejs from my OSX system. I came across this: https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/ and followed it.
The result was that node -v and npm -v could not be found any longer on my OSX system.

I then reinstalled Homebrew. Then checked to see if node -v and npm -v had been reinstalled. They had not.
I ran npm -g install @wordpress/env but it could not be found.


Right now I am looking at https://changelog.com/posts/install-node-js-with-homebrew-on-os-x and following the instructions there. I got this message at the end:
"Warning: node 14.4.0 is already installed, it's just not linked
You can use brew link node to link this version."

I typed brew link node

Then received:

Error: Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.

Right now I am not sure how to proceed.

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 22, 2020

I uninstalled Homebrew.
https://osxdaily.com/2018/08/12/how-uninstall-homebrew-mac/
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Reinstalled using https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
That seemed to work.

Then typed: brew install node

==> Installing node
==> Pouring node-14.4.0.catalina.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man1/node.1
Target /usr/local/share/man/man1/node.1
already exists. You may want to remove it:
  rm '/usr/local/share/man/man1/node.1'

I added rm '/usr/local/share/man/man1/node.1' to remove it and did brew install node again.

==> node
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
paaljoachimromdahl@Paals-MacBook-Pro ~ % node -v
zsh: command not found: node
paaljoachimromdahl@Paals-MacBook-Pro ~ % rm '/usr/local/share/man/man1/node.1'
override rw-r--r--  root/wheel for /usr/local/share/man/man1/node.1? yes
paaljoachimromdahl@Paals-MacBook-Pro ~ % brew install node
Warning: node 14.4.0 is already installed, it's just not linked
You can use `brew link node` to link this version.
paaljoachimromdahl@Paals-MacBook-Pro ~ % node -v
zsh: command not found: node
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

EDIT:

Another try. This seemed to have worked:
I found this thread: https://discourse.brew.sh/t/mac-osx-homebrew-error-could-not-symlink-include-node-common-gypi/4717/5

I ran:
sudo chown -R $(whoami) /usr/local/*

Then reinstalled Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then typed: brew install node

Node and npm are now showing up:

node -v
v14.4.0
npm -v
6.14.4

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 23, 2020

Next step is installing:
npm -g install @wordpress/env

These are the messages I received in terminal:

paaljoachimromdahl@Paals-MacBook-Pro ~ % npm -g install @wordpress/env
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
/usr/local/bin/wp-env -> /usr/local/lib/node_modules/@wordpress/env/bin/wp-env

> [email protected] install /usr/local/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
node-pre-gyp
WARN Tried to download(404): https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.26.5-node-v83-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, unknown) (falling back to source compile with node-gyp)
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp
ERR! configure error
gyp
ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack
at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR!
System Darwin 19.5.0
gyp ERR! command "/usr/local/Cellar/node/14.4.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release/nodegit.node" "--module_name=nodegit" "--module_path=/usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR!
cwd /usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit
gyp ERR! node -v v14.4.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

node-pre-gyp
ERR! build error
node-pre-gyp ERR!
stack Error: Failed to execute '/usr/local/Cellar/node/14.4.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release/nodegit.node --module_name=nodegit --module_path=/usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@wordpress/env/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp
ERR! stack     at maybeClose (internal/child_process.js:1051:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp
ERR! System Darwin 19.5.0
node-pre-gyp ERR!
command "/usr/local/Cellar/node/14.4.0/bin/node" "/usr/local/lib/node_modules/@wordpress/env/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit
node-pre-gyp ERR! node -v v14.4.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok

Failed to execute '/usr/local/Cellar/node/14.4.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release/nodegit.node --module_name=nodegit --module_path=/usr/local/lib/node_modules/@wordpress/env/node_modules/nodegit/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
[nodegit] ERROR - Could not finish install
[nodegit] ERROR - finished with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node lifecycleScripts/preinstall && node lifecycleScripts/install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/paaljoachimromdahl/.npm/_logs/2020-06-23T12_59_42_470Z-debug.log

Checking:

paaljoachimromdahl@Paals-MacBook-Pro ~ % wp-env --version
zsh: command not found: wp-env
paaljoachimromdahl@Paals-MacBook-Pro ~ % 

I am a present time not able to get the wp-env installed through terminal.

@paaljoachim
Copy link
Contributor

Looking at alternatives such as Local.

WordPress Plugin (doc page)

"If you do not plan to use wp-env change to your local WordPress plugin directory; if you do plan to use wp-env start from any directory for your project."

--->
If you decided to not use wp-env then change to your local WordPress plugin directory.
Example: ~\Local Sites\nameofwpsite\wp-content\plugins

"Run the following command to generate plugin files:"
npx @wordpress/create-block gutenpride

---> If using Local or another software. What would be the correct terminal command be? For instance based on the above example.

"The generated plugin should now be listed on the Plugins admin page in your WordPress install. If you are using wp-env, see Development Enviornment (typo) setup, then you should now run:"
wp-env start

If using Local? Start the site up in Local and enter the WordPress site.

@mkaz
Copy link
Member Author

mkaz commented Jun 23, 2020

@paaljoachim I added heading to the plugin section, so it says which each step is, plus made it clear the options for each one giving an A and B for Local vs. wp-env

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 23, 2020

A work around suggested by Marcus.
https://tecadmin.net/install-nodejs-with-nvm/

I pasted this code into terminal:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

It seemed to work alright until this point:

=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
  OR
=> Append the following lines to the correct file yourself:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
=> 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
paaljoachimromdahl@Paals-MacBook-Pro ~ %

The above code asked me to create one of the files listed. I typed this into terminal:
touch ~/.zshrc
touch = creates a file.
~/ = home directory.

I received no confirmation that the file was created.
I quit terminal and reopened it and once again ran:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

This time it seemed to work.


I tried again to install npm -g install @wordpress/env
The same errors showed up.

Closed terminal and reopened.
Next step: nvm install node

There seemed to be some errors, but I closed terminal and reopened and ran nvm install node again. This time terminal gave this message:

v14.4.0 is already installed.
Now using node v14.4.0 (npm v6.14.5)

Closed and reopened terminal. Pasted:
npm -g install @wordpress/env into terminal again.

The same errors as seen further above came back.

One error that is seen in the longer terminal message above containing the errors is:
gyp: No Xcode or CLT version detected!

I followed the instructions here: https://anansewaa.com/install-command-line-tools-on-macos-catalina/ to (re)install Xcode.

paaljoachimromdahl@Paals-MacBook-Pro ~ % xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Testing this: https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-line
softwareupdate --install -a

No updates are available.

I have logged into: https://developer.apple.com/download/more/ to download the latest stable Xcode. Version 11.5. It is currently downloading the 7.6GB zip file. I also downloaded the Command Line Tools for Xcode 11.5GM Seed.dmg

@gziolo
Copy link
Member

gziolo commented Jun 24, 2020

@paaljoachim for typos and different phrasing you can propose the change directly in the UI. This way it’s going to be much easier to apply (anyone with member can do it) and your contributions will be attributed to you out of the box. See: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/reviewing-proposed-changes-in-a-pull-request#starting-a-review

@mkaz
Copy link
Member Author

mkaz commented Jun 24, 2020

I've linked up the tutorial to table of contents, and added a link at the bottom of each page to the next.

My preference is to get this merged and up and then iterate with additional information, it will be easier to track individual changes and suggestions -vs- continuing on a large set of docs at once.

@gziolo
Copy link
Member

gziolo commented Jun 25, 2020

@mkaz, is there a way to put this tutorial in a temporary folder in docs and iterate with follow-up tasks?

In the meantime, I helped @coreymckrill to merge this change where we generate block.json for blocks: #23399. It looks like it should deserve its own section in the tutorial.

Earlier this week, I backported to WordPress core new method for block registration that will make it possible to register blocks from PHP using block.json – register_block_type_from_metadata. It will be the preferred way to register blocks for Block Directory. Related commit: WordPress/wordpress-develop@5f6ab44.

If it's merged, some other folks could help with the individual steps of this tutorial.

@mkaz
Copy link
Member Author

mkaz commented Jun 25, 2020

@mkaz, is there a way to put this tutorial in a temporary folder in docs and iterate with follow-up tasks?

@gziolo I can remove it from Table of Contents, we could still merge, it would not get published since it wouldn't be in the manifest. So it'd be in the repo but not published to Block Editor handbook. Is that what you were thinking?

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Yes, it works for me, let's do it :)

@paaljoachim, any concerns?

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 25, 2020

I have not yet tested the most recent version so I do not know if that works.
But what we have now seems like a very good first version.
I can aim on giving feedback to version 2.

@mkaz mkaz merged commit 1e3372a into master Jun 25, 2020
@mkaz mkaz deleted the add/docs-create-block branch June 25, 2020 18:35
@github-actions github-actions bot added this to the Gutenberg 8.5 milestone Jun 25, 2020
@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 26, 2020

As the initial link to the documentation has changed. The documentation is now here: https://github.com/WordPress/gutenberg/tree/master/docs/designers-developers/developers/tutorials/create-block

@paaljoachim
Copy link
Contributor

paaljoachim commented Jun 30, 2020

Btw I am using Mac OSX 10.15.5. (macOS Catalina).
As I am having problems with setting up the dev environment I would also suggest adding a trouble shooting section.

  • A how to reset the dev environment back to scratch and starting the procedure all over again.

As soon as the next iteration PR has been setup. Let me know and I will begin to give feedback there.

@paaljoachim
Copy link
Contributor

One more thing.
Setting up the documentation.

A user who turns into a developer needs to know how to set up the Gutenberg development environment. So the very first tutorial would be setting up a local development environment for Gutenberg. It should contain various information which has been setup up to this point. With a trouble shooting section at the end.

At the end of setting up the Gutenberg development environment it branches out to (adds links to)
->
Creating the first block with Gutenberg.
with a link to: Add block submission guidelines. #23545
and links to other tutorials. Such as the below.

Contributing to Gutenberg. Can contain: Setting up a PR. Contributing to an existing PR. Code reviews. Etc.... (adds links to)
->
(Create tutorials based on existing issues/PRs.)
-How to add an icon to a toolbar with examples of existing blocks. This issue be a good example issue to create a good from: #12684 (comment)
-How to adjust the sidebar setting.
-Actually a lot of how to links here.....

Bottom line. It all starts with setting up the Gutenberg environment. Kinda like a breadcrumbs path containing parents and children.
(Parent) Gutenberg environment -> (child) Creating the first block with Gutenberg.
(Parent) Gutenberg environment -> (child) Contributing to Gutenberg.
(Parent) Gutenberg environment -> (child) How to add icon to toolbar.
(Parent) Gutenberg environment -> (child) ---There are a lot of tutorials--

@paaljoachim
Copy link
Contributor

We have the Setting up the base/foundation for local WordPress Development Environment here: #23593
For creating a plugin or contributing to WordPress core and/or Gutenberg.

--

But where are the docs for Creating a Block?

@mkaz
Copy link
Member Author

mkaz commented Jul 13, 2020

@paaljoachim I need approval and then I can merge #23593 after that is in, I can link up the Create a Block tutorial. Right now it's only in GitHub and not published publicly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants