-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
2,205 additions
and
1,461 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-react"], ["@babel/preset-env"] | ||
], | ||
"plugins": [ | ||
["@babel/plugin-transform-react-jsx", { "runtime": "automatic" }] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,66 @@ | ||
const fs = require("fs") | ||
const path = require("path") | ||
const crypto = require("crypto") | ||
const chalk = require("react-dev-utils/chalk") | ||
const paths = require("./paths") | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const crypto = require('crypto'); | ||
const chalk = require('react-dev-utils/chalk'); | ||
const paths = require('./paths'); | ||
|
||
// Ensure the certificate and key provided are valid and if not | ||
// throw an easy to debug error | ||
function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { | ||
let encrypted | ||
let encrypted; | ||
try { | ||
// publicEncrypt will throw an error with an invalid cert | ||
encrypted = crypto.publicEncrypt(cert, Buffer.from("test")) | ||
encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); | ||
} catch (err) { | ||
throw new Error(`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`) | ||
throw new Error( | ||
`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` | ||
); | ||
} | ||
|
||
try { | ||
// privateDecrypt will throw an error with an invalid key | ||
crypto.privateDecrypt(key, encrypted) | ||
crypto.privateDecrypt(key, encrypted); | ||
} catch (err) { | ||
throw new Error(`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${err.message}`) | ||
throw new Error( | ||
`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ | ||
err.message | ||
}` | ||
); | ||
} | ||
} | ||
|
||
// Read file and throw an error if it doesn't exist | ||
function readEnvFile(file, type) { | ||
if (!fs.existsSync(file)) { | ||
throw new Error( | ||
`You specified ${chalk.cyan(type)} in your env, but the file "${chalk.yellow(file)}" can't be found.` | ||
) | ||
`You specified ${chalk.cyan( | ||
type | ||
)} in your env, but the file "${chalk.yellow(file)}" can't be found.` | ||
); | ||
} | ||
return fs.readFileSync(file) | ||
return fs.readFileSync(file); | ||
} | ||
|
||
// Get the https config | ||
// Return cert files if provided in env, otherwise just true or false | ||
function getHttpsConfig() { | ||
const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env | ||
const isHttps = HTTPS === "true" | ||
const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; | ||
const isHttps = HTTPS === 'true'; | ||
|
||
if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { | ||
const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE) | ||
const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE) | ||
const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); | ||
const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); | ||
const config = { | ||
cert: readEnvFile(crtFile, "SSL_CRT_FILE"), | ||
key: readEnvFile(keyFile, "SSL_KEY_FILE"), | ||
} | ||
cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), | ||
key: readEnvFile(keyFile, 'SSL_KEY_FILE'), | ||
}; | ||
|
||
validateKeyAndCerts({ ...config, keyFile, crtFile }) | ||
return config | ||
validateKeyAndCerts({ ...config, keyFile, crtFile }); | ||
return config; | ||
} | ||
return isHttps | ||
return isHttps; | ||
} | ||
|
||
module.exports = getHttpsConfig | ||
module.exports = getHttpsConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
const babelJest = require("babel-jest") | ||
'use strict'; | ||
|
||
const babelJest = require('babel-jest').default; | ||
|
||
const hasJsxRuntime = (() => { | ||
if (process.env.DISABLE_NEW_JSX_TRANSFORM === "true") { | ||
return false | ||
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') { | ||
return false; | ||
} | ||
|
||
try { | ||
require.resolve("react/jsx-runtime") | ||
return true | ||
require.resolve('react/jsx-runtime'); | ||
return true; | ||
} catch (e) { | ||
return false | ||
return false; | ||
} | ||
})() | ||
})(); | ||
|
||
module.exports = babelJest.createTransformer({ | ||
presets: [ | ||
[ | ||
require.resolve("babel-preset-react-app"), | ||
require.resolve('babel-preset-react-app'), | ||
{ | ||
runtime: hasJsxRuntime ? "automatic" : "classic", | ||
runtime: hasJsxRuntime ? 'automatic' : 'classic', | ||
}, | ||
], | ||
], | ||
babelrc: false, | ||
configFile: false, | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
'use strict'; | ||
|
||
// This is a custom Jest transformer turning style imports into empty objects. | ||
// http://facebook.github.io/jest/docs/en/webpack.html | ||
|
||
module.exports = { | ||
process() { | ||
return "module.exports = {};" | ||
return 'module.exports = {};'; | ||
}, | ||
getCacheKey() { | ||
// The output is always the same. | ||
return "cssTransform" | ||
return 'cssTransform'; | ||
}, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.