Skip to content

Commit fcd54fe

Browse files
authored
Merge pull request #1 from antohaby/minor-ux-fixes
Update projectsDir option checker and make reporter to store all data in the reporterDir, instead of parent directory
2 parents 9cb438e + d2768ac commit fcd54fe

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.idea/codeStyles/codeStyleConfig.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/kotlin/DatalyzerCommand.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class DatalyzerCommand : CliktCommand() {
2828
private val gradleProjectDir: Path by option("--projectDir", help = "Location of the Gradle Project")
2929
.path()
3030
.default(Path(".").absolute())
31-
.check("Must be a directory, but was a file") { it.isDirectory() }
31+
.check("Must be a root directory of a Gradle Project") { it.exists() && it.isDirectory() }
3232

3333
private val reportsDir: Path by option("--reportsDir", help = "Output reports directory")
3434
.path()

src/main/kotlin/Reporter.kt

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package org.jetbrains.experimental.gradle.datalyzer
44

55
import com.github.ajalt.mordant.terminal.Terminal
6-
import org.jetbrains.experimental.gradle.datalyzer.utils.replaceNonAlphaNumeric
76
import java.io.BufferedOutputStream
87
import java.io.BufferedWriter
98
import java.io.File
@@ -13,19 +12,24 @@ import java.nio.file.StandardOpenOption.SYNC
1312
import java.util.zip.ZipEntry
1413
import java.util.zip.ZipOutputStream
1514
import kotlin.io.path.*
15+
import org.jetbrains.experimental.gradle.datalyzer.utils.replaceNonAlphaNumeric
1616

1717
/**
1818
* Gather information about the Gradle project, and save it to disk.
1919
*/
2020
internal class Reporter(
21-
private val reportsDir: Path,
21+
reportsDir: Path,
2222
private val terminal: Terminal,
2323
) {
24-
private val scripts = reportsDir.resolve("scripts.md")
25-
private val log = reportsDir.resolve("output.log")
24+
private val reportZip = reportsDir.resolve("${reportsDir.name}.zip")
25+
private val dataDir = reportsDir.resolve("data")
26+
27+
private val scripts = dataDir.resolve("scripts.md")
28+
private val log = dataDir.resolve("output.log")
2629

2730
init {
2831
reportsDir.createDirectories()
32+
dataDir.createDirectories()
2933
scripts.createFile()
3034
log.createFile()
3135
}
@@ -67,15 +71,15 @@ internal class Reporter(
6771

6872

6973
fun taskOutput(taskName: String): BufferedOutputStream {
70-
return reportsDir
74+
return dataDir
7175
.resolve("task-stdout-${taskName.replaceNonAlphaNumeric()}-${System.currentTimeMillis()}.txt")
7276
.createFile()
7377
.outputStream()
7478
.buffered()
7579
}
7680

7781
fun taskData(taskName: String): BufferedWriter {
78-
return reportsDir
82+
return dataDir
7983
.resolve("task-data-${taskName.replaceNonAlphaNumeric()}-${System.currentTimeMillis()}.txt")
8084
.createFile()
8185
.bufferedWriter()
@@ -100,15 +104,15 @@ internal class Reporter(
100104
}
101105

102106
fun zip(): Path {
103-
val zipFile = reportsDir.parent.resolve("${reportsDir.name}.zip").apply {
107+
val zipFile = reportZip.apply {
104108
if (exists()) deleteExisting()
105109
createFile()
106110
}
107111

108112
ZipOutputStream(zipFile.outputStream().buffered()).use { zip ->
109-
reportsDir.walk().forEach { src ->
113+
dataDir.walk().forEach { src ->
110114
val zipFileName = src.absolute().invariantSeparatorsPathString
111-
.removePrefix(reportsDir.absolute().invariantSeparatorsPathString)
115+
.removePrefix(dataDir.absolute().invariantSeparatorsPathString)
112116
.removePrefix("/")
113117
.let { if (src.isDirectory()) "$it/" else it }
114118

0 commit comments

Comments
 (0)