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

DevTools build script enhancements #17653

Merged
merged 5 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
},
"scripts": {
"build": "node ./scripts/rollup/build.js",
"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",
"linc": "node ./scripts/tasks/linc.js",
"lint": "node ./scripts/tasks/eslint.js",
"lint-build": "node ./scripts/rollup/validate/index.js",
Expand Down
22 changes: 16 additions & 6 deletions packages/react-devtools-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ The easiest way to install this extension is as a browser add-on:
* [Chrome web store](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
* [Firefox Add-ons](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/)

## Development

## Local development
You can also build and install this extension from source.

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:
### Prerequisite steps
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.

<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API.

#### Build from source
To build dependencies from source, run the following command from the root of the repository:
```sh
yarn build -- react,react-dom,react-is,scheduler --type=NODE
yarn build-for-devtools
```

Once the above packages have been built, you can build the extension by running:
#### Download from CI
To use the latest build from CI, run the following command from the root of the repository:
Copy link
Contributor

Choose a reason for hiding this comment

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

It’s not clear that this is an alternative to the previous step.

Copy link
Contributor Author

@bvaughn bvaughn Dec 18, 2019

Choose a reason for hiding this comment

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

Why not? They're subheaders under the same header which says,

You'll need to either build or download those packages first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could make the header size smaller maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a problem with just having one of them? Like, downloading from CI could be the suggested option, and you have a postscript that mentions that’s you can also build from source if needed.

I’m thinking from perspective of someone following instructions to build the extension, who doesn’t understand what these deps are, or what context they provide. If I had to quickly make a build and followed these instructions, I might have done both steps. Ofc this is just a nit, so feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's not sufficient.

We probably want to build from source, so we can test both DevTools and React changes.

External contributors (or Mozilla reviewers) probably want to download a CI build because it's faster and their purpose is not to test React.

```sh
./scripts/release/download-experimental-build.js
```
### Build steps
Once the above packages have been built or downloaded, you can build the extension by running:
```sh
cd packages/react-devtools-extensions/

Expand Down
25 changes: 22 additions & 3 deletions packages/react-devtools-inline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,28 @@ iframe.onload = () => {
};
```

## Development
## Local development
You can also build and test this package from source.

Watch for changes made to the source code and rebuild:
### Prerequisite steps
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.

<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API.

#### Build from source
To build dependencies from source, run the following command from the root of the repository:
```sh
yarn build-for-devtools
```
#### Download from CI
To use the latest build from CI, run the following command from the root of the repository:
```sh
./scripts/release/download-experimental-build.js
```
### Build steps
Once the above packages have been built or downloaded, you can watch for changes made to the source code and automatically rebuild by running:
```sh
yarn start
```
```

To test package changes, refer to the [`react-devtools-shell` README](https://github.com/facebook/react/blob/master/packages/react-devtools-shell/README.md).
9 changes: 2 additions & 7 deletions packages/react-devtools-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ Harness for testing local changes to the `react-devtools-inline` and `react-devt

## Development

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:
```sh
cd packages/react-devtools-inline

yarn start
```
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).

Next, watch for changes to the test harness:
The test harness can then be run as follows:
```sh
cd packages/react-devtools-shell

Expand Down
21 changes: 20 additions & 1 deletion packages/react-devtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,26 @@ Or you could develop with a local HTTP server [like `serve`](https://www.npmjs.c

**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.

## Development
## Local development
The standalone DevTools app can be built and tested from source following the instructions below.

### Prerequisite steps
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.

<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API.

#### Build from source
To build dependencies from source, run the following command from the root of the repository:
```sh
yarn build-for-devtools
```
#### Download from CI
To use the latest build from CI, run the following command from the root of the repository:
```sh
./scripts/release/download-experimental-build.js
```
### Build steps
Once the above packages have been built or downloaded, you can test the standalone DevTools by running the following:

* Run `yarn start:backend` and `yarn start:standalone` in `../react-devtools-core`
* Run `yarn start` in this folder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node

'use strict';

const clear = require('clear');
const {join, relative} = require('path');
const theme = require('../theme');

module.exports = ({build}) => {
const commandPath = relative(
process.env.PWD,
join(__dirname, '../download-experimental-build.js')
);

clear();

const message = theme`
{caution An experimental build has been downloaded!}

You can download this build again by running:
{path ${commandPath}} --build={build ${build}}
`;

console.log(message.replace(/\n +/g, '\n').trim());
};
33 changes: 33 additions & 0 deletions scripts/release/download-experimental-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env node

'use strict';

const {join} = require('path');
const {getPublicPackages, handleError} = require('./utils');

const checkEnvironmentVariables = require('./shared-commands/check-environment-variables');
const downloadBuildArtifacts = require('./shared-commands/download-build-artifacts');
const getLatestMasterBuildNumber = require('./shared-commands/get-latest-master-build-number');
const parseParams = require('./shared-commands/parse-params');
const printSummary = require('./download-experimental-build-commands/print-summary');

const run = async () => {
try {
const params = parseParams();
params.cwd = join(__dirname, '..', '..');
params.packages = await getPublicPackages();

if (!params.build) {
params.build = await getLatestMasterBuildNumber(true);
}

await checkEnvironmentVariables(params);
await downloadBuildArtifacts(params);

printSummary(params);
} catch (error) {
handleError(error);
}
};

run();
10 changes: 5 additions & 5 deletions scripts/release/prepare-canary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
const {join} = require('path');
const {getPublicPackages, handleError} = require('./utils');

const checkEnvironmentVariables = require('./prepare-canary-commands/check-environment-variables');
const downloadBuildArtifacts = require('./prepare-canary-commands/download-build-artifacts');
const getLatestMasterBuildNumber = require('./prepare-canary-commands/get-latest-master-build-number');
const parseParams = require('./prepare-canary-commands/parse-params');
const checkEnvironmentVariables = require('./shared-commands/check-environment-variables');
const downloadBuildArtifacts = require('./shared-commands/download-build-artifacts');
const getLatestMasterBuildNumber = require('./shared-commands/get-latest-master-build-number');
const parseParams = require('./shared-commands/parse-params');
const printPrereleaseSummary = require('./shared-commands/print-prerelease-summary');
const testPackagingFixture = require('./shared-commands/test-packaging-fixture');
const testTracingFixture = require('./shared-commands/test-tracing-fixture');
Expand All @@ -20,7 +20,7 @@ const run = async () => {
params.packages = await getPublicPackages();

if (!params.build) {
params.build = await getLatestMasterBuildNumber();
params.build = await getLatestMasterBuildNumber(false);
}

await checkEnvironmentVariables(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
const http = require('request-promise-json');
const {logPromise} = require('../utils');

const run = async () => {
const run = async useExperimentalBuild => {
const targetJobName = useExperimentalBuild
? 'process_artifacts_experimental'
: 'process_artifacts';

// https://circleci.com/docs/api/#recent-builds-for-a-project-branch
const metadataURL = `https://circleci.com/api/v1.1/project/github/facebook/react/tree/master`;
const metadata = await http.get(metadataURL, true);
const build = metadata.find(
entry =>
entry.branch === 'master' &&
entry.status === 'success' &&
entry.workflows.job_name === 'process_artifacts'
entry.workflows.job_name === targetJobName
).build_num;

return build;
Expand Down