Web.Bower.PackageMeta

bower-json-0.8.0: 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 String
  - bowerMain :: [FilePath]
  - bowerModuleType :: [ModuleType]
  - bowerLicense :: [String]
  - bowerIgnore :: [String]
  - bowerKeywords :: [String]
  - bowerAuthors :: [Author]
  - bowerHomepage :: Maybe String
  - bowerRepository :: Maybe Repository
  - bowerDependencies :: [(PackageName, VersionRange)]
  - bowerDevDependencies :: [(PackageName, VersionRange)]
  - bowerResolutions :: [(PackageName, Version)]
  - bowerPrivate :: Bool
  }
- data PackageName
- runPackageName :: PackageName -> String
- mkPackageName :: String -> Either PackageNameError PackageName
- data Author = Author {
  - authorName :: String
  - authorEmail :: Maybe String
  - authorHomepage :: Maybe String
  }
- data ModuleType
  - = Globals
  - | AMD
  - | Node
  - | ES6
  - | YUI
- moduleTypes :: [(String, ModuleType)]
- data Repository = Repository {
  - repositoryUrl :: String
  - repositoryType :: String
  }
- newtype Version = Version {
  - runVersion :: String
  }
- newtype VersionRange = VersionRange {
  - runVersionRange :: String
  }
- data BowerError
  - = InvalidPackageName PackageNameError
  - | InvalidModuleType String
- showBowerError :: BowerError -> Text
- data PackageNameError
  - = NotEmpty
  - | TooLong Int
  - | InvalidChars String
  - | RepeatedSeparators
  - | MustNotBeginSeparator
  - | MustNotEndSeparator
- showPackageNameError :: PackageNameError -> Text
- decodeFile :: FilePath -> IO (Either (ParseError BowerError) PackageMeta)
- displayError :: ParseError BowerError -> Text
- asPackageMeta :: Parse BowerError PackageMeta
- parseModuleType :: String -> Either BowerError ModuleType
- parsePackageName :: String -> 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 String bowerMain :: [FilePath] bowerModuleType :: [ModuleType] bowerLicense :: [String] bowerIgnore :: [String] bowerKeywords :: [String] bowerAuthors :: [Author] bowerHomepage :: Maybe String 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 #
ToJSON PackageMeta # |
Methods toJSON :: PackageMeta -> Value # toEncoding :: PackageMeta -> Encoding #
FromJSON PackageMeta # |
Methods parseJSON :: Value -> Parser PackageMeta #

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 #
ToJSON PackageName # |
Methods toJSON :: PackageName -> Value # toEncoding :: PackageName -> Encoding #
FromJSON PackageName # |
Methods parseJSON :: Value -> Parser PackageName #

runPackageName :: PackageName -> String #

mkPackageName :: String -> 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 :: String authorEmail :: Maybe String authorHomepage :: Maybe String

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 #
ToJSON Author # |
Methods toJSON :: Author -> Value # toEncoding :: Author -> Encoding #
FromJSON Author # |
Methods parseJSON :: Value -> Parser Author #

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 #
ToJSON ModuleType # |
Methods toJSON :: ModuleType -> Value # toEncoding :: ModuleType -> Encoding #
FromJSON ModuleType # |
Methods parseJSON :: Value -> Parser ModuleType #

moduleTypes :: [(String, ModuleType)] #

data Repository #

Constructors

Repository |
Fields repositoryUrl :: String repositoryType :: String

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 #
ToJSON Repository # |
Methods toJSON :: Repository -> Value # toEncoding :: Repository -> Encoding #
FromJSON Repository # |
Methods parseJSON :: Value -> Parser Repository #

newtype Version #

Constructors

Version |
Fields runVersion :: String

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 #
ToJSON Version # |
Methods toJSON :: Version -> Value # toEncoding :: Version -> Encoding #
FromJSON Version # |
Methods parseJSON :: Value -> Parser Version #

newtype VersionRange #

Constructors

VersionRange |
Fields runVersionRange :: String

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 #
ToJSON VersionRange # |
Methods toJSON :: VersionRange -> Value # toEncoding :: VersionRange -> Encoding #
FromJSON VersionRange # |
Methods parseJSON :: Value -> Parser VersionRange #

data BowerError #

Constructors

InvalidPackageName PackageNameError |
InvalidModuleType String |

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 #

showBowerError :: BowerError -> Text #

data PackageNameError #

Constructors

NotEmpty |
TooLong Int |
InvalidChars String |
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 #

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 :: String -> Either BowerError ModuleType #

parsePackageName :: String -> Either BowerError PackageName #

asAuthor :: Parse e Author #

asRepository :: Parse e Repository #