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

Commit

Permalink
Merge pull request #221 from wmonk/2.10.0
Browse files Browse the repository at this point in the history
2.11.0
  • Loading branch information
wmonk authored Jan 14, 2018
2 parents 22e52e1 + e637c79 commit ea32709
Show file tree
Hide file tree
Showing 179 changed files with 1,585 additions and 1,273 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
43 changes: 17 additions & 26 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 0 additions & 33 deletions PATENTS

This file was deleted.

1 change: 1 addition & 0 deletions appveyor.cleanup-cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ http://help.appveyor.com/discussions/questions/1310-delete-cache

----
Just testing if this works.
lalala.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
12 changes: 6 additions & 6 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"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"
},
"files": [
"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": {
Expand Down
125 changes: 85 additions & 40 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
@@ -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.
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -75,14 +73,10 @@ const program = new commander.Command(packageJson.name)
);
console.log(` - a specific npm version: ${chalk.green('0.8.2')}`);
console.log(
` - a custom fork published on npm: ${chalk.green(
'my-react-scripts'
)}`
` - a custom fork published on npm: ${chalk.green('my-react-scripts')}`
);
console.log(
` - a .tgz archive: ${chalk.green(
'https://mysite.com/my-react-scripts-0.8.2.tgz'
)}`
` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}`
);
console.log(
` It is not needed unless you specifically want to use a fork.`
Expand All @@ -92,9 +86,7 @@ const program = new commander.Command(packageJson.name)
` If you have any problems, do not hesitate to file an issue:`
);
console.log(
` ${chalk.cyan(
'https://github.com/facebookincubator/create-react-app/issues/new'
)}`
` ${chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new')}`
);
console.log();
})
Expand Down Expand Up @@ -160,8 +152,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(
Expand All @@ -174,7 +171,6 @@ function createApp(name, verbose, version, template) {
version = '[email protected]';
}

const useYarn = shouldUseYarn();
if (!useYarn) {
const npmInfo = checkNpmVersion();
if (!npmInfo.hasMinNpm) {
Expand Down Expand Up @@ -202,7 +198,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;
Expand All @@ -214,6 +210,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.'));
Expand Down Expand Up @@ -261,23 +265,19 @@ function run(

console.log('Installing packages. This might take a couple of minutes.');
getPackageName(packageToInstall)
.then(packageName =>
checkIfOnline(useYarn).then(isOnline => ({
isOnline: isOnline,
packageName: packageName,
}))
)
.then(packageName => checkIfOnline(useYarn).then(isOnline => ({
isOnline: isOnline,
packageName: packageName,
})))
.then(info => {
const isOnline = info.isOnline;
const packageName = info.packageName;
console.log(
`Installing ${chalk.cyan('react')}, ${chalk.cyan(
'react-dom'
)}, and ${chalk.cyan(packageName)}...`
`Installing ${chalk.cyan('react')}, ${chalk.cyan('react-dom')}, and ${chalk.cyan(packageName)}...`
);
console.log();

return install(useYarn, allDependencies, verbose, isOnline).then(
return install(root, useYarn, allDependencies, verbose, isOnline).then(
() => packageName
);
})
Expand Down Expand Up @@ -341,9 +341,7 @@ function run(
if (!remainingFiles.length) {
// Delete target folder if empty
console.log(
`Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(
path.resolve(root, '..')
)}`
`Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(path.resolve(root, '..'))}`
);
process.chdir(path.resolve(root, '..'));
fs.removeSync(path.join(root));
Expand Down Expand Up @@ -431,9 +429,7 @@ function getPackageName(installPackage) {
/^.+\/(.+?)(?:-\d+.+)?\.tgz$/
)[1];
console.log(
`Based on the filename, assuming it is "${chalk.cyan(
assumedProjectName
)}"`
`Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"`
);
return Promise.resolve(assumedProjectName);
});
Expand Down Expand Up @@ -496,9 +492,7 @@ function checkAppName(appName) {
const validationResult = validateProjectName(appName);
if (!validationResult.validForNewPackages) {
console.error(
`Could not create a project called ${chalk.red(
`"${appName}"`
)} because of npm naming restrictions:`
`Could not create a project called ${chalk.red(`"${appName}"`)} because of npm naming restrictions:`
);
printValidationResults(validationResult.errors);
printValidationResults(validationResult.warnings);
Expand All @@ -510,9 +504,7 @@ function checkAppName(appName) {
if (dependencies.indexOf(appName) >= 0) {
console.error(
chalk.red(
`We cannot create a project called ${chalk.green(
appName
)} because a dependency with the same name exists.\n` +
`We cannot create a project called ${chalk.green(appName)} because a dependency with the same name exists.\n` +
`Due to the way npm works, the following names are not allowed:\n\n`
) +
chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) +
Expand All @@ -534,9 +526,7 @@ function makeCaretRange(dependencies, name) {

if (!semver.validRange(patchedVersion)) {
console.error(
`Unable to patch ${name} dependency version because version ${chalk.red(
version
)} will become invalid ${chalk.red(patchedVersion)}`
`Unable to patch ${name} dependency version because version ${chalk.red(version)} will become invalid ${chalk.red(patchedVersion)}`
);
patchedVersion = version;
}
Expand Down Expand Up @@ -606,6 +596,61 @@ 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.
Expand Down
Loading

0 comments on commit ea32709

Please sign in to comment.