Skip to content

Commit 5c974fa

Browse files
authored
Merge pull request #178 from adpi2/update-readme
Describe githubGenerateSnapshot in readme
2 parents a7a4a86 + 11d09d6 commit 5c974fa

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,32 @@ steps:
107107

108108
## Troubleshooting
109109

110+
### How to generate a snapshot locally?
111+
112+
For troubleshooting, it can be convenient to generate a snapshot locally.
113+
114+
To do so you need to install the `sbt-dependency-submission` plugin in your sbt project.
115+
116+
```scala
117+
// In project/plugins.sbt
118+
addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-submission" % "3.0.0")
119+
```
120+
121+
After reloading your build, you can run:
122+
```
123+
sbt:example> githubGenerateSnapshot
124+
...
125+
[info] Dependency snapshot written to /tmp/dependency-snapshot-3080240838874963577.json
126+
```
127+
128+
Or if you want to exclude some modules or configs:
129+
130+
```
131+
sbt:example> githubGenerateSnapshot {"ignoredModules":["server_2.13"], "ignoredConfigs":["test"]}
132+
...
133+
[info] Dependency snapshot written to /tmp/dependency-snapshot-14803616116503623758.json
134+
```
135+
110136
### Unexpected Status: 404
111137

112138
This error happens when the `Dependency Graph` feature is disabled.

sbt-plugin/build.sbt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ inThisBuild(
1717
},
1818
// Scalafix settings
1919
semanticdbEnabled := true,
20-
semanticdbVersion := scalafixSemanticdb.revision,
21-
scalafixDependencies ++= List(
22-
"com.github.liancheng" %% "organize-imports" % "0.6.0"
23-
)
20+
semanticdbVersion := scalafixSemanticdb.revision
2421
)
2522
)
2623

sbt-plugin/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import sjsonnew.support.scalajson.unsafe.{Parser => JsonParser, _}
2222

2323
object SubmitDependencyGraph {
2424
val Generate = "githubGenerateSnapshot"
25-
private val GenerateUsage = s"""$Generate {"projects":[], "scalaVersions":[]}"""
25+
private val GenerateUsage = s"""$Generate {"ignoredModules":[], "ignoredConfig":[]}"""
2626
private val GenerateDetail = "Generate the dependency graph of a set of projects and scala versions"
2727

2828
private val GenerateInternal = s"${Generate}Internal"
@@ -31,8 +31,6 @@ object SubmitDependencyGraph {
3131
val Submit = "githubSubmitSnapshot"
3232
private val SubmitDetail = "Submit the dependency graph to Github Dependency API."
3333

34-
def usage(command: String): String = s"""$command {"projects":[], "scalaVersions":[]}"""
35-
3634
val commands: Seq[Command] = Seq(
3735
Command(Generate, (GenerateUsage, GenerateDetail), GenerateDetail)(inputParser)(generate),
3836
Command.command(GenerateInternal, InternalOnly, InternalOnly)(generateInternal),
@@ -43,10 +41,13 @@ object SubmitDependencyGraph {
4341

4442
private def inputParser(state: State): Parser[DependencySnapshotInput] =
4543
Parsers.any.*.map { raw =>
46-
JsonParser
47-
.parseFromString(raw.mkString)
48-
.flatMap(Converter.fromJson[DependencySnapshotInput])
49-
.get
44+
val rawString = raw.mkString
45+
if (rawString.isEmpty) DependencySnapshotInput(None, Vector.empty, Vector.empty)
46+
else
47+
JsonParser
48+
.parseFromString(rawString)
49+
.flatMap(Converter.fromJson[DependencySnapshotInput])
50+
.get
5051
}.failOnException
5152

5253
private def generate(state: State, input: DependencySnapshotInput): State = {

0 commit comments

Comments
 (0)