forked from googlemaps/js-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
112 lines (102 loc) · 2.21 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
110
111
112
load("@npm//eslint:index.bzl", "eslint", "eslint_test")
load("@npm//http-server:index.bzl", "http_server")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
exports_files(
[
"LICENSE",
".eslintrc.json",
".babelrc",
".babelrc.jsfiddle.json",
"package.json",
"jest.config.js",
"tsconfig.json",
],
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_DATA = [
# config files
":.eslintrc.json",
"//samples:.eslintrc.json",
# plugins
"@npm//eslint-config-prettier",
"@npm//eslint-plugin-jest",
"@npm//eslint-plugin-prettier",
"@npm//@typescript-eslint/parser",
"@npm//@typescript-eslint/eslint-plugin",
]
eslint_test(
name = "eslint",
args = [
"samples/**/*.ts",
"samples/**/*.js",
],
data = ESLINT_DATA + [
"//samples:inputs",
"//samples:outputs",
],
)
eslint(
name = "eslint-fix",
args = [
"samples/**/*.ts",
"--fix",
],
data = ESLINT_DATA + [
"//samples:inputs",
],
)
pkg_tar(
name = "public",
srcs = [
"//:index.html",
"//samples:outputs",
],
strip_prefix = ".",
)