Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 707ffe2

Browse filesBrowse files
committed
# Conflicts: # .gitignore # packages/babel-preset-react-app/package.json # packages/create-react-app/package.json # packages/eslint-config-react-app/package.json # packages/react-dev-utils/package.json # packages/react-scripts/config/webpack.config.dev.js # packages/react-scripts/config/webpack.config.prod.js # packages/react-scripts/package.json # packages/react-scripts/utils/createJestConfig.js
2 parents d71ef77 + 3a67987 commit 707ffe2
Copy full SHA for 707ffe2

33 files changed

+955
-213
lines changed

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ my-app*
66
template/src/__tests__/__snapshots__/
77
lerna-debug.log
88
npm-debug.log
9+
/.changelog
10+
911
.idea

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
language: node_js
33
node_js:
4+
- 0.10
45
- 4
56
- 6
67
cache:

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+394Lines changed: 394 additions & 0 deletions
Large diffs are not rendered by default.

‎CONTRIBUTING.md

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ and then run `npm start` or `npm run build`.
6060

6161
## Cutting a Release
6262

63-
1. Tag all merged PRs that go into the release with the relevant milestone.
63+
1. Tag all merged pull requests that go into the release with the relevant milestone. Each merged PR should also be labeled with one of the [labels](https://github.com/facebookincubator/create-react-app/labels) named `tag: ...` to indicate what kind of change it is.
6464
2. Close the milestone.
6565
3. In most releases, only `react-scripts` needs to be released. If you don’t have any changes to the `packages/create-react-app` folder, you don’t need to bump its version or publish it (the publish script will publish only changed packages).
6666
4. Note that files in `packages/create-react-app` should be modified with extreme caution. Since it’s a global CLI, any version of `create-react-app` (global CLI) including very old ones should work with the latest version of `react-scripts`.
67-
5. Add an entry to `CHANGELOG.md` detailing what has changed with links to PRs and their authors. Use previous entries for inspiration. Group changes to `react-scripts` and `create-react-app` separately in the notes, for example like in `0.2.0` release notes.
67+
5. Create a change log entry for the release:
68+
* You'll need an [access token for the GitHub API](https://help.github.com/articles/creating-an-access-token-for-command-line-use/). Save it to this environment variable: `export GITHUB_AUTH="..."`
69+
* Run `npm run changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
70+
* 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.
6871
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
6972
7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration.
7073
8. **Do not run `npm publish`. Instead, run `npm run publish`.**

‎README.md

Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
102102
- [Updating to New Releases](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases)
103103
- [Folder Structure](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#folder-structure)
104104
- [Available Scripts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#available-scripts)
105+
- [Syntax Highlighting in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#syntax-highlighting-in-the-editor)
105106
- [Displaying Lint Output in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor)
106107
- [Installing a Dependency](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#installing-a-dependency)
107108
- [Importing a Component](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#importing-a-component)

‎lerna.json

Copy file name to clipboard
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{
22
"lerna": "2.0.0-beta.30",
3-
"version": "independent"
3+
"version": "independent",
4+
"changelog": {
5+
"repo": "facebookincubator/create-react-app",
6+
"labels": {
7+
"tag: new feature": ":rocket: New Feature",
8+
"tag: breaking change": ":boom: Breaking Change",
9+
"tag: bug fix": ":bug: Bug Fix",
10+
"tag: enhancement": ":nail_care: Enhancement",
11+
"tag: documentation": ":memo: Documentation",
12+
"tag: internal": ":house: Internal"
13+
},
14+
"cacheDir": ".changelog"
15+
}
416
}

‎package.json

Copy file name to clipboardExpand all lines: package.json
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"private": true,
33
"scripts": {
44
"build": "node packages/react-scripts/scripts/build.js",
5+
"changelog": "lerna-changelog",
56
"create-react-app": "tasks/cra.sh",
67
"e2e": "tasks/e2e.sh",
78
"postinstall": "lerna bootstrap",
@@ -19,6 +20,7 @@
1920
"eslint-plugin-import": "1.12.0",
2021
"eslint-plugin-jsx-a11y": "2.2.2",
2122
"eslint-plugin-react": "6.3.0",
22-
"lerna": "2.0.0-beta.30"
23+
"lerna": "2.0.0-beta.30",
24+
"lerna-changelog": "^0.2.3"
2325
}
2426
}

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

Copy file name to clipboardExpand all lines: packages/babel-preset-react-app/index.js
+35-27Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,27 @@
1111
var path = require('path');
1212

1313
const plugins = [
14-
// class { handleClick = () => { } }
15-
require.resolve('babel-plugin-transform-class-properties'),
16-
// The following two plugins use Object.assign directly, instead of Babel's
17-
// extends helper. Note that this assumes `Object.assign` is available.
18-
// { ...todo, completed: true }
19-
[require.resolve('babel-plugin-transform-object-rest-spread'), {
20-
useBuiltIns: true
21-
}],
22-
// Transforms JSX
23-
[require.resolve('babel-plugin-transform-react-jsx'), {
24-
useBuiltIns: true
25-
}],
26-
// function* () { yield 42; yield 43; }
27-
[require.resolve('babel-plugin-transform-regenerator'), {
28-
// Async functions are converted to generators by babel-preset-latest
29-
async: false
30-
}],
31-
// Polyfills the runtime needed for async/await and generators
32-
[require.resolve('babel-plugin-transform-runtime'), {
33-
helpers: false,
34-
polyfill: false,
35-
regenerator: true,
36-
// Resolve the Babel runtime relative to the config.
37-
moduleName: path.dirname(require.resolve('babel-runtime/package'))
38-
}]
39-
];
14+
// class { handleClick = () => { } }
15+
require.resolve('babel-plugin-transform-class-properties'),
16+
// The following two plugins use Object.assign directly, instead of Babel's
17+
// extends helper. Note that this assumes `Object.assign` is available.
18+
// { ...todo, completed: true }
19+
[require.resolve('babel-plugin-transform-object-rest-spread'), {
20+
useBuiltIns: true
21+
}],
22+
// Transforms JSX
23+
[require.resolve('babel-plugin-transform-react-jsx'), {
24+
useBuiltIns: true
25+
}],
26+
// Polyfills the runtime needed for async/await and generators
27+
[require.resolve('babel-plugin-transform-runtime'), {
28+
helpers: false,
29+
polyfill: false,
30+
regenerator: true,
31+
// Resolve the Babel runtime relative to the config.
32+
moduleName: path.dirname(require.resolve('babel-runtime/package'))
33+
}]
34+
];
4035

4136
// This is similar to how `env` works in Babel:
4237
// https://babeljs.io/docs/usage/babelrc/#env-option
@@ -69,6 +64,13 @@ if (env === 'development' || env === 'test') {
6964
}
7065

7166
if (env === 'test') {
67+
plugins.push.apply(plugins, [
68+
// We always include this plugin regardless of environment
69+
// because of a Babel bug that breaks object rest/spread without it:
70+
// https://github.com/babel/babel/issues/4851
71+
require.resolve('babel-plugin-transform-es2015-parameters')
72+
]);
73+
7274
module.exports = {
7375
presets: [
7476
// ES features necessary for user's Node version
@@ -90,7 +92,13 @@ if (env === 'test') {
9092
// JSX, Flow
9193
require.resolve('babel-preset-react')
9294
],
93-
plugins: plugins
95+
plugins: plugins.concat([
96+
// function* () { yield 42; yield 43; }
97+
[require.resolve('babel-plugin-transform-regenerator'), {
98+
// Async functions are converted to generators by babel-preset-latest
99+
async: false
100+
}],
101+
])
94102
};
95103

96104
if (env === 'production') {

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

Copy file name to clipboardExpand all lines: packages/babel-preset-react-app/package.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "babel-preset-react-app",
3+
"version": "2.0.1",
34
"private": true,
45
"version": "1.0.0",
56
"description": "Babel preset used by Create React App",
@@ -13,6 +14,7 @@
1314
],
1415
"dependencies": {
1516
"babel-plugin-transform-class-properties": "6.16.0",
17+
"babel-plugin-transform-es2015-parameters": "6.18.0",
1618
"babel-plugin-transform-object-rest-spread": "6.19.0",
1719
"babel-plugin-transform-react-constant-elements": "6.9.1",
1820
"babel-plugin-transform-react-jsx": "6.8.0",

‎packages/create-react-app/index.js

Copy file name to clipboardExpand all lines: packages/create-react-app/index.js
+87-62Lines changed: 87 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,65 @@
3838

3939
'use strict';
4040

41+
var chalk = require('chalk');
42+
43+
var currentNodeVersion = process.versions.node
44+
if (currentNodeVersion.split('.')[0] < 4) {
45+
console.error(
46+
chalk.red(
47+
'You are running Node ' + currentNodeVersion + '.\n' +
48+
'Create React App requires Node 4 or higher. \n' +
49+
'Please update your version of Node.'
50+
)
51+
);
52+
process.exit(1);
53+
}
54+
4155
var fs = require('fs');
4256
var path = require('path');
57+
var execSync = require('child_process').execSync;
4358
var spawn = require('cross-spawn');
44-
var chalk = require('chalk');
4559
var semver = require('semver');
46-
var argv = require('minimist')(process.argv.slice(2));
4760
var pathExists = require('path-exists');
4861

49-
/**
50-
* Arguments:
51-
* --version - to print current version
52-
* --verbose - to print logs while init
53-
* --scripts-version <alternative package>
54-
* Example of valid values:
55-
* - a specific npm version: "0.22.0-rc1"
56-
* - a .tgz archive from any npm repo: "https://registry.npmjs.org/react-scripts/-/react-scripts-0.20.0.tgz"
57-
* - a package prepared with `tasks/clean_pack.sh`: "/Users/home/vjeux/create-react-app/react-scripts-0.22.0.tgz"
58-
*/
59-
var commands = argv._;
60-
if (commands.length === 0) {
61-
if (argv.version) {
62-
console.log('create-react-app version: ' + require('./package.json').version);
63-
process.exit();
64-
}
65-
console.error(
66-
'Usage: create-react-app <project-directory> [--verbose]'
67-
);
62+
var projectName;
63+
64+
var program = require('commander')
65+
.version(require('./package.json').version)
66+
.arguments('<project-directory>')
67+
.usage(chalk.green('<project-directory>') + ' [options]')
68+
.action(function (name) {
69+
projectName = name;
70+
})
71+
.option('--verbose', 'print additional logs')
72+
.option('--scripts-version <alternative-package>', 'use a non-standard version of react-scripts')
73+
.on('--help', function () {
74+
console.log(' Only ' + chalk.green('<project-directory>') + ' is required.');
75+
console.log();
76+
console.log(' A custom ' + chalk.cyan('--scripts-version') + ' can be one of:');
77+
console.log(' - a specific npm version: ' + chalk.green('0.8.2'));
78+
console.log(' - a custom fork published on npm: ' + chalk.green('my-react-scripts'));
79+
console.log(' - a .tgz archive: ' + chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz'));
80+
console.log(' It is not needed unless you specifically want to use a fork.');
81+
console.log();
82+
console.log(' If you have any problems, do not hesitate to file an issue:');
83+
console.log(' ' + chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new'));
84+
console.log();
85+
})
86+
.parse(process.argv)
87+
88+
if (typeof projectName === 'undefined') {
89+
console.error('Please specify the project directory:');
90+
console.log(' ' + chalk.cyan(program.name()) + chalk.green(' <project-directory>'));
91+
console.log();
92+
console.log('For example:');
93+
console.log(' ' + chalk.cyan(program.name()) + chalk.green(' my-react-app'));
94+
console.log();
95+
console.log('Run ' + chalk.cyan(program.name() + ' --help') + ' to see all options.');
6896
process.exit(1);
6997
}
7098

71-
createApp(commands[0], argv.verbose, argv['scripts-version']);
99+
createApp(projectName, program.verbose, program.scriptsVersion);
72100

73101
function createApp(name, verbose, version) {
74102
var root = path.resolve(name);
@@ -79,12 +107,13 @@ function createApp(name, verbose, version) {
79107
if (!pathExists.sync(name)) {
80108
fs.mkdirSync(root);
81109
} else if (!isSafeToCreateProjectIn(root)) {
82-
console.log('The directory `' + name + '` contains file(s) that could conflict. Aborting.');
110+
console.log('The directory ' + chalk.green(name) + ' contains files that could conflict.');
111+
console.log('Try using a new directory name.');
83112
process.exit(1);
84113
}
85114

86115
console.log(
87-
'Creating a new React app in ' + root + '.'
116+
'Creating a new React app in ' + chalk.green(root) + '.'
88117
);
89118
console.log();
90119

@@ -101,55 +130,50 @@ function createApp(name, verbose, version) {
101130
process.chdir(root);
102131

103132
console.log('Installing packages. This might take a couple minutes.');
104-
console.log('Installing react-scripts...');
133+
console.log('Installing ' + chalk.cyan('react-scripts') + '...');
105134
console.log();
106135

107136
run(root, appName, version, verbose, originalDirectory);
108137
}
109138

139+
function shouldUseYarn() {
140+
try {
141+
execSync('yarn --version', {stdio: 'ignore'});
142+
return true;
143+
} catch (e) {
144+
return false;
145+
}
146+
}
147+
110148
function install(packageToInstall, verbose, callback) {
111-
var args = [
112-
'add',
113-
'--dev',
114-
'--exact',
115-
packageToInstall,
116-
];
117-
var proc = spawn('yarn', args, {stdio: 'inherit'});
149+
var command;
150+
var args;
151+
if (shouldUseYarn()) {
152+
command = 'yarn';
153+
args = [ 'add', '--dev', '--exact', packageToInstall];
154+
} else {
155+
command = 'npm';
156+
args = ['install', '--save-dev', '--save-exact', packageToInstall];
157+
}
118158

119-
var yarnExists = true;
120-
proc.on('error', function (err) {
121-
if (err.code === 'ENOENT') {
122-
yarnExists = false;
123-
}
124-
});
125-
proc.on('close', function (code) {
126-
if (yarnExists) {
127-
callback(code, 'yarn', args);
128-
return;
129-
}
130-
// No Yarn installed, continuing with npm.
131-
args = [
132-
'install',
133-
verbose && '--verbose',
134-
'--save-dev',
135-
'--save-exact',
136-
packageToInstall,
137-
].filter(function(e) { return e; });
138-
var npmProc = spawn('npm', args, {stdio: 'inherit'});
139-
npmProc.on('close', function (code) {
140-
callback(code, 'npm', args);
141-
});
159+
if (verbose) {
160+
args.push('--verbose');
161+
}
162+
163+
var child = spawn(command, args, {stdio: 'inherit'});
164+
child.on('close', function(code) {
165+
callback(code, command, args);
142166
});
143167
}
144168

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

149-
install(packageToInstall, verbose, function (code, command, args) {
173+
install(packageToInstall, verbose, function(code, command, args) {
150174
if (code !== 0) {
151-
console.error('`' + command + ' ' + args.join(' ') + '` failed');
152-
return;
175+
console.error(chalk.cyan(command + ' ' + args.join(' ')) + ' failed');
176+
process.exit(1);
153177
}
154178

155179
checkNodeVersion(packageName);
@@ -182,7 +206,7 @@ function getInstallPackage(version) {
182206
function getPackageName(installPackage) {
183207
if (installPackage.indexOf('.tgz') > -1) {
184208
// The package name could be with or without semver version, e.g. react-scripts-0.2.0-alpha.1.tgz
185-
// However, this function returns package name only wihout semver version.
209+
// However, this function returns package name only without semver version.
186210
return installPackage.match(/^.+\/(.+?)(?:-\d+.+)?\.tgz$/)[1];
187211
} else if (installPackage.indexOf('@') > 0) {
188212
// Do not match @scope/ when stripping off @version or @tag
@@ -206,8 +230,9 @@ function checkNodeVersion(packageName) {
206230
if (!semver.satisfies(process.version, packageJson.engines.node)) {
207231
console.error(
208232
chalk.red(
209-
'You are currently running Node %s but create-react-app requires %s.' +
210-
' Please use a supported version of Node.\n'
233+
'You are running Node %s.\n' +
234+
'Create React App requires Node %s or higher. \n' +
235+
'Please update your version of Node.'
211236
),
212237
process.version,
213238
packageJson.engines.node
@@ -225,7 +250,7 @@ function checkAppName(appName) {
225250
if (allDependencies.indexOf(appName) >= 0) {
226251
console.error(
227252
chalk.red(
228-
'We cannot create a project called `' + appName + '` because a dependency with the same name exists.\n' +
253+
'We cannot create a project called ' + chalk.green(appName) + ' because a dependency with the same name exists.\n' +
229254
'Due to the way npm works, the following names are not allowed:\n\n'
230255
) +
231256
chalk.cyan(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.