Parameterized platforms in project.clj
This commit is contained in:
parent
76c4bc78e4
commit
a10bc8906b
|
@ -24,6 +24,8 @@ projNameRx = /\$PROJECT_NAME\$/g
|
|||
projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
|
||||
projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g
|
||||
interfaceDepsRx = /\$INTERFACE_DEPS\$/g
|
||||
devProfilesRx = /\$DEV_PROFILES\$/g
|
||||
prodProfilesRx = /\$PROD_PROFILES\$/g
|
||||
platformRx = /\$PLATFORM\$/g
|
||||
devHostRx = /\$DEV_HOST\$/g
|
||||
ipAddressRx = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/i
|
||||
|
@ -364,9 +366,18 @@ copySrcFiles = (interfaceName, projName, projNameUs, projNameHyph) ->
|
|||
shimCljsNamespace(namespace)
|
||||
|
||||
copyProjectClj = (interfaceName, projNameHyph) ->
|
||||
devProfileTemplate = readFile "#{resources}/dev.profile"
|
||||
prodProfileTemplate = readFile "#{resources}/prod.profile"
|
||||
|
||||
devProfiles = []
|
||||
prodProfiles = []
|
||||
for platform in platforms
|
||||
devProfiles.push devProfileTemplate.replace(platformRx, platform)
|
||||
prodProfiles.push prodProfileTemplate.replace(platformRx, platform)
|
||||
|
||||
fs.copySync("#{resources}/project.clj", "project.clj")
|
||||
deps = interfaceConf[interfaceName].deps.join("\n")
|
||||
edit 'project.clj', [[projNameHyphRx, projNameHyph], [interfaceDepsRx, deps]]
|
||||
edit 'project.clj', [[projNameHyphRx, projNameHyph], [interfaceDepsRx, deps], [devProfilesRx, devProfiles.join("\n")], [prodProfilesRx, prodProfiles.join("\n")]]
|
||||
|
||||
init = (interfaceName, projName) ->
|
||||
if projName.toLowerCase() is 'react' or !projName.match validNameRx
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{:id "$PLATFORM$"
|
||||
:source-paths ["src" "env/dev"]
|
||||
:figwheel true
|
||||
:compiler {:output-to "target/$PLATFORM$/not-used.js"
|
||||
:main "env.$PLATFORM$.main"
|
||||
:output-dir "target/$PLATFORM$"
|
||||
:optimizations :none}}
|
|
@ -0,0 +1,9 @@
|
|||
{:id "$PLATFORM$"
|
||||
:source-paths ["src" "env/prod"]
|
||||
:compiler {:output-to "index.$PLATFORM$.js"
|
||||
:main "env.$PLATFORM$.main"
|
||||
:output-dir "target/$PLATFORM$"
|
||||
:static-fns true
|
||||
:optimize-constants true
|
||||
:optimizations :simple
|
||||
:closure-defines {"goog.DEBUG" false}}}
|
|
@ -15,36 +15,10 @@
|
|||
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.8"]
|
||||
[com.cemerick/piggieback "0.2.1"]]
|
||||
:source-paths ["src" "env/dev"]
|
||||
:cljsbuild {:builds [{:id "ios"
|
||||
:source-paths ["src" "env/dev"]
|
||||
:figwheel true
|
||||
:compiler {:output-to "target/ios/not-used.js"
|
||||
:main "env.ios.main"
|
||||
:output-dir "target/ios"
|
||||
:optimizations :none}}
|
||||
{:id "android"
|
||||
:source-paths ["src" "env/dev"]
|
||||
:figwheel true
|
||||
:compiler {:output-to "target/android/not-used.js"
|
||||
:main "env.android.main"
|
||||
:output-dir "target/android"
|
||||
:optimizations :none}}]}
|
||||
:cljsbuild {:builds [
|
||||
$DEV_PROFILES$]}
|
||||
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}
|
||||
:prod {:cljsbuild {:builds [{:id "ios"
|
||||
:source-paths ["src" "env/prod"]
|
||||
:compiler {:output-to "index.ios.js"
|
||||
:main "env.ios.main"
|
||||
:output-dir "target/ios"
|
||||
:static-fns true
|
||||
:optimize-constants true
|
||||
:optimizations :simple
|
||||
:closure-defines {"goog.DEBUG" false}}}
|
||||
{:id "android"
|
||||
:source-paths ["src" "env/prod"]
|
||||
:compiler {:output-to "index.android.js"
|
||||
:main "env.android.main"
|
||||
:output-dir "target/android"
|
||||
:static-fns true
|
||||
:optimize-constants true
|
||||
:optimizations :simple
|
||||
:closure-defines {"goog.DEBUG" false}}}]}}})
|
||||
:prod {:cljsbuild {:builds [
|
||||
$PROD_PROFILES$]}}})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue