This repository has been archived by the owner on Nov 1, 2021. It is now read-only.
forked from archived-codacy/codacy-eslint-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
executable file
·148 lines (127 loc) · 5.85 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd}
name := "codacy-eslint"
version := "1.0.0-SNAPSHOT"
val languageVersion = "2.12.6"
scalaVersion := languageVersion
resolvers ++= Seq("Sonatype OSS Snapshots".at("https://oss.sonatype.org/content/repositories/releases"),
"Typesafe Repo".at("http://repo.typesafe.com/typesafe/releases/"))
libraryDependencies ++= Seq(("com.codacy" %% "codacy-engine-scala-seed" % "3.0.183").withSources(),
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withSources())
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
version in Docker := "1.0.0-SNAPSHOT"
organization := "com.codacy"
lazy val toolVersion = taskKey[String]("Retrieve the version of the underlying tool from patterns.json")
toolVersion := {
import better.files.File
import play.api.libs.json.{JsString, JsValue, Json}
val jsonFile = resourceDirectory.in(Compile).value / "docs" / "patterns.json"
val patternsJsonValues = Json.parse(File(jsonFile.toPath).contentAsString).as[Map[String, JsValue]]
patternsJsonValues
.collectFirst {
case ("version", JsString(version)) => version
}
.getOrElse(throw new Exception("Failed to retrieve version from docs/patterns.json"))
}
def installAll(toolVersion: String) =
s"""apk update &&
|apk add bash curl nodejs-npm &&
|npm install -g npm@5 &&
|npm install -g eslint@$toolVersion &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g [email protected] &&
|npm install -g @prodigy/eslint-config-prodigy &&
|rm -rf /tmp/* &&
|rm -rf /var/cache/apk/*""".stripMargin
.replaceAll(System.lineSeparator(), " ")
mappings.in(Universal) ++= resourceDirectory
.in(Compile)
.map { resourceDir: File =>
val src = resourceDir / "docs"
val dest = "/docs"
(for {
path <- better.files.File(src.toPath).listRecursively()
if !path.isDirectory
} yield path.toJava -> path.toString.replaceFirst(src.toString, dest)).toSeq
}
.value
val dockerUser = "docker"
val dockerGroup = "docker"
daemonUser in Docker := dockerUser
daemonGroup in Docker := dockerGroup
dockerBaseImage := "openjdk:8-jre-alpine"
dockerCommands := {
dockerCommands.dependsOn(toolVersion).value.flatMap {
case cmd @ Cmd("ADD", _) =>
List(Cmd("RUN", s"adduser -u 2004 -D $dockerUser"),
cmd,
Cmd("RUN", installAll(toolVersion.value)),
Cmd("RUN", "mv /opt/docker/docs /docs"),
ExecCmd("RUN", Seq("chown", "-R", s"$dockerUser:$dockerGroup", "/docs"): _*),
Cmd("ENV", "NODE_PATH /usr/lib/node_modules"))
case other => List(other)
}
}