stack-all 0.4.1 → 0.4.2
raw patch · 6 files changed
+92/−51 lines, 6 filesdep ~simple-cmd-args
Dependency ranges changed: simple-cmd-args
Files
- ChangeLog.md +4/−0
- README.md +36/−9
- src/Main.hs +14/−12
- src/MajorVer.hs +3/−1
- src/Snapshots.hs +14/−14
- stack-all.cabal +21/−15
ChangeLog.md view
@@ -1,5 +1,9 @@ # Release history for stack-all +## 0.4.2 (2023-10-01)+- support unversioned "lts" argument+- add --refresh-cache option to force refresh of cached snapshots.json+ ## 0.4.1 (2023-02-20) - ignore nightly as a base when creating a new lts file
README.md view
@@ -8,7 +8,7 @@ `stack-all` by default runs `stack build` over Stackage Nightly and LTS major versions-(current default is nightly & LTS 20, 19, 18, 16, 14, 13, 12, 11)+(current default is nightly & LTS 21, 20, 19, 18, 16, 14, 13, 12, 11) corresponding to latest major ghc minor versions, with appropriate stack `--resolver` options. @@ -17,6 +17,33 @@ Of course it may still fail to build, but this allows for quickly trying to build a package that does not include stack support. +### Help output+```shellsession+$ stack-all --version+0.4.2+$ stack-all --help+Build over Stackage versions++Usage: stack-all [--version] [(-c|--create-config) | (-s|--make-lts)]+ [-k|--keep-going] [-d|--debug] [--refresh-cache]+ [-n|--newest MAJOR] [(-o|--oldest MAJOR) | (-a|--all-lts)]+ [MAJORVER... [COMMAND...]]++ stack-all builds projects easily across different Stackage versions++Available options:+ -h,--help Show this help text+ --version Show version+ -c,--create-config Create a project .stack-all file+ -s,--make-lts Create a stack-ltsXX.yaml file+ -k,--keep-going Keep going even if an LTS fails+ -d,--debug Verbose stack build output on error+ --refresh-cache Force refresh of stackage snapshots.json cache+ -n,--newest MAJOR Newest LTS release to build from+ -o,--oldest MAJOR Oldest compatible LTS release+ -a,--all-lts Try to build back to LTS 1 even+```+ ### Overriding stack.yaml `stack-all` can use `stack-ltsXX.yaml` files to override the default `stack.yaml` file for particular Stackage major versions.@@ -24,11 +51,11 @@ older LTS major versions until another `stack-ltsYY.yaml` file is found. `stack-nightly.yaml` is also supported, but used only for nightly. -For example if you have `stack-lts18.yaml` and `stack-lts13.yaml` files+For example if you have `stack-lts19.yaml` and `stack-lts16.yaml` files in your project,-then `stack.yaml` will be used as normal to build nightly, lts-20 and lts-19,-but `stack-lts18.yaml` will be used for building lts-18 and lts-16,-and `stack-lts14.yaml` will be used for lts-14, lts-13 (and older).+then `stack.yaml` will be used as normal to build nightly, lts-21 and lts-20,+but `stack-lts19.yaml` will be used for building lts-19 and lts-18,+and `stack-lts16.yaml` will be used for lts-16, lts-14 (and older). Since `stack-all` overrides the exact resolver with the latest minor snapshot, the exact minor Stackage version specified in the `stack*.yaml` files doesn't actually matter: `stack-all` always uses the latest published@@ -47,14 +74,14 @@ There are `--oldest` and `--newest` options to specify the range of lts versions to build over: -You can specify the oldest major LTS to build for with eg `stack-all -o lts13`.+You can specify the oldest major LTS to build for with eg `stack-all -o lts14`. Otherwise if not configured the default oldest LTS is currently `lts-11`. Similarly you can specify the newest LTS version to build from with-eg `stack-all -n lts18`. (The default is to build from nightly.)+eg `stack-all -n lts19`. (The default is to build from nightly.) Alternatively, one can give one or more explicit LTS major versions to build-for as arguments: eg `stack-all lts16` if you only wish to build that version.+for as arguments: eg `stack-all lts18` if you only wish to build that version. ### Configuring the oldest and/or newest LTS to build You can configure the oldest working LTS major version for your project@@ -69,7 +96,7 @@ This specifies that the oldest LTS version to build for is lts-16. The newest LTS to build with stack-all can similarly be configured:-`stack-all -c -n lts19` or setting `newest = lts-19`.+`stack-all -c -n lts20` or setting `newest = lts-20`. ### Running other stack commands By default `stack-all` just runs the stack `build` command over
src/Main.hs view
@@ -36,14 +36,15 @@ flagWith DefaultRun MakeStackLTS 's' "make-lts" "Create a stack-ltsXX.yaml file") <*> switchWith 'k' "keep-going" "Keep going even if an LTS fails" <*> switchWith 'd' "debug" "Verbose stack build output on error" <*>+ switchLongWith "refresh-cache" "Force refresh of stackage snapshots.json cache" <*> optional (readMajor <$> strOptionWith 'n' "newest" "MAJOR" "Newest LTS release to build from") <*> (Oldest . readMajor <$> strOptionWith 'o' "oldest" "MAJOR" "Oldest compatible LTS release" <|> flagWith DefaultLimit AllVersions 'a' "all-lts" "Try to build back to LTS 1 even") <*> many (strArg "MAJORVER... [COMMAND...]") -run :: Command -> Bool ->Bool -> Maybe MajorVer -> VersionLimit -> [String]- -> IO ()-run command keepgoing debug mnewest verlimit verscmd = do+run :: Command -> Bool ->Bool -> Bool -> Maybe MajorVer+ -> VersionLimit -> [String] -> IO ()+run command keepgoing debug refresh mnewest verlimit verscmd = do findStackProjectDir Nothing case command of CreateConfig ->@@ -54,12 +55,12 @@ (versions, _) <- getVersionsCmd if null versions then error' "--make-lts needs an LTS major version"- else makeStackLTS versions+ else makeStackLTS refresh versions DefaultRun -> do (versions, cargs) <- getVersionsCmd configs <- readStackConfigs let newestFilter = maybe id (filter . (>=)) mnewest- mapM_ (stackBuild configs keepgoing debug cargs) (newestFilter versions)+ mapM_ (stackBuild configs keepgoing debug refresh cargs) (newestFilter versions) where findStackProjectDir :: Maybe FilePath -> IO () findStackProjectDir mcwd = do@@ -80,7 +81,7 @@ -- FIXME take suggested extra-deps into stack.yaml -- FIXME stack init content too verbose unlessM (cmdBool "stack" ["init"]) $ do- snap <- latestLtsSnapshot+ snap <- latestLtsSnapshot refresh writeFile "stack.yaml" $ "resolver: " ++ snap ++ "\n" else error' "no package/project found" @@ -159,8 +160,8 @@ ini <- T.readFile inifile return $ either error id $ parseIniFile ini iniparser -makeStackLTS :: [MajorVer] -> IO ()-makeStackLTS vers = do+makeStackLTS :: Bool -> [MajorVer] -> IO ()+makeStackLTS refresh vers = do configs <- readStackConfigs forM_ vers $ \ver -> do let newfile = configFile ver@@ -174,14 +175,15 @@ Just conf -> do let origfile = configFile conf copyFile origfile newfile- whenJustM (latestMajorSnapshot ver) $ \latest ->+ whenJustM (latestMajorSnapshot refresh ver) $ \latest -> cmd_ "sed" ["-i", "-e", "s/\\(resolver:\\) .*/\\1 " ++ latest ++ "/", newfile] configFile :: MajorVer -> FilePath configFile ver = "stack-" ++ showCompact ver <.> "yaml" -stackBuild :: [MajorVer] -> Bool -> Bool -> [String] -> MajorVer -> IO ()-stackBuild configs keepgoing debug command ver = do+stackBuild :: [MajorVer] -> Bool -> Bool -> Bool -> [String]+ -> MajorVer -> IO ()+stackBuild configs keepgoing debug refresh command ver = do let mcfgver = case ver of Nightly | Nightly `elem` configs -> Just Nightly@@ -189,7 +191,7 @@ case sort (filter (ver <=) (delete Nightly configs)) of [] -> Nothing (cfg:_) -> Just cfg- latest <- latestMajorSnapshot ver+ latest <- latestMajorSnapshot refresh ver case latest of Nothing -> error' $ "no snapshot not found for " ++ showMajor ver Just minor -> do
src/MajorVer.hs view
@@ -16,7 +16,7 @@ import Text.Read (readMaybe) -- FIXME allow specific snapshots?-data MajorVer = LTS Int | Nightly+data MajorVer = LTS Int | LTSLatest | Nightly deriving (Eq, Ord) maybeReadMajor :: String -> Maybe MajorVer@@ -31,6 +31,7 @@ -- readMajor "lts-16" readMajor :: String -> MajorVer readMajor "nightly" = Nightly+readMajor "lts" = LTSLatest readMajor ver = case maybeReadMajor ver of Just s -> s@@ -50,6 +51,7 @@ showMajor :: MajorVer -> String showMajor Nightly = "nightly"+showMajor LTSLatest = "lts" showMajor (LTS ver) = "lts-" ++ show ver showCompact :: MajorVer -> String
src/Snapshots.hs view
@@ -29,30 +29,30 @@ getMajorVers :: IO [MajorVer] getMajorVers = do- obj <- getSnapshots+ obj <- getSnapshots False return $ reverse . sort $ map (readMajor . T.unpack . toText) (M.keys obj \\ ["lts"]) \\ excludedMajors #if !MIN_VERSION_aeson(2,0,0) where toText = id #endif -latestMajorSnapshot :: MajorVer -> IO (Maybe String)-latestMajorSnapshot ver = do- lookupKey (T.pack (showMajor ver)) <$> getSnapshots+latestMajorSnapshot :: Bool -> MajorVer -> IO (Maybe String)+latestMajorSnapshot forcerefresh ver = do+ lookupKey (T.pack (showMajor ver)) <$> getSnapshots forcerefresh -getSnapshots :: IO Object-getSnapshots =- getCachedJSON "stackage-snapshots" "snapshots.json" "http://haddock.stackage.org/snapshots.json" 200+getSnapshots :: Bool -> IO Object+getSnapshots forcerefresh =+ getCachedJSON "stackage-snapshots" "snapshots.json" "http://haddock.stackage.org/snapshots.json" $ if forcerefresh then 0 else 200 --minutes -latestLTS :: IO MajorVer-latestLTS = do- msnap <- lookupKey "lts" <$> getSnapshots+latestLTS :: Bool -> IO MajorVer+latestLTS refresh = do+ msnap <- lookupKey "lts" <$> getSnapshots refresh case msnap of Just snap -> return $ snapMajorVer snap Nothing -> error' "could not resolve lts major version" -latestLtsSnapshot :: IO String-latestLtsSnapshot = do- msnap <- resolveMajor LatestLTS >>= latestMajorSnapshot+latestLtsSnapshot :: Bool -> IO String+latestLtsSnapshot refresh = do+ msnap <- resolveMajor LatestLTS >>= latestMajorSnapshot refresh case msnap of Nothing -> error' "failed to determine latest lts snapshot"@@ -60,5 +60,5 @@ -- converts 'lts' to actual version resolveMajor :: MajorVerAlias -> IO MajorVer-resolveMajor LatestLTS = latestLTS+resolveMajor LatestLTS = latestLTS False resolveMajor (MajorVer ver) = return ver
stack-all.cabal view
@@ -1,5 +1,5 @@ name: stack-all-version: 0.4.1+version: 0.4.2 synopsis: CLI tool for building across Stackage major versions description: Build your Haskell project over Stackage major LTS versions.@@ -16,31 +16,37 @@ ChangeLog.md cabal-version: 1.18 tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5,- GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.5+ GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.7 source-repository head type: git location: https://github.com/juhp/stack-all.git +flag aeson1+ description: aeson-1 needs unordered-containers+ default: False+ manual: False+ executable stack-all main-is: Main.hs other-modules: Paths_stack_all MajorVer Snapshots hs-source-dirs: src- build-depends: base < 5,- aeson,- cached-json-file,- config-ini,- directory >= 1.2.5,- extra >= 1.6.15,- filepath,- http-query,- process,- simple-cmd >= 0.1.4,- simple-cmd-args,- text,- unordered-containers+ build-depends: base < 5+ , aeson+ , cached-json-file+ , config-ini+ , directory >= 1.2.5+ , extra >= 1.6.15+ , filepath+ , http-query+ , process+ , simple-cmd >= 0.1.4+ , simple-cmd-args >= 0.1.8+ , text+ if flag(aeson1)+ build-depends: unordered-containers default-language: Haskell2010 ghc-options: -Wall if impl(ghc >= 8.0)