Web.Bower.PackageMeta

bower-json-1.0.0.1: Read bower.json from Haskell

Safe Haskell | None
Language | Haskell2010

Web.Bower.PackageMeta

Contents

- Data types
- Parsing

Description

A data type representing the Bower.json package description file, together with a parser and related functions.

This code is based on the specification at https://github.com/bower/bower.json-spec.

Synopsis

- data PackageMeta = PackageMeta {
  - bowerName :: PackageName
  - bowerDescription :: Maybe Text
  - bowerMain :: [FilePath]
  - bowerModuleType :: [ModuleType]
  - bowerLicense :: [Text]
  - bowerIgnore :: [Text]
  - bowerKeywords :: [Text]
  - bowerAuthors :: [Author]
  - bowerHomepage :: Maybe Text
  - bowerRepository :: Maybe Repository
  - bowerDependencies :: [(PackageName, VersionRange)]
  - bowerDevDependencies :: [(PackageName, VersionRange)]
  - bowerResolutions :: [(PackageName, Version)]
  - bowerPrivate :: Bool
  }
- data PackageName
- runPackageName :: PackageName -> Text
- mkPackageName :: Text -> Either PackageNameError PackageName
- data Author = Author {
  - authorName :: Text
  - authorEmail :: Maybe Text
  - authorHomepage :: Maybe Text
  }
- data ModuleType
  - = Globals
  - | AMD
  - | Node
  - | ES6
  - | YUI
- moduleTypes :: [(Text, ModuleType)]
- data Repository = Repository {
  - repositoryUrl :: Text
  - repositoryType :: Text
  }
- newtype Version = Version {
  - runVersion :: Text
  }
- newtype VersionRange = VersionRange {
  - runVersionRange :: Text
  }
- data BowerError
  - = InvalidPackageName PackageNameError
  - | InvalidModuleType Text
- showBowerError :: BowerError -> Text
- data PackageNameError
  - = NotEmpty
  - | TooLong Int
  - | InvalidChars [Char]
  - | RepeatedSeparators
  - | MustNotBeginSeparator
  - | MustNotEndSeparator
- showPackageNameError :: PackageNameError -> Text
- decodeFile :: FilePath -> IO (Either (ParseError BowerError) PackageMeta)
- displayError :: ParseError BowerError -> Text
- asPackageMeta :: Parse BowerError PackageMeta
- parseModuleType :: Text -> Either BowerError ModuleType
- parsePackageName :: Text -> Either BowerError PackageName
- asAuthor :: Parse e Author
- asRepository :: Parse e Repository

# Data types

data PackageMeta #

A data type representing the data stored in a bower.json package manifest file.

Note that the `ToJSON` / `FromJSON` instances don't exactly match; for example, it is not always the case that decoding from JSON and then encoding to JSON will give you the exact same JSON that you started with. However, if you start with a PackageMeta value, encode to JSON, and then decode, you should always get the same value back.

Constructors

PackageMeta |
Fields bowerName :: PackageName bowerDescription :: Maybe Text bowerMain :: [FilePath] bowerModuleType :: [ModuleType] bowerLicense :: [Text] bowerIgnore :: [Text] bowerKeywords :: [Text] bowerAuthors :: [Author] bowerHomepage :: Maybe Text bowerRepository :: Maybe Repository bowerDependencies :: [(PackageName, VersionRange)] bowerDevDependencies :: [(PackageName, VersionRange)] bowerResolutions :: [(PackageName, Version)] bowerPrivate :: Bool

Instances

