Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit a60bbca

Browse files
Merge pull request #60 from stack-spot/bug/sc-390954/ide-intellij-ajuste-project-wizard-link-documentação
Bug Fix: Documentation link in project wizard was not visible
2 parents 14960ae + 692f2f2 commit a60bbca

File tree

18 files changed

+77
-75
lines changed

18 files changed

+77
-75
lines changed

src/main/kotlin/com/stackspot/intellij/commands/BackgroundCommandRunner.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.stackspot.intellij.commons.singleThreadAsCoroutine
2323
import kotlinx.coroutines.Deferred
2424
import java.nio.charset.Charset
2525

26-
class BackgroundCommandRunner(private var workingDir: String? = null) : CommandRunner {
26+
class BackgroundCommandRunner : CommandRunner {
2727

2828
var stdout: String = ""
2929
get() {
@@ -34,11 +34,11 @@ class BackgroundCommandRunner(private var workingDir: String? = null) : CommandR
3434
var timeout: Boolean = false
3535
var cancelled: Boolean = false
3636

37-
override fun run(commandLine: List<String>, listener: CommandRunner.CommandEndedListener?) {
37+
override fun run(commandLine: List<String>, listener: CommandRunner.CommandEndedListener?, workingDir: String?) {
3838
val generalCommandLine = GeneralCommandLine(commandLine)
3939
.withCharset(Charset.forName("UTF-8"))
4040
.withWorkDirectory(workingDir)
41-
.withEnvironment(CommandRunner.STK_CHANNEL_ENVIRONMENT_VARIABLE, CommandRunner.STK_CHANNLE_INTELLIJ)
41+
.withEnvironment(CommandRunner.STK_CHANNEL_ENVIRONMENT_VARIABLE, CommandRunner.STK_CHANNEL_INTELLIJ)
4242
val processOutput = execAndGetOutput(generalCommandLine)
4343
stdout = processOutput.stdout
4444
stderr = processOutput.stderr
@@ -51,14 +51,14 @@ class BackgroundCommandRunner(private var workingDir: String? = null) : CommandR
5151
private fun replaceStdout(stdout: String) =
5252
stdout.replace("\\n".toRegex(), "")
5353

54-
override fun runSync(commandLine: List<String>): BackgroundCommandRunner {
54+
override fun runSync(commandLine: List<String>, workingDir: String?): BackgroundCommandRunner {
5555
return singleThread {
5656
var done = false
5757
run(commandLine, object : CommandRunner.CommandEndedListener {
5858
override fun notifyEnded() {
5959
done = true
6060
}
61-
})
61+
}, workingDir)
6262

6363
while (!done) {
6464
Thread.sleep(1L)
@@ -67,16 +67,14 @@ class BackgroundCommandRunner(private var workingDir: String? = null) : CommandR
6767
}
6868
}
6969

70-
override suspend fun runAsync(
71-
commandLine: List<String>
72-
): Deferred<BackgroundCommandRunner> {
70+
override suspend fun runAsync(commandLine: List<String>,workingDir: String?): Deferred<BackgroundCommandRunner> {
7371
var done = false
7472
return singleThreadAsCoroutine {
7573
this.run(commandLine, object : CommandRunner.CommandEndedListener {
7674
override fun notifyEnded() {
7775
done = true
7876
}
79-
})
77+
}, workingDir)
8078
this
8179
}
8280
}

src/main/kotlin/com/stackspot/intellij/commands/BaseCommand.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import kotlinx.coroutines.Deferred
2020

2121
abstract class BaseCommand(val runner: CommandRunner) : Command {
2222
abstract fun commandLine(): List<String>
23-
override fun run(listener: CommandRunner.CommandEndedListener?) = runner.run(commandLine(), listener)
24-
override fun runSync(): BackgroundCommandRunner = runner.runSync(commandLine())
25-
override suspend fun runAsync(): Deferred<BackgroundCommandRunner> = runner.runAsync(commandLine())
23+
override fun run(listener: CommandRunner.CommandEndedListener?, workingDir: String?) =
24+
runner.run(commandLine(), listener, workingDir)
25+
26+
override fun runSync(workingDir: String?): BackgroundCommandRunner = runner.runSync(commandLine(), workingDir)
27+
override suspend fun runAsync(workingDir: String?): Deferred<BackgroundCommandRunner> =
28+
runner.runAsync(commandLine(), workingDir)
2629
}

src/main/kotlin/com/stackspot/intellij/commands/Command.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
package com.stackspot.intellij.commands
1818

19+
import com.stackspot.constants.Constants
1920
import kotlinx.coroutines.Deferred
2021

2122
interface Command {
22-
fun run(listener: CommandRunner.CommandEndedListener? = null)
23+
fun run(listener: CommandRunner.CommandEndedListener? = null, workingDir: String? = Constants.Paths.STK_HOME.toString())
2324

24-
fun runSync(): BackgroundCommandRunner
25+
fun runSync(workingDir: String? = Constants.Paths.STK_HOME.toString()): BackgroundCommandRunner
2526

26-
suspend fun runAsync(): Deferred<BackgroundCommandRunner>
27+
suspend fun runAsync(workingDir: String? = Constants.Paths.STK_HOME.toString()): Deferred<BackgroundCommandRunner>
2728

2829
}

src/main/kotlin/com/stackspot/intellij/commands/CommandRunner.kt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,33 @@
1616

1717
package com.stackspot.intellij.commands
1818

19+
import com.stackspot.constants.Constants
1920
import kotlinx.coroutines.Deferred
2021

21-
2222
interface CommandRunner {
2323

2424
companion object {
25-
val STK_CHANNEL_ENVIRONMENT_VARIABLE = "STK_CHANNEL"
26-
val STK_CHANNLE_INTELLIJ = "intellij"
25+
const val STK_CHANNEL_ENVIRONMENT_VARIABLE = "STK_CHANNEL"
26+
const val STK_CHANNEL_INTELLIJ = "intellij"
2727
}
2828

2929
interface CommandEndedListener {
3030
fun notifyEnded()
3131
}
3232

33-
fun run(commandLine: List<String>, listener: CommandEndedListener? = null)
34-
35-
fun runSync(commandLine: List<String>): BackgroundCommandRunner
36-
suspend fun runAsync(commandLine: List<String>): Deferred<BackgroundCommandRunner>
33+
fun run(
34+
commandLine: List<String>,
35+
listener: CommandEndedListener? = null,
36+
workingDir: String? = Constants.Paths.STK_HOME.toString()
37+
)
38+
39+
fun runSync(
40+
commandLine: List<String>,
41+
workingDir: String? = Constants.Paths.STK_HOME.toString()
42+
): BackgroundCommandRunner
43+
44+
suspend fun runAsync(
45+
commandLine: List<String>,
46+
workingDir: String? = Constants.Paths.STK_HOME.toString()
47+
): Deferred<BackgroundCommandRunner>
3748
}

src/main/kotlin/com/stackspot/intellij/commands/git/GitBranch.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ package com.stackspot.intellij.commands.git
1919
import com.stackspot.intellij.commands.BackgroundCommandRunner
2020
import com.stackspot.intellij.commands.BaseCommand
2121

22-
class GitBranch(var workingDir: String, private val flags: Array<String>) :
23-
BaseCommand(BackgroundCommandRunner(workingDir)) {
22+
class GitBranch(private val flags: Array<String>) : BaseCommand(BackgroundCommandRunner()) {
2423

2524
override fun commandLine(): List<String> {
2625
return listOf("git", "branch", *flags)

src/main/kotlin/com/stackspot/intellij/commands/git/GitConfig.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ package com.stackspot.intellij.commands.git
1919
import com.stackspot.intellij.commands.BackgroundCommandRunner
2020
import com.stackspot.intellij.commands.BaseCommand
2121

22-
class GitConfig(var workingDirectory: String) :
23-
BaseCommand(BackgroundCommandRunner(workingDirectory)) {
22+
class GitConfig : BaseCommand(BackgroundCommandRunner()) {
2423

2524
var flags: Array<String> = arrayOf()
2625

src/main/kotlin/com/stackspot/intellij/commands/stk/CommandInfoList.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import com.stackspot.intellij.commands.BackgroundCommandRunner
2020
import com.stackspot.intellij.commands.BaseCommand
2121
import org.apache.commons.lang3.StringUtils
2222

23-
class CommandInfoList(
24-
workingDir: String? = null
25-
): BaseCommand(BackgroundCommandRunner(workingDir)) {
23+
class CommandInfoList: BaseCommand(BackgroundCommandRunner()) {
2624

2725
var command: String = StringUtils.EMPTY
28-
var flags: Array<String> = arrayOf()
26+
private var flags: Array<String> = arrayOf()
2927

3028
override fun commandLine() = listOf("stk", "list", command, "--json", *flags)
3129
}

src/main/kotlin/com/stackspot/intellij/commands/stk/CreateProjectByStackfile.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import com.stackspot.intellij.commands.BaseCommand
2121
import com.stackspot.intellij.ui.StackSpotTerminalRunner
2222
import com.stackspot.model.Stack
2323
import com.stackspot.model.Stackfile
24-
import kotlin.io.path.Path
2524

2625
class CreateProjectByStackfile(
2726
private val project: Project,
2827
private val stack: Stack,
2928
private val stackfile: Stackfile
30-
) : BaseCommand(StackSpotTerminalRunner(project, Path(project.basePath!!).parent.toString())) {
29+
) : BaseCommand(StackSpotTerminalRunner(project)) {
3130

3231
override fun commandLine(): List<String> {
3332
return listOf(

src/main/kotlin/com/stackspot/intellij/commands/stk/DeleteStack.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ import com.stackspot.model.Stack
2323

2424
class DeleteStack(private val stack: Stack, private val project: Project) :
2525
BaseCommand(StackSpotTerminalRunner(project)) {
26-
override fun commandLine() = listOf("stk", "delete", "stack", "${stack.name}")
26+
override fun commandLine() = listOf("stk", "delete", "stack", stack.name)
2727
}

src/main/kotlin/com/stackspot/intellij/commands/stk/UpdateAllStacks.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project
2020
import com.stackspot.intellij.commands.BaseCommand
2121
import com.stackspot.intellij.ui.StackSpotTerminalRunner
2222

23-
class UpdateAllStacks(private val project: Project) :
24-
BaseCommand(StackSpotTerminalRunner(project)) {
23+
class UpdateAllStacks(project: Project) : BaseCommand(StackSpotTerminalRunner(project)) {
2524
override fun commandLine() = listOf("stk", "update", "stack")
2625
}

0 commit comments

Comments
 (0)