DevTools build script enhancements (#17653)
* Updated DevTools local development instructions to mention experimental build step * Added a command to download latest experimental release (for DevTools) * Updated build instructions for clarity * Added build-for-devtools package alias
Brian Vaughn committed
Dec 18, 2019 at 14:34 UTC
95056b68365f1f3a646d1d6c65c9e3d2a50122ca
12 files changed
+130
-24
package.json
+1
@@ -98,6 +98,7 @@
98
},
99
"scripts": {
100
"build": "node ./scripts/rollup/build.js",
101
+ "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build -- react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer --type=NODE",
102
"linc": "node ./scripts/tasks/linc.js",
103
"lint": "node ./scripts/tasks/eslint.js",
104
"lint-build": "node ./scripts/rollup/validate/index.js",
packages/react-devtools-extensions/README.md
+16
-6
@@ -6,16 +6,26 @@ The easiest way to install this extension is as a browser add-on:
6
* [Chrome web store](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
7
* [Firefox Add-ons](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/)
8
9
-## Development
10
-
9
+## Local development
10
You can also build and install this extension from source.
11
13
-DevTools embeds local versions of several NPM packages also in this workspace. If you have not already built them, you'll need to do that before getting started by running the following command in the root directory of this repository:
12
+### Prerequisite steps
13
+DevTools depends on local versions of several NPM packages<sup>1</sup> also in this workspace. You'll need to either build or download those packages first.
14
+
15
+<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API.
16
+
17
+#### Build from source
18
+To build dependencies from source, run the following command from the root of the repository:
19
```sh
15
-yarn build -- react,react-dom,react-is,scheduler --type=NODE
20
+yarn build-for-devtools
21
```
17
-
18
-Once the above packages have been built, you can build the extension by running:
22
+#### Download from CI
23
+To use the latest build from CI, run the following command from the root of the repository:
24
+```sh
25
+./scripts/release/download-experimental-build.js
26
+```
27
+### Build steps
28
+Once the above packages have been built or downloaded, you can build the extension by running:
29
```sh
30
cd packages/react-devtools-extensions/
31
packages/react-devtools-inline/README.md
+22
-3
@@ -153,9 +153,28 @@ iframe.onload = () => {
153
};
154
```
155
156
-## Development
156
+## Local development
157
+You can also build and test this package from source.
158
158
-Watch for changes made to the source code and rebuild:
159
+### Prerequisite steps
160
+DevTools depends on local versions of several NPM packages<sup>1</sup> also in this workspace. You'll need to either build or download those packages first.
161
+
162
+<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API.
163
+
164
+#### Build from source
165
+To build dependencies from source, run the following command from the root of the repository:
166
+```sh
167
+yarn build-for-devtools
168
+```
169
+#### Download from CI
170
+To use the latest build from CI, run the following command from the root of the repository:
171
+```sh
172
+./scripts/release/download-experimental-build.js
173
+```
174
+### Build steps
175
+Once the above packages have been built or downloaded, you can watch for changes made to the source code and automatically rebuild by running:
176
```sh
177
yarn start
161
-```
\ No newline at end of file
178
+```
179
+
180
+To test package changes, refer to the [`react-devtools-shell` README](https://github.com/facebook/react/blob/master/packages/react-devtools-shell/README.md).
\ No newline at end of file
packages/react-devtools-shell/README.md
+2
-7
@@ -2,14 +2,9 @@ Harness for testing local changes to the `react-devtools-inline` and `react-devt
2
3
## Development
4
5
-This target should be run in parallel with the `react-devtools-inline` package. The first step then is to watch for changes to that target:
6
-```sh
7
-cd packages/react-devtools-inline
8
-
9
-yarn start
10
-```
5
+This target should be run in parallel with the `react-devtools-inline` package. The first step then is to run that target following the instructions in the [`react-devtools-inline` README](https://github.com/facebook/react/blob/master/packages/react-devtools-inline/README.md).
6
12
-Next, watch for changes to the test harness:
7
+The test harness can then be run as follows:
8
```sh
9
cd packages/react-devtools-shell
10
packages/react-devtools/README.md
+20
-1
@@ -109,7 +109,26 @@ Or you could develop with a local HTTP server [like `serve`](https://www.npmjs.c
109
110
**If you still have issues** please [report them](https://github.com/facebook/react/issues/new?labels=Component:%20Developer%20Tools). Don't forget to specify your OS, browser version, extension version, and the exact instructions to reproduce the issue with a screenshot.
111
112
-## Development
112
+## Local development
113
+The standalone DevTools app can be built and tested from source following the instructions below.
114
+
115
+### Prerequisite steps
116
+DevTools depends on local versions of several NPM packages<sup>1</sup> also in this workspace. You'll need to either build or download those packages first.
117
+
118
+<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API.
119
+
120
+#### Build from source
121
+To build dependencies from source, run the following command from the root of the repository:
122
+```sh
123
+yarn build-for-devtools
124
+```
125
+#### Download from CI
126
+To use the latest build from CI, run the following command from the root of the repository:
127
+```sh
128
+./scripts/release/download-experimental-build.js
129
+```
130
+### Build steps
131
+Once the above packages have been built or downloaded, you can test the standalone DevTools by running the following:
132
133
* Run `yarn start:backend` and `yarn start:standalone` in `../react-devtools-core`
134
* Run `yarn start` in this folder
scripts/release/download-experimental-build-commands/print-summary.js
new
+25
@@ -0,0 +1,25 @@
1
+#!/usr/bin/env node
2
+
3
+'use strict';
4
+
5
+const clear = require('clear');
6
+const {join, relative} = require('path');
7
+const theme = require('../theme');
8
+
9
+module.exports = ({build}) => {
10
+ const commandPath = relative(
11
+ process.env.PWD,
12
+ join(__dirname, '../download-experimental-build.js')
13
+ );
14
+
15
+ clear();
16
+
17
+ const message = theme`
18
+ {caution An experimental build has been downloaded!}
19
+
20
+ You can download this build again by running:
21
+ {path ${commandPath}} --build={build ${build}}
22
+ `;
23
+
24
+ console.log(message.replace(/\n +/g, '\n').trim());
25
+};
scripts/release/download-experimental-build.js
new
+33
@@ -0,0 +1,33 @@
1
+#!/usr/bin/env node
2
+
3
+'use strict';
4
+
5
+const {join} = require('path');
6
+const {getPublicPackages, handleError} = require('./utils');
7
+
8
+const checkEnvironmentVariables = require('./shared-commands/check-environment-variables');
9
+const downloadBuildArtifacts = require('./shared-commands/download-build-artifacts');
10
+const getLatestMasterBuildNumber = require('./shared-commands/get-latest-master-build-number');
11
+const parseParams = require('./shared-commands/parse-params');
12
+const printSummary = require('./download-experimental-build-commands/print-summary');
13
+
14
+const run = async () => {
15
+ try {
16
+ const params = parseParams();
17
+ params.cwd = join(__dirname, '..', '..');
18
+ params.packages = await getPublicPackages();
19
+
20
+ if (!params.build) {
21
+ params.build = await getLatestMasterBuildNumber(true);
22
+ }
23
+
24
+ await checkEnvironmentVariables(params);
25
+ await downloadBuildArtifacts(params);
26
+
27
+ printSummary(params);
28
+ } catch (error) {
29
+ handleError(error);
30
+ }
31
+};
32
+
33
+run();
scripts/release/prepare-canary.js
+5
-5
@@ -5,10 +5,10 @@
5
const {join} = require('path');
6
const {getPublicPackages, handleError} = require('./utils');
7
8
-const checkEnvironmentVariables = require('./prepare-canary-commands/check-environment-variables');
9
-const downloadBuildArtifacts = require('./prepare-canary-commands/download-build-artifacts');
10
-const getLatestMasterBuildNumber = require('./prepare-canary-commands/get-latest-master-build-number');
11
-const parseParams = require('./prepare-canary-commands/parse-params');
8
+const checkEnvironmentVariables = require('./shared-commands/check-environment-variables');
9
+const downloadBuildArtifacts = require('./shared-commands/download-build-artifacts');
10
+const getLatestMasterBuildNumber = require('./shared-commands/get-latest-master-build-number');
11
+const parseParams = require('./shared-commands/parse-params');
12
const printPrereleaseSummary = require('./shared-commands/print-prerelease-summary');
13
const testPackagingFixture = require('./shared-commands/test-packaging-fixture');
14
const testTracingFixture = require('./shared-commands/test-tracing-fixture');
@@ -20,7 +20,7 @@ const run = async () => {
20
params.packages = await getPublicPackages();
21
22
if (!params.build) {
23
- params.build = await getLatestMasterBuildNumber();
23
+ params.build = await getLatestMasterBuildNumber(false);
24
}
25
26
await checkEnvironmentVariables(params);
scripts/release/shared-commands/check-environment-variables.js
renamed
scripts/release/shared-commands/download-build-artifacts.js
renamed
scripts/release/shared-commands/get-latest-master-build-number.js
renamed
+6
-2
@@ -5,7 +5,11 @@
5
const http = require('request-promise-json');
6
const {logPromise} = require('../utils');
7
8
-const run = async () => {
8
+const run = async useExperimentalBuild => {
9
+ const targetJobName = useExperimentalBuild
10
+ ? 'process_artifacts_experimental'
11
+ : 'process_artifacts';
12
+
13
// https://circleci.com/docs/api/#recent-builds-for-a-project-branch
14
const metadataURL = `https://circleci.com/api/v1.1/project/github/facebook/react/tree/master`;
15
const metadata = await http.get(metadataURL, true);
@@ -13,7 +17,7 @@ const run = async () => {
17
entry =>
18
entry.branch === 'master' &&
19
entry.status === 'success' &&
16
- entry.workflows.job_name === 'process_artifacts'
20
+ entry.workflows.job_name === targetJobName
21
).build_num;
22
23
return build;