@@ -20,16 +20,21 @@ async function promptForConfig() {
2020 {
2121 type : 'checkbox' ,
2222 name : 'additionalFeatures' ,
23- message : 'What additional features does your app require' ,
23+ message : 'What additional features does your app require (these are checkboxes)' ,
24+ default : [ 'electric-flow' , 'header-footer' ] ,
2425 choices : [
25- {
26- name : 'Using a shared Polymer Component within your React App?' ,
27- value : 'polymer' ,
28- } ,
2926 {
3027 name : `Configure app for Electric Flow` ,
3128 value : 'electric-flow' ,
3229 } ,
30+ {
31+ name : `Include hf (header/footer)` ,
32+ value : 'header-footer' ,
33+ } ,
34+ {
35+ name : 'Using a shared Polymer Component within your React App?' ,
36+ value : 'polymer' ,
37+ } ,
3338 ] ,
3439 } ,
3540 ] ;
@@ -48,6 +53,9 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
4853 if ( additionalFeatures . includes ( 'electric-flow' ) ) {
4954 configureEF ( appPath , useYarn , ownPath ) ;
5055 }
56+ if ( additionalFeatures . includes ( 'header-footer' ) ) {
57+ configureHF ( appPath , useYarn , ownPath ) ;
58+ }
5159 injectPolymerCode ( appPath ) ;
5260
5361 const defaultModules = [ 'http-proxy-middleware@0.19.0' , 'fs-webdev/exo' ] ;
@@ -127,6 +135,40 @@ function configureEF(appPath, useYarn, ownPath) {
127135
128136 const templatePath = path . join ( ownPath , 'template-ef' ) ;
129137 fs . copySync ( templatePath , appPath , { overwrite : true } ) ;
138+
139+ alterPackageJsonFile ( appPath , appPackage => {
140+ const packageJson = { ...appPackage } ;
141+ const additionalScripts = {
142+ "heroku-prebuild" : "./heroku-prebuild.sh"
143+ } ;
144+ packageJson . scripts = sortScripts ( { ...packageJson . scripts , ...additionalScripts } ) ;
145+ return packageJson ;
146+ } ) ;
147+ }
148+
149+ function configureHF ( appPath , useYarn , ownPath ) {
150+
151+ const templatePath = path . join ( ownPath , 'template-hf' ) ;
152+ fs . copySync ( templatePath , appPath , { overwrite : true } ) ;
153+
154+ alterPackageJsonFile ( appPath , appPackage => {
155+ const packageJson = { ...appPackage } ;
156+ const additionalScripts = {
157+ "build:prod" : "PUBLIC_URL=https://edge.fscdn.org/assets/ react-scripts build" ,
158+ "heroku-postbuild" : "npm run build:prod"
159+ } ;
160+ packageJson . scripts = sortScripts ( { ...packageJson . scripts , ...additionalScripts } ) ;
161+ packageJson . main = "./server.js" ;
162+
163+ return packageJson ;
164+ } ) ;
165+
166+ let modules = [
167+ 'github:fs-webdev/hf#cra' ,
168+ 'github:fs-webdev/snow#cra' ,
169+ 'github:fs-webdev/startup' ,
170+ ]
171+ installModulesSync ( modules , useYarn ) ;
130172}
131173
132174function cleanupFrontierCode ( appPath ) { }
@@ -154,3 +196,11 @@ function buildInstallCommandAndArgs(useYarn, saveDev = false) {
154196 }
155197 return { command, args } ;
156198}
199+
200+ function sortScripts ( scripts ) {
201+ const sortedScripts = { } ;
202+ Object . keys ( scripts ) . sort ( ) . forEach ( function ( key ) {
203+ sortedScripts [ key ] = scripts [ key ] ;
204+ } ) ;
205+ return sortedScripts ;
206+ }
0 commit comments