From db5c4cf1ad1d0cda7da7ed6e9191ff393121d664 Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Tue, 10 Sep 2019 12:51:01 -0400 Subject: [PATCH 001/398] fix tox.ini so tests dont fail --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index fd29ab082..c94d73996 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist=True -envlist=py{27,36}-dj{111} +envlist=py{27,37}-dj{111} [testenv] install_command=pip install -e ".[testing]" -U {opts} {packages} @@ -11,7 +11,7 @@ commands= basepython= py27: python2.7 - py36: python3.6 + py37: python3.7 deps= coverage==4.5.1 From 7e908a9f55722e5265f70f8d9b30358b1a687fcd Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Mon, 30 Sep 2019 13:36:28 -0400 Subject: [PATCH 002/398] save work --- .eslintrc | 55 ++++++++--------- config/modules.js | 88 +++++++++++++++++++++++++++ config/paths.js | 39 ++++++++++-- package.json | 150 ++++++++++++++++++++++++++++------------------ 4 files changed, 244 insertions(+), 88 deletions(-) create mode 100644 config/modules.js diff --git a/.eslintrc b/.eslintrc index aedeb1dd5..d48bfbfd7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,31 +1,32 @@ root: true # Enable ecmascript 6 features. -ecmaFeatures: - arrowFunctions: false - binaryLiterals: false - blockBindings: false - classes: false - defaultParams: false - destructuring: false - forOf: true - generators: false - modules: true - objectLiteralComputedProperties: false - objectLiteralDuplicateProperties: false - objectLiteralShorthandMethods: false - objectLiteralShorthandProperties: false - octalLiterals: false - regexUFlag: false - regexYFlag: false - restParams: true - spread: false - superInFunctions: false - templateStrings: false - unicodeCodePointEscapes: false - globalReturn: false - jsx: true - experimentalObjectRestSpread: false +parserOptions: + ecmaFeatures: + arrowFunctions: false + binaryLiterals: false + blockBindings: false + classes: false + defaultParams: false + destructuring: false + forOf: true + generators: false + modules: true + objectLiteralComputedProperties: false + objectLiteralDuplicateProperties: false + objectLiteralShorthandMethods: false + objectLiteralShorthandProperties: false + octalLiterals: false + regexUFlag: false + regexYFlag: false + restParams: true + spread: false + superInFunctions: false + templateStrings: false + unicodeCodePointEscapes: false + globalReturn: false + jsx: true + experimentalObjectRestSpread: false parser: babel-eslint @@ -221,8 +222,8 @@ rules: # Enforces use of === and !== over == and !=. eqeqeq: - - 2 - - smart + - 2 + - smart # Enforces necessary if statements in for-in loops. guard-for-in: 1 diff --git a/config/modules.js b/config/modules.js new file mode 100644 index 000000000..f69b18af1 --- /dev/null +++ b/config/modules.js @@ -0,0 +1,88 @@ + + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); +const chalk = require('react-dev-utils/chalk'); +const resolve = require('resolve'); + +/** + * Get the baseUrl of a compilerOptions object. + * + * @param {Object} options + */ +function getAdditionalModulePaths(options = {}) { + const baseUrl = options.baseUrl; + + // We need to explicitly check for null and undefined (and not a falsy value) because + // TypeScript treats an empty string as `.`. + if (baseUrl == null) { + // If there's no baseUrl set we respect NODE_PATH + // Note that NODE_PATH is deprecated and will be removed + // in the next major release of create-react-app. + + const nodePath = process.env.NODE_PATH || ''; + return nodePath.split(path.delimiter).filter(Boolean); + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + // We don't need to do anything if `baseUrl` is set to `node_modules`. This is + // the default behavior. + if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { + return null; + } + + // Allow the user set the `baseUrl` to `appSrc`. + if (path.relative(paths.appSrc, baseUrlResolved) === '') { + return [paths.appSrc]; + } + + // Otherwise, throw an error. + throw new Error( + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) + ); +} + +function getModules() { + // Check if TypeScript is setup + const hasTsConfig = fs.existsSync(paths.appTsConfig); + const hasJsConfig = fs.existsSync(paths.appJsConfig); + + if (hasTsConfig && hasJsConfig) { + throw new Error( + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + ); + } + + let config; + + // If there's a tsconfig.json we assume it's a + // TypeScript project and set up the config + // based on tsconfig.json + if (hasTsConfig) { + const ts = require(resolve.sync('typescript', { + basedir: paths.appNodeModules, + })); + config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; + // Otherwise we'll check if there is jsconfig.json + // for non TS projects. + } else if (hasJsConfig) { + config = require(paths.appJsConfig); + } + + config = config || {}; + const options = config.compilerOptions || {}; + + const additionalModulePaths = getAdditionalModulePaths(options); + + return { + additionalModulePaths: additionalModulePaths, + hasTsConfig, + }; +} + +module.exports = getModules(); diff --git a/config/paths.js b/config/paths.js index b3567b01a..e63703566 100644 --- a/config/paths.js +++ b/config/paths.js @@ -23,7 +23,7 @@ function ensureSlash(path, needsSlash) { } const getPublicUrl = appPackageJson => - envPublicUrl || require(appPackageJson).homepage; + envPublicUrl || require(appPackageJson).homepage; // We use `PUBLIC_URL` environment variable or "homepage" field to infer // "public path" at which the app is served. @@ -34,22 +34,53 @@ const getPublicUrl = appPackageJson => function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); const servedUrl = - envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); + envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); return ensureSlash(servedUrl, true); } +const moduleFileExtensions = [ + '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}`)) + ); + + if (extension) { + return resolveFn(`${filePath}.${extension}`); + } + + return resolveFn(`${filePath}.js`); +}; + + // config after eject: we're in ./config/ module.exports = { dotenv: resolveApp('.env'), appBuild: resolveApp('ccdb5_ui/static'), + appPath: resolveApp('.'), appPublic: resolveApp('public'), appHtml: resolveApp('public/index.html'), - appIndexJs: resolveApp('src/index.js'), + appIndexJs: resolveModule(resolveApp, 'src/index'), appPackageJson: resolveApp('package.json'), appSrc: resolveApp('src'), yarnLockFile: resolveApp('yarn.lock'), - testsSetup: resolveApp('src/setupTests.js'), + testsSetup: resolveModule(resolveApp, 'src/setupTests'), appNodeModules: resolveApp('node_modules'), publicUrl: getPublicUrl(resolveApp('package.json')), servedPath: getServedPath(resolveApp('package.json')), }; + +module.exports.moduleFileExtensions = moduleFileExtensions; diff --git a/package.json b/package.json index e62f523f0..39f06dcbd 100644 --- a/package.json +++ b/package.json @@ -14,85 +14,109 @@ }, "license": "CC0-1.0", "dependencies": { + "@babel/core": "7.5.5", + "@babel/preset-env": "^7.0.0", + "@babel/preset-react": "^7.0.0", + "@svgr/webpack": "4.3.2", + "@typescript-eslint/eslint-plugin": "1.13.0", + "@typescript-eslint/parser": "1.13.0", + "autoprefixer": "7.1.5", + "babel-eslint": "10.0.2", + "babel-jest": "^24.8.0", + "babel-loader": "8.0.6", + "babel-plugin-named-asset-import": "^0.3.3", + "babel-runtime": "^6.20.0", + "camelcase": "^5.2.0", + "case-sensitive-paths-webpack-plugin": "2.2.0", "cf-buttons": "^4.3.0", "cf-core": "^4.2.0", "cf-expandables": "^4.1.2", - "cf-forms": "^10.2.0", + "cf-forms": "^10.2.1", "cf-grid": "^4.1.0", - "cf-icons": "^10.1.0", + "cf-icons": "^10.2.1", "cf-layout": "^4.2.0", "cf-pagination": "^4.1.1", "cf-tables": "^4.1.1", "cf-typography": "^4.1.0", - "history": "^4.6.1", - "moment": "^2.19.3", - "prop-types": "^15.5.10", - "query-string": "^5.0.0", - "react": "^16.0.0", - "react-dom": "^16.0.0", - "react-intl": "^2.4.0", - "react-modal": "^3.0.4", - "react-redux": "^5.0.5", - "react-router": "^4.2.0", - "react-router-dom": "^4.2.2", - "redux": "^3.7.0", - "redux-devtools-extension": "^2.13.2", - "redux-thunk": "^2.2.0" - }, - "devDependencies": { - "autoprefixer": "7.1.5", - "babel-core": "6.26.0", - "babel-eslint": "8.0.1", - "babel-jest": "21.2.0", - "babel-loader": "7.1.2", - "babel-preset-es2015": "^6.24.1", - "babel-preset-react": "^6.24.1", - "babel-preset-react-app": "^3.0.3", - "babel-runtime": "^6.20.0", - "case-sensitive-paths-webpack-plugin": "2.1.1", + "cfpb-chart-builder": "git+https://github.com/flacoman91/cfpb-chart-builder.git", "chalk": "2.2.0", "connect-history-api-fallback": "1.4.0", "core-js": "^2.5.1", - "coveralls": "^3.0.1", + "coveralls": "^3.0.6", "cross-spawn": "5.1.0", - "css-loader": "0.28.7", + "css-loader": "2.1.1", "detect-port": "1.2.1", - "dotenv": "4.0.0", + "dotenv": "6.2.0", + "dotenv-expand": "4.2.0", "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.0.1", - "eslint": "4.9.0", - "eslint-config-react-app": "^2.0.1", - "eslint-loader": "1.9.0", - "eslint-plugin-flowtype": "2.39.1", - "eslint-plugin-import": "2.8.0", - "eslint-plugin-jsx-a11y": "6.0.2", - "eslint-plugin-react": "7.4.0", - "extract-text-webpack-plugin": "3.0.1", - "file-loader": "1.1.5", - "fs-extra": "4.0.2", - "html-webpack-plugin": "2.30.1", + "eslint": "^6.1.0", + "eslint-config-react-app": "^5.0.1", + "eslint-loader": "2.2.1", + "eslint-plugin-flowtype": "3.13.0", + "eslint-plugin-import": "2.18.2", + "eslint-plugin-jsx-a11y": "6.2.3", + "eslint-plugin-react": "7.14.3", + "eslint-plugin-react-hooks": "^1.6.1", + "file-loader": "3.0.1", + "fs-extra": "7.0.1", + "history": "^4.10.1", + "html-webpack-plugin": "4.0.0-beta.5", "http-proxy-middleware": "0.17.4", + "identity-obj-proxy": "3.0.0", "ignore-loader": "^0.1.2", - "jest": "^21.2.1", + "is-wsl": "^1.1.0", + "jest": "24.8.0", "jest-cli": "^21.2.1", + "jest-environment-jsdom-fourteen": "0.1.0", + "jest-resolve": "24.8.0", + "jest-watch-typeahead": "0.3.1", "json-loader": "0.5.7", - "less": "^3.0.0-alpha.3", + "less": "^3.10.3", "less-loader": "^4.0.5", + "mini-css-extract-plugin": "0.5.0", + "moment": "^2.19.3", "object-assign": "4.1.1", - "postcss-flexbugs-fixes": "^3.2.0", - "postcss-loader": "2.0.8", + "optimize-css-assets-webpack-plugin": "5.0.3", + "pnp-webpack-plugin": "1.5.0", + "postcss-flexbugs-fixes": "4.1.0", + "postcss-loader": "3.0.0", + "postcss-normalize": "7.0.1", + "postcss-preset-env": "6.7.0", + "postcss-safe-parser": "4.0.1", "promise": "8.0.1", - "react-dev-utils": "^4.1.0", - "react-test-renderer": "^16.0.0", + "prop-types": "^15.5.10", + "query-string": "^5.0.0", + "react": "^16.9.0", + "react-app-polyfill": "^1.0.2", + "react-dev-utils": "^9.0.3", + "react-dom": "^16.9.0", + "react-intl": "^2.4.0", + "react-modal": "^3.10.1", + "react-redux": "^5.0.5", + "react-router": "^4.2.0", + "react-router-dom": "^4.2.2", + "react-scripts": "^3.1.2", + "react-test-renderer": "^16.9.0", + "redux": "^3.7.0", + "redux-devtools-extension": "^2.13.2", "redux-mock-store": "^1.2.3", + "redux-thunk": "^2.2.0", + "resolve": "1.12.0", + "resolve-url-loader": "3.1.0", + "sass-loader": "7.2.0", + "semver": "6.3.0", "string-replace-loader": "^1.2.0", - "style-loader": "0.19.0", - "url-loader": "0.6.2", - "webpack": "3.8.1", - "webpack-dev-server": "2.9.2", - "webpack-manifest-plugin": "1.3.2", - "webpack-merge": "^4.1.0", - "whatwg-fetch": "2.0.3" + "style-loader": "1.0.0", + "terser-webpack-plugin": "1.4.1", + "ts-pnp": "1.1.2", + "url-loader": "2.1.0", + "webpack": "4.39.1", + "webpack-dev-server": "3.2.1", + "webpack-manifest-plugin": "2.0.4", + "webpack-merge": "^4.2.2", + "whatwg-fetch": "2.0.3", + "workbox-webpack-plugin": "4.3.1" }, "scripts": { "start": "node scripts/start.js", @@ -129,11 +153,23 @@ }, "babel": { "presets": [ - "es2015", - "react-app" + "@babel/preset-env", + "@babel/preset-react" ] }, "eslintConfig": { "extends": "react-app" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] } } From 6ff8bb1ed1fb58c28598a91e4d4cde5a8838db67 Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Wed, 11 Sep 2019 14:20:27 -0400 Subject: [PATCH 003/398] save initial results points save up some work save some work save work ssave work save some work save off some crazy work it compiles! updating dummy code updating scripts to match modern CRA update start script eslint autofix update build script eslint fixes, use build.js from latest. use webpack configs from latest before we shove in old config options working less ? and string replace, need to get mini-css-extract-plugin working instead of extracttext remove tile map work put back fix remove added files remove unused reference --- config/modules.js | 10 +- config/webpack.config.dev.js | 14 +- config/webpack.config.old.js | 418 + config/webpack.config.prod.js | 969 ++- package-lock.json | 14672 -------------------------------- package.json | 1 - scripts/build.js | 73 +- scripts/start.js | 140 +- src/actions/analytics.jsx | 2 +- 9 files changed, 1277 insertions(+), 15022 deletions(-) create mode 100644 config/webpack.config.old.js delete mode 100644 package-lock.json diff --git a/config/modules.js b/config/modules.js index f69b18af1..6e5ea4da1 100644 --- a/config/modules.js +++ b/config/modules.js @@ -40,10 +40,10 @@ function getAdditionalModulePaths(options = {}) { // Otherwise, throw an error. throw new Error( - chalk.red.bold( - "Your project's `baseUrl` can only be set to `src` or `node_modules`." + - ' Create React App does not support other values at this time.' - ) + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) ); } @@ -54,7 +54,7 @@ function getModules() { if (hasTsConfig && hasJsConfig) { throw new Error( - 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' ); } diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index b2e00ce68..3e241274b 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -66,7 +66,7 @@ module.exports = { // Point sourcemap entries to original disk location (format as URL on Windows) devtoolModuleFilenameTemplate: info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'), - library: 'ccdb5_ui' + library: 'ccdb5_ui' }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. @@ -85,7 +85,7 @@ module.exports = { // for React Native Web. extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], alias: { - + // Support React Native Web // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ 'react-native': 'react-native-web', @@ -116,7 +116,7 @@ module.exports = { options: { formatter: eslintFormatter, eslintPath: require.resolve('eslint'), - + }, loader: require.resolve('eslint-loader'), }, @@ -147,7 +147,7 @@ module.exports = { { loader: require.resolve('babel-loader'), options: { - + // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. @@ -158,7 +158,7 @@ module.exports = { loader: require.resolve('string-replace-loader'), options: { search: '@@API', - replace: 'http://localhost:8000/data-research/consumer-complaints/search/api/v1/', + replace: 'http://localhost:8333/data-research/consumer-complaints/search/api/v1/', flags: 'g' // If using the API without cf.gov build, you can use: // replace: 'http://localhost:8000/' @@ -226,13 +226,13 @@ module.exports = { // Makes some environment variables available in index.html. // The public URL is available as %PUBLIC_URL% in index.html, e.g.: // - // In development, this will be an empty string. - new InterpolateHtmlPlugin(env.raw), // Generates an `index.html` file with the