Skip to content

merge official changes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Nov 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ca443ab
Enable compression on webpack-dev-server (#966) (#968)
frontsideair Oct 28, 2016
91c8650
Gently nudge users towards https by default (#974)
Swizec Oct 28, 2016
0bd593b
Catch and noop call to open web browser. (#964)
spadin Oct 28, 2016
a0efbeb
Add collectCoverageFrom option to collect coverage on files without a…
mackbyte Oct 28, 2016
fcda24e
Always build before deploying to gh-pages (#959)
dsernst Oct 28, 2016
8a5c50d
Fixes https://github.com/facebookincubator/create-react-app/issues/95…
vadzim Oct 28, 2016
7ce4b6e
Check for presence of folders before continuing eject. Closes #939. (…
heldinz Oct 28, 2016
6bda4b9
Remove custom babel-loader cache dir config (#983)
fson Oct 29, 2016
e3b6966
Allow webpack 2 as peerDependency in react-dev-utils (#963)
Oct 31, 2016
b855cc3
Add Gatsby to alternatives (#995)
KyleAMathews Oct 31, 2016
79160b8
Remove redundant `function` from export statement (#996)
gnowoel Nov 1, 2016
da1d534
Update babel-present-env and use node: 'current' as target (#1051)
valscion Nov 17, 2016
80fe767
Clears the usage of react-jsx-source & react-jsx-self (#992)
sathishsoundharajan Nov 17, 2016
4a7f78e
Remove unnecessary transform plugins for object spread to work (#1052)
valscion Nov 17, 2016
b9c9aed
Fix chrome tab reuse (#1035)
Nov 17, 2016
bcc469c
Support Yarn (#898)
fson Nov 17, 2016
bc4a12a
It's important after all
gaearon Nov 20, 2016
1668fb1
Add missing --dev argument (#1058)
nhajidin Nov 20, 2016
f4cb595
Update css loader (#1057)
nhajidin Nov 20, 2016
a5c30b9
Don't look for babelrc file during test (#1017)
nhajidin Nov 20, 2016
e14d2da
fix poor performance with firefox when using `eval` as `devtool` (#924)
ekaradon Nov 20, 2016
ff7e22e
Update GH deploy instructions to match User Guide
gaearon Nov 20, 2016
445048b
Move the remove-on-eject-end tag at the end of the file (#978)
EnoahNetzach Nov 20, 2016
8cf45e1
Add Storybook to the user guide (#738)
arunoda Nov 20, 2016
61b123d
Added info on using global variables. (#976)
jhorneman Nov 20, 2016
5f15e56
Remove "Defined Elsewhere" from the header
gaearon Nov 20, 2016
0a0ecab
Tweak wording
gaearon Nov 20, 2016
1ca4542
Add new guide topics to README
gaearon Nov 20, 2016
6fca0fe
No Configuration -> Convention over Configuration (#1031)
sheerun Nov 20, 2016
8edfcb5
Better GH Pages guide
gaearon Nov 20, 2016
1c622ec
Use url-loader with limit 10k as a default loader. (#1059)
bebbi Nov 20, 2016
29299f2
Adds to docs - deployment with S3/CloudFront (#1071)
wolovim Nov 20, 2016
e042634
Remove bundledDependencies (#1068)
fson Nov 21, 2016
058b2cc
exclude html from default loader. (#1075)
bebbi Nov 21, 2016
2da6eda
Replace rimraf with fs-extra functions (#1072)
existentialism Nov 21, 2016
7e9cb18
Upgrade Jest to 17.0 (#1078)
fson Nov 21, 2016
6e00813
Adapt jest and eslint for new default loader scope. (#1077)
bebbi Nov 21, 2016
9c45b25
Enable useBuiltIns option on object-rest-spread (#902)
existentialism Nov 21, 2016
05c3b55
add logging of existing default port process on start (#816)
ianmcnally Nov 22, 2016
66adb3e
Add a note for OSX users about watchman and jest (#1080)
dmr Nov 23, 2016
ab57f77
Add troubleshooting to main ToC
gaearon Nov 23, 2016
ce91819
Enable proxying of websockets (#1090)
dceddia Nov 23, 2016
dc6edce
Add support for non-interactive terminal (#1032)
sheerun Nov 23, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ cache:
- packages/create-react-app/node_modules
- packages/react-scripts/node_modules
script: tasks/e2e.sh
env:
- USE_YARN=no
- USE_YARN=yes
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ and then run `npm start` or `npm run build`.
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. It will bundle dependencies into a single tarball before publishing for faster installs. In the end the publish script will prompt for versions before publishing the packages.
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.

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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
- [Post-Processing CSS](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#post-processing-css)
- [Adding Images and Fonts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-images-and-fonts)
- [Using the `public` Folder](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-the-public-folder)
- [Using Global Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables)
- [Adding Bootstrap](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bootstrap)
- [Adding Flow](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-flow)
- [Adding Custom Environment Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables)
Expand All @@ -118,7 +119,9 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
- [Using HTTPS in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-https-in-development)
- [Generating Dynamic `<meta>` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server)
- [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
- [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation)
- [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment)
- [Troubleshooting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#troubleshooting)

A copy of the user guide will be created as `README.md` in your project folder.

Expand All @@ -130,7 +133,7 @@ Please refer to the [User Guide](https://github.com/facebookincubator/create-rea

* **One Dependency:** There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.

* **Zero Configuration:** There are no configuration files or command line options. Configuring both development and production builds is handled for you so you can focus on writing code.
* **Convention over Configuration:** You don't need to configure anything by default. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.

* **No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.

Expand Down Expand Up @@ -206,6 +209,7 @@ Some of the more popular and actively maintained ones are:
* [mozilla/neo](https://github.com/mozilla/neo)
* [NYTimes/kyt](https://github.com/NYTimes/kyt)
* [zeit/next.js](https://github.com/zeit/next.js)
* [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby)

Notable alternatives also include:

Expand Down
2 changes: 2 additions & 0 deletions packages/babel-preset-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ Then create a file named `.babelrc` with following contents in the root folder o
"presets": ["react-app"]
}
```

This preset uses the `useBuiltIns` option with [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](http://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled.
29 changes: 17 additions & 12 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ var path = require('path');
const plugins = [
// class { handleClick = () => { } }
require.resolve('babel-plugin-transform-class-properties'),
// The following two plugins use Object.assign directly, instead of Babel's
// extends helper. Note that this assumes `Object.assign` is available.
// { ...todo, completed: true }
require.resolve('babel-plugin-transform-object-rest-spread'),
[require.resolve('babel-plugin-transform-object-rest-spread'), {
useBuiltIns: true
}],
// Transforms JSX
[require.resolve('babel-plugin-transform-react-jsx'), {
useBuiltIns: true
}],
// function* () { yield 42; yield 43; }
[require.resolve('babel-plugin-transform-regenerator'), {
// Async functions are converted to generators by babel-preset-latest
Expand All @@ -27,15 +35,7 @@ const plugins = [
regenerator: true,
// Resolve the Babel runtime relative to the config.
moduleName: path.dirname(require.resolve('babel-runtime/package'))
}],
// The following two plugins are currently necessary to get
// babel-preset-env to work with rest/spread. More info here:
// https://github.com/babel/babel-preset-env#caveats
// https://github.com/babel/babel/issues/4074
// const { a, ...z } = obj;
require.resolve('babel-plugin-transform-es2015-destructuring'),
// const fn = ({ a, ...otherProps }) => otherProps;
require.resolve('babel-plugin-transform-es2015-parameters')
}]
];

// This is similar to how `env` works in Babel:
Expand All @@ -54,6 +54,12 @@ if (env !== 'development' && env !== 'test' && env !== 'production') {
}

if (env === 'development' || env === 'test') {
// The following two plugins are currently necessary to make React warnings
// include more valuable information. They are included here because they are
// currently not enabled in babel-preset-react. See the below threads for more info:
// https://github.com/babel/babel/issues/4702
// https://github.com/babel/babel/pull/3540#issuecomment-228673661
// https://github.com/facebookincubator/create-react-app/issues/989
plugins.push.apply(plugins, [
// Adds component stack to warning messages
require.resolve('babel-plugin-transform-react-jsx-source'),
Expand All @@ -68,7 +74,7 @@ if (env === 'test') {
// ES features necessary for user's Node version
[require('babel-preset-env').default, {
targets: {
node: parseFloat(process.versions.node),
node: 'current',
},
}],
// JSX, Flow
Expand Down Expand Up @@ -99,4 +105,3 @@ if (env === 'test') {
// ]);
}
}

7 changes: 3 additions & 4 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
],
"dependencies": {
"babel-plugin-transform-class-properties": "6.16.0",
"babel-plugin-transform-es2015-destructuring": "6.16.0",
"babel-plugin-transform-es2015-parameters": "6.17.0",
"babel-plugin-transform-object-rest-spread": "6.16.0",
"babel-plugin-transform-object-rest-spread": "6.19.0",
"babel-plugin-transform-react-constant-elements": "6.9.1",
"babel-plugin-transform-react-jsx": "6.8.0",
"babel-plugin-transform-react-jsx-self": "6.11.0",
"babel-plugin-transform-react-jsx-source": "6.9.0",
"babel-plugin-transform-regenerator": "6.16.1",
"babel-plugin-transform-runtime": "6.15.0",
"babel-preset-env": "0.0.6",
"babel-preset-env": "0.0.8",
"babel-preset-latest": "6.16.0",
"babel-preset-react": "6.16.0",
"babel-runtime": "6.11.6"
Expand Down
52 changes: 40 additions & 12 deletions packages/create-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,54 @@ function createApp(name, verbose, version) {
process.chdir(root);

console.log('Installing packages. This might take a couple minutes.');
console.log('Installing react-scripts from npm...');
console.log('Installing react-scripts...');
console.log();

run(root, appName, version, verbose, originalDirectory);
}

function run(root, appName, version, verbose, originalDirectory) {
var installPackage = getInstallPackage(version);
var packageName = getPackageName(installPackage);
function install(packageToInstall, verbose, callback) {
var args = [
'install',
verbose && '--verbose',
'--save-dev',
'--save-exact',
installPackage,
].filter(function(e) { return e; });
var proc = spawn('npm', args, {stdio: 'inherit'});
'add',
'--dev',
'--exact',
packageToInstall,
];
var proc = spawn('yarn', args, {stdio: 'inherit'});

var yarnExists = true;
proc.on('error', function (err) {
if (err.code === 'ENOENT') {
yarnExists = false;
}
});
proc.on('close', function (code) {
if (yarnExists) {
callback(code, 'yarn', args);
return;
}
// No Yarn installed, continuing with npm.
args = [
'install',
verbose && '--verbose',
'--save-dev',
'--save-exact',
packageToInstall,
].filter(function(e) { return e; });
var npmProc = spawn('npm', args, {stdio: 'inherit'});
npmProc.on('close', function (code) {
callback(code, 'npm', args);
});
});
}

function run(root, appName, version, verbose, originalDirectory) {
var packageToInstall = getInstallPackage(version);
var packageName = getPackageName(packageToInstall);

install(packageToInstall, verbose, function (code, command, args) {
if (code !== 0) {
console.error('`npm ' + args.join(' ') + '` failed');
console.error('`' + command + ' ' + args.join(' ') + '` failed');
return;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-config-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ module.exports = {

settings: {
'import/ignore': [
'node_modules',
'\\.(json|css|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$',
'node_modules'
],
'import/extensions': ['.js'],
'import/resolver': {
Expand Down
16 changes: 16 additions & 0 deletions packages/react-dev-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ compiler.plugin('done', function(stats) {
});
```

#### `getProcessForPort(port: number): string`

Finds the currently running process on `port`.
Returns a string containing the name and directory, e.g.,

```
create-react-app
in /Users/developer/create-react-app
```

```js
var getProcessForPort = require('react-dev-utils/getProcessForPort');

getProcessForPort(3000);
```

#### `openBrowser(url: string): boolean`

Attempts to open the browser with a given URL.
Expand Down
61 changes: 61 additions & 0 deletions packages/react-dev-utils/getProcessForPort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
var chalk = require('chalk');
var execSync = require('child_process').execSync;
var path = require('path');

var execOptions = {
encoding: 'utf8',
stdio: [
'pipe', // stdin (default)
'pipe', // stdout (default)
'ignore' //stderr
]
};

function isProcessAReactApp(processCommand) {
return /^node .*react-scripts\/scripts\/start\.js\s?$/.test(processCommand);
}

function getProcessIdOnPort(port) {
return execSync('lsof -i:' + port + ' -P -t -sTCP:LISTEN', execOptions).trim();
}

function getPackageNameInDirectory(directory) {
var packagePath = path.join(directory.trim(), 'package.json');

try {
return require(packagePath).name;
} catch(e) {
return null;
}

}

function getProcessCommand(processId, processDirectory) {
var command = execSync('ps -o command -p ' + processId + ' | sed -n 2p', execOptions);

if (isProcessAReactApp(command)) {
const packageName = getPackageNameInDirectory(processDirectory);
return (packageName) ? packageName + '\n' : command;
} else {
return command;
}

}

function getDirectoryOfProcessById(processId) {
return execSync('lsof -p '+ processId + ' | grep cwd | awk \'{print $9}\'', execOptions).trim();
}

function getProcessForPort(port) {
try {
var processId = getProcessIdOnPort(port);
var directory = getDirectoryOfProcessById(processId);
var command = getProcessCommand(processId, directory);
return chalk.cyan(command) + chalk.blue(' in ') + chalk.cyan(directory);
} catch(e) {
return null;
}
}

module.exports = getProcessForPort;

2 changes: 1 addition & 1 deletion packages/react-dev-utils/openBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function openBrowser(url) {
// Fallback to opn
// (It will always open new tab)
try {
opn(url);
opn(url).catch(() => {}); // Prevent `unhandledRejection` error.
return true;
} catch (err) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dev-utils/openChrome.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on run argv
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL is theURL then
if theTab's URL as string contains theURL then
set found to true
exit repeat
end if
Expand All @@ -38,6 +38,7 @@ on run argv
tell theTab to reload
set index of theWindow to 1
set theWindow's active tab index to theTabIndex
tell theWindow to activate
else
tell window 1
activate
Expand Down
4 changes: 1 addition & 3 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"clearConsole.js",
"checkRequiredFiles.js",
"formatWebpackMessages.js",
"getProcessForPort.js",
"InterpolateHtmlPlugin.js",
"openChrome.applescript",
"openBrowser.js",
Expand All @@ -29,8 +30,5 @@
"opn": "4.0.2",
"sockjs-client": "1.0.3",
"strip-ansi": "3.0.1"
},
"peerDependencies": {
"webpack": "^1.13.2"
}
}
3 changes: 2 additions & 1 deletion packages/react-scripts/config/jest/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
const babelJest = require('babel-jest');

module.exports = babelJest.createTransformer({
presets: [require.resolve('babel-preset-react-app')]
presets: [require.resolve('babel-preset-react-app')],
babelrc: false
});
5 changes: 4 additions & 1 deletion packages/react-scripts/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = {
appIndexJs: resolveApp('src/index.js'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.js'),
appNodeModules: resolveApp('node_modules'),
ownNodeModules: resolveApp('node_modules'),
Expand All @@ -62,13 +63,13 @@ module.exports = {
appIndexJs: resolveApp('src/index.js'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.js'),
appNodeModules: resolveApp('node_modules'),
// this is empty with npm3 but node resolution searches higher anyway:
ownNodeModules: resolveOwn('../node_modules'),
nodePaths: nodePaths
};
// @remove-on-eject-end

// config before publish: we're in ./packages/react-scripts/config/
if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) {
Expand All @@ -79,9 +80,11 @@ if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1)
appIndexJs: resolveOwn('../template/src/index.js'),
appPackageJson: resolveOwn('../package.json'),
appSrc: resolveOwn('../template/src'),
yarnLockFile: resolveOwn('../template/yarn.lock'),
testsSetup: resolveOwn('../template/src/setupTests.js'),
appNodeModules: resolveOwn('../node_modules'),
ownNodeModules: resolveOwn('../node_modules'),
nodePaths: nodePaths
};
}
// @remove-on-eject-end
Loading