]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
recipetool: create: npm: Add support for the new format of the shrinkwrap file
authorBELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>
Tue, 30 May 2023 22:27:49 +0000 (00:27 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 29 Jun 2023 10:07:51 +0000 (11:07 +0100)
The shrinkwrap file changed its format, but npm does not version this file. So we can use it properly.
The actual changes make the script check if the npm package has dependencies in the actual shrinkwrap format.

Signed-off-by: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
scripts/lib/recipetool/create_npm.py

index e667a4d19bab6cc3745f55449f03a4901ed3101b..25e7ddb472cbfb5839c9427aadda40a7033eaf7a 100644 (file)
@@ -134,11 +134,10 @@ class NpmRecipeHandler(RecipeHandler):
                     licfiles.append(os.path.relpath(readme, srctree))
 
         # Handle the dependencies
-        def _handle_dependency(name, params, deptree):
+        def _handle_dependency(name, params, destdir):
+            deptree = destdir.split('node_modules/')
             suffix = "-".join([npm_package(dep) for dep in deptree])
-            destdirs = [os.path.join("node_modules", dep) for dep in deptree]
-            destdir = os.path.join(*destdirs)
-            packages["${PN}-" + suffix] = destdir
+            packages["${PN}" + suffix] = destdir
             _licfiles_append_fallback_readme_files(destdir)
 
         with open(shrinkwrap_file, "r") as f:
@@ -234,7 +233,7 @@ class NpmRecipeHandler(RecipeHandler):
             value = origvalue.replace("version=" + data["version"], "version=${PV}")
             value = value.replace("version=latest", "version=${PV}")
             values = [line.strip() for line in value.strip('\n').splitlines()]
-            if "dependencies" in shrinkwrap:
+            if "dependencies" in shrinkwrap.get("packages", {}).get("", {}):
                 values.append(url_recipe)
             return values, None, 4, False