Skip to content

Commit d5465c1

Browse files
authored
Merge branch 'plugin_api_v2' into add_virus_toal_scan
2 parents ad0fdca + 8562a63 commit d5465c1

File tree

171 files changed

+4580
-3029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+4580
-3029
lines changed

.github/workflows/links.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ jobs:
3030
with:
3131
args: --verbose --no-progress plugins.json
3232
fail: true
33+
failIfEmpty: false
3334
token: ${{ secrets.LINKCHECKER }}

.github/workflows/python-passed.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ jobs:
1919
uses: actions/setup-python@v5
2020
with:
2121
python-version: 3.x
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r ./ci/envs/requirements-update-tested.txt
2226
- name: Run script
23-
run: python ./ci/src/update-tested.py
27+
run: python ./ci/src/update-tested.py ${{ secrets.DISCORD_WEBHOOK }}
2428
- name: Update plugin manifest
2529
if: success()
2630
uses: stefanzweifel/git-auto-commit-action@v4

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
uses: actions/setup-python@v5
4848
with:
4949
python-version: ${{ github.event.inputs.pyversion }}
50-
- uses: actions/cache@v2
50+
- uses: actions/cache@v4
5151
if: startsWith(runner.os, 'Windows')
5252
with:
5353
path: ~\AppData\Local\pip\Cache
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deploy Website
2+
3+
on:
4+
push:
5+
branches: [ plugin_api_v2 ]
6+
paths:
7+
- 'plugins.json'
8+
workflow_dispatch:
9+
10+
jobs:
11+
dispatch:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Dispatch event
15+
run: |
16+
http_status=$(curl -L -f -s -o /dev/null -w "%{http_code}" \
17+
-X POST \
18+
-H "Accept: application/vnd.github+json" \
19+
-H "Authorization: Bearer ${{ secrets.DEPLOY_WEBSITE }}" \
20+
https://api.github.com/repos/Flow-Launcher/flow-launcher.github.io/dispatches \
21+
-d '{"event_type":"deploy"}')
22+
if [ "$http_status" -ne 204 ]; then echo "Error: Deploy trigger failed, HTTP status code is $http_status"; exit 1; fi

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ This repository contains the information for community-made plugins used in [Flo
66

77
## Plugin list
88

9-
Looking for a list of currently available plugins in Flow? Visit [here](https://flow-launcher.github.io/docs/#/plugins)
9+
Looking for a list of currently available plugins in Flow? Visit [here](https://www.flowlauncher.com/plugins)
1010

1111
## How to submit your plugin
1212

13-
1. Create a file named `${name}-${uuid}.json` in the _plugins_ directory.
14-
2. Copy these items from your plugin project's plugin.json file:
13+
1. Create a file named `${name}-${uuid}.json` in the [plugins](https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest/tree/plugin_api_v2/plugins) directory.
14+
2. Copy these items from your plugin project's `plugin.json` file:
1515
- `ID`
1616
- `Name`
1717
- `Description`
@@ -23,16 +23,16 @@ Looking for a list of currently available plugins in Flow? Visit [here](https://
2323
4. It should look like this:
2424
```json
2525
{
26-
"ID": "Unique GUID from your plugin.json",
27-
"Name": "Plugin name",
28-
"Description": "Short description",
29-
"Author": "Author",
30-
"Version": "Version from your plugin.json",
31-
"Language": "Programming language",
32-
"Website": "Plugin website",
33-
"UrlDownload": "URL to download",
34-
"UrlSourceCode": "URL to source code",
35-
"IcoPath": "Plugin icon image's CDN URL, e.g. https://cdn.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Images/explorer.png"
26+
"ID": "Unique GUID from your plugin.json, e.g. 2f4e384e-76ce-45c3-aea2-b16f5e5c328f",
27+
"Name": "Plugin name, e.g. Hello World Python",
28+
"Description": "Short description, e.g. Python Hello World example plugin",
29+
"Author": "Author, e.g. Flow Launcher",
30+
"Version": "Version from your plugin.json, e.g. 1.0.0",
31+
"Language": "Programming language, e.g. python",
32+
"Website": "Plugin website, e.g. https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldPython",
33+
"UrlDownload": "URL to download, e.g. https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldPython/releases/download/v1.0.0/Flow.Launcher.Plugin.HelloWorldPython.zip",
34+
"UrlSourceCode": "URL to source code, e.g. https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldPython/tree/main",
35+
"IcoPath": "Plugin icon image's CDN URL, e.g. https://cdn.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldPython@main/Images/app.png"
3636
}
3737
```
3838
5. For `IcoPath`, use a CDN provider for global accessibility. [jsdelivr.com](https://www.jsdelivr.com/) for example as shown above, works well with GitHub repositories.
@@ -49,6 +49,8 @@ While the plugin has not yet appeared in the store, you and your users can manua
4949

5050
Every three hours the *CI* in this repository will check for new updates from plugins and automatically update them to the latest version.
5151

52+
So you do not need to manually submit a pull request after you make a new release.
53+
5254
## Plugin Store policy
5355

5456
Plugins that facilitate or contain any of the following will not be allowed:
@@ -65,7 +67,7 @@ Plugins that facilitate or contain any of the following will not be allowed:
6567
## Plugin Store
6668

6769
Users will be able to install your plugin via the store or type `pm install <your-plugin-name>`:
68-
<p align="center"><img src="https://user-images.githubusercontent.com/6903107/207155616-d559f0d2-ee95-4072-a7bc-3ffcc2faec27.png" width="800"></p>
70+
<p align="center"><img src="assets/plugin_store.png" width="800"></p>
6971

7072
## Have a plugin enhancement request or issue?
7173

assets/plugin_store.png

99.3 KB
Loading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aiohttp
2+
tqdm

ci/src/_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
# If adding a third-party library here, check CI workflows Python files
99
# that are dependant on this and require pip install.
1010

11+
github_download_url_regex = re.compile(
12+
r"https://github\.com/(?P<author>[a-zA-Z0-9-]+)/(?P<repo>[a-zA-Z0-9\.\-\_]*)/releases/download/(?P<version>[a-zA-Z\.0-9]+)/(?P<filename>.*)\.zip"
13+
)
14+
1115
# path
1216
utils_path = Path(__file__).resolve()
1317

@@ -44,6 +48,7 @@
4448
github_url = "https://github.com"
4549
release_date = "LatestReleaseDate"
4650
date_added = "DateAdded"
51+
website = "Website"
4752

4853
# typing
4954
PluginType = Dict[str, str]

ci/src/discord.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import aiohttp
2-
2+
from tqdm.asyncio import tqdm
33
from _utils import *
44

55
MAX_BODY_LEN = 1024
66

77

8-
async def update_hook(webhook_url: str, info: dict, latest_ver: str, release: dict) -> None:
8+
async def update_hook(webhook_url: str, info: PluginType, latest_ver: str, release: dict) -> None:
99
embed = {
1010
"content": None,
1111
"embeds": [
@@ -43,6 +43,43 @@ async def update_hook(webhook_url: str, info: dict, latest_ver: str, release: di
4343
embed['embeds'][0]['fields'].append({"name": "Release Notes", "value": truncate_release_notes(release['html_url'], release.get('body', ""))})
4444
async with aiohttp.ClientSession() as session:
4545
await session.post(webhook_url, json=embed)
46+
47+
async def release_hook(webhook_url: str, info: PluginType) -> None:
48+
embed = {
49+
"content": None,
50+
"embeds": [
51+
{
52+
"title": info[plugin_name],
53+
"description": f"New Plugin!\nReleased at v{info[version]}.",
54+
"url": info[website],
55+
"color": 5763719, # green
56+
"fields": [
57+
{
58+
"name": "Plugin Description",
59+
"value": info[description]
60+
},
61+
{
62+
"name": "Plugin Language",
63+
"value": info[language_name]
64+
}
65+
],
66+
"author": {
67+
"name": info[author]
68+
},
69+
"thumbnail": {
70+
"url": info[icon_path]
71+
}
72+
}
73+
]
74+
}
75+
if 'github.com' in info[url_sourcecode].lower():
76+
github_username = info[url_sourcecode].split('/')[3]
77+
embed['embeds'][0]['author']['name'] = github_username
78+
embed['embeds'][0]['author']['url'] = f"{github_url}/{github_username}"
79+
embed['embeds'][0]["author"]["icon_url"] = f"{github_url}/{github_username}.png?size=40"
80+
81+
async with aiohttp.ClientSession() as session:
82+
await session.post(webhook_url, json=embed)
4683

4784
def truncate_release_notes(url: str, release_notes: str, length: int = MAX_BODY_LEN) -> str:
4885
if len(release_notes) <= length:

ci/src/test-python.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,36 @@ def get_all_python_plugins(manifest: dict) -> list:
8181
return [plugin for plugin in manifest if plugin["Language"].lower() == "python"]
8282

8383
def run_plugin(plugin_name: str, plugin_path: str, execute_path: str) -> bool:
84-
"""Run plugin and check output. Returns true if test successfull else false"""
84+
"""Run plugin and check output. Returns true if test successful else false"""
8585
os.chdir(plugin_path)
8686
default_settings = init_settings(plugin_name, plugin_path)
8787
args = json.dumps(
8888
{"method": "query", "parameters": [""], "Settings": default_settings}
8989
)
90-
full_args = ["python", "-S", Path(plugin_path, execute_path), args]
90+
9191
# Older Flox used environmental variable to locate Images directory
9292
os.environ["PYTHONPATH"] = str(USER_PATH.joinpath("PythonEmbeddable"))
93+
94+
# Compose the sys.path setup and runpy logic as Flow Launcher does in
95+
# https://github.com/Flow-Launcher/Flow.Launcher/blob/dfe96160ed44684810bcdf853f86fda4305122d6/Flow.Launcher.Core/Plugin/PythonPlugin.cs#L69-L81
96+
sys_path_setup = (
97+
f"import sys; "
98+
f"sys.path.append(r'{plugin_path}'); "
99+
f"sys.path.append(r'{plugin_path}\\lib'); "
100+
f"sys.path.append(r'{plugin_path}\\lib\\win32\\lib'); "
101+
f"sys.path.append(r'{plugin_path}\\lib\\win32'); "
102+
f"sys.path.append(r'{plugin_path}\\plugin'); "
103+
f"import runpy; "
104+
f"runpy.run_path(r'{Path(plugin_path, execute_path)}', None, '__main__')"
105+
)
106+
107+
full_args = [
108+
"python",
109+
"-S",
110+
"-c",
111+
sys_path_setup,
112+
args
113+
]
93114
print_section("Input", full_args)
94115
p = Popen(full_args, text=True, stdout=PIPE, stderr=PIPE)
95116
stdout, stderr = p.communicate()
@@ -104,7 +125,7 @@ def run_plugin(plugin_name: str, plugin_path: str, execute_path: str) -> bool:
104125
return True
105126
else:
106127
print_section(f"{plugin['Name']} test FAILED!", "")
107-
print(f'Plugin returned a non-zero exit code: {max(exit_code, 1)}')
128+
print(f'Plugin has returned a non-zero exit code: {max(exit_code, 1)}')
108129
if stderr != "":
109130
print_section('Trace', stderr)
110131
if json_msg:

0 commit comments

Comments
 (0)