Skip to content

Describe githubGenerateSnapshot in readme #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 1 addition & 4 deletions sbt-plugin/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ inThisBuild(
},
// Scalafix settings
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalafixDependencies ++= List(
"com.github.liancheng" %% "organize-imports" % "0.6.0"
)
semanticdbVersion := scalafixSemanticdb.revision
)
)

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,10 +41,13 @@ object SubmitDependencyGraph {

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

private def generate(state: State, input: DependencySnapshotInput): State = {
Expand Down
Loading