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

Commit 692ac50

Browse files
merge: solved merge with release-0.1.4
Signed-off-by: Matheus Ferreira <matheus.ferreira@zup.com.br>
2 parents 252c96b + 09ec1c0 commit 692ac50

File tree

11 files changed

+92
-33
lines changed

11 files changed

+92
-33
lines changed

.github/release.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ changelog:
1919
labels:
2020
- ignore-for-release
2121
categories:
22-
- title: Breaking Changes 🛠
22+
- title: Breaking Changes 💥
2323
labels:
2424
- breaking-change
2525
- title: Exciting New Features 🎉
2626
labels:
2727
- enhancement
28+
- title: Bug Fixes 🛠
29+
labels:
30+
- bug
2831
- title: Other Changes
2932
labels:
3033
- "*"

.github/workflows/check-callback.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ jobs:
5555
"description": "Internal error",
5656
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
5757
}'
58-
58+
5959
PUSBLISH:
60-
if: ${{ success() && github.event.event_type == 'RELEASED' }}
60+
if: ${{ success() && github.event.event_type == 'RELEASED' }}
6161
uses: stack-spot/stackspot-intellij-extension/.github/workflows/publish-release.yml@main
6262
secrets:
63-
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
64-
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
65-
CHANNEL: ${{ secrets.CHANNEL }}
63+
accessToken: ${{ secrets.ACCESS_TOKEN }}
64+
publishToken: ${{ secrets.PUBLISH_TOKEN }}
65+
marketplaceChannel: ${{ secrets.MARKETPLACE_CHANNEL }}

.github/workflows/publish-release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ name: Publish Release
1919
on:
2020
workflow_call:
2121
secrets:
22-
ACCESS_TOKEN:
22+
accessToken:
2323
required: true
24-
PUBLISH_TOKEN:
24+
publishToken:
2525
required: true
26-
CHANNEL:
26+
marketplaceChannel:
2727
required: true
2828

2929
concurrency:
@@ -67,8 +67,8 @@ jobs:
6767
# Publish the plugin to the Marketplace
6868
- name: Publish Plugin
6969
env:
70-
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
71-
CHANNEL: ${{ secrets.CHANNEL }}
70+
PUBLISH_TOKEN: ${{ secrets.publishToken }}
71+
MARKETPLACE_CHANNEL: ${{ secrets.marketplaceChannel }}
7272
run: |
7373
TAG=${{ github.event.release.tag_name }}
7474
TAG="${TAG//v/""}"
@@ -77,7 +77,7 @@ jobs:
7777
# Upload artifact as a release asset
7878
- name: Upload Release Asset
7979
env:
80-
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
80+
GITHUB_TOKEN: ${{ secrets.accessToken }}
8181
run: |
8282
gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
8383
@@ -104,7 +104,7 @@ jobs:
104104
- name: Create Pull Request
105105
if: ${{ needs.EXPORT_PROPERTIES.outputs.changelog != '' }}
106106
env:
107-
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
107+
GITHUB_TOKEN: ${{ secrets.accessToken }}
108108
run: |
109109
VERSION="${{ github.event.release.tag_name }}"
110110
BRANCH="changelog-update-$VERSION"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Using StackSpot tool window after project opened:
6666
## **Documentation**
6767

