@@ -45,9 +45,6 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
4545  if  ( additionalFeatures . includes ( 'polymer' ) )  { 
4646    configurePolymer ( appPath ,  useYarn ) ; 
4747  } 
48-   if  ( additionalFeatures . includes ( 'redux' ) )  { 
49-     configureRedux ( appPath ,  useYarn ,  ownPath ) ; 
50-   } 
5148  if  ( additionalFeatures . includes ( 'electric-flow' ) )  { 
5249    configureEF ( appPath ,  useYarn ,  ownPath ) ; 
5350  } 
@@ -60,59 +57,59 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
6057  ] ; 
6158
6259  const  defaultDevModules  =  [ 
60+     'eslint@5.6.0' , 
61+     'fs-webdev/eslint-config-frontier#settingUpRecommendedReactConfig' , 
6362    'react-styleguidist@9.0.0-beta4' , 
6463    'webpack@4.19.1' , 
6564  ] ; 
6665
6766  installModulesSync ( defaultModules ,  useYarn ) ; 
6867  installModulesSync ( defaultDevModules ,  useYarn ,  true ) ; 
69-   addStyleguidistScriptsToPackageJson ( appPath ) ; 
70- } 
7168
72- function  addStyleguidistScriptsToPackageJson ( appPath )  { 
73-   //we read the package.json using fs instead of require() because require() uses the 
74-   //cached result from earlier, even though the package.json has been updated previously. 
75-   const  appPackage  =  JSON . parse ( 
69+   alterPackageJsonFile ( appPath ,  appPackage  =>  { 
70+     const  packageJson  =  {  ...appPackage  } ; 
71+     const  additionalScripts  =  { 
72+       styleguide : 'styleguidist server --open' , 
73+       'styleguide:build' : 'styleguidist build' , 
74+       lint : 'eslint src/' , 
75+       'lint:fix' : 'eslint src/ --fix' , 
76+     } ; 
77+     packageJson . scripts  =  {  ...packageJson . scripts ,  ...additionalScripts  } ; 
78+     packageJson . eslintConfig  =  { 
79+       extends : [ 'frontier/recommended' ] , 
80+     } ; 
81+     return  packageJson ; 
82+   } ) ; 
83+ } 
84+ function  alterPackageJsonFile ( appPath ,  extendFunction )  { 
85+   let  appPackage  =  JSON . parse ( 
7686    fs . readFileSync ( path . join ( appPath ,  'package.json' ) ,  'UTF8' ) 
7787  ) ; 
78- 
79-   appPackage . scripts . styleguide  =  'styleguidist server --open' ; 
80-   appPackage . scripts [ 'styleguide:build' ]  =  'styleguidist build' ; 
81- 
88+   appPackage  =  extendFunction ( appPackage ) ; 
8289  fs . writeFileSync ( 
8390    path . join ( appPath ,  'package.json' ) , 
8491    JSON . stringify ( appPackage ,  null ,  2 )  +  os . EOL 
8592  ) ; 
8693} 
8794
8895function  configurePolymer ( appPath ,  useYarn )  { 
89-   //we read the package.json using fs instead of require() because require() uses the 
90-   //cached result from earlier, even though the package.json has been updated previously. 
91-   const  appPackage  =  JSON . parse ( 
92-     fs . readFileSync ( path . join ( appPath ,  'package.json' ) ,  'UTF8' ) 
93-   ) ; 
94-   appPackage . vendorCopy  =  [ 
95-     { 
96-       from :
97-         'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js' , 
98-       to : 'public/vendor/custom-elements-es5-adapter.js' , 
99-     } , 
100-     { 
101-       from :
102-         'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js' , 
103-       to : 'public/vendor/webcomponents-bundle.js' , 
104-     } , 
105-   ] ; 
106- 
107-   const  {  postinstall }  =  appPackage . scripts ; 
108-   appPackage . scripts . postinstall  =  postinstall 
109-     ? `${ postinstall }   && ` 
110-     : ''  +  'vendor-copy' ; 
111- 
112-   fs . writeFileSync ( 
113-     path . join ( appPath ,  'package.json' ) , 
114-     JSON . stringify ( appPackage ,  null ,  2 )  +  os . EOL 
115-   ) ; 
96+   alterPackageJsonFile ( appPath ,  appPackage  =>  { 
97+     const  packageJson  =  {  ...appPackage  } ; 
98+     packageJson . vendorCopy  =  [ 
99+       { 
100+         from :
101+           'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js' , 
102+         to : 'public/vendor/custom-elements-es5-adapter.js' , 
103+       } , 
104+       { 
105+         from :
106+           'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js' , 
107+         to : 'public/vendor/webcomponents-bundle.js' , 
108+       } , 
109+     ] ; 
110+     packageJson . scripts . postinstall  =  'vendor-copy' ; 
111+     return  packageJson ; 
112+   } ) ; 
116113
117114  const  polymerModules  =  [ 
118115    'vendor-copy@2.0.0' , 
@@ -137,19 +134,6 @@ function injectPolymerCode(appPath) {
137134  fs . writeFileSync ( indexPath ,  indexHtml ) ; 
138135} 
139136
140- function  configureRedux ( appPath ,  useYarn ,  ownPath )  { 
141-   const  reduxModules  =  [ 
142-     'redux@4.0.0' , 
143-     'react-redux@5.0.7' , 
144-     'redux-logger@3.0.6' , 
145-     'redux-thunk@2.3.0' , 
146-   ] ; 
147-   installModulesSync ( reduxModules ,  useYarn ) ; 
148- 
149-   const  templatePath  =  path . join ( ownPath ,  'template-redux' ) ; 
150-   fs . copySync ( templatePath ,  appPath ,  {  overwrite : true  } ) ; 
151- } 
152- 
153137function  configureEF ( appPath ,  useYarn ,  ownPath )  { 
154138  // TODO - modify package.json to make sure name is correct for blueprint 
155139  // TODO - use blueprint.yml as a template 
0 commit comments