diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index dc25d841a..d09f2d1b4 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -79,11 +79,10 @@ Please fill in all the relevant fields by running these commands in terminal. --> -1. `npm ls react-scripts-ts` (if you haven’t ejected): -2. `node -v`: -3. `npm -v`: -4. `yarn --version` (if you use Yarn): -5. `npm ls react-scripts-ts` (if you haven’t ejected): +1. `node -v`: +2. `npm -v`: +3. `yarn --version` (if you use Yarn): +4. `npm ls react-scripts-ts` (if you haven’t ejected): Then, specify: diff --git a/.travis.yml b/.travis.yml index 167fc436b..0ca362c23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,12 +16,19 @@ cache: install: true script: - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi' + - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi' + - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi' env: global: - USE_YARN=no matrix: - TEST_SUITE=simple - - TEST_SUITE=install + - TEST_SUITE=installs + - TEST_SUITE=kitchensink +matrix: + include: + - node_js: 0.10 + env: TEST_SUITE=simple # There's a weird Yarn/Lerna bug related to prerelease versions. # TODO: reenable after we ship 1.0. # - node_js: 6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a77c54b2..f233de0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,270 @@ +## 1.0.17 (November 3, 2017) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#3401](https://github.com/facebookincubator/create-react-app/pull/3401) Stop using a deprecated option. ([@gaearon](https://github.com/gaearon)) + +#### :memo: Documentation + +* `react-scripts` + + * [#3399](https://github.com/facebookincubator/create-react-app/pull/3399) Add link to VS Code troubleshooting guide. ([@auchenberg](https://github.com/auchenberg)) + * [#3400](https://github.com/facebookincubator/create-react-app/pull/3400) Update VS Code debug configuration. ([@auchenberg](https://github.com/auchenberg)) + +#### Committers: 3 + +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Kenneth Auchenberg ([auchenberg](https://github.com/auchenberg)) +- Loren Sands-Ramshaw ([lorensr](https://github.com/lorensr)) + +### Migrating from 1.0.16 to 1.0.17 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.17 +``` + +or + +``` +yarn add --exact react-scripts@1.0.17 +``` + +## 1.0.16 (October 31, 2017) 🎃 + +#### :bug: Bug Fix + +* `react-scripts` + + * [#3374](https://github.com/facebookincubator/create-react-app/pull/3374) Set correct image type and sizes in `manifest.json`. ([@piotr-cz](https://github.com/piotr-cz)) + +* `react-dev-utils` + + * [#3368](https://github.com/facebookincubator/create-react-app/pull/3368) Fix a crash in development mode in older browsers. ([@felthy](https://github.com/felthy)) + +#### Committers: 2 + +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Piotr ([piotr-cz](https://github.com/piotr-cz)) + +### Migrating from 1.0.15 to 1.0.16 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.16 +``` + +or + +``` +yarn add --exact react-scripts@1.0.16 +``` + +## 1.0.15 (October 30, 2017) + +#### :bug: Bug Fix + +* `react-scripts` + + * [#3287](https://github.com/facebookincubator/create-react-app/pull/3287) Fix favicon sizes value in the project manifest. ([@ryansully](https://github.com/ryansully)) + +* `react-dev-utils`, `react-scripts` + + * [#3230](https://github.com/facebookincubator/create-react-app/pull/3230) Fix watching for changes in `src/node_modules`. ([@xjlim](https://github.com/xjlim)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#3239](https://github.com/facebookincubator/create-react-app/pull/3239) Allow importing `.mjs` files. ([@Timer](https://github.com/Timer)) + * [#3340](https://github.com/facebookincubator/create-react-app/pull/3340) Polyfill `requestAnimationFrame` in test environment. ([@gaearon](https://github.com/gaearon)) + +* `babel-preset-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts` + + * [#3342](https://github.com/facebookincubator/create-react-app/pull/3342) Bump dependencies. ([@gaearon](https://github.com/gaearon)) + +* `react-dev-utils`, `react-error-overlay` + + * [#3100](https://github.com/facebookincubator/create-react-app/pull/3100) Add click-to-open support for build errors. ([@tharakawj](https://github.com/tharakawj)) + +* `create-react-app` + + * [#3355](https://github.com/facebookincubator/create-react-app/pull/3355) Add preflight CWD check for npm to detect bad Windows setups. ([@gaearon](https://github.com/gaearon)) + +#### :memo: Documentation + +* User Guide + + * [#2957](https://github.com/facebookincubator/create-react-app/pull/2957) Use `npm-run-all` to build Sass and JS. ([@shime](https://github.com/shime)) + * [#3108](https://github.com/facebookincubator/create-react-app/pull/3108) Update the Service Worker opt-out documentation. ([@captDaylight](https://github.com/captDaylight)) + * [#3286](https://github.com/facebookincubator/create-react-app/pull/3286) Add documentation for Enzyme 3 integration. ([@ryansully](https://github.com/ryansully)) + * [#3328](https://github.com/facebookincubator/create-react-app/pull/3328) Recommend react-snap as an alternative to react-snapshot. ([@aaronshaf](https://github.com/aaronshaf)) + * [#3279](https://github.com/facebookincubator/create-react-app/pull/3279) Add jest coverage configuration docs. ([@mattphillips](https://github.com/mattphillips)) + * [#3303](https://github.com/facebookincubator/create-react-app/pull/3303) Update link to Jest Expect docs. ([@jbranchaud](https://github.com/jbranchaud)) + * [#3289](https://github.com/facebookincubator/create-react-app/pull/3289) Fix dead link to Jest "expect" docs. ([@alexkrolick](https://github.com/alexkrolick)) + * [#3265](https://github.com/facebookincubator/create-react-app/pull/3265) Add external links to deployment services. ([@aericson](https://github.com/aericson)) + * [#3075](https://github.com/facebookincubator/create-react-app/pull/3075) Minor docs change to highlight dev proxy behaviour. ([@davidjb](https://github.com/davidjb)) + * [#3185](https://github.com/facebookincubator/create-react-app/pull/3185) Correct manual proxy documentation. ([@robertpanzer](https://github.com/robertpanzer)) + +* README + + * [#3227](https://github.com/facebookincubator/create-react-app/pull/3227) Fix package management link in README for issue #3218. ([@nishina555](https://github.com/nishina555)) + * [#3211](https://github.com/facebookincubator/create-react-app/pull/3211) Improve grammar in README. ([@Mohamed3on](https://github.com/Mohamed3on)) + +#### :house: Internal + +* Other + + * [#3345](https://github.com/facebookincubator/create-react-app/pull/3345) Stop using `npm link` in tests. ([@Timer](https://github.com/Timer)) + +* `react-error-overlay` + + * [#3122](https://github.com/facebookincubator/create-react-app/pull/3122) Fix for add .gitattributes file #3080. ([@ijajmulani](https://github.com/ijajmulani)) + * [#3267](https://github.com/facebookincubator/create-react-app/pull/3267) Use production React version for bundled overlay. ([@Timer](https://github.com/Timer)) + * [#3264](https://github.com/facebookincubator/create-react-app/pull/3264) Add warning when using `react-error-overlay` in production. ([@Timer](https://github.com/Timer)) + * [#3263](https://github.com/facebookincubator/create-react-app/pull/3263) `react-error-overlay` has no dependencies now (it's bundled). ([@Timer](https://github.com/Timer)) + * [#3142](https://github.com/facebookincubator/create-react-app/pull/3142) Make error overlay run in the context of the iframe. ([@tharakawj](https://github.com/tharakawj)) + +* `react-scripts` + + * [#3150](https://github.com/facebookincubator/create-react-app/pull/3150) Remove an useless negation in `registerServiceWorker.js`. ([@dunglas](https://github.com/dunglas)) + * [#3158](https://github.com/facebookincubator/create-react-app/pull/3158) Remove `output.path` from dev webpack config. ([@nikolas](https://github.com/nikolas)) + * [#3281](https://github.com/facebookincubator/create-react-app/pull/3281) Add a workaround for Uglify incompatiblity with Safari 10.0 in the future. ([@satyavh](https://github.com/satyavh)) + * [#3146](https://github.com/facebookincubator/create-react-app/pull/3146) Fix `reason-react` support. ([@lpalmes](https://github.com/lpalmes)) + * [#3236](https://github.com/facebookincubator/create-react-app/pull/3236) Update `style-loader` and disable inclusion of its HMR code in builds. ([@insin](https://github.com/insin)) + * [#3246](https://github.com/facebookincubator/create-react-app/pull/3246) Update `url-loader` to 0.6.2 for mime ReDoS vulnerability. ([@d3viant0ne](https://github.com/d3viant0ne)) + * [#2914](https://github.com/facebookincubator/create-react-app/pull/2914) `` -> ``. ([@Hurtak](https://github.com/Hurtak)) + +#### Committers: 24 + +- Aaron Shafovaloff ([aaronshaf](https://github.com/aaronshaf)) +- Alex ([alexkrolick](https://github.com/alexkrolick)) +- André Ericson ([aericson](https://github.com/aericson)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- David Beitey ([davidjb](https://github.com/davidjb)) +- Hrvoje Šimić ([shime](https://github.com/shime)) +- IJAJ MULANI ([ijajmulani](https://github.com/ijajmulani)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Joe Lim ([xjlim](https://github.com/xjlim)) +- Jonny Buchanan ([insin](https://github.com/insin)) +- Josh Branchaud ([jbranchaud](https://github.com/jbranchaud)) +- Joshua Wiens ([d3viant0ne](https://github.com/d3viant0ne)) +- Kévin Dunglas ([dunglas](https://github.com/dunglas)) +- Lorenzo Palmes ([lpalmes](https://github.com/lpalmes)) +- Matt Phillips ([mattphillips](https://github.com/mattphillips)) +- Mohamed Oun ([Mohamed3on](https://github.com/Mohamed3on)) +- Nik Nyby ([nikolas](https://github.com/nikolas)) +- Petr Huřťák ([Hurtak](https://github.com/Hurtak)) +- Robert Panzer ([robertpanzer](https://github.com/robertpanzer)) +- Ryan Sullivan ([ryansully](https://github.com/ryansully)) +- Satya van Heummen ([satyavh](https://github.com/satyavh)) +- Tharaka Wijebandara ([tharakawj](https://github.com/tharakawj)) +- Toshiharu Nishina ([nishina555](https://github.com/nishina555)) +- [captDaylight](https://github.com/captDaylight) + +### Migrating from 1.0.14 to 1.0.15 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.15 +``` + +or + +``` +yarn add --exact react-scripts@1.0.15 +``` + +## 1.0.14 (September 26, 2017) + +#### :bug: Bug Fix + +* `react-dev-utils` + + * [#3098](https://github.com/facebookincubator/create-react-app/pull/3098) Always reload the page on next compile after a runtime error. ([@Timer](https://github.com/Timer)) + +* `react-error-overlay` + + * [#3079](https://github.com/facebookincubator/create-react-app/pull/3079) Fix code context on Windows. ([@Timer](https://github.com/Timer)) + +#### :nail_care: Enhancement + +* `react-dev-utils` + + * [#3077](https://github.com/facebookincubator/create-react-app/pull/3077) Auto-detect running editor on Linux for error overlay. ([@gulderov](https://github.com/gulderov)) + + * [#3131](https://github.com/facebookincubator/create-react-app/pull/3131) Display process pid in already running message. ([@Pajn](https://github.com/Pajn)) + +#### :memo: Documentation + +* Other + + * [#3163](https://github.com/facebookincubator/create-react-app/pull/3163) Add link to active CSS modules discussion. ([@NeekSandhu](https://github.com/NeekSandhu)) + +* `react-scripts` + + * [#2908](https://github.com/facebookincubator/create-react-app/pull/2908) Note that class fields have progressed to stage 3. ([@rickbeerendonk](https://github.com/rickbeerendonk)) + + * [#3160](https://github.com/facebookincubator/create-react-app/pull/3160) Update unclear wording in webpack configuration (file loader section). ([@kristiehoward](https://github.com/kristiehoward)) + +* `eslint-config-react-app` + + * [#3072](https://github.com/facebookincubator/create-react-app/pull/3072) Update eslint versions for install instructions. ([@jdcrensh](https://github.com/jdcrensh)) + +#### :house: Internal + +* `react-scripts` + + * [#3157](https://github.com/facebookincubator/create-react-app/pull/3157) Update `webpack-dev-server` to `2.8.2`. ([@nikolas](https://github.com/nikolas)) + + * [#2989](https://github.com/facebookincubator/create-react-app/pull/2989) Update install template to match accessibility guidelines. ([@davidleger95](https://github.com/davidleger95)) + +* `react-error-overlay` + + * [#3065](https://github.com/facebookincubator/create-react-app/pull/3065) Updated `react-error-overlay` to latest Flow (`0.54.0`). ([@duvet86](https://github.com/duvet86)) + + * [#3102](https://github.com/facebookincubator/create-react-app/pull/3102) Clean target directory before compiling overlay. ([@Timer](https://github.com/Timer)) + +* `create-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts` + + * [#3058](https://github.com/facebookincubator/create-react-app/pull/3058) Re-run prettier for all files and pin the version. ([@viankakrisna](https://github.com/viankakrisna)) + + * [#3107](https://github.com/facebookincubator/create-react-app/pull/3107) Run CI on `npm@^4`. ([@viankakrisna](https://github.com/viankakrisna)) + +#### Committers: 12 + +- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna)) +- David Leger ([davidleger95](https://github.com/davidleger95)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Jon Crenshaw ([jdcrensh](https://github.com/jdcrensh)) +- Kristie Howard ([kristiehoward](https://github.com/kristiehoward)) +- Luca ([duvet86](https://github.com/duvet86)) +- Neek Sandhu ([NeekSandhu](https://github.com/NeekSandhu)) +- Nik Nyby ([nikolas](https://github.com/nikolas)) +- Rasmus Eneman ([Pajn](https://github.com/Pajn)) +- Rick Beerendonk ([rickbeerendonk](https://github.com/rickbeerendonk)) +- Sophie Alpert ([sophiebits](https://github.com/sophiebits)) +- [gulderov](https://github.com/gulderov) + +### Migrating from 1.0.13 to 1.0.14 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.14 +``` + +or + +``` +yarn add --exact react-scripts@1.0.14 +``` + ## 1.0.13 (September 2, 2017) #### :bug: Bug Fix diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68a9c4e09..86b392f2f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,9 +108,9 @@ More detailed information are in the dedicated [README](/packages/react-scripts/ * 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. * 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. 6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them. -7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration. -8. **Do not run `npm publish`. Instead, run `npm run publish`.** -9. 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. +7. **Do not run `npm publish`. Instead, run `npm run publish`.** +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. +9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration. Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- --tag next` instead of `npm run publish`. diff --git a/LICENSE b/LICENSE index a6b451216..188fb2b0b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,30 +1,21 @@ -BSD License +MIT License -For create-react-app software +Copyright (c) 2013-present, Facebook, Inc. -Copyright (c) 2016-present, Facebook, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name Facebook nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index fddffcbdd..304935a20 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,9 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog +### 2.9.0 (unpublished) +* Merge latest facebook/create-react-app - @bootstraponline + ### 2.8.0 * Update typescript to 2.5.3 - @nicolaserny diff --git a/appveyor.cleanup-cache.txt b/appveyor.cleanup-cache.txt index 19d0b989b..ea6d1b9c0 100644 --- a/appveyor.cleanup-cache.txt +++ b/appveyor.cleanup-cache.txt @@ -3,3 +3,4 @@ http://help.appveyor.com/discussions/questions/1310-delete-cache ---- Just testing if this works. +lalala. diff --git a/appveyor.yml b/appveyor.yml index e00da3943..5d957aa7e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,11 +2,11 @@ image: Visual Studio 2017 environment: matrix: - - nodejs_version: 7 + - nodejs_version: 8 test_suite: "simple" - - nodejs_version: 7 + - nodejs_version: 8 test_suite: "installs" - - nodejs_version: 7 + - nodejs_version: 8 test_suite: "kitchensink" - nodejs_version: 6 test_suite: "simple" @@ -28,8 +28,6 @@ platform: - x64 install: - # TODO: Remove after https://github.com/appveyor/ci/issues/1426 is fixed - - set PATH=C:\Program Files\Git\mingw64\bin;%PATH% - ps: Install-Product node $env:nodejs_version $env:platform build: off @@ -41,4 +39,4 @@ skip_commits: test_script: - node --version - npm --version - - sh tasks/e2e-%test_suite%.sh + - bash tasks/e2e-%test_suite%.sh diff --git a/package.json b/package.json index 4beaa5f8c..d623871ff 100644 --- a/package.json +++ b/package.json @@ -14,16 +14,16 @@ "precommit": "lint-staged" }, "devDependencies": { - "@types/jest": "^20.0.4", - "@types/node": "^7.0.21", - "@types/react": "^15.6.1", - "@types/react-dom": "^15.5.0", + "@types/jest": "^21.1.5", + "@types/node": "^8.0.47", + "@types/react": "^16.0.20", + "@types/react-dom": "^16.0.2", "eslint": "^4.4.1", "husky": "^0.13.2", "lerna": "^2.0.0", "lerna-changelog": "^0.6.0", "lint-staged": "^3.3.1", - "prettier": "^1.5.2" + "prettier": "1.6.1" }, "lint-staged": { "*.js": [ diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index f6102dc05..0d961af6f 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index dce674298..f020f99e0 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -1,9 +1,9 @@ { "name": "babel-preset-react-app", - "version": "3.0.2", + "version": "3.1.0", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, @@ -11,17 +11,17 @@ "index.js" ], "dependencies": { - "babel-plugin-dynamic-import-node": "1.0.2", + "babel-plugin-dynamic-import-node": "1.1.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-plugin-transform-class-properties": "6.24.1", - "babel-plugin-transform-object-rest-spread": "6.23.0", + "babel-plugin-transform-object-rest-spread": "6.26.0", "babel-plugin-transform-react-constant-elements": "6.23.0", "babel-plugin-transform-react-jsx": "6.24.1", "babel-plugin-transform-react-jsx-self": "6.22.0", "babel-plugin-transform-react-jsx-source": "6.22.0", - "babel-plugin-transform-regenerator": "6.24.1", + "babel-plugin-transform-regenerator": "6.26.0", "babel-plugin-transform-runtime": "6.23.0", - "babel-preset-env": "1.5.2", + "babel-preset-env": "1.6.1", "babel-preset-react": "6.24.1" }, "peerDependencies": { diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 4a1b7901d..9ff7c08cf 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -160,8 +158,13 @@ function createApp(name, verbose, version, template) { path.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) ); + + const useYarn = shouldUseYarn(); const originalDirectory = process.cwd(); process.chdir(root); + if (!useYarn && !checkThatNpmCanReadCwd()) { + process.exit(1); + } if (!semver.satisfies(process.version, '>=6.0.0')) { console.log( @@ -174,7 +177,6 @@ function createApp(name, verbose, version, template) { version = 'react-scripts@0.9.x'; } - const useYarn = shouldUseYarn(); if (!useYarn) { const npmInfo = checkNpmVersion(); if (!npmInfo.hasMinNpm) { @@ -202,7 +204,7 @@ function shouldUseYarn() { } } -function install(useYarn, dependencies, verbose, isOnline) { +function install(root, useYarn, dependencies, verbose, isOnline) { return new Promise((resolve, reject) => { let command; let args; @@ -214,6 +216,14 @@ function install(useYarn, dependencies, verbose, isOnline) { } [].push.apply(args, dependencies); + // Explicitly set cwd() to work around issues like + // https://github.com/facebookincubator/create-react-app/issues/3326. + // Unfortunately we can only do this for Yarn because npm support for + // equivalent --prefix flag doesn't help with this issue. + // This is why for npm, we run checkThatNpmCanReadCwd() early instead. + args.push('--cwd'); + args.push(root); + if (!isOnline) { console.log(chalk.yellow('You appear to be offline.')); console.log(chalk.yellow('Falling back to the local Yarn cache.')); @@ -277,7 +287,7 @@ function run( ); console.log(); - return install(useYarn, allDependencies, verbose, isOnline).then( + return install(root, useYarn, allDependencies, verbose, isOnline).then( () => packageName ); }) @@ -455,7 +465,9 @@ function checkNpmVersion() { let hasMinNpm = false; let npmVersion = null; try { - npmVersion = execSync('npm --version').toString().trim(); + npmVersion = execSync('npm --version') + .toString() + .trim(); hasMinNpm = semver.gte(npmVersion, '3.0.0'); } catch (err) { // ignore @@ -606,6 +618,67 @@ function isSafeToCreateProjectIn(root, name) { return false; } +function checkThatNpmCanReadCwd() { + const cwd = process.cwd(); + let childOutput = null; + try { + // Note: intentionally using spawn over exec since + // the problem doesn't reproduce otherwise. + // `npm config list` is the only reliable way I could find + // to reproduce the wrong path. Just printing process.cwd() + // in a Node process was not enough. + childOutput = spawn.sync('npm', ['config', 'list']).output.join(''); + } catch (err) { + // Something went wrong spawning node. + // Not great, but it means we can't do this check. + // We might fail later on, but let's continue. + return true; + } + if (typeof childOutput !== 'string') { + return true; + } + const lines = childOutput.split('\n'); + // `npm config list` output includes the following line: + // "; cwd = C:\path\to\current\dir" (unquoted) + // I couldn't find an easier way to get it. + const prefix = '; cwd = '; + const line = lines.find(line => line.indexOf(prefix) === 0); + if (typeof line !== 'string') { + // Fail gracefully. They could remove it. + return true; + } + const npmCWD = line.substring(prefix.length); + if (npmCWD === cwd) { + return true; + } + console.error( + chalk.red( + `Could not start an npm process in the right directory.\n\n` + + `The current directory is: ${chalk.bold(cwd)}\n` + + `However, a newly started npm process runs in: ${chalk.bold( + npmCWD + )}\n\n` + + `This is probably caused by a misconfigured system terminal shell.` + ) + ); + if (process.platform === 'win32') { + console.error( + chalk.red(`On Windows, this can usually be fixed by running:\n\n`) + + ` ${chalk.cyan( + 'reg' + )} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` + + ` ${chalk.cyan( + 'reg' + )} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` + + chalk.red(`Try to run the above two lines in the terminal.\n`) + + chalk.red( + `To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/` + ) + ); + } + return false; +} + function checkIfOnline(useYarn) { if (!useYarn) { // Don't ping the Yarn registry. diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index 4df90f53f..a09363660 100755 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -2,11 +2,9 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 42ee3497e..569985f5c 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,12 +1,12 @@ { "name": "create-react-app", - "version": "1.4.0", + "version": "1.4.3", "keywords": [ "react" ], "description": "Create React apps with no build configuration.", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "engines": { "node": ">=4" }, diff --git a/packages/eslint-config-react-app/README.md b/packages/eslint-config-react-app/README.md index 0679552a2..6918cda52 100644 --- a/packages/eslint-config-react-app/README.md +++ b/packages/eslint-config-react-app/README.md @@ -19,7 +19,7 @@ If you want to use this ESLint configuration in a project not built with Create First, install this package, ESLint and the necessary plugins. ```sh - npm install --save-dev eslint-config-react-app babel-eslint@7.2.3 eslint@3.19.0 eslint-plugin-flowtype@2.33.0 eslint-plugin-import@2.2.0 eslint-plugin-jsx-a11y@5.0.1 eslint-plugin-react@7.0.1 + npm install --save-dev eslint-config-react-app babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0 ``` Then create a file named `.eslintrc` with following contents in the root folder of your project: diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 4e94e650c..adcdb86bc 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 375c9f54b..a10ef6799 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -1,9 +1,9 @@ { "name": "eslint-config-react-app", - "version": "2.0.0", + "version": "2.0.1", "description": "ESLint configuration used by Create React App", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index f25e47378..01ce52c6b 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/InterpolateHtmlPlugin.js b/packages/react-dev-utils/InterpolateHtmlPlugin.js index ac1d3e996..9233bdefa 100644 --- a/packages/react-dev-utils/InterpolateHtmlPlugin.js +++ b/packages/react-dev-utils/InterpolateHtmlPlugin.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // This Webpack plugin lets us interpolate custom variables into `index.html`. diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index 3a10904d3..101a30a1f 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js index 91b089c05..ae11cdc90 100644 --- a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js +++ b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // This Webpack plugin ensures `npm install ` forces a project rebuild. diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index bb4a8c790..c2d038654 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/__tests__/.eslintrc b/packages/react-dev-utils/__tests__/.eslintrc new file mode 100644 index 000000000..55f121d15 --- /dev/null +++ b/packages/react-dev-utils/__tests__/.eslintrc @@ -0,0 +1,5 @@ +{ + "env": { + "jest": true + } +} diff --git a/packages/react-dev-utils/__tests__/ignoredFiles.test.js b/packages/react-dev-utils/__tests__/ignoredFiles.test.js new file mode 100644 index 000000000..6feed9797 --- /dev/null +++ b/packages/react-dev-utils/__tests__/ignoredFiles.test.js @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +const ignoredFiles = require('../ignoredFiles'); + +describe('ignore watch files regex', () => { + it('normal file', () => { + const appSrc = '/root/src/'; + const isIgnored = ignoredFiles(appSrc).test('/foo'); + const isIgnoredInSrc = ignoredFiles(appSrc).test('/root/src/foo'); + + expect(isIgnored).toBe(false); + expect(isIgnoredInSrc).toBe(false); + }); + + it('node modules', () => { + const appSrc = '/root/src/'; + const isIgnored = ignoredFiles(appSrc).test('/root/node_modules/foo'); + + expect(isIgnored).toBe(true); + }); + + it('node modules inside source directory', () => { + const appSrc = '/root/src/'; + const isIgnored = ignoredFiles(appSrc).test('/root/src/node_modules/foo'); + const isIgnoredMoreThanOneLevel = ignoredFiles(appSrc).test( + '/root/src/bar/node_modules/foo' + ); + + expect(isIgnored).toBe(false); + expect(isIgnoredMoreThanOneLevel).toBe(false); + }); + + it('path contains source directory', () => { + const appSrc = '/root/src/'; + const isIgnored = ignoredFiles(appSrc).test( + '/bar/root/src/node_modules/foo' + ); + + expect(isIgnored).toBe(true); + }); + + it('path starts with source directory', () => { + const appSrc = '/root/src/'; + const isIgnored = ignoredFiles(appSrc).test('/root/src2/node_modules/foo'); + + expect(isIgnored).toBe(true); + }); +}); diff --git a/packages/react-dev-utils/checkRequiredFiles.js b/packages/react-dev-utils/checkRequiredFiles.js index 55139b0b8..9799cf6b5 100644 --- a/packages/react-dev-utils/checkRequiredFiles.js +++ b/packages/react-dev-utils/checkRequiredFiles.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/clearConsole.js b/packages/react-dev-utils/clearConsole.js index 05ab28c44..6e3b3c9ce 100644 --- a/packages/react-dev-utils/clearConsole.js +++ b/packages/react-dev-utils/clearConsole.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/crossSpawn.js b/packages/react-dev-utils/crossSpawn.js index 8424dcf09..b772086f2 100644 --- a/packages/react-dev-utils/crossSpawn.js +++ b/packages/react-dev-utils/crossSpawn.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/errorOverlayMiddleware.js b/packages/react-dev-utils/errorOverlayMiddleware.js index b2a857d6e..b756b0ef6 100644 --- a/packages/react-dev-utils/errorOverlayMiddleware.js +++ b/packages/react-dev-utils/errorOverlayMiddleware.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/eslintFormatter.js b/packages/react-dev-utils/eslintFormatter.js index b7756b7a2..a269ccc82 100644 --- a/packages/react-dev-utils/eslintFormatter.js +++ b/packages/react-dev-utils/eslintFormatter.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index 1f22a0059..7aea5582c 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index 428dc62cf..932f3e5bf 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; @@ -48,9 +46,11 @@ function getProcessCommand(processId, processDirectory) { execOptions ); + command = command.replace(/\n$/, ''); + if (isProcessAReactApp(command)) { const packageName = getPackageNameInDirectory(processDirectory); - return packageName ? packageName + '\n' : command; + return packageName ? packageName : command; } else { return command; } @@ -68,7 +68,12 @@ function getProcessForPort(port) { var processId = getProcessIdOnPort(port); var directory = getDirectoryOfProcessById(processId); var command = getProcessCommand(processId, directory); - return chalk.cyan(command) + chalk.blue(' in ') + chalk.cyan(directory); + return ( + chalk.cyan(command) + + chalk.grey(' (pid ' + processId + ')\n') + + chalk.blue(' in ') + + chalk.cyan(directory) + ); } catch (e) { return null; } diff --git a/packages/react-dev-utils/ignoredFiles.js b/packages/react-dev-utils/ignoredFiles.js new file mode 100644 index 000000000..50348ea6b --- /dev/null +++ b/packages/react-dev-utils/ignoredFiles.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +const path = require('path'); + +module.exports = function ignoredFiles(appSrc) { + return new RegExp( + `^(?!${path + .normalize(appSrc + '/') + .replace(/[\\]+/g, '/')}).+/node_modules/`, + 'g' + ); +}; diff --git a/packages/react-dev-utils/inquirer.js b/packages/react-dev-utils/inquirer.js index 9dbc08026..6b8eca9ea 100644 --- a/packages/react-dev-utils/inquirer.js +++ b/packages/react-dev-utils/inquirer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index e1ea29c88..ba16827e6 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; @@ -43,7 +41,7 @@ const COMMON_EDITORS_OSX = { '/Applications/CLion.app/Contents/MacOS/clion': '/Applications/CLion.app/Contents/MacOS/clion', '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea': - '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', + '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', '/Applications/PhpStorm.app/Contents/MacOS/phpstorm': '/Applications/PhpStorm.app/Contents/MacOS/phpstorm', '/Applications/PyCharm.app/Contents/MacOS/pycharm': @@ -53,7 +51,21 @@ const COMMON_EDITORS_OSX = { '/Applications/RubyMine.app/Contents/MacOS/rubymine': '/Applications/RubyMine.app/Contents/MacOS/rubymine', '/Applications/WebStorm.app/Contents/MacOS/webstorm': - '/Applications/WebStorm.app/Contents/MacOS/webstorm', + '/Applications/WebStorm.app/Contents/MacOS/webstorm', +}; + +const COMMON_EDITORS_LINUX = { + atom: 'atom', + Brackets: 'brackets', + code: 'code', + emacs: 'emacs', + 'idea.sh': 'idea', + 'phpstorm.sh': 'phpstorm', + 'pycharm.sh': 'pycharm', + 'rubymine.sh': 'rubymine', + sublime_text: 'sublime_text', + vim: 'vim', + 'webstorm.sh': 'webstorm', }; const COMMON_EDITORS_WIN = [ @@ -144,8 +156,9 @@ function guessEditor() { return shellQuote.parse(process.env.REACT_EDITOR); } - // Using `ps x` on OSX or `Get-Process` on Windows we can find out which editor is currently running. - // Potentially we could use similar technique for Linux + // We can find out which editor is currently running by: + // `ps x` on macOS and Linux + // `Get-Process` on Windows try { if (process.platform === 'darwin') { const output = child_process.execSync('ps x').toString(); @@ -176,6 +189,20 @@ function guessEditor() { return [fullProcessPath]; } } + } else if (process.platform === 'linux') { + // --no-heading No header line + // x List all processes owned by you + // -o comm Need only names column + const output = child_process + .execSync('ps x --no-heading -o comm --sort=comm') + .toString(); + const processNames = Object.keys(COMMON_EDITORS_LINUX); + for (let i = 0; i < processNames.length; i++) { + const processName = processNames[i]; + if (output.indexOf(processName) !== -1) { + return [COMMON_EDITORS_LINUX[processName]]; + } + } } } catch (error) { // Ignore... diff --git a/packages/react-dev-utils/launchEditorEndpoint.js b/packages/react-dev-utils/launchEditorEndpoint.js index e21870be9..99b5935d9 100644 --- a/packages/react-dev-utils/launchEditorEndpoint.js +++ b/packages/react-dev-utils/launchEditorEndpoint.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/noopServiceWorkerMiddleware.js b/packages/react-dev-utils/noopServiceWorkerMiddleware.js index b6cee7350..41566dd7f 100644 --- a/packages/react-dev-utils/noopServiceWorkerMiddleware.js +++ b/packages/react-dev-utils/noopServiceWorkerMiddleware.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/openBrowser.js b/packages/react-dev-utils/openBrowser.js index 4f5700125..cb9f32c6a 100644 --- a/packages/react-dev-utils/openBrowser.js +++ b/packages/react-dev-utils/openBrowser.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/openChrome.applescript b/packages/react-dev-utils/openChrome.applescript index 0f5602721..3b1b5a29d 100644 --- a/packages/react-dev-utils/openChrome.applescript +++ b/packages/react-dev-utils/openChrome.applescript @@ -1,10 +1,8 @@ (* Copyright (c) 2015-present, Facebook, Inc. -All rights reserved. -This source code is licensed under the BSD-style license found in the --- LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory. +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. *) property targetTab: null diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index ec8b44292..54606f33f 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,9 +1,9 @@ { "name": "react-dev-utils", - "version": "4.0.1", + "version": "4.2.1", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, @@ -21,6 +21,7 @@ "printBuildError.js", "formatWebpackMessages.js", "getProcessForPort.js", + "ignoredFiles.js", "inquirer.js", "InterpolateHtmlPlugin.js", "launchEditor.js", @@ -35,23 +36,29 @@ "webpackHotDevClient.js" ], "dependencies": { - "address": "1.0.2", - "babel-code-frame": "6.22.0", + "address": "1.0.3", + "babel-code-frame": "6.26.0", "chalk": "1.1.3", "cross-spawn": "5.1.0", "detect-port-alt": "1.1.3", "escape-string-regexp": "1.0.5", - "filesize": "3.5.10", + "filesize": "3.5.11", "global-modules": "1.0.0", "gzip-size": "3.0.0", - "inquirer": "3.2.1", + "inquirer": "3.3.0", "is-root": "1.0.0", "opn": "5.1.0", - "react-error-overlay": "^2.0.1", + "react-error-overlay": "^3.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", "strip-ansi": "3.0.1", "text-table": "0.2.0" + }, + "devDependencies": { + "jest": "20.0.4" + }, + "scripts": { + "test": "jest" } } diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js index eadfff471..26e291356 100644 --- a/packages/react-dev-utils/printBuildError.js +++ b/packages/react-dev-utils/printBuildError.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index 2ef25767a..4a080dba2 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 18a6a4a0a..296e38046 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; @@ -25,13 +23,27 @@ var launchEditorEndpoint = require('./launchEditorEndpoint'); var formatWebpackMessages = require('./formatWebpackMessages'); var ErrorOverlay = require('react-error-overlay'); +ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) { + // Keep this sync with errorOverlayMiddleware.js + fetch( + launchEditorEndpoint + + '?fileName=' + + window.encodeURIComponent(errorLocation.fileName) + + '&lineNumber=' + + window.encodeURIComponent(errorLocation.lineNumber || 1) + ); +}); + +// We need to keep track of if there has been a runtime error. +// Essentially, we cannot guarantee application state was not corrupted by the +// runtime error. To prevent confusing behavior, we forcibly reload the entire +// application. This is handled below when we are notified of a compile (code +// change). +// See https://github.com/facebookincubator/create-react-app/issues/3096 +var hadRuntimeError = false; ErrorOverlay.startReportingRuntimeErrors({ - launchEditorEndpoint: launchEditorEndpoint, onError: function() { - // TODO: why do we need this? - if (module.hot && typeof module.hot.decline === 'function') { - module.hot.decline(); - } + hadRuntimeError = true; }, filename: '/static/js/bundle.js', }); @@ -227,7 +239,7 @@ function tryApplyUpdates(onHotUpdateSuccess) { } function handleApplyUpdates(err, updatedModules) { - if (err || !updatedModules) { + if (err || !updatedModules || hadRuntimeError) { window.location.reload(); return; } diff --git a/packages/react-error-overlay/.gitattributes b/packages/react-error-overlay/.gitattributes new file mode 100644 index 000000000..cbdcbbc25 --- /dev/null +++ b/packages/react-error-overlay/.gitattributes @@ -0,0 +1 @@ +*.js text eol=lf diff --git a/packages/react-error-overlay/build.js b/packages/react-error-overlay/build.js new file mode 100644 index 000000000..592da141f --- /dev/null +++ b/packages/react-error-overlay/build.js @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const webpack = require('webpack'); +const chalk = require('chalk'); +const webpackConfig = require('./webpack.config.js'); +const iframeWebpackConfig = require('./webpack.config.iframe.js'); +const rimraf = require('rimraf'); +const chokidar = require('chokidar'); + +const args = process.argv.slice(2); +const watchMode = args[0] === '--watch' || args[0] === '-w'; + +const isCI = + process.env.CI && + (typeof process.env.CI !== 'string' || + process.env.CI.toLowerCase() !== 'false'); + +function build(config, name, callback) { + console.log(chalk.cyan('Compiling ' + name)); + webpack(config).run((error, stats) => { + if (error) { + console.log(chalk.red('Failed to compile.')); + console.log(error.message || error); + console.log(); + } + + if (stats.compilation.errors.length) { + console.log(chalk.red('Failed to compile.')); + console.log(stats.toString({ all: false, errors: true })); + } + + if (stats.compilation.warnings.length) { + console.log(chalk.yellow('Compiled with warnings.')); + console.log(stats.toString({ all: false, warnings: true })); + } + + // Fail the build if running in a CI server + if ( + error || + stats.compilation.errors.length || + stats.compilation.warnings.length + ) { + isCI && process.exit(1); + return; + } + + console.log( + stats.toString({ colors: true, modules: false, version: false }) + ); + console.log(); + + callback(stats); + }); +} + +function runBuildSteps() { + build(iframeWebpackConfig, 'iframeScript.js', () => { + build(webpackConfig, 'index.js', () => { + console.log(chalk.bold.green('Compiled successfully!\n\n')); + }); + }); +} + +function setupWatch() { + const watcher = chokidar.watch('./src', { + ignoreInitial: true, + }); + + watcher.on('change', runBuildSteps); + watcher.on('add', runBuildSteps); + + watcher.on('ready', () => { + runBuildSteps(); + }); + + process.on('SIGINT', function() { + watcher.close(); + process.exit(0); + }); + + watcher.on('error', error => { + console.error('Watcher failure', error); + process.exit(1); + }); +} + +// Clean up lib folder +rimraf('lib/', () => { + console.log('Cleaned up the lib folder.\n'); + watchMode ? setupWatch() : runBuildSteps(); +}); diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index b3b9365ae..d4e528ea6 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,17 +1,17 @@ { "name": "react-error-overlay", - "version": "2.0.1", + "version": "3.0.0", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { "prepublishOnly": "npm run build:prod && npm test", - "start": "cross-env NODE_ENV=development npm run build -- --watch", - "test": "flow && jest", - "build": "babel src/ -d lib/", - "build:prod": "cross-env NODE_ENV=production babel src/ -d lib/" + "start": "cross-env NODE_ENV=development node build.js --watch", + "test": "flow && cross-env NODE_ENV=test jest", + "build": "cross-env NODE_ENV=development node build.js", + "build:prod": "cross-env NODE_ENV=production node build.js" }, "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, @@ -27,33 +27,38 @@ ], "author": "Joe Haddad ", "files": [ - "lib/", - "middleware.js" + "lib/index.js" ], - "dependencies": { - "anser": "1.4.1", - "babel-code-frame": "6.22.0", - "babel-runtime": "6.26.0", - "html-entities": "1.2.1", - "react": "^15 || ^16", - "react-dom": "^15 || ^16", - "settle-promise": "1.0.0", - "source-map": "0.5.6" - }, "devDependencies": { - "babel-cli": "6.24.1", + "anser": "1.4.4", + "babel-code-frame": "6.26.0", + "babel-core": "^6.26.0", "babel-eslint": "7.2.3", - "babel-preset-react-app": "^3.0.2", + "babel-loader": "^7.1.2", + "babel-preset-react-app": "^3.1.0", + "babel-runtime": "6.26.0", + "chalk": "^2.1.0", + "chokidar": "^1.7.0", "cross-env": "5.0.5", "eslint": "4.4.1", - "eslint-config-react-app": "^2.0.0", + "eslint-config-react-app": "^2.0.1", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", - "flow-bin": "0.52.0", + "flow-bin": "^0.54.0", + "html-entities": "1.2.1", "jest": "20.0.4", - "jest-fetch-mock": "1.2.1" + "jest-fetch-mock": "1.2.1", + "object-assign": "4.1.1", + "promise": "8.0.1", + "raw-loader": "^0.5.1", + "react": "^16.0.0", + "react-dom": "^16.0.0", + "rimraf": "^2.6.1", + "settle-promise": "1.0.0", + "source-map": "0.5.6", + "webpack": "^3.6.0" }, "jest": { "setupFiles": [ diff --git a/packages/react-error-overlay/src/__tests__/extract-source-map.js b/packages/react-error-overlay/src/__tests__/extract-source-map.js index 85c30accd..b47f5ab5f 100644 --- a/packages/react-error-overlay/src/__tests__/extract-source-map.js +++ b/packages/react-error-overlay/src/__tests__/extract-source-map.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { extractSourceMapUrl } from '../utils/getSourceMap'; diff --git a/packages/react-error-overlay/src/__tests__/get-source-map.js b/packages/react-error-overlay/src/__tests__/get-source-map.js index 299069266..27c6d5f78 100644 --- a/packages/react-error-overlay/src/__tests__/get-source-map.js +++ b/packages/react-error-overlay/src/__tests__/get-source-map.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { getSourceMap } from '../utils/getSourceMap'; diff --git a/packages/react-error-overlay/src/__tests__/lines-around.js b/packages/react-error-overlay/src/__tests__/lines-around.js index 0317bd47b..64595df30 100644 --- a/packages/react-error-overlay/src/__tests__/lines-around.js +++ b/packages/react-error-overlay/src/__tests__/lines-around.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { getLinesAround } from '../utils/getLinesAround'; diff --git a/packages/react-error-overlay/src/__tests__/mapper.js b/packages/react-error-overlay/src/__tests__/mapper.js index 169bf6c59..bd733487f 100644 --- a/packages/react-error-overlay/src/__tests__/mapper.js +++ b/packages/react-error-overlay/src/__tests__/mapper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { map } from '../utils/mapper'; diff --git a/packages/react-error-overlay/src/__tests__/parser/chrome.js b/packages/react-error-overlay/src/__tests__/parser/chrome.js index caf95a6fc..651f584cc 100644 --- a/packages/react-error-overlay/src/__tests__/parser/chrome.js +++ b/packages/react-error-overlay/src/__tests__/parser/chrome.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/firefox.js b/packages/react-error-overlay/src/__tests__/parser/firefox.js index 4f1d19ac2..8aa0f4d6c 100644 --- a/packages/react-error-overlay/src/__tests__/parser/firefox.js +++ b/packages/react-error-overlay/src/__tests__/parser/firefox.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/generic.js b/packages/react-error-overlay/src/__tests__/parser/generic.js index b58c537d3..32bade931 100644 --- a/packages/react-error-overlay/src/__tests__/parser/generic.js +++ b/packages/react-error-overlay/src/__tests__/parser/generic.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/react.js b/packages/react-error-overlay/src/__tests__/parser/react.js index 907fae239..e7dcc07cb 100644 --- a/packages/react-error-overlay/src/__tests__/parser/react.js +++ b/packages/react-error-overlay/src/__tests__/parser/react.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/safari.js b/packages/react-error-overlay/src/__tests__/parser/safari.js index 69ecf6c78..74d169d99 100644 --- a/packages/react-error-overlay/src/__tests__/parser/safari.js +++ b/packages/react-error-overlay/src/__tests__/parser/safari.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/script-lines.js b/packages/react-error-overlay/src/__tests__/script-lines.js index e26e8d4f8..ec5ff0b0f 100644 --- a/packages/react-error-overlay/src/__tests__/script-lines.js +++ b/packages/react-error-overlay/src/__tests__/script-lines.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { ScriptLine } from '../utils/stack-frame'; diff --git a/packages/react-error-overlay/src/__tests__/setupJest.js b/packages/react-error-overlay/src/__tests__/setupJest.js index 496826f2c..91757b455 100644 --- a/packages/react-error-overlay/src/__tests__/setupJest.js +++ b/packages/react-error-overlay/src/__tests__/setupJest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ global.fetch = require('jest-fetch-mock'); diff --git a/packages/react-error-overlay/src/__tests__/stack-frame.js b/packages/react-error-overlay/src/__tests__/stack-frame.js index 5a015260a..af1f05e0a 100644 --- a/packages/react-error-overlay/src/__tests__/stack-frame.js +++ b/packages/react-error-overlay/src/__tests__/stack-frame.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { StackFrame } from '../utils/stack-frame'; diff --git a/packages/react-error-overlay/src/__tests__/unmapper.js b/packages/react-error-overlay/src/__tests__/unmapper.js index fd162ccac..c9dc32a53 100644 --- a/packages/react-error-overlay/src/__tests__/unmapper.js +++ b/packages/react-error-overlay/src/__tests__/unmapper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { unmap } from '../utils/unmapper'; diff --git a/packages/react-error-overlay/src/components/CloseButton.js b/packages/react-error-overlay/src/components/CloseButton.js index 503b1198c..ed7006ea3 100644 --- a/packages/react-error-overlay/src/components/CloseButton.js +++ b/packages/react-error-overlay/src/components/CloseButton.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/CodeBlock.js b/packages/react-error-overlay/src/components/CodeBlock.js index 478f0111b..3165bb3b0 100644 --- a/packages/react-error-overlay/src/components/CodeBlock.js +++ b/packages/react-error-overlay/src/components/CodeBlock.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/Collapsible.js b/packages/react-error-overlay/src/components/Collapsible.js index 92f1de429..016f3c7a7 100644 --- a/packages/react-error-overlay/src/components/Collapsible.js +++ b/packages/react-error-overlay/src/components/Collapsible.js @@ -1,16 +1,16 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ import React, { Component } from 'react'; import { black } from '../styles'; +import type { Element as ReactElement } from 'react'; + const _collapsibleStyle = { color: black, cursor: 'pointer', @@ -35,7 +35,15 @@ const collapsibleExpandedStyle = { marginBottom: '0.6em', }; -class Collapsible extends Component { +type Props = {| + children: ReactElement[], +|}; + +type State = {| + collapsed: boolean, +|}; + +class Collapsible extends Component { state = { collapsed: true, }; diff --git a/packages/react-error-overlay/src/components/ErrorOverlay.js b/packages/react-error-overlay/src/components/ErrorOverlay.js index 446105dad..da4154002 100644 --- a/packages/react-error-overlay/src/components/ErrorOverlay.js +++ b/packages/react-error-overlay/src/components/ErrorOverlay.js @@ -1,16 +1,16 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ import React, { Component } from 'react'; import { black } from '../styles'; +import type { Node as ReactNode } from 'react'; + const overlayStyle = { position: 'relative', display: 'inline-flex', @@ -31,10 +31,19 @@ const overlayStyle = { color: black, }; -class ErrorOverlay extends Component { +type Props = {| + children: ReactNode, + shortcutHandler?: (eventKey: string) => void, +|}; + +type State = {| + collapsed: boolean, +|}; + +class ErrorOverlay extends Component { iframeWindow: window = null; - getIframeWindow = (element: HTMLDivElement) => { + getIframeWindow = (element: ?HTMLDivElement) => { if (element) { const document = element.ownerDocument; this.iframeWindow = document.defaultView; diff --git a/packages/react-error-overlay/src/components/Footer.js b/packages/react-error-overlay/src/components/Footer.js index 68eb84656..bef53f6c1 100644 --- a/packages/react-error-overlay/src/components/Footer.js +++ b/packages/react-error-overlay/src/components/Footer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/Header.js b/packages/react-error-overlay/src/components/Header.js index a2f40973d..7b45ceef5 100644 --- a/packages/react-error-overlay/src/components/Header.js +++ b/packages/react-error-overlay/src/components/Header.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ @@ -29,11 +27,7 @@ type HeaderPropType = {| |}; function Header(props: HeaderPropType) { - return ( -
- {props.headerText} -
- ); + return
{props.headerText}
; } export default Header; diff --git a/packages/react-error-overlay/src/components/NavigationBar.js b/packages/react-error-overlay/src/components/NavigationBar.js index 4eba743ce..6fb7b14ab 100644 --- a/packages/react-error-overlay/src/components/NavigationBar.js +++ b/packages/react-error-overlay/src/components/NavigationBar.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index a3e89fe59..9d1e399fd 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ @@ -14,14 +12,34 @@ import Footer from '../components/Footer'; import Header from '../components/Header'; import CodeBlock from '../components/CodeBlock'; import generateAnsiHTML from '../utils/generateAnsiHTML'; +import parseCompileError from '../utils/parseCompileError'; +import type { ErrorLocation } from '../utils/parseCompileError'; -class CompileErrorContainer extends PureComponent { +const codeAnchorStyle = { + cursor: 'pointer', +}; + +type Props = {| + error: string, + editorHandler: (errorLoc: ErrorLocation) => void, +|}; + +class CompileErrorContainer extends PureComponent { render() { - const { error } = this.props; + const { error, editorHandler } = this.props; + const errLoc: ?ErrorLocation = parseCompileError(error); + const canOpenInEditor = errLoc !== null && editorHandler !== null; return (
- + editorHandler(errLoc) : null + } + style={canOpenInEditor ? codeAnchorStyle : null} + > + +