From 00d695992777423c32ad24f9dcc5676f89c727ac Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Thu, 7 Feb 2019 12:47:18 +0100 Subject: [PATCH] Create synapse-admin using 'rekit create --sass synapse-admin' Change-Id: I14a94754264c83faffb7fea5099d37c97e60b07a --- .babelrc | 4 + .editorconfig | 5 + .gitignore | 21 ++ .prettierrc | 5 + README.md | 1 + config/env.js | 93 +++++ config/jest/cssTransform.js | 14 + config/jest/fileTransform.js | 12 + config/paths.js | 56 +++ config/polyfills.js | 22 ++ config/webpack.config.dev.js | 267 ++++++++++++++ config/webpack.config.prod.js | 346 ++++++++++++++++++ config/webpackDevServer.config.js | 95 +++++ package.json | 115 ++++++ public/favicon.ico | Bin 0 -> 3870 bytes public/index.html | 40 ++ public/manifest.json | 15 + scripts/build.js | 160 ++++++++ scripts/start.js | 117 ++++++ scripts/startRekitStudio.js | 38 ++ scripts/test.js | 26 ++ src/Root.js | 57 +++ src/common/configStore.js | 44 +++ src/common/history.js | 5 + src/common/rootReducer.js | 19 + src/common/routeConfig.js | 44 +++ src/favicon.png | Bin 0 -> 1530 bytes src/features/common/PageNotFound.js | 11 + src/features/common/PageNotFound.scss | 5 + src/features/common/index.js | 1 + src/features/common/redux/actions.js | 0 src/features/common/redux/constants.js | 0 src/features/common/redux/initialState.js | 12 + src/features/common/redux/reducer.js | 24 ++ src/features/common/route.js | 9 + src/features/common/style.scss | 1 + src/features/examples/CounterPage.js | 45 +++ src/features/examples/CounterPage.scss | 18 + src/features/examples/Layout.js | 20 + src/features/examples/Layout.scss | 9 + src/features/examples/RedditListPage.js | 57 +++ src/features/examples/RedditListPage.scss | 24 ++ src/features/examples/SidePanel.js | 54 +++ src/features/examples/SidePanel.scss | 46 +++ src/features/examples/WelcomePage.js | 57 +++ src/features/examples/WelcomePage.scss | 36 ++ src/features/examples/index.js | 5 + src/features/examples/redux/actions.js | 4 + src/features/examples/redux/constants.js | 7 + .../examples/redux/counterMinusOne.js | 24 ++ src/features/examples/redux/counterPlusOne.js | 24 ++ src/features/examples/redux/counterReset.js | 24 ++ .../examples/redux/fetchRedditList.js | 97 +++++ src/features/examples/redux/initialState.js | 15 + src/features/examples/redux/reducer.js | 31 ++ src/features/examples/route.js | 20 + src/features/examples/style.scss | 6 + src/features/home/App.js | 25 ++ src/features/home/App.scss | 4 + src/features/home/DefaultPage.js | 80 ++++ src/features/home/DefaultPage.scss | 77 ++++ src/features/home/index.js | 2 + src/features/home/redux/actions.js | 0 src/features/home/redux/constants.js | 0 src/features/home/redux/initialState.js | 4 + src/features/home/redux/reducer.js | 16 + src/features/home/route.js | 15 + src/features/home/style.scss | 3 + src/images/logo.png | Bin 0 -> 135598 bytes src/images/react-logo.svg | 7 + src/images/rekit-logo.svg | 32 ++ src/index.js | 32 ++ src/logo.svg | 7 + src/styles/global.scss | 9 + src/styles/index.scss | 5 + src/styles/mixins.scss | 0 tests/Root.test.js | 30 ++ tests/features/common/PageNotFound.test.js | 11 + tests/features/examples/CounterPage.test.js | 35 ++ tests/features/examples/Layout.test.js | 11 + .../features/examples/RedditListPage.test.js | 51 +++ tests/features/examples/SidePanel.test.js | 15 + tests/features/examples/WelcomePage.test.js | 15 + .../examples/redux/counterMinusOne.test.js | 28 ++ .../examples/redux/counterPlusOne.test.js | 25 ++ .../examples/redux/counterReset.test.js | 25 ++ .../examples/redux/fetchRedditList.test.js | 102 ++++++ tests/features/examples/redux/reducer.test.js | 14 + tests/features/home/App.test.js | 11 + tests/features/home/DefaultPage.test.js | 15 + tests/index.test.js | 7 + tests/setup.js | 13 + tools/index.js | 1 + 93 files changed, 3034 insertions(+) create mode 100644 .babelrc create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .prettierrc create mode 100644 README.md create mode 100644 config/env.js create mode 100644 config/jest/cssTransform.js create mode 100644 config/jest/fileTransform.js create mode 100644 config/paths.js create mode 100644 config/polyfills.js create mode 100644 config/webpack.config.dev.js create mode 100644 config/webpack.config.prod.js create mode 100644 config/webpackDevServer.config.js create mode 100644 package.json create mode 100644 public/favicon.ico create mode 100644 public/index.html create mode 100644 public/manifest.json create mode 100644 scripts/build.js create mode 100644 scripts/start.js create mode 100644 scripts/startRekitStudio.js create mode 100644 scripts/test.js create mode 100644 src/Root.js create mode 100644 src/common/configStore.js create mode 100644 src/common/history.js create mode 100644 src/common/rootReducer.js create mode 100644 src/common/routeConfig.js create mode 100644 src/favicon.png create mode 100644 src/features/common/PageNotFound.js create mode 100644 src/features/common/PageNotFound.scss create mode 100644 src/features/common/index.js create mode 100644 src/features/common/redux/actions.js create mode 100644 src/features/common/redux/constants.js create mode 100644 src/features/common/redux/initialState.js create mode 100644 src/features/common/redux/reducer.js create mode 100644 src/features/common/route.js create mode 100644 src/features/common/style.scss create mode 100644 src/features/examples/CounterPage.js create mode 100644 src/features/examples/CounterPage.scss create mode 100644 src/features/examples/Layout.js create mode 100644 src/features/examples/Layout.scss create mode 100644 src/features/examples/RedditListPage.js create mode 100644 src/features/examples/RedditListPage.scss create mode 100644 src/features/examples/SidePanel.js create mode 100644 src/features/examples/SidePanel.scss create mode 100644 src/features/examples/WelcomePage.js create mode 100644 src/features/examples/WelcomePage.scss create mode 100644 src/features/examples/index.js create mode 100644 src/features/examples/redux/actions.js create mode 100644 src/features/examples/redux/constants.js create mode 100644 src/features/examples/redux/counterMinusOne.js create mode 100644 src/features/examples/redux/counterPlusOne.js create mode 100644 src/features/examples/redux/counterReset.js create mode 100644 src/features/examples/redux/fetchRedditList.js create mode 100644 src/features/examples/redux/initialState.js create mode 100644 src/features/examples/redux/reducer.js create mode 100644 src/features/examples/route.js create mode 100644 src/features/examples/style.scss create mode 100644 src/features/home/App.js create mode 100644 src/features/home/App.scss create mode 100644 src/features/home/DefaultPage.js create mode 100644 src/features/home/DefaultPage.scss create mode 100644 src/features/home/index.js create mode 100644 src/features/home/redux/actions.js create mode 100644 src/features/home/redux/constants.js create mode 100644 src/features/home/redux/initialState.js create mode 100644 src/features/home/redux/reducer.js create mode 100644 src/features/home/route.js create mode 100644 src/features/home/style.scss create mode 100644 src/images/logo.png create mode 100644 src/images/react-logo.svg create mode 100644 src/images/rekit-logo.svg create mode 100644 src/index.js create mode 100644 src/logo.svg create mode 100644 src/styles/global.scss create mode 100644 src/styles/index.scss create mode 100644 src/styles/mixins.scss create mode 100644 tests/Root.test.js create mode 100644 tests/features/common/PageNotFound.test.js create mode 100644 tests/features/examples/CounterPage.test.js create mode 100644 tests/features/examples/Layout.test.js create mode 100644 tests/features/examples/RedditListPage.test.js create mode 100644 tests/features/examples/SidePanel.test.js create mode 100644 tests/features/examples/WelcomePage.test.js create mode 100644 tests/features/examples/redux/counterMinusOne.test.js create mode 100644 tests/features/examples/redux/counterPlusOne.test.js create mode 100644 tests/features/examples/redux/counterReset.test.js create mode 100644 tests/features/examples/redux/fetchRedditList.test.js create mode 100644 tests/features/examples/redux/reducer.test.js create mode 100644 tests/features/home/App.test.js create mode 100644 tests/features/home/DefaultPage.test.js create mode 100644 tests/index.test.js create mode 100644 tests/setup.js create mode 100644 tools/index.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..27d3b85 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["react-app"], + "plugins": ["react-hot-loader/babel", "syntax-dynamic-import", "lodash"] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d52f02b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +{ + indent_style: 'space', + indent_size: 2, + tab_width: 2 +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d30f40e --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..2fec1f2 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 100 +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e59600 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# README diff --git a/config/env.js b/config/env.js new file mode 100644 index 0000000..30a6c7f --- /dev/null +++ b/config/env.js @@ -0,0 +1,93 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); + +// Make sure that including paths.js after env.js will read .env variables. +delete require.cache[require.resolve('./paths')]; + +const NODE_ENV = process.env.NODE_ENV; +if (!NODE_ENV) { + throw new Error( + 'The NODE_ENV environment variable is required but was not specified.' + ); +} + +// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use +var dotenvFiles = [ + `${paths.dotenv}.${NODE_ENV}.local`, + `${paths.dotenv}.${NODE_ENV}`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, + paths.dotenv, +].filter(Boolean); + +// Load environment variables from .env* files. Suppress warnings using silent +// if this file is missing. dotenv will never modify any environment variables +// that have already been set. Variable expansion is supported in .env files. +// https://github.com/motdotla/dotenv +// https://github.com/motdotla/dotenv-expand +dotenvFiles.forEach(dotenvFile => { + if (fs.existsSync(dotenvFile)) { + require('dotenv-expand')( + require('dotenv').config({ + path: dotenvFile, + }) + ); + } +}); + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebookincubator/create-react-app/issues/253. +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. +// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 +// We also resolve them to make sure all tools using them work consistently. +const appDirectory = fs.realpathSync(process.cwd()); +process.env.NODE_PATH = (process.env.NODE_PATH || '') + .split(path.delimiter) + .filter(folder => folder && !path.isAbsolute(folder)) + .map(folder => path.resolve(appDirectory, folder)) + .join(path.delimiter); + +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in Webpack configuration. +const REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + const raw = Object.keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce( + (env, key) => { + env[key] = process.env[key]; + return env; + }, + { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + NODE_ENV: process.env.NODE_ENV || 'development', + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + PUBLIC_URL: publicUrl, + } + ); + // Stringify all values so we can feed into Webpack DefinePlugin + const stringified = { + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), + }; + + return { raw, stringified }; +} + +module.exports = getClientEnvironment; diff --git a/config/jest/cssTransform.js b/config/jest/cssTransform.js new file mode 100644 index 0000000..8f65114 --- /dev/null +++ b/config/jest/cssTransform.js @@ -0,0 +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 = {};'; + }, + getCacheKey() { + // The output is always the same. + return 'cssTransform'; + }, +}; diff --git a/config/jest/fileTransform.js b/config/jest/fileTransform.js new file mode 100644 index 0000000..9e4047d --- /dev/null +++ b/config/jest/fileTransform.js @@ -0,0 +1,12 @@ +'use strict'; + +const path = require('path'); + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process(src, filename) { + return `module.exports = ${JSON.stringify(path.basename(filename))};`; + }, +}; diff --git a/config/paths.js b/config/paths.js new file mode 100644 index 0000000..06c5f8c --- /dev/null +++ b/config/paths.js @@ -0,0 +1,56 @@ +'use strict'; + +const path = require('path'); +const fs = require('fs'); +const url = require('url'); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebookincubator/create-react-app/issues/637 +const appDirectory = fs.realpathSync(process.cwd()); +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); + +const envPublicUrl = process.env.PUBLIC_URL; + +function ensureSlash(path, needsSlash) { + const hasSlash = path.endsWith('/'); + if (hasSlash && !needsSlash) { + return path.substr(path, path.length - 1); + } else if (!hasSlash && needsSlash) { + return `${path}/`; + } else { + return path; + } +} + +const getPublicUrl = appPackageJson => + envPublicUrl || require(appPackageJson).homepage; + +// We use `PUBLIC_URL` environment variable or "homepage" field to infer +// "public path" at which the app is served. +// Webpack needs to know it to put the right