Skip to content

Commit 9136b19

Browse files
authored
Merge branch 'dev' into improve_update
2 parents 2229db0 + d3824f2 commit 9136b19

File tree

50 files changed

+2066
-171
lines changed

Some content is hidden

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

50 files changed

+2066
-171
lines changed

.github/actions/spelling/allow.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ ssh
44
ubuntu
55
runcount
66
Firefox
7-
Português
8-
Português (Brasil)
7+
workaround

.github/actions/spelling/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ Reloadable
103103
metadatas
104104
WMP
105105
VSTHRD
106+
CJK

.github/actions/spelling/patterns.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,12 @@
134134
\bčeština\b
135135
\bPortuguês\b
136136
\bIoc\b
137+
\bXiao\s*He\b
138+
\bZi\s*Ran\s*Ma\b
139+
\bWei\s*Ruan\b
140+
\bZhi\s*Neng\s*ABC\b
141+
\bZi\s*Guang\s*Pin\s*Yin\b
142+
\bPin\s*Yin\s*Jia\s*Jia\b
143+
\bXing\s*Kong\s*Jian\s*Dao\b
144+
\bDa\s*Niu\b
145+
\bXiao\s*Lang\b

.github/workflows/default_plugins.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup .NET
1515
uses: actions/setup-dotnet@v4
1616
with:
17-
dotnet-version: 7.0.x
17+
dotnet-version: 9.0.x
1818

1919
- name: Update Plugins To Production Version
2020
run: |
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Build BrowserBookmark
4444
run: |
45-
dotnet publish 'Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.BrowserBookmark"
45+
dotnet publish 'Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.BrowserBookmark"
4646
7z a -tzip "Flow.Launcher.Plugin.BrowserBookmark.zip" "./Flow.Launcher.Plugin.BrowserBookmark/*"
4747
rm -r "Flow.Launcher.Plugin.BrowserBookmark"
4848
@@ -66,7 +66,7 @@ jobs:
6666

6767
- name: Build Calculator
6868
run: |
69-
dotnet publish 'Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.Calculator"
69+
dotnet publish 'Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.Calculator"
7070
7z a -tzip "Flow.Launcher.Plugin.Calculator.zip" "./Flow.Launcher.Plugin.Calculator/*"
7171
rm -r "Flow.Launcher.Plugin.Calculator"
7272
@@ -90,7 +90,7 @@ jobs:
9090

9191
- name: Build Explorer
9292
run: |
93-
dotnet publish 'Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.Explorer"
93+
dotnet publish 'Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.Explorer"
9494
7z a -tzip "Flow.Launcher.Plugin.Explorer.zip" "./Flow.Launcher.Plugin.Explorer/*"
9595
rm -r "Flow.Launcher.Plugin.Explorer"
9696
@@ -114,7 +114,7 @@ jobs:
114114

115115
- name: Build PluginIndicator
116116
run: |
117-
dotnet publish 'Plugins/Flow.Launcher.Plugin.PluginIndicator/Flow.Launcher.Plugin.PluginIndicator.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.PluginIndicator"
117+
dotnet publish 'Plugins/Flow.Launcher.Plugin.PluginIndicator/Flow.Launcher.Plugin.PluginIndicator.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.PluginIndicator"
118118
7z a -tzip "Flow.Launcher.Plugin.PluginIndicator.zip" "./Flow.Launcher.Plugin.PluginIndicator/*"
119119
rm -r "Flow.Launcher.Plugin.PluginIndicator"
120120
@@ -138,7 +138,7 @@ jobs:
138138

139139
- name: Build PluginsManager
140140
run: |
141-
dotnet publish 'Plugins/Flow.Launcher.Plugin.PluginsManager/Flow.Launcher.Plugin.PluginsManager.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.PluginsManager"
141+
dotnet publish 'Plugins/Flow.Launcher.Plugin.PluginsManager/Flow.Launcher.Plugin.PluginsManager.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.PluginsManager"
142142
7z a -tzip "Flow.Launcher.Plugin.PluginsManager.zip" "./Flow.Launcher.Plugin.PluginsManager/*"
143143
rm -r "Flow.Launcher.Plugin.PluginsManager"
144144
@@ -162,7 +162,7 @@ jobs:
162162

