mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 16:56:29 +03:00
Merge pull request #183 from gren-lang/make-package-validate-local-dep-aware
Validate now checks that package doesn't contain any local dependencies.
This commit is contained in:
commit
9630bc0ab8
@ -400,6 +400,7 @@ data Validate
|
||||
| ValidateNoReadme
|
||||
| ValidateShortReadme
|
||||
| ValidateNoLicense
|
||||
| ValidateHasLocalDependencies
|
||||
| ValidateBuildProblem BuildProblem
|
||||
| ValidateCannotGetDocs V.Version V.Version DocsProblem
|
||||
| ValidateMissingTag V.Version
|
||||
@ -646,6 +647,16 @@ validateToReport validate =
|
||||
\ license text must appear in the root of your project in a file\
|
||||
\ named LICENSE. Add that file and you will be all set!"
|
||||
]
|
||||
ValidateHasLocalDependencies ->
|
||||
Help.report
|
||||
"FOUND LOCAL DEPENDENCIES"
|
||||
(Just "gren.json")
|
||||
"When installing a package, all of the package's dependencies are also installed.\
|
||||
\ Local (on-disk) dependencies cannot be installed over the network, so when you\
|
||||
\ rely on such a package, no one else can install your package either."
|
||||
[ D.reflow
|
||||
"Remove all local dependencies (those prefixed with local:) from your gren.json file."
|
||||
]
|
||||
ValidateBuildProblem buildProblem ->
|
||||
toBuildProblemReport buildProblem
|
||||
ValidateCannotGetDocs old new docsProblem ->
|
||||
|
@ -10,17 +10,21 @@ import Build qualified
|
||||
import Control.Monad (void)
|
||||
import Data.Either qualified as Either
|
||||
import Data.List qualified as List
|
||||
import Data.Map qualified as Map
|
||||
import Data.NonEmptyList qualified as NE
|
||||
import Deps.Diff qualified as Diff
|
||||
import Deps.Package qualified as Package
|
||||
import Directories qualified as Dirs
|
||||
import File qualified
|
||||
import Git qualified
|
||||
import Gren.Constraint qualified as Con
|
||||
import Gren.Details qualified as Details
|
||||
import Gren.Docs qualified as Docs
|
||||
import Gren.Magnitude qualified as M
|
||||
import Gren.Outline qualified as Outline
|
||||
import Gren.Package qualified as Pkg
|
||||
import Gren.PossibleFilePath (PossibleFilePath)
|
||||
import Gren.PossibleFilePath qualified as PossibleFilePath
|
||||
import Gren.Version qualified as V
|
||||
import Json.String qualified as Json
|
||||
import Reporting qualified
|
||||
@ -64,7 +68,7 @@ validate env@(Env root _ outline) =
|
||||
case outline of
|
||||
Outline.App _ ->
|
||||
Task.throw Exit.ValidateApplication
|
||||
Outline.Pkg (Outline.PkgOutline pkg summary _ vsn exposed _ _ _) ->
|
||||
Outline.Pkg (Outline.PkgOutline pkg summary _ vsn exposed deps _ _) ->
|
||||
do
|
||||
knownVersionsResult <- Task.io $ Package.getVersions pkg
|
||||
let knownVersionsMaybe = Either.either (const Nothing) Just knownVersionsResult
|
||||
@ -75,12 +79,13 @@ validate env@(Env root _ outline) =
|
||||
|
||||
verifyReadme root
|
||||
verifyLicense root
|
||||
verifyNoLocalDeps deps
|
||||
docs <- verifyBuild root
|
||||
verifyVersion env pkg vsn docs knownVersionsMaybe
|
||||
verifyTag vsn
|
||||
verifyNoChanges vsn
|
||||
|
||||
Task.io $ putStrLn "Success!"
|
||||
Task.io $ putStrLn "Everything looks good!"
|
||||
|
||||
-- VERIFY SUMMARY
|
||||
|
||||
@ -124,6 +129,16 @@ verifyLicense root =
|
||||
then return (Right ())
|
||||
else return (Left Exit.ValidateNoLicense)
|
||||
|
||||
-- VERIFY NO LOCAL DEPS
|
||||
|
||||
verifyNoLocalDeps :: Map.Map Pkg.Name (PossibleFilePath Con.Constraint) -> Task.Task Exit.Validate ()
|
||||
verifyNoLocalDeps deps =
|
||||
reportLocalDepsCheck $
|
||||
do
|
||||
if any PossibleFilePath.is (Map.elems deps)
|
||||
then return (Left Exit.ValidateHasLocalDependencies)
|
||||
else return (Right ())
|
||||
|
||||
-- VERIFY BUILD
|
||||
|
||||
verifyBuild :: FilePath -> Task.Task Exit.Validate Docs.Documentation
|
||||
@ -246,6 +261,13 @@ reportLicenseCheck =
|
||||
"Found LICENSE"
|
||||
"Problem with your LICENSE"
|
||||
|
||||
reportLocalDepsCheck :: IO (Either x a) -> Task.Task x a
|
||||
reportLocalDepsCheck =
|
||||
reportCheck
|
||||
"Making sure there are no local dependencies"
|
||||
"Found no local dependencies"
|
||||
"Problem with dependencies"
|
||||
|
||||
reportBuildCheck :: IO (Either x a) -> Task.Task x a
|
||||
reportBuildCheck =
|
||||
reportCheck
|
||||
|
Loading…
Reference in New Issue
Block a user