forked from googlemaps/js-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
109 lines (100 loc) · 2.29 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
load("@npm//eslint:index.bzl", "eslint", "eslint_test")
load("@npm//license-check-and-add:index.bzl", "license_check_and_add_test")
load("@npm//http-server:index.bzl", "http_server")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test")
load("@rules_pkg//:pkg.bzl", "pkg_deb", "pkg_tar")
exports_files(
[
"tsconfig.json",
"LICENSE",
"package.json",
"babel.config.json",
"rollup.config.js",
],
visibility = ["//:__subpackages__"],
)
http_server(
name = "serve",
args = [
],
data = [
"//:index.html",
"//samples:outputs",
],
)
CMD = '''
set -e
context="{\\"packages\\": {\n"
packages=$$($(location @npm//lerna/bin:lerna) list)
i=0
for p in $$packages; do
if ((i > 0)); then
context="$${context},\\n"
fi
context="$${context}\\"$$($(location @npm//json/bin:json) -f samples/$$p/data.json title)\\": \\"$$p\\""
i=$$((i + 1))
done
context="$${context}}}"
echo -e $${context} > $@
'''
# Used to generate data.json
#
# genrule(
# name = "data",
# outs = ["data.json"],
# cmd = CMD,
# local = 1,
# tools = [
# "@npm//json/bin:json",
# "@npm//lerna/bin:lerna",
# ],
# )
genrule(
name = "index",
srcs = [
":data.json",
":index.njk",
"//shared:templates",
],
outs = ["index.html"],
cmd = "$(location @npm//nunjucks-cli/bin:nunjucks) $(location index.njk) $(location data.json) -p . && cat index.html > $@",
tools = ["@npm//nunjucks-cli/bin:nunjucks"],
)
eslint_test(
name = "eslint",
args = ["samples/**/*.js"],
data = [
# config files
":.eslintrc.json",
"//samples:.eslintrc.json",
# files to test
"//samples:inputs",
# plugins
"@npm//eslint-config-prettier",
"@npm//eslint-plugin-jest",
"@npm//eslint-plugin-prettier",
],
)
license_check_and_add_test(
name = "license_check",
args = [
"check",
"**/*.js",
"-f",
".license-check.json",
],
data = [
":.license-check.json",
":LICENSE",
"//samples:inputs",
],
)
pkg_tar(
name = "public",
srcs = [
"//:index.html",
"//samples:inputs",
"//samples:outputs",
],
strip_prefix = ".",
)