summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create_npm.py
diff options
context:
space:
mode:
authorAnders Darander <anders@chargestorm.se>2017-03-13 11:01:52 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-22 11:35:20 +0000
commit6fa0fda1165f05adc9d971a8c873dbbd4ba18d6a (patch)
tree2980ee319648c05dbe042860d007b1da23dbd342 /scripts/lib/recipetool/create_npm.py
parent2b52d7ebc0a1dea68bfad8dcb048778ab00c631d (diff)
downloadpoky-6fa0fda1165f05adc9d971a8c873dbbd4ba18d6a.tar.gz
devtool/recipetill: npm install of devDependencies
Web applications built using e.g. angular2, usually requires that the packages in devDependencies are available. Thus, add an option '--fetch-dev' to both devtool add and recipetool, to add npm packages in devDependencies to DEPENDS. (From OE-Core rev: f246f820d53b459596fde6758a09f7a0d7db7c4c) Signed-off-by: Anders Darander <anders@chargestorm.se> Signed-off-by: Ross Burton <ross.burton@intel.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.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index 158029fa04..a21502679e 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -101,7 +101,7 @@ class NpmRecipeHandler(RecipeHandler):
101 extravalues['extrafiles']['lockdown.json'] = tmpfile 101 extravalues['extrafiles']['lockdown.json'] = tmpfile
102 lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"') 102 lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"')
103 103
104 def _handle_dependencies(self, d, deps, optdeps, lines_before, srctree): 104 def _handle_dependencies(self, d, deps, optdeps, devdeps, lines_before, srctree):
105 import scriptutils 105 import scriptutils
106 # If this isn't a single module we need to get the dependencies 106 # If this isn't a single module we need to get the dependencies
107 # and add them to SRC_URI 107 # and add them to SRC_URI
@@ -115,6 +115,10 @@ class NpmRecipeHandler(RecipeHandler):
115 depdata = self.get_npm_data(dep, depver, d) 115 depdata = self.get_npm_data(dep, depver, d)
116 if self.check_npm_optional_dependency(depdata): 116 if self.check_npm_optional_dependency(depdata):
117 deplist[dep] = depdata 117 deplist[dep] = depdata
118 for dep, depver in devdeps.items():
119 depdata = self.get_npm_data(dep, depver, d)
120 if self.check_npm_optional_dependency(depdata):
121 deplist[dep] = depdata
118 for dep, depver in deps.items(): 122 for dep, depver in deps.items():
119 depdata = self.get_npm_data(dep, depver, d) 123 depdata = self.get_npm_data(dep, depver, d)
120 deplist[dep] = depdata 124 deplist[dep] = depdata
@@ -197,8 +201,9 @@ class NpmRecipeHandler(RecipeHandler):
197 if 'homepage' in data: 201 if 'homepage' in data:
198 extravalues['HOMEPAGE'] = data['homepage'] 202 extravalues['HOMEPAGE'] = data['homepage']
199 203
200 deps, optdeps = self.get_npm_package_dependencies(data) 204 fetchdev = extravalues['fetchdev'] or None
201 updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, lines_before, srctree) 205 deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev)
206 updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, devdeps, lines_before, srctree)
202 if updated: 207 if updated:
203 # We need to redo the license stuff 208 # We need to redo the license stuff
204 self._replace_license_vars(srctree, lines_before, handled, extravalues, tinfoil.config_data) 209 self._replace_license_vars(srctree, lines_before, handled, extravalues, tinfoil.config_data)
@@ -293,18 +298,26 @@ class NpmRecipeHandler(RecipeHandler):
293 298
294 # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py 299 # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
295 # (split out from _getdependencies()) 300 # (split out from _getdependencies())
296 def get_npm_package_dependencies(self, pdata): 301 def get_npm_package_dependencies(self, pdata, fetchdev):
297 dependencies = pdata.get('dependencies', {}) 302 dependencies = pdata.get('dependencies', {})
298 optionalDependencies = pdata.get('optionalDependencies', {}) 303 optionalDependencies = pdata.get('optionalDependencies', {})
299 dependencies.update(optionalDependencies) 304 dependencies.update(optionalDependencies)
305 if fetchdev:
306 devDependencies = pdata.get('devDependencies', {})
307 dependencies.update(devDependencies)
308 else:
309 devDependencies = {}
300 depsfound = {} 310 depsfound = {}
301 optdepsfound = {} 311 optdepsfound = {}
312 devdepsfound = {}
302 for dep in dependencies: 313 for dep in dependencies:
303 if dep in optionalDependencies: 314 if dep in optionalDependencies:
304 optdepsfound[dep] = dependencies[dep] 315 optdepsfound[dep] = dependencies[dep]
316 elif dep in devDependencies:
317 devdepsfound[dep] = dependencies[dep]
305 else: 318 else:
306 depsfound[dep] = dependencies[dep] 319 depsfound[dep] = dependencies[dep]
307 return depsfound, optdepsfound 320 return depsfound, optdepsfound, devdepsfound
308 321
309 # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py 322 # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
310 # (split out from _getdependencies()) 323 # (split out from _getdependencies())