Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit 1a27e6a

Browse files
authored
Merge pull request #277 from wmonk/react-scripts-1.1.1
Merge react scripts 1.1.1
2 parents 244650d + 00e385e commit 1a27e6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+784
-206
lines changed

Diff for: .yarnrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--install.no-lockfile true
2+
--install.check-files true
3+
--add.no-lockfile true

Diff for: CODE_OF_CONDUCT.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Code of Conduct
2+
3+
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.

Diff for: CONTRIBUTING.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,40 @@ All functionality must be retained (and configuration given to the user) if they
7575

7676
1. Clone the repo with `git clone https://github.com/facebookincubator/create-react-app`
7777

78-
2. Run `npm install` in the root `create-react-app` folder.
78+
2. Run `yarn` in the root `create-react-app` folder.
7979

80-
Once it is done, you can modify any file locally and run `npm start`, `npm test` or `npm run build` just like in a generated project.
80+
Once it is done, you can modify any file locally and run `yarn start`, `yarn test` or `yarn build` just like in a generated project.
8181

8282
If you want to try out the end-to-end flow with the global CLI, you can do this too:
8383

8484
```
85-
npm run create-react-app my-app
85+
yarn create-react-app my-app
8686
cd my-app
8787
```
8888

89-
and then run `npm start` or `npm run build`.
90-
91-
*Note: if you are using yarn, we suggest that you use `yarn install --no-lockfile` instead of the bare `yarn` or `yarn install` because we [intentionally](https://github.com/facebookincubator/create-react-app/pull/2014#issuecomment-300811661) do not ignore or add yarn.lock to our repo.*
89+
and then run `yarn start` or `yarn build`.
9290

9391
## Contributing to E2E (end to end) tests
9492

9593
**TL;DR** use the command `yarn e2e:docker` to run unit and e2e tests.
9694

9795
More detailed information are in the dedicated [README](/packages/react-scripts/fixtures/kitchensink/README.md).
9896

97+
## Tips for contributors using Windows
98+
99+
The scripts in tasks folder and other scripts in `package.json` will not work in Windows out of the box. However, using [Bash on windows](https://msdn.microsoft.com/en-us/commandline/wsl/about) makes it easier to use those scripts without any workarounds. The steps to do so are detailed below:
100+
101+
### Install Bash on Ubuntu on Windows
102+
103+
A good step by step guide can be found [here](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/)
104+
105+
### Install Node.js and yarn
106+
Even if you have node and yarn installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via [`nvm`](https://github.com/creationix/nvm#install-script) is recommended.
107+
108+
### Line endings
109+
110+
By default git would use `CRLF` line endings which would cause the scripts to fail. You can change it for this repo only by setting `autocrlf` to false by running `git config core.autocrlf false`. You can also enable it for all your repos by using the `--global` flag if you wish to do so.
111+
99112
## Cutting a Release
100113

101114
1. Tag all merged pull requests that go into the release with the relevant milestone. Each merged PR should also be labeled with one of the [labels](https://github.com/facebookincubator/create-react-app/labels) named `tag: ...` to indicate what kind of change it is.
@@ -104,11 +117,11 @@ More detailed information are in the dedicated [README](/packages/react-scripts/
104117
4. Note that files in `packages/create-react-app` should be modified with extreme caution. Since it’s a global CLI, any version of `create-react-app` (global CLI) including very old ones should work with the latest version of `react-scripts`.
105118
5. Create a change log entry for the release:
106119
* You'll need an [access token for the GitHub API](https://help.github.com/articles/creating-an-access-token-for-command-line-use/). Save it to this environment variable: `export GITHUB_AUTH="..."`
107-
* Run `npm run changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
120+
* Run `yarn changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
108121
* Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code.
109122
* Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped.
110123
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
111-
7. **Do not run `npm publish`. Instead, run `npm run publish`.**
124+
7. Run `npm run publish`. (It has to be `npm run publish` exactly, not just `npm publish` or `yarn publish`.)
112125
8. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages.
113126
9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.
114127

Diff for: appveyor.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ platform:
2828
- x64
2929

3030
install:
31-
# TODO: Remove after https://github.com/appveyor/ci/issues/1426 is fixed
32-
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%
3331
- ps: Install-Product node $env:nodejs_version $env:platform
3432

3533
build: off
@@ -41,4 +39,4 @@ skip_commits:
4139
test_script:
4240
- node --version
4341
- npm --version
44-
- sh tasks/e2e-%test_suite%.sh
42+
- bash tasks/e2e-%test_suite%.sh

Diff for: lerna.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"lerna": "2.0.0",
2+
"lerna": "2.6.0",
3+
"npmClient": "yarn",
4+
"useWorkspaces": true,
35
"version": "independent",
46
"changelog": {
57
"repo": "facebookincubator/create-react-app",
@@ -12,8 +14,5 @@
1214
"tag: internal": ":house: Internal"
1315
},
1416
"cacheDir": ".changelog"
15-
},
16-
"packages": [
17-
"packages/*"
18-
]
17+
}
1918
}

Diff for: packages/babel-preset-react-app/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ If you want to use this Babel preset in a project not built with Create React Ap
1616

1717
First, [install Babel](https://babeljs.io/docs/setup/).
1818

19+
Then install babel-preset-react-app.
20+
21+
```sh
22+
npm install babel-preset-react-app --save-dev
23+
```
24+
1925
Then create a file named `.babelrc` with following contents in the root folder of your project:
2026

2127
```js

Diff for: packages/babel-preset-react-app/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
'use strict';
88

99
const plugins = [
10+
// Necessary to include regardless of the environment because
11+
// in practice some other transforms (such as object-rest-spread)
12+
// don't work without it: https://github.com/babel/babel/issues/7215
13+
require.resolve('babel-plugin-transform-es2015-destructuring'),
1014
// class { handleClick = () => { } }
1115
require.resolve('babel-plugin-transform-class-properties'),
1216
// The following two plugins use Object.assign directly, instead of Babel's

Diff for: packages/babel-preset-react-app/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "babel-preset-react-app",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "Babel preset used by Create React App",
55
"repository": "facebookincubator/create-react-app",
66
"license": "MIT",
@@ -14,6 +14,7 @@
1414
"babel-plugin-dynamic-import-node": "1.1.0",
1515
"babel-plugin-syntax-dynamic-import": "6.18.0",
1616
"babel-plugin-transform-class-properties": "6.24.1",
17+
"babel-plugin-transform-es2015-destructuring": "6.23.0",
1718
"babel-plugin-transform-object-rest-spread": "6.26.0",
1819
"babel-plugin-transform-react-constant-elements": "6.23.0",
1920
"babel-plugin-transform-react-jsx": "6.24.1",

Diff for: packages/create-react-app/createReactApp.js

+56-8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const tmp = require('tmp');
4747
const unpack = require('tar-pack').unpack;
4848
const url = require('url');
4949
const hyperquest = require('hyperquest');
50+
const envinfo = require('envinfo');
5051

5152
const packageJson = require('./package.json');
5253

@@ -60,10 +61,12 @@ const program = new commander.Command(packageJson.name)
6061
projectName = name;
6162
})
6263
.option('--verbose', 'print additional logs')
64+
.option('--info', 'print environment debug info')
6365
.option(
6466
'--scripts-version <alternative-package>',
6567
'use a non-standard version of react-scripts'
6668
)
69+
.option('--use-npm')
6770
.allowUnknownOption()
6871
.on('--help', () => {
6972
console.log(` Only ${chalk.green('<project-directory>')} is required.`);
@@ -78,6 +81,11 @@ const program = new commander.Command(packageJson.name)
7881
console.log(
7982
` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}`
8083
);
84+
console.log(
85+
` - a .tar.gz archive: ${chalk.green(
86+
'https://mysite.com/my-react-scripts-0.8.2.tar.gz'
87+
)}`
88+
);
8189
console.log(
8290
` It is not needed unless you specifically want to use a fork.`
8391
);
@@ -93,6 +101,14 @@ const program = new commander.Command(packageJson.name)
93101
.parse(process.argv);
94102

95103
if (typeof projectName === 'undefined') {
104+
if (program.info) {
105+
envinfo.print({
106+
packages: ['react', 'react-dom', 'react-scripts'],
107+
noNativeIDE: true,
108+
duplicates: true,
109+
});
110+
process.exit(0);
111+
}
96112
console.error('Please specify the project directory:');
97113
console.log(
98114
` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`
@@ -127,10 +143,11 @@ createApp(
127143
projectName,
128144
program.verbose,
129145
program.scriptsVersion,
146+
program.useNpm,
130147
hiddenProgram.internalTestingTemplate
131148
);
132149

133-
function createApp(name, verbose, version, template) {
150+
function createApp(name, verbose, version, useNpm, template) {
134151
const root = path.resolve(name);
135152
const appName = path.basename(root);
136153

@@ -153,7 +170,7 @@ function createApp(name, verbose, version, template) {
153170
JSON.stringify(packageJson, null, 2)
154171
);
155172

156-
const useYarn = shouldUseYarn();
173+
const useYarn = useNpm ? false : shouldUseYarn();
157174
const originalDirectory = process.cwd();
158175
process.chdir(root);
159176
if (!useYarn && !checkThatNpmCanReadCwd()) {
@@ -260,7 +277,7 @@ function run(
260277
template,
261278
useYarn
262279
) {
263-
const packageToInstall = getInstallPackage(version);
280+
const packageToInstall = getInstallPackage(version, originalDirectory);
264281
const allDependencies = ['react', 'react-dom', packageToInstall];
265282

266283
console.log('Installing packages. This might take a couple of minutes.');
@@ -351,11 +368,16 @@ function run(
351368
});
352369
}
353370

354-
function getInstallPackage(version) {
371+
function getInstallPackage(version, originalDirectory) {
355372
let packageToInstall = 'react-scripts';
356373
const validSemver = semver.valid(version);
357374
if (validSemver) {
358375
packageToInstall += `@${validSemver}`;
376+
} else if (version && version.match(/^file:/)) {
377+
packageToInstall = `file:${path.resolve(
378+
originalDirectory,
379+
version.match(/^file:(.*)?$/)[1]
380+
)}`;
359381
} else if (version) {
360382
// for tar.gz or alternative paths
361383
packageToInstall = version;
@@ -403,7 +425,7 @@ function extractStream(stream, dest) {
403425

404426
// Extract package name from tarball url or path.
405427
function getPackageName(installPackage) {
406-
if (installPackage.indexOf('.tgz') > -1) {
428+
if (installPackage.match(/^.+\.(tgz|tar\.gz)$/)) {
407429
return getTemporaryDirectory()
408430
.then(obj => {
409431
let stream;
@@ -426,7 +448,7 @@ function getPackageName(installPackage) {
426448
`Could not extract the package name from the archive: ${err.message}`
427449
);
428450
const assumedProjectName = installPackage.match(
429-
/^.+\/(.+?)(?:-\d+.+)?\.tgz$/
451+
/^.+\/(.+?)(?:-\d+.+)?\.(tgz|tar\.gz)$/
430452
)[1];
431453
console.log(
432454
`Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"`
@@ -443,6 +465,10 @@ function getPackageName(installPackage) {
443465
return Promise.resolve(
444466
installPackage.charAt(0) + installPackage.substr(1).split('@')[0]
445467
);
468+
} else if (installPackage.match(/^file:/)) {
469+
const installPackagePath = installPackage.match(/^file:(.*)?$/)[1];
470+
const installPackageJson = require(path.join(installPackagePath, 'package.json'));
471+
return Promise.resolve(installPackageJson.name);
446472
}
447473
return Promise.resolve(installPackage);
448474
}
@@ -571,6 +597,12 @@ function isSafeToCreateProjectIn(root, name) {
571597
'.hg',
572598
'.hgignore',
573599
'.hgcheck',
600+
'.npmignore',
601+
'mkdocs.yml',
602+
'docs',
603+
'.travis.yml',
604+
'.gitlab-ci.yml',
605+
'.gitattributes',
574606
];
575607
console.log();
576608

@@ -596,6 +628,21 @@ function isSafeToCreateProjectIn(root, name) {
596628
return false;
597629
}
598630

631+
function getProxy() {
632+
if (process.env.https_proxy) {
633+
return process.env.https_proxy;
634+
} else {
635+
try {
636+
// Trying to read https-proxy from .npmrc
637+
let httpsProxy = execSync('npm config get https-proxy')
638+
.toString()
639+
.trim();
640+
return httpsProxy !== 'null' ? httpsProxy : undefined;
641+
} catch (e) {
642+
return;
643+
}
644+
}
645+
}
599646
function checkThatNpmCanReadCwd() {
600647
const cwd = process.cwd();
601648
let childOutput = null;
@@ -660,10 +707,11 @@ function checkIfOnline(useYarn) {
660707

661708
return new Promise(resolve => {
662709
dns.lookup('registry.yarnpkg.com', err => {
663-
if (err != null && process.env.https_proxy) {
710+
let proxy;
711+
if (err != null && (proxy = getProxy())) {
664712
// If a proxy is defined, we likely can't resolve external hostnames.
665713
// Try to resolve the proxy name as an indication of a connection.
666-
dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => {
714+
dns.lookup(url.parse(proxy).hostname, proxyErr => {
667715
resolve(proxyErr == null);
668716
});
669717
} else {

Diff for: packages/create-react-app/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-react-app",
3-
"version": "1.4.3",
3+
"version": "1.5.2",
44
"keywords": [
55
"react"
66
],
@@ -24,6 +24,7 @@
2424
"chalk": "^1.1.1",
2525
"commander": "^2.9.0",
2626
"cross-spawn": "^4.0.0",
27+
"envinfo": "3.4.2",
2728
"fs-extra": "^1.0.0",
2829
"hyperquest": "^2.1.2",
2930
"semver": "^5.0.3",

Diff for: packages/eslint-config-react-app/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen
4545
- [aria-role](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md)
4646
- [aria-unsupported-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md)
4747
- [heading-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md)
48-
- [href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md)
48+
- [href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/v5.1.1/docs/rules/href-no-hash.md)
4949
- [iframe-has-title](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md)
5050
- [img-redundant-alt](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md)
5151
- [no-access-key](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md)

Diff for: packages/eslint-config-react-app/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = {
116116
'new-parens': 'warn',
117117
'no-array-constructor': 'warn',
118118
'no-caller': 'warn',
119-
'no-cond-assign': ['warn', 'always'],
119+
'no-cond-assign': ['warn', 'except-parens'],
120120
'no-const-assign': 'warn',
121121
'no-control-regex': 'warn',
122122
'no-delete-var': 'warn',

Diff for: packages/eslint-config-react-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-react-app",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "ESLint configuration used by Create React App",
55
"repository": "facebookincubator/create-react-app",
66
"license": "MIT",

0 commit comments

Comments
 (0)