yarn-lock-0.3.2: Represent and parse yarn.lock files

MaintainerProfpatsch
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Yarn.Lock.Parse

Contents

Description

This module provides a parser for the AST of yarn.lock files.

Synopsis

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

type Parser = Parsec Dec Text #

Modules corresponding to various types of streams define Parser accordingly, so the user can use it to easily change type of input stream by importing different “type modules”. This one is for strict Text.

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

field :: Parser (Text, Either Text PackageFields) Source #

Either a simple or a nested field.

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 [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 ".