All of lore.kernel.org
 help / color / mirror / Atom feed
* [master][PATCH 1/6] recipetool: create: npm: Remove duplicate function to not have future conflicts
@ 2023-05-30 22:27 belouargamohamed
  2023-05-30 22:27 ` [master][PATCH 2/6] classes: npm: Handle peer dependencies for npm packages belouargamohamed
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: belouargamohamed @ 2023-05-30 22:27 UTC (permalink / raw)
  To: openembedded-core; +Cc: f.lahoudere, e.aubineau, j.guignard, BELOUARGA Mohamed

From: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>

Npm packages do not have yocto friendly names. fore instance we can have names like
"@example/npmPackage"

npm fetcher has a function that convert these names to yocto friendly names.
But in recipe tool we have an other function (duplicate).

Signed-off-by: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>
---
 scripts/lib/recipetool/create_npm.py | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index 3394a89970..e667a4d19b 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -13,6 +13,7 @@ import sys
 import tempfile
 import bb
 from bb.fetch2.npm import NpmEnvironment
+from bb.fetch2.npm import npm_package
 from bb.fetch2.npmsw import foreach_dependencies
 from recipetool.create import RecipeHandler
 from recipetool.create import get_license_md5sums
@@ -30,15 +31,6 @@ def tinfoil_init(instance):
 class NpmRecipeHandler(RecipeHandler):
     """Class to handle the npm recipe creation"""
 
-    @staticmethod
-    def _npm_name(name):
-        """Generate a Yocto friendly npm name"""
-        name = re.sub("/", "-", name)
-        name = name.lower()
-        name = re.sub(r"[^\-a-z0-9]", "", name)
-        name = name.strip("-")
-        return name
-
     @staticmethod
     def _get_registry(lines):
         """Get the registry value from the 'npm://registry' url"""
@@ -143,7 +135,7 @@ class NpmRecipeHandler(RecipeHandler):
 
         # Handle the dependencies
         def _handle_dependency(name, params, deptree):
-            suffix = "-".join([self._npm_name(dep) for dep in deptree])
+            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
@@ -173,7 +165,7 @@ class NpmRecipeHandler(RecipeHandler):
         if "name" not in data or "version" not in data:
             return False
 
-        extravalues["PN"] = self._npm_name(data["name"])
+        extravalues["PN"] = npm_package(data["name"])
         extravalues["PV"] = data["version"]
 
         if "description" in data:
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-31 18:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 22:27 [master][PATCH 1/6] recipetool: create: npm: Remove duplicate function to not have future conflicts belouargamohamed
2023-05-30 22:27 ` [master][PATCH 2/6] classes: npm: Handle peer dependencies for npm packages belouargamohamed
2023-05-30 22:27 ` [master][PATCH 3/6] recipetool: create: npm: Add support for the new format of the shrinkwrap file belouargamohamed
2023-05-30 22:27 ` [master][PATCH 4/6] recipetool: create: npm: Add support to handle peer dependencies belouargamohamed
2023-05-30 22:27 ` [master][PATCH 5/6] classes: npm: Add support for the new format of the shrinkwrap file belouargamohamed
2023-05-30 22:27 ` [master][PATCH 6/6] classe-recipes: npm: Add support for dependencies and devDependencies belouargamohamed
2023-05-31  6:51 ` [OE-core] [master][PATCH 1/6] recipetool: create: npm: Remove duplicate function to not have future conflicts Alexander Kanavin
2023-05-31 18:54   ` belouargamohamed

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.