load("@toolchains//rover:macros.bzl", "supergraph", "diff_check", "dev_update_file")
load( ":tilt.bzl", "tilt",)

# Bring up the full set of services for development
tilt(
    name = "up",
    subcmd = "up",
)

# Bring down any remaining/running services
tilt(
    name = "down",
    subcmd = "down",
)

python_bootstrap_binary(
    name = "healthcheck",
    main = "healthcheck.py",
    visibility = ["PUBLIC"],
)

supergraph(
  name = "supergraph",
  config = "config/apollo-federation/supergraph-config.yaml",
  subgraphs = {
    "API_KEYS_SCHEMA": "//core/api-keys:sdl",
    "NOTIFICATIONS_SCHEMA": "//core/notifications:sdl",
    "PUBLIC_SCHEMA": "//core/api:public-sdl",
  },
)

diff_check(
  name = "supergraph-diff",
  original = "config/apollo-federation/supergraph.graphql",
  new = ":supergraph"
)

test_suite(
    name = "check-sdls",
    tests = [
        ":supergraph-diff",
        "//core/api:public-schema-diff",
        "//core/api:admin-schema-diff",
        "//core/api-keys:schema-diff",
        "//core/notifications:schema-diff",
    ],
)

dev_update_file(
  name = "update-supergraph",
  generated = ":supergraph",
  out = "config/apollo-federation/supergraph.graphql"
)

dev_update_file(
  name = "update-core-supergraph",
  generated = ":supergraph",
  out = "../core/api/dev/apollo-federation/supergraph.graphql"
)

sh_binary(
  name = "update-schemas",
  main = "bin/update-schemas.sh",
)

sh_binary(
  name = "init-onchain",
  main = "bin/init-onchain.sh",
)

sh_binary(
  name = "init-lightning",
  main = "bin/init-lightning.sh",
)

sh_binary(
  name = "init-user",
  main = "bin/init-user.sh",
)

sh_binary(
  name = "setup-hydra-client",
  main = "bin/setup-hydra-client.sh",
)

sh_binary(
  name = "stoppable-trigger",
  main = "bin/run-stoppable-trigger.sh",
)

sh_binary(
  name = "add-test-users-with-usernames",
  main = "bin/add-test-users-with-usernames.sh",
)

sh_binary(
  name = "fund-user",
  main = "bin/fund-user.sh",
)
