Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Nov 22, 2023
1 parent 0ae9da4 commit cc3602f
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions cabal-install/src/Distribution/Client/CmdOutdated.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ module Distribution.Client.CmdOutdated
import qualified Data.Set as Set

import Distribution.Client.Compat.Prelude
import Distribution.Client.Config
( SavedConfig
( savedGlobalFlags
)
)
import Distribution.Client.Errors (CabalInstallException (OutdatedAction))
import qualified Distribution.Client.IndexUtils as IndexUtils
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..)
Expand All @@ -41,14 +35,10 @@ import Distribution.Client.ProjectOrchestration
, ProjectBaseContext (..)
, establishProjectBaseContext
)
import Distribution.Client.Sandbox
( loadConfigOrSandboxConfig
)
import Distribution.Client.Setup
( ConfigFlags (..)
, GlobalFlags (..)
, configCompilerAux'
, withRepoContext
)
import Distribution.Client.Types.PackageLocation
( UnresolvedPkgLoc
Expand Down Expand Up @@ -79,7 +69,6 @@ import Distribution.Simple.Setup
)
import Distribution.Simple.Utils
( debug
, dieWithException
, wrapText
)
import Distribution.Solver.Types.SourcePackage
Expand All @@ -103,7 +92,6 @@ import Distribution.Types.UnqualComponentName (UnqualComponentName)
import Distribution.Verbosity
( lessVerbose
, normal
, silent
)
import Distribution.Version
( simplifyVersionRange
Expand Down Expand Up @@ -131,34 +119,42 @@ outdatedCommand =
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
outdatedAction :: NixStyleFlags OutdatedFlags -> [String] -> GlobalFlags -> IO ()
outdatedAction flags@NixStyleFlags{configFlags} _extraArgs globalFlags = do
outdatedAction flags _extraArgs globalFlags = do
ProjectBaseContext{localPackages, projectConfig} <- establishProjectBaseContext verbosity cliConfig OtherCommand

projectConfigWithSolverRepoContext
verbosity
(projectConfigShared projectConfig)
(projectConfigBuildOnly projectConfig)
$ \repoContext -> do
-- Why?
-- when (not v2FreezeFile && (isJust mprojectDir || isJust mprojectFile)) $
-- dieWithException verbosity OutdatedAction
let mprojectDir = flagToMaybe . flagProjectDir $ projectFlags flags
mprojectFile = flagToMaybe . flagProjectFile $ projectFlags flags

sourcePkgDb <- IndexUtils.getSourcePackages verbosity repoContext

let pkgVerConstraints = extractPackageVersionConstraints localPackages
pkgVerConstraints <-
if
| v1FreezeFile -> V1Outdated.depsFromFreezeFile verbosity
| v2FreezeFile -> do
(comp, platform, _progdb) <- configCompilerAux' $ configFlags flags
V1Outdated.depsFromNewFreezeFile verbosity globalFlags comp platform mprojectDir mprojectFile
| otherwise -> pure $ force (extractPackageVersionConstraints localPackages)

debug verbosity $
"Dependencies loaded: " ++ intercalate ", " (map prettyShow pkgVerConstraints)

let outdatedDeps = V1Outdated.listOutdated pkgVerConstraints sourcePkgDb (ListOutdatedSettings ignorePred minorPred)

V1Outdated.showResult (lessVerbose verbosity) outdatedDeps simpleOutput
when (not quiet) $ do
putStrLn "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
V1Outdated.showResult (lessVerbose verbosity) outdatedDeps simpleOutput
putStrLn "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

if exitCode && (not . null $ outdatedDeps)
then exitFailure
else pure ()
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
verbosity = fromFlagOrDefault normal (configVerbosity $ configFlags flags)

cliConfig =
commandLineFlagsToProjectConfig
Expand Down

0 comments on commit cc3602f

Please sign in to comment.