From: BELOUARGA Mohamed Date: Tue, 30 May 2023 22:27:49 +0000 (+0200) Subject: recipetool: create: npm: Add support for the new format of the shrinkwrap file X-Git-Tag: lucaceresoli/bug-15201-perf-libtraceevent-missing~461 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=488d17c2af0c927ec66f0eee124bf6fc5b7f7c95;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git recipetool: create: npm: Add support for the new format of the shrinkwrap file 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 Signed-off-by: Alexandre Belloni --- diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index e667a4d19ba..25e7ddb472c 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -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