Eq PackageMeta # |
Methods (==) :: PackageMeta -> PackageMeta -> Bool # (/=) :: PackageMeta -> PackageMeta -> Bool #
Ord PackageMeta # |
Methods compare :: PackageMeta -> PackageMeta -> Ordering # (<) :: PackageMeta -> PackageMeta -> Bool # (<=) :: PackageMeta -> PackageMeta -> Bool # (>) :: PackageMeta -> PackageMeta -> Bool # (>=) :: PackageMeta -> PackageMeta -> Bool # max :: PackageMeta -> PackageMeta -> PackageMeta # min :: PackageMeta -> PackageMeta -> PackageMeta #
Show PackageMeta # |
Methods showsPrec :: Int -> PackageMeta -> ShowS # show :: PackageMeta -> String # showList :: [PackageMeta] -> ShowS #
Generic PackageMeta # |
Associated Types type Rep PackageMeta :: * -> * # Methods from :: PackageMeta -> Rep PackageMeta x # to :: Rep PackageMeta x -> PackageMeta #
FromJSON PackageMeta # |
Methods parseJSON :: Value -> Parser PackageMeta # parseJSONList :: Value -> Parser [PackageMeta] #
ToJSON PackageMeta # |
Methods toJSON :: PackageMeta -> Value # toEncoding :: PackageMeta -> Encoding # toJSONList :: [PackageMeta] -> Value # toEncodingList :: [PackageMeta] -> Encoding #
NFData PackageMeta # |
Methods rnf :: PackageMeta -> () #
type Rep PackageMeta # |
type Rep PackageMeta = D1 (MetaData "PackageMeta" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" False) (C1 (MetaCons "PackageMeta" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "bowerName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 PackageName)) ((:*:) (S1 (MetaSel (Just Symbol "bowerDescription") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))) (S1 (MetaSel (Just Symbol "bowerMain") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [FilePath])))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "bowerModuleType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ModuleType])) (S1 (MetaSel (Just Symbol "bowerLicense") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text]))) ((:*:) (S1 (MetaSel (Just Symbol "bowerIgnore") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text])) (S1 (MetaSel (Just Symbol "bowerKeywords") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text]))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "bowerAuthors") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Author])) ((:*:) (S1 (MetaSel (Just Symbol "bowerHomepage") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))) (S1 (MetaSel (Just Symbol "bowerRepository") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Repository))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "bowerDependencies") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(PackageName, VersionRange)])) (S1 (MetaSel (Just Symbol "bowerDevDependencies") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(PackageName, VersionRange)]))) ((:*:) (S1 (MetaSel (Just Symbol "bowerResolutions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(PackageName, Version)])) (S1 (MetaSel (Just Symbol "bowerPrivate") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))))))

data PackageName #

A valid package name for a Bower package.

Instances

Eq PackageName # |
Methods (==) :: PackageName -> PackageName -> Bool # (/=) :: PackageName -> PackageName -> Bool #
Ord PackageName # |
Methods compare :: PackageName -> PackageName -> Ordering # (<) :: PackageName -> PackageName -> Bool # (<=) :: PackageName -> PackageName -> Bool # (>) :: PackageName -> PackageName -> Bool # (>=) :: PackageName -> PackageName -> Bool # max :: PackageName -> PackageName -> PackageName # min :: PackageName -> PackageName -> PackageName #
Show PackageName # |
Methods showsPrec :: Int -> PackageName -> ShowS # show :: PackageName -> String # showList :: [PackageName] -> ShowS #
Generic PackageName # |
Associated Types type Rep PackageName :: * -> * # Methods from :: PackageName -> Rep PackageName x # to :: Rep PackageName x -> PackageName #
FromJSON PackageName # |
Methods parseJSON :: Value -> Parser PackageName # parseJSONList :: Value -> Parser [PackageName] #
ToJSON PackageName # |
Methods toJSON :: PackageName -> Value # toEncoding :: PackageName -> Encoding # toJSONList :: [PackageName] -> Value # toEncodingList :: [PackageName] -> Encoding #
NFData PackageName # |
Methods rnf :: PackageName -> () #
type Rep PackageName # |
type Rep PackageName = D1 (MetaData "PackageName" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" True) (C1 (MetaCons "PackageName" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

runPackageName :: PackageName -> Text #

mkPackageName :: Text -> Either PackageNameError PackageName #

A smart constructor for a PackageName. It ensures that the package name satisfies the restrictions described at https://github.com/bower/bower.json-spec#name.

data Author #

Constructors

Author |
Fields authorName :: Text authorEmail :: Maybe Text authorHomepage :: Maybe Text

Instances

Eq Author # |
Methods (==) :: Author -> Author -> Bool # (/=) :: Author -> Author -> Bool #
Ord Author # |
Methods compare :: Author -> Author -> Ordering # (<) :: Author -> Author -> Bool # (<=) :: Author -> Author -> Bool # (>) :: Author -> Author -> Bool # (>=) :: Author -> Author -> Bool # max :: Author -> Author -> Author # min :: Author -> Author -> Author #
Show Author # |
Methods showsPrec :: Int -> Author -> ShowS # show :: Author -> String # showList :: [Author] -> ShowS #
Generic Author # |
Associated Types type Rep Author :: * -> * # Methods from :: Author -> Rep Author x # to :: Rep Author x -> Author #
FromJSON Author # |
Methods parseJSON :: Value -> Parser Author # parseJSONList :: Value -> Parser [Author] #
ToJSON Author # |
Methods toJSON :: Author -> Value # toEncoding :: Author -> Encoding # toJSONList :: [Author] -> Value # toEncodingList :: [Author] -> Encoding #
NFData Author # |
Methods rnf :: Author -> () #
type Rep Author # |
type Rep Author = D1 (MetaData "Author" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" False) (C1 (MetaCons "Author" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "authorName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)) ((:*:) (S1 (MetaSel (Just Symbol "authorEmail") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))) (S1 (MetaSel (Just Symbol "authorHomepage") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))))))

