Skip to content

Commit 7a69c31

Browse files
committed
initial commit
0 parents  commit 7a69c31

File tree

101 files changed

+5551
-0
lines changed

Some content is hidden

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

101 files changed

+5551
-0
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/fixtures

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# react-scripts
2+
3+
This package includes scripts and configuration used by [Create React App](https://github.com/facebookincubator/create-react-app).<br>
4+
Please refer to its documentation:
5+
6+
* [Getting Started](https://github.com/facebookincubator/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
7+
* [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.

babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react-app"]
3+
}

bin/react-scripts.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the BSD-style license found in the
7+
* LICENSE file in the root directory of this source tree. An additional grant
8+
* of patent rights can be found in the PATENTS file in the same directory.
9+
*/
10+
11+
'use strict';
12+
13+
var spawn = require('cross-spawn');
14+
var script = process.argv[2];
15+
var args = process.argv.slice(3);
16+
17+
switch (script) {
18+
case 'build':
19+
case 'eject':
20+
case 'start':
21+
case 'test':
22+
var result = spawn.sync(
23+
'node',
24+
[require.resolve('../scripts/' + script)].concat(args),
25+
{stdio: 'inherit'}
26+
);
27+
if (result.signal) {
28+
if (result.signal === 'SIGKILL') {
29+
console.log(
30+
'The build failed because the process exited too early. ' +
31+
'This probably means the system ran out of memory or someone called ' +
32+
'`kill -9` on the process.'
33+
);
34+
} else if (result.signal === 'SIGTERM') {
35+
console.log(
36+
'The build failed because the process exited too early. ' +
37+
'Someone might have called `kill` or `killall`, or the system could ' +
38+
'be shutting down.'
39+
);
40+
}
41+
process.exit(1);
42+
}
43+
process.exit(result.status);
44+
break;
45+
default:
46+
console.log('Unknown script "' + script + '".');
47+
console.log('Perhaps you need to update react-scripts?');
48+
console.log('See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases');
49+
break;
50+
}

config/env.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the BSD-style license found in the
7+
* LICENSE file in the root directory of this source tree. An additional grant
8+
* of patent rights can be found in the PATENTS file in the same directory.
9+
*/
10+
// @remove-on-eject-end
11+
'use strict';
12+
13+
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
14+
// injected into the application via DefinePlugin in Webpack configuration.
15+
16+
var REACT_APP = /^REACT_APP_/i;
17+
18+
function getClientEnvironment(publicUrl) {
19+
var raw = Object
20+
.keys(process.env)
21+
.filter(key => REACT_APP.test(key))
22+
.reduce((env, key) => {
23+
env[key] = process.env[key];
24+
return env;
25+
}, {
26+
// Useful for determining whether we’re running in production mode.
27+
// Most importantly, it switches React into the correct mode.
28+
'NODE_ENV': process.env.NODE_ENV || 'development',
29+
// Useful for resolving the correct path to static assets in `public`.
30+
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
31+
// This should only be used as an escape hatch. Normally you would put
32+
// images into the `src` and `import` them in code to get their paths.
33+
'PUBLIC_URL': publicUrl
34+
});
35+
// Stringify all values so we can feed into Webpack DefinePlugin
36+
var stringified = {
37+
'process.env': Object
38+
.keys(raw)
39+
.reduce((env, key) => {
40+
env[key] = JSON.stringify(raw[key]);
41+
return env;
42+
}, {})
43+
};
44+
45+
return { raw, stringified };
46+
}
47+
48+
module.exports = getClientEnvironment;

config/jest/babelTransform.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
3+
*
4+
* This source code is licensed under the BSD-style license found in the
5+
* LICENSE file in the root directory of this source tree. An additional grant
6+
* of patent rights can be found in the PATENTS file in the same directory.
7+
*/
8+
9+
'use strict';
10+
11+
const babelJest = require('babel-jest');
12+
13+
module.exports = babelJest.createTransformer({
14+
presets: [require.resolve('babel-preset-react-app')],
15+
babelrc: false
16+
});

config/jest/cssTransform.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2014-present, Facebook, Inc. 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+
// @remove-on-eject-end
10+
'use strict';
11+
12+
// This is a custom Jest transformer turning style imports into empty objects.
13+
// http://facebook.github.io/jest/docs/tutorial-webpack.html
14+
15+
module.exports = {
16+
process() {
17+
return 'module.exports = {};';
18+
},
19+
getCacheKey() {
20+
// The output is always the same.
21+
return 'cssTransform';
22+
},
23+
};

config/jest/fileTransform.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2014-present, Facebook, Inc. 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+
// @remove-on-eject-end
10+
'use strict';
11+
12+
const path = require('path');
13+
14+
// This is a custom Jest transformer turning file imports into filenames.
15+
// http://facebook.github.io/jest/docs/tutorial-webpack.html
16+
17+
module.exports = {
18+
process(src, filename) {
19+
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
20+
},
21+
};

config/paths.js

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the BSD-style license found in the
7+
* LICENSE file in the root directory of this source tree. An additional grant
8+
* of patent rights can be found in the PATENTS file in the same directory.
9+
*/
10+
// @remove-on-eject-end
11+
'use strict';
12+
13+
var path = require('path');
14+
var fs = require('fs');
15+
var url = require('url');
16+
17+
// Make sure any symlinks in the project folder are resolved:
18+
// https://github.com/facebookincubator/create-react-app/issues/637
19+
var appDirectory = fs.realpathSync(process.cwd());
20+
function resolveApp(relativePath) {
21+
return path.resolve(appDirectory, relativePath);
22+
}
23+
24+
// We support resolving modules according to `NODE_PATH`.
25+
// This lets you use absolute paths in imports inside large monorepos:
26+
// https://github.com/facebookincubator/create-react-app/issues/253.
27+
28+
// It works similar to `NODE_PATH` in Node itself:
29+
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
30+
31+
// We will export `nodePaths` as an array of absolute paths.
32+
// It will then be used by Webpack configs.
33+
// Jest doesn’t need this because it already handles `NODE_PATH` out of the box.
34+
35+
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
36+
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
37+
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
38+
39+
var nodePaths = (process.env.NODE_PATH || '')
40+
.split(process.platform === 'win32' ? ';' : ':')
41+
.filter(Boolean)
42+
.filter(folder => !path.isAbsolute(folder))
43+
.map(resolveApp);
44+
45+
var envPublicUrl = process.env.PUBLIC_URL;
46+
47+
function ensureSlash(path, needsSlash) {
48+
var hasSlash = path.endsWith('/');
49+
if (hasSlash && !needsSlash) {
50+
return path.substr(path, path.length - 1);
51+
} else if (!hasSlash && needsSlash) {
52+
return path + '/';
53+
} else {
54+
return path;
55+
}
56+
}
57+
58+
function getPublicUrl(appPackageJson) {
59+
return envPublicUrl || require(appPackageJson).homepage;
60+
}
61+
62+
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
63+
// "public path" at which the app is served.
64+
// Webpack needs to know it to put the right <script> hrefs into HTML even in
65+
// single-page apps that may serve index.html for nested URLs like /todos/42.
66+
// We can't use a relative path in HTML because we don't want to load something
67+
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
68+
function getServedPath(appPackageJson) {
69+
var publicUrl = getPublicUrl(appPackageJson);
70+
var servedUrl = envPublicUrl || (
71+
publicUrl ? url.parse(publicUrl).pathname : '/'
72+
);
73+
return ensureSlash(servedUrl, true);
74+
}
75+
76+
// config after eject: we're in ./config/
77+
module.exports = {
78+
appBuild: resolveApp('build'),
79+
appPublic: resolveApp('public'),
80+
appHtml: resolveApp('public/index.html'),
81+
appIndexJs: resolveApp('src/index.js'),
82+
appPackageJson: resolveApp('package.json'),
83+
appSrc: resolveApp('src'),
84+
yarnLockFile: resolveApp('yarn.lock'),
85+
testsSetup: resolveApp('src/setupTests.js'),
86+
appNodeModules: resolveApp('node_modules'),
87+
nodePaths: nodePaths,
88+
publicUrl: getPublicUrl(resolveApp('package.json')),
89+
servedPath: getServedPath(resolveApp('package.json'))
90+
};
91+
92+
// @remove-on-eject-begin
93+
function resolveOwn(relativePath) {
94+
return path.resolve(__dirname, '..', relativePath);
95+
}
96+
97+
// config before eject: we're in ./node_modules/react-scripts/config/
98+
module.exports = {
99+
appPath: resolveApp('.'),
100+
appBuild: resolveApp('build'),
101+
appPublic: resolveApp('public'),
102+
appHtml: resolveApp('public/index.html'),
103+
appIndexJs: resolveApp('src/index.js'),
104+
appPackageJson: resolveApp('package.json'),
105+
appSrc: resolveApp('src'),
106+
yarnLockFile: resolveApp('yarn.lock'),
107+
testsSetup: resolveApp('src/setupTests.js'),
108+
appNodeModules: resolveApp('node_modules'),
109+
nodePaths: nodePaths,
110+
publicUrl: getPublicUrl(resolveApp('package.json')),
111+
servedPath: getServedPath(resolveApp('package.json')),
112+
// These properties only exist before ejecting:
113+
ownPath: resolveOwn('.'),
114+
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
115+
};
116+
117+
var ownPackageJson = require('../package.json');
118+
var reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
119+
var reactScriptsLinked = fs.existsSync(reactScriptsPath) && fs.lstatSync(reactScriptsPath).isSymbolicLink();
120+
121+
// config before publish: we're in ./packages/react-scripts/config/
122+
if (!reactScriptsLinked && __dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) {
123+
module.exports = {
124+
appPath: resolveApp('.'),
125+
appBuild: resolveOwn('../../build'),
126+
appPublic: resolveOwn('template/public'),
127+
appHtml: resolveOwn('template/public/index.html'),
128+
appIndexJs: resolveOwn('template/src/index.js'),
129+
appPackageJson: resolveOwn('package.json'),
130+
appSrc: resolveOwn('template/src'),
131+
yarnLockFile: resolveOwn('template/yarn.lock'),
132+
testsSetup: resolveOwn('template/src/setupTests.js'),
133+
appNodeModules: resolveOwn('node_modules'),
134+
nodePaths: nodePaths,
135+
publicUrl: getPublicUrl(resolveOwn('package.json')),
136+
servedPath: getServedPath(resolveOwn('package.json')),
137+
// These properties only exist before ejecting:
138+
ownPath: resolveOwn('.'),
139+
ownNodeModules: resolveOwn('node_modules'),
140+
};
141+
}
142+
// @remove-on-eject-end

config/polyfills.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the BSD-style license found in the
7+
* LICENSE file in the root directory of this source tree. An additional grant
8+
* of patent rights can be found in the PATENTS file in the same directory.
9+
*/
10+
// @remove-on-eject-end
11+
'use strict';
12+
13+
if (typeof Promise === 'undefined') {
14+
// Rejection tracking prevents a common issue where React gets into an
15+
// inconsistent state due to an error, but it gets swallowed by a Promise,
16+
// and the user has no idea what causes React's erratic future behavior.
17+
require('promise/lib/rejection-tracking').enable();
18+
window.Promise = require('promise/lib/es6-extensions.js');
19+
}
20+
21+
// fetch() polyfill for making API calls.
22+
require('whatwg-fetch');
23+
24+
// Object.assign() is commonly used with React.
25+
// It will use the native implementation if it's present and isn't buggy.
26+
Object.assign = require('object-assign');

0 commit comments

Comments
 (0)