6868
Check our official documentation page to use StackSpot IntelliJ plugin:
69-
[Documentation link](https://docs.stackspot.com/latest/)
69+
[Documentation link](https://docs.stackspot.com/latest/docs/extensions-for-ide/intellij/)
7070

7171
## **Contributing**
7272

src/main/kotlin/com/stackspot/constants/Constants.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,5 @@ object Constants {
3838
val USER_HOME: Path = Path(System.getProperty("user.home"))
3939
val STK_HOME: Path = USER_HOME.resolve(".stk")
4040
val STK_BIN: Path = STK_HOME.resolve("bin")
41-
val STACKS_DIR: Path = if (STK_HOME.resolve("stacks").exists()) {
42-
STK_HOME.resolve("stacks")
43-
} else {
44-
STK_HOME.resolve("plugins")
45-
}
4641
}
4742
}

src/main/kotlin/com/stackspot/intellij/actions/ImportStackAction.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import com.intellij.openapi.project.DumbAware
2222
import com.intellij.openapi.ui.Messages
2323
import com.stackspot.intellij.commands.listeners.NotifyStacksUpdatedCommandListener
2424
import com.stackspot.intellij.commands.stk.ImportStack
25+
import com.stackspot.intellij.commons.ErrorDialog
26+
import com.stackspot.intellij.commons.InputDialog.REPOSITORY_URL
27+
import com.stackspot.intellij.commons.isUrlValid
2528
import com.stackspot.intellij.ui.Icons
2629
import com.stackspot.intellij.ui.StackSpotTerminalRunner
2730

@@ -30,14 +33,20 @@ const val IMPORT_STACK = "Import Stack"
3033

3134
class ImportStackAction : AnAction(IMPORT_STACK, IMPORT_STACK, Icons.IMPORT_STACK), DumbAware {
3235
override fun actionPerformed(e: AnActionEvent) {
33-
val stackUrl = askForStackUrl()
36+
val stackUrl = askForStackUrl() ?: return
37+
38+
if (!stackUrl.isUrlValid()) {
39+
Messages.showErrorDialog(ErrorDialog.URL_IS_NOT_VALID_MESSAGE, ErrorDialog.URL_IS_NOT_VALID_TITLE)
40+
return
41+
}
42+
3443
val project = e.project
35-
if (stackUrl != null && project != null) {
44+
if (project != null) {
3645
ImportStack(stackUrl, StackSpotTerminalRunner(project)).run(NotifyStacksUpdatedCommandListener())
3746
}
3847
}
3948

4049
private fun askForStackUrl(): String? {
41-
return Messages.showInputDialog("Enter Stack GIT URL To Import", IMPORT_STACK, Messages.getQuestionIcon())
50+
return Messages.showInputDialog(REPOSITORY_URL, IMPORT_STACK, Messages.getQuestionIcon())
4251
}
4352
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.stackspot.intellij.commons
2+
3+
object InputDialog {
4+
const val REPOSITORY_URL = "Insert a stack repository URL"
5+
}
6+
7+
object ErrorDialog {
8+
const val URL_IS_NOT_VALID_MESSAGE = "Requested URL is not valid"
9+
const val URL_IS_NOT_VALID_TITLE = "Invalid URL"
10+
}
11+
12+
fun String?.isUrlValid(): Boolean {
13+
val regex = """((git|ssh|https)|(git@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?""".toRegex()
14+
return (this?.isNotEmpty() == true) && regex.matches(this)
15+
}

src/main/kotlin/com/stackspot/intellij/services/CreateProjectService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CreateProjectService {
3737
get() {
3838
return if (!Constants.Paths.STK_BIN.exists()) {
3939
ProjectWizardState.NOT_INSTALLED
40-
} else if (ImportedStacks().list().isEmpty()) {
40+
} else if (!ImportedStacks().hasStackFiles()) {
4141
ProjectWizardState.STACKFILES_EMPTY
4242
} else if (!isGitConfigOk()) {
4343
ProjectWizardState.GIT_CONFIG_NOT_OK

src/main/kotlin/com/stackspot/intellij/ui/project_wizard/panels/StackSpotNoStackfilesErrorPanel.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import com.stackspot.intellij.actions.IMPORT_STACK
2424
import com.stackspot.intellij.commands.BackgroundCommandRunner
2525
import com.stackspot.intellij.commands.listeners.NotifyProjectWizardImportedStack
2626
import com.stackspot.intellij.commands.stk.ImportStack
27+
import com.stackspot.intellij.commons.ErrorDialog.URL_IS_NOT_VALID_MESSAGE
28+
import com.stackspot.intellij.commons.ErrorDialog.URL_IS_NOT_VALID_TITLE
29+
import com.stackspot.intellij.commons.InputDialog.REPOSITORY_URL
30+
import com.stackspot.intellij.commons.isUrlValid
2731
import java.util.concurrent.Executors
2832
import javax.swing.JComponent
2933

@@ -33,7 +37,7 @@ class StackSpotNoStackfilesErrorPanel(val parentPanel: StackSpotParentPanel) {
3337
return panel {
3438
row {
3539
text(
36-
"In order to create a StackSpot project, you need to have stacks imported.",
40+
"In order to create a StackSpot project, you need to have stacks imported with <b>stackfiles.</b>",
3741
maxLineLength = 80
3842
)
3943
}
@@ -57,20 +61,25 @@ class StackSpotNoStackfilesErrorPanel(val parentPanel: StackSpotParentPanel) {
5761
}
5862

5963
private fun askForStackUrl(): String? {
60-
return Messages.showInputDialog("Enter Stack GIT URL To Import", IMPORT_STACK, Messages.getQuestionIcon())
64+
return Messages.showInputDialog(REPOSITORY_URL, IMPORT_STACK, Messages.getQuestionIcon())
6165
}
6266

6367
private fun runImportStack() {
64-
val url = askForStackUrl()
68+
val url = askForStackUrl() ?: return
69+
70+
if (!url.isUrlValid()) {
71+
Messages.showErrorDialog(URL_IS_NOT_VALID_MESSAGE, URL_IS_NOT_VALID_TITLE)
72+
return
73+
}
74+
6575
parentPanel.showImportingStack()
76+
6677
val executor = Executors.newSingleThreadExecutor()
6778
executor.submit {
68-
if (!url.isNullOrEmpty()) {
6979
ImportStack(url, BackgroundCommandRunner(Constants.Paths.STK_HOME.toString()))
7080
.run(NotifyProjectWizardImportedStack(parentPanel))
71-
}
7281
}
7382
executor.shutdown()
7483
}
7584

76-
}
85+
}

src/main/kotlin/com/stackspot/model/ImportedStacks.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ package com.stackspot.model
1818

1919
import com.stackspot.constants.Constants
2020
import com.stackspot.yaml.parseStackYaml
21+
import java.nio.file.Path
22+
import kotlin.io.path.exists
2123

2224
class ImportedStacks {
2325

26+
fun hasStackFiles() = list().any { it.listStackfiles().isNotEmpty() }
27+
2428
fun list(): List<Stack> {
25-
val stacksDir = Constants.Paths.STACKS_DIR.toFile()
29+
val stacksDir = getStacksDirPath().toFile()
2630
return stacksDir.walk().filter {
2731
it.isDirectory
2832
}.mapNotNull {
@@ -35,4 +39,15 @@ class ImportedStacks {
3539
fun getByName(name: String): Stack? {
3640
return list().firstOrNull { it.name == name }
3741
}
42+
43+
private fun getStacksDirPath(): Path {
44+
val stkHome = Constants.Paths.STK_HOME
45+
val stacks = stkHome.resolve("stacks")
46+
val stackDir: Path = if (stacks.exists()) {
47+
stacks
48+
} else {
49+
stkHome.resolve("plugins")
50+
}
51+
return stackDir
52+
}
3853
}

0 commit comments

Comments
 (0)