data ModuleType #

See: https://github.com/bower/bower.json-spec#moduletype

Constructors

Globals |
AMD |
Node |
ES6 |
YUI |

Instances

Bounded ModuleType # |
Methods minBound :: ModuleType # maxBound :: ModuleType #
Enum ModuleType # |
Methods succ :: ModuleType -> ModuleType # pred :: ModuleType -> ModuleType # toEnum :: Int -> ModuleType # fromEnum :: ModuleType -> Int # enumFrom :: ModuleType -> [ModuleType] # enumFromThen :: ModuleType -> ModuleType -> [ModuleType] # enumFromTo :: ModuleType -> ModuleType -> [ModuleType] # enumFromThenTo :: ModuleType -> ModuleType -> ModuleType -> [ModuleType] #
Eq ModuleType # |
Methods (==) :: ModuleType -> ModuleType -> Bool # (/=) :: ModuleType -> ModuleType -> Bool #
Ord ModuleType # |
Methods compare :: ModuleType -> ModuleType -> Ordering # (<) :: ModuleType -> ModuleType -> Bool # (<=) :: ModuleType -> ModuleType -> Bool # (>) :: ModuleType -> ModuleType -> Bool # (>=) :: ModuleType -> ModuleType -> Bool # max :: ModuleType -> ModuleType -> ModuleType # min :: ModuleType -> ModuleType -> ModuleType #
Show ModuleType # |
Methods showsPrec :: Int -> ModuleType -> ShowS # show :: ModuleType -> String # showList :: [ModuleType] -> ShowS #
Generic ModuleType # |
Associated Types type Rep ModuleType :: * -> * # Methods from :: ModuleType -> Rep ModuleType x # to :: Rep ModuleType x -> ModuleType #
FromJSON ModuleType # |
Methods parseJSON :: Value -> Parser ModuleType # parseJSONList :: Value -> Parser [ModuleType] #
ToJSON ModuleType # |
Methods toJSON :: ModuleType -> Value # toEncoding :: ModuleType -> Encoding # toJSONList :: [ModuleType] -> Value # toEncodingList :: [ModuleType] -> Encoding #
NFData ModuleType # |
Methods rnf :: ModuleType -> () #
type Rep ModuleType # |
type Rep ModuleType = D1 (MetaData "ModuleType" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" False) ((:+:) ((:+:) (C1 (MetaCons "Globals" PrefixI False) U1) (C1 (MetaCons "AMD" PrefixI False) U1)) ((:+:) (C1 (MetaCons "Node" PrefixI False) U1) ((:+:) (C1 (MetaCons "ES6" PrefixI False) U1) (C1 (MetaCons "YUI" PrefixI False) U1))))

moduleTypes :: [(Text, ModuleType)] #

data Repository #

Constructors

Repository |
Fields repositoryUrl :: Text repositoryType :: Text

Instances

Eq Repository # |
Methods (==) :: Repository -> Repository -> Bool # (/=) :: Repository -> Repository -> Bool #
Ord Repository # |
Methods compare :: Repository -> Repository -> Ordering # (<) :: Repository -> Repository -> Bool # (<=) :: Repository -> Repository -> Bool # (>) :: Repository -> Repository -> Bool # (>=) :: Repository -> Repository -> Bool # max :: Repository -> Repository -> Repository # min :: Repository -> Repository -> Repository #
Show Repository # |
Methods showsPrec :: Int -> Repository -> ShowS # show :: Repository -> String # showList :: [Repository] -> ShowS #
Generic Repository # |
Associated Types type Rep Repository :: * -> * # Methods from :: Repository -> Rep Repository x # to :: Rep Repository x -> Repository #
FromJSON Repository # |
Methods parseJSON :: Value -> Parser Repository # parseJSONList :: Value -> Parser [Repository] #
ToJSON Repository # |
Methods toJSON :: Repository -> Value # toEncoding :: Repository -> Encoding # toJSONList :: [Repository] -> Value # toEncodingList :: [Repository] -> Encoding #
NFData Repository # |
Methods rnf :: Repository -> () #
type Rep Repository # |
type Rep Repository = D1 (MetaData "Repository" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" False) (C1 (MetaCons "Repository" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "repositoryUrl") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)) (S1 (MetaSel (Just Symbol "repositoryType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))))

