load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//common:browsers.bzl", "chrome_data", "firefox_data")
load("//java:browsers.bzl", "chrome_jvm_flags", "firefox_jvm_flags")
load("//java:defs.bzl", "artifact")

exports_files([
    "package.json",
    "pnpm-workspace.yaml",
])

npm_link_all_packages(name = "node_modules")

filegroup(
    name = "license",
    srcs = [
        "LICENSE",
        "NOTICE",
    ],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "rakefile",
    srcs = [
        "Rakefile",
    ],
    visibility = ["//rb:__subpackages__"],
)

alias(
    name = "grid",
    actual = "//java/src/org/openqa/selenium/grid:executable-grid",
)

alias(
    name = "pinned-grid",
    actual = "//java/src/org/openqa/selenium/grid:pinned-grid",
)

alias(
    name = "debug-server",
    actual = "//java/test/org/openqa/selenium/environment:appserver",
)

alias(
    name = "calcdeps",
    actual = "//javascript/atoms:deps",
)

alias(
    name = "selenium-server-standalone",
    actual = "//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
)

java_binary(
    name = "server",
    args = [
        "standalone",
        "--relax-checks",
        "true",
    ],
    data = chrome_data + firefox_data,
    jvm_flags = chrome_jvm_flags + firefox_jvm_flags,
    main_class = "org.openqa.selenium.grid.Bootstrap",
    runtime_deps = [
        "//java/src/org/openqa/selenium/grid",
        artifact("org.slf4j:slf4j-jdk14"),
    ],
)

npm_link_package(
    name = "node_modules/selenium-webdriver",
    src = "//javascript/node/selenium-webdriver",
)

platform(
    name = "rosetta",
    constraint_values = [
        "@platforms//os:osx",
        "@platforms//cpu:x86_64",
    ],
)

buildifier(
    name = "buildifier",
    lint_mode = "fix",
    mode = "fix",
    tags = [
        "manual",
    ],
)
