0e27d41
#!/usr/bin/python3
0e27d41
"""
0e27d41
Parse the package-lock.json to populate Provides for the spec
0e27d41
0e27d41
File: parse-deps.py
0e27d41
0e27d41
Copyright 2020 Ankur Sinha
0e27d41
Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com>
0e27d41
"""
0e27d41
0e27d41
0e27d41
import json
0e27d41
0e27d41
0e27d41
with open("package-lock.json", 'r') as f:
0e27d41
    lockfile = json.load(f)
0e27d41
    for depname, depdict in lockfile['dependencies'].items():
0e27d41
        if 'dev' not in depdict:
0e27d41
            print("Provides: bundled(nodejs-{}) = {}".format(
0e27d41
                depname, depdict['version']))
0e27d41
    # Generate package URLs to check license
0e27d41
    for depname, depdict in lockfile['dependencies'].items():
0e27d41
        if 'dev' not in depdict:
0e27d41
            print("https://www.npmjs.com/package/{}".format(depname))