163163
- name: Build ProcessKiller
164164
run: |
165-
dotnet publish 'Plugins/Flow.Launcher.Plugin.ProcessKiller/Flow.Launcher.Plugin.ProcessKiller.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.ProcessKiller"
165+
dotnet publish 'Plugins/Flow.Launcher.Plugin.ProcessKiller/Flow.Launcher.Plugin.ProcessKiller.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.ProcessKiller"
166166
7z a -tzip "Flow.Launcher.Plugin.ProcessKiller.zip" "./Flow.Launcher.Plugin.ProcessKiller/*"
167167
rm -r "Flow.Launcher.Plugin.ProcessKiller"
168168
@@ -186,7 +186,7 @@ jobs:
186186

187187
- name: Build Program
188188
run: |
189-
dotnet publish 'Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj' --framework net7.0-windows10.0.19041.0 -c Release -o "Flow.Launcher.Plugin.Program"
189+
dotnet publish 'Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj' --framework net9.0-windows10.0.19041.0 -c Release -o "Flow.Launcher.Plugin.Program"
190190
7z a -tzip "Flow.Launcher.Plugin.Program.zip" "./Flow.Launcher.Plugin.Program/*"
191191
rm -r "Flow.Launcher.Plugin.Program"
192192
@@ -210,7 +210,7 @@ jobs:
210210

211211
- name: Build Shell
212212
run: |
213-
dotnet publish 'Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.Shell"
213+
dotnet publish 'Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.Shell"
214214
7z a -tzip "Flow.Launcher.Plugin.Shell.zip" "./Flow.Launcher.Plugin.Shell/*"
215215
rm -r "Flow.Launcher.Plugin.Shell"
216216
@@ -234,7 +234,7 @@ jobs:
234234

235235
- name: Build Sys
236236
run: |
237-
dotnet publish 'Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.Sys"
237+
dotnet publish 'Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.Sys"
238238
7z a -tzip "Flow.Launcher.Plugin.Sys.zip" "./Flow.Launcher.Plugin.Sys/*"
239239
rm -r "Flow.Launcher.Plugin.Sys"
240240
@@ -258,7 +258,7 @@ jobs:
258258

259259
- name: Build Url
260260
run: |
261-
dotnet publish 'Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.Url"
261+
dotnet publish 'Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.Url"
262262
7z a -tzip "Flow.Launcher.Plugin.Url.zip" "./Flow.Launcher.Plugin.Url/*"
263263
rm -r "Flow.Launcher.Plugin.Url"
264264
@@ -282,7 +282,7 @@ jobs:
282282

283283
- name: Build WebSearch
284284
run: |
285-
dotnet publish 'Plugins/Flow.Launcher.Plugin.WebSearch/Flow.Launcher.Plugin.WebSearch.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.WebSearch"
285+
dotnet publish 'Plugins/Flow.Launcher.Plugin.WebSearch/Flow.Launcher.Plugin.WebSearch.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.WebSearch"
286286
7z a -tzip "Flow.Launcher.Plugin.WebSearch.zip" "./Flow.Launcher.Plugin.WebSearch/*"
287287
rm -r "Flow.Launcher.Plugin.WebSearch"
288288
@@ -306,7 +306,7 @@ jobs:
306306

