packages feed

stack-all 0.7 → 0.7.1

raw patch · 5 files changed

+75/−40 lines, 5 filesdep ~simple-cmd

Dependency ranges changed: simple-cmd

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Release history for stack-all +## 0.7.1 (2025-08-05)+- check for stack+- for lts <= 11 fallback to stack-2.15.7+- MajorVer: improve parsing of nightly (nightly-\*), lts (lts-\*), ghc-\*+- add ghc9.10 alias for lts24+ ## 0.7 (2025-05-25) - complete rework of stack*.yaml config file logic - add --stack option to specify stack program (eg stack-2)
README.md view
@@ -25,7 +25,7 @@ `$ stack-all --version`  ```-0.7+0.7.1 ``` `$ stack-all --help` @@ -47,7 +47,7 @@   -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-  --stack STACKPROG        stack program [default: "stack"]+  --stack STACKPROG        stack program to use [default: stack]   -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@@ -66,15 +66,18 @@ 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-lts22.yaml` and `stack-lts20.yaml` files+For example if you have `stack-lts23.yaml` and `stack-lts21.yaml` files in your project,-then `stack.yaml` will be used as normal to build nightly and lts-23,-but `stack-lts22.yaml` will be used for building lts-22 and lts-21,-and `stack-lts20.yaml` will be used for lts-20 (and older).+then `stack.yaml` will be used as normal to build nightly and lts-24,+but `stack-lts23.yaml` will be used for building lts-23 and lts-22,+and `stack-lts21.yaml` will be used for lts-21 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-minor releases of Stackage major versions.+minor releases of Stackage major versions. (Since 0.7 the version handling+is slightly more complex, since it allows using eg `stack-lts24.yaml` before+an `stack.yaml` set for lts23 or older say: previously `stack.yaml` was always used+before any `stack-lts*.yaml` files.)  `stack-ltsXX.yaml` files can be easily created using `stack-all --make-lts ltsXX` (or `-s ltsXX` for short).@@ -93,9 +96,9 @@ You can abbreviate `lts-XX` args to `ltsXX` on the commandline. `lts` is also accepted and resolves to the latest major LTS version. -You can also use (hardcoded) ghc major version aliases:-eg `ghc9.8` corresponds to `lts23` or `ghc-9.2` to `lts-20`,-though not for `nightly` currently.+You can also use (hardcoded) ghc major version aliases for LTS's:+eg `ghc9.10` corresponds to `lts24` and `ghc-9.2` to `lts-20`+(but not for `nightly`).  There are `--oldest`  and `--newest` options to specify the range of lts versions to build over:@@ -104,7 +107,7 @@ Otherwise if not configured the default oldest LTS is currently `lts-20`.  Similarly you can specify the newest LTS version to build from with-eg `stack-all -n lts21`. (The default is to build from nightly.)+eg `stack-all -n lts23`. (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 lts22` if you only wish to build that version.
src/Main.hs view
@@ -7,7 +7,7 @@ import Data.Maybe (fromMaybe, listToMaybe) import Data.Tuple (swap) import Data.Version.Extra-import SimpleCmd ((+-+), cmdBool, cmd, cmd_, error',+import SimpleCmd ((+-+), cmdBool, cmd, cmd_, error', needProgram, warning, #if MIN_VERSION_simple_cmd(0,2,4)                   fileWithExtension #endif@@ -53,7 +53,7 @@     <$> 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"-    <*> strOptionalLongWith "stack" "STACKPROG" "stack program to use" "stack"+    <*> optional (strOptionLongWith "stack" "STACKPROG" "stack program to use [default: stack]")     <*> 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")@@ -65,9 +65,9 @@      flagWith' MakeAllLTS 'S' "make-all-lts" "Create all stack-ltsXX.yaml files" <|>      RunCmd <$> many (strArg "MAJORVER... COMMAND...")) -run :: Bool ->Bool -> Bool -> FilePath -> Maybe MajorVer -> VersionLimit+run :: Bool ->Bool -> Bool -> Maybe FilePath -> Maybe MajorVer -> VersionLimit     -> Command -> IO ()-run keepgoing debug refresh stack mnewest verlimit com = do+run keepgoing debug refresh mstack mnewest verlimit com = do   whenJustM findStackProjectDir setCurrentDirectory   case com of     CreateConfig ->@@ -83,8 +83,9 @@     RunCmd verscmd -> do       (versions, cargs) <- getVersionsAndCmd verscmd       configs <- readStackConfigs+      needProgram $ fromMaybe "stack" mstack       let finalvers = maybe id (filter . (>=)) mnewest versions-      mapM_ (runStack configs keepgoing debug refresh stack $ if null cargs then ["build"] else cargs) finalvers+      mapM_ (runStack configs keepgoing debug refresh mstack $ if null cargs then ["build"] else cargs) finalvers   where     findStackProjectDir :: IO (Maybe FilePath)     findStackProjectDir = do@@ -102,6 +103,8 @@           putStrLn $ "creating" +-+ stackYaml +-+ "in" +-+ cwdir           -- FIXME take suggested extra-deps into stack.yaml           -- FIXME stack init content too verbose+          let stack = fromMaybe "stack" mstack+          needProgram stack           unlessM (cmdBool stack ["init"]) $ do             snap <- latestLtsSnapshot refresh             writeFile stackYaml $ "resolver: " ++ snap ++ "\n"@@ -235,14 +238,23 @@       (if multiple then putStrLn else error') $ "overlapping major versions:" +-+       unwords (map configFile cs) -runStack :: [ConfigVersion] -> Bool -> Bool -> Bool -> FilePath -> [String]+runStack :: [ConfigVersion] -> Bool -> Bool -> Bool -> Maybe FilePath -> [String]          -> MajorVer -> IO ()-runStack configs keepgoing debug refresh stack command ver = do-  -- FIXME add --stack or STACK envvar or look for stack-<VERSION>-  when (ver <= LTS 11) $ do-    stackver <- readVersion <$> cmd stack ["--numeric-version"]-    when (stackver >= makeVersion [3]) $-      error' $ "stack-" ++ showVersion stackver +-+ "no longer supports lts < 12"+runStack configs keepgoing debug refresh mstack command ver = do+  stack <-+    case mstack of+      Just stk -> return stk+      Nothing ->+        if ver <= LTS 11+        then do+          stackver <- readVersion <$> cmd "stack" ["--numeric-version"]+          if stackver >= makeVersion [3]+            then do+            warning $ "Warning: found stack version" +-+ showVersion stackver ++ ", which does not support lts < 12"+            warning "Trying stack-2.15.7 (otherwise use '--stack stack-2.*')"+            return "stack-2.15.7"+            else return "stack"+        else return "stack"   let !mconfig =         case filter (isVersion ver) configs of           [] ->@@ -260,7 +272,7 @@                  maybe [] (\f -> ["--stack-yaml", configFile f]) mconfig       putStrLn $ "# " ++ minor       if debug-        then debugBuild $ opts ++ command+        then debugBuild stack $ opts ++ command         else do         ok <- cmdBool stack $ opts ++ command         unless (ok || keepgoing) $ do@@ -269,8 +281,8 @@           error' $ "failed for " ++ showMajor ver       putStrLn ""   where-    debugBuild :: [String] -> IO ()-    debugBuild args = do+    debugBuild :: FilePath -> [String] -> IO ()+    debugBuild stack args = do       putStr $ stack +-+ unwords args       (ret,out,err) <- readProcessWithExitCode stack args ""       putStrLn "\n"
src/MajorVer.hs view
@@ -13,7 +13,7 @@ import Data.Char (isDigit) import Data.List.Extra import Numeric.Natural (Natural)-import SimpleCmd (error')+import SimpleCmd (error', (+-+)) import Text.Read (readMaybe)  -- FIXME allow specific snapshots?@@ -21,21 +21,32 @@   deriving (Eq, Ord)  maybeReadMajor :: String -> Maybe MajorVer+maybeReadMajor "nightly" = Just Nightly maybeReadMajor ver-  | "nightly" `isPrefixOf` ver =-      case dropPrefix "-" $ dropPrefix "nightly" ver of-        "" -> Just Nightly+  | "nightly-" `isPrefixOf` ver =+      case dropPrefix "nightly-" ver of         ds ->-          if all (\d -> isDigit d || d == '-') ds-          then Just Nightly-          else Nothing+          if null ds+          then error' $ "bad major:" +-+ ver+          else+            if all (\d -> isDigit d || d == '-') ds+            then Just Nightly+            else error' $ "bad major version:" +-+ ver maybeReadMajor ver   | "lts" `isPrefixOf` ver =-      case readMaybe (dropPrefix "-" (dropPrefix "lts" ver)) of-        Just major -> Just (LTS major)-        Nothing -> Nothing+      case dropPrefix "-" (dropPrefix "lts" ver) of+        vs ->+          if null vs+          then error' $ "bad major:" +-+ ver+          else+            if all (\d -> isDigit d || d == '.') vs+            then Just (LTS $ read $ takeWhile isDigit vs)+            else error' $ "bad major version:" +-+ ver+maybeReadMajor "ghc" = Nothing+maybeReadMajor ver   | "ghc" `isPrefixOf` ver =-      case dropPrefix "-" (dropPrefix "ghc" ver) of+      case dropPrefix "-" $ dropPrefix "ghc" ver of+        "9.10" -> Just (LTS 24)         "9.8" -> Just (LTS 23)         "9.6" -> Just (LTS 22)         "9.4" -> Just (LTS 21)@@ -49,7 +60,10 @@         "8.0" -> Just (LTS 9)         "7.10" -> Just (LTS 6)         "7.8" -> Just (LTS 2)-        _ -> Nothing+        ds ->+          if all (\d -> isDigit d || d == '.') ds+          then error' $ "bad major version:" +-+ ver+          else Nothing   | otherwise = Nothing  -- readMajor "lts-16"
stack-all.cabal view
@@ -1,5 +1,5 @@ name:                stack-all-version:             0.7+version:             0.7.1 synopsis:            CLI tool for building over Stackage major versions description:         Stack-all is a tool for stack building of a Haskell project@@ -45,7 +45,7 @@                      , filepath                      , http-query                      , process-                     , simple-cmd >= 0.1.4+                     , simple-cmd >= 0.2.1                      , simple-cmd-args >= 0.1.8                      , text                      , yaml