Skip to content

Commit 706ab57

Browse files
committed
copied initial repo from create-react-app and added gitignore
0 parents  commit 706ab57

File tree

139 files changed

+6549
-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.

139 files changed

+6549
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.idea/
2+
.vscode/
3+
node_modules/
4+
build
5+
.DS_Store
6+
*.tgz
7+
my-app*
8+
template/src/__tests__/__snapshots__/
9+
lerna-debug.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
/.changelog
14+
.npm/
15+
yarn.lock

.npmignore

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

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2013-present, Facebook, Inc.
4+
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:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
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.

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/facebook/create-react-app).<br>
4+
Please refer to its documentation:
5+
6+
- [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
7+
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.

bin/react-scripts.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
// Makes the script crash on unhandled rejections instead of silently
12+
// ignoring them. In the future, promise rejections that are not handled will
13+
// terminate the Node.js process with a non-zero exit code.
14+
process.on('unhandledRejection', err => {
15+
throw err;
16+
});
17+
18+
const spawn = require('react-dev-utils/crossSpawn');
19+
const args = process.argv.slice(2);
20+
21+
const scriptIndex = args.findIndex(
22+
x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
23+
);
24+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
25+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
26+
27+
if (['build', 'eject', 'start', 'test'].includes(script)) {
28+
const result = spawn.sync(
29+
process.execPath,
30+
nodeArgs
31+
.concat(require.resolve('../scripts/' + script))
32+
.concat(args.slice(scriptIndex + 1)),
33+
{ stdio: 'inherit' }
34+
);
35+
if (result.signal) {
36+
if (result.signal === 'SIGKILL') {
37+
console.log(
38+
'The build failed because the process exited too early. ' +
39+
'This probably means the system ran out of memory or someone called ' +
40+
'`kill -9` on the process.'
41+
);
42+
} else if (result.signal === 'SIGTERM') {
43+
console.log(
44+
'The build failed because the process exited too early. ' +
45+
'Someone might have called `kill` or `killall`, or the system could ' +
46+
'be shutting down.'
47+
);
48+
}
49+
process.exit(1);
50+
}
51+
process.exit(result.status);
52+
} else {
53+
console.log('Unknown script "' + script + '".');
54+
console.log('Perhaps you need to update react-scripts?');
55+
console.log(
56+
'See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases'
57+
);
58+
}

config/env.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
// @remove-on-eject-end
9+
'use strict';
10+
11+
const fs = require('fs');
12+
const path = require('path');
13+
const paths = require('./paths');
14+
15+
// Make sure that including paths.js after env.js will read .env variables.
16+
delete require.cache[require.resolve('./paths')];
17+
18+
const NODE_ENV = process.env.NODE_ENV;
19+
if (!NODE_ENV) {
20+
throw new Error(
21+
'The NODE_ENV environment variable is required but was not specified.'
22+
);
23+
}
24+
25+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
26+
const dotenvFiles = [
27+
`${paths.dotenv}.${NODE_ENV}.local`,
28+
// Don't include `.env.local` for `test` environment
29+
// since normally you expect tests to produce the same
30+
// results for everyone
31+
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
32+
`${paths.dotenv}.${NODE_ENV}`,
33+
paths.dotenv,
34+
].filter(Boolean);
35+
36+
// Load environment variables from .env* files. Suppress warnings using silent
37+
// if this file is missing. dotenv will never modify any environment variables
38+
// that have already been set. Variable expansion is supported in .env files.
39+
// https://github.com/motdotla/dotenv
40+
// https://github.com/motdotla/dotenv-expand
41+
dotenvFiles.forEach(dotenvFile => {
42+
if (fs.existsSync(dotenvFile)) {
43+
require('dotenv-expand')(
44+
require('dotenv').config({
45+
path: dotenvFile,
46+
})
47+
);
48+
}
49+
});
50+
51+
// We support resolving modules according to `NODE_PATH`.
52+
// This lets you use absolute paths in imports inside large monorepos:
53+
// https://github.com/facebook/create-react-app/issues/253.
54+
// It works similar to `NODE_PATH` in Node itself:
55+
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
56+
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
57+
// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
58+
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
59+
// We also resolve them to make sure all tools using them work consistently.
60+
const appDirectory = fs.realpathSync(process.cwd());
61+
process.env.NODE_PATH = (process.env.NODE_PATH || '')
62+
.split(path.delimiter)
63+
.filter(folder => folder && !path.isAbsolute(folder))
64+
.map(folder => path.resolve(appDirectory, folder))
65+
.join(path.delimiter);
66+
67+
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
68+
// injected into the application via DefinePlugin in webpack configuration.
69+
const REACT_APP = /^REACT_APP_/i;
70+
71+
function getClientEnvironment(publicUrl) {
72+
const raw = Object.keys(process.env)
73+
.filter(key => REACT_APP.test(key))
74+
.reduce(
75+
(env, key) => {
76+
env[key] = process.env[key];
77+
return env;
78+
},
79+
{
80+
// Useful for determining whether we’re running in production mode.
81+
// Most importantly, it switches React into the correct mode.
82+
NODE_ENV: process.env.NODE_ENV || 'development',
83+
// Useful for resolving the correct path to static assets in `public`.
84+
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
85+
// This should only be used as an escape hatch. Normally you would put
86+
// images into the `src` and `import` them in code to get their paths.
87+
PUBLIC_URL: publicUrl,
88+
// We support configuring the sockjs pathname during development.
89+
// These settings let a developer run multiple simultaneous projects.
90+
// They are used as the connection `hostname`, `pathname` and `port`
91+
// in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
92+
// and `sockPort` options in webpack-dev-server.
93+
WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
94+
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
95+
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
96+
// Whether or not react-refresh is enabled.
97+
// react-refresh is not 100% stable at this time,
98+
// which is why it's disabled by default.
99+
// It is defined here so it is available in the webpackHotDevClient.
100+
FAST_REFRESH: process.env.FAST_REFRESH || false,
101+
}
102+
);
103+
// Stringify all values so we can feed into webpack DefinePlugin
104+
const stringified = {
105+
'process.env': Object.keys(raw).reduce((env, key) => {
106+
env[key] = JSON.stringify(raw[key]);
107+
return env;
108+
}, {}),
109+
};
110+
111+
return { raw, stringified };
112+
}
113+
114+
module.exports = getClientEnvironment;

config/getHttpsConfig.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
// @remove-on-eject-end
9+
'use strict';
10+
11+
const fs = require('fs');
12+
const path = require('path');
13+
const crypto = require('crypto');
14+
const chalk = require('react-dev-utils/chalk');
15+
const paths = require('./paths');
16+
17+
// Ensure the certificate and key provided are valid and if not
18+
// throw an easy to debug error
19+
function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
20+
let encrypted;
21+
try {
22+
// publicEncrypt will throw an error with an invalid cert
23+
encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
24+
} catch (err) {
25+
throw new Error(
26+
`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
27+
);
28+
}
29+
30+
try {
31+
// privateDecrypt will throw an error with an invalid key
32+
crypto.privateDecrypt(key, encrypted);
33+
} catch (err) {
34+
throw new Error(
35+
`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
36+
err.message
37+
}`
38+
);
39+
}
40+
}
41+
42+
// Read file and throw an error if it doesn't exist
43+
function readEnvFile(file, type) {
44+
if (!fs.existsSync(file)) {
45+
throw new Error(
46+
`You specified ${chalk.cyan(
47+
type
48+
)} in your env, but the file "${chalk.yellow(file)}" can't be found.`
49+
);
50+
}
51+
return fs.readFileSync(file);
52+
}
53+
54+
// Get the https config
55+
// Return cert files if provided in env, otherwise just true or false
56+
function getHttpsConfig() {
57+
const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
58+
const isHttps = HTTPS === 'true';
59+
60+
if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
61+
const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
62+
const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
63+
const config = {
64+
cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
65+
key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
66+
};
67+
68+
validateKeyAndCerts({ ...config, keyFile, crtFile });
69+
return config;
70+
}
71+
return isHttps;
72+
}
73+
74+
module.exports = getHttpsConfig;