307307
- name: Build WindowsSettings
308308
run: |
309-
dotnet publish 'Plugins/Flow.Launcher.Plugin.WindowsSettings/Flow.Launcher.Plugin.WindowsSettings.csproj' --framework net7.0-windows -c Release -o "Flow.Launcher.Plugin.WindowsSettings"
309+
dotnet publish 'Plugins/Flow.Launcher.Plugin.WindowsSettings/Flow.Launcher.Plugin.WindowsSettings.csproj' --framework net9.0-windows -c Release -o "Flow.Launcher.Plugin.WindowsSettings"
310310
7z a -tzip "Flow.Launcher.Plugin.WindowsSettings.zip" "./Flow.Launcher.Plugin.WindowsSettings/*"
311311
rm -r "Flow.Launcher.Plugin.WindowsSettings"
312312

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
runs-on: windows-latest
1818
env:
19-
FlowVersion: 1.19.5
19+
FlowVersion: 1.20.2
2020
NUGET_CERT_REVOCATION_MODE: offline
2121
BUILD_NUMBER: ${{ github.run_number }}
2222
steps:
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup .NET
3232
uses: actions/setup-dotnet@v4
3333
with:
34-
dotnet-version: 7.0.x
34+
dotnet-version: 9.0.x
3535
# cache: true
3636
# cache-dependency-path: |
3737
# Flow.Launcher/packages.lock.json

.github/workflows/spelling.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
steps:
7373
- name: check-spelling
7474
id: spelling
75-
uses: check-spelling/check-spelling@prerelease
75+
uses: check-spelling/check-spelling@v0.0.25
7676
with:
7777
suppress_push_for_open_pull_request: 1
7878
checkout: true
@@ -128,7 +128,7 @@ jobs:
128128
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
129129
steps:
130130
- name: comment
131-
uses: check-spelling/check-spelling@prerelease
131+
uses: check-spelling/check-spelling@v0.0.25
132132
with:
133133
checkout: true
134134
spell_check_this: check-spelling/spell-check-this@main

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0-windows</TargetFramework>
4+
<TargetFramework>net9.0-windows</TargetFramework>
55
<UseWpf>true</UseWpf>
66
<UseWindowsForms>true</UseWindowsForms>
77
<OutputType>Library</OutputType>
@@ -12,6 +12,7 @@
1212
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
1313
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1414
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
15+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -57,6 +58,7 @@
5758
<PackageReference Include="FSharp.Core" Version="9.0.201" />
5859
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.4.0" />
5960
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
61+
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
6062
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
6163
<PackageReference Include="StreamJsonRpc" Version="2.21.10" />
6264
</ItemGroup>

Flow.Launcher.Core/Plugin/PluginInstaller.cs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.IO.Compression;
45
using System.Linq;
@@ -277,6 +278,122 @@ await DownloadFileAsync(
277278
}
278279
}
279280

