* [PATCH v2 0/2] devtool/recipetool: allow installation of devDependencies
@ 2017-03-13 10:01 Anders Darander
2017-03-13 10:01 ` [PATCH v2 1/2] devtool/recipetill: npm install " Anders Darander
2017-03-13 10:01 ` [PATCH v2 2/2] classes/npm: allow installation " Anders Darander
0 siblings, 2 replies; 3+ messages in thread
From: Anders Darander @ 2017-03-13 10:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Anders Darander
This allows the conditional addition of devDependencies to DEPENDS, as well asi
installation to the recipes WORKDIR.
changes from v1:
* A number of patches was merged.
* Make the addition of devDependencies from package.json optional in create_npm.py
from recipetool.
The following changes since commit a47e64d985a610535449730806651f5bfd75d9ec:
libcomps: add a recipe (2017-03-11 16:08:50 +0000)
are available in the git repository at:
git://github.com/darander/openembedded-core npm
https://github.com/darander/openembedded-core/tree/npm
Anders Darander (2):
devtool/recipetill: npm install of devDependencies
classes/npm: allow installation of devDependencies
meta/classes/npm.bbclass | 13 +++++++++++--
scripts/lib/devtool/standard.py | 3 +++
scripts/lib/recipetool/create.py | 6 ++++++
scripts/lib/recipetool/create_npm.py | 23 ++++++++++++++++++-----
4 files changed, 38 insertions(+), 7 deletions(-)
--
2.10.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] devtool/recipetill: npm install of devDependencies
2017-03-13 10:01 [PATCH v2 0/2] devtool/recipetool: allow installation of devDependencies Anders Darander
@ 2017-03-13 10:01 ` Anders Darander
2017-03-13 10:01 ` [PATCH v2 2/2] classes/npm: allow installation " Anders Darander
1 sibling, 0 replies; 3+ messages in thread
From: Anders Darander @ 2017-03-13 10:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Anders Darander
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.
Signed-off-by: Anders Darander <anders@chargestorm.se>
---
scripts/lib/devtool/standard.py | 3 +++
scripts/lib/recipetool/create.py | 6 ++++++
scripts/lib/recipetool/create_npm.py | 23 ++++++++++++++++++-----
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 5bd498c..07c1400 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -150,6 +150,8 @@ def add(args, config, basepath, workspace):
extracmdopts += ' --src-subdir "%s"' % args.src_subdir
if args.autorev:
extracmdopts += ' -a'
+ if args.fetch_dev:
+ extracmdopts += ' --fetch-dev'
tempdir = tempfile.mkdtemp(prefix='devtool')
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('--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-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('--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")
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 1be3f14..648f2d6 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -599,6 +599,11 @@ def create_recipe(args):
lines_after.append('INSANE_SKIP_${PN} += "already-stripped"')
lines_after.append('')
+ if args.fetch_dev:
+ extravalues['fetchdev'] = True
+ else:
+ extravalues['fetchdev'] = None
+
# Find all plugins that want to register handlers
logger.debug('Loading recipe 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('-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('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies')
parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)
parser_create.set_defaults(func=create_recipe)
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index 158029f..a215026 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -101,7 +101,7 @@ class NpmRecipeHandler(RecipeHandler):
extravalues['extrafiles']['lockdown.json'] = tmpfile
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
# If this isn't a single module we need to get the dependencies
# and add them to SRC_URI
@@ -115,6 +115,10 @@ class NpmRecipeHandler(RecipeHandler):
depdata = self.get_npm_data(dep, depver, d)
if self.check_npm_optional_dependency(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():
depdata = self.get_npm_data(dep, depver, d)
deplist[dep] = depdata
@@ -197,8 +201,9 @@ class NpmRecipeHandler(RecipeHandler):
if 'homepage' in data:
extravalues['HOMEPAGE'] = data['homepage']
- deps, optdeps = self.get_npm_package_dependencies(data)
- updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, lines_before, srctree)
+ fetchdev = extravalues['fetchdev'] or None
+ 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:
# We need to redo the license stuff
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
# (split out from _getdependencies())
- def get_npm_package_dependencies(self, pdata):
+ def get_npm_package_dependencies(self, pdata, fetchdev):
dependencies = pdata.get('dependencies', {})
optionalDependencies = pdata.get('optionalDependencies', {})
dependencies.update(optionalDependencies)
+ if fetchdev:
+ devDependencies = pdata.get('devDependencies', {})
+ dependencies.update(devDependencies)
+ else:
+ devDependencies = {}
depsfound = {}
optdepsfound = {}
+ devdepsfound = {}
for dep in dependencies:
if dep in optionalDependencies:
optdepsfound[dep] = dependencies[dep]
+ elif dep in devDependencies:
+ devdepsfound[dep] = dependencies[dep]
else:
depsfound[dep] = dependencies[dep]
- return depsfound, optdepsfound
+ return depsfound, optdepsfound, devdepsfound
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
# (split out from _getdependencies())
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] classes/npm: allow installation of devDependencies
2017-03-13 10:01 [PATCH v2 0/2] devtool/recipetool: allow installation of devDependencies Anders Darander
2017-03-13 10:01 ` [PATCH v2 1/2] devtool/recipetill: npm install " Anders Darander
@ 2017-03-13 10:01 ` Anders Darander
1 sibling, 0 replies; 3+ messages in thread
From: Anders Darander @ 2017-03-13 10:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Anders Darander
Often, eg when using angular2, there's a need to install also
the devDependencies.
The default is to keep the old behaviour, to not install
devDependencies.
Signed-off-by: Anders Darander <anders@chargestorm.se>
---
meta/classes/npm.bbclass | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass
index c538040..a69bedb 100644
--- a/meta/classes/npm.bbclass
+++ b/meta/classes/npm.bbclass
@@ -14,6 +14,7 @@ def npm_oe_arch_map(target_arch, d):
return target_arch
NPM_ARCH ?= "${@npm_oe_arch_map(d.getVar('TARGET_ARCH'), d)}"
+NPM_INSTALL_DEV = "0"
npm_do_compile() {
# Copy in any additionally fetched modules
@@ -23,12 +24,20 @@ npm_do_compile() {
# changing the home directory to the working directory, the .npmrc will
# be created in this directory
export HOME=${WORKDIR}
- npm config set dev false
+ if [ "${NPM_INSTALL_DEV}" = "1" ]; then
+ npm config set dev true
+ else
+ npm config set dev false
+ fi
npm set cache ${WORKDIR}/npm_cache
# clear cache before every build
npm cache clear
# Install pkg into ${S} without going to the registry
- npm --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry install
+ if [ "${NPM_INSTALL_DEV}" = "1" ]; then
+ npm --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --no-registry install
+ else
+ npm --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry install
+ fi
}
npm_do_install() {
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-13 10:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 10:01 [PATCH v2 0/2] devtool/recipetool: allow installation of devDependencies Anders Darander
2017-03-13 10:01 ` [PATCH v2 1/2] devtool/recipetill: npm install " Anders Darander
2017-03-13 10:01 ` [PATCH v2 2/2] classes/npm: allow installation " Anders Darander
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.