...
1load("@aspect_rules_js//js:defs.bzl", "js_test")
2load("@aspect_rules_js//npm:defs.bzl", "npm_package", "stamped_package_json")
3load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
4
5copy_file(
6 name = "copy_LICENSE",
7 src = "//:LICENSE",
8 out = "LICENSE",
9)
10
11genrule(
12 name = "buildozer_launcher",
13 srcs = ["//:launcher.js"],
14 outs = ["buildozer.js"],
15 cmd = "sed s/_TOOL_/buildozer/ $< > $@",
16)
17
18# npm rules live in this subdirectory to avoid a load() statement
19# in the parent package leaking to users. This means we need
20# to copy the output files so the pkg_npm will find them in the
21# output directory for this package.
22_PARENT_PACKAGE_FILES = [
23 "README.md",
24 "buildozer-darwin_amd64",
25 "buildozer-darwin_arm64",
26 "buildozer-linux_amd64",
27 "buildozer-linux_arm64",
28 "buildozer-windows_amd64.exe",
29]
30
31[
32 copy_file(
33 name = "copy_%s" % s,
34 # go_binary doesn't give a predeclared output for
35 # the file in "out" so we have to construct a
36 # label to reference the go_binary rule itself.
37 src = "//buildozer:%s" % s.replace("_arm64", "-arm64").split("_amd64")[0],
38 out = s,
39 )
40 for s in _PARENT_PACKAGE_FILES
41]
42
43stamped_package_json(
44 name = "package",
45 stamp_var = "BUILD_SCM_VERSION",
46)
47
48npm_package(
49 name = "buildozer",
50 srcs = [
51 "LICENSE",
52 "buildozer.js",
53 "index.js",
54 ":package",
55 ] + _PARENT_PACKAGE_FILES,
56 package = "@bazel/buildozer",
57)
58
59js_test(
60 name = "integration_test",
61 data = [":buildozer"],
62 entry_point = "test.js",
63)
View as plain text