You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge branch 'trunk' of github.com:WordPress/gutenberg into fix/env-wp-tests-config
* 'trunk' of github.com:WordPress/gutenberg: (88 commits)
Components: refactor `AlignmentMatrixControl` to pass `exhaustive-deps` (#41167)
[RNMobile] Add 'Insert from URL' option to Image block (#40334)
[RNMobile] Improvements to Getting Started Guides (#40964)
Post Author Name: Add to and from Post Author transformations (#41151)
CheckboxControl: Add unit tests (#41165)
Improve inline documentation (#41209)
Mobile Release v1.76.1 (#41196)
Use explicit type definitions for entity configuration (#40995)
Scripts: Convert file extension to js in `block.json` during build (#41068)
Reflects revert in 6446878 (#41221)
get_style_nodes should be compatible with parent method. (#41217)
Gallery: Opt-in to axial (column/row) block spacing controls (#41175)
Table of Contents block: convert line breaks to spaces in headings. (#41206)
Add support for button elements to theme.json (#40260)
Global Styles: Load block CSS conditionally (#41160)
Update URL (#41188)
Improve autocompleter performance (#41197)
Site Editor: Set min-width for styles preview (#41198)
Remove Navigation Editor screen from experiments page (#40878)
Fix broken Page title for pages created inline within in Nav block (#41063)
...
Copy file name to clipboardexpand all lines: docs/contributors/code/coding-guidelines.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Coding Guidelines
2
2
3
-
This living document serves to prescribe coding guidelines specific to the Gutenberg project. Base coding guidelines follow the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/). The following sections outline additional patterns and conventions used in the Gutenberg project.
3
+
This living document serves to prescribe coding guidelines specific to the Gutenberg project. Base coding guidelines follow the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/). The following sections outline additional patterns and conventions used in the Gutenberg project.
Copy file name to clipboardexpand all lines: docs/contributors/code/react-native/getting-started-react-native.md
+2
Original file line number
Diff line number
Diff line change
@@ -72,6 +72,8 @@ To see a list of all of your available iOS devices, use `xcrun simctl list devic
72
72
73
73
### Troubleshooting
74
74
75
+
If the Android emulator doesn't start correctly, or compiling fails with `Could not initialize class org.codehaus.groovy.runtime.InvokerHelper` or similar, it may help to double check the set up of your development environment against the latest requirements in [React Native's documentation](https://reactnative.dev/docs/environment-setup). With Android Studio, for example, you will need to configure the `ANDROID_HOME` environment variable and ensure that your version of JDK matches the latest requirements.
76
+
75
77
Some times, and especially when tweaking anything in the `package.json`, Babel configuration (`.babelrc`) or the Jest configuration (`jest.config.js`), your changes might seem to not take effect as expected. On those times, you might need to stop the metro bunder process and restart it with `npm run native start:reset`. Other times, you might want to reinstall the NPM packages from scratch and the `npm run native clean:install` script can be handy.
# Setup guide for React Native development (macOS)
2
2
3
-
Are you interested in contributing to the native mobile editor? This
4
-
guide is a detailed walk through designed to get you up and running!
3
+
Are you interested in contributing to the native mobile editor? This guide is a detailed walk through designed to get you up and running!
5
4
6
-
Note that the following instructions here are primarily focused on the
7
-
macOS environment. For other environments, [the React Native quickstart documentation](https://reactnative.dev/docs/environment-setup)
8
-
has helpful pointers and steps for getting set up.
9
-
10
-
## Install Xcode
11
-
12
-
Install [Xcode](https://developer.apple.com/xcode/) via the app store. We'll be using
13
-
the XCode to both compile the iOS app and use the phone simulator app.
14
-
15
-
Once it has been installed from the App Store, open it by visiting `Applications > Xcode`
16
-
17
-
After opening the application:
18
-
19
-
- Accept the license agreement.
20
-
- Verify that `Xcode > Preferences > Locations > Command Line Tools` points at the current Xcode version.
21
-
22
-
<imgsrc="https://developer.wordpress.org/files/2021/10/xcode-command-line-tools.png"width="500"alt="Screenshot of XCode command line tools settings.">
5
+
Note that these instructions are primarily focused on the macOS environment. For other environments, [the React Native quickstart documentation](https://reactnative.dev/docs/environment-setup) has helpful pointers and steps for getting set up.
23
6
24
7
## Clone Gutenberg
25
8
26
-
If Xcode was installed successfully, we'll also have a version of git available. (It's possible to
27
-
update this later if we want to use a more recent version).
28
-
29
-
In a terminal run:
30
-
31
9
```sh
32
10
git clone git@github.com:WordPress/gutenberg.git
33
11
```
34
12
35
13
### Install node and npm
36
14
37
-
If you’re working in multiple JS projects, a node version manager may make sense. A manager will let you
38
-
switch between different node and npm versions of your choosing.
39
-
40
-
Some good options are [nvm](https://github.com/nvm-sh/nvm) or [volta](https://volta.sh/).
15
+
If you’re working in multiple JS projects, a node version manager may make sense. A manager will let you switch between different node and npm versions of your choosing.
41
16
42
-
Pick one and follow the install instructions noted on their website.
17
+
We recommend [nvm](https://github.com/nvm-sh/nvm).
43
18
44
-
Then run:
19
+
After installing nvm, run the following from the top-level directory of the cloned project:
45
20
46
21
```sh
47
22
nvm install 'lts/*'
48
23
nvm alias default 'lts/*'# sets this as the default when opening a new terminal
49
24
nvm use # switches to the project settings
50
25
```
51
26
52
-
Or
53
-
54
-
```sh
55
-
volta install node #defaults to installing lts
56
-
```
57
-
58
-
Then install dependencies from your Gutenberg checkout folder:
27
+
Then install dependencies:
59
28
60
29
```
61
30
npm ci
62
31
```
63
32
64
-
####Do you have an older existing Gutenberg checkout?
33
+
### Do you have an older existing Gutenberg checkout?
65
34
66
35
If you have an existing Gutenberg checkout be sure to fully clean `node_modules` and re-install dependencies.
67
36
This may help avoid errors in the future.
@@ -71,28 +40,56 @@ npm run distclean
71
40
npm ci
72
41
```
73
42
74
-
## Unit Tests
43
+
## iOS
75
44
76
-
Unit tests should work at this point.
45
+
### CocoaPods
77
46
78
-
```sh
79
-
npm run native test
47
+
[CocoaPods](https://guides.cocoapods.org/using/getting-started.html) is required to fetch React and third-party dependencies. The steps to install it vary depending on how Ruby is managed on your machine.
48
+
49
+
#### System Ruby
50
+
51
+
If you're using the default Ruby available with MacOS, you'll need to use the `sudo` command to install gems like Cocoapods:
52
+
53
+
```
54
+
sudo gem install cocoapods
80
55
```
81
56
82
-
## iOS
57
+
Note, Mac M1 is not directly compatible with Cocoapods. If you encounter issues, try running these commands to install the ffi package, which will enable pods to be installed with the proper architecture:
58
+
59
+
```
60
+
sudo arch -x86_64 gem install ffi
61
+
arch -x86_64 pod install
62
+
```
63
+
64
+
#### Ruby Manager
65
+
66
+
It may not be necessary to manually install Cocoapods or the `ffi` package if you're using a Ruby Version manager. Please refer to your chosen manager's documentation for guidance.
67
+
68
+
[`rbenv`](https://github.com/rbenv/rbenv) is the recommended manager if you're running Gutenberg from within [the WordPress iOS app](https://github.com/wordpress-mobile/WordPress-iOS) (vs. only the demo app).
83
69
84
-
The easiest way to figure out what needs to be installed is using the
85
-
[react native doctor](https://reactnative.dev/blog/2019/11/18/react-native-doctor). From your checkout, or
86
-
relative to `/packages/react-native-editor folder`, run:
70
+
### Set up Xcode
71
+
72
+
Install [Xcode](https://developer.apple.com/xcode/) via the app store and then open it up:
73
+
74
+
- Accept the license agreement.
75
+
- Verify that `Xcode > Preferences > Locations > Command Line Tools` points to the current Xcode version.
76
+
77
+
<imgsrc="https://developer.wordpress.org/files/2021/10/xcode-command-line-tools.png"width="700px"alt="Screenshot of XCode command line tools settings.">
78
+
79
+
### react-native doctor
80
+
81
+
[react-native doctor](https://reactnative.dev/blog/2019/11/18/react-native-doctor) can be used to identify anything that's missing from your development environment. From your Gutenberg checkout, or relative to `/packages/react-native-editor folder`, run:
87
82
88
83
```sh
89
84
npx @react-native-community/cli doctor
90
85
```
91
86
92
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-doctor.png"width="500px"alt="Screenshot of react-native-community/cli doctor tool running in the terminal.">
87
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-doctor.png"width="700px"alt="Screenshot of react-native-community/cli doctor tool running in the terminal.">
93
88
94
89
See if `doctor` can fix both "common" and "iOS" issues. (Don't worry if "Android" still has ❌s at this stage, we'll get to those later!)
95
90
91
+
### Run the demo app
92
+
96
93
Once all common and iOS issues are resolved, try:
97
94
98
95
```
@@ -105,37 +102,46 @@ In another terminal type:
105
102
npm run native ios
106
103
```
107
104
108
-
After waiting for everything to build we should see:
105
+
After waiting for everything to build, the demo app should be running from the iOS simulator:
109
106
110
-
<imgsrc="https://developer.wordpress.org/files/2021/10/iOS-Simulator.png"alt="Screenshot of the block editor in iOS simulator." />
107
+
<imgsrc="https://developer.wordpress.org/files/2021/10/iOS-Simulator.png"width="700px"alt="Screenshot of the block editor in iOS simulator." />
111
108
112
109
## Android
113
110
114
-
To keep things simple, let's use Android Studio for all JDK and SDK package management.
115
-
The first step is [downloading Android Studio](https://developer.android.com/studio).
111
+
### Java Development Kit (JDK)
116
112
117
-
Next, open an existing project and select the gutenberg folder you cloned:
113
+
The JDK recommended in [the React Native documentation](https://reactnative.dev/docs/environment-setup) is called Azul Zulu. It can be installed using [Homebrew](https://brew.sh/). To install it, run the following commands in a terminal after installing Homebrew:
118
114
119
-
Click on the cube with the down arrow:
115
+
```
116
+
brew tap homebrew/cask-versions
117
+
brew install --cask zulu11
118
+
```
120
119
121
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-package-manager.png"alt="Screenshot highlighting where the package manager button is located in Android Studio.">
120
+
If you already have a JDK installed on your system, it should be JDK 11 or newer.
122
121
123
-
We can download SDK platforms, packages and other tools on this screen. Specific versions are
124
-
hidden behind the "Show package details" checkbox, check it, since our build requires specific versions for E2E and
125
-
development:
122
+
### Set up Android Studio
126
123
127
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-show-package-details.png"alt="Screenshot of the package manager in Android Studio, highlighting the Show Package Details checkbox.">
124
+
To compile the Android app, [download Android Studio](https://developer.android.com/studio).
128
125
129
-
Check all related packages from [build.gradle](https://github.com/WordPress/gutenberg/blob/trunk/packages/react-native-editor/android/build.gradle).
130
-
Then click on "Apply" to download items. There may be other related dependencies from build.gradle files in node_modules.
131
-
If you don’t want to dig through files, stack traces will complain of missing packages, but it does take quite a number
132
-
of tries if you go through this route.
126
+
Next, open an existing project and select the Gutenberg folder you cloned.
133
127
134
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-editor-build-gradle.png"alt="Screenshot of the build.gradle configuration file.">
128
+
From here, click on the cube icon that's highlighted in the following screenshot to access the SDK Manager. Another way to the SDK Manager is to navigate to `Tools > SDK Manager`:
135
129
136
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-sdk.png"width="500"alt="Screenshot of the package manager displaying SDK Platforms.">
130
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-package-manager.png"width="700px"alt="Screenshot highlighting where the package manager button is located in Android Studio.">
137
131
138
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-sdk-tools.png"width="500"alt="Screenshot of the package manager displaying SDK Tools.">
132
+
We can download SDK platforms, packages and other tools on this screen. Specific versions are hidden behind the "Show package details" checkbox, check it, since our build requires specific versions for E2E and development:
133
+
134
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-show-package-details.png"width="700px"alt="Screenshot of the package manager in Android Studio, highlighting the Show Package Details checkbox.">
135
+
136
+
Check all related packages from [build.gradle](https://github.com/WordPress/gutenberg/blob/trunk/packages/react-native-editor/android/build.gradle). Then click on "Apply" to download items. There may be other related dependencies from build.gradle files in node_modules.
137
+
138
+
If you don’t want to dig through files, stack traces will complain of missing packages, but it does take quite a number of tries if you go through this route.
139
+
140
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-editor-build-gradle.png"width="700px"alt="Screenshot of the build.gradle configuration file.">
141
+
142
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-sdk.png"width="700px"alt="Screenshot of the package manager displaying SDK Platforms.">
143
+
144
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-sdk-tools.png"width="700px"alt="Screenshot of the package manager displaying SDK Tools.">
139
145
140
146
### Update Paths
141
147
@@ -167,26 +173,25 @@ source ~/.bash_profile
167
173
168
174
If the SDK path can't be found, you can verify its location by visiting Android Studio > Preferences > System Settings > Android SDK
169
175
170
-
<imgsrc="https://developer.wordpress.org/files/2021/10/sdk-path.png"alt="Screenshot of where the SDK Path may be found in Android Studio.">
176
+
<imgsrc="https://developer.wordpress.org/files/2021/10/sdk-path.png"width="700px"alt="Screenshot of where the SDK Path may be found in Android Studio.">
171
177
172
178
### Create a new device image
173
179
174
180
Next, let’s create a virtual device image. Click on the phone icon with an android to the bottom-right.
175
181
176
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-android-device-manager-button.png"alt="Screenshot of where to find the android device manager button.">
182
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-android-device-manager-button.png"width="700px"alt="Screenshot of where to find the android device manager button.">
177
183
178
184
This brings up the “Android Virtual Device Manager” or (AVD). Click on “Create Virtual Device”. Pick a phone type of your choice:
179
185
180
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-android-select-hardware.png"alt="Screenshot of the Virtual Device Configuration setup.">
186
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-android-select-hardware.png"width="700px"alt="Screenshot of the Virtual Device Configuration setup.">
181
187
182
-
Pick the target SDK version. This is the targetSdkVersion set in the
Pick the target SDK version. This is the targetSdkVersion set in the [build.gradle](https://github.com/WordPress/gutenberg/blob/trunk/packages/react-native-editor/android/build.gradle) file.
184
189
185
-
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-adv-system-image.png"alt="Screenshot of picking a system image in the Android Device Manager workflow.">
190
+
<imgsrc="https://developer.wordpress.org/files/2021/10/react-native-adv-system-image.png"width="700px"alt="Screenshot of picking a system image in the Android Device Manager workflow.">
186
191
187
192
There are some advanced settings we can toggle, but these are optional. Click finish.
188
193
189
-
### Putting it all together
194
+
### Run the demo app
190
195
191
196
Start metro:
192
197
@@ -202,7 +207,13 @@ npm run native android
202
207
203
208
After a bit of a wait, we’ll see something like this:
204
209
205
-
<imgsrc="https://developer.wordpress.org/files/2021/10/android-simulator.png"alt="Screenshot of a the block editor in Android Simulator.">
210
+
<imgsrc="https://developer.wordpress.org/files/2021/10/android-simulator.png"width="700px"alt="Screenshot of a the block editor in Android Simulator.">
211
+
212
+
## Unit Tests
213
+
214
+
```sh
215
+
npm run native test
216
+
```
206
217
207
218
## Integration Tests
208
219
@@ -212,14 +223,13 @@ After a bit of a wait, we’ll see something like this:
212
223
npx appium-doctor
213
224
```
214
225
215
-
<imgsrc="https://developer.wordpress.org/files/2021/10/CleanShot-2021-10-27-at-15.20.16.png"width="500px"alt="Screenshot of the appium-doctor tool running in the terminal.">
226
+
<imgsrc="https://developer.wordpress.org/files/2021/10/CleanShot-2021-10-27-at-15.20.16.png"width="700px"alt="Screenshot of the appium-doctor tool running in the terminal.">
216
227
217
228
Resolve any required dependencies.
218
229
219
230
### iOS Integration Tests
220
231
221
-
If we know we can run the iOS local environment without issue, E2Es for iOS are straightforward. Stop any running metro processes.
222
-
This was launched previously with `npm run native start:reset`.
232
+
If we know we can run the iOS local environment without issue, E2Es for iOS are straightforward. Stop any running metro processes. This was launched previously with `npm run native start:reset`.
223
233
224
234
Then in terminal type:
225
235
@@ -243,7 +253,7 @@ If all things go well, it should look like:
243
253
244
254
Start the virtual device first. Go back to the AVD by clicking on the phone icon, then click the green play button.
245
255
246
-
<imgsrc="https://developer.wordpress.org/files/2021/10/adv-integration.png"alt="A screenshot of how to start the Android Simulator.">
256
+
<imgsrc="https://developer.wordpress.org/files/2021/10/adv-integration.png"width="700px"alt="A screenshot of how to start the Android Simulator.">
247
257
248
258
Make sure no metro processes are running. This was launched previously with `npm run native start:reset`.
249
259
@@ -261,4 +271,4 @@ npm run native test:e2e:android:local gutenberg-editor-paragraph.test.js
261
271
262
272
After a bit of a wait we should see:
263
273
264
-
<imgsrc="https://developer.wordpress.org/files/2021/10/CleanShot-2021-10-27-at-15.28.22.png"alt="A screenshot of block editor integration tests in Android Simulator.">
274
+
<imgsrc="https://developer.wordpress.org/files/2021/10/CleanShot-2021-10-27-at-15.28.22.png"width="700px"alt="A screenshot of block editor integration tests in Android Simulator.">
0 commit comments