Skip to content

🎥 Make videos programmatically with React

remove stuff

Jonny Burger6a3ad968b1f7
diff --git a/packages/player-example/config/getHttpsConfig.js b/packages/player-example/config/getHttpsConfig.js
deleted file mode 100644
index 8f9d4f2236..0000000000
--- a/packages/player-example/config/getHttpsConfig.js
+++ /dev/null
@@ -1,66 +0,0 @@
-'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;
- try {
- // PublicEncrypt will throw an error with an invalid cert
- encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
- } catch (err) {
- 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);
- } catch (err) {
- 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.`
- );
- }
- 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';
-
- 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 config = {
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
- };
-
- validateKeyAndCerts({ ...config, keyFile, crtFile });
- return config;
- }
- return isHttps;
-}
-
-module.exports = getHttpsConfig;
diff --git a/packages/player-example/config/paths.js b/packages/player-example/config/paths.js
index ab3be8052b..1ffcda8fd6 100644
--- a/packages/player-example/config/paths.js
+++ b/packages/player-example/config/paths.js
@@ -7,7 +7,7 @@ const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
-const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
+const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
// "public path" at which the app is served.
@@ -16,62 +16,55 @@ const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
// We can't use a relative path in HTML because we don't want to load something
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
const publicUrlOrPath = getPublicUrlOrPath(
- process.env.NODE_ENV === 'development',
- require(resolveApp('package.json')).homepage,
- process.env.PUBLIC_URL
+ process.env.NODE_ENV === 'development',
+ require(resolveApp('package.json')).homepage,
+ process.env.PUBLIC_URL
);
const buildPath = process.env.BUILD_PATH || 'build';
const moduleFileExtensions = [
- 'web.mjs',
- 'mjs',
- 'web.js',
- 'js',
- 'web.ts',
- 'ts',
- 'web.tsx',
- 'tsx',
- 'json',
- 'web.jsx',
- 'jsx',
+ 'web.mjs',
+ 'mjs',
+ 'web.js',
+ 'js',
+ 'web.ts',
+ 'ts',
+ 'web.tsx',
+ 'tsx',
+ 'json',
+ 'web.jsx',
+ 'jsx',
];
// Resolve file paths in the same order as webpack
const resolveModule = (resolveFn, filePath) => {
- const extension = moduleFileExtensions.find(extension =>
- fs.existsSync(resolveFn(`${filePath}.${extension}`))
- );
+ const extension = moduleFileExtensions.find((extension) =>
+ fs.existsSync(resolveFn(`${filePath}.${extension}`))
+ );
- if (extension) {
- return resolveFn(`${filePath}.${extension}`);
- }
+ if (extension) {
+ return resolveFn(`${filePath}.${extension}`);
+ }
- return resolveFn(`${filePath}.js`);
+ return resolveFn(`${filePath}.js`);
};
// Config after eject: we're in ./config/
module.exports = {
- dotenv: resolveApp('.env'),
- appPath: resolveApp('.'),
- appBuild: resolveApp(buildPath),
- appPublic: resolveApp('public'),
- appHtml: resolveApp('public/index.html'),
- appIndexJs: resolveModule(resolveApp, 'src/index'),
- appPackageJson: resolveApp('package.json'),
- appSrc: resolveApp('src'),
- appTsConfig: resolveApp('tsconfig.json'),
- appJsConfig: resolveApp('jsconfig.json'),
- yarnLockFile: resolveApp('yarn.lock'),
- testsSetup: resolveModule(resolveApp, 'src/setupTests'),
- proxySetup: resolveApp('src/setupProxy.js'),
- appNodeModules: resolveApp('node_modules'),
- appWebpackCache: resolveApp('node_modules/.cache'),
- appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
- swSrc: resolveModule(resolveApp, 'src/service-worker'),
- publicUrlOrPath,
+ appPath: resolveApp('.'),
+ appBuild: resolveApp(buildPath),
+ appPublic: resolveApp('public'),
+ appHtml: resolveApp('public/index.html'),
+ appIndexJs: resolveModule(resolveApp, 'src/index'),
+ appPackageJson: resolveApp('package.json'),
+ appSrc: resolveApp('src'),
+ appTsConfig: resolveApp('tsconfig.json'),
+ appJsConfig: resolveApp('jsconfig.json'),
+ yarnLockFile: resolveApp('yarn.lock'),
+ appNodeModules: resolveApp('node_modules'),
+ appWebpackCache: resolveApp('node_modules/.cache'),
+ publicUrlOrPath,
};
-
-
module.exports.moduleFileExtensions = moduleFileExtensions;
diff --git a/packages/player-example/config/webpackDevServer.config.js b/packages/player-example/config/webpackDevServer.config.js
index ec8e9d7409..2c459264d9 100644
--- a/packages/player-example/config/webpackDevServer.config.js
+++ b/packages/player-example/config/webpackDevServer.config.js
@@ -1,12 +1,10 @@
'use strict';
-const fs = require('fs');
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const ignoredFiles = require('react-dev-utils/ignoredFiles');
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
const paths = require('./paths');
-const getHttpsConfig = require('./getHttpsConfig');
const host = process.env.HOST || '0.0.0.0';
const sockHost = process.env.WDS_SOCKET_HOST;
@@ -14,114 +12,108 @@ const sockPath = process.env.WDS_SOCKET_PATH; // Default: '/ws'
const sockPort = process.env.WDS_SOCKET_PORT;
module.exports = function (proxy, allowedHost) {
- const disableFirewall =
- !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
- return {
- // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
- // websites from potentially accessing local content through DNS rebinding:
- // https://github.com/webpack/webpack-dev-server/issues/887
- // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
- // However, it made several existing use cases such as development in cloud
- // environment or subdomains in development significantly more complicated:
- // https://github.com/facebook/create-react-app/issues/2271
- // https://github.com/facebook/create-react-app/issues/2233
- // While we're investigating better solutions, for now we will take a
- // compromise. Since our WDS configuration only serves files in the `public`
- // folder we won't consider accessing them a vulnerability. However, if you
- // use the `proxy` feature, it gets more dangerous because it can expose
- // remote code execution vulnerabilities in backends like Django and Rails.
- // So we will disable the host check normally, but enable it if you have
- // specified the `proxy` setting. Finally, we let you override it if you
- // really know what you're doing with a special environment variable.
- // Note: ["localhost", ".localhost"] will support subdomains - but we might
- // want to allow setting the allowedHosts manually for more complex setups
- allowedHosts: disableFirewall ? 'all' : [allowedHost],
- headers: {
- 'Access-Control-Allow-Origin': '*',
- 'Access-Control-Allow-Methods': '*',
- 'Access-Control-Allow-Headers': '*',
- },
- // Enable gzip compression of generated files.
- compress: true,
- static: {
- // By default WebpackDevServer serves physical files from current directory
- // in addition to all the virtual build products that it serves from memory.
- // This is confusing because those files won’t automatically be available in
- // production build folder unless we copy them. However, copying the whole
- // project directory is dangerous because we may expose sensitive files.
- // Instead, we establish a convention that only files in `public` directory
- // get served. Our build script will copy `public` into the `build` folder.
- // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
- // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
- // Note that we only recommend to use `public` folder as an escape hatch
- // for files like `favicon.ico`, `manifest.json`, and libraries that are
- // for some reason broken when imported through webpack. If you just want to
- // use an image, put it in `src` and `import` it from JavaScript instead.
- directory: paths.appPublic,
- publicPath: [paths.publicUrlOrPath],
- // By default files from `contentBase` will not trigger a page reload.
- watch: {
- // Reportedly, this avoids CPU overload on some systems.
- // https://github.com/facebook/create-react-app/issues/293
- // src/node_modules is not ignored to support absolute imports
- // https://github.com/facebook/create-react-app/issues/1065
- ignored: ignoredFiles(paths.appSrc),
- },
- },
- client: {
- webSocketURL: {
- // Enable custom sockjs pathname for websocket connection to hot reloading server.
- // Enable custom sockjs hostname, pathname and port for websocket connection
- // to hot reloading server.
- hostname: sockHost,
- pathname: sockPath,
- port: sockPort,
- },
- overlay: {
- errors: true,
- warnings: false,
- },
- },
- devMiddleware: {
- // It is important to tell WebpackDevServer to use the same "publicPath" path as
- // we specified in the webpack config. When homepage is '.', default to serving
- // from the root.
- // remove last slash so user can land on `/test` instead of `/test/`
- publicPath: paths.publicUrlOrPath.slice(0, -1),
- },
+ const disableFirewall =
+ !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
+ return {
+ // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
+ // websites from potentially accessing local content through DNS rebinding:
+ // https://github.com/webpack/webpack-dev-server/issues/887
+ // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
+ // However, it made several existing use cases such as development in cloud
+ // environment or subdomains in development significantly more complicated:
+ // https://github.com/facebook/create-react-app/issues/2271
+ // https://github.com/facebook/create-react-app/issues/2233
+ // While we're investigating better solutions, for now we will take a
+ // compromise. Since our WDS configuration only serves files in the `public`
+ // folder we won't consider accessing them a vulnerability. However, if you
+ // use the `proxy` feature, it gets more dangerous because it can expose
+ // remote code execution vulnerabilities in backends like Django and Rails.
+ // So we will disable the host check normally, but enable it if you have
+ // specified the `proxy` setting. Finally, we let you override it if you
+ // really know what you're doing with a special environment variable.
+ // Note: ["localhost", ".localhost"] will support subdomains - but we might
+ // want to allow setting the allowedHosts manually for more complex setups
+ allowedHosts: disableFirewall ? 'all' : [allowedHost],
+ headers: {
+ 'Access-Control-Allow-Origin': '*',
+ 'Access-Control-Allow-Methods': '*',
+ 'Access-Control-Allow-Headers': '*',
+ },
+ // Enable gzip compression of generated files.
+ compress: true,
+ static: {
+ // By default WebpackDevServer serves physical files from current directory
+ // in addition to all the virtual build products that it serves from memory.
+ // This is confusing because those files won’t automatically be available in
+ // production build folder unless we copy them. However, copying the whole
+ // project directory is dangerous because we may expose sensitive files.
+ // Instead, we establish a convention that only files in `public` directory
+ // get served. Our build script will copy `public` into the `build` folder.
+ // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
+ // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
+ // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
+ // Note that we only recommend to use `public` folder as an escape hatch
+ // for files like `favicon.ico`, `manifest.json`, and libraries that are
+ // for some reason broken when imported through webpack. If you just want to
+ // use an image, put it in `src` and `import` it from JavaScript instead.
+ directory: paths.appPublic,
+ publicPath: [paths.publicUrlOrPath],
+ // By default files from `contentBase` will not trigger a page reload.
+ watch: {
+ // Reportedly, this avoids CPU overload on some systems.
+ // https://github.com/facebook/create-react-app/issues/293
+ // src/node_modules is not ignored to support absolute imports
+ // https://github.com/facebook/create-react-app/issues/1065
+ ignored: ignoredFiles(paths.appSrc),
+ },
+ },
+ client: {
+ webSocketURL: {
+ // Enable custom sockjs pathname for websocket connection to hot reloading server.
+ // Enable custom sockjs hostname, pathname and port for websocket connection
+ // to hot reloading server.
+ hostname: sockHost,
+ pathname: sockPath,
+ port: sockPort,
+ },
+ overlay: {
+ errors: true,
+ warnings: false,
+ },
+ },
+ devMiddleware: {
+ // It is important to tell WebpackDevServer to use the same "publicPath" path as
+ // we specified in the webpack config. When homepage is '.', default to serving
+ // from the root.
+ // remove last slash so user can land on `/test` instead of `/test/`
+ publicPath: paths.publicUrlOrPath.slice(0, -1),
+ },
- https: getHttpsConfig(),
- host,
- historyApiFallback: {
- // Paths with dots should still use the history fallback.
- // See https://github.com/facebook/create-react-app/issues/387.
- disableDotRule: true,
- index: paths.publicUrlOrPath,
- },
- // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
- proxy,
- onBeforeSetupMiddleware(devServer) {
- // Keep `evalSourceMapMiddleware`
- // middlewares before `redirectServedPath` otherwise will not have any effect
- // This lets us fetch source contents from webpack for the error overlay
- devServer.app.use(evalSourceMapMiddleware(devServer));
+ host,
+ historyApiFallback: {
+ // Paths with dots should still use the history fallback.
+ // See https://github.com/facebook/create-react-app/issues/387.
+ disableDotRule: true,
+ index: paths.publicUrlOrPath,
+ },
+ // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
+ proxy,
+ onBeforeSetupMiddleware(devServer) {
+ // Keep `evalSourceMapMiddleware`
+ // middlewares before `redirectServedPath` otherwise will not have any effect
+ // This lets us fetch source contents from webpack for the error overlay
+ devServer.app.use(evalSourceMapMiddleware(devServer));
+ },
+ onAfterSetupMiddleware(devServer) {
+ // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
+ devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
- if (fs.existsSync(paths.proxySetup)) {
- // This registers user provided middleware for proxy reasons
- require(paths.proxySetup)(devServer.app);
- }
- },
- onAfterSetupMiddleware(devServer) {
- // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
- devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
-
- // This service worker file is effectively a 'no-op' that will reset any
- // previous service worker registered for the same host:port combination.
- // We do this in development to avoid hitting the production cache if
- // it used the same host and port.
- // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
- devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
- },
- };
+ // This service worker file is effectively a 'no-op' that will reset any
+ // previous service worker registered for the same host:port combination.
+ // We do this in development to avoid hitting the production cache if
+ // it used the same host and port.
+ // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
+ devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
+ },
+ };
};