bower2bazel: don't specify versions for non-seed packages.
The 'seed' packages are the ones whose versions are set by us in WORKSPACE. We should not set the versions for the rest of the packages in the bower input JSON, so bower can suggest the right versions to use. Change-Id: I9b75f16655d049e2064726862980a339c91dd534
This commit is contained in:
parent
a461a3d45a
commit
3dede1653a
@ -2,9 +2,11 @@ package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("//tools/bzl:js.bzl", "bower_component", "js_component")
|
||||
|
||||
# For updating the bower versions, run
|
||||
# For importing new versions of existing bower packages,
|
||||
#
|
||||
# python tools/js/bower2bazel.py -w lib/js/bower_archives.bzl -b lib/js/bower_components.bzl
|
||||
# 1) edit the versions of 'seed' components in WORKSPACE as desired
|
||||
#
|
||||
# 2) Run: 'python tools/js/bower2bazel.py -w lib/js/bower_archives.bzl -b lib/js/bower_components.bzl', to update dependency versions.
|
||||
#
|
||||
|
||||
# For adding a new component as dependency to a bower_component_bundle
|
||||
|
@ -268,6 +268,15 @@ bower_component_bundle = rule(
|
||||
"version_json": "%{name}-versions.json",
|
||||
},
|
||||
)
|
||||
"""Groups a set of bower components together in a zip file.
|
||||
|
||||
Outputs:
|
||||
NAME-versions.json:
|
||||
a JSON file containing a PKG-NAME => PKG-NAME#VERSION mapping for the
|
||||
transitive dependencies.
|
||||
NAME.zip:
|
||||
a zip file containing the transitive dependencies for this bundle.
|
||||
"""
|
||||
|
||||
def _vulcanize_impl(ctx):
|
||||
# intermediate artifact.
|
||||
|
@ -59,15 +59,22 @@ package_licenses = {
|
||||
}
|
||||
|
||||
|
||||
def build_bower_json(version_targets):
|
||||
"""Generate bower JSON file, return its path."""
|
||||
def build_bower_json(version_targets, seeds):
|
||||
"""Generate bower JSON file, return its path.
|
||||
|
||||
Args:
|
||||
version_targets: bazel target names of the versions.json file.
|
||||
seeds: an iterable of bower package names of the seed packages, ie.
|
||||
the packages whose versions we control manually.
|
||||
"""
|
||||
bower_json = collections.OrderedDict()
|
||||
bower_json['name'] = 'bower2buck-output'
|
||||
bower_json['name'] = 'bower2bazel-output'
|
||||
bower_json['version'] = '0.0.0'
|
||||
bower_json['description'] = 'Auto-generated bower.json for dependency management'
|
||||
bower_json['private'] = True
|
||||
bower_json['dependencies'] = {}
|
||||
|
||||
seeds = set(seeds)
|
||||
for v in version_targets:
|
||||
fn = os.path.join("bazel-out/local-fastbuild/bin", v.lstrip("/").replace(":", "/"))
|
||||
with open(fn) as f:
|
||||
@ -75,7 +82,13 @@ def build_bower_json(version_targets):
|
||||
if "" in j:
|
||||
# drop dummy entries.
|
||||
del j[""]
|
||||
bower_json['dependencies'].update(j)
|
||||
|
||||
trimmed = {}
|
||||
for k, v in j.items():
|
||||
if k in seeds:
|
||||
trimmed[k] = v
|
||||
|
||||
bower_json['dependencies'].update(trimmed)
|
||||
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
ret = os.path.join(tmpdir, 'bower.json')
|
||||
@ -110,9 +123,8 @@ def main(args):
|
||||
seeds = set([s[len(prefix):] for s in seeds])
|
||||
|
||||
version_targets = [t + "-versions.json" for t in targets]
|
||||
|
||||
subprocess.check_call(['bazel', 'build'] + version_targets)
|
||||
bower_json_path = build_bower_json(version_targets)
|
||||
bower_json_path = build_bower_json(version_targets, seeds)
|
||||
dir = os.path.dirname(bower_json_path)
|
||||
cmd = bower_command(["install"])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user