newtype Version #

Constructors

Version |
Fields runVersion :: Text

Instances

Eq Version # |
Methods (==) :: Version -> Version -> Bool # (/=) :: Version -> Version -> Bool #
Ord Version # |
Methods compare :: Version -> Version -> Ordering # (<) :: Version -> Version -> Bool # (<=) :: Version -> Version -> Bool # (>) :: Version -> Version -> Bool # (>=) :: Version -> Version -> Bool # max :: Version -> Version -> Version # min :: Version -> Version -> Version #
Show Version # |
Methods showsPrec :: Int -> Version -> ShowS # show :: Version -> String # showList :: [Version] -> ShowS #
Generic Version # |
Associated Types type Rep Version :: * -> * # Methods from :: Version -> Rep Version x # to :: Rep Version x -> Version #
FromJSON Version # |
Methods parseJSON :: Value -> Parser Version # parseJSONList :: Value -> Parser [Version] #
ToJSON Version # |
Methods toJSON :: Version -> Value # toEncoding :: Version -> Encoding # toJSONList :: [Version] -> Value # toEncodingList :: [Version] -> Encoding #
NFData Version # |
Methods rnf :: Version -> () #
type Rep Version # |
type Rep Version = D1 (MetaData "Version" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" True) (C1 (MetaCons "Version" PrefixI True) (S1 (MetaSel (Just Symbol "runVersion") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

newtype VersionRange #

Constructors

VersionRange |
Fields runVersionRange :: Text

Instances

Eq VersionRange # |
Methods (==) :: VersionRange -> VersionRange -> Bool # (/=) :: VersionRange -> VersionRange -> Bool #
Ord VersionRange # |
Methods compare :: VersionRange -> VersionRange -> Ordering # (<) :: VersionRange -> VersionRange -> Bool # (<=) :: VersionRange -> VersionRange -> Bool # (>) :: VersionRange -> VersionRange -> Bool # (>=) :: VersionRange -> VersionRange -> Bool # max :: VersionRange -> VersionRange -> VersionRange # min :: VersionRange -> VersionRange -> VersionRange #
Show VersionRange # |
Methods showsPrec :: Int -> VersionRange -> ShowS # show :: VersionRange -> String # showList :: [VersionRange] -> ShowS #
Generic VersionRange # |
Associated Types type Rep VersionRange :: * -> * # Methods from :: VersionRange -> Rep VersionRange x # to :: Rep VersionRange x -> VersionRange #
FromJSON VersionRange # |
Methods parseJSON :: Value -> Parser VersionRange # parseJSONList :: Value -> Parser [VersionRange] #
ToJSON VersionRange # |
Methods toJSON :: VersionRange -> Value # toEncoding :: VersionRange -> Encoding # toJSONList :: [VersionRange] -> Value # toEncodingList :: [VersionRange] -> Encoding #
NFData VersionRange # |
Methods rnf :: VersionRange -> () #
type Rep VersionRange # |
type Rep VersionRange = D1 (MetaData "VersionRange" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" True) (C1 (MetaCons "VersionRange" PrefixI True) (S1 (MetaSel (Just Symbol "runVersionRange") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

data BowerError #

Constructors

InvalidPackageName PackageNameError |
InvalidModuleType Text |

Instances

Eq BowerError # |
Methods (==) :: BowerError -> BowerError -> Bool # (/=) :: BowerError -> BowerError -> Bool #
Ord BowerError # |
Methods compare :: BowerError -> BowerError -> Ordering # (<) :: BowerError -> BowerError -> Bool # (<=) :: BowerError -> BowerError -> Bool # (>) :: BowerError -> BowerError -> Bool # (>=) :: BowerError -> BowerError -> Bool # max :: BowerError -> BowerError -> BowerError # min :: BowerError -> BowerError -> BowerError #
Show BowerError # |
Methods showsPrec :: Int -> BowerError -> ShowS # show :: BowerError -> String # showList :: [BowerError] -> ShowS #
Generic BowerError # |
Associated Types type Rep BowerError :: * -> * # Methods from :: BowerError -> Rep BowerError x # to :: Rep BowerError x -> BowerError #
NFData BowerError # |
Methods rnf :: BowerError -> () #
type Rep BowerError # |
type Rep BowerError = D1 (MetaData "BowerError" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" False) ((:+:) (C1 (MetaCons "InvalidPackageName" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 PackageNameError))) (C1 (MetaCons "InvalidModuleType" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))))

showBowerError :: BowerError -> Text #

data PackageNameError #

Constructors

NotEmpty |
TooLong Int |
InvalidChars [Char] |
RepeatedSeparators |
MustNotBeginSeparator |
MustNotEndSeparator |

Instances

Eq PackageNameError # |
Methods (==) :: PackageNameError -> PackageNameError -> Bool # (/=) :: PackageNameError -> PackageNameError -> Bool #
Ord PackageNameError # |
Methods compare :: PackageNameError -> PackageNameError -> Ordering # (<) :: PackageNameError -> PackageNameError -> Bool # (<=) :: PackageNameError -> PackageNameError -> Bool # (>) :: PackageNameError -> PackageNameError -> Bool # (>=) :: PackageNameError -> PackageNameError -> Bool # max :: PackageNameError -> PackageNameError -> PackageNameError # min :: PackageNameError -> PackageNameError -> PackageNameError #
Show PackageNameError # |
Methods showsPrec :: Int -> PackageNameError -> ShowS # show :: PackageNameError -> String # showList :: [PackageNameError] -> ShowS #
Generic PackageNameError # |
Associated Types type Rep PackageNameError :: * -> * # Methods from :: PackageNameError -> Rep PackageNameError x # to :: Rep PackageNameError x -> PackageNameError #
NFData PackageNameError # |
Methods rnf :: PackageNameError -> () #
type Rep PackageNameError # |
type Rep PackageNameError = D1 (MetaData "PackageNameError" "Web.Bower.PackageMeta.Internal" "bower-json-1.0.0.1-KHYO9JtCsLgJhicOVc5y3l" False) ((:+:) ((:+:) (C1 (MetaCons "NotEmpty" PrefixI False) U1) ((:+:) (C1 (MetaCons "TooLong" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int))) (C1 (MetaCons "InvalidChars" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Char]))))) ((:+:) (C1 (MetaCons "RepeatedSeparators" PrefixI False) U1) ((:+:) (C1 (MetaCons "MustNotBeginSeparator" PrefixI False) U1) (C1 (MetaCons "MustNotEndSeparator" PrefixI False) U1))))

showPackageNameError :: PackageNameError -> Text #

# Parsing

decodeFile :: FilePath -> IO (Either (ParseError BowerError) PackageMeta) #

Read and attempt to decode a bower.json file.

displayError :: ParseError BowerError -> Text #

asPackageMeta :: Parse BowerError PackageMeta #

A parser for bower.json files, using the aeson-better-errors package.

parseModuleType :: Text -> Either BowerError ModuleType #

parsePackageName :: Text -> Either BowerError PackageName #

asAuthor :: Parse e Author #

asRepository :: Parse e Repository #