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>
This commit is contained in:
parent
2b52d7ebc0
commit
6fa0fda116
|
@ -150,6 +150,8 @@ def add(args, config, basepath, workspace):
|
||||||
extracmdopts += ' --src-subdir "%s"' % args.src_subdir
|
extracmdopts += ' --src-subdir "%s"' % args.src_subdir
|
||||||
if args.autorev:
|
if args.autorev:
|
||||||
extracmdopts += ' -a'
|
extracmdopts += ' -a'
|
||||||
|
if args.fetch_dev:
|
||||||
|
extracmdopts += ' --fetch-dev'
|
||||||
|
|
||||||
tempdir = tempfile.mkdtemp(prefix='devtool')
|
tempdir = tempfile.mkdtemp(prefix='devtool')
|
||||||
try:
|
try:
|
||||||
|
@ -1823,6 +1825,7 @@ def register_commands(subparsers, context):
|
||||||
group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true")
|
group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true")
|
||||||
group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true")
|
group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true")
|
||||||
parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree (deprecated - pass as positional argument instead)', metavar='URI')
|
parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree (deprecated - pass as positional argument instead)', metavar='URI')
|
||||||
|
parser_add.add_argument('--fetch-dev', help='For npm, also fetch devDependencies', action="store_true")
|
||||||
parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
|
parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
|
||||||
parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true")
|
parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true")
|
||||||
parser_add.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
|
parser_add.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
|
||||||
|
|
|
@ -599,6 +599,11 @@ def create_recipe(args):
|
||||||
lines_after.append('INSANE_SKIP_${PN} += "already-stripped"')
|
lines_after.append('INSANE_SKIP_${PN} += "already-stripped"')
|
||||||
lines_after.append('')
|
lines_after.append('')
|
||||||
|
|
||||||
|
if args.fetch_dev:
|
||||||
|
extravalues['fetchdev'] = True
|
||||||
|
else:
|
||||||
|
extravalues['fetchdev'] = None
|
||||||
|
|
||||||
# Find all plugins that want to register handlers
|
# Find all plugins that want to register handlers
|
||||||
logger.debug('Loading recipe handlers')
|
logger.debug('Loading recipe handlers')
|
||||||
raw_handlers = []
|
raw_handlers = []
|
||||||
|
@ -1134,6 +1139,7 @@ def register_commands(subparsers):
|
||||||
parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
|
parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
|
||||||
parser_create.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
|
parser_create.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
|
||||||
parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)')
|
parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)')
|
||||||
|
parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies')
|
||||||
parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)
|
parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)
|
||||||
parser_create.set_defaults(func=create_recipe)
|
parser_create.set_defaults(func=create_recipe)
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ class NpmRecipeHandler(RecipeHandler):
|
||||||
extravalues['extrafiles']['lockdown.json'] = tmpfile
|
extravalues['extrafiles']['lockdown.json'] = tmpfile
|
||||||
lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"')
|
lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"')
|
||||||
|
|
||||||
def _handle_dependencies(self, d, deps, optdeps, lines_before, srctree):
|
def _handle_dependencies(self, d, deps, optdeps, devdeps, lines_before, srctree):
|
||||||
import scriptutils
|
import scriptutils
|
||||||
# If this isn't a single module we need to get the dependencies
|
# If this isn't a single module we need to get the dependencies
|
||||||
# and add them to SRC_URI
|
# and add them to SRC_URI
|
||||||
|
@ -115,6 +115,10 @@ class NpmRecipeHandler(RecipeHandler):
|
||||||
depdata = self.get_npm_data(dep, depver, d)
|
depdata = self.get_npm_data(dep, depver, d)
|
||||||
if self.check_npm_optional_dependency(depdata):
|
if self.check_npm_optional_dependency(depdata):
|
||||||
deplist[dep] = depdata
|
deplist[dep] = depdata
|
||||||
|
for dep, depver in devdeps.items():
|
||||||
|
depdata = self.get_npm_data(dep, depver, d)
|
||||||
|
if self.check_npm_optional_dependency(depdata):
|
||||||
|
deplist[dep] = depdata
|
||||||
for dep, depver in deps.items():
|
for dep, depver in deps.items():
|
||||||
depdata = self.get_npm_data(dep, depver, d)
|
depdata = self.get_npm_data(dep, depver, d)
|
||||||
deplist[dep] = depdata
|
deplist[dep] = depdata
|
||||||
|
@ -197,8 +201,9 @@ class NpmRecipeHandler(RecipeHandler):
|
||||||
if 'homepage' in data:
|
if 'homepage' in data:
|
||||||
extravalues['HOMEPAGE'] = data['homepage']
|
extravalues['HOMEPAGE'] = data['homepage']
|
||||||
|
|
||||||
deps, optdeps = self.get_npm_package_dependencies(data)
|
fetchdev = extravalues['fetchdev'] or None
|
||||||
updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, lines_before, srctree)
|
deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev)
|
||||||
|
updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, devdeps, lines_before, srctree)
|
||||||
if updated:
|
if updated:
|
||||||
# We need to redo the license stuff
|
# We need to redo the license stuff
|
||||||
self._replace_license_vars(srctree, lines_before, handled, extravalues, tinfoil.config_data)
|
self._replace_license_vars(srctree, lines_before, handled, extravalues, tinfoil.config_data)
|
||||||
|
@ -293,18 +298,26 @@ class NpmRecipeHandler(RecipeHandler):
|
||||||
|
|
||||||
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
|
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
|
||||||
# (split out from _getdependencies())
|
# (split out from _getdependencies())
|
||||||
def get_npm_package_dependencies(self, pdata):
|
def get_npm_package_dependencies(self, pdata, fetchdev):
|
||||||
dependencies = pdata.get('dependencies', {})
|
dependencies = pdata.get('dependencies', {})
|
||||||
optionalDependencies = pdata.get('optionalDependencies', {})
|
optionalDependencies = pdata.get('optionalDependencies', {})
|
||||||
dependencies.update(optionalDependencies)
|
dependencies.update(optionalDependencies)
|
||||||
|
if fetchdev:
|
||||||
|
devDependencies = pdata.get('devDependencies', {})
|
||||||
|
dependencies.update(devDependencies)
|
||||||
|
else:
|
||||||
|
devDependencies = {}
|
||||||
depsfound = {}
|
depsfound = {}
|
||||||
optdepsfound = {}
|
optdepsfound = {}
|
||||||
|
devdepsfound = {}
|
||||||
for dep in dependencies:
|
for dep in dependencies:
|
||||||
if dep in optionalDependencies:
|
if dep in optionalDependencies:
|
||||||
optdepsfound[dep] = dependencies[dep]
|
optdepsfound[dep] = dependencies[dep]
|
||||||
|
elif dep in devDependencies:
|
||||||
|
devdepsfound[dep] = dependencies[dep]
|
||||||
else:
|
else:
|
||||||
depsfound[dep] = dependencies[dep]
|
depsfound[dep] = dependencies[dep]
|
||||||
return depsfound, optdepsfound
|
return depsfound, optdepsfound, devdepsfound
|
||||||
|
|
||||||
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
|
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
|
||||||
# (split out from _getdependencies())
|
# (split out from _getdependencies())
|
||||||
|
|
Loading…
Reference in New Issue