Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.

Commit 00ad604

Browse files
committed
Update Ormolu to 0.5.0.0
1 parent 7b8146f commit 00ad604

File tree

6 files changed

+101
-68
lines changed

6 files changed

+101
-68
lines changed

flake.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
nixpkgs-fmt.enable = true;
6161
ormolu = {
6262
enable = true;
63-
entry = lib.mkForce "${ormolu}/bin/ormolu -e --mode inplace";
63+
entry = lib.mkForce "${ormolu}/bin/ormolu -i";
6464
};
6565
hlint.enable = true;
6666
};

src/HellSmack/Curse.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ withModpackMetadata mcSide afid cont = do
181181
serverId <-
182182
file ^. #serverPackFileId & maybe (throwString "no server pack available") pure
183183
file <-
184-
getAddonFilesByFileIds [serverId] <&> (^? each . folded)
184+
getAddonFilesByFileIds [serverId]
185+
<&> (^? each . folded)
185186
>>= maybe (throwString "server pack not found") pure
186187
when (file ^. #isServerPack /= Just True) $
187188
throwString "expected a server pack from curse"
@@ -244,8 +245,8 @@ searchInstallModpack ModpackSearchInstallOptions {..} = do
244245
files <-
245246
getAddonFilesByAddonId (addon ^. #id)
246247
<&> sortOn (^. #fileDate . to Down) . filter \f ->
247-
coerce (toList mcVersion) `isInfixOf` (f ^. #gameVersion)
248-
&& f ^. #releaseType <= maxReleaseType
248+
(coerce (toList mcVersion) `isInfixOf` (f ^. #gameVersion))
249+
&& (f ^. #releaseType <= maxReleaseType)
249250
file <- case files & take (fromIntegral numFiles) & nonEmpty of
250251
Nothing -> logWarn "no modpack versions found" $> Nothing
251252
Just files ->

src/HellSmack/ModLoader/Forge.hs

+28-22
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ findVersion (V.MCVersion mcVersion) fvq = do
135135
RecommendedVersion -> Left ("recommended" :: Text)
136136
LatestVersion -> Left "latest"
137137
(view chosen -> version) <-
138-
promoOrVersion & _Left %%~ \promoKey ->
139-
downloadJson promotionsUrl
140-
>>= rethrow . \(versions :: Value) ->
141-
versions ^? (key "promos" . key [iFS|$mcVersion-$promoKey|] . _String)
142-
& maybeToRight "no promoted version found"
138+
promoOrVersion
139+
& _Left %%~ \promoKey ->
140+
downloadJson promotionsUrl
141+
>>= rethrow . \(versions :: Value) ->
142+
versions ^? (key "promos" . key [iFS|$mcVersion-$promoKey|] . _String)
143+
& maybeToRight "no promoted version found"
143144
downloadMaybeJson manifestUrl manifestPath Nothing \(versions :: Value) ->
144145
case versions ^.. key (mcVersion ^. _Key) . values . _String . filtered (version `T.isInfixOf`) of
145146
[v] -> Right $ ForgeVersion v
@@ -254,10 +255,11 @@ getLibraries vm = do
254255
pure V.Artifact {size = Nothing, ..}
255256
artifact <- Just <$> toArtifact name (checksums ^? _Just . _head)
256257
classifiers <-
257-
natives & _Just %%~ do
258-
fmap M.fromList
259-
. traverse ((_2 %%~ \c -> toArtifact (name & #classifier ?~ c) Nothing) . dup)
260-
. toList
258+
natives
259+
& _Just %%~ do
260+
fmap M.fromList
261+
. traverse ((_2 %%~ \c -> toArtifact (name & #classifier ?~ c) Nothing) . dup)
262+
. toList
261263
pure V.Library {downloads = V.LibraryDownload {..}, ..}
262264
Post113Lib l -> pure l
263265

@@ -318,7 +320,8 @@ preprocess fv vvm im = do
318320
v -> pure $ Left v
319321
(excess, dataMap) <-
320322
forM (im ^@.. #dataEntries . ifolded) do
321-
fmap (\(k, v) -> v & chosen %~ (k,)) . (_2 %%~ expandMavenIdsAndLiterals)
323+
fmap (\(k, v) -> v & chosen %~ (k,))
324+
. (_2 %%~ expandMavenIdsAndLiterals)
322325
. (_2 %~ view case side of MCClient -> #client; MCServer -> #server)
323326
. (_1 %~ \k -> "{" <> k <> "}")
324327
<&> partitionEithers
@@ -346,11 +349,12 @@ preprocess fv vvm im = do
346349
]
347350
dataMap <-
348351
M.union extraDataEntries . M.union dataMap <$> do
349-
excess & each %%~ \(toString . T.drop 1 -> fp) -> do
350-
fp <- reThrow $ parseRelFile fp
351-
newFp <- liftIO $ parseAbsFile =<< emptyTempFile tmpDir "embedded"
352-
extractFromInstaller' fv fp newFp
353-
pure $ toText . toFilePath $ newFp
352+
excess
353+
& each %%~ \(toString . T.drop 1 -> fp) -> do
354+
fp <- reThrow $ parseRelFile fp
355+
newFp <- liftIO $ parseAbsFile =<< emptyTempFile tmpDir "embedded"
356+
extractFromInstaller' fv fp newFp
357+
pure $ toText . toFilePath $ newFp
354358
let preprocessors =
355359
-- filter out the new (in forge 1.17.1) preprocessor which copies server scripts around
356360
im ^.. #processors . each . filtered (not . isServerOnlyProcessor)
@@ -468,17 +472,19 @@ launch fv = do
468472
False -> do
469473
launcherJar <-
470474
libs ^? each . #name . filteredBy (#artifactId . only "forge")
471-
& rethrow . maybeToRight "launcher library not found" >>= reThrow . libraryPath
475+
& rethrow . maybeToRight "launcher library not found"
476+
>>= reThrow . libraryPath
472477
jarManifest <- readJarManifest launcherJar
473478
let expectEntry (k :: String) = rethrow . maybeToRight [i|$k not found|]
474479
mainClass <- expectEntry "main class" $ jarManifest ^? ix "Main-Class" . unpacked
475480
otherLibs <- do
476481
raw <- expectEntry "classpath" $ jarManifest ^? ix "Class-Path" . to (T.splitOn " ")
477482
libDir <- siehs @DirConfig #libraryDir
478-
raw & each %%~ \case
479-
(T.stripPrefix "libraries/" -> Just p) -> do
480-
p <- reThrow $ parseRelFile $ toString p
481-
pure $ libDir </> p
482-
p | "minecraft_server." `T.isPrefixOf` p -> reThrow $ V.mainJarPath vvm
483-
p -> throwString [i|invalid classpath entry: $p|]
483+
raw
484+
& each %%~ \case
485+
(T.stripPrefix "libraries/" -> Just p) -> do
486+
p <- reThrow $ parseRelFile $ toString p
487+
pure $ libDir </> p
488+
p | "minecraft_server." `T.isPrefixOf` p -> reThrow $ V.mainJarPath vvm
489+
p -> throwString [i|invalid classpath entry: $p|]
484490
runMCJava $ ["-cp", joinClasspath $ launcherJar : otherLibs] ++ [mainClass]

src/HellSmack/Vanilla.hs

+30-28
Original file line numberDiff line numberDiff line change
@@ -473,40 +473,42 @@ processArguments vm assets classpath = do
473473
<$> sequence [forM oldArgs processOldArgs, forM newArgs processNewArgs]
474474
where
475475
processNewArgs Arguments {game, jvm} =
476-
(game, jvm) & each %%~ \args -> traverse replaceInputs do
477-
Argument {value, rules} <- args
478-
guard $ processRules rules == Allow
479-
toString <$> value
476+
(game, jvm)
477+
& each %%~ \args -> traverse replaceInputs do
478+
Argument {value, rules} <- args
479+
guard $ processRules rules == Allow
480+
toString <$> value
480481
processOldArgs args = do
481482
game <- T.splitOn " " args <&> toString & traverse replaceInputs
482483
natDir <- reThrow $ versionNativeDir vm
483484
pure (game, ["-cp", classpath, [i|-Djava.library.path=$natDir|]])
484485
replaceInputs =
485486
packed . [_regex|\$\{(?<prop>[^\}]+)\}|] %%~ \cap ->
486-
cap & _capture @0 %%~ const case cap ^. _capture @"prop" of
487-
"classpath" -> pure $ toText classpath
488-
"natives_directory" -> fromPath $ versionNativeDir vm
489-
"game_assets" -> fromPath $ assetObjectsDir assets
490-
"assets_root" -> fromPath $ siehs @DirConfig #assetDir
491-
"assets_index_name" -> pure $ vm ^. #assetIndex . #id
492-
"game_directory" -> fromPath $ siehs @GameDir $ to unGameDir
493-
"auth_player_name" -> siehs @MCAuth #username
494-
"auth_uuid" -> siehs @MCAuth #uuid
495-
((`elem` ["auth_access_token", "auth_session"]) -> True) ->
496-
siehs @MCAuth $ #accessToken . to unAccessToken
497-
((`elem` ["clientid", "auth_xuid"]) -> True) ->
498-
pure "bogus" -- TODO implement new auth stuff...
499-
((`elem` ["version_name", "launcher_name"]) -> True) -> pure Meta.name
500-
"launcher_version" -> pure Meta.version
501-
"version_type" -> pure case vm ^. #versionType of
502-
Release -> "release"
503-
Snapshot -> "snapshot"
504-
_ -> "unknown"
505-
"user_type" -> pure "mojang" -- NOTE legacy?
506-
"user_properties" -> pure "{}"
507-
"library_directory" -> fromPath $ siehs @DirConfig #libraryDir
508-
"classpath_separator" -> pure $ toText classpathSeparator
509-
input -> throwString [i|invalid input '${input}' in argument|]
487+
cap
488+
& _capture @0 %%~ const case cap ^. _capture @"prop" of
489+
"classpath" -> pure $ toText classpath
490+
"natives_directory" -> fromPath $ versionNativeDir vm
491+
"game_assets" -> fromPath $ assetObjectsDir assets
492+
"assets_root" -> fromPath $ siehs @DirConfig #assetDir
493+
"assets_index_name" -> pure $ vm ^. #assetIndex . #id
494+
"game_directory" -> fromPath $ siehs @GameDir $ to unGameDir
495+
"auth_player_name" -> siehs @MCAuth #username
496+
"auth_uuid" -> siehs @MCAuth #uuid
497+
((`elem` ["auth_access_token", "auth_session"]) -> True) ->
498+
siehs @MCAuth $ #accessToken . to unAccessToken
499+
((`elem` ["clientid", "auth_xuid"]) -> True) ->
500+
pure "bogus" -- TODO implement new auth stuff...
501+
((`elem` ["version_name", "launcher_name"]) -> True) -> pure Meta.name
502+
"launcher_version" -> pure Meta.version
503+
"version_type" -> pure case vm ^. #versionType of
504+
Release -> "release"
505+
Snapshot -> "snapshot"
506+
_ -> "unknown"
507+
"user_type" -> pure "mojang" -- NOTE legacy?
508+
"user_properties" -> pure "{}"
509+
"library_directory" -> fromPath $ siehs @DirConfig #libraryDir
510+
"classpath_separator" -> pure $ toText classpathSeparator
511+
input -> throwString [i|invalid input '${input}' in argument|]
510512
fromPath = reThrow . fmap (toText . toFilePath)
511513

512514
launch ::

src/Main.hs

+35-11
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
178178
mcSideLike t = enumLike t \case MCClient -> "client"; MCServer -> "server"
179179
mcVersionLike t mods =
180180
fmap Vanilla.MCVersion . t $
181-
OA.metavar "MINECRAFT-VERSION" <> mcVersionCompleter <> mods
181+
OA.metavar "MINECRAFT-VERSION"
182+
<> mcVersionCompleter
183+
<> mods
182184
<> OA.help "Minecraft version, like 1.7.10 or 1.16-pre8"
183185
versionLatest, versionRecommended :: String
184186
specialVersions@(versionLatest, versionRecommended) = ("latest", "recommended")
@@ -196,7 +198,9 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
196198
Curse.Beta -> "beta"
197199
Curse.Alpha -> "alpha"
198200
do
199-
OA.short 't' <> OA.long "max-release-type" <> OA.value Curse.Beta
201+
OA.short 't'
202+
<> OA.long "max-release-type"
203+
<> OA.value Curse.Beta
200204
<> OA.help "most unstable release type to display"
201205
outDirOpt = dirPath OA.option do
202206
OA.short 'o' <> OA.long "out-dir" <> OA.help "Output directory" <> OA.value (Rel [reldir|.|])
@@ -223,7 +227,8 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
223227
cliParser = do
224228
dataDir <-
225229
optional $ dirPath OA.option do
226-
OA.short 'd' <> OA.long "data-dir"
230+
OA.short 'd'
231+
<> OA.long "data-dir"
227232
<> OA.help "Directory for assets, libraries etc. (cached)"
228233
verbosity <- enumLike
229234
OA.option
@@ -244,7 +249,10 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
244249

245250
launchOptions = do
246251
javaBin <- filePath OA.option do
247-
OA.short 'j' <> OA.long "java" <> OA.showDefault <> OA.value (Rel [relfile|java|])
252+
OA.short 'j'
253+
<> OA.long "java"
254+
<> OA.showDefault
255+
<> OA.value (Rel [relfile|java|])
248256
<> OA.help "Java path"
249257
extraJvmArgs <-
250258
let a1 = many $ OA.strOption do
@@ -298,10 +306,16 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
298306
"Search and install a modpack",
299307
do
300308
numModpacks <- OA.option (filterAuto (> 0)) do
301-
OA.short 'm' <> OA.long "num-modpacks" <> OA.value 8 <> OA.showDefault
309+
OA.short 'm'
310+
<> OA.long "num-modpacks"
311+
<> OA.value 8
312+
<> OA.showDefault
302313
<> OA.help "number of modpacks to show"
303314
numFiles <- OA.option (filterAuto (> 0)) do
304-
OA.short 'f' <> OA.long "num-files" <> OA.value 8 <> OA.showDefault
315+
OA.short 'f'
316+
<> OA.long "num-files"
317+
<> OA.value 8
318+
<> OA.showDefault
305319
<> OA.help "number of concrete modpack versions to show"
306320
maxReleaseType <- releaseTypeOpt
307321
outDir <- outDirOpt
@@ -331,10 +345,16 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
331345
"Search and install a mod",
332346
do
333347
numMods <- OA.option (filterAuto (> 0)) do
334-
OA.short 'm' <> OA.long "num-mods" <> OA.value 8 <> OA.showDefault
348+
OA.short 'm'
349+
<> OA.long "num-mods"
350+
<> OA.value 8
351+
<> OA.showDefault
335352
<> OA.help "number of mods to show"
336353
numFiles <- OA.option (filterAuto (> 0)) do
337-
OA.short 'f' <> OA.long "num-files" <> OA.value 8 <> OA.showDefault
354+
OA.short 'f'
355+
<> OA.long "num-files"
356+
<> OA.value 8
357+
<> OA.showDefault
338358
<> OA.help "number of mod files to show"
339359
maxReleaseType <- releaseTypeOpt
340360
modLoader <- enumLike
@@ -343,12 +363,15 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
343363
Curse.ForgeModLoader -> "forge"
344364
Curse.FabricModLoader -> "fabric"
345365
do
346-
OA.short 'l' <> OA.long "mod-loader" <> OA.value Curse.ForgeModLoader
366+
OA.short 'l'
367+
<> OA.long "mod-loader"
368+
<> OA.value Curse.ForgeModLoader
347369
<> OA.help "mod loader to use"
348370
outDir <- outDirOpt
349371
installDependencies <-
350372
not <$> OA.switch do
351-
OA.short 'd' <> OA.long "ignore-dependencies"
373+
OA.short 'd'
374+
<> OA.long "ignore-dependencies"
352375
<> OA.help "whether to ignore mod dependencies"
353376
mcVersion <- mcVersionLike OA.strArgument mempty
354377
modName <- OA.strArgument do
@@ -366,7 +389,8 @@ getCLI = OA.execParser $ OA.info (OA.helper <*> ver <*> cliParser) OA.fullDesc
366389
mcVersion <- optional $ mcVersionLike OA.strOption do
367390
OA.short 'v' <> OA.long "mc-version"
368391
inputs <- some $ OA.strArgument do
369-
OA.metavar "INPUTS..." <> fileAction
392+
OA.metavar "INPUTS..."
393+
<> fileAction
370394
<> OA.help "Input files and/or directories"
371395
pure $ ModUpdates Curse.ModUpdateOptions {..}
372396
),

0 commit comments

Comments
 (0)