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

Commit

Permalink
Merge pull request #55 from stack-spot/release-1.0.0
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
matheusferreirazup authored Oct 6, 2022
2 parents a5f2a1f + 6979c85 commit 75b81f6
Show file tree
Hide file tree
Showing 32 changed files with 732 additions and 147 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@

## Releases

## [v1.0.0] - 2022-10-06
<!-- Release notes generated using configuration in .github/release.yaml at release-1.0.0 -->

### Exciting New Features 🎉
* Feature: Improve code coverage with unit tests by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/48
### Bug Fixes 🛠
* Bug Fix: Add mock for git config command runner by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/53


Full Changelog: https://github.com/stack-spot/stackspot-intellij-extension/compare/v0.1.4...v1.0.0

## [v0.1.4] - 2022-09-21
<!-- Release notes generated using configuration in .github/release.yaml at release-0.1.4 -->

### Exciting New Features 🎉
* Feature: Improve plugin description in marketplace page by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/19
* Feature: changed the documentation url inside the readme by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/22
* Feature: Created workflow to generate release notes and publish plugin by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/23
* Feature: Add Sonarqube and first unit tests by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/33

### Bug Fixes 🛠
* Bug fix: Project wizard always stuck in "no stackfiles panel" by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/17
* Bug fix: Stack url dialog by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/18
Expand All @@ -19,7 +30,8 @@
* Bug Fix: Moved changelog jobs into deploy prod workflow by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/28
* Bug Fix: Changed changelog extension in build gradle and disable buildSearchableOptions by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/29
* Bug Fix: Added project version property in update changelog command by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/30

### Other Changes
* Refactor: Change reusable workflows to use the main branch instead of release branch by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/24

Full Changelog: https://github.com/stack-spot/stackspot-intellij-extension/compare/v0.0.3...v0.1.4
Full Changelog: https://github.com/stack-spot/stackspot-intellij-extension/compare/v0.0.3...v0.1.4
48 changes: 46 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.changelog.date

fun properties(key: String) = project.findProperty(key).toString()
Expand Down Expand Up @@ -27,8 +28,11 @@ repositories {
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.0"))
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("io.mockk:mockk:1.13.1")
testImplementation("io.kotest:kotest-assertions-core:5.4.2")
testImplementation("org.awaitility:awaitility-kotlin:4.2.0")
}

kotlin {
Expand All @@ -52,8 +56,26 @@ intellij {
}

sonarqube {
val exclusions = listOf(
"**/com/stackspot/constants/**",
"**/com/stackspot/exceptions/**",
"**/com/stackspot/intellij/actions/**",
"**/com/stackspot/intellij/commands/git/**",
"**/com/stackspot/intellij/commands/listeners/**",
"**/com/stackspot/intellij/commands/stk/**",
"**/com/stackspot/intellij/listeners/**",
"**/com/stackspot/intellij/messaging/**",
"**/com/stackspot/intellij/ui/**",
"**/com/stackspot/model/Plugin.kt",
"**/com/stackspot/model/Stackfile.kt",
"**/com/stackspot/model/StackfilePlugin.kt",
"**/com/stackspot/model/StackfileUseCase.kt",
"**/com/stackspot/model/TemplateType.kt",
)

properties {
property("sonar.projectName", "ide-intellij-plugin")
property("sonar.coverage.exclusions", exclusions)
}
}

Expand Down Expand Up @@ -107,7 +129,7 @@ tasks {
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
finalizedBy(jacocoTestReport)
}
Expand All @@ -117,5 +139,27 @@ tasks {
reports {
xml.required.set(true)
}
classDirectories.setFrom(
files(classDirectories.files.map {
fileTree(it) {
exclude(
"com/stackspot/constants/*",
"com/stackspot/exceptions/*",
"com/stackspot/intellij/actions/*",
"com/stackspot/intellij/commands/git/*",
"com/stackspot/intellij/commands/listeners/*",
"com/stackspot/intellij/commands/stk/*",
"com/stackspot/intellij/listeners/*",
"com/stackspot/intellij/messaging/*",
"com/stackspot/intellij/ui/*",
"com/stackspot/model/Plugin.kt",
"com/stackspot/model/Stackfile.kt",
"com/stackspot/model/StackfilePlugin.kt",
"com/stackspot/model/StackfileUseCase.kt",
"com/stackspot/model/TemplateType.kt",
)
}
})
)
}
}
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ platformType = IC
platformVersion = 2022.1
platformPlugins = org.jetbrains.plugins.terminal, com.intellij.gradle, org.jetbrains.idea.maven

gradleVersion = 7.5.1
gradleVersion = 7.4

# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false
kotlin.stdlib.default.dependency = false

org.gradle.jvmargs=-Xmx2048M
1 change: 0 additions & 1 deletion src/main/kotlin/com/stackspot/constants/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.stackspot.constants

import java.nio.file.Path
import kotlin.io.path.Path
import kotlin.io.path.exists

