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

Commit 614b2db

Browse files
committed
random fixes + license
1 parent 760d32e commit 614b2db

File tree

8 files changed

+115
-99
lines changed

8 files changed

+115
-99
lines changed

global-cli/index.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* of patent rights can be found in the PATENTS file in the same directory.
1010
*/
1111

12-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13-
// /!\ DO NOT MODIFY THIS FILE /!\
14-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
// /!\ DO NOT MODIFY THIS FILE /!\
14+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515
//
1616
// create-react-app is installed globally on people's computers. This means
1717
// that it is extremely difficult to have them upgrade the version and
@@ -21,17 +21,17 @@
2121
// The only job of create-react-app is to init the repository and then
2222
// forward all the commands to the local version of create-react-app.
2323
//
24-
// If you need to add a new command, please add it to local-cli/.
24+
// If you need to add a new command, please add it to the scripts/ folder.
2525
//
2626
// The only reason to modify this file is to add more warnings and
27-
// troubleshooting information for the `react init` command.
27+
// troubleshooting information for the `create-react-app` command.
2828
//
2929
// Do not make breaking changes! We absolutely don't want to have to
3030
// tell people to update their global version of create-react-app.
3131
//
32-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33-
// /!\ DO NOT MODIFY THIS FILE /!\
34-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33+
// /!\ DO NOT MODIFY THIS FILE /!\
34+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3535

3636
'use strict';
3737

@@ -40,18 +40,18 @@ var path = require('path');
4040
var spawn = require('child_process').spawn;
4141
var chalk = require('chalk');
4242
var semver = require('semver');
43+
var argv = require('minimist')(process.argv.slice(2));
44+
4345
/**
44-
* Used arguments:
45-
* -v --version - to print current version of create-react-app and create-react-app-scripts dependency
46+
* Arguments:
47+
* --version - to print current version
4648
* --verbose - to print logs while init
47-
* --scripts-version <alternative create-react-app-scripts package> - override default (https://registry.npmjs.org/create-react-app-scripts@latest),
48-
* package to install, examples:
49-
* - "0.22.0-rc1" - A new app will be created using a specific version of React CLI from npm repo
50-
* - "https://registry.npmjs.org/create-react-app-scripts/-/create-react-app-scripts-0.20.0.tgz" - a .tgz archive from any npm repo
51-
* - "/Users/home/create-react-app/create-react-app-scripts-0.22.0.tgz" - for package prepared with `npm pack`, useful for e2e tests
49+
* --scripts-version <alternative package>
50+
* Example of valid values:
51+
* - a specific npm version: "0.22.0-rc1"
52+
* - a .tgz archive from any npm repo: "https://registry.npmjs.org/create-react-app-scripts/-/create-react-app-scripts-0.20.0.tgz"
53+
* - a package prepared with `npm pack`: "/Users/home/vjeux/create-react-app/create-react-app-scripts-0.22.0.tgz"
5254
*/
53-
var argv = require('minimist')(process.argv.slice(2));
54-
5555
var commands = argv._;
5656
if (commands.length === 0) {
5757
console.error(
@@ -60,8 +60,8 @@ if (commands.length === 0) {
6060
process.exit(1);
6161
}
6262

63-
if (argv.v || argv.version) {
64-
console.log('create-react-app: ' + require('./package.json').version);
63+
if (argv.version) {
64+
console.log('create-react-app version: ' + require('./package.json').version);
6565
process.exit();
6666
}
6767

@@ -70,7 +70,7 @@ createApp(commands[0], argv.verbose, argv['scripts-version']);
7070
function createApp(name, verbose, version) {
7171
if (fs.existsSync(name)) {
7272
console.log('Directory `' + name + '` already exists. Aborting.');
73-
process.exit();
73+
process.exit(1);
7474
}
7575

7676
var root = path.resolve(name);
@@ -146,11 +146,12 @@ function checkNodeVersion() {
146146
if (!packageJson.engines || !packageJson.engines.node) {
147147
return;
148148
}
149+
149150
if (!semver.satisfies(process.version, packageJson.engines.node)) {
150151
console.error(
151152
chalk.red(
152-
'You are currently running Node %s but React CLI requires %s. ' +
153-
'Please use a supported version of Node.\n'
153+
'You are currently running Node %s but create-react-app requires %s.' +
154+
' Please use a supported version of Node.\n'
154155
),
155156
process.version,
156157
packageJson.engines.node

scripts/build.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
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.
8+
*/
9+
110
process.env.NODE_ENV = 'production';
211

312
var spawnSync = require('child_process').spawnSync;

scripts/export-scripts.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

scripts/graduate.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
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.
8+
*/
9+
10+
var fs = require('fs');
11+
12+
console.log('Extracting scripts...');
13+
14+
var hostPath = __dirname;
15+
var selfPath = hostPath + '/node_modules/create-react-app-scripts';
16+
17+
var files = [
18+
'scripts',
19+
'.webpack.config.dev.js',
20+
'.webpack.config.prod.js',
21+
'.babelrc',
22+
'.eslintrc',
23+
];
24+
25+
// Ensure that the host folder is clean and we won't override any files
26+
files.forEach(function(file) {
27+
if (fs.existsSync(hostPath + '/' + file)) {
28+
console.error(
29+
'`' + file + '` already exists on your app folder, we cannot ' +
30+
'continue as you would lose all the changes in that file.',
31+
'Please delete it (maybe make a copy for backup) and run this ' +
32+
'command again.'
33+
);
34+
process.exit(1);
35+
}
36+
});
37+
38+
// Move the files over
39+
files.forEach(function(file) {
40+
fs.renameSync(selfPath + '/' + file, hostPath + '/' + file);
41+
});
42+
43+
var hostPackage = require(hostPath + '/package.json');
44+
45+
console.log('Done!');

scripts/init.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
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.
8+
*/
9+
110
var fs = require('fs');
211

312
module.exports = function(hostPath, appName) {
@@ -15,7 +24,8 @@ module.exports = function(hostPath, appName) {
1524
// Setup the script rules
1625
hostPackage.scripts = {};
1726
['start', 'build'].forEach(function(command) {
18-
hostPackage.scripts[command] = 'node node_modules/create-react-app-scripts/scripts/' + command + '.js';
27+
hostPackage.scripts[command] =
28+
'node node_modules/create-react-app-scripts/scripts/' + command + '.js';
1929
});
2030

2131
fs.writeFileSync(hostPath + '/package.json', JSON.stringify(hostPackage, null, 2));

scripts/start.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
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.
8+
*/
9+
110
process.env.NODE_ENV = 'development';
211

312
var webpack = require('webpack');

webpack.config.dev.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
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.
8+
*/
9+
110
var path = require('path');
211
var autoprefixer = require('autoprefixer');
312
var webpack = require('webpack');

webpack.config.prod.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
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.
8+
*/
9+
110
var path = require('path');
211
var autoprefixer = require('autoprefixer');
312
var webpack = require('webpack');

0 commit comments

Comments
 (0)