config/jest/babelTransform.js

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

config/jest/cssTransform.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2014-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
// @remove-on-eject-end
9+
'use strict';
10+
11+
// This is a custom Jest transformer turning style imports into empty objects.
12+
// http://facebook.github.io/jest/docs/en/webpack.html
13+
14+
module.exports = {
15+
process() {
16+
return 'module.exports = {};';
17+
},
18+
getCacheKey() {
19+
// The output is always the same.
20+
return 'cssTransform';
21+
},
22+
};

config/jest/fileTransform.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const camelcase = require('camelcase');
5+
6+
// This is a custom Jest transformer turning file imports into filenames.
7+
// http://facebook.github.io/jest/docs/en/webpack.html
8+
9+
module.exports = {
10+
process(src, filename) {
11+
const assetFilename = JSON.stringify(path.basename(filename));
12+
13+
if (filename.match(/\.svg$/)) {
14+
// Based on how SVGR generates a component name:
15+
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16+
const pascalCaseFilename = camelcase(path.parse(filename).name, {
17+
pascalCase: true,
18+
});
19+
const componentName = `Svg${pascalCaseFilename}`;
20+
return `const React = require('react');
21+
module.exports = {
22+
__esModule: true,
23+
default: ${assetFilename},
24+
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25+
return {
26+
$$typeof: Symbol.for('react.element'),
27+
type: 'svg',
28+
ref: ref,
29+
key: null,
30+
props: Object.assign({}, props, {
31+
children: ${assetFilename}
32+
})
33+
};
34+
}),
35+
};`;
36+
}
37+
38+
return `module.exports = ${assetFilename};`;
39+
},
40+
};

0 commit comments

Comments
 (0)