]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
npm: accept unspecified versions in package.json
authorEnguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Mon, 12 Aug 2024 12:28:26 +0000 (14:28 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 23 Aug 2024 08:49:13 +0000 (09:49 +0100)
Our current emulation mandates that the package.json contains a version
field. Some packages may not provide it when they are not published to
the registry. The actual `npm pack` would allow such packages, so
should we.

This patch adds a default value to allow building such packages.

This applies for instance to this package which doesn't declare a
version:
 - https://github.com/cockpit-project/cockpit/blob/23701a555a5af13f998ee4c7526d27fdb5669d63/package.json#L2

v3:
 - Split bitbake npmsw.py modification in another commit

Co-authored-by: Tanguy Raufflet <tanguy.raufflet@savoirfairelinux.com>
Signed-off-by: Tanguy Raufflet <tanguy.raufflet@savoirfairelinux.com>
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/npm.bbclass

index 91da3295f2f5d7ba23a179ce8e676b8567cbbf3e..a73ff29be894ea7dacce3b89ec0579932b30f1a4 100644 (file)
@@ -72,8 +72,10 @@ def npm_pack(env, srcdir, workdir):
         j = json.load(f)
 
     # base does not really matter and is for documentation purposes
-    # only.  But the 'version' part must exist because other parts of
+    # only. But the 'version' part must exist because other parts of
     # the bbclass rely on it.
+    if 'version' not in j:
+        j['version'] = '0.0.0-unknown'
     base = j['name'].split('/')[-1]
     tarball = os.path.join(workdir, "%s-%s.tgz" % (base, j['version']));