blob: a1c869d20c9026e9e718f9d7f327b012131faf1e [file]
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@com_googlesource_gerrit_bazlets//tools:genrule2.bzl", "genrule2")
ts_project(
name = "licenses-config",
srcs = [
"licenses.ts",
],
tsconfig = "tsconfig.json",
deps = [
"//tools/node_tools:node_modules",
"//tools/node_tools/node_modules_licenses:licenses-map",
],
)
# (TODO)dmfilippov Find a better way to fix it (another workaround or submit a bug to
# plugin's authors or to a ts_config rule author).
# The following genrule is a workaround for a bazel intellij plugin's bug.
# According to the documentation, the ts_config_rules section should be added
# to a .bazelproject file if a project uses typescript
# (https://ij.bazel.build/docs/dynamic-languages-typescript.html)
# Unfortunately, this doesn't work. It seems, that the plugin expects some output from
# the ts_config rule, but the rule doesn't produce any output.
# To workaround the issue, the tsconfig_editor genrule was added. The genrule only copies
# input file to the output file, but this is enough to make bazel plugins works.
# So, if you have any problem a typescript editor (import errors, types not found, etc...) -
# try to build this rule from the command line
# (bazel build tools/node_tools/node_modules/licenses:tsconfig_editor) and then sync bazel project
# in intellij.
genrule(
name = "tsconfig_editor",
srcs = [":tsconfig.json"],
outs = ["tsconfig_editor.json"],
cmd = "cp $< $@",
)
filegroup(
name = "licenses-config-js",
srcs = [":licenses-config"],
)
genrule2(
name = "node_modules_files",
srcs = ["//polygerrit-ui/app:node_modules"],
outs = ["package_json.properties"],
cmd = "find -L $(locations //polygerrit-ui/app:node_modules) -type f -print | grep '.aspect_rules_js' > $$ROOT/$@",
)
filegroup(
name = "licenses-texts",
srcs = glob(["licenses/*.txt"]),
)
genrule2(
name = "licenses-text-properties",
srcs = [":licenses-texts"],
outs = ["licenses.properties"],
cmd = "find ./polygerrit-ui/app/node_modules_licenses/licenses -name '*.txt' > $$ROOT/$@",
)
# Generate polygerrit-licenses.json for files in @ui_npm workspace.
# For details - see comments for node_modules_licenses rule and
# tools/node_tools/node_modules_licenses/license-map-generator.ts file
js_run_binary(
name = "polygerrit-licenses",
srcs = [
"//polygerrit-ui/app:node_modules",
"//polygerrit-ui/app/node_modules_licenses:licenses-config-js",
"//polygerrit-ui/app/node_modules_licenses:licenses-text-properties",
"//polygerrit-ui/app/node_modules_licenses:licenses-texts",
"//polygerrit-ui/app/node_modules_licenses:node_modules_files",
],
outs = ["polygerrit-licenses.json"],
args = [
"$(location //polygerrit-ui/app/node_modules_licenses:licenses-config-js)",
"$(location //polygerrit-ui/app/node_modules_licenses:node_modules_files)",
"$(location //polygerrit-ui/app/node_modules_licenses:licenses-text-properties)",
"$@",
],
chdir = "",
tool = "//tools/node_tools/node_modules_licenses:license-map-generator-bin",
visibility = ["//visibility:public"],
)