require 'shellwords'
require 'set'
require_relative 'helpers/pretty_table'
require_relative 'helpers/git'
require_relative 'helpers/github'

before_all do
  if is_ci
    skip_docs
  end
end

lane :benchmark do |options|
  desc "Benchmark runtime of a CI workflow for a PR base and head refs"
  benchmark_workflow(**options)
end

desc "Runs release-please dry-run"
lane :please do |options|
  token = `gh auth token 2>/dev/null`.strip
  if token.nil?
    UI.user_error!("Unable to fetch github token. Please run `gh auth login` and try again")
  end

  Dir.chdir(Git.root) do
    sh([
      "release-please",
      "release-pr",
      "--token='#{token}'",
      "--repo-url=#{Github.repo_url}",
      "--target-branch=main",
      "--dry-run"
    ].compact, log: true)
  end
end
