22 Commits

Author SHA1 Message Date
Logan Hanks
b824e5ee2e Fix glob in bower2bazel.py
This fixes I850271bb1c657a5ffe77946a6beaf54a3680af75.

Change-Id: I128ae1b88adc267b0f1f9b1db7b0a96a87a861b3
(cherry picked from commit 9ffd58a82b497dbdfcf73945dea240469fee3b14)
2017-07-31 10:44:57 +00:00
Paladox none
104a6a184e Fix bazel 0.5.* support
Change-Id: I751b4fca32964a400bf6875950b2114bf542b981
2017-06-16 09:09:35 +00:00
Shawn Pearce
41c2e73da2 Support Bazel 0.5.1
Bazel 0.5.1 is using "bazel-out/darwin_x86_64-fastbuild/", which
failed these extraction patterns.  Allow anything before the
-fastbuild part of the path.

Change-Id: I850271bb1c657a5ffe77946a6beaf54a3680af75
2017-06-12 08:53:05 +09:00
Han-Wen Nienhuys
3dede1653a 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
2017-02-01 13:33:55 +01:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
Han-Wen Nienhuys
42ea853037 bazel: remove code to sniff license field in bower.json.
Instead, use a hard-coded map of licenses.

Hardcode a false dependency on diff-match-patch to avoid a diff for
the Apache2.0 license.

Tested:
  bazel build Documentation:js_licenses.txt
  buck build Documentation:js_licenses.txt
  diff -u  buck-out/gen/Documentation/js_licenses.txt/js_licenses.txt \
    bazel-genfiles/Documentation/js_licenses.txt
 diff shows only diffs for added [[header]] anchors.

Change-Id: I7886e1fadec900cf854a1b3b7c538b83d66af7a4
2016-12-20 15:44:52 +01:00
Han-Wen Nienhuys
246f928887 bazel: update bower packages.
Change-Id: I1672018089db8df90f52416f532436b387c242cb
2016-11-03 13:01:39 +01:00
David Pursehouse
6935c62ea8 bower2buck: Fix import to follow Google's Python Style Guide
The Imports section of the style guide [1] says imports should
only be used for packages and modules.

[1] https://google.github.io/styleguide/pyguide.html?showone=Imports#Imports

Change-Id: Id293cc0a0243d7f4943fe5b7645f8798633c3423
2016-10-20 08:46:01 +09:00
David Pursehouse
ccc45ad75d Remove unused imports in Python scripts
Change-Id: I4397b76d8dbfe5e73b7cede4c15bd77ad322c04e
2016-10-19 12:19:54 +09:00
Han-Wen Nienhuys
939e8df480 Fix bowerutil import in bower2buck.
Bug: Issue 4780
Change-Id: I8b35616030cd8ef4ffdb8fa4edb3649e457ea988
2016-10-19 12:19:45 +09:00
Han-Wen Nienhuys
36502628b7 bazel: add rules for vulcanize & crisper, and use them in //polygerrit-ui/app.
Change-Id: Icaa15889f9963464897742c5003bbf0b15c56ffd
2016-10-06 14:01:05 +02:00
Han-Wen Nienhuys
28e7a6d3fe bazel: bower support
* npm_binary (download tarball packaged npm apps)

* bower_archive (download a zip file, to be put in WORKSPACE)

* bower_component (defining a bower library, with dependency )

* bower_component_bundle (zipping up libraries together)

* js_component (insert plain js file into bower component bundle)

* bower2bazel.py: run bower to find dependencies, generate a .bzl to
  define archives and define components

Tested:

 python tools/js/bower2bazel.py -w lib/js/bower_archives.bzl -b \
    lib/js/bower_components.bzl

 bazel build polygerrit-ui:components
 unzip -v bazel-bin/polygerrit-ui/components.zip > /tmp/baz

 buck build polygerrit-ui:polygerrit_components
 unzip -v buck-out/gen/polygerrit-ui/polygerrit_components/polygerrit_components.bower_components.zip > /tmp/buck

 diff /tmp/buck /tmp/baz

The diff corresponds to newer file versions pinned through bower2bazel.

Change-Id: I4f33914d4853bcf8afe78b4719d0e0e83b139031
2016-09-29 13:18:19 +02:00
Andrew Bonventre
724b4e1a90 Add fetch polyfill for use in all supported browsers
Additionally fix a bug in bower2buck.py where it would
bail when a license is not specified in a Bower package
info response.

[1] http://caniuse.com/#feat=fetch
[2] http://github.github.io/fetch/

Change-Id: Ibf754aab98bab6e34b7a9fb5d6c9801bb612f5d5
2016-03-03 23:49:18 -05:00
Dave Borowitz
6b99cd488c download_bower: Remove cache entries with invalid SHA-1
Change-Id: I7c971b1c1b82c80da669036b3405bd52e193b9d2
2015-12-07 15:43:56 +00:00
Dave Borowitz
dc7cff2b84 Fix lib/js/BUCK to work with bower2buck
web-animations is weird because it can be referred to either as
'web-animations' or 'web-animations/web-animations-js'. Manually
entering it as the former confuses bower2buck when it's referred to
elsewhere as the latter.

