Skip to content

Commit

Permalink
Describe githubGenerateSnapshot in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed May 15, 2024
1 parent a7a4a86 commit 354a3cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,32 @@ steps:

## Troubleshooting

### How to generate a snapshot locally?

For troubleshooting, it can be convenient to generate a snapshot locally.

To do so you need to install the `sbt-dependency-submission` plugin in your sbt project.

```scala
// In project/plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-submission" % "3.0.0")
```

After reloading your build, you can run:
```
sbt:example> githubGenerateSnapshot
...
[info] Dependency snapshot written to /tmp/dependency-snapshot-3080240838874963577.json
```

Or if you want to exclude some modules or configs:

```
sbt:example> githubGenerateSnapshot {"ignoredModules":["server_2.13"], "ignoredConfigs":["test"]}
...
[info] Dependency snapshot written to /tmp/dependency-snapshot-14803616116503623758.json
```

### Unexpected Status: 404

This error happens when the `Dependency Graph` feature is disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import sjsonnew.support.scalajson.unsafe.{Parser => JsonParser, _}

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

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

def usage(command: String): String = s"""$command {"projects":[], "scalaVersions":[]}"""

val commands: Seq[Command] = Seq(
Command(Generate, (GenerateUsage, GenerateDetail), GenerateDetail)(inputParser)(generate),
Command.command(GenerateInternal, InternalOnly, InternalOnly)(generateInternal),
Expand All @@ -43,8 +41,10 @@ object SubmitDependencyGraph {

private def inputParser(state: State): Parser[DependencySnapshotInput] =
Parsers.any.*.map { raw =>
JsonParser
.parseFromString(raw.mkString)
val rawString = raw.mkString
if (rawString.isEmpty) DependencySnapshotInput(None, Vector.empty, Vector.empty)
else JsonParser
.parseFromString(rawString)
.flatMap(Converter.fromJson[DependencySnapshotInput])
.get
}.failOnException
Expand Down

0 comments on commit 354a3cf

Please sign in to comment.