summaryrefslogtreecommitdiffstats
path: root/scripts/lib
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:10:39 +0100
commit2dacac93bccc5c50bde1749f9b3f86a3a953d760 (patch)
tree68e25ffdbae587026fafdf5775cceb888594dff7 /scripts/lib
parentdbc1da2fb89b0560c7a3304b93639685e306c9e3 (diff)
downloadpoky-2dacac93bccc5c50bde1749f9b3f86a3a953d760.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. (From OE-Core rev: f36021a749974ef3d4a6abe4d5429544a815071a) Signed-off-by: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-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):
146 foreach_dependencies(shrinkwrap, _handle_dependency, dev) 146 foreach_dependencies(shrinkwrap, _handle_dependency, dev)
147 147
148 return licfiles, packages 148 return licfiles, packages
149
150 # Handle the peer dependencies
151 def _handle_peer_dependency(self, shrinkwrap_file):
152 """Check if package has peer dependencies and show warning if it is the case"""
153 with open(shrinkwrap_file, "r") as f:
154 shrinkwrap = json.load(f)
155
156 packages = shrinkwrap.get("packages", {})
157 peer_deps = packages.get("", {}).get("peerDependencies", {})
158
159 for peer_dep in peer_deps:
160 peer_dep_yocto_name = npm_package(peer_dep)
161 bb.warn(peer_dep + " is a peer dependencie of the actual package. " +
162 "Please add this peer dependencie to the RDEPENDS variable as %s and generate its recipe with devtool"
163 % peer_dep_yocto_name)
164
165
149 166
150 def process(self, srctree, classes, lines_before, lines_after, handled, extravalues): 167 def process(self, srctree, classes, lines_before, lines_after, handled, extravalues):
151 """Handle the npm recipe creation""" 168 """Handle the npm recipe creation"""
@@ -283,6 +300,9 @@ class NpmRecipeHandler(RecipeHandler):
283 classes.append("npm") 300 classes.append("npm")
284 handled.append("buildsystem") 301 handled.append("buildsystem")
285 302
303 # Check if package has peer dependencies and inform the user
304 self._handle_peer_dependency(shrinkwrap_file)
305
286 return True 306 return True
287 307
288def register_recipe_handlers(handlers): 308def register_recipe_handlers(handlers):