@@ -11,7 +11,6 @@ module.exports = {
1111 installFrontierDependencies,
1212 promptForConfig,
1313 packageJsonWritten,
14- cleanupFrontierCode,
1514} ;
1615
1716async function promptForConfig ( ) {
@@ -44,19 +43,18 @@ async function promptForConfig() {
4443
4544function packageJsonWritten ( ) { }
4645
47- function installFrontierDependencies ( appPath , answers , useYarn , ownPath ) {
46+ function installFrontierDependencies ( appPath , answers , ownPath ) {
4847 const { additionalFeatures } = answers ;
4948
5049 if ( additionalFeatures . includes ( 'polymer' ) ) {
51- configurePolymer ( appPath , useYarn ) ;
50+ configurePolymer ( appPath ) ;
5251 }
5352 if ( additionalFeatures . includes ( 'electric-flow' ) ) {
54- configureEF ( appPath , useYarn , ownPath ) ;
53+ configureEF ( appPath , ownPath ) ;
5554 }
5655 if ( additionalFeatures . includes ( 'header-footer' ) ) {
57- configureHF ( appPath , useYarn , ownPath ) ;
56+ configureHF ( appPath , ownPath ) ;
5857 }
59- injectPolymerCode ( appPath ) ;
6058
6159 const defaultModules = [ 'http-proxy-middleware@0.19.0' , 'fs-webdev/exo' ] ;
6260
@@ -67,8 +65,8 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
6765 'webpack@4.19.1' ,
6866 ] ;
6967
70- installModulesSync ( defaultModules , useYarn ) ;
71- installModulesSync ( defaultDevModules , useYarn , true ) ;
68+ installModulesSync ( defaultModules ) ;
69+ installModulesSync ( defaultDevModules , true ) ;
7270
7371 alterPackageJsonFile ( appPath , appPackage => {
7472 const packageJson = { ...appPackage } ;
@@ -81,7 +79,7 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
8179 } ;
8280 packageJson . scripts = { ...packageJson . scripts , ...additionalScripts } ;
8381 packageJson . eslintConfig = {
84- extends : [ 'frontier/recommended ' ] ,
82+ extends : [ '@fs/eslint-config-frontier-react ' ] ,
8583 } ;
8684 return packageJson ;
8785 } ) ;
@@ -95,7 +93,7 @@ function alterPackageJsonFile(appPath, extendFunction) {
9593 ) ;
9694}
9795
98- function configurePolymer ( appPath , useYarn ) {
96+ function configurePolymer ( appPath ) {
9997 alterPackageJsonFile ( appPath , appPackage => {
10098 const packageJson = { ...appPackage } ;
10199 packageJson . vendorCopy = [
@@ -112,8 +110,9 @@ function configurePolymer(appPath, useYarn) {
112110 return packageJson ;
113111 } ) ;
114112
113+ injectPolymerCode ( appPath ) ;
115114 const polymerModules = [ 'vendor-copy@2.0.0' , '@webcomponents/webcomponentsjs@2.1.3' ] ;
116- installModulesSync ( polymerModules , useYarn , true ) ;
115+ installModulesSync ( polymerModules , true ) ;
117116}
118117
119118function injectPolymerCode ( appPath ) {
@@ -129,7 +128,7 @@ function injectPolymerCode(appPath) {
129128 fs . writeFileSync ( indexPath , indexHtml ) ;
130129}
131130
132- function configureEF ( appPath , useYarn , ownPath ) {
131+ function configureEF ( appPath , ownPath ) {
133132 // TODO - modify package.json to make sure name is correct for blueprint
134133 // TODO - use blueprint.yml as a template
135134
@@ -139,68 +138,54 @@ function configureEF(appPath, useYarn, ownPath) {
139138 alterPackageJsonFile ( appPath , appPackage => {
140139 const packageJson = { ...appPackage } ;
141140 const additionalScripts = {
142- " heroku-prebuild" : " ./heroku-prebuild.sh"
141+ ' heroku-prebuild' : ' ./heroku-prebuild.sh' ,
143142 } ;
144143 packageJson . scripts = sortScripts ( { ...packageJson . scripts , ...additionalScripts } ) ;
145144 return packageJson ;
146145 } ) ;
147146}
148147
149- function configureHF ( appPath , useYarn , ownPath ) {
150-
148+ function configureHF ( appPath , ownPath ) {
151149 const templatePath = path . join ( ownPath , 'template-hf' ) ;
152150 fs . copySync ( templatePath , appPath , { overwrite : true } ) ;
153151
154152 alterPackageJsonFile ( appPath , appPackage => {
155153 const packageJson = { ...appPackage } ;
156154 const additionalScripts = {
157- " build:prod" : " PUBLIC_URL=https://edge.fscdn.org/assets/ react-scripts build" ,
158- " heroku-postbuild" : " npm run build:prod"
155+ ' build:prod' : ' PUBLIC_URL=https://edge.fscdn.org/assets/ react-scripts build' ,
156+ ' heroku-postbuild' : ' npm run build:prod' ,
159157 } ;
160158 packageJson . scripts = sortScripts ( { ...packageJson . scripts , ...additionalScripts } ) ;
161- packageJson . main = " ./server.js" ;
159+ packageJson . main = ' ./server.js' ;
162160
163161 return packageJson ;
164162 } ) ;
165163
164+ createLocalEnvFile ( ) ;
166165 let modules = [
167166 'github:fs-webdev/hf#cra' ,
168167 'github:fs-webdev/snow#cra' ,
169168 'github:fs-webdev/startup' ,
170- ]
171- installModulesSync ( modules , useYarn ) ;
169+ ] ;
170+ installModulesSync ( modules ) ;
172171}
173172
174- function cleanupFrontierCode ( appPath ) { }
175-
176- function installModulesSync ( modules , useYarn , saveDev = false ) {
177- const { command, args } = buildInstallCommandAndArgs ( useYarn , saveDev ) ;
178- osUtils . runExternalCommandSync ( command , args . concat ( modules ) ) ;
173+ function installModulesSync ( modules , saveDev = false ) {
174+ const command = 'npm' ;
175+ const args = [ 'install' , `--save${ saveDev ? '-dev' : '' } ` ] . concat ( modules ) ;
176+ osUtils . runExternalCommandSync ( command , args ) ;
179177}
180178
181- function buildInstallCommandAndArgs ( useYarn , saveDev = false ) {
182- let command ;
183- let args ;
184- if ( useYarn ) {
185- command = 'yarnpkg' ;
186- args = [ 'add' ] ;
187- if ( saveDev ) {
188- args . push ( '--dev' ) ;
189- }
190- } else {
191- command = 'npm' ;
192- args = [ 'install' , '--save' ] ;
193- if ( saveDev ) {
194- args [ 1 ] = '--save-dev' ;
195- }
196- }
197- return { command, args } ;
179+ function createLocalEnvFile ( ) {
180+ osUtils . runExternalCommandSync ( 'npx' , [ '@fs/fr-cli' , 'env' , 'local' ] ) ;
198181}
199182
200- function sortScripts ( scripts ) {
183+ function sortScripts ( scripts ) {
201184 const sortedScripts = { } ;
202- Object . keys ( scripts ) . sort ( ) . forEach ( function ( key ) {
203- sortedScripts [ key ] = scripts [ key ] ;
204- } ) ;
185+ Object . keys ( scripts )
186+ . sort ( )
187+ . forEach ( function ( key ) {
188+ sortedScripts [ key ] = scripts [ key ] ;
189+ } ) ;
205190 return sortedScripts ;
206191}
0 commit comments