Skip to content

Commit 354a3cf

Browse files
committed
Describe githubGenerateSnapshot in readme
1 parent a7a4a86 commit 354a3cf

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
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/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala

Lines changed: 5 additions & 5 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,8 +41,10 @@ object SubmitDependencyGraph {
4341

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

0 commit comments

Comments
 (0)