25
25
from packagedcode .utils import yield_dependencies_from_package_data
26
26
from packagedcode .utils import yield_dependencies_from_package_resource
27
27
from packagedcode .utils import update_dependencies_as_resolved
28
+ from packagedcode .utils import is_path_pattern
29
+ from packagedcode .utils import is_simple_path_pattern
28
30
import saneyaml
29
31
30
32
"""
@@ -299,8 +301,7 @@ def get_workspace_members(cls, workspaces, codebase, workspace_root_path):
299
301
for workspace_path in workspaces :
300
302
301
303
# 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 ):
304
305
workspace_dir_path = os .path .join (workspace_root_path , workspace_path )
305
306
workspace_member_path = os .path .join (workspace_dir_path , 'package.json' )
306
307
workspace_member = codebase .get_resource (path = workspace_member_path )
@@ -310,8 +311,8 @@ def get_workspace_members(cls, workspaces, codebase, workspace_root_path):
310
311
# Case 2: we have glob path which is a directory, relative to the workspace root
311
312
# Here we have only one * at the last (This is an optimization, this is a very
312
313
# 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 ('*' )
315
316
workspace_dir_path = os .path .join (workspace_root_path , workspace_pattern_prefix )
316
317
workspace_search_dir = codebase .get_resource (path = workspace_dir_path )
317
318
if not workspace_search_dir :
@@ -785,7 +786,8 @@ def parse(cls, location, package_only=False):
785
786
version = version ,
786
787
)
787
788
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
789
791
checksum = details .get ('checksum' )
790
792
dependencies = details .get ('dependencies' ) or {}
791
793
peer_dependencies = details .get ('peerDependencies' ) or {}
@@ -826,12 +828,16 @@ def parse(cls, location, package_only=False):
826
828
is_virtual = True ,
827
829
)
828
830
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
829
836
dependency = models .DependentPackage (
830
837
purl = str (purl ),
831
838
extracted_requirement = version ,
832
839
is_resolved = True ,
833
840
resolved_package = resolved_package .to_dict (),
834
- # FIXME: these are NOT correct
835
841
scope = 'dependencies' ,
836
842
is_optional = False ,
837
843
is_runtime = True ,
@@ -1008,7 +1014,8 @@ def parse(cls, location, package_only=False):
1008
1014
if not dep_purl in dependencies_by_purl :
1009
1015
dependencies_by_purl [dep_purl ] = dep .to_dict ()
1010
1016
else :
1011
- # We have duplicate dependencies because of aliases
1017
+ # FIXME: We have duplicate dependencies because of aliases
1018
+ # should we do something?
1012
1019
pass
1013
1020
1014
1021
dependencies = list (dependencies_by_purl .values ())
0 commit comments