Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/doorgan/yarn_parser

A simple Yarn lockfile parser and encoder
https://github.com/doorgan/yarn_parser

elixir-lang elixir-library yarn yarnpkg

Last synced: about 1 month ago
JSON representation

A simple Yarn lockfile parser and encoder

Awesome Lists containing this project

README

        

# YarnParser

## Installation

[Available in Hex](https://hex.pm/packages/yarn_parser), the package can be installed
by adding `yarn_parser` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:yarn_parser, "~> 0.3.1"}
]
end
```

## Usage

```elixir
iex> input =
"""
# Some comment
# yarn lockfile v1
key1, key2:
val1 true
subkey1:
val2 123
"""

iex> {:ok, parsed} = YarnParser.decode(input)
iex> parsed
%YarnParser.YarnLock{
metadata: %{
"version" => 1
}
dependencies: {
"key1" => %{
"val1" => true,
"subkey1" => %{
"val2" => 123
}
},
"key2" => %{
"val1" => true,
"subkey1" => %{
"val2" => 123
}
}
}
}

iex> YarnParser.get_version(parsed)
1

iex> YarnParser.encode(parsed)
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

key1, key2:
subkey1:
val2 123
val1 true

```

## TODO
- [ ] Parse with merge conflicts
- [ ] Improve error messages
- [ ] Improve test suite
- [ ] Implement encoder for v2 lockfiles