summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-recipe/npm.bbclass27
1 files changed, 6 insertions, 21 deletions
diff --git a/meta/classes-recipe/npm.bbclass b/meta/classes-recipe/npm.bbclass
index 92e59fefce..c1944ca14e 100644
--- a/meta/classes-recipe/npm.bbclass
+++ b/meta/classes-recipe/npm.bbclass
@@ -130,22 +130,6 @@ python npm_do_configure() {
130 sha512 = bb.utils.sha512_file(tarball) 130 sha512 = bb.utils.sha512_file(tarball)
131 return "sha512-" + base64.b64encode(bytes.fromhex(sha512)).decode() 131 return "sha512-" + base64.b64encode(bytes.fromhex(sha512)).decode()
132 132
133 def _npmsw_dependency_dict(orig, deptree):
134 """
135 Return the sub dictionary in the 'orig' dictionary corresponding to the
136 'deptree' dependency tree. This function follows the shrinkwrap file
137 format.
138 """
139 ptr = orig
140 for dep in deptree:
141 if "dependencies" not in ptr:
142 ptr["dependencies"] = {}
143 ptr = ptr["dependencies"]
144 if dep not in ptr:
145 ptr[dep] = {}
146 ptr = ptr[dep]
147 return ptr
148
149 # Manage the manifest file and shrinkwrap files 133 # Manage the manifest file and shrinkwrap files
150 orig_manifest_file = d.expand("${S}/package.json") 134 orig_manifest_file = d.expand("${S}/package.json")
151 orig_shrinkwrap_file = d.expand("${S}/npm-shrinkwrap.json") 135 orig_shrinkwrap_file = d.expand("${S}/npm-shrinkwrap.json")
@@ -177,24 +161,25 @@ python npm_do_configure() {
177 progress_total = 1 # also count the main package 161 progress_total = 1 # also count the main package
178 progress_done = 0 162 progress_done = 0
179 163
180 def _count_dependency(name, params, deptree): 164 def _count_dependency(name, params, destsuffix):
181 nonlocal progress_total 165 nonlocal progress_total
182 progress_total += 1 166 progress_total += 1
183 167
184 def _cache_dependency(name, params, deptree): 168 def _cache_dependency(name, params, destsuffix):
185 destsubdirs = [os.path.join("node_modules", dep) for dep in deptree]
186 destsuffix = os.path.join(*destsubdirs)
187 with tempfile.TemporaryDirectory() as tmpdir: 169 with tempfile.TemporaryDirectory() as tmpdir:
188 # Add the dependency to the npm cache 170 # Add the dependency to the npm cache
189 destdir = os.path.join(d.getVar("S"), destsuffix) 171 destdir = os.path.join(d.getVar("S"), destsuffix)
190 (tarball, pkg) = npm_pack(env, destdir, tmpdir) 172 (tarball, pkg) = npm_pack(env, destdir, tmpdir)
191 _npm_cache_add(tarball, pkg) 173 _npm_cache_add(tarball, pkg)
192 # Add its signature to the cached shrinkwrap 174 # Add its signature to the cached shrinkwrap
193 dep = _npmsw_dependency_dict(cached_shrinkwrap, deptree) 175 dep = params
194 dep["version"] = pkg['version'] 176 dep["version"] = pkg['version']
195 dep["integrity"] = _npm_integrity(tarball) 177 dep["integrity"] = _npm_integrity(tarball)
196 if params.get("dev", False): 178 if params.get("dev", False):
197 dep["dev"] = True 179 dep["dev"] = True
180 if "dependencies" not in cached_shrinkwrap:
181 cached_shrinkwrap["dependencies"] = {}
182 cached_shrinkwrap["dependencies"][name] = dep
198 # Display progress 183 # Display progress
199 nonlocal progress_done 184 nonlocal progress_done
200 progress_done += 1 185 progress_done += 1