Skip to content

Commit

Permalink
Make SynchronizeProject an action as well
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Sep 1, 2024
1 parent cb44bf1 commit 477a9ef
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
57 changes: 33 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
> It may or may not work.
> Use it at your own risk.
[![Build](https://github.com/InSyncWithFoo/ryecharm/actions/workflows/build.yaml/badge.svg)][4]
[![Docs](https://github.com/InSyncWithFoo/ryecharm/actions/workflows/docs.yaml/badge.svg)][5]
[![Build](https://github.com/InSyncWithFoo/ryecharm/actions/workflows/build.yaml/badge.svg)][5]
[![Docs](https://github.com/InSyncWithFoo/ryecharm/actions/workflows/docs.yaml/badge.svg)][6]
[![Version](https://img.shields.io/jetbrains/plugin/v/25230)][7]
[![Rating](https://img.shields.io/jetbrains/plugin/r/rating/25230)][8]
[![Downloads](https://img.shields.io/jetbrains/plugin/d/25230)][9]

<!-- Plugin description -->
The all-in-one PyCharm plugin for Astral-backed Python tools.
Expand All @@ -23,6 +26,8 @@ If you already have Ruff, uv and/or Rye installed,
you can start using this plugin the moment you install it.
The executables will be automatically detected.

See [the documentation][4] for more information.


## Logging

Expand All @@ -42,15 +47,16 @@ Add the following line to the <b>Help</b> |
[1]: https://github.com/astral-sh/ruff
[2]: https://github.com/astral-sh/uv
[3]: https://github.com/astral-sh/rye
[4]: https://insyncwithfoo.github.io/ryecharm
<!-- Plugin description end -->


## Installation

This plugin is not yet available on the Marketplace.
You can download the ZIP files manually from [the <i>Releases</i> tab][6],
[the `build` branch][7] or [the <i>Actions</i> tab][8]
and follow the instructions described [here][9].
This plugin is [available on the Marketplace][7] under the Nightly channel.
You can also download the ZIP files manually from [the <i>Releases</i> tab][10],
[the `build` branch][11] or [the <i>Actions</i> tab][12]
and follow the instructions described [here][13].

Currently supported versions:
2024.2 (build 242.20224.347) - 2024.3.* (build 243.*).
Expand All @@ -63,21 +69,24 @@ Parts of this repository were taken or derived from:
* [@astral-sh/ruff][1]
* [@astral-sh/rye][3]
* [@astral-sh/uv][2]
* [@JetBrains/intellij-community][10]
* [@JetBrains/intellij-platform-plugin-template][11]
* [@koxudaxi/poetry-pycharm-plugin][12]
* [@koxudaxi/ruff-pycharm-plugin][13]
* [@lensvol/intellij-blackconnect][14]


[4]: https://github.com/InSyncWithFoo/ryecharm/actions/workflows/build.yaml
[5]: https://github.com/InSyncWithFoo/ryecharm/actions/workflows/docs.yaml
[6]: https://github.com/InSyncWithFoo/ryecharm/releases
[7]: https://github.com/InSyncWithFoo/ryecharm/tree/build
[8]: https://github.com/InSyncWithFoo/ryecharm/actions/workflows/build.yaml
[9]: https://www.jetbrains.com/help/pycharm/managing-plugins.html#install_plugin_from_disk
[10]: https://github.com/JetBrains/intellij-community
[11]: https://github.com/JetBrains/intellij-platform-plugin-template
[12]: https://github.com/koxudaxi/poetry-pycharm-plugin
[13]: https://github.com/koxudaxi/ruff-pycharm-plugin
[14]: https://github.com/lensvol/intellij-blackconnect
* [@JetBrains/intellij-community][14]
* [@JetBrains/intellij-platform-plugin-template][15]
* [@koxudaxi/poetry-pycharm-plugin][16]
* [@koxudaxi/ruff-pycharm-plugin][17]
* [@lensvol/intellij-blackconnect][18]


[5]: https://github.com/InSyncWithFoo/ryecharm/actions/workflows/build.yaml
[6]: https://github.com/InSyncWithFoo/ryecharm/actions/workflows/docs.yaml
[7]: https://plugins.jetbrains.com/plugin/25230/versions
[8]: https://plugins.jetbrains.com/plugin/25230/reviews
[9]: https://plugins.jetbrains.com/plugin/25230
[10]: https://github.com/InSyncWithFoo/ryecharm/releases
[11]: https://github.com/InSyncWithFoo/ryecharm/tree/build
[12]: https://github.com/InSyncWithFoo/ryecharm/actions/workflows/build.yaml
[13]: https://www.jetbrains.com/help/pycharm/managing-plugins.html#install_plugin_from_disk
[14]: https://github.com/JetBrains/intellij-community
[15]: https://github.com/JetBrains/intellij-platform-plugin-template
[16]: https://github.com/koxudaxi/poetry-pycharm-plugin
[17]: https://github.com/koxudaxi/ruff-pycharm-plugin
[18]: https://github.com/lensvol/intellij-blackconnect
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package insyncwithfoo.ryecharm.uv.intentions

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
Expand All @@ -9,6 +11,7 @@ import insyncwithfoo.ryecharm.WriteIntentionAction
import insyncwithfoo.ryecharm.fileDocumentManager
import insyncwithfoo.ryecharm.isPyprojectToml
import insyncwithfoo.ryecharm.message
import insyncwithfoo.ryecharm.noProjectFound
import insyncwithfoo.ryecharm.notifyIfProcessIsUnsuccessfulOr
import insyncwithfoo.ryecharm.processCompletedSuccessfully
import insyncwithfoo.ryecharm.runInBackground
Expand All @@ -19,7 +22,7 @@ import insyncwithfoo.ryecharm.uv.commands.UV
import insyncwithfoo.ryecharm.uv.commands.uv


internal class SyncFromPyprojectToml : ExternalIntentionAction, WriteIntentionAction, DumbAware {
internal class SynchronizeProject : AnAction(), ExternalIntentionAction, WriteIntentionAction, DumbAware {

override fun getFamilyName() = message("intentions.uv.sync.familyName")

Expand All @@ -35,6 +38,13 @@ internal class SyncFromPyprojectToml : ExternalIntentionAction, WriteIntentionAc
project.runUVSyncAndReport(uv)
}

override fun actionPerformed(event: AnActionEvent) {
val project = event.project ?: return noProjectFound()
val uv = project.uv ?: return project.unableToRunCommand()

project.runUVSyncAndReport(uv)
}

private fun Project.runUVSyncAndReport(uv: UV) = runIntention {
val command = uv.sync()

Expand Down
11 changes: 10 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@

<intentionAction>
<language/>
<className>insyncwithfoo.ryecharm.uv.intentions.SyncFromPyprojectToml</className>
<className>insyncwithfoo.ryecharm.uv.intentions.SynchronizeProject</className>
<category>RyeCharm</category>
<skipBeforeAfter>true</skipBeforeAfter>
</intentionAction>
Expand Down Expand Up @@ -340,6 +340,15 @@
description="Show the output of `uv version`"
icon="AllIcons.General.ShowInfos"
/>

<!--suppress PluginXmlCapitalization -->
<action
id="insyncwithfoo.ryecharm.uv.intentions.SynchronizeProject"
class="insyncwithfoo.ryecharm.uv.intentions.SynchronizeProject"
text="uv: Synchronize project"
description="Run `uv sync`"
icon="com.intellij.icons.ExpUiIcons.General.Refresh"
/>
</actions>

<projectListeners>
Expand Down

0 comments on commit 477a9ef

Please sign in to comment.