Maintainer | Profpatsch |
---|---|
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module provides a parser for the AST of yarn.lock
files.
- newtype PackageFields = PackageFields (Map Text (Either Text PackageFields))
- type Package = Keyed (SourcePos, PackageFields)
- type Parser = Parsec Dec Text
- packageList :: Parser [Package]
- packageEntry :: Parser (Keyed (SourcePos, PackageFields))
- field :: Parser (Text, Either Text PackageFields)
- nestedField :: Parser (Text, PackageFields)
- simpleField :: Parser (Text, Text)
- packageKeys :: Parser (NonEmpty PackageKey)
- packageKey :: [Char] -> Parser PackageKey
Documentation
newtype PackageFields Source #
The yarn.lock
format doesn’t specifically include a fixed scheme,
it’s just an unnecessary custom version of a list of fields.
An field can either be a string or more fields w/ deeper indentation.
The actual conversion to semantic structures needs to be done afterwards.
type Package = Keyed (SourcePos, PackageFields) Source #
A parsed Package
AST has one or more keys, a position in the original files
and a collection of fields.
Parsing
Re-export
Parsers
packageList :: Parser [Package] Source #
Parse a complete yarn.lock into an abstract syntax tree, keeping the source positions of each package entry.
packageEntry :: Parser (Keyed (SourcePos, PackageFields)) Source #
A single Package.
Example:
handlebars@^4.0.4: version "4.0.6" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.6.tgz#2ce4484850537f9c97a8026d5399b935c4ed4ed7" dependencies: async "^1.4.0" optimist "^0.6.1" source-map "^0.4.4" optionalDependencies: uglify-js "^2.6" "
Internal Parsers
nestedField :: Parser (Text, PackageFields) Source #
Similar to a simpleField
, but instead of a string
we get another block with deeper indentation.
simpleField :: Parser (Text, Text) Source #
A key-value pair, separated by space. Key any value may be enclosed in "". Returns key and value.
packageKeys :: Parser (NonEmpty PackageKey) Source #
The list of PackageKeys that index the same Package
align-text^0.1.1, align-text
^0.1.3:\n
packageKey :: [Char] -> Parser PackageKey Source #
A packageKey is <package-name>@<semver>
;
If the semver contains spaces, it is also quoted with "
.