summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorBELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>2023-05-31 00:27:50 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-29 11:07:51 +0100
commitf36021a749974ef3d4a6abe4d5429544a815071a (patch)
treeaa78f4f5e04f0fee577f1a6904a6e61c57af1fed /scripts
parent488d17c2af0c927ec66f0eee124bf6fc5b7f7c95 (diff)
downloadopenembedded-core-f36021a749974ef3d4a6abe4d5429544a815071a.tar.gz
recipetool: create: npm: Add support to handle peer dependencies
NPM changed its manner to handle peer dependencies over its versions. Before NPM 3: NPM installs automatically peer dependencies between NPM 3 and 7: NPM shows a warning about peer dependencies After NPM 3: NPM reworked its manner how to handle peer dependencies The shrinkwrap doesn't have the parameters of the peer dependencies, so we cannot fetch them. in the same time peer dependencies are not direct dependencies, they should be installed as run time dependencies. Signed-off-by: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/recipetool/create_npm.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index 25e7ddb472..113a89f6a6 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -146,6 +146,23 @@ class NpmRecipeHandler(RecipeHandler):
foreach_dependencies(shrinkwrap, _handle_dependency, dev)
return licfiles, packages
+
+ # Handle the peer dependencies
+ def _handle_peer_dependency(self, shrinkwrap_file):
+ """Check if package has peer dependencies and show warning if it is the case"""
+ with open(shrinkwrap_file, "r") as f:
+ shrinkwrap = json.load(f)
+
+ packages = shrinkwrap.get("packages", {})
+ peer_deps = packages.get("", {}).get("peerDependencies", {})
+
+ for peer_dep in peer_deps:
+ peer_dep_yocto_name = npm_package(peer_dep)
+ bb.warn(peer_dep + " is a peer dependencie of the actual package. " +
+ "Please add this peer dependencie to the RDEPENDS variable as %s and generate its recipe with devtool"
+ % peer_dep_yocto_name)
+
+
def process(self, srctree, classes, lines_before, lines_after, handled, extravalues):
"""Handle the npm recipe creation"""
@@ -283,6 +300,9 @@ class NpmRecipeHandler(RecipeHandler):
classes.append("npm")
handled.append("buildsystem")
+ # Check if package has peer dependencies and inform the user
+ self._handle_peer_dependency(shrinkwrap_file)
+
return True
def register_recipe_handlers(handlers):