Skip to content

Commit

Permalink
implement scala optimized sbt imports, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Deliganli committed Dec 21, 2020
1 parent ccf0673 commit 37ef8cd
Show file tree
Hide file tree
Showing 30 changed files with 684 additions and 523 deletions.
28 changes: 9 additions & 19 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,12 @@ lazy val `maven-search` =
(project in file("."))
.aggregate(logging)
.dependsOn(logging)
.enablePlugins(UniversalPlugin, JvmPlugin)
.enablePlugins(JavaAppPackaging)
.settings(
name := "maven-search",
common,
Deployment.assemblySettings,
libraryDependencies ++= Seq(
scopt,
"net.java.dev.jna" % "jna" % "5.6.0"
//"org.fusesource.jansi" % "jansi" % "1.18"
) ++ Seq(
"org.jline" % "jline-terminal" % Versions.jline,
"org.jline" % "jline-reader" % Versions.jline,
"org.jline" % "jline-console" % Versions.jline,
"org.jline" % "jline-terminal-jna" % Versions.jline
//"org.jline" % "jline-terminal-jansi" % Versions.jline
) ++ Seq(
"io.circe" %% "circe-core" % Versions.circe,
circeConfig,
http4sCirce
)
++ http4sClient
++ scalatest
deployment,
libraryDependencies ++= Seq(scopt) ++ scalatest ++ jline.jna ++ circe ++ http4sClient
)

lazy val logging = (project in file("logging"))
Expand All @@ -44,3 +28,9 @@ lazy val common = Seq(
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full)
)

