Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config key for default maven repo and self check url #1899

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ object Cli {
bitbucketServerUseDefaultReviewers: Boolean = false,
gitlabMergeWhenPipelineSucceeds: Boolean = false,
githubAppKeyFile: Option[File] = None,
githubAppId: Option[Long] = None
githubAppId: Option[Long] = None,
urlCheckerTestUrl: Option[Uri] = None,
defaultMavenRepo: Option[String] = None
)

final case class EnvVar(name: String, value: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import cats.syntax.all._
import cats.{Apply, Monad}
import org.http4s.Uri
import org.http4s.Uri.UserInfo
import org.http4s.syntax.literals._
import org.scalasteward.core.application.Cli.EnvVar
import org.scalasteward.core.application.Config._
import org.scalasteward.core.data.Resolver
import org.scalasteward.core.git.Author
import org.scalasteward.core.io.{ProcessAlg, WorkspaceAlg}
import org.scalasteward.core.util
Expand Down Expand Up @@ -72,7 +74,9 @@ final case class Config(
cacheTtl: FiniteDuration,
bitbucketServerCfg: BitbucketServerCfg,
gitLabCfg: GitLabCfg,
githubApp: Option[GitHubApp]
githubApp: Option[GitHubApp],
urlCheckerTestUrl: Uri,
defaultResolver: Resolver
) {
def vcsUser[F[_]](implicit
processAlg: ProcessAlg[F],
Expand Down Expand Up @@ -157,6 +161,10 @@ object Config {
gitLabCfg = GitLabCfg(
mergeWhenPipelineSucceeds = args.gitlabMergeWhenPipelineSucceeds
),
githubApp = Apply[Option].map2(args.githubAppId, args.githubAppKeyFile)(GitHubApp)
githubApp = Apply[Option].map2(args.githubAppId, args.githubAppKeyFile)(GitHubApp),
urlCheckerTestUrl = args.urlCheckerTestUrl.getOrElse(uri"https://github.com"),
defaultResolver = args.defaultMavenRepo
.map(url => Resolver.MavenRepository("default", url, None))
.getOrElse(Resolver.mavenCentral)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ object Context {
implicit val pullRequestRepository: PullRequestRepository[F] =
new PullRequestRepository[F](pullRequestsStore)
implicit val scalafmtAlg: ScalafmtAlg[F] = ScalafmtAlg.create[F]
implicit val selfCheckAlg: SelfCheckAlg[F] = new SelfCheckAlg[F]
implicit val selfCheckAlg: SelfCheckAlg[F] = new SelfCheckAlg[F](config)
implicit val coursierAlg: CoursierAlg[F] = CoursierAlg.create[F]
implicit val versionsCache: VersionsCache[F] =
new VersionsCache[F](config.cacheTtl, versionsStore)
implicit val updateAlg: UpdateAlg[F] = new UpdateAlg[F]
implicit val mavenAlg: MavenAlg[F] = MavenAlg.create[F](config)
implicit val sbtAlg: SbtAlg[F] = SbtAlg.create[F](config)
implicit val millAlg: MillAlg[F] = MillAlg.create[F]
implicit val buildToolDispatcher: BuildToolDispatcher[F] = BuildToolDispatcher.create[F]
implicit val buildToolDispatcher: BuildToolDispatcher[F] =
BuildToolDispatcher.create[F](config)
implicit val refreshErrorAlg: RefreshErrorAlg[F] = new RefreshErrorAlg[F](refreshErrorStore)
implicit val repoCacheAlg: RepoCacheAlg[F] = new RepoCacheAlg[F](config)
implicit val editAlg: EditAlg[F] = new EditAlg[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ package org.scalasteward.core.application
import cats.MonadThrow
import cats.syntax.all._
import org.typelevel.log4cats.Logger
import org.http4s.Uri
import org.scalasteward.core.git.GitAlg
import org.scalasteward.core.scalafmt.{scalafmtBinary, ScalafmtAlg}
import org.scalasteward.core.util.UrlChecker
import org.scalasteward.core.util.logger.LoggerOps

final class SelfCheckAlg[F[_]](implicit
final class SelfCheckAlg[F[_]](config: Config)(implicit
gitAlg: GitAlg[F],
logger: Logger[F],
scalafmtAlg: ScalafmtAlg[F],
Expand Down Expand Up @@ -55,8 +54,8 @@ final class SelfCheckAlg[F[_]](implicit

private def checkUrlChecker: F[Unit] =
for {
url <- F.fromEither(Uri.fromString("https://github.com"))
res <- urlChecker.exists(url)
res <- urlChecker.exists(config.urlCheckerTestUrl)
url = config.urlCheckerTestUrl
msg = s"Self check of UrlChecker failed: checking that $url exists failed"
_ <- if (!res) logger.warn(msg) else F.unit
} yield ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package org.scalasteward.core.buildtool

import cats.Monad
import cats.syntax.all._
import org.scalasteward.core.application.Config
import org.scalasteward.core.buildtool.maven.MavenAlg
import org.scalasteward.core.buildtool.mill.MillAlg
import org.scalasteward.core.buildtool.sbt.SbtAlg
import org.scalasteward.core.data.{Resolver, Scope}
import org.scalasteward.core.data.Scope
import org.scalasteward.core.edit.scalafix.ScalafixMigration
import org.scalasteward.core.scalafmt.ScalafmtAlg
import org.scalasteward.core.vcs.data.Repo
Expand All @@ -31,7 +32,7 @@ import org.scalasteward.core.vcs.data.BuildRoot
trait BuildToolDispatcher[F[_]] extends BuildToolAlg[F, Repo]

object BuildToolDispatcher {
def create[F[_]](implicit
def create[F[_]](config: Config)(implicit
mavenAlg: MavenAlg[F],
millAlg: MillAlg[F],
sbtAlg: SbtAlg[F],
Expand Down Expand Up @@ -85,7 +86,7 @@ object BuildToolDispatcher {
def getAdditionalDependencies(buildRoot: BuildRoot): F[List[Scope.Dependencies]] =
scalafmtAlg
.getScalafmtDependency(buildRoot)
.map(_.map(dep => Scope(List(dep), List(Resolver.mavenCentral))).toList)
.map(_.map(dep => Scope(List(dep), List(config.defaultResolver))).toList)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.scalasteward.core.application.Config
import org.scalasteward.core.buildtool.BuildToolAlg
import org.scalasteward.core.buildtool.sbt.command._
import org.scalasteward.core.buildtool.sbt.data.SbtVersion
import org.scalasteward.core.data.{Dependency, Resolver, Scope}
import org.scalasteward.core.data.{Dependency, Scope}
import org.scalasteward.core.io.{FileAlg, FileData, ProcessAlg, WorkspaceAlg}
import org.scalasteward.core.edit.scalafix.ScalafixMigration
import org.scalasteward.core.util.Nel
Expand Down Expand Up @@ -130,6 +130,6 @@ object SbtAlg {

def getAdditionalDependencies(buildRoot: BuildRoot): F[List[Scope.Dependencies]] =
getSbtDependency(buildRoot)
.map(_.map(dep => Scope(List(dep), List(Resolver.mavenCentral))).toList)
.map(_.map(dep => Scope(List(dep), List(config.defaultResolver))).toList)
}
}