https://github.com/containerbuildsystem/pyarn
https://github.com/containerbuildsystem/pyarn
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/containerbuildsystem/pyarn
- Owner: containerbuildsystem
- License: gpl-3.0
- Created: 2020-11-12T15:07:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T13:36:21.000Z (over 1 year ago)
- Last Synced: 2025-11-10T10:24:25.743Z (7 months ago)
- Language: Python
- Size: 177 KB
- Stars: 6
- Watchers: 5
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://coveralls.io/github/containerbuildsystem/pyarn?branch=master)
# PYarn
If, for some weird reason, you need to parse a Yarn's `yarn.lock` file using
Python, you are in the right place!
PYarn is currently in an early developmente stage. It will create a dict from a
yarn.lock file, given the yarn.lock file is correct as per [its
implementation](https://github.com/yarnpkg/yarn/blob/master/src/lockfile/parse.js).
At this moment, there is no guarantees that PYarn will behave well (e.g., raise
an error) in case a malformed Yarn lockfile is passed to PYarn.
PYarn only supports Yarn v1 lockfiles. Parsing Yarn v2 lockfiles should be
trivial since they are yaml files.
## Development
```
make devel
make check
```
## Usage
The following prints all the content in the `yarn.lock` file:
```
from pyarn import lockfile
my_lockfile = lockfile.Lockfile.from_file(FILE_NAME)
print(my_lockfile.data)
# or
my_lockfile.to_json()
```
`my_lockfile.data` is a `dict` where the top level keys are the top level entries
(i.e., the package names) for the `yarn.lock` file entries.
## Releasing
Before releasing a new version to PyPI, don't forget to bump the version number in
[setup.cfg](./setup.cfg).
Make sure to `git tag` the release commit with the corresponding version and create
a Github release explaining what is new.
Afterwards, releasing to PyPI is quite simple:
```shell
make build
twine check dist/*
twine upload dist/*
```