Skip to content

Commit

Permalink
Resolve #83
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-ycv committed Mar 25, 2024
1 parent 25ff10c commit 474cece
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 54 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/packageManagers.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: sync to choco and winget
name: sync to package repos

on:
release:
Expand Down Expand Up @@ -48,12 +48,18 @@ jobs:
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
cd .\EverythingPowerToys
rm .git -Recurse -Force -Confirm:$false
$verArray = $ver -split '\.'
$verArray[1] -= 1
if ($verArray[1] -lt 0) {
$verArray[1] = 0
$verArray[0] -=1
}
$prevVer = $verArray -join '.'
Get-ChildItem *.* -Recurse | ForEach { (Get-Content $_) | ForEach {$_ -Replace '_VERSION_', $ver} | ForEach {$_ -Replace '_URL_', $exe} | ForEach {$_ -Replace '_CRC_', $exehash} | ForEach {$_ -Replace '_PV_', $prevVer} | Set-Content $_ }
Get-ChildItem *.* -Recurse | ForEach { (Get-Content $_) | ForEach {$_ -Replace '_VERSION_', $ver} | ForEach {$_ -Replace '_URL_', $exe} | ForEach {$_ -Replace '_CRC_', $exehash} | Set-Content $_ }
..\wingetcreate submit -p "New version: lin-ycv.EverythingPowerToys version $ver" -t ${{ secrets.GITHUB_TOKEN }} .
# scoop # takes too long to get approvaed, impractical to implement
# cd ..
# rm -Path .\* -Recurse -Force
# git clone -b EverythingPowerToys https://github.com/lin-ycv/ScoopExtras.git --depth 1
# cd .\bucket
# rm EverythingPowerToys.json -Force
# Invoke-WebRequest https://github.com/lin-ycv/EverythingPowerToys/raw/scoop/EverythingPowerToys.json -OutFile EverythingPowerToys.json
# (Get-Content EverythingPowerToys.json) | ForEach-Object {$_ -Replace '_VERSION_', $ver} | ForEach-Object {$_ -Replace '_URL_', $zip} | ForEach-Object {$_ -Replace '_CRC_', $ziphash} | Set-Content EverythingPowerToys.json
# git add .
# git commit -m "EverythingPowerToys@$ver: Update"
# git push -f
# gh pr create --base main --head EverythingPowerToys --title "EverythingPowerToys@$ver: Update" --body "- [X] I have read the [Contributing Guide](https://github.com/ScoopInstaller/.github/blob/main/.github/CONTRIBUTING.md).`r`n`r`n/verify"
2 changes: 1 addition & 1 deletion Community.PowerToys.Run.Plugin.Everything.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del /Q &quot;$(TargetDir)*.pdb&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)PowerToys*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Wox*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Ijwhost.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)*.xml&quot;&#xD;&#xA;del/ Q &quot;$(TargetDir)backup_restore_settings.json&quot;&#xD;&#xA;powershell Compress-Archive -Path $(TargetDir) -DestinationPath .\bin\EverythingPT-$(Version)-x64.zip -Force&#xD;&#xA;&quot;C:\Program Files (x86)\NSIS\makensis&quot; /Dver=$(Version) .\NSIS\exeCreator.nsi&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64.zip SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64.exe SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;rd /Q /S &quot;$(TargetDir)&quot;" />
<Exec Command="del /Q &quot;$(TargetDir)*.pdb&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)PowerToys*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Wox*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Ijwhost.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)*.xml&quot;&#xD;&#xA;del/ Q &quot;$(TargetDir)backup_restore_settings.json&quot;&#xD;&#xA;del /Q &quot;.\bin\CHECKSUM.txt&quot;&#xD;&#xA;powershell Compress-Archive -Path $(TargetDir) -DestinationPath .\bin\EverythingPT-$(Version)-x64.zip -Force&#xD;&#xA;&quot;C:\Program Files (x86)\NSIS\makensis&quot; /Dver=$(Version) .\NSIS\exeCreator.nsi&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64.zip SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64.exe SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;rd /Q /S &quot;$(TargetDir)&quot;" />
</Target>