281+
/// <summary>
282+
/// Updates the plugin to the latest version available from its source.
283+
/// </summary>
284+
/// <param name="updateAllPlugins">Action to execute when the user chooses to update all plugins.</param>
285+
/// <param name="silentUpdate">If true, do not show any messages when there is no update available.</param>
286+
/// <param name="usePrimaryUrlOnly">If true, only use the primary URL for updates.</param>
287+
/// <param name="token">Cancellation token to cancel the update operation.</param>
288+
/// <returns></returns>
289+
public static async Task CheckForPluginUpdatesAsync(Action<List<PluginUpdateInfo>> updateAllPlugins, bool silentUpdate = true, bool usePrimaryUrlOnly = false, CancellationToken token = default)
290+
{
291+
// Update the plugin manifest
292+
await API.UpdatePluginManifestAsync(usePrimaryUrlOnly, token);
293+
294+
// Get all plugins that can be updated
295+
var resultsForUpdate = (
296+
from existingPlugin in API.GetAllPlugins()
297+
join pluginUpdateSource in API.GetPluginManifest()
298+
on existingPlugin.Metadata.ID equals pluginUpdateSource.ID
299+
where string.Compare(existingPlugin.Metadata.Version, pluginUpdateSource.Version,
300+
StringComparison.InvariantCulture) <
301+
0 // if current version precedes version of the plugin from update source (e.g. PluginsManifest)
302+
&& !API.PluginModified(existingPlugin.Metadata.ID)
303+
select
304+
new PluginUpdateInfo()
305+
{
306+
ID = existingPlugin.Metadata.ID,
307+
Name = existingPlugin.Metadata.Name,
308+
Author = existingPlugin.Metadata.Author,
309+
CurrentVersion = existingPlugin.Metadata.Version,
310+
NewVersion = pluginUpdateSource.Version,
311+
IcoPath = existingPlugin.Metadata.IcoPath,
312+
PluginExistingMetadata = existingPlugin.Metadata,
313+
PluginNewUserPlugin = pluginUpdateSource
314+
}).ToList();
315+
316+
// No updates
317+
if (!resultsForUpdate.Any())
318+
{
319+
if (!silentUpdate)
320+
{
321+
API.ShowMsg(API.GetTranslation("updateNoResultTitle"), API.GetTranslation("updateNoResultSubtitle"));
322+
}
323+
return;
324+
}
325+
326+
// If all plugins are modified, just return
327+
if (resultsForUpdate.All(x => API.PluginModified(x.ID)))
328+
{
329+
return;
330+
}
331+
332+
// Show message box with button to update all plugins
333+
API.ShowMsgWithButton(
334+
API.GetTranslation("updateAllPluginsTitle"),
335+
API.GetTranslation("updateAllPluginsButtonContent"),
336+
() =>
337+
{
338+
updateAllPlugins(resultsForUpdate);
339+
},
340+
string.Join(", ", resultsForUpdate.Select(x => x.PluginExistingMetadata.Name)));
341+
}
342+
343+
/// <summary>
344+
/// Updates all plugins that have available updates.
345+
/// </summary>
346+
/// <param name="resultsForUpdate"></param>
347+
/// <param name="restart"></param>
348+
public static async Task UpdateAllPluginsAsync(IEnumerable<PluginUpdateInfo> resultsForUpdate, bool restart)
349+
{
350+
var anyPluginSuccess = false;
351+
await Task.WhenAll(resultsForUpdate.Select(async plugin =>
352+
{
353+
var downloadToFilePath = Path.Combine(Path.GetTempPath(), $"{plugin.Name}-{plugin.NewVersion}.zip");
354+
355+
try
356+
{
357+
using var cts = new CancellationTokenSource();
358+
359+
await DownloadFileAsync(
360+
$"{API.GetTranslation("DownloadingPlugin")} {plugin.PluginNewUserPlugin.Name}",
361+
plugin.PluginNewUserPlugin.UrlDownload, downloadToFilePath, cts);
362+
363+
// check if user cancelled download before installing plugin
364+
if (cts.IsCancellationRequested)
365+
{
366+
return;
367+
}
368+
369+
if (!await API.UpdatePluginAsync(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath))
370+
{
371+
return;
372+
}
373+
374+
anyPluginSuccess = true;
375+
}
376+
catch (Exception e)
377+
{
378+
API.LogException(ClassName, "Failed to update plugin", e);
379+
API.ShowMsgError(API.GetTranslation("ErrorUpdatingPlugin"));
380+
}
381+
}));
382+
383+
if (!anyPluginSuccess) return;
384+
385+
if (restart)
386+
{
387+
API.RestartApp();
388+
}
389+
else
390+
{
391+
API.ShowMsg(
392+
API.GetTranslation("updatebtn"),
393+
API.GetTranslation("PluginsUpdateSuccessNoRestart"));
394+
}
395+
}
396+
280397
/// <summary>
281398
/// Downloads a file from a URL to a local path, optionally showing a progress box and handling cancellation.
282399
/// </summary>
@@ -351,3 +468,15 @@ private static bool InstallSourceKnown(string url)
351468
);
352469
}
353470
}
471+
472+
public record PluginUpdateInfo
473+
{
474+
public string ID { get; init; }
475+
public string Name { get; init; }
476+
public string Author { get; init; }
477+
public string CurrentVersion { get; init; }
478+
public string NewVersion { get; init; }
479+
public string IcoPath { get; init; }
480+
public PluginMetadata PluginExistingMetadata { get; init; }
481+
public UserPlugin PluginNewUserPlugin { get; init; }
482+
}

0 commit comments

Comments
 (0)