Skip to content

Commit 1061fde

Browse files
committed
Merge facebookincubator/create-react-app@1.0.17
2 parents cc52d21 + 4b55193 commit 1061fde

File tree

179 files changed

+1584
-1337
lines changed

Some content is hidden

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

179 files changed

+1584
-1337
lines changed

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ More detailed information are in the dedicated [README](/packages/react-scripts/
108108
* 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.
109109
* 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.
110110
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
111-
7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration.
112-
8. **Do not run `npm publish`. Instead, run `npm run publish`.**
113-
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.
111+
7. **Do not run `npm publish`. Instead, run `npm run publish`.**
112+
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.
113+
9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.
114114

115115
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`.
116116

LICENSE

+17-26
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
BSD License
1+
MIT License
22

3-
For create-react-app software
3+
Copyright (c) 2013-present, Facebook, Inc.
44

5-
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
611

7-
Redistribution and use in source and binary forms, with or without modification,
8-
are permitted provided that the following conditions are met:
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
914

10-
* Redistributions of source code must retain the above copyright notice, this
11-
list of conditions and the following disclaimer.
12-
13-
* Redistributions in binary form must reproduce the above copyright notice,
14-
this list of conditions and the following disclaimer in the documentation
15-
and/or other materials provided with the distribution.
16-
17-
* Neither the name Facebook nor the names of its contributors may be used to
18-
endorse or promote products derived from this software without specific
19-
prior written permission.
20-
21-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PATENTS

-33
This file was deleted.

appveyor.cleanup-cache.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ http://help.appveyor.com/discussions/questions/1310-delete-cache
33

44
----
55
Just testing if this works.
6+
lalala.

appveyor.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ image: Visual Studio 2017
22

33
environment:
44
matrix:
5-
- nodejs_version: 7
5+
- nodejs_version: 8
66
test_suite: "simple"
7-
- nodejs_version: 7
7+
- nodejs_version: 8
88
test_suite: "installs"
9-
- nodejs_version: 7
9+
- nodejs_version: 8
1010
test_suite: "kitchensink"
1111
- nodejs_version: 6
1212
test_suite: "simple"

packages/babel-preset-react-app/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
22
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
43
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
86
*/
97
'use strict';
108

packages/babel-preset-react-app/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
22
"name": "babel-preset-react-app",
3-
"version": "3.0.2",
3+
"version": "3.1.0",
44
"description": "Babel preset used by Create React App",
55
"repository": "facebookincubator/create-react-app",
6-
"license": "BSD-3-Clause",
6+
"license": "MIT",
77
"bugs": {
88
"url": "https://github.com/facebookincubator/create-react-app/issues"
99
},
1010
"files": [
1111
"index.js"
1212
],
1313
"dependencies": {
14-
"babel-plugin-dynamic-import-node": "1.0.2",
14+
"babel-plugin-dynamic-import-node": "1.1.0",
1515
"babel-plugin-syntax-dynamic-import": "6.18.0",
1616
"babel-plugin-transform-class-properties": "6.24.1",
17-
"babel-plugin-transform-object-rest-spread": "6.23.0",
17+
"babel-plugin-transform-object-rest-spread": "6.26.0",
1818
"babel-plugin-transform-react-constant-elements": "6.23.0",
1919
"babel-plugin-transform-react-jsx": "6.24.1",
2020
"babel-plugin-transform-react-jsx-self": "6.22.0",
2121
"babel-plugin-transform-react-jsx-source": "6.22.0",
22-
"babel-plugin-transform-regenerator": "6.24.1",
22+
"babel-plugin-transform-regenerator": "6.26.0",
2323
"babel-plugin-transform-runtime": "6.23.0",
24-
"babel-preset-env": "1.5.2",
24+
"babel-preset-env": "1.6.1",
2525
"babel-preset-react": "6.24.1"
2626
},
2727
"peerDependencies": {

packages/create-react-app/createReactApp.js

+85-40
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
22
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
43
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
86
*/
97

108
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -75,14 +73,10 @@ const program = new commander.Command(packageJson.name)
7573
);
7674
console.log(` - a specific npm version: ${chalk.green('0.8.2')}`);
7775
console.log(
78-
` - a custom fork published on npm: ${chalk.green(
79-
'my-react-scripts'
80-
)}`
76+
` - a custom fork published on npm: ${chalk.green('my-react-scripts')}`
8177
);
8278
console.log(
83-
` - a .tgz archive: ${chalk.green(
84-
'https://mysite.com/my-react-scripts-0.8.2.tgz'
85-
)}`
79+
` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}`
8680
);
8781
console.log(
8882
` It is not needed unless you specifically want to use a fork.`
@@ -92,9 +86,7 @@ const program = new commander.Command(packageJson.name)
9286
` If you have any problems, do not hesitate to file an issue:`
9387
);
9488
console.log(
95-
` ${chalk.cyan(
96-
'https://github.com/facebookincubator/create-react-app/issues/new'
97-
)}`
89+
` ${chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new')}`
9890
);
9991
console.log();
10092
})
@@ -160,8 +152,13 @@ function createApp(name, verbose, version, template) {
160152
path.join(root, 'package.json'),
161153
JSON.stringify(packageJson, null, 2)
162154
);
155+
156+
const useYarn = shouldUseYarn();
163157
const originalDirectory = process.cwd();
164158
process.chdir(root);
159+
if (!useYarn && !checkThatNpmCanReadCwd()) {
160+
process.exit(1);
161+
}
165162

