From 4afde945f316155dcbe10097a832087a64351388 Mon Sep 17 00:00:00 2001 From: gmdayley Date: Wed, 13 Feb 2019 08:25:16 -0700 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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