Run bower2buck to normalize the current contents.

Band-aid the situation for now, and jot down some of my ideas for
fixing when I find the time.

Change-Id: I64ae3c376df7b83008462c663de4a3998749c365
2015-12-03 13:49:40 -05:00
Dave Borowitz
770d62e87f Improve bower2buck instructions
Instead of requiring a target, default to //polygerrit-ui/...; this
package and subpackages have several bower_components rules, and
using all of them is most likely to produce all the existing rules in
lib/js/BUCK.

Rewrite instructions in lib/js/BUCK so they are more copy-and-
pasteable. Add instructions to the generated new BUCK file on how to
merge with an existing BUCK file.

Normalize the existing package names so there's less delta on each
diff.

Change-Id: I5f46d4d06d6aaacf40c9a7771eec6e85710093e1
2015-12-01 17:57:13 +00:00
Dave Borowitz
868f76458a tools: Use common hash_file implementation
Change-Id: Idf0dce913e012bfc3bcf12d6cd19d322af69505b
2015-11-25 10:15:17 -05:00
Dave Borowitz
5da89cf34c Add bower2buck script to convert bower deps to Buck rules
This script merges dependencies of a bower_components rule into a
synthetic bower.json, then runs bower install to evaluate the version
rules and install packages locally. It walks through the downloaded
.bower.json files to produce new bower_component rules to put back in
lib/js/BUCK.

Change-Id: Iaea0b0a54ca4305ce40accf5924cd12fbf07b0d8
2015-11-25 10:12:29 -05:00
Dave Borowitz
0cb928cd53 download_bower.py: Fix hash_dir
We were passing the wrong directory name, resulting in hashing a
nonexistent directory and all components having the same SHA-1.
Unfortunately os.walk succeeds silently in this case.

Move hash_dir and hash_file to util so they can be used by other
scripts. (Migration of existing hashfile implementations will come
later.)

Restructure the main function to look a little more like the logic in
download_file.py, where we download to the cached location first and
then copy it after.

Fix all the broken SHA-1s in lib/js/BUCK.

Change-Id: I58bc62f84b62169bf18695a6a6704c989036c4f6
2015-11-25 10:10:09 -05:00
Dave Borowitz
b9fe4daf26 run_npm_binary.py: Support Debian's "nodejs"
Change-Id: Iaf37279cdf5d225f425eec7f87eed5dd5531be7c
2015-11-13 12:41:45 -05:00
Dave Borowitz
cfd221eede Add script to pack npm_binary tarballs with dependencies
Contrary to our experience with bower, not all packages on
registry.npmjs.org come with dependencies bundled. This script
produces a tarball with bundled dependencies which can be hosted on
the Gerrit GCS bucket and used as an npm_binary.

Change-Id: I2403c7f0acf759be2508b845d1f359cdf6a65e4e
2015-11-12 19:03:09 -05:00
Dave Borowitz
ffe301570c Build bower_components with buck
Add support for downloading npm binaries including dependencies and
running them in buck genrules. In npm land, transitive dependencies
are generally included in the package distribution, and there are a
*lot* of them. Since we aren't redistributing these binaries and
they're only part of the build process, we don't have to worry too
much about licensing, only that they don't have anything totally
crazy.

We assume packages have a certain format and we can detect the binary
to run from the genrule output filename. Actually running the binary
is tricky as well, since we have to extract it first. But it might be
large, so we don't want to extract it on every invocation; and naive
extraction to a common location (in buck-out) is racy. So we need a
custom extractor scheme using atomic rename to make this work.

Download bower as an npm package and use it to download bower
packages. Bower packages can come from a variety of sources, usually
git repositories, so we can't simply use download_file. There is
additional logic in bower to read bower.json and strip out unneeded
files, so I didn't want to get into reimplementing that. The tricky
thing about bower is convincing it to avoid transitive dependencies so
we can let Buck handle parallelism and caching. To do this, we need to
read the package information from the upstream bower repository, and
explicitly ignore all listed dependencies when downloading.

We combine the flattened list of bower packages in a single
bower_components rule. It would be nice to have deps of each
bower_component so we didn't need to flatten these, but Buck genrules
don't have deps so this is a nonstarter. Considering we only expect to
have a single bower_components for the whole project, hopefully this
is not too onerous.

This change just gets us the bower_components directory. We still have
some work to do to use this from Gerrit. Plus even more work to
replace the gulpfile and actually package this stuff together into a
compiled JS app for the war distribution.

Change-Id: Id277d2d812ffcc3bce87ff00b5894bacdffc038e
2015-11-12 19:01:53 -05:00