@@ -172,20 +172,6 @@ deployPush deployPath getNixBuilders = do
172deployUpdate :: MonadObelisk m => FilePath -> m ()
172deployUpdate :: MonadObelisk m => FilePath -> m ()
173deployUpdate deployPath = updateThunkToLatest (deployPath </> "src") Nothing
173deployUpdate deployPath = updateThunkToLatest (deployPath </> "src") Nothing
175−keytoolToAndroidConfig :: KeytoolConfig -> HM.HashMap Text (NValue t Identity m)
176−keytoolToAndroidConfig conf =
177− let path = nvPath $ _keytoolConfig_keystore conf
178− fromStr = nvStr . principledMakeNixStringWithoutContext . T.pack
179− storepass = fromStr $ _keytoolConfig_storepass conf
180− alias = fromStr $ _keytoolConfig_alias conf
181− keypass = fromStr $ _keytoolConfig_keypass conf
183− [ ("storeFile", path)
184− , ("storePassword", storepass)
185− , ("keyAlias", alias)
186− , ("keyPassword", keypass)
189data PlatformDeployment = Android | IOS
175data PlatformDeployment = Android | IOS
190 deriving (Show, Eq)
176 deriving (Show, Eq)
@@ -200,7 +186,7 @@ deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
200 configDir = root </> "config"
186 configDir = root </> "config"
201 exists <- liftIO $ doesDirectoryExist srcDir
187 exists <- liftIO $ doesDirectoryExist srcDir
202 unless exists $ failWith "ob test should be run inside of a deploy directory"
188 unless exists $ failWith "ob test should be run inside of a deploy directory"
203− nixBuildTarget <- case platform of
189+ (nixBuildTarget, extraArgs) <- case platform of
204 Android -> do
190 Android -> do
205 let keystorePath = root </> "android_keystore.jks"
191 let keystorePath = root </> "android_keystore.jks"
206 keytoolConfPath = root </> "android_keytool_config.json"
192 keytoolConfPath = root </> "android_keytool_config.json"
@@ -225,38 +211,43 @@ deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
225 unless checkKeytoolConfExist $ failWith "Missing android KeytoolConfig"
211 unless checkKeytoolConfExist $ failWith "Missing android KeytoolConfig"
226 keytoolConfContents <- liftIO $ BSL.readFile keytoolConfPath
212 keytoolConfContents <- liftIO $ BSL.readFile keytoolConfPath
227 liftIO $ print keytoolConfContents
213 liftIO $ print keytoolConfContents
228− releaseKey :: String <- case eitherDecode keytoolConfContents :: Either String KeytoolConfig of
214+ keyArgs <- case eitherDecode keytoolConfContents :: Either String KeytoolConfig of
229 Left err -> failWith $ T.pack err
215 Left err -> failWith $ T.pack err
230− Right conf -> return $
216+ Right conf -> [ "--sign"
231− (printNix :: MonadObelisk m => NValue t Identity m -> String) $
217+ , "--store-file", _keytoolConfig_keystore conf
232− nvSet (keytoolToAndroidConfig conf) HM.empty
218+ , "--store-password", _keytoolConfig_storepass conf
219+ , "--key-alias", _keytoolConfig_alias conf
220+ , "--key-password", _keytoolConfig_keypass conf]
233− let expr = mconcat
221+ let expr = unlines
234 [ "with (import ", srcDir, " {});"
222 [ "with (import ", srcDir, " {});"
235− , "android.frontend.override (drv: { "
223+ , "android.frontend.override (drv: {"
236− , "releaseKey = (if builtins.isNull drv.releaseKey then {} else drv.releaseKey) // " <> releaseKey <> "; "
224+ , " isRelease = true;"
237− , "staticSrc = (passthru.__androidWithConfig ", configDir, ").frontend.staticSrc;"
225+ , " staticSrc = (passthru.__androidWithConfig ", configDir, ").frontend.staticSrc;"
240− return $ Target
228+ return (Target
241 { _target_path = Nothing
229 { _target_path = Nothing
242 , _target_attr = Nothing
230 , _target_attr = Nothing
243 , _target_expr = Just expr
231 , _target_expr = Just expr
245 IOS -> do
233 IOS -> do
246 let expr = mconcat
234 let expr = mconcat
247 [ "with (import ", srcDir, " {});"
235 [ "with (import ", srcDir, " {});"
248 , "ios.frontend.override (_: { staticSrc = (passthru.__iosWithConfig ", configDir, ").frontend.staticSrc; })"
236 , "ios.frontend.override (_: { staticSrc = (passthru.__iosWithConfig ", configDir, ").frontend.staticSrc; })"
250− return $ Target
238+ return (Target
251 { _target_path = Nothing
239 { _target_path = Nothing
252 , _target_attr = Nothing
240 , _target_attr = Nothing
253 , _target_expr = Just expr
241 , _target_expr = Just expr
255 result <- nixCmd $ NixCmd_Build $ def
243 result <- nixCmd $ NixCmd_Build $ def
256 & nixBuildConfig_outLink .~ OutLink_None
244 & nixBuildConfig_outLink .~ OutLink_None
257 & nixCmdConfig_target .~ nixBuildTarget
245 & nixCmdConfig_target .~ nixBuildTarget
246+ let mobileArtifact = case platform of
248+ Android -> "Android APK"
258− putLog Notice $ T.pack $ "Your recently built android apk can be found at the following path: " <> show result
249+ in putLog Notice $ T.pack $ unwords ["Your recently built", mobileArtifact, "can be found at the following path:", show result]
259− callProcessAndLogOutput (Notice, Error) $ proc (result </> "bin" </> "deploy") mobileArgs
250+ callProcessAndLogOutput (Notice, Error) $ proc (result </> "bin" </> "deploy") (mobileArgs ++ extraArgs)
261 withEcho showEcho f = do
252 withEcho showEcho f = do
262 prevEcho <- hGetEcho stdin
253 prevEcho <- hGetEcho stdin