Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/doorgan/yarn_parser
- Owner: doorgan
- License: mit
- Created: 2020-08-04T03:11:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-11T23:11:00.000Z (about 4 years ago)
- Last Synced: 2024-09-30T17:31:30.567Z (about 2 months ago)
- Topics: elixir-lang, elixir-library, yarn, yarnpkg
- Language: Elixir
- Homepage:
- Size: 25.4 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
1iex> YarnParser.encode(parsed)
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1key1, key2:
subkey1:
val2 123
val1 true```
## TODO
- [ ] Parse with merge conflicts
- [ ] Improve error messages
- [ ] Improve test suite
- [ ] Implement encoder for v2 lockfiles