object Constants {
const val MODULE_TYPE = "STACK_SPOT_TYPE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.util.ExecUtil.execAndGetOutput
import java.nio.charset.Charset

class BackgroundCommandRunner(private val workingDir: String) : CommandRunner {
class BackgroundCommandRunner(private var workingDir: String) : CommandRunner {

var stdout: String = ""
get() {
return field.replace("\\n".toRegex(), "")
}
lateinit var stderr: String
var exitCode: Int = 0
var timeout: Boolean = false
var cancelled: Boolean = false

override fun run(commandLine: List<String>, listener: CommandRunner.CommandEndedListener?) {
val generalCommandLine = GeneralCommandLine(commandLine)
Expand All @@ -36,6 +39,9 @@ class BackgroundCommandRunner(private val workingDir: String) : CommandRunner {
val processOutput = execAndGetOutput(generalCommandLine)
stdout = processOutput.stdout
stderr = processOutput.stderr
exitCode = processOutput.exitCode
timeout = processOutput.isTimeout
cancelled = processOutput.isCancelled
listener?.notifyEnded()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ package com.stackspot.intellij.commands.git

import com.stackspot.intellij.commands.BackgroundCommandRunner
import com.stackspot.intellij.commands.BaseCommand
import com.stackspot.model.Stack

class GitBranch(stack: Stack, private val flags: Array<String>) :
BaseCommand(BackgroundCommandRunner(stack.location.toPath().toString())) {
class GitBranch(var workingDir: String, private val flags: Array<String>) :
BaseCommand(BackgroundCommandRunner(workingDir)) {

override fun commandLine(): List<String> {
return listOf("git", "branch", *flags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package com.stackspot.intellij.commands.git
import com.stackspot.intellij.commands.BackgroundCommandRunner
import com.stackspot.intellij.commands.BaseCommand

class GitConfig(workingDirectory: String, private val flags: Array<String>) :
class GitConfig(var workingDirectory: String) :
BaseCommand(BackgroundCommandRunner(workingDirectory)) {

var flags: Array<String> = arrayOf()

override fun commandLine(): List<String> {
return listOf("git", "config", *flags)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,35 @@ import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

@Service
class CreateProjectService {
class CreateProjectService() {

var stack: Stack? = null
var stackfile: Stackfile? = null
val state: ProjectWizardState
get() {
return if (!Constants.Paths.STK_BIN.exists()) {
return if (!isInstalled) {
ProjectWizardState.NOT_INSTALLED
} else if (!ImportedStacks().hasStackFiles()) {
} else if (!importedStacks.hasStackFiles()) {
ProjectWizardState.STACKFILES_EMPTY
} else if (!isGitConfigOk()) {
ProjectWizardState.GIT_CONFIG_NOT_OK
} else {
ProjectWizardState.OK
}
}
private var isInstalled = Constants.Paths.STK_BIN.exists()
private var importedStacks = ImportedStacks()
private var gitConfigCmd = GitConfig(Constants.Paths.STK_HOME.toString())

constructor(
importedStacks: ImportedStacks = ImportedStacks(),
isInstalled: Boolean = Constants.Paths.STK_BIN.exists(),
gitConfigCmd: GitConfig = GitConfig(Constants.Paths.STK_HOME.toString())
) : this() {
this.importedStacks = importedStacks
this.isInstalled = isInstalled
this.gitConfigCmd = gitConfigCmd
}

fun isStackfileSelected(): Boolean = stack != null && stackfile != null

Expand All @@ -62,9 +75,11 @@ class CreateProjectService {
fun addGitConfig(username: String, email: String) {
val executor = Executors.newSingleThreadExecutor()
executor.submit {
val workingDir = Constants.Paths.STK_HOME.toString()
GitConfig(workingDir, arrayOf("--global", "user.name", "\"$username\"")).run()
GitConfig(workingDir, arrayOf("--global", "user.email", "\"$email\"")).run()
gitConfigCmd.flags = arrayOf("--global", "user.name", "\"$username\"")
gitConfigCmd.run()

gitConfigCmd.flags = arrayOf("--global", "user.email", "\"$email\"")
gitConfigCmd.run()
}
executor.shutdown()
}
Expand All @@ -87,14 +102,14 @@ class CreateProjectService {
}

private fun getEmailGitConfig(): String {
val gitConfigUserEmail = GitConfig(Constants.Paths.STK_HOME.toString(), arrayOf("--get", "user.email"))
gitConfigUserEmail.run()
return (gitConfigUserEmail.runner as BackgroundCommandRunner).stdout
gitConfigCmd.flags = arrayOf("--get", "user.email")
gitConfigCmd.run()
return (gitConfigCmd.runner as BackgroundCommandRunner).stdout
}

private fun getUsernameGitConfig(): String {
val gitConfigUserName = GitConfig(Constants.Paths.STK_HOME.toString(), arrayOf("--get", "user.name"))
gitConfigUserName.run()
return (gitConfigUserName.runner as BackgroundCommandRunner).stdout
gitConfigCmd.flags = arrayOf("--get", "user.name")
gitConfigCmd.run()
return (gitConfigCmd.runner as BackgroundCommandRunner).stdout
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.stackspot.intellij.services

import com.intellij.openapi.components.Service
import com.intellij.util.containers.isNullOrEmpty
import com.stackspot.constants.Constants
import com.stackspot.intellij.commands.BackgroundCommandRunner
import com.stackspot.intellij.commands.git.GitBranch
import com.stackspot.intellij.commands.git.GitConfig
Expand All @@ -27,9 +28,20 @@ import java.util.logging.Level
import java.util.logging.Logger

@Service
class GetDocumentationService {
class GetDocumentationService() {

companion object {
private var gitConfigCmd = GitConfig(Constants.Paths.STK_HOME.toString())
private var gitBranchCmd = GitBranch(Constants.Paths.STK_HOME.toString(), arrayOf("--show-current"))

constructor(
gitConfigCmd: GitConfig = GitConfig(Constants.Paths.STK_HOME.toString()),
gitBranchCmd: GitBranch = GitBranch(Constants.Paths.STK_HOME.toString(), arrayOf("--show-current"))
) : this() {
this.gitConfigCmd = gitConfigCmd
this.gitBranchCmd = gitBranchCmd
}

private companion object {
val LOGGER: Logger = Logger.getLogger(GetDocumentationService::class.java.name)
val REMOTE_URL_SSH_REGEX = Regex("(?i)(git@).*?.git")
}
Expand Down Expand Up @@ -71,13 +83,14 @@ class GetDocumentationService {
}

private fun getRemoteUrl(stack: Stack): String {
val gitRemoteCmd = GitConfig(stack.location.toPath().toString(), arrayOf("--get", "remote.origin.url"))
gitRemoteCmd.run()
return (gitRemoteCmd.runner as BackgroundCommandRunner).stdout
gitConfigCmd.workingDirectory = stack.location.toPath().toString()
gitConfigCmd.flags = arrayOf("--get", "remote.origin.url")
gitConfigCmd.run()
return (gitConfigCmd.runner as BackgroundCommandRunner).stdout
}

private fun getCurrentBranchName(stack: Stack): String {
val gitBranchCmd = GitBranch(stack, arrayOf("--show-current"))
gitBranchCmd.workingDir = stack.location.toPath().toString()
gitBranchCmd.run()
return (gitBranchCmd.runner as BackgroundCommandRunner).stdout
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ enum class RepositoryUriGenerator(private val domainName: Array<String>? = null)
}
};

abstract fun generateUri(branchName: String): String

companion object {
fun findByName(name: String): RepositoryUriGenerator =
RepositoryUriGenerator.values().find { enum -> enum.name.contains(name, ignoreCase = true) } ?: UNKNOWN
RepositoryUriGenerator.values()
.find { enum -> name.isNotEmpty() && enum.name.contains(name, ignoreCase = true) } ?: UNKNOWN

fun findByDomainName(domainName: String): RepositoryUriGenerator {
var repository: RepositoryUriGenerator = UNKNOWN
Expand All @@ -56,6 +59,4 @@ enum class RepositoryUriGenerator(private val domainName: Array<String>? = null)
}
}

abstract fun generateUri(branchName: String): String

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.ui.content.Content
import com.intellij.ui.content.ContentManager
import com.jediterm.terminal.model.TerminalModelListener
import com.stackspot.constants.Constants
Expand Down Expand Up @@ -65,10 +64,6 @@ class StackSpotTerminalCommandMonitoringTask(
}
widget.terminalTextBuffer.removeModelListener(this)
}

private fun hasRunningCommand(): Boolean {
return widget.ttyConnector != null && widget.hasRunningCommands()
}
}

class StackSpotTerminalRunner(private val project: Project, private val workingDir: String? = null) : CommandRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import javax.swing.JComponent

class StackSpotGitConfigErrorPanel(private val parentPanel: StackSpotParentPanel) {

lateinit var username: Cell<JBTextField>
lateinit var email: Cell<JBTextField>
private lateinit var username: Cell<JBTextField>
private lateinit var email: Cell<JBTextField>

fun getComponent(): JComponent {
return panel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.ui.components.JBScrollPane
import com.intellij.ui.dsl.builder.BottomGap
import com.intellij.ui.dsl.builder.Row
import com.intellij.ui.dsl.builder.TopGap
import com.intellij.ui.dsl.builder.panel
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/com/stackspot/model/Stack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ data class Stack(
it.isDirectory
}.filter {
val template = it.parseTemplateYaml(this)
template != null && (template.types.contains(TemplateType.APP.pluginType) || template.types.contains(
TemplateType.APP.pluginType
))
template != null && (template.types.contains(TemplateType.APP.pluginType))
}.mapNotNull {
it.parsePluginYaml(this)
}.toList()
Expand Down
Loading

0 comments on commit 75b81f6

Please sign in to comment.