lazy val deployment = Seq(
maintainer := "Sait Sami Kocatas",
packageSummary := "Command line program searches given query on maven",
executableScriptName := "mvns"
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.deliganli.core.logging
package com.deliganli.maven.search.logging

import cats.effect.{Concurrent, ContextShift, Resource, Timer}
import io.odin._
import io.odin.formatter.Formatter
import io.odin.{asyncFileLogger, Level, Logger}

object PresetLogger {

Expand Down
2 changes: 1 addition & 1 deletion logging/src/main/scala/org/slf4j/impl/ExternalLogger.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.slf4j.impl

import cats.effect.{Clock, ContextShift, Effect, IO, Timer}
import com.deliganli.core.logging.PresetLogger
import com.deliganli.maven.search.logging.PresetLogger
import io.odin._
import io.odin.slf4j.OdinLoggerBinder

Expand Down
167 changes: 34 additions & 133 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,21 @@ import sbt._
object Dependencies {

object Versions {
val scalatest = "3.2.0"
val cats = "2.2.0"
val osLib = "0.3.0"
val circeFs2 = "0.13.0"
val circe = "0.13.0"
val circeConfig = "0.7.0"
val fs2 = "2.1.0"
val enumeratum = "1.5.15"
val enumeratumCirce = "1.5.21"
val breeze = "1.0"
val shapeless = "2.3.3"
val mockito = "1.16.0"
val jodaDateTime = "2.10.3"
val http4s = "0.21.7"
val http4sJdk = "0.3.1"
val scopt = "4.0.0-RC2"
val jsoup = "1.13.1"
val doobie = "0.9.0"
val odin = "0.9.1"
val flyway = "6.2.3"
val tsec = "0.2.0"
val awsS3 = "2.13.10"
val monocle = "2.0.0"
val gcVision = "1.99.3"
val gcStorage = "1.107.0"
val pdfbox = "2.0.19"
val jbig2 = "3.0.3"
val itext = "7.1.11"
val jline = "3.16.0"
val scalatest = "3.2.0"
val cats = "2.2.0"
val circe = "0.13.0"
val circeConfig = "0.8.0"
val mockito = "1.16.0"
val http4s = "0.21.7"
val http4sJdk = "0.3.1"
val scopt = "4.0.0-RC2"
val odin = "0.9.1"
val jline = "3.16.0"
}

val circe = Seq(
"io.circe" %% "circe-core" % Versions.circe,
"io.circe" %% "circe-generic" % Versions.circe,
"io.circe" %% "circe-generic-extras" % Versions.circe,
"io.circe" %% "circe-parser" % Versions.circe,
"io.circe" %% "circe-shapes" % Versions.circe
)

val doobie = Seq(
"org.tpolecat" %% "doobie-core" % Versions.doobie,
"org.tpolecat" %% "doobie-hikari" % Versions.doobie,
"org.tpolecat" %% "doobie-quill" % Versions.doobie,
"org.tpolecat" %% "doobie-scalatest" % Versions.doobie % "test"
)

val fs2 = Seq(
"co.fs2" %% "fs2-core" % Versions.fs2,
"co.fs2" %% "fs2-io" % Versions.fs2,
"co.fs2" %% "fs2-reactive-streams" % Versions.fs2,
"co.fs2" %% "fs2-experimental" % Versions.fs2
)

val enumeratum = Seq(
"com.beachape" %% "enumeratum" % Versions.enumeratum,
"com.beachape" %% "enumeratum-circe" % Versions.enumeratumCirce
)

val breeze = Seq(
"org.scalanlp" %% "breeze" % Versions.breeze
// "org.scalanlp" %% "breeze-natives" % Versions.breeze
"io.circe" %% "circe-core" % Versions.circe,
"io.circe" %% "circe-config" % Versions.circeConfig
)

val scalatest = Seq(
Expand All @@ -81,88 +35,35 @@ object Dependencies {

val http4sClient = Seq(
"org.http4s" %% "http4s-blaze-client" % Versions.http4s,
"org.http4s" %% "http4s-circe" % Versions.http4s,
"org.http4s" %% "http4s-jdk-http-client" % Versions.http4sJdk
)

val jline = Seq(
"org.jline" % "jline-terminal" % Versions.jline,
"org.jline" % "jline-reader" % Versions.jline,
"org.jline" % "jline-console" % Versions.jline,
"org.jline" % "jline-terminal-jna" % Versions.jline,
"org.jline" % "jline-terminal-jansi" % Versions.jline
)

val http4sServer = Seq(
"org.http4s" %% "http4s-dsl",
"org.http4s" %% "http4s-blaze-server"
).map(_ % Versions.http4s)

val http4sCirce = "org.http4s" %% "http4s-circe" % Versions.http4s

val odin = Seq(
"com.github.valskalla" %% "odin-core",
"com.github.valskalla" %% "odin-json",
"com.github.valskalla" %% "odin-extras",
"com.github.valskalla" %% "odin-slf4j"
).map(_ % Versions.odin)

val tsec = Seq(
"io.github.jmcardon" %% "tsec-common",
"io.github.jmcardon" %% "tsec-password",
"io.github.jmcardon" %% "tsec-cipher-jca",
"io.github.jmcardon" %% "tsec-cipher-bouncy",
"io.github.jmcardon" %% "tsec-mac",
"io.github.jmcardon" %% "tsec-signatures",
"io.github.jmcardon" %% "tsec-hash-jca",
"io.github.jmcardon" %% "tsec-hash-bouncy",
//"io.github.jmcardon" %% "tsec-libsodium",
"io.github.jmcardon" %% "tsec-jwt-mac",
"io.github.jmcardon" %% "tsec-jwt-sig",
"io.github.jmcardon" %% "tsec-http4s"
).map(_ % Versions.tsec)

val pdfbox = Seq(
"org.apache.pdfbox" % "pdfbox"
).map(_ % Versions.pdfbox) ++ Seq(
"org.apache.pdfbox" % "jbig2-imageio" % Versions.jbig2
)

val itext = Seq(
"com.itextpdf" % "kernel", // always needed
"com.itextpdf" % "io", // always needed
"com.itextpdf" % "layout", // always needed
"com.itextpdf" % "forms", // only needed for forms
"com.itextpdf" % "pdfa", // only needed for PDF/A
"com.itextpdf" % "sign", // only needed for digital signatures
"com.itextpdf" % "barcodes", // only needed for barcodes
"com.itextpdf" % "font-asian", // only needed for Asian fonts
"com.itextpdf" % "hyph" // only needed for hyphenation
).map(_ % Versions.itext)

val opencv = Seq(
//"org.openpnp" % "opencv" % "4.3.0-2",
"org.bytedeco" % "javacv-platform" % "1.5.3"
)

val monocle = Seq(
"com.github.julien-truffaut" %% "monocle-core" % Versions.monocle,
"com.github.julien-truffaut" %% "monocle-macro" % Versions.monocle,
"com.github.julien-truffaut" %% "monocle-law" % Versions.monocle % "test"
)
object jline {

val base = Seq(
"org.jline" % "jline-terminal" % Versions.jline,
"org.jline" % "jline-reader" % Versions.jline,
"org.jline" % "jline-console" % Versions.jline
)

def jna =
base ++ Seq(
"org.jline" % "jline-terminal-jna" % Versions.jline,
"net.java.dev.jna" % "jna" % "5.6.0"
)

def jansi =
base ++ Seq(
"org.jline" % "jline-terminal-jansi" % Versions.jline,
"org.fusesource.jansi" % "jansi" % "1.18"
)
}

val sqlite = "org.xerial" % "sqlite-jdbc" % "3.32.3.2"
val postgres = "org.tpolecat" %% "doobie-postgres" % Versions.doobie
val gcVision = "com.google.cloud" % "google-cloud-vision" % Versions.gcVision
val gcStorage = "com.google.cloud" % "google-cloud-storage" % Versions.gcStorage
val awsS3 = "software.amazon.awssdk" % "s3" % Versions.awsS3
val tesseract = "net.sourceforge.tess4j" % "tess4j" % "4.5.1"
val flyway = "org.flywaydb" % "flyway-core" % Versions.flyway
val circeFs2 = "io.circe" %% "circe-fs2" % Versions.circeFs2
val circeConfig = "io.circe" %% "circe-config" % Versions.circeConfig
val osLib = "com.lihaoyi" %% "os-lib" % Versions.osLib
val shapeless = "com.chuusai" %% "shapeless" % Versions.shapeless
val jodaTime = "joda-time" % "joda-time" % Versions.jodaDateTime
val scopt = "com.github.scopt" %% "scopt" % Versions.scopt
val jsoup = "org.jsoup" % "jsoup" % Versions.jsoup
val console4cats = "dev.profunktor" %% "console4cats" % "0.8.1"
val scopt = "com.github.scopt" %% "scopt" % Versions.scopt
}
22 changes: 11 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Search packages in maven through console, sbt style dependency string can be copied to clipboard

```bash
mvns cats
./mvns cats
```

```text
$ java -jar maven-search.jar cats
[1] org.typelevel : cats-tests_2.10 : 0.6.0-M1
[2] org.typelevel : cats-tests_2.11 : 0.6.0-M1
[3] org.typelevel : cats-tests_sjs0.6_2.10 : 0.6.0-M1
[4] org.typelevel : cats-tests_sjs0.6_2.11 : 0.6.0-M1
[5] org.typelevel : cats-docs_2.10 : 0.6.0-M1
[6] org.typelevel : cats-docs_2.11 : 0.6.0-M1
[7] org.typelevel : cats-bench_2.10 : 0.6.0-M1
[8] org.typelevel : cats-bench_2.11 : 0.6.0-M1
[9] dev.profunktor : redis4cats-log4cats_2.12 : 0.11.0
$ ./mvns cats
[1] org.typelevel %% cats-parse % 0.2-41-437af75
[2] org.typelevel %% cats-core % 2.3.1
[3] com.flowtick %% graphs-cats % 0.5.0
[4] org.typelevel %% cats-testkit % 2.3.1
[5] org.typelevel %% cats-core % 2.3.0-M2
[6] org.typelevel %%% cats-tests % 0.6.0-M1
[7] org.typelevel %% cats-tests % 0.6.0-M1
[8] org.scodec %% scodec-cats % 1.1.0-M4
[9] io.regadas %% scio-cats % 0.1.3
Page:1
Select a number to copy to clipboard (1 - 9, n:next page):
```
3 changes: 2 additions & 1 deletion src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
maven-search {
copyToClipboard = true
query = ""
chunkSize = 90
importFormat = "sbt"
debug = false
mavenUri = "https://search.maven.org/solrsearch/select"
itemPerPage = 9
clearScreen = true
}
30 changes: 20 additions & 10 deletions src/main/scala/com/deliganli/maven/search/Domain.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.deliganli.maven.search

import com.deliganli.maven.search.Domain.MavenModel.MavenDoc
import org.http4s.Uri

object Domain {

Expand All @@ -19,16 +18,27 @@ object Domain {
sealed trait ImportFormat

object ImportFormat {
class Sbt extends ImportFormat
class Maven extends ImportFormat
case object Sbt extends ImportFormat
//case object Maven extends ImportFormat
case object Generic extends ImportFormat
}

case class Config(
mavenUri: Uri,
chunkSize: Int,
itemPerPage: Int,
copyToClipboard: Boolean,
importFormat: ImportFormat,
debug: Boolean)
sealed trait ProgramEvent

object ProgramEvent {
case class Search(page: Int) extends ProgramEvent
case object Prompt extends ProgramEvent
case class Copy(selection: Int) extends ProgramEvent
case class Move(page: Int) extends ProgramEvent
case object Exit extends ProgramEvent
}

sealed trait UserEvent

object UserEvent {
case object Next extends UserEvent
case object Prev extends UserEvent
case class Selection(i: Int) extends UserEvent
}

}
Loading

0 comments on commit 37ef8cd

Please sign in to comment.