npm package.json parsing and license requesting
6 unresolved threads
6 unresolved threads
I wrote some lines to parse a package.json and retrieve the license info from the NPM registry.
Unfortunately npm project files are not yet passed to the script, guess I missed some config property somewhere, @mdolling hope you can point me in the right direction.
Merge request reports
Activity
58 60 self.parent.dependencies_per_language["Python"] = deps 59 61 self.parent.errors["Python"] = errors 62 elif "Node" in self.parent.files_per_language: 63 deps, errors = self._get_node_libs() 64 self.parent.dependencies_per_language["Node"] = deps 65 self.parent.errors["Node"] = errors 66 67 def _get_node_libs(self) -> (list, list): 68 """ 69 Parses package.json to get all imports and their versions. 70 71 :return: a list of dictionaries; dictionaries {key, value} represents {import name, import version} 72 """ 73 deps = {} 74 errors = {} 75 std_lib_list = stdlib_list() changed this line in version 5 of the diff
75 std_lib_list = stdlib_list() 76 77 for file_path in self.parent.files_per_language["Node"]: 78 # parse package.json 79 package: Optional[dict] = None 80 81 if file_path.endswith('package.json'): 82 with open(file_path) as file: 83 package = json.load(file) 84 85 # invalid package dict 86 if package is None: 87 errors['package.json'] = {'unable to load package.json'} 88 continue 89 90 # missing dependencies key that would technically be valid. a big js lib i use is reveal.js and they have no dependencies
changed this line in version 6 of the diff
87 errors['package.json'] = {'unable to load package.json'} 88 continue 89 90 # missing dependencies key 91 if 'dependencies' not in package: 92 errors['package.json'] = {"missing 'dependencies' entry"} 93 continue 94 95 # check dependency version for local file and url references 96 for dep, value in package['dependencies'].items(): 97 version: str = value.trim() 98 99 if version.startswith('file') or 'https://' in version or 'http://' in version: 100 # local file or url dependency 101 errors[dep] = {'url/path not supported'} 102 # elif version.startswith('^') or version.startswith('~'): changed this line in version 5 of the diff
57 59 deps, errors = self._get_python_libs() 58 60 self.parent.dependencies_per_language["Python"] = deps 59 61 self.parent.errors["Python"] = errors 62 elif "Node" in self.parent.files_per_language: changed this line in version 5 of the diff
@eggi you can also bumb the version to 0.7.0 =)
@eggi i will switch the MR to merge to dev branch. i will also rebase
added 14 commits
-
799a1e7e...02c7ad31 - 12 commits from branch
dev
- 69241198 - npm package.json parsing and license requesting
- 040b3c23 - Merge branch 'npm-license-check' of...
-
799a1e7e...02c7ad31 - 12 commits from branch
added 15 commits
-
040b3c23...4c2fdc99 - 13 commits from branch
dev
- c8b958f9 - npm package.json parsing and license requesting
- d2479d12 - Merge branch 'npm-license-check' of...
-
040b3c23...4c2fdc99 - 13 commits from branch
see !63 (merged)
mentioned in commit cfb07dbd
Please register or sign in to reply