#16 Drop detection of only bundled libraries
Opened 3 years ago by sgallagh. Modified 3 years ago
sgallagh/nodejs-packaging bundle_detection  into  master

file modified
-36
@@ -610,39 +610,6 @@ 

          return requirement

  

  

- def has_only_bundled_dependencies(module_dir_path):

-     """Determines if the module contains only bundled dependencies.

- 

-     Dependencies are considered un-bundled when they are symlinks

-     pointing outside the root module's tree.

- 

-     Arguments:

-         module_dir_path (str):

-             Path to the module directory (directory with ``package.json``).

- 

-     Returns:

-         bool: True if all dependencies are bundled, False otherwise.

-     """

- 

-     module_root_path = os.path.abspath(module_dir_path)

-     dependency_root_path = os.path.join(module_root_path, "node_modules")

- 

-     try:

-         dependency_path_iter = (

-             os.path.join(dependency_root_path, basename)

-             for basename in os.listdir(dependency_root_path)

-         )

-         bundled_dependency_iter = (

-             os.path.realpath(path)

-             for path in dependency_path_iter

-             if not os.path.islink(path) or not path.startswith(module_root_path)

-         )

- 

-         return any(bundled_dependency_iter)

-     except OSError:  # node_modules does not exist

-         return False

- 

- 

  def extract_dependencies(metadata_path, optional=False):

      """Extract all dependencies in RPM format from package metadata.

  
@@ -659,9 +626,6 @@ 

          TypeError: Invalid dependency data type.

      """

  

-     if has_only_bundled_dependencies(os.path.dirname(metadata_path)):

-         return  # skip

- 

      # Read metadata

      try:

          with open(metadata_path, mode="r") as metadata_file:

This will ensure that the nodejs(engine) dependency is always added,
along with any Suggests: optionalDependencies.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

rebased onto c83f06c

3 years ago

Seems reasonable to me.

What about the other things which happen after that, like processing optional dependencies? Do we not need to do that for packages with no dependencies?

@tomh Yeah, that's a good point. I honestly can't think of any reason for this function to even exist.

I'll update the patch.

rebased onto c130ab1

3 years ago

Looks like that was indeed suppressing the optionalDependencies. I don't see any reason for this at all, so I just pushed a new version that removes it entirely.

Actually there is a very good reason for it - with that removed we will generate requires for dependencies which have been bundled because the dependencies are generated from package.json without considering if the modules are link or not.

It's not that much better with that though - then it can only handle either "all bundled" or "all unbundled" packages, which would have broken if we had tried to leave clone unbundled from less.

Metadata