mirror of
https://github.com/status-im/re-natal.git
synced 2025-01-28 13:24:54 +00:00
remove code duplications when creating build profiles
This commit is contained in:
parent
fabcaab72d
commit
14a120ec90
@ -26,12 +26,6 @@ projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
|
|||||||
projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g
|
projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g
|
||||||
interfaceDepsRx = /\$INTERFACE_DEPS\$/g
|
interfaceDepsRx = /\$INTERFACE_DEPS\$/g
|
||||||
platformRx = /\$PLATFORM\$/g
|
platformRx = /\$PLATFORM\$/g
|
||||||
devProfilesRx = /#_\(\$DEV_PROFILES\$\)/g
|
|
||||||
devProfilesId = "#_($DEV_PROFILES$)"
|
|
||||||
prodProfilesRx = /#_\(\$PROD_PROFILES\$\)/g
|
|
||||||
prodProfilesId = "#_($PROD_PROFILES$)"
|
|
||||||
advProfilesRx = /#_\(\$ADVANCED_PROFILES\$\)/g
|
|
||||||
advProfilesId = "#_($ADVANCED_PROFILES$)"
|
|
||||||
platformCleanRx = /#_\(\$PLATFORM_CLEAN\$\)/g
|
platformCleanRx = /#_\(\$PLATFORM_CLEAN\$\)/g
|
||||||
platformCleanId = "#_($PLATFORM_CLEAN$)"
|
platformCleanId = "#_($PLATFORM_CLEAN$)"
|
||||||
devHostRx = /\$DEV_HOST\$/g
|
devHostRx = /\$DEV_HOST\$/g
|
||||||
@ -43,6 +37,16 @@ rnVersion = '0.46.3'
|
|||||||
rnWinVersion = '0.46.0-rc.0'
|
rnWinVersion = '0.46.0-rc.0'
|
||||||
rnPackagerPort = 8081
|
rnPackagerPort = 8081
|
||||||
process.title = 're-natal'
|
process.title = 're-natal'
|
||||||
|
buildProfiles =
|
||||||
|
dev:
|
||||||
|
profilesRx: /#_\(\$DEV_PROFILES\$\)/g
|
||||||
|
profilesId: "#_($DEV_PROFILES$)"
|
||||||
|
prod:
|
||||||
|
profilesRx: /#_\(\$PROD_PROFILES\$\)/g
|
||||||
|
profilesId: "#_($PROD_PROFILES$)"
|
||||||
|
advanced:
|
||||||
|
profilesRx: /#_\(\$ADVANCED_PROFILES\$\)/g
|
||||||
|
profilesId: "#_($ADVANCED_PROFILES$)"
|
||||||
interfaceConf =
|
interfaceConf =
|
||||||
'reagent':
|
'reagent':
|
||||||
cljsDir: "cljs-reagent"
|
cljsDir: "cljs-reagent"
|
||||||
@ -405,6 +409,15 @@ copySrcFiles = (interfaceName, projName, projNameUs, projNameHyph) ->
|
|||||||
for namespace in shims
|
for namespace in shims
|
||||||
shimCljsNamespace(namespace)
|
shimCljsNamespace(namespace)
|
||||||
|
|
||||||
|
creteBuildConfigs = (profiles, platforms) ->
|
||||||
|
builds = {}
|
||||||
|
for profile in profiles
|
||||||
|
template = readFile "#{resources}/#{profile}.profile"
|
||||||
|
configs = platforms.map (platform) -> template.replace(platformRx, platform)
|
||||||
|
configs.push buildProfiles[profile].profilesId
|
||||||
|
builds[profile] = configs.join("\n")
|
||||||
|
builds
|
||||||
|
|
||||||
copyProjectClj = (interfaceName, projNameHyph) ->
|
copyProjectClj = (interfaceName, projNameHyph) ->
|
||||||
fs.copySync("#{resources}/project.clj", "project.clj")
|
fs.copySync("#{resources}/project.clj", "project.clj")
|
||||||
deps = interfaceConf[interfaceName].deps.join("\n")
|
deps = interfaceConf[interfaceName].deps.join("\n")
|
||||||
@ -412,25 +425,15 @@ copyProjectClj = (interfaceName, projNameHyph) ->
|
|||||||
cleans = platforms.map (platform) -> "\"index.#{platform}.js\""
|
cleans = platforms.map (platform) -> "\"index.#{platform}.js\""
|
||||||
cleans.push platformCleanId
|
cleans.push platformCleanId
|
||||||
|
|
||||||
devProfileTemplate = readFile "#{resources}/dev.profile"
|
builds = creteBuildConfigs ['dev', 'prod', 'advanced'], platforms
|
||||||
devProfiles = platforms.map (platform) -> devProfileTemplate.replace(platformRx, platform)
|
|
||||||
devProfiles.push devProfilesId
|
|
||||||
|
|
||||||
prodProfileTemplate = readFile "#{resources}/prod.profile"
|
|
||||||
prodProfiles = platforms.map (platform) -> prodProfileTemplate.replace(platformRx, platform)
|
|
||||||
prodProfiles.push prodProfilesId
|
|
||||||
|
|
||||||
advProfileTemplate = readFile "#{resources}/advanced.profile"
|
|
||||||
advProfiles = platforms.map (platform) -> advProfileTemplate.replace(platformRx, platform)
|
|
||||||
advProfiles.push advProfilesId
|
|
||||||
|
|
||||||
edit 'project.clj', [
|
edit 'project.clj', [
|
||||||
[projNameHyphRx, projNameHyph],
|
[projNameHyphRx, projNameHyph],
|
||||||
[interfaceDepsRx, deps],
|
[interfaceDepsRx, deps],
|
||||||
[platformCleanRx, cleans.join(' ')],
|
[platformCleanRx, cleans.join(' ')],
|
||||||
[devProfilesRx, devProfiles.join("\n")],
|
[buildProfiles.dev.profilesRx, builds.dev],
|
||||||
[prodProfilesRx, prodProfiles.join("\n")],
|
[buildProfiles.prod.profilesRx, builds.prod],
|
||||||
[advProfilesRx, advProfiles.join("\n")]]
|
[buildProfiles.advanced.profilesRx, builds.advanced]]
|
||||||
|
|
||||||
updateProjectClj = (platform) ->
|
updateProjectClj = (platform) ->
|
||||||
proj = readFile('project.clj')
|
proj = readFile('project.clj')
|
||||||
@ -443,39 +446,19 @@ updateProjectClj = (platform) ->
|
|||||||
log "Manual update of project.clj required: add clean targets:"
|
log "Manual update of project.clj required: add clean targets:"
|
||||||
log "#{cleans.join(' ')}", "red"
|
log "#{cleans.join(' ')}", "red"
|
||||||
|
|
||||||
devProfileTemplate = readFile "#{resources}/dev.profile"
|
builds = creteBuildConfigs ['dev', 'prod', 'advanced'], [platform]
|
||||||
devProfiles = []
|
|
||||||
devProfiles.push devProfileTemplate.replace(platformRx, platform)
|
|
||||||
devProfiles.push devProfilesId
|
|
||||||
|
|
||||||
if !proj.match(devProfilesRx)
|
|
||||||
log "Manual update of project.clj required: add new build to dev profile:"
|
|
||||||
log "#{devProfiles.join('\n')}", "red"
|
|
||||||
|
|
||||||
prodProfileTemplate = readFile "#{resources}/prod.profile"
|
|
||||||
prodProfiles = []
|
|
||||||
prodProfiles.push prodProfileTemplate.replace(platformRx, platform)
|
|
||||||
prodProfiles.push prodProfilesId
|
|
||||||
|
|
||||||
if !proj.match(prodProfilesRx)
|
|
||||||
log "Manual update of project.clj required: add new build to prod profile:"
|
|
||||||
log "#{prodProfiles.join('\n')}", "red"
|
|
||||||
|
|
||||||
advProfileTemplate = readFile "#{resources}/advanced.profile"
|
|
||||||
advProfiles = []
|
|
||||||
advProfiles.push advProfileTemplate.replace(platformRx, platform)
|
|
||||||
advProfiles.push advProfilesId
|
|
||||||
|
|
||||||
if !proj.match(advProfilesRx)
|
|
||||||
log "Manual update of project.clj required: add new build to advanced profile:"
|
|
||||||
log "#{advProfiles.join('\n')}", "red"
|
|
||||||
|
|
||||||
|
profileKeys = Object.keys buildProfiles
|
||||||
|
for key in profileKeys
|
||||||
|
if !proj.match(buildProfiles[key].profilesRx)
|
||||||
|
log "Manual update of project.clj required: add new build to #{key} profile:"
|
||||||
|
log "#{builds[key]}", "red"
|
||||||
|
|
||||||
edit 'project.clj', [
|
edit 'project.clj', [
|
||||||
[platformCleanRx, cleans.join(' ')],
|
[platformCleanRx, cleans.join(' ')],
|
||||||
[devProfilesRx, devProfiles.join("\n")],
|
[buildProfiles.dev.profilesRx, builds.dev],
|
||||||
[prodProfilesRx, prodProfiles.join("\n")],
|
[buildProfiles.prod.profilesRx, builds.prod],
|
||||||
[advProfilesRx, advProfiles.join("\n")]
|
[buildProfiles.advanced.profilesRx, builds.advanced]
|
||||||
]
|
]
|
||||||
|
|
||||||
init = (interfaceName, projName) ->
|
init = (interfaceName, projName) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user