From 4afde945f316155dcbe10097a832087a64351388 Mon Sep 17 00:00:00 2001 From: gmdayley Date: Wed, 13 Feb 2019 08:25:16 -0700 Subject: [PATCH 01/31] Adding files necessary to build and deploy app in Electric Flow --- packages/react-scripts/template/.buildpacks | 1 + packages/react-scripts/template/Procfile | 1 + packages/react-scripts/template/blueprint.yml | 44 +++++++++++++++++++ .../hooks/pre-build/npm-build/create-npmrc.sh | 10 +++++ packages/react-scripts/template/src/server.js | 10 +++++ 5 files changed, 66 insertions(+) create mode 100644 packages/react-scripts/template/.buildpacks create mode 100644 packages/react-scripts/template/Procfile create mode 100644 packages/react-scripts/template/blueprint.yml create mode 100644 packages/react-scripts/template/hooks/pre-build/npm-build/create-npmrc.sh create mode 100644 packages/react-scripts/template/src/server.js diff --git a/packages/react-scripts/template/.buildpacks b/packages/react-scripts/template/.buildpacks new file mode 100644 index 00000000000..96d0a9ddcec --- /dev/null +++ b/packages/react-scripts/template/.buildpacks @@ -0,0 +1 @@ +https://github.com/heroku/heroku-buildpack-nodejs.git diff --git a/packages/react-scripts/template/Procfile b/packages/react-scripts/template/Procfile new file mode 100644 index 00000000000..08ee8b7485d --- /dev/null +++ b/packages/react-scripts/template/Procfile @@ -0,0 +1 @@ +web: node src/server.js \ No newline at end of file diff --git a/packages/react-scripts/template/blueprint.yml b/packages/react-scripts/template/blueprint.yml new file mode 100644 index 00000000000..03b9797237a --- /dev/null +++ b/packages/react-scripts/template/blueprint.yml @@ -0,0 +1,44 @@ +version: 1.0 +name: frontier-{{APP_NAME}} + +build: + - type: "Npm-Heroku v1_0" + heroku_stack: heroku-18 + name: npm-build + +deploy: + int: + {{APP_NAME}}: &APP_DEFAULTS + type: "Heroku v1_0" + stack_name: heroku-18 + location: development-fh5-useast1-heroku + binding_sets: + {{BINDING_PATH}}: + - type: "Service v1_0" + sites: + - integ + bindings: &BINDING_DEFAULTS + heroku: + type: "Alias v1_0" + aliases: + - www + non_ssl_action: + type: redirect_to_https + append_slash: true + prod: + {{APP_NAME}}: + <<: *APP_DEFAULTS + type: "Heroku v1_0" + stack_name: cedar-14 + location: production-fh1-useast1-heroku + binding_sets: + {{BINDING_PATH}}: + - type: "Service v1_0" + sites: + - prod + bindings: + <<: *BINDING_DEFAULTS +deliver: + deploy_order: + - int + - prod diff --git a/packages/react-scripts/template/hooks/pre-build/npm-build/create-npmrc.sh b/packages/react-scripts/template/hooks/pre-build/npm-build/create-npmrc.sh new file mode 100644 index 00000000000..90cbd6a25a7 --- /dev/null +++ b/packages/react-scripts/template/hooks/pre-build/npm-build/create-npmrc.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Get artifactory token from SAS +ICS_AF_TOKEN=ec-sas-client frontier-hub-ics-public-artifactory-db password +NPMRC_TOKEN="//code.lds.org/artifactory/api/npm/npm-fhd/:_authToken=${ICS_AF_TOKEN}" +NPMRC_ICS_REGISTRY="@fs:registry=https://code.lds.org/artifactory/api/npm/npm-fhd/" + +# Write .npmrc +echo $NPMRC_TOKEN > .npmrc +echo $NPMRC_ICS_REGISTRY >> .npmrc \ No newline at end of file diff --git a/packages/react-scripts/template/src/server.js b/packages/react-scripts/template/src/server.js new file mode 100644 index 00000000000..374f5ab738a --- /dev/null +++ b/packages/react-scripts/template/src/server.js @@ -0,0 +1,10 @@ +var express = require("express"); +var path = require("path"); +var app = express(); + +// React App +app.use(express.static(__dirname + "/build")); + +const port = process.env.PORT || 3000; +app.listen(port); +console.log("Listening on port " + port) From d262b577ac5637f2ecad60e4aafbab8c34f4a99e Mon Sep 17 00:00:00 2001 From: gmdayley Date: Wed, 13 Feb 2019 08:41:13 -0700 Subject: [PATCH 02/31] Add new template for electric flow Add option in cli --- .../react-scripts/scripts/utils/frontierInit.js | 15 +++++++++++++++ .../{template => template-ef}/.buildpacks | 0 .../{template => template-ef}/Procfile | 0 .../{template => template-ef}/blueprint.yml | 0 .../hooks/pre-build/npm-build/create-npmrc.sh | 0 .../{template => template-ef}/src/server.js | 0 6 files changed, 15 insertions(+) rename packages/react-scripts/{template => template-ef}/.buildpacks (100%) rename packages/react-scripts/{template => template-ef}/Procfile (100%) rename packages/react-scripts/{template => template-ef}/blueprint.yml (100%) rename packages/react-scripts/{template => template-ef}/hooks/pre-build/npm-build/create-npmrc.sh (100%) rename packages/react-scripts/{template => template-ef}/src/server.js (100%) diff --git a/packages/react-scripts/scripts/utils/frontierInit.js b/packages/react-scripts/scripts/utils/frontierInit.js index 29da677b116..b81347783f1 100644 --- a/packages/react-scripts/scripts/utils/frontierInit.js +++ b/packages/react-scripts/scripts/utils/frontierInit.js @@ -30,6 +30,10 @@ async function promptForConfig() { name: `Redux (Chances are high you don't need this yet)`, value: 'redux', }, + { + name: `Configure app for Electric Flow`, + value: 'redux', + }, ], }, ]; @@ -48,6 +52,9 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { if (additionalFeatures.includes('redux')) { configureRedux(appPath, useYarn, ownPath); } + if (additionalFeatures.includes('electic-flow')) { + configureEF(appPath); + } injectPolymerCode(appPath); const defaultModules = [ @@ -144,6 +151,14 @@ function configureRedux(appPath, useYarn, ownPath) { fs.copySync(templatePath, appPath, { overwrite: true }); } +function configureEF(appPath, useYarn, ownPath) { + // TODO - modify package.json to make sure name is correct for blueprint + // TODO - use blueprint.yml as a template + + const templatePath = path.join(ownPath, 'template-ef'); + fs.copySync(templatePath, appPath, { overwrite: true }); +} + function cleanupFrontierCode(appPath) {} function installModulesSync(modules, useYarn, saveDev = false) { diff --git a/packages/react-scripts/template/.buildpacks b/packages/react-scripts/template-ef/.buildpacks similarity index 100% rename from packages/react-scripts/template/.buildpacks rename to packages/react-scripts/template-ef/.buildpacks diff --git a/packages/react-scripts/template/Procfile b/packages/react-scripts/template-ef/Procfile similarity index 100% rename from packages/react-scripts/template/Procfile rename to packages/react-scripts/template-ef/Procfile diff --git a/packages/react-scripts/template/blueprint.yml b/packages/react-scripts/template-ef/blueprint.yml similarity index 100% rename from packages/react-scripts/template/blueprint.yml rename to packages/react-scripts/template-ef/blueprint.yml diff --git a/packages/react-scripts/template/hooks/pre-build/npm-build/create-npmrc.sh b/packages/react-scripts/template-ef/hooks/pre-build/npm-build/create-npmrc.sh similarity index 100% rename from packages/react-scripts/template/hooks/pre-build/npm-build/create-npmrc.sh rename to packages/react-scripts/template-ef/hooks/pre-build/npm-build/create-npmrc.sh diff --git a/packages/react-scripts/template/src/server.js b/packages/react-scripts/template-ef/src/server.js similarity index 100% rename from packages/react-scripts/template/src/server.js rename to packages/react-scripts/template-ef/src/server.js From 1a6880a3c60d0bd19a5b228afc9b564cd21304ae Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Wed, 13 Feb 2019 10:37:06 -0700 Subject: [PATCH 03/31] minor tweaking/cleaning up --- packages/react-scripts/scripts/init.js | 1 + .../scripts/utils/frontierInit.js | 26 ++++++++++++------- .../react-scripts/template-ef/blueprint.yml | 1 - .../hooks/pre-build/npm-build/create-npmrc.sh | 8 +++--- .../react-scripts/template-ef/src/server.js | 15 ++++++----- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 57436f1472e..468eec0f980 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -264,6 +264,7 @@ module.exports = async function( } console.log(); console.log('Happy hacking!'); + frontierInit.logEndingMessages(answers); }; function isReactInstalled(appPackage) { diff --git a/packages/react-scripts/scripts/utils/frontierInit.js b/packages/react-scripts/scripts/utils/frontierInit.js index b81347783f1..4d33282ddc8 100644 --- a/packages/react-scripts/scripts/utils/frontierInit.js +++ b/packages/react-scripts/scripts/utils/frontierInit.js @@ -12,8 +12,17 @@ module.exports = { promptForConfig, packageJsonWritten, cleanupFrontierCode, + logEndingMessages, }; +function logEndingMessages(answers) { + if (answers.includes('electric-flow')) { + console.log( + 'You will need to edit your blueprint.yml file before the Electric Flow build will work' + ); + } +} + async function promptForConfig() { console.log(fsCli.fsLogo('Frontier React Scripts')); const questions = [ @@ -26,13 +35,9 @@ async function promptForConfig() { name: 'Using a shared Polymer Component within your React App?', value: 'polymer', }, - { - name: `Redux (Chances are high you don't need this yet)`, - value: 'redux', - }, { name: `Configure app for Electric Flow`, - value: 'redux', + value: 'electric-flow', }, ], }, @@ -52,8 +57,8 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { if (additionalFeatures.includes('redux')) { configureRedux(appPath, useYarn, ownPath); } - if (additionalFeatures.includes('electic-flow')) { - configureEF(appPath); + if (additionalFeatures.includes('electric-flow')) { + configureEF(appPath, useYarn, ownPath); } injectPolymerCode(appPath); @@ -63,7 +68,10 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { 'fs-webdev/exo', ]; - const defaultDevModules = ['react-styleguidist@9.0.0-beta4', 'webpack@4.19.1']; + const defaultDevModules = [ + 'react-styleguidist@9.0.0-beta4', + 'webpack@4.19.1', + ]; installModulesSync(defaultModules, useYarn); installModulesSync(defaultDevModules, useYarn, true); @@ -153,7 +161,7 @@ function configureRedux(appPath, useYarn, ownPath) { function configureEF(appPath, useYarn, ownPath) { // TODO - modify package.json to make sure name is correct for blueprint - // TODO - use blueprint.yml as a template + // TODO - use blueprint.yml as a template const templatePath = path.join(ownPath, 'template-ef'); fs.copySync(templatePath, appPath, { overwrite: true }); diff --git a/packages/react-scripts/template-ef/blueprint.yml b/packages/react-scripts/template-ef/blueprint.yml index 03b9797237a..0d6d6d2eb34 100644 --- a/packages/react-scripts/template-ef/blueprint.yml +++ b/packages/react-scripts/template-ef/blueprint.yml @@ -10,7 +10,6 @@ deploy: int: {{APP_NAME}}: &APP_DEFAULTS type: "Heroku v1_0" - stack_name: heroku-18 location: development-fh5-useast1-heroku binding_sets: {{BINDING_PATH}}: diff --git a/packages/react-scripts/template-ef/hooks/pre-build/npm-build/create-npmrc.sh b/packages/react-scripts/template-ef/hooks/pre-build/npm-build/create-npmrc.sh index 90cbd6a25a7..9f09b759324 100644 --- a/packages/react-scripts/template-ef/hooks/pre-build/npm-build/create-npmrc.sh +++ b/packages/react-scripts/template-ef/hooks/pre-build/npm-build/create-npmrc.sh @@ -1,10 +1,8 @@ #!/bin/bash # Get artifactory token from SAS -ICS_AF_TOKEN=ec-sas-client frontier-hub-ics-public-artifactory-db password -NPMRC_TOKEN="//code.lds.org/artifactory/api/npm/npm-fhd/:_authToken=${ICS_AF_TOKEN}" -NPMRC_ICS_REGISTRY="@fs:registry=https://code.lds.org/artifactory/api/npm/npm-fhd/" +ICS_AF_TOKEN=$(ec-sas-client frontier-hub-ics-public-artifactory-db -b fchPassword) # Write .npmrc -echo $NPMRC_TOKEN > .npmrc -echo $NPMRC_ICS_REGISTRY >> .npmrc \ No newline at end of file +echo "//code.lds.org/artifactory/api/npm/npm-fhd/:_authToken=${ICS_AF_TOKEN}" > .npmrc +echo "@fs:registry=https://code.lds.org/artifactory/api/npm/npm-fhd/" >> .npmrc \ No newline at end of file diff --git a/packages/react-scripts/template-ef/src/server.js b/packages/react-scripts/template-ef/src/server.js index 374f5ab738a..720cecd0be9 100644 --- a/packages/react-scripts/template-ef/src/server.js +++ b/packages/react-scripts/template-ef/src/server.js @@ -1,10 +1,11 @@ -var express = require("express"); -var path = require("path"); -var app = express(); +const path = require('path'); +const express = require('express'); +const app = express(); -// React App -app.use(express.static(__dirname + "/build")); +// Statically serve up the production built React App +app.use(express.static(`${__dirname}/build`)); const port = process.env.PORT || 3000; -app.listen(port); -console.log("Listening on port " + port) +app.listen(port, () => { + console.log(`Listening on port ${port}`); +}); From 4072e9c39d1f7cc55e100c92ec97021de7aa497c Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Fri, 15 Feb 2019 13:49:39 -0700 Subject: [PATCH 04/31] removing unused logging stuff --- packages/react-scripts/scripts/init.js | 1 - packages/react-scripts/scripts/utils/frontierInit.js | 9 --------- 2 files changed, 10 deletions(-) diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 468eec0f980..57436f1472e 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -264,7 +264,6 @@ module.exports = async function( } console.log(); console.log('Happy hacking!'); - frontierInit.logEndingMessages(answers); }; function isReactInstalled(appPackage) { diff --git a/packages/react-scripts/scripts/utils/frontierInit.js b/packages/react-scripts/scripts/utils/frontierInit.js index 4d33282ddc8..52a2fb3e905 100644 --- a/packages/react-scripts/scripts/utils/frontierInit.js +++ b/packages/react-scripts/scripts/utils/frontierInit.js @@ -12,17 +12,8 @@ module.exports = { promptForConfig, packageJsonWritten, cleanupFrontierCode, - logEndingMessages, }; -function logEndingMessages(answers) { - if (answers.includes('electric-flow')) { - console.log( - 'You will need to edit your blueprint.yml file before the Electric Flow build will work' - ); - } -} - async function promptForConfig() { console.log(fsCli.fsLogo('Frontier React Scripts')); const questions = [ From 40a736823b4422654400c1eee28687648aea7c35 Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Fri, 15 Feb 2019 14:06:35 -0700 Subject: [PATCH 05/31] adding beta to the blueprint --- packages/react-scripts/template-ef/blueprint.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/template-ef/blueprint.yml b/packages/react-scripts/template-ef/blueprint.yml index 0d6d6d2eb34..21a6946ea53 100644 --- a/packages/react-scripts/template-ef/blueprint.yml +++ b/packages/react-scripts/template-ef/blueprint.yml @@ -24,11 +24,22 @@ deploy: non_ssl_action: type: redirect_to_https append_slash: true + beta: + {{APP_NAME}}: + <<: *APP_DEFAULTS + type: "Heroku v1_0" + location: test-fh3-useast1-heroku + binding_sets: + {{BINDING_PATH}}: + - type: "Service v1_0" + sites: + - beta + bindings: + <<: *BINDING_DEFAULTS prod: {{APP_NAME}}: <<: *APP_DEFAULTS type: "Heroku v1_0" - stack_name: cedar-14 location: production-fh1-useast1-heroku binding_sets: {{BINDING_PATH}}: @@ -40,4 +51,5 @@ deploy: deliver: deploy_order: - int + - beta - prod From 5a60c856a949acd521fb9125bb7df2b0df7587e3 Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Tue, 19 Feb 2019 08:35:58 -0700 Subject: [PATCH 06/31] added eslint-config-frontier:recommended to the templates, as well as to the webpack.config used during development --- .../react-scripts/config/webpack.config.js | 6 +- packages/react-scripts/gitTagForkedStyle.js | 6 -- packages/react-scripts/package.json | 3 - .../scripts/utils/frontierInit.js | 90 ++++++++----------- packages/react-scripts/template/.env | 2 + .../template/src/components/App.jsx | 6 +- .../template/src/components/index.js | 2 +- packages/react-scripts/template/src/index.js | 1 + 8 files changed, 48 insertions(+), 68 deletions(-) delete mode 100644 packages/react-scripts/gitTagForkedStyle.js create mode 100644 packages/react-scripts/template/.env diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 6f517ff4f4d..03855ea9d8e 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -313,7 +313,11 @@ module.exports = function(webpackEnv) { eslintPath: require.resolve('eslint'), // @remove-on-eject-begin baseConfig: { - extends: [require.resolve('eslint-config-react-app')], + extends: [ + require + .resolve('eslint-config-frontier') + .replace('index.js', 'recommended.js'), + ], settings: { react: { version: '999.999.999' } }, }, ignore: false, diff --git a/packages/react-scripts/gitTagForkedStyle.js b/packages/react-scripts/gitTagForkedStyle.js deleted file mode 100644 index d5953ce37ef..00000000000 --- a/packages/react-scripts/gitTagForkedStyle.js +++ /dev/null @@ -1,6 +0,0 @@ -const { version, upstreamVersion } = require('./package'); -const osUtils = require('./scripts/utils/osUtils'); - -const command = 'git'; -const args = ['tag', `v${version}-upstream-${upstreamVersion}`]; -osUtils.runExternalCommandSync(command, args); diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 77f774f4284..ce8d350b838 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -8,9 +8,6 @@ "engines": { "node": ">=6" }, - "scripts": { - "postversion": "node gitTagForkedStyle.js" - }, "bugs": { "url": "https://github.com/fs-webdev/create-react-app/issues" }, diff --git a/packages/react-scripts/scripts/utils/frontierInit.js b/packages/react-scripts/scripts/utils/frontierInit.js index 52a2fb3e905..01b5c3c8f44 100644 --- a/packages/react-scripts/scripts/utils/frontierInit.js +++ b/packages/react-scripts/scripts/utils/frontierInit.js @@ -45,9 +45,6 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { if (additionalFeatures.includes('polymer')) { configurePolymer(appPath, useYarn); } - if (additionalFeatures.includes('redux')) { - configureRedux(appPath, useYarn, ownPath); - } if (additionalFeatures.includes('electric-flow')) { configureEF(appPath, useYarn, ownPath); } @@ -60,25 +57,35 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { ]; const defaultDevModules = [ + 'eslint@5.6.0', + 'fs-webdev/eslint-config-frontier#settingUpRecommendedReactConfig', 'react-styleguidist@9.0.0-beta4', 'webpack@4.19.1', ]; installModulesSync(defaultModules, useYarn); installModulesSync(defaultDevModules, useYarn, true); - addStyleguidistScriptsToPackageJson(appPath); -} -function addStyleguidistScriptsToPackageJson(appPath) { - //we read the package.json using fs instead of require() because require() uses the - //cached result from earlier, even though the package.json has been updated previously. - const appPackage = JSON.parse( + alterPackageJsonFile(appPath, appPackage => { + const packageJson = { ...appPackage }; + const additionalScripts = { + styleguide: 'styleguidist server --open', + 'styleguide:build': 'styleguidist build', + lint: 'eslint src/', + 'lint:fix': 'eslint src/ --fix', + }; + packageJson.scripts = { ...packageJson.scripts, ...additionalScripts }; + packageJson.eslintConfig = { + extends: ['frontier/recommended'], + }; + return packageJson; + }); +} +function alterPackageJsonFile(appPath, extendFunction) { + let appPackage = JSON.parse( fs.readFileSync(path.join(appPath, 'package.json'), 'UTF8') ); - - appPackage.scripts.styleguide = 'styleguidist server --open'; - appPackage.scripts['styleguide:build'] = 'styleguidist build'; - + appPackage = extendFunction(appPackage); fs.writeFileSync( path.join(appPath, 'package.json'), JSON.stringify(appPackage, null, 2) + os.EOL @@ -86,33 +93,23 @@ function addStyleguidistScriptsToPackageJson(appPath) { } function configurePolymer(appPath, useYarn) { - //we read the package.json using fs instead of require() because require() uses the - //cached result from earlier, even though the package.json has been updated previously. - const appPackage = JSON.parse( - fs.readFileSync(path.join(appPath, 'package.json'), 'UTF8') - ); - appPackage.vendorCopy = [ - { - from: - 'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js', - to: 'public/vendor/custom-elements-es5-adapter.js', - }, - { - from: - 'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js', - to: 'public/vendor/webcomponents-bundle.js', - }, - ]; - - const { postinstall } = appPackage.scripts; - appPackage.scripts.postinstall = postinstall - ? `${postinstall} && ` - : '' + 'vendor-copy'; - - fs.writeFileSync( - path.join(appPath, 'package.json'), - JSON.stringify(appPackage, null, 2) + os.EOL - ); + alterPackageJsonFile(appPath, appPackage => { + const packageJson = { ...appPackage }; + packageJson.vendorCopy = [ + { + from: + 'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js', + to: 'public/vendor/custom-elements-es5-adapter.js', + }, + { + from: + 'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js', + to: 'public/vendor/webcomponents-bundle.js', + }, + ]; + packageJson.scripts.postinstall = 'vendor-copy'; + return packageJson; + }); const polymerModules = [ 'vendor-copy@2.0.0', @@ -137,19 +134,6 @@ function injectPolymerCode(appPath) { fs.writeFileSync(indexPath, indexHtml); } -function configureRedux(appPath, useYarn, ownPath) { - const reduxModules = [ - 'redux@4.0.0', - 'react-redux@5.0.7', - 'redux-logger@3.0.6', - 'redux-thunk@2.3.0', - ]; - installModulesSync(reduxModules, useYarn); - - const templatePath = path.join(ownPath, 'template-redux'); - fs.copySync(templatePath, appPath, { overwrite: true }); -} - function configureEF(appPath, useYarn, ownPath) { // TODO - modify package.json to make sure name is correct for blueprint // TODO - use blueprint.yml as a template diff --git a/packages/react-scripts/template/.env b/packages/react-scripts/template/.env new file mode 100644 index 00000000000..93740cd04a4 --- /dev/null +++ b/packages/react-scripts/template/.env @@ -0,0 +1,2 @@ +#dont worry about using newer versions of libraries than react-scripts +SKIP_PREFLIGHT_CHECK=true diff --git a/packages/react-scripts/template/src/components/App.jsx b/packages/react-scripts/template/src/components/App.jsx index e347894b031..8e60245cab1 100644 --- a/packages/react-scripts/template/src/components/App.jsx +++ b/packages/react-scripts/template/src/components/App.jsx @@ -1,9 +1,8 @@ -import React, { Component } from 'react'; +import React from 'react'; import logo from './logo.svg'; import styles from './App.module.css'; -class App extends Component { - render() { +function App() { return (
@@ -22,7 +21,6 @@ class App extends Component {
); - } } export default App; diff --git a/packages/react-scripts/template/src/components/index.js b/packages/react-scripts/template/src/components/index.js index 0626e6e26a6..f1f2a246e94 100644 --- a/packages/react-scripts/template/src/components/index.js +++ b/packages/react-scripts/template/src/components/index.js @@ -1,3 +1,3 @@ import App from './App'; -export { App }; +export default App; diff --git a/packages/react-scripts/template/src/index.js b/packages/react-scripts/template/src/index.js index fece4db44c8..b83f21d7461 100644 --- a/packages/react-scripts/template/src/index.js +++ b/packages/react-scripts/template/src/index.js @@ -4,6 +4,7 @@ import './index.css'; import App from './components/App'; import * as serviceWorker from './serviceWorker'; +// eslint-disable-next-line react/jsx-filename-extension ReactDOM.render(, document.getElementById('root')); // If you want your app to work offline and load faster, you can change From cb6931cc49a99ba90dab8fbc29165e7a567082fd Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Tue, 19 Feb 2019 09:22:29 -0700 Subject: [PATCH 07/31] fixing pre-commit stuff to work with our prettier rules --- package.json | 2 +- packages/react-scripts/config/webpack.config.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 97e13dd1180..721830780e9 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "lint-staged": { "*.{js,md,css,html}": [ - "prettier --trailing-comma es5 --single-quote --write", + "prettier --pinrt-width 100 es5 --single-quote --write", "git add" ], "yarn.lock": [ diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 03855ea9d8e..c74deaf6bd8 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -314,6 +314,8 @@ module.exports = function(webpackEnv) { // @remove-on-eject-begin baseConfig: { extends: [ + //in order to keep backwards compatability for people currently using eslint-config-frontier + //with their old polymer projects, we have to point to the recommended file instead of index.js require .resolve('eslint-config-frontier') .replace('index.js', 'recommended.js'), From 1b2c1074c6bad54db521e4810ec6575c9c5eef9a Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Tue, 19 Feb 2019 09:27:45 -0700 Subject: [PATCH 08/31] trying to fix the prettier changes to a template file From 91a29e7049bcf318f2957a7ce46c70766179c9aa Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Tue, 19 Feb 2019 09:28:32 -0700 Subject: [PATCH 09/31] trying to fix the prettier changes to a template file --- package.json | 2 +- packages/react-scripts/template/src/serviceWorker.js | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 721830780e9..3d129d0945f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "lint-staged": { "*.{js,md,css,html}": [ - "prettier --pinrt-width 100 es5 --single-quote --write", + "prettier --print-width 100 es5 --single-quote --write", "git add" ], "yarn.lock": [ diff --git a/packages/react-scripts/template/src/serviceWorker.js b/packages/react-scripts/template/src/serviceWorker.js index 2283ff9ced1..6fc3f97d2dd 100644 --- a/packages/react-scripts/template/src/serviceWorker.js +++ b/packages/react-scripts/template/src/serviceWorker.js @@ -15,9 +15,7 @@ const isLocalhost = Boolean( // [::1] is the IPv6 localhost address. window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) ); export function register(config) { @@ -120,9 +118,7 @@ function checkValidServiceWorker(swUrl, config) { } }) .catch(() => { - console.log( - 'No internet connection found. App is running in offline mode.' - ); + console.log('No internet connection found. App is running in offline mode.'); }); } From 02b48580cbd337463ad47ff977713948bc7fe2ac Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Tue, 19 Feb 2019 10:04:44 -0700 Subject: [PATCH 10/31] 1.4.4 version bump; --- CHANGELOG-FRONTIER.md | 6 ++++++ packages/react-scripts/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-FRONTIER.md b/CHANGELOG-FRONTIER.md index e27584b309f..489babb16a0 100644 --- a/CHANGELOG-FRONTIER.md +++ b/CHANGELOG-FRONTIER.md @@ -1,3 +1,9 @@ +## 1.4.4 + +#### :rocket: New Feature + +- eslint-config-frontier is setup and being used in the template for new react apps + ## 1.4.3 #### :bug: Bug Fix diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index ce8d350b838..3b85cb95fca 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@fs/react-scripts", - "version": "1.4.3", + "version": "1.4.4", "upstreamVersion": "2.1.3", "description": "Configuration and scripts for Create React App.", "repository": "fs-webdev/create-react-app", From 9cd7a06ecedc82b077cda27ff4fc15e69e94a89d Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Tue, 19 Feb 2019 10:07:02 -0700 Subject: [PATCH 11/31] readme update --- README-FRONTIER.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README-FRONTIER.md b/README-FRONTIER.md index ee9b3ceef2c..c462d674906 100644 --- a/README-FRONTIER.md +++ b/README-FRONTIER.md @@ -26,12 +26,12 @@ If you have cloned this repo and made changes locally and want to test them befo - When the develop branch is in a good state and ready for release follow these steps 1. Bump the version in `packages/react-scripts/package.json` 2. Make a PR from develop into frontierMaster - - Squash commits and merge. + - Nice url to go straight to making a PR with the correct branches set + - https://github.com/fs-webdev/create-react-app/compare/frontierMaster...fs-webdev:develop?expand=1 3. At this point, Travis will pickup the change in frontierMaster and attempt to publish to artifactory ## Merging Upstream changes from Facebook - When we are ready to pull in changes from Facebook, here are the steps 1. Make a PR from facebook's master into our fork's master. This url SHOULD be what you want... please verify before blindly doing anything @@ -43,4 +43,3 @@ When we are ready to pull in changes from Facebook, here are the steps 5. Run `git merge ${HASH_OF_RELEASE_YOU_WANT}` 6. Fix any merge conflicts 7. Probably a good idea to cut a release at that point. - From 64feeade80ad5463026cd7e8a7b43e90b5145f24 Mon Sep 17 00:00:00 2001 From: Joey Cozza Date: Thu, 21 Feb 2019 10:18:05 -0700 Subject: [PATCH 12/31] adding eslint to tests, and removed react-router-dom from default dependencies --- packages/react-scripts/scripts/utils/frontierInit.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/scripts/utils/frontierInit.js b/packages/react-scripts/scripts/utils/frontierInit.js index 959d4a9e117..bad5731f537 100644 --- a/packages/react-scripts/scripts/utils/frontierInit.js +++ b/packages/react-scripts/scripts/utils/frontierInit.js @@ -50,11 +50,7 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { } injectPolymerCode(appPath); - const defaultModules = [ - 'http-proxy-middleware@0.19.0', - 'react-router-dom@4.3.1', - 'fs-webdev/exo', - ]; + const defaultModules = ['http-proxy-middleware@0.19.0', 'fs-webdev/exo']; const defaultDevModules = [ 'eslint@5.6.0', @@ -73,6 +69,7 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) { 'styleguide:build': 'styleguidist build', lint: 'eslint src/', 'lint:fix': 'eslint src/ --fix', + test: `eslint src/ && ${packageJson.scripts.test}`, }; packageJson.scripts = { ...packageJson.scripts, ...additionalScripts }; packageJson.eslintConfig = { From a53b58f8c47ddd584f56c9571c8bd65a28f44b65 Mon Sep 17 00:00:00 2001 From: Tyler Graf Date: Thu, 21 Feb 2019 15:20:16 -0700 Subject: [PATCH 13/31] Edit webpack and webpack dev server configs to work with hf. --- packages/react-scripts/config/webpack.config.js | 14 ++++++++++++-- .../config/webpackDevServer.config.js | 4 ++-- packages/react-scripts/package.json | 3 ++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 54f14bc1e2c..c5f165e2856 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -31,6 +31,8 @@ const getClientEnvironment = require('./env'); const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin-alt'); const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); + // @remove-on-eject-begin const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier'); // @remove-on-eject-end @@ -237,12 +239,12 @@ module.exports = function(webpackEnv) { // https://twitter.com/wSokra/status/969633336732905474 // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 splitChunks: { - chunks: 'all', + chunks: 'async', name: false, }, // Keep the runtime chunk separated to enable long term caching // https://twitter.com/wSokra/status/969679223278505985 - runtimeChunk: true, + runtimeChunk: false, }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. @@ -512,12 +514,20 @@ module.exports = function(webpackEnv) { ], }, plugins: [ + new CopyWebpackPlugin([ + { + from: path.join(paths.appNodeModules, `hf/dist/${isEnvProduction ? 'prod' : 'dev'}`), + to: 'static/hf/[name].[ext]', + toType: 'template', + }, + ]), // Generates an `index.html` file with the