</Project>
30 changes: 8 additions & 22 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@
using System.Windows.Controls;
using Community.PowerToys.Run.Plugin.Everything.Properties;
using Microsoft.PowerToys.Settings.UI.Library;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using Wox.Plugin.Logger;
using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods;

namespace Community.PowerToys.Run.Plugin.Everything
{
public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu, ISettingProvider, IPluginI18n, ISavable
public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu, ISettingProvider, IPluginI18n
{
public static string PluginID => "A86867E2D932459CBD77D176373DD657";
public string Name => Resources.plugin_name;
public string Description => Resources.plugin_description;

private readonly Settings _setting;
private readonly PluginJsonStorage<Settings> _storage;
private readonly Everything _everything;
private readonly Settings _setting = new();
private Everything _everything;

private ContextMenuLoader _contextMenuLoader;
private bool _disposed;
Expand Down Expand Up @@ -104,19 +102,18 @@ public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu,
},
};

public Main()
public void Init(PluginInitContext context)
{
_storage = new PluginJsonStorage<Settings>();
_setting = _storage.Load();
_setting.Getfilters();
if (_setting.Updates)
Task.Run(() => new Update().UpdateAsync(Assembly.GetExecutingAssembly().GetName().Version, _setting));
_everything = new Everything(_setting);
_contextMenuLoader = new ContextMenuLoader(context, _setting.Context);
_contextMenuLoader.Update(_setting);
}

public void UpdateSettings(PowerLauncherPluginSettings settings)
{
if (settings != null && settings.AdditionalOptions != null)
if (settings.AdditionalOptions != null)
{
_setting.Sort = (Sort)settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Sort)).ComboBoxValue;
_setting.Max = (uint)settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Max)).NumberValue;
Expand All @@ -129,20 +126,11 @@ public void UpdateSettings(PowerLauncherPluginSettings settings)
_setting.EnvVar = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.EnvVar)).Value;
_setting.Updates = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(_setting.Updates)).Value;

_everything.UpdateSettings(_setting);

_everything?.UpdateSettings(_setting);
_contextMenuLoader?.Update(_setting);

Save();
}
}

public void Init(PluginInitContext context)
{
_contextMenuLoader = new ContextMenuLoader(context, _setting.Context);
_contextMenuLoader.Update(_setting);
}

public List<Result> Query(Query query)
{
List<Result> results = [];
Expand Down Expand Up @@ -179,8 +167,6 @@ public List<Result> Query(Query query, bool delayedExecution)
return results;
}

public void Save() => _storage.Save();

