diff options
| author | BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com> | 2023-05-31 00:27:47 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-29 11:10:39 +0100 |
| commit | 2a3888069fc516f7f1749f7123eef43994248511 (patch) | |
| tree | 60d9bc53119a6bcb6037fdc042f71557ae24b2da /scripts/lib/recipetool/create_npm.py | |
| parent | 55f2e2035035ac52c096018dbb38103c5301082c (diff) | |
| download | poky-2a3888069fc516f7f1749f7123eef43994248511.tar.gz | |
recipetool: create: npm: Remove duplicate function to not have future conflicts
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).
(From OE-Core rev: 18e5438de5389b58c8b6a548d4474128d510a28d)
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/recipetool/create_npm.py')
| -rw-r--r-- | scripts/lib/recipetool/create_npm.py | 14 |
1 files 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 | |||
| 13 | import tempfile | 13 | import tempfile |
| 14 | import bb | 14 | import bb |
| 15 | from bb.fetch2.npm import NpmEnvironment | 15 | from bb.fetch2.npm import NpmEnvironment |
| 16 | from bb.fetch2.npm import npm_package | ||
| 16 | from bb.fetch2.npmsw import foreach_dependencies | 17 | from bb.fetch2.npmsw import foreach_dependencies |
| 17 | from recipetool.create import RecipeHandler | 18 | from recipetool.create import RecipeHandler |
| 18 | from recipetool.create import get_license_md5sums | 19 | from recipetool.create import get_license_md5sums |
| @@ -31,15 +32,6 @@ class NpmRecipeHandler(RecipeHandler): | |||
| 31 | """Class to handle the npm recipe creation""" | 32 | """Class to handle the npm recipe creation""" |
| 32 | 33 | ||
| 33 | @staticmethod | 34 | @staticmethod |
| 34 | def _npm_name(name): | ||
| 35 | """Generate a Yocto friendly npm name""" | ||
| 36 | name = re.sub("/", "-", name) | ||
| 37 | name = name.lower() | ||
| 38 | name = re.sub(r"[^\-a-z0-9]", "", name) | ||
| 39 | name = name.strip("-") | ||
| 40 | return name | ||
| 41 | |||
| 42 | @staticmethod | ||
| 43 | def _get_registry(lines): | 35 | def _get_registry(lines): |
| 44 | """Get the registry value from the 'npm://registry' url""" | 36 | """Get the registry value from the 'npm://registry' url""" |
| 45 | registry = None | 37 | registry = None |
| @@ -143,7 +135,7 @@ class NpmRecipeHandler(RecipeHandler): | |||
| 143 | 135 | ||
| 144 | # Handle the dependencies | 136 | # Handle the dependencies |
| 145 | def _handle_dependency(name, params, deptree): | 137 | def _handle_dependency(name, params, deptree): |
| 146 | suffix = "-".join([self._npm_name(dep) for dep in deptree]) | 138 | suffix = "-".join([npm_package(dep) for dep in deptree]) |
| 147 | destdirs = [os.path.join("node_modules", dep) for dep in deptree] | 139 | destdirs = [os.path.join("node_modules", dep) for dep in deptree] |
| 148 | destdir = os.path.join(*destdirs) | 140 | destdir = os.path.join(*destdirs) |
| 149 | packages["${PN}-" + suffix] = destdir | 141 | packages["${PN}-" + suffix] = destdir |
| @@ -173,7 +165,7 @@ class NpmRecipeHandler(RecipeHandler): | |||
| 173 | if "name" not in data or "version" not in data: | 165 | if "name" not in data or "version" not in data: |
| 174 | return False | 166 | return False |
| 175 | 167 | ||
| 176 | extravalues["PN"] = self._npm_name(data["name"]) | 168 | extravalues["PN"] = npm_package(data["name"]) |
| 177 | extravalues["PV"] = data["version"] | 169 | extravalues["PV"] = data["version"] |
| 178 | 170 | ||
| 179 | if "description" in data: | 171 | if "description" in data: |