166163
if (!semver.satisfies(process.version, '>=6.0.0')) {
167164
console.log(
@@ -174,7 +171,6 @@ function createApp(name, verbose, version, template) {
174171
version = 'react-scripts@0.9.x';
175172
}
176173

177-
const useYarn = shouldUseYarn();
178174
if (!useYarn) {
179175
const npmInfo = checkNpmVersion();
180176
if (!npmInfo.hasMinNpm) {
@@ -202,7 +198,7 @@ function shouldUseYarn() {
202198
}
203199
}
204200

205-
function install(useYarn, dependencies, verbose, isOnline) {
201+
function install(root, useYarn, dependencies, verbose, isOnline) {
206202
return new Promise((resolve, reject) => {
207203
let command;
208204
let args;
@@ -214,6 +210,14 @@ function install(useYarn, dependencies, verbose, isOnline) {
214210
}
215211
[].push.apply(args, dependencies);
216212

213+
// Explicitly set cwd() to work around issues like
214+
// https://github.com/facebookincubator/create-react-app/issues/3326.
215+
// Unfortunately we can only do this for Yarn because npm support for
216+
// equivalent --prefix flag doesn't help with this issue.
217+
// This is why for npm, we run checkThatNpmCanReadCwd() early instead.
218+
args.push('--cwd');
219+
args.push(root);
220+
217221
if (!isOnline) {
218222
console.log(chalk.yellow('You appear to be offline.'));
219223
console.log(chalk.yellow('Falling back to the local Yarn cache.'));
@@ -261,23 +265,19 @@ function run(
261265

262266
console.log('Installing packages. This might take a couple of minutes.');
263267
getPackageName(packageToInstall)
264-
.then(packageName =>
265-
checkIfOnline(useYarn).then(isOnline => ({
266-
isOnline: isOnline,
267-
packageName: packageName,
268-
}))
269-
)
268+
.then(packageName => checkIfOnline(useYarn).then(isOnline => ({
269+
isOnline: isOnline,
270+
packageName: packageName,
271+
})))
270272
.then(info => {
271273
const isOnline = info.isOnline;
272274
const packageName = info.packageName;
273275
console.log(
274-
`Installing ${chalk.cyan('react')}, ${chalk.cyan(
275-
'react-dom'
276-
)}, and ${chalk.cyan(packageName)}...`
276+
`Installing ${chalk.cyan('react')}, ${chalk.cyan('react-dom')}, and ${chalk.cyan(packageName)}...`
277277
);
278278
console.log();
279279

280-
return install(useYarn, allDependencies, verbose, isOnline).then(
280+
return install(root, useYarn, allDependencies, verbose, isOnline).then(
281281
() => packageName
282282
);
283283
})
@@ -341,9 +341,7 @@ function run(
341341
if (!remainingFiles.length) {
342342
// Delete target folder if empty
343343
console.log(
344-
`Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(
345-
path.resolve(root, '..')
346-
)}`
344+
`Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(path.resolve(root, '..'))}`
347345
);
348346
process.chdir(path.resolve(root, '..'));
349347
fs.removeSync(path.join(root));
@@ -431,9 +429,7 @@ function getPackageName(installPackage) {
431429
/^.+\/(.+?)(?:-\d+.+)?\.tgz$/
432430
)[1];
433431
console.log(
434-
`Based on the filename, assuming it is "${chalk.cyan(
435-
assumedProjectName
436-
)}"`
432+
`Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"`
437433
);
438434
return Promise.resolve(assumedProjectName);
439435
});
@@ -496,9 +492,7 @@ function checkAppName(appName) {
496492
const validationResult = validateProjectName(appName);
497493
if (!validationResult.validForNewPackages) {
498494
console.error(
499-
`Could not create a project called ${chalk.red(
500-
`"${appName}"`
501-
)} because of npm naming restrictions:`
495+
`Could not create a project called ${chalk.red(`"${appName}"`)} because of npm naming restrictions:`
502496
);
503497
printValidationResults(validationResult.errors);
504498
printValidationResults(validationResult.warnings);
@@ -510,9 +504,7 @@ function checkAppName(appName) {
510504
if (dependencies.indexOf(appName) >= 0) {
511505
console.error(
512506
chalk.red(
513-
`We cannot create a project called ${chalk.green(
514-
appName
515-
)} because a dependency with the same name exists.\n` +
507+
`We cannot create a project called ${chalk.green(appName)} because a dependency with the same name exists.\n` +
516508
`Due to the way npm works, the following names are not allowed:\n\n`
517509
) +
518510
chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) +
@@ -534,9 +526,7 @@ function makeCaretRange(dependencies, name) {
534526

535527
if (!semver.validRange(patchedVersion)) {
536528
console.error(
537-
`Unable to patch ${name} dependency version because version ${chalk.red(
538-
version
539-
)} will become invalid ${chalk.red(patchedVersion)}`
529+
`Unable to patch ${name} dependency version because version ${chalk.red(version)} will become invalid ${chalk.red(patchedVersion)}`
540530
);
541531
patchedVersion = version;
542532
}
@@ -606,6 +596,61 @@ function isSafeToCreateProjectIn(root, name) {
606596
return false;
607597
}
608598

599+
function checkThatNpmCanReadCwd() {
600+
const cwd = process.cwd();
601+
let childOutput = null;
602+
try {
603+
// Note: intentionally using spawn over exec since
604+
// the problem doesn't reproduce otherwise.
605+
// `npm config list` is the only reliable way I could find
606+
// to reproduce the wrong path. Just printing process.cwd()
607+
// in a Node process was not enough.
608+
childOutput = spawn.sync('npm', ['config', 'list']).output.join('');
609+
} catch (err) {
610+
// Something went wrong spawning node.
611+
// Not great, but it means we can't do this check.
612+
// We might fail later on, but let's continue.
613+
return true;
614+
}
615+
if (typeof childOutput !== 'string') {
616+
return true;
617+
}
618+
const lines = childOutput.split('\n');
619+
// `npm config list` output includes the following line:
620+
// "; cwd = C:\path\to\current\dir" (unquoted)
621+
// I couldn't find an easier way to get it.
622+
const prefix = '; cwd = ';
623+
const line = lines.find(line => line.indexOf(prefix) === 0);
624+
if (typeof line !== 'string') {
625+
// Fail gracefully. They could remove it.
626+
return true;
627+
}
628+
const npmCWD = line.substring(prefix.length);
629+
if (npmCWD === cwd) {
630+
return true;
631+
}
632+
console.error(
633+
chalk.red(
634+
`Could not start an npm process in the right directory.\n\n` +
635+
`The current directory is: ${chalk.bold(cwd)}\n` +
636+
`However, a newly started npm process runs in: ${chalk.bold(npmCWD)}\n\n` +
637+
`This is probably caused by a misconfigured system terminal shell.`
638+
)
639+
);
640+
if (process.platform === 'win32') {
641+
console.error(
642+
chalk.red(`On Windows, this can usually be fixed by running:\n\n`) +
643+
` ${chalk.cyan('reg')} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` +
644+
` ${chalk.cyan('reg')} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` +
645+
chalk.red(`Try to run the above two lines in the terminal.\n`) +
646+
chalk.red(
647+
`To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/`
648+
)
649+
);
650+
}
651+
return false;
652+
}
653+
609654
function checkIfOnline(useYarn) {
610655
if (!useYarn) {
611656
// Don't ping the Yarn registry.

0 commit comments

Comments
 (0)