2525from packagedcode .utils import yield_dependencies_from_package_data
2626from packagedcode .utils import yield_dependencies_from_package_resource
2727from packagedcode .utils import update_dependencies_as_resolved
28+ from packagedcode .utils import is_path_pattern
29+ from packagedcode .utils import is_simple_path_pattern
2830import saneyaml
2931
3032"""
@@ -299,8 +301,7 @@ def get_workspace_members(cls, workspaces, codebase, workspace_root_path):
299301 for workspace_path in workspaces :
300302
301303 # Case 1: A definite path, instead of a pattern (only one package.json)
302- if '*' not in workspace_path :
303-
304+ if is_path_pattern (workspace_path ):
304305 workspace_dir_path = os .path .join (workspace_root_path , workspace_path )
305306 workspace_member_path = os .path .join (workspace_dir_path , 'package.json' )
306307 workspace_member = codebase .get_resource (path = workspace_member_path )
@@ -310,8 +311,8 @@ def get_workspace_members(cls, workspaces, codebase, workspace_root_path):
310311 # Case 2: we have glob path which is a directory, relative to the workspace root
311312 # Here we have only one * at the last (This is an optimization, this is a very
312313 # commonly encountered subcase of case 3)
313- elif '*' == workspace_path [ - 1 ] and '*' not in workspace_path . replace ( '*' , '' ):
314- workspace_pattern_prefix = workspace_path .replace ('*' , ' ' )
314+ elif is_simple_path_pattern ( workspace_path ):
315+ workspace_pattern_prefix = workspace_path .rstrip ('*' )
315316 workspace_dir_path = os .path .join (workspace_root_path , workspace_pattern_prefix )
316317 workspace_search_dir = codebase .get_resource (path = workspace_dir_path )
317318 if not workspace_search_dir :
@@ -785,7 +786,8 @@ def parse(cls, location, package_only=False):
785786 version = version ,
786787 )
787788
788- # TODO: what type of checksum is this?
789+ # TODO: what type of checksum is this? ... this is a complex one
790+ # See https://github.com/yarnpkg/berry/blob/f1edfae49d1bab7679ce3061e2749113dc3b80e8/packages/yarnpkg-core/sources/tgzUtils.ts
789791 checksum = details .get ('checksum' )
790792 dependencies = details .get ('dependencies' ) or {}
791793 peer_dependencies = details .get ('peerDependencies' ) or {}
@@ -826,12 +828,16 @@ def parse(cls, location, package_only=False):
826828 is_virtual = True ,
827829 )
828830 resolved_package = models .PackageData .from_data (resolved_package_mapping )
831+
832+ # These are top level dependencies which do not have a
833+ # scope defined there, so we are assigning the default
834+ # scope, this would be merged with the dependency having
835+ # correct scope value when resolved
829836 dependency = models .DependentPackage (
830837 purl = str (purl ),
831838 extracted_requirement = version ,
832839 is_resolved = True ,
833840 resolved_package = resolved_package .to_dict (),
834- # FIXME: these are NOT correct
835841 scope = 'dependencies' ,
836842 is_optional = False ,
837843 is_runtime = True ,
@@ -1008,7 +1014,8 @@ def parse(cls, location, package_only=False):
10081014 if not dep_purl in dependencies_by_purl :
10091015 dependencies_by_purl [dep_purl ] = dep .to_dict ()
10101016 else :
1011- # We have duplicate dependencies because of aliases
1017+ # FIXME: We have duplicate dependencies because of aliases
1018+ # should we do something?
10121019 pass
10131020
10141021 dependencies = list (dependencies_by_purl .values ())
0 commit comments