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 |
Ord PackageMeta |
Show PackageMeta |
ToJSON PackageMeta |
FromJSON PackageMeta |

data PackageName

A valid package name for a Bower package.

Instances

Eq PackageName |
Ord PackageName |
Show PackageName |
ToJSON PackageName |
FromJSON 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 |
Ord Author |
Show Author |
ToJSON Author |
FromJSON Author |

data ModuleType

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

Constructors

Globals |
AMD |
Node |
ES6 |
YUI |

Instances

Bounded ModuleType |
Enum ModuleType |
Eq ModuleType |
Ord ModuleType |
Show ModuleType |
ToJSON ModuleType |
FromJSON ModuleType |

moduleTypes :: [(String, ModuleType)]

data Repository

Constructors

Repository |
Fields repositoryUrl :: String repositoryType :: String

Instances

Eq Repository |
Ord Repository |
Show Repository |
ToJSON Repository |
FromJSON Repository |

newtype Version

Constructors

Version |
Fields runVersion :: String

Instances

Eq Version |
Ord Version |
Show Version |
ToJSON Version |
FromJSON Version |

newtype VersionRange

Constructors

VersionRange |
Fields runVersionRange :: String

Instances

Eq VersionRange |
Ord VersionRange |
Show VersionRange |
ToJSON VersionRange |
FromJSON VersionRange |

data BowerError

Constructors

InvalidPackageName PackageNameError |
InvalidModuleType String |

Instances

Eq BowerError |
Ord BowerError |
Show BowerError |

showBowerError :: BowerError -> Text

data PackageNameError

Constructors

NotEmpty |
TooLong Int |
InvalidChars String |
RepeatedSeparators |
MustNotBeginSeparator |
MustNotEndSeparator |

Instances

Eq PackageNameError |
Ord PackageNameError |
Show PackageNameError |

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