protected virtual void Dispose(bool disposing)
{
if (!_disposed)
Expand Down
30 changes: 16 additions & 14 deletions NSIS/exeCreator.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,34 @@ Page instfiles

Section ""

; Don't terminate processes, helps reduce AV FP
;ExecWait '"$%SystemRoot%\system32\TaskKill.exe" /F /IM ${PT}'
ExecWait 'wmic process where name="${PT}" call terminate'
Sleep 3000
;ExecWait 'wmic process where name="${PT}" call terminate'
;Sleep 3000

SetOutPath $INSTDIR
GetFullPathName $0 "$EXEDIR\"
GetFullPathName $0 $0
File /r ".\..\..\..\..\..\..\x64\Release\RunPlugins\Everything\*"

IfFileExists "$LOCALAPPDATA\PowerToys\${PT}" 0 +2
Exec '"$LOCALAPPDATA\PowerToys\${PT}"'
; Also don't launch processes, helps reduce AV FP
;IfFileExists "$LOCALAPPDATA\PowerToys\${PT}" 0 +2
;Exec '"$LOCALAPPDATA\PowerToys\${PT}"'

IfFileExists "$PROGRAMFILES64\PowerToys\${PT}" 0 +2
Exec '"$PROGRAMFILES64\PowerToys\${PT}"'
;IfFileExists "$PROGRAMFILES64\PowerToys\${PT}" 0 +2
;Exec '"$PROGRAMFILES64\PowerToys\${PT}"'

SectionEnd

;--------------------------------
; Don't query proceses, helps reduce AV FP
;Function .onInit

Function .onInit

System::Call 'kernel32::CreateMutex(p 0, i 0, t "ACFEF7F6-7856-4BB3-82E3-0877CBB4E9C7") p .r1 ?e'
Pop $R0
; System::Call 'kernel32::CreateMutex(p 0, i 0, t "ACFEF7F6-7856-4BB3-82E3-0877CBB4E9C7") p .r1 ?e'
; Pop $R0

StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
; StrCmp $R0 0 +3
; MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
; Abort

FunctionEnd
; FunctionEnd
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Everything for PowerToys Run
[![GitHub repo size](https://img.shields.io/github/repo-size/lin-ycv/everythingpowertoys)](#)
[![GitHub release (release name instead of tag name)](https://img.shields.io/github/v/release/lin-ycv/everythingpowertoys)](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)
[![Chocolatey Version](https://img.shields.io/chocolatey/v/everythingpowertoys)](https://community.chocolatey.org/packages/everythingpowertoys)
![Winget version](https://img.shields.io/badge/dynamic/xml?label=Winget&prefix=v&query=%2F%2Ftr%5B%40id%3D%27winget%27%5D%2Ftd%5B3%5D%2Fspan%2Fa&url=https%3A%2F%2Frepology.org%2Fproject%2Feverythingpowertoys%2Fversions&color=orange)
[![Chocolatey Version](https://img.shields.io/chocolatey/v/everythingpowertoys?color=orange)](https://community.chocolatey.org/packages/everythingpowertoys)
[![GitHub all releases](https://img.shields.io/github/downloads/lin-ycv/EverythingPowerToys/total)](https://github.com/lin-ycv/EverythingPowerToys/releases/)
[![GitHub release (latest by date)](https://img.shields.io/github/downloads/lin-ycv/everythingpowertoys/latest/total)](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)
<!--- [![Scoop Version](https://img.shields.io/scoop/v/EverythingPowerToys?bucket=extras&color=orange)](https://scoop.sh/#/apps?q=EverythingPowerToys) -->

This plugin adds Everything search results to PowerToys Run.<br>
This repo is to be used with the [PowerToys repo](https://github.com/microsoft/PowerToys), this will not compile when used standalone, as it's missing references from PowerToys.<br>
Dev instructions are in the wiki.

#### Install instructions
There are now 4 different methods of installation, chose the one you prefer:
1) WinGet (Recommended) : `winget install lin-ycv.EverythingPowerToys`
There are 4 different methods of installation, chose the one you prefer:
1) WinGet : `winget install lin-ycv.EverythingPowerToys`
2) Chocolatey : `choco install everythingpowertoys`
3) Self-Extraction Installer (EXE) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)
4) Manual Installation (ZIP) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)
3) ~ Scoop : `scoop install everythingpowertoys` ~
4) Self-Extraction Installer (EXE) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)
5) Manual Installation (ZIP) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)

Detailed explanations and instructions are on the [release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest)

Expand Down
2 changes: 1 addition & 1 deletion Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal async Task UpdateAsync(Version v, Settings s)
string fileName = Path.Combine(Path.GetTempPath(), nameUrl[0]);
File.WriteAllBytes(fileName, fileContent);
using Process updater = Process.Start(fileName);
updater.WaitForExit();
updater.WaitForExit(5000);
if (updater.ExitCode == 1)
{
ProcessStartInfo p = new("https://github.com/lin-ycv/EverythingPowerToys/releases/latest")
Expand Down
1 change: 0 additions & 1 deletion bin/.gitinclude

This file was deleted.

2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"IsGlobal": true,
"Name": "Everything",
"Author": "Yu Chieh (Victor) Lin",
"Version": "0.78.0",
"Version": "0.80.0",
"Language": "csharp",
"Website": "https://github.com/Lin-ycv/EverythingPowerToys",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
Expand Down

0 comments on commit 474cece

Please sign in to comment.