mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 08:45:42 +03:00
Setup new terminal command: outdated.
This commit is contained in:
parent
5bda3496e2
commit
ec26054a26
@ -59,6 +59,7 @@ Common gren-common
|
|||||||
Package
|
Package
|
||||||
Package.Install
|
Package.Install
|
||||||
Package.Uninstall
|
Package.Uninstall
|
||||||
|
Package.Outdated
|
||||||
Package.Bump
|
Package.Bump
|
||||||
Package.Diff
|
Package.Diff
|
||||||
Package.Validate
|
Package.Validate
|
||||||
|
@ -9,6 +9,7 @@ import Data.List qualified as List
|
|||||||
import Package.Bump qualified as Bump
|
import Package.Bump qualified as Bump
|
||||||
import Package.Diff qualified as Diff
|
import Package.Diff qualified as Diff
|
||||||
import Package.Install qualified as Install
|
import Package.Install qualified as Install
|
||||||
|
import Package.Outdated qualified as Outdated
|
||||||
import Package.Uninstall qualified as Uninstall
|
import Package.Uninstall qualified as Uninstall
|
||||||
import Package.Validate qualified as Validate
|
import Package.Validate qualified as Validate
|
||||||
import Terminal
|
import Terminal
|
||||||
@ -25,6 +26,7 @@ run =
|
|||||||
P.empty
|
P.empty
|
||||||
[ install,
|
[ install,
|
||||||
uninstall,
|
uninstall,
|
||||||
|
outdated,
|
||||||
bump,
|
bump,
|
||||||
diff,
|
diff,
|
||||||
validate
|
validate
|
||||||
@ -107,6 +109,35 @@ uninstall =
|
|||||||
|-- onOff "yes" "Assume yes for all interactive prompts."
|
|-- onOff "yes" "Assume yes for all interactive prompts."
|
||||||
in Terminal.Command "uninstall" Uncommon details example uninstallArgs uninstallFlags Uninstall.run
|
in Terminal.Command "uninstall" Uncommon details example uninstallArgs uninstallFlags Uninstall.run
|
||||||
|
|
||||||
|
-- OUTDATED
|
||||||
|
|
||||||
|
outdated :: Terminal.Command
|
||||||
|
outdated =
|
||||||
|
let details =
|
||||||
|
"The `outdated` command lists the latest version of your dependencies, if you're\
|
||||||
|
\ not already using them:"
|
||||||
|
|
||||||
|
example =
|
||||||
|
stack
|
||||||
|
[ reflow
|
||||||
|
"For example, if you want to list any outdated dependencies in your project,\
|
||||||
|
\ you would say:",
|
||||||
|
P.indent 4 $
|
||||||
|
P.green $
|
||||||
|
P.vcat $
|
||||||
|
[ "gren package outdated"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
outdatedArgs =
|
||||||
|
require0 Outdated.NoArgs
|
||||||
|
|
||||||
|
outdatedFlags =
|
||||||
|
flags Outdated.Flags
|
||||||
|
|-- onOff "yes" "Assume yes for all interactive prompts."
|
||||||
|
|-- onOff "unsafe" "Show latest version, even if it contains breaking changes."
|
||||||
|
in Terminal.Command "outdated" Uncommon details example outdatedArgs outdatedFlags Outdated.run
|
||||||
|
|
||||||
-- VALIDATE
|
-- VALIDATE
|
||||||
|
|
||||||
validate :: Terminal.Command
|
validate :: Terminal.Command
|
||||||
|
49
terminal/src/Package/Outdated.hs
Normal file
49
terminal/src/Package/Outdated.hs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Package.Outdated
|
||||||
|
( Args (..),
|
||||||
|
Flags (..),
|
||||||
|
run,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Deps.Solver qualified as Solver
|
||||||
|
import Directories qualified as Dirs
|
||||||
|
import Gren.Outline qualified as Outline
|
||||||
|
import Reporting qualified
|
||||||
|
import Reporting.Exit qualified as Exit
|
||||||
|
import Reporting.Task qualified as Task
|
||||||
|
|
||||||
|
-- RUN
|
||||||
|
|
||||||
|
data Args
|
||||||
|
= NoArgs
|
||||||
|
|
||||||
|
data Flags = Flags
|
||||||
|
{ _skipPrompts :: Bool
|
||||||
|
, _unsafe :: Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: Args -> Flags -> IO ()
|
||||||
|
run _ (Flags _skipPrompts _unafe) =
|
||||||
|
Reporting.attempt Exit.installToReport $
|
||||||
|
do
|
||||||
|
maybeRoot <- Dirs.findRoot
|
||||||
|
case maybeRoot of
|
||||||
|
Nothing ->
|
||||||
|
return (Left Exit.InstallNoOutline)
|
||||||
|
Just root ->
|
||||||
|
Task.run $
|
||||||
|
do
|
||||||
|
env <- Task.io Solver.initEnv
|
||||||
|
oldOutline <- Task.eio Exit.InstallBadOutline $ Outline.read root
|
||||||
|
installDependencies env oldOutline
|
||||||
|
|
||||||
|
-- LIST OUTDATED
|
||||||
|
|
||||||
|
type Task = Task.Task Exit.Install
|
||||||
|
|
||||||
|
installDependencies :: Solver.Env -> Outline.Outline -> Task ()
|
||||||
|
installDependencies (Solver.Env _) _ =
|
||||||
|
return ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user