Compare commits
No commits in common. "master" and "1.0.7471.8864" have entirely different histories.
master
...
1.0.7471.8
145
.github/workflows/main.yml
vendored
Normal file
145
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
name: CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.0.0
|
||||||
|
- name: Build
|
||||||
|
id: base_init
|
||||||
|
run: |
|
||||||
|
cd $Env:GITHUB_WORKSPACE
|
||||||
|
dotnet build --verbosity:m -p:Configuration=Release
|
||||||
|
cp ".\UpTool build tool\bin\Release\netcoreapp3.1\package.zip" $Env:GITHUB_WORKSPACE\Tools.zip
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\netcoreapp3.1\UpTool2.exe
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\netcoreapp3.1\*.dll
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\netcoreapp3.1\UpTool2.runtimeconfig.json
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\netcoreapp3.1\runtimes
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\netcoreapp3.1\uptool.exe
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\netcoreapp3.1\*.dll
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\netcoreapp3.1\uptool.runtimeconfig.json
|
||||||
|
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\netcoreapp3.1\runtimes
|
||||||
|
$asmver = $([Reflection.Assembly]::Loadfile($(pwd).Path + "\\UpTool2\\bin\\Release\\netcoreapp3.1\\UpTool2.dll").GetName().version.ToString())
|
||||||
|
$pkgtoolver = $([Reflection.Assembly]::Loadfile($(pwd).Path + "\\UpTool build tool\\bin\\Release\\netcoreapp3.1\\pkgtool.dll").GetName().version.ToString())
|
||||||
|
echo "::set-output name=vers::$asmver"
|
||||||
|
echo "::set-output name=pkgvers::$pkgtoolver"
|
||||||
|
cd $Env:GITHUB_WORKSPACE\InstallerCLI
|
||||||
|
& "C:\Program Files\7-Zip\7z" a ..\Installer-generic.zip .\bin\Release\netcoreapp3.1\Installer.exe
|
||||||
|
& "C:\Program Files\7-Zip\7z" a ..\Installer-generic.zip .\bin\Release\netcoreapp3.1\*.dll
|
||||||
|
& "C:\Program Files\7-Zip\7z" a ..\Installer-generic.zip .\bin\Release\netcoreapp3.1\Installer.runtimeconfig.json
|
||||||
|
& "C:\Program Files\7-Zip\7z" a ..\Installer-generic.zip .\Info.txt
|
||||||
|
cd $Env:GITHUB_WORKSPACE
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1.0.1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.base_init.outputs.vers }}
|
||||||
|
release_name: Release ${{ steps.base_init.outputs.vers }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
- name: Upload Release Asset
|
||||||
|
id: upload_release_asset
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./Release.zip
|
||||||
|
asset_name: Release.zip
|
||||||
|
asset_content_type: application/zip
|
||||||
|
- name: Upload Tool Asset
|
||||||
|
id: upload_tool_asset
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./Tools.zip
|
||||||
|
asset_name: Tools.zip
|
||||||
|
asset_content_type: application/zip
|
||||||
|
- name: Upload generic Installer
|
||||||
|
id: upload_generic_installer
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./Installer-generic.zip
|
||||||
|
asset_name: Installer-generic.zip
|
||||||
|
asset_content_type: application/zip
|
||||||
|
- name: Create XML
|
||||||
|
run: |
|
||||||
|
[System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
|
||||||
|
[System.XML.XMLElement]$app=$xml.CreateElement("app")
|
||||||
|
$xml.appendChild($app)
|
||||||
|
$app.appendChild($xml.CreateElement("Name")).InnerText = "UpTool2 package tools"
|
||||||
|
$app.appendChild($xml.CreateElement("Description")).InnerText = "Tools for automating package creation"
|
||||||
|
$app.appendChild($xml.CreateElement("Version")).InnerText = "${{ steps.base_init.outputs.pkgvers }}"
|
||||||
|
$app.appendChild($xml.CreateElement("ID")).InnerText = "0e35d154-d0d3-45e0-b080-62f521263a44"
|
||||||
|
$app.appendChild($xml.CreateElement("File")).InnerText = "${{ steps.upload_tool_asset.outputs.browser_download_url }}"
|
||||||
|
$app.appendChild($xml.CreateElement("Hash")).InnerText = $(Get-FileHash $Env:GITHUB_WORKSPACE\Tools.zip).Hash
|
||||||
|
echo NULL > tools.xml
|
||||||
|
$xml.save($(gi .\tools.xml).Fullname)
|
||||||
|
[System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
|
||||||
|
[System.XML.XMLElement]$app=$xml.CreateElement("meta")
|
||||||
|
$xml.appendChild($app)
|
||||||
|
$app.appendChild($xml.CreateElement("Version")).InnerText = "${{ steps.base_init.outputs.vers }}"
|
||||||
|
$app.appendChild($xml.CreateElement("File")).InnerText = "${{ steps.upload_release_asset.outputs.browser_download_url }}"
|
||||||
|
$app.appendChild($xml.CreateElement("Hash")).InnerText = $(Get-FileHash $Env:GITHUB_WORKSPACE\Release.zip).Hash
|
||||||
|
$app.appendChild($xml.CreateElement("Installer")).InnerText = "${{ steps.upload_generic_installer.outputs.browser_download_url }}"
|
||||||
|
$app.appendChild($xml.CreateElement("InstallerHash")).InnerText = $(Get-FileHash $Env:GITHUB_WORKSPACE\Installer-generic.zip).Hash
|
||||||
|
echo NULL > meta.xml
|
||||||
|
$xml.save($(gi .\meta.xml).Fullname)
|
||||||
|
- name: Upload Meta XML
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./meta.xml
|
||||||
|
asset_name: meta.xml
|
||||||
|
asset_content_type: text/xml
|
||||||
|
- name: Upload Tool XML
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./tools.xml
|
||||||
|
asset_name: tools.xml
|
||||||
|
asset_content_type: text/xml
|
||||||
|
- name: Build non-generic installers
|
||||||
|
run: |
|
||||||
|
cd $Env:GITHUB_WORKSPACE\Installer
|
||||||
|
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
|
||||||
|
dotnet publish -r win-x86 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
|
||||||
|
cp .\bin\Release\netcoreapp3.1\win-x64\publish\Installer.exe ..\Installer-x64.exe
|
||||||
|
cp .\bin\Release\netcoreapp3.1\win-x86\publish\Installer.exe ..\Installer-x86.exe
|
||||||
|
cd $Env:GITHUB_WORKSPACE
|
||||||
|
- name: Upload x86 Installer
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./Installer-x86.exe
|
||||||
|
asset_name: Installer-x86.exe
|
||||||
|
asset_content_type: application/vnd.microsoft.portable-executable
|
||||||
|
- name: Upload x64 Installer
|
||||||
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./Installer-x64.exe
|
||||||
|
asset_name: Installer-x64.exe
|
||||||
|
asset_content_type: application/vnd.microsoft.portable-executable
|
@ -1,72 +0,0 @@
|
|||||||
.shared_windows_runners:
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
|
|
||||||
uptool:
|
|
||||||
extends:
|
|
||||||
- .shared_windows_runners
|
|
||||||
stage: deploy
|
|
||||||
script: |
|
|
||||||
Invoke-WebRequest -Uri https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
|
|
||||||
Set-ExecutionPolicy Unrestricted -Scope Process
|
|
||||||
.\dotnet-install.ps1 -Channel 5.0
|
|
||||||
$env:Path = "C:\Users\gitlab_runner\AppData\Local\Microsoft\dotnet;" + $env:Path + ";C:\Users\gitlab_runner\AppData\Local\Microsoft\dotnet"
|
|
||||||
dotnet build --verbosity:m -p:Configuration=Release
|
|
||||||
cp ".\UpTool build tool\bin\Release\net5.0\package.zip" .\Tools.zip
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\net5.0-windows\UpTool2.exe
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\net5.0-windows\*.dll
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpTool2\bin\Release\net5.0-windows\UpTool2.runtimeconfig.json
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\net5.0\uptool.exe
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\net5.0\*.dll
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Release.zip .\UpToolCLI\bin\Release\net5.0\uptool.runtimeconfig.json
|
|
||||||
$asmver = $([Reflection.Assembly]::Loadfile($(pwd).Path + "\\UpTool2\\bin\\Release\\net5.0-windows\\UpTool2.dll").GetName().version.ToString())
|
|
||||||
$pkgtoolver = $([Reflection.Assembly]::Loadfile($(pwd).Path + "\\UpTool build tool\\bin\\Release\\net5.0\\pkgtool.dll").GetName().version.ToString())
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-generic.zip .\InstallerCLI\bin\Release\net5.0\Installer.exe
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-generic.zip .\InstallerCLI\bin\Release\net5.0\*.dll
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-generic.zip .\InstallerCLI\bin\Release\net5.0\Installer.runtimeconfig.json
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-generic.zip .\InstallerCLI\Info.txt
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-gui.zip .\Installer\bin\Release\net5.0-windows\Installer.exe
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-gui.zip .\Installer\bin\Release\net5.0-windows\*.dll
|
|
||||||
& "C:\Program Files\7-Zip\7z" a .\Installer-gui.zip .\Installer\bin\Release\net5.0-windows\Installer.runtimeconfig.json
|
|
||||||
[System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
|
|
||||||
[System.XML.XMLElement]$app=$xml.CreateElement("app")
|
|
||||||
$xml.appendChild($app)
|
|
||||||
$app.appendChild($xml.CreateElement("Name")).InnerText = "UpTool2 package tools"
|
|
||||||
$app.appendChild($xml.CreateElement("Description")).InnerText = "Tools for automating package creation"
|
|
||||||
$app.appendChild($xml.CreateElement("Version")).InnerText = $pkgtoolver
|
|
||||||
$app.appendChild($xml.CreateElement("ID")).InnerText = "0e35d154-d0d3-45e0-b080-62f521263a44"
|
|
||||||
$app.appendChild($xml.CreateElement("File")).InnerText = $CI_PROJECT_URL + "/-/jobs/" + $CI_JOB_ID + "/artifacts/raw/Tools.zip"
|
|
||||||
$app.appendChild($xml.CreateElement("Hash")).InnerText = $(Get-FileHash .\Tools.zip).Hash
|
|
||||||
$app.appendChild($xml.CreateElement("MainFile")).InnerText = "pkgtool.exe"
|
|
||||||
$app.appendChild($xml.CreateElement("Icon")).InnerText = "https://gitlab.com/JFronny/UpTool2/-/raw/master/UpTool2.ico"
|
|
||||||
echo NULL > tools.xml
|
|
||||||
$xml.save($(gi .\tools.xml).Fullname)
|
|
||||||
[System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
|
|
||||||
[System.XML.XMLElement]$app=$xml.CreateElement("meta")
|
|
||||||
$xml.appendChild($app)
|
|
||||||
$app.appendChild($xml.CreateElement("Version")).InnerText = $asmver
|
|
||||||
$app.appendChild($xml.CreateElement("File")).InnerText = $CI_PROJECT_URL + "/-/jobs/" + $CI_JOB_ID + "/artifacts/raw/Release.zip"
|
|
||||||
$app.appendChild($xml.CreateElement("Hash")).InnerText = $(Get-FileHash .\Release.zip).Hash
|
|
||||||
$app.appendChild($xml.CreateElement("Installer")).InnerText = $CI_PROJECT_URL + "/-/jobs/" + $CI_JOB_ID + "/artifacts/raw/Installer-generic.zip"
|
|
||||||
$app.appendChild($xml.CreateElement("InstallerHash")).InnerText = $(Get-FileHash .\Installer-generic.zip).Hash
|
|
||||||
$app.appendChild($xml.CreateElement("InstallerGui")).InnerText = $CI_PROJECT_URL + "/-/jobs/" + $CI_JOB_ID + "/artifacts/raw/Installer-gui.zip"
|
|
||||||
$app.appendChild($xml.CreateElement("InstallerGuiHash")).InnerText = $(Get-FileHash .\Installer-gui.zip).Hash
|
|
||||||
echo NULL > meta.xml
|
|
||||||
$xml.save($(gi .\meta.xml).Fullname)
|
|
||||||
#cd Installer
|
|
||||||
#dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
|
|
||||||
#dotnet publish -r win-x86 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
|
|
||||||
#cp .\bin\Release\net5.0-windows\win-x64\publish\Installer.exe ..\Installer-x64.exe
|
|
||||||
#cp .\bin\Release\net5.0-windows\win-x86\publish\Installer.exe ..\Installer-x86.exe
|
|
||||||
#cd ..
|
|
||||||
#Installer-x64 and Installer-x86 were also originally artifacts but there doesn't seem to be a x86-64 windows runner
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- Release.zip
|
|
||||||
- Tools.zip
|
|
||||||
- Installer-generic.zip
|
|
||||||
- Installer-gui.zip
|
|
||||||
- meta.xml
|
|
||||||
- tools.xml
|
|
||||||
only:
|
|
||||||
- master
|
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DiscordProjectSettings">
|
<component name="DiscordProjectSettings">
|
||||||
<option name="show" value="PROJECT_FILES" />
|
<option name="show" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectNotificationSettings">
|
<component name="ProjectNotificationSettings">
|
||||||
<option name="askShowProject" value="false" />
|
<option name="askShowProject" value="false" />
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.UpTool2/.idea/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.UpTool2/.idea/riderModule.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.UpTool2/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.UpTool2/riderModule.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="RIDER_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$/../.." />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,8 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ApplicationIcon>..\UpTool2.ico</ApplicationIcon>
|
<ApplicationIcon>..\UpTool2.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
1
Installer/InstallerForm.Designer.cs
generated
1
Installer/InstallerForm.Designer.cs
generated
@ -17,7 +17,6 @@
|
|||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
_lib.Dispose();
|
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -11,8 +11,7 @@ using System.Windows.Forms;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace Installer
|
namespace Installer
|
||||||
{
|
{
|
||||||
@ -21,17 +20,16 @@ namespace Installer
|
|||||||
private const string AppName = "UpTool2";
|
private const string AppName = "UpTool2";
|
||||||
private readonly RegistryKey _rkApp;
|
private readonly RegistryKey _rkApp;
|
||||||
private string _log = "";
|
private string _log = "";
|
||||||
private UpToolLibMain _lib;
|
|
||||||
|
|
||||||
public InstallerForm()
|
public InstallerForm()
|
||||||
{
|
{
|
||||||
_lib = new UpToolLibMain(new UtLibFunctionsGui(Log));
|
ExternalFunctionalityManager.Init(new UtLibFunctionsGui(Log));
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Step(0, "Initialized");
|
Step(0, "Initialized");
|
||||||
_log = _log.TrimStart(Environment.NewLine.ToCharArray());
|
_log = _log.TrimStart(Environment.NewLine.ToCharArray());
|
||||||
_rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
_rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
||||||
pathBox.Checked = !File.Exists(_lib.V1.PathTool.InfoXml) ||
|
pathBox.Checked = !File.Exists(PathTool.InfoXml) ||
|
||||||
Path.Content.Contains(Path.GetName(_lib.V1.PathTool.GetRelative("Install")));
|
Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install")));
|
||||||
startupBox.Checked = pathBox.Checked && _rkApp.GetValue(AppName) != null;
|
startupBox.Checked = pathBox.Checked && _rkApp.GetValue(AppName) != null;
|
||||||
updateAppsBox.Checked = pathBox.Checked && startupBox.Checked &&
|
updateAppsBox.Checked = pathBox.Checked && startupBox.Checked &&
|
||||||
(string) _rkApp.GetValue(AppName) == "uptool dist-upgrade";
|
(string) _rkApp.GetValue(AppName) == "uptool dist-upgrade";
|
||||||
@ -43,15 +41,14 @@ namespace Installer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
progress.Visible = true;
|
progress.Visible = true;
|
||||||
WebClient client = new();
|
WebClient client = new WebClient();
|
||||||
Step(1, "Downloading metadata");
|
Step(1, "Downloading metadata");
|
||||||
XElement meta = XDocument
|
XElement meta = XDocument.Load("https://github.com/JFronny/UpTool2/releases/latest/download/meta.xml")
|
||||||
.Load("https://gitlab.com/JFronny/UpTool2/-/jobs/artifacts/master/raw/meta.xml?job=uptool")
|
|
||||||
.Element("meta");
|
.Element("meta");
|
||||||
Step(2, "Downloading binary");
|
Step(2, "Downloading binary");
|
||||||
byte[] dl = client.DownloadData(meta.Element("File").Value);
|
byte[] dl = client.DownloadData(meta.Element("File").Value);
|
||||||
Step(3, "Verifying integrity");
|
Step(3, "Verifying integrity");
|
||||||
using (SHA256CryptoServiceProvider sha256 = new())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
||||||
if (pkgHash != meta.Element("Hash").Value.ToUpper())
|
if (pkgHash != meta.Element("Hash").Value.ToUpper())
|
||||||
@ -61,26 +58,26 @@ Package: {pkgHash}
|
|||||||
Online: {meta.Element("Hash").Value.ToUpper()}");
|
Online: {meta.Element("Hash").Value.ToUpper()}");
|
||||||
}
|
}
|
||||||
Step(4, "Extracting");
|
Step(4, "Extracting");
|
||||||
if (Directory.Exists(_lib.V1.PathTool.GetRelative("Install")))
|
if (Directory.Exists(PathTool.GetRelative("Install")))
|
||||||
Directory.Delete(_lib.V1.PathTool.GetRelative("Install"), true);
|
Directory.Delete(PathTool.GetRelative("Install"), true);
|
||||||
Directory.CreateDirectory(_lib.V1.PathTool.GetRelative("Install"));
|
Directory.CreateDirectory(PathTool.GetRelative("Install"));
|
||||||
using (MemoryStream ms = new(dl))
|
using (MemoryStream ms = new MemoryStream(dl))
|
||||||
{
|
{
|
||||||
using ZipArchive ar = new(ms);
|
using ZipArchive ar = new ZipArchive(ms);
|
||||||
ar.ExtractToDirectory(_lib.V1.PathTool.GetRelative("Install"), true);
|
ar.ExtractToDirectory(PathTool.GetRelative("Install"), true);
|
||||||
}
|
}
|
||||||
Step(5, "Creating shortcut");
|
Step(5, "Creating shortcut");
|
||||||
Shortcut.Make(_lib.V1.PathTool.GetRelative("Install", "UpTool2.exe"),
|
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
|
||||||
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
|
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
|
||||||
"UpTool2.lnk"));
|
"UpTool2.lnk"));
|
||||||
Step(6, "Preparing Repos");
|
Step(6, "Preparing Repos");
|
||||||
_lib.V1.XmlTool.FixXml();
|
XmlTool.FixXml();
|
||||||
_lib.V2.RepoManagement.FetchRepos();
|
RepoManagement.FetchRepos();
|
||||||
if (pathBox.Checked)
|
if (pathBox.Checked)
|
||||||
{
|
{
|
||||||
Step(7, startupBox.Checked ? "Creating PATH & Autostart entry" : "Creating PATH entry");
|
Step(7, startupBox.Checked ? "Creating PATH & Autostart entry" : "Creating PATH entry");
|
||||||
if (!Path.Content.Contains(Path.GetName(_lib.V1.PathTool.GetRelative("Install"))))
|
if (!Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install"))))
|
||||||
Path.Append(_lib.V1.PathTool.GetRelative("Install"));
|
Path.Append(PathTool.GetRelative("Install"));
|
||||||
if (startupBox.Checked)
|
if (startupBox.Checked)
|
||||||
_rkApp.SetValue(AppName, updateAppsBox.Checked ? "uptool dist-upgrade" : "uptool upgrade-self");
|
_rkApp.SetValue(AppName, updateAppsBox.Checked ? "uptool dist-upgrade" : "uptool upgrade-self");
|
||||||
else if (_rkApp.GetValue(AppName) != null)
|
else if (_rkApp.GetValue(AppName) != null)
|
||||||
|
@ -12,10 +12,18 @@ namespace Installer
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
try
|
||||||
Application.EnableVisualStyles();
|
{
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
MutexLock.Lock();
|
||||||
Application.Run(new InstallerForm());
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new InstallerForm());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
MutexLock.Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ namespace Installer
|
|||||||
|
|
||||||
public Tuple<bool, byte[]> Download(Uri link)
|
public Tuple<bool, byte[]> Download(Uri link)
|
||||||
{
|
{
|
||||||
using WebClient cli = new();
|
using WebClient cli = new WebClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new Tuple<bool, byte[]>(true, cli.DownloadData(link));
|
return new Tuple<bool, byte[]>(true, cli.DownloadData(link));
|
||||||
@ -29,10 +29,10 @@ namespace Installer
|
|||||||
|
|
||||||
public string FetchImageB64(Uri link)
|
public string FetchImageB64(Uri link)
|
||||||
{
|
{
|
||||||
using WebClient client = new();
|
using WebClient client = new WebClient();
|
||||||
Image src = Image.FromStream(
|
Image src = Image.FromStream(
|
||||||
client.OpenRead(link));
|
client.OpenRead(link));
|
||||||
Bitmap dest = new(70, 70);
|
Bitmap dest = new Bitmap(70, 70);
|
||||||
dest.SetResolution(src.HorizontalResolution, src.VerticalResolution);
|
dest.SetResolution(src.HorizontalResolution, src.VerticalResolution);
|
||||||
using (Graphics g = Graphics.FromImage(dest))
|
using (Graphics g = Graphics.FromImage(dest))
|
||||||
{
|
{
|
||||||
@ -41,12 +41,12 @@ namespace Installer
|
|||||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
using ImageAttributes wrapMode = new();
|
using ImageAttributes wrapMode = new ImageAttributes();
|
||||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||||
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height,
|
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height,
|
||||||
GraphicsUnit.Pixel, wrapMode);
|
GraphicsUnit.Pixel, wrapMode);
|
||||||
}
|
}
|
||||||
using MemoryStream ms = new();
|
using MemoryStream ms = new MemoryStream();
|
||||||
dest.Save(ms, ImageFormat.Png);
|
dest.Save(ms, ImageFormat.Png);
|
||||||
return Convert.ToBase64String(ms.ToArray());
|
return Convert.ToBase64String(ms.ToArray());
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>Installer</AssemblyName>
|
<AssemblyName>Installer</AssemblyName>
|
||||||
<RootNamespace>Installer</RootNamespace>
|
<RootNamespace>Installer</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -12,8 +12,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0002" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20253.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.Invocation;
|
using System.CommandLine.Invocation;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -7,26 +7,21 @@ using System.Net;
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace Installer
|
namespace Installer
|
||||||
{
|
{
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
public static bool Basic;
|
|
||||||
private static UpToolLibMain _lib;
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
|
MutexLock.Lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Basic = args.Length > 0 && args[0].ToLower() == "--basic";
|
ExternalFunctionalityManager.Init(new UtLibFunctions());
|
||||||
_lib = new UpToolLibMain(new UtLibFunctions());
|
RootCommand rootCommand = new RootCommand();
|
||||||
RootCommand rootCommand = new();
|
Command install = new Command("install", "Install UpTool")
|
||||||
rootCommand.AddGlobalOption(new Option<bool>("--basic",
|
|
||||||
"Use only basic console functionality. Must be the first parameter in the call"));
|
|
||||||
Command install = new("install", "Install UpTool")
|
|
||||||
{
|
{
|
||||||
new Option<bool>(new[] {"--noPrep", "-p"}, "Doesn't initialize repos. Use with caution!")
|
new Option<bool>(new[] {"--noPrep", "-p"}, "Doesn't initialize repos. Use with caution!")
|
||||||
};
|
};
|
||||||
@ -43,48 +38,45 @@ namespace Installer
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_lib?.Dispose();
|
MutexLock.Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Install(bool noPrep)
|
private static void Install(bool noPrep)
|
||||||
{
|
{
|
||||||
WebClient client = new();
|
WebClient client = new WebClient();
|
||||||
Console.WriteLine("Downloading metadata");
|
Console.WriteLine("Downloading metadata");
|
||||||
UpdateCheck check =
|
UpdateCheck.Reload("https://github.com/JFronny/UpTool2/releases/latest/download/meta.xml");
|
||||||
_lib.V2.UpdateChecker.Check(
|
|
||||||
"https://gitlab.com/JFronny/UpTool2/-/jobs/artifacts/master/raw/meta.xml?job=uptool");
|
|
||||||
PathTool pathTool = _lib.V1.PathTool;
|
|
||||||
Console.WriteLine("Downloading binary");
|
Console.WriteLine("Downloading binary");
|
||||||
byte[] dl = client.DownloadData(check.App);
|
byte[] dl = client.DownloadData(UpdateCheck.App);
|
||||||
Console.WriteLine("Verifying integrity");
|
Console.WriteLine("Verifying integrity");
|
||||||
using (SHA256CryptoServiceProvider sha256 = new())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty)
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty)
|
||||||
.ToUpper();
|
.ToUpper();
|
||||||
if (pkgHash != check.AppHash)
|
if (pkgHash != UpdateCheck.AppHash)
|
||||||
throw new Exception($@"The hash is not equal to the one stored in the repo:
|
throw new Exception($@"The hash is not equal to the one stored in the repo:
|
||||||
Package: {pkgHash}
|
Package: {pkgHash}
|
||||||
Online: {check.AppHash}");
|
Online: {UpdateCheck.AppHash}");
|
||||||
}
|
}
|
||||||
Console.WriteLine("Extracting");
|
Console.WriteLine("Extracting");
|
||||||
if (Directory.Exists(pathTool.GetRelative("Install")))
|
if (Directory.Exists(PathTool.GetRelative("Install")))
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.GetFiles(pathTool.GetRelative("Install"))) File.Delete(file);
|
foreach (string file in Directory.GetFiles(PathTool.GetRelative("Install"))) File.Delete(file);
|
||||||
foreach (string dir in Directory.GetDirectories(pathTool.GetRelative("Install")))
|
foreach (string dir in Directory.GetDirectories(PathTool.GetRelative("Install")))
|
||||||
if (Path.GetFileName(dir) != "tmp")
|
if (Path.GetFileName(dir) != "tmp")
|
||||||
Directory.Delete(dir, true);
|
Directory.Delete(dir, true);
|
||||||
}
|
}
|
||||||
Directory.CreateDirectory(pathTool.GetRelative("Install"));
|
Directory.CreateDirectory(PathTool.GetRelative("Install"));
|
||||||
using (MemoryStream ms = new(dl))
|
using (MemoryStream ms = new MemoryStream(dl))
|
||||||
{
|
{
|
||||||
using ZipArchive ar = new(ms);
|
using ZipArchive ar = new ZipArchive(ms);
|
||||||
ar.ExtractToDirectory(pathTool.GetRelative("Install"), true);
|
ar.ExtractToDirectory(PathTool.GetRelative("Install"), true);
|
||||||
}
|
}
|
||||||
if (noPrep) return;
|
if (noPrep) return;
|
||||||
Console.WriteLine("Preparing Repos");
|
Console.WriteLine("Preparing Repos");
|
||||||
_lib.V1.XmlTool.FixXml();
|
XmlTool.FixXml();
|
||||||
_lib.V2.RepoManagement.FetchRepos();
|
RepoManagement.FetchRepos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ using System.Threading;
|
|||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using static Installer.Program;
|
|
||||||
|
|
||||||
namespace Installer
|
namespace Installer
|
||||||
{
|
{
|
||||||
@ -13,7 +12,7 @@ namespace Installer
|
|||||||
{
|
{
|
||||||
public Tuple<bool, byte[]> Download(Uri link)
|
public Tuple<bool, byte[]> Download(Uri link)
|
||||||
{
|
{
|
||||||
using WebClient client = new();
|
using WebClient client = new WebClient();
|
||||||
byte[] result = new byte[0];
|
byte[] result = new byte[0];
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@ -26,12 +25,9 @@ namespace Installer
|
|||||||
};
|
};
|
||||||
client.DownloadProgressChanged += (sender, e) =>
|
client.DownloadProgressChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (!Basic)
|
Console.Write(
|
||||||
{
|
$"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
|
||||||
Console.Write(
|
Console.CursorLeft = 0;
|
||||||
$"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
|
|
||||||
Console.CursorLeft = 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
client.DownloadDataAsync(link);
|
client.DownloadDataAsync(link);
|
||||||
while (!finished)
|
while (!finished)
|
||||||
@ -41,76 +37,64 @@ namespace Installer
|
|||||||
|
|
||||||
public string FetchImageB64(Uri link)
|
public string FetchImageB64(Uri link)
|
||||||
{
|
{
|
||||||
using WebClient client = new();
|
using WebClient client = new WebClient();
|
||||||
using Image image = Image.Load(client.OpenRead(link));
|
using Image image = Image.Load(client.OpenRead(link));
|
||||||
using MemoryStream ms = new();
|
image.Mutate(x => x.Resize(70, 70));
|
||||||
|
using MemoryStream ms = new MemoryStream();
|
||||||
image.SaveAsPng(ms);
|
image.SaveAsPng(ms);
|
||||||
return Convert.ToBase64String(ms.ToArray());
|
return Convert.ToBase64String(ms.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool YesNoDialog(string text, bool defaultVal)
|
public bool YesNoDialog(string text, bool defaultVal)
|
||||||
{
|
{
|
||||||
if (Basic)
|
bool choosing = true;
|
||||||
|
bool current = defaultVal;
|
||||||
|
Console.WriteLine(text);
|
||||||
|
while (choosing)
|
||||||
{
|
{
|
||||||
Console.WriteLine(text);
|
Console.CursorLeft = 0;
|
||||||
Console.WriteLine($"Selecting: {defaultVal}");
|
Console.BackgroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
||||||
return defaultVal;
|
Console.ForegroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
||||||
}
|
Console.Write("Yes");
|
||||||
else
|
|
||||||
{
|
|
||||||
bool choosing = true;
|
|
||||||
bool current = defaultVal;
|
|
||||||
Console.WriteLine(text);
|
|
||||||
while (choosing)
|
|
||||||
{
|
|
||||||
Console.CursorLeft = 0;
|
|
||||||
Console.BackgroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
|
||||||
Console.ForegroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
|
||||||
Console.Write("Yes");
|
|
||||||
Console.ResetColor();
|
|
||||||
Console.Write(" ");
|
|
||||||
Console.BackgroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
|
||||||
Console.ForegroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
|
||||||
Console.Write("No");
|
|
||||||
Console.ResetColor();
|
|
||||||
switch (Console.ReadKey().Key)
|
|
||||||
{
|
|
||||||
case ConsoleKey.LeftArrow:
|
|
||||||
case ConsoleKey.RightArrow:
|
|
||||||
current = !current;
|
|
||||||
break;
|
|
||||||
case ConsoleKey.Enter:
|
|
||||||
choosing = false;
|
|
||||||
break;
|
|
||||||
case ConsoleKey.Escape:
|
|
||||||
current = defaultVal;
|
|
||||||
choosing = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
Console.WriteLine($" Selecting: {current}");
|
Console.Write(" ");
|
||||||
return current;
|
Console.BackgroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
||||||
|
Console.ForegroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
||||||
|
Console.Write("No");
|
||||||
|
Console.ResetColor();
|
||||||
|
switch (Console.ReadKey().Key)
|
||||||
|
{
|
||||||
|
case ConsoleKey.LeftArrow:
|
||||||
|
case ConsoleKey.RightArrow:
|
||||||
|
current = !current;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Enter:
|
||||||
|
choosing = false;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Escape:
|
||||||
|
current = defaultVal;
|
||||||
|
choosing = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Console.ResetColor();
|
||||||
|
Console.WriteLine($" Selecting: {current}");
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OkDialog(string text)
|
public void OkDialog(string text)
|
||||||
{
|
{
|
||||||
if (Basic)
|
Console.WriteLine(text);
|
||||||
Console.WriteLine(text);
|
Console.BackgroundColor = ConsoleColor.White;
|
||||||
else
|
Console.Write("OK");
|
||||||
{
|
Console.ResetColor();
|
||||||
Console.WriteLine(text);
|
Console.ReadKey();
|
||||||
Console.BackgroundColor = ConsoleColor.White;
|
|
||||||
Console.Write("OK");
|
|
||||||
Console.ResetColor();
|
|
||||||
Console.ReadKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object GetDefaultIcon() => 0;
|
public object GetDefaultIcon() => 0;
|
||||||
|
|
||||||
public object ImageFromB64(string b64) => 0;
|
public object ImageFromB64(string b64) => 0;
|
||||||
|
|
||||||
public void Log(string text) => Console.WriteLine(text);
|
public void Log(string text) => Console.WriteLine(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2020 J. Fronny
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
17
README.md
17
README.md
@ -1,8 +1,11 @@
|
|||||||
# UpTool2
|
# UpTool2
|
||||||
Downloading software from online repos since 2019\
|
Downloading software from online repos since 2019\
|
||||||
[![GitLab pipeline](https://img.shields.io/gitlab/pipeline/JFronny/UpTool2)](https://gitlab.com/JFronny/UpTool2/builds)
|
[![CodeFactor](https://www.codefactor.io/repository/github/jfronny/uptool2/badge)](https://www.codefactor.io/repository/github/jfronny/uptool2)
|
||||||
|
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/JFronny/UpTool2)](https://github.com/JFronny/UpTool2/releases/latest)
|
||||||
|
[![GitHub repo size](https://img.shields.io/github/repo-size/JFronny/UpTool2)](https://github.com/JFronny/UpTool2/archive/master.zip)
|
||||||
|
[![GitHub All Releases](https://img.shields.io/github/downloads/JFronny/UpTool2/total)](https://github.com/JFronny/UpTool2/releases)
|
||||||
[![Discord](https://img.shields.io/discord/466965965658128384)](https://discordapp.com/invite/UjhHBqt)
|
[![Discord](https://img.shields.io/discord/466965965658128384)](https://discordapp.com/invite/UjhHBqt)
|
||||||
[![Default Repo](https://img.shields.io/badge/Default-Repo-informational)](https://gitlab.com/JFronny/UpTool2/snippets/1988600)
|
[![Default Repo](https://img.shields.io/badge/Default-Repo-informational)](https://gist.github.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4)
|
||||||
## How to automate UpTool2 deployments
|
## How to automate UpTool2 deployments
|
||||||
You will want the assembly version to automatically increment.
|
You will want the assembly version to automatically increment.
|
||||||
To achieve this you have to add this:\
|
To achieve this you have to add this:\
|
||||||
@ -13,14 +16,14 @@ Now you can add this\
|
|||||||
as a PostBuild event to automatically run pkgtool. Customize this if you need to.\
|
as a PostBuild event to automatically run pkgtool. Customize this if you need to.\
|
||||||
For GitHub actions I wrote [this](https://github.com/JFronny/CC-Clicker/blob/master/.github/workflows/main.yml).\
|
For GitHub actions I wrote [this](https://github.com/JFronny/CC-Clicker/blob/master/.github/workflows/main.yml).\
|
||||||
If you copy it, make sure to replace the descriptions and ID under the `Generate XML` step\
|
If you copy it, make sure to replace the descriptions and ID under the `Generate XML` step\
|
||||||
You can also add something like this to your Readme: [![UpTool2](https://img.shields.io/badge/Get%20it-on%20UpTool2-blue)](https://jfronny.gitlab.io/home/uptool)\
|
You can also add something like this to your Readme: [![UpTool2](https://img.shields.io/github/v/tag/JFronny/CC-Clicker?color=informational&label=UpTool2)](https://jfronny.github.io/home/uptool)\
|
||||||
(Look at the source for the MD Code)
|
(Look at the source for the MD Code)
|
||||||
## Folder layout
|
## Folder layout
|
||||||
- %APPDATA%\UpTool2
|
- %APPDATA%\UpTool2
|
||||||
- Apps
|
- Apps
|
||||||
- __APPGUID
|
- __APPGUID
|
||||||
- `info.xml` Local copy of some app information, like [this](https://gitlab.com/JFronny/UpTool2#app-layout) but missing ID, File, Hash, Platform and Icon
|
- `info.xml` Local copy of some app information, like [this](https://github.com/JFronny/UpTool2#app-layout) but missing ID, File, Hash, Platform and Icon
|
||||||
- [`package.zip`](https://gitlab.com/JFronny/UpTool2#package-layout) The package that was downloaded on install
|
- [`package.zip`](https://github.com/JFronny/UpTool2#package-layout) The package that was downloaded on install
|
||||||
- `app` The app install path
|
- `app` The app install path
|
||||||
- `__APPFILES` Copy of the app files from above, may contain user-configs
|
- `__APPFILES` Copy of the app files from above, may contain user-configs
|
||||||
- `info.xml` File used by UpTool2 for saving info
|
- `info.xml` File used by UpTool2 for saving info
|
||||||
@ -30,7 +33,7 @@ You can also add something like this to your Readme: [![UpTool2](https://img.shi
|
|||||||
- `Name` The display name of the repository
|
- `Name` The display name of the repository
|
||||||
- `Link` The source of the repo xml
|
- `Link` The source of the repo xml
|
||||||
- `Local Repo` A preprocessed copy of the online repos
|
- `Local Repo` A preprocessed copy of the online repos
|
||||||
- [`__APP`](https://gitlab.com/JFronny/UpTool2#app-layout) A normal app with the icon processed as Base64
|
- [`__APP`](https://github.com/JFronny/UpTool2#app-layout) A normal app with the icon processed as Base64
|
||||||
- `Install` The folder containing the actual tool
|
- `Install` The folder containing the actual tool
|
||||||
- `__ZIP CONTENTS` The app files
|
- `__ZIP CONTENTS` The app files
|
||||||
- `tmp` A temporary folder used during updates
|
- `tmp` A temporary folder used during updates
|
||||||
@ -39,7 +42,7 @@ You can also add something like this to your Readme: [![UpTool2](https://img.shi
|
|||||||
- `repo` The main repo tag
|
- `repo` The main repo tag
|
||||||
- `__APPLINK` Links to external app XMLs
|
- `__APPLINK` Links to external app XMLs
|
||||||
- `__REPOLINK` Links to external repos
|
- `__REPOLINK` Links to external repos
|
||||||
- [`__APP`](https://gitlab.com/JFronny/UpTool2#app-layout) Apps
|
- [`__APP`](https://github.com/JFronny/UpTool2#app-layout) Apps
|
||||||
## App layout
|
## App layout
|
||||||
- app
|
- app
|
||||||
- `Name` Name of the application
|
- `Name` Name of the application
|
||||||
|
@ -14,7 +14,7 @@ namespace UpTool_build_tool
|
|||||||
{
|
{
|
||||||
installBat += "\r\n";
|
installBat += "\r\n";
|
||||||
installBat +=
|
installBat +=
|
||||||
$@"powershell ""$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk');$s.TargetPath='%cd%\{Path.GetFileName(mainBin)}';$s.Save()""";
|
$@"powershell ""$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk');$s.TargetPath='%cd%\{mainBin}';$s.Save()""";
|
||||||
removeBat += "\r\n";
|
removeBat += "\r\n";
|
||||||
removeBat += $@"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
|
removeBat += $@"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using CC_Functions.Core;
|
using CC_Functions.Misc;
|
||||||
|
|
||||||
namespace UpTool_build_tool
|
namespace UpTool_build_tool
|
||||||
{
|
{
|
||||||
@ -30,13 +30,13 @@ namespace UpTool_build_tool
|
|||||||
"This indicates that your program supports multiple platforms natively and doesn't require WINE")
|
"This indicates that your program supports multiple platforms natively and doesn't require WINE")
|
||||||
};
|
};
|
||||||
build.Handler =
|
build.Handler =
|
||||||
CommandHandler.Create((Action<string?, string, string, string, string, bool, bool, bool>) Build);
|
CommandHandler.Create((Action<string, string, string, string, string, bool, bool, bool>) Build);
|
||||||
rootCommand.AddCommand(build);
|
rootCommand.AddCommand(build);
|
||||||
return rootCommand.InvokeAsync(args).Result;
|
return rootCommand.InvokeAsync(args).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Build(string? binDir, string? mainBin, string? packageFile, string? postInstall,
|
private static void Build(string binDir, string mainBin, string packageFile, string postInstall,
|
||||||
string? postRemove, bool noLogo, bool noShortcuts, bool noWine)
|
string postRemove, bool noLogo, bool noShortcuts, bool noWine)
|
||||||
{
|
{
|
||||||
Stopwatch watch = Stopwatch.StartNew();
|
Stopwatch watch = Stopwatch.StartNew();
|
||||||
if (!noLogo)
|
if (!noLogo)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace UpTool_build_tool
|
namespace UpTool_build_tool
|
||||||
@ -18,7 +17,7 @@ namespace UpTool_build_tool
|
|||||||
{
|
{
|
||||||
installSh += $@"
|
installSh += $@"
|
||||||
echo ""[Desktop Entry]"" > {lnkName}
|
echo ""[Desktop Entry]"" > {lnkName}
|
||||||
echo ""Exec={(wine ? "wine " : "")}{Path.GetFileName(mainBin)}"" >> {lnkName}
|
echo ""Exec={(wine ? "wine " : "")}{mainBin}"" >> {lnkName}
|
||||||
echo ""Icon=application/x-shellscript"" >> {lnkName}
|
echo ""Icon=application/x-shellscript"" >> {lnkName}
|
||||||
echo ""Name={upRgx.Replace(programName, "")}"" >> {lnkName}
|
echo ""Name={upRgx.Replace(programName, "")}"" >> {lnkName}
|
||||||
echo ""StartupNotify=false"" >> {lnkName}
|
echo ""StartupNotify=false"" >> {lnkName}
|
||||||
@ -30,7 +29,7 @@ echo ""Type=Application"" >> {lnkName}";
|
|||||||
if (!string.IsNullOrWhiteSpace(mainBin))
|
if (!string.IsNullOrWhiteSpace(mainBin))
|
||||||
{
|
{
|
||||||
removeSh += "\r\n";
|
removeSh += "\r\n";
|
||||||
removeSh += $@"pkill -f ""{Path.GetFileName(mainBin)}""";
|
removeSh += $@"pkill -f ""{mainBin}""";
|
||||||
}
|
}
|
||||||
installSh += $"\r\n{postInstall}";
|
installSh += $"\r\n{postInstall}";
|
||||||
removeSh += $"\r\n{postRemove}";
|
removeSh += $"\r\n{postRemove}";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>UpTool_build_tool</RootNamespace>
|
<RootNamespace>UpTool_build_tool</RootNamespace>
|
||||||
<AssemblyName>pkgtool</AssemblyName>
|
<AssemblyName>pkgtool</AssemblyName>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<ApplicationIcon>..\UpTool2.ico</ApplicationIcon>
|
<ApplicationIcon>..\UpTool2.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CC-Functions.Core" Version="1.1.7628.34181" />
|
<PackageReference Include="CC-Functions.Misc" Version="1.1.7468.32091" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20253.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
23
UpTool2.sln
23
UpTool2.sln
@ -8,9 +8,9 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9841227C-3F1B-4C32-8123-3DB2CF4E15EE}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9841227C-3F1B-4C32-8123-3DB2CF4E15EE}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
|
.github\workflows\main.yml = .github\workflows\main.yml
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
CLI.md = CLI.md
|
CLI.md = CLI.md
|
||||||
.gitlab-ci.yml = .gitlab-ci.yml
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UpTool build tool", "UpTool build tool\UpTool build tool.csproj", "{AAB8D6BA-3A43-4DC4-95EE-6757482B77FD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UpTool build tool", "UpTool build tool\UpTool build tool.csproj", "{AAB8D6BA-3A43-4DC4-95EE-6757482B77FD}"
|
||||||
@ -29,12 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{0E7784
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallerCLI", "InstallerCLI\InstallerCLI.csproj", "{493B2CC5-29E9-4F10-A2F5-E10B9584D667}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallerCLI", "InstallerCLI\InstallerCLI.csproj", "{493B2CC5-29E9-4F10-A2F5-E10B9584D667}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpToolEto", "UpToolEto\UpToolEto\UpToolEto.csproj", "{213FF69B-426E-475F-8A77-0A20EA4257C2}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpToolEto.Gtk", "UpToolEto\UpToolEto.Gtk\UpToolEto.Gtk.csproj", "{8A544AEA-3081-45C9-BED2-7E424EB287B1}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpToolEto.Wpf", "UpToolEto\UpToolEto.Wpf\UpToolEto.Wpf.csproj", "{C89EC79F-CC2B-4B8E-B4CB-D4DFD30A58AB}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -65,18 +59,6 @@ Global
|
|||||||
{493B2CC5-29E9-4F10-A2F5-E10B9584D667}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{493B2CC5-29E9-4F10-A2F5-E10B9584D667}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{493B2CC5-29E9-4F10-A2F5-E10B9584D667}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{493B2CC5-29E9-4F10-A2F5-E10B9584D667}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{493B2CC5-29E9-4F10-A2F5-E10B9584D667}.Release|Any CPU.Build.0 = Release|Any CPU
|
{493B2CC5-29E9-4F10-A2F5-E10B9584D667}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{213FF69B-426E-475F-8A77-0A20EA4257C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{213FF69B-426E-475F-8A77-0A20EA4257C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{213FF69B-426E-475F-8A77-0A20EA4257C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{213FF69B-426E-475F-8A77-0A20EA4257C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{8A544AEA-3081-45C9-BED2-7E424EB287B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{8A544AEA-3081-45C9-BED2-7E424EB287B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{8A544AEA-3081-45C9-BED2-7E424EB287B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{8A544AEA-3081-45C9-BED2-7E424EB287B1}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C89EC79F-CC2B-4B8E-B4CB-D4DFD30A58AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C89EC79F-CC2B-4B8E-B4CB-D4DFD30A58AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C89EC79F-CC2B-4B8E-B4CB-D4DFD30A58AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C89EC79F-CC2B-4B8E-B4CB-D4DFD30A58AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -91,8 +73,5 @@ Global
|
|||||||
{3EC369B9-D927-4A53-BE1A-7E7006081BCE} = {3CFAB991-C12A-4B51-BC91-6965133DAF53}
|
{3EC369B9-D927-4A53-BE1A-7E7006081BCE} = {3CFAB991-C12A-4B51-BC91-6965133DAF53}
|
||||||
{1D273392-3796-4BE9-A67F-BB402315D52D} = {EA919DFD-766B-423C-99DF-C99356592842}
|
{1D273392-3796-4BE9-A67F-BB402315D52D} = {EA919DFD-766B-423C-99DF-C99356592842}
|
||||||
{493B2CC5-29E9-4F10-A2F5-E10B9584D667} = {3CFAB991-C12A-4B51-BC91-6965133DAF53}
|
{493B2CC5-29E9-4F10-A2F5-E10B9584D667} = {3CFAB991-C12A-4B51-BC91-6965133DAF53}
|
||||||
{213FF69B-426E-475F-8A77-0A20EA4257C2} = {EA919DFD-766B-423C-99DF-C99356592842}
|
|
||||||
{8A544AEA-3081-45C9-BED2-7E424EB287B1} = {EA919DFD-766B-423C-99DF-C99356592842}
|
|
||||||
{C89EC79F-CC2B-4B8E-B4CB-D4DFD30A58AB} = {EA919DFD-766B-423C-99DF-C99356592842}
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -4,34 +4,33 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using UpTool2.Task;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using UpToolLib.v1.Tool;
|
#endif
|
||||||
using UpToolLib.v2;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
public sealed partial class MainForm : Form
|
public sealed partial class MainForm : Form
|
||||||
{
|
{
|
||||||
private readonly HelpEventHandler _help;
|
private readonly HelpEventHandler _help;
|
||||||
private List<AppTask> _tasks;
|
private List<IAppTask> _tasks;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_tasks = new List<AppTask>();
|
_tasks = new List<IAppTask>();
|
||||||
_help = MainForm_HelpRequested;
|
_help = MainForm_HelpRequested;
|
||||||
HelpRequested += _help;
|
HelpRequested += _help;
|
||||||
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
||||||
if (Program.Online)
|
if (Program.Online)
|
||||||
{
|
RepoManagement.FetchRepos();
|
||||||
Program.SetSplash(8, "Fetching repositories");
|
|
||||||
Program.Lib.V2.RepoManagement.FetchRepos();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Starting in offline mode!");
|
MessageBox.Show("Starting in offline mode!");
|
||||||
@ -39,10 +38,10 @@ namespace UpTool2
|
|||||||
filterBox.Enabled = false;
|
filterBox.Enabled = false;
|
||||||
filterBox.SelectedIndex = 2;
|
filterBox.SelectedIndex = 2;
|
||||||
}
|
}
|
||||||
Program.SetSplash(9, "Reloading data");
|
Program.SetSplash(8, "Reloading data");
|
||||||
ReloadElements();
|
ReloadElements();
|
||||||
if (!Directory.Exists(Program.Lib.V1.PathTool.AppsPath))
|
if (!Directory.Exists(PathTool.AppsPath))
|
||||||
Directory.CreateDirectory(Program.Lib.V1.PathTool.AppsPath);
|
Directory.CreateDirectory(PathTool.AppsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Action_install_Click(object sender, EventArgs e)
|
private void Action_install_Click(object sender, EventArgs e)
|
||||||
@ -55,7 +54,7 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tasks.Add(Program.Lib.V2.TaskFactory.CreateInstall(tmp, ReloadElements));
|
_tasks.Add(new InstallTask(tmp, ReloadElements));
|
||||||
action_install.BackColor = Color.Green;
|
action_install.BackColor = Color.Green;
|
||||||
}
|
}
|
||||||
UpdateChangesLabel();
|
UpdateChangesLabel();
|
||||||
@ -71,7 +70,7 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tasks.Add(Program.Lib.V2.TaskFactory.CreateRemove(tmp, ReloadElements));
|
_tasks.Add(new RemoveTask(tmp, ReloadElements));
|
||||||
action_remove.BackColor = Color.Green;
|
action_remove.BackColor = Color.Green;
|
||||||
}
|
}
|
||||||
UpdateChangesLabel();
|
UpdateChangesLabel();
|
||||||
@ -82,7 +81,7 @@ namespace UpTool2
|
|||||||
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
if (!_tasks.Any(s => s is UploadTask t && t.ZipFile == searchPackageDialog.FileName))
|
if (!_tasks.Any(s => s is UploadTask t && t.ZipFile == searchPackageDialog.FileName))
|
||||||
_tasks.Add(Program.Lib.V2.TaskFactory.CreateUpload(searchPackageDialog.FileName, AppNameDialog.Show(), ReloadElements));
|
_tasks.Add(new UploadTask(searchPackageDialog.FileName, AppNameDialog.Show(), ReloadElements));
|
||||||
UpdateChangesLabel();
|
UpdateChangesLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tasks.Add(Program.Lib.V2.TaskFactory.CreateUpdate(tmp, ReloadElements));
|
_tasks.Add(new UpdateTask(tmp, ReloadElements));
|
||||||
action_update.BackColor = Color.Green;
|
action_update.BackColor = Color.Green;
|
||||||
}
|
}
|
||||||
UpdateChangesLabel();
|
UpdateChangesLabel();
|
||||||
@ -111,7 +110,7 @@ namespace UpTool2
|
|||||||
infoPanel_Description.Invalidate();
|
infoPanel_Description.Invalidate();
|
||||||
int f = sidebarPanel.Controls.Count;
|
int f = sidebarPanel.Controls.Count;
|
||||||
for (int i = 0; i < f; i++) sidebarPanel.Controls[0].Dispose();
|
for (int i = 0; i < f; i++) sidebarPanel.Controls[0].Dispose();
|
||||||
Program.Lib.V1.Apps.Clear();
|
GlobalVariables.Apps.Clear();
|
||||||
//add
|
//add
|
||||||
toolTip.SetToolTip(controls_settings, "Settings");
|
toolTip.SetToolTip(controls_settings, "Settings");
|
||||||
toolTip.SetToolTip(controls_reload, "Refresh repositories");
|
toolTip.SetToolTip(controls_reload, "Refresh repositories");
|
||||||
@ -121,9 +120,9 @@ namespace UpTool2
|
|||||||
toolTip.SetToolTip(action_remove, "Remove");
|
toolTip.SetToolTip(action_remove, "Remove");
|
||||||
toolTip.SetToolTip(action_update, "Update");
|
toolTip.SetToolTip(action_update, "Update");
|
||||||
toolTip.SetToolTip(action_run, "Run");
|
toolTip.SetToolTip(action_run, "Run");
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
int availableUpdates = 0;
|
int availableUpdates = 0;
|
||||||
foreach (App app in Program.Lib.V1.Apps.Values)
|
foreach (App app in GlobalVariables.Apps.Values)
|
||||||
{
|
{
|
||||||
Panel sidebarIcon = new Panel
|
Panel sidebarIcon = new Panel
|
||||||
{
|
{
|
||||||
@ -133,13 +132,7 @@ namespace UpTool2
|
|||||||
BackgroundImage = (Bitmap) app.Icon,
|
BackgroundImage = (Bitmap) app.Icon,
|
||||||
BackgroundImageLayout = ImageLayout.Stretch
|
BackgroundImageLayout = ImageLayout.Stretch
|
||||||
};
|
};
|
||||||
sidebarIcon.Paint += (sender, args) =>
|
bool updateable = !app.Local && (app.Status & Status.Updatable) == Status.Updatable;
|
||||||
{
|
|
||||||
args.Graphics.Clear(sidebarIcon.BackColor);
|
|
||||||
args.Graphics.DrawImage(sidebarIcon.BackgroundImage, args.ClipRectangle,
|
|
||||||
new Rectangle(new Point(0, 0), sidebarIcon.BackgroundImage.Size), GraphicsUnit.Pixel);
|
|
||||||
};
|
|
||||||
bool updateable = !app.Local && app.Status.Contains(Status.Updatable);
|
|
||||||
sidebarIcon.Click += (sender, e) =>
|
sidebarIcon.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
infoPanel_Title.Text = app.Name;
|
infoPanel_Title.Text = app.Name;
|
||||||
@ -164,7 +157,7 @@ namespace UpTool2
|
|||||||
else
|
else
|
||||||
action_update.ResetBackColor();
|
action_update.ResetBackColor();
|
||||||
action_run.Tag = app;
|
action_run.Tag = app;
|
||||||
action_run.Enabled = app.Status.Contains(Status.Installed) && !app.Local &&
|
action_run.Enabled = (app.Status & Status.Installed) == Status.Installed && !app.Local &&
|
||||||
app.Runnable && Directory.Exists(app.AppPath);
|
app.Runnable && Directory.Exists(app.AppPath);
|
||||||
};
|
};
|
||||||
if (updateable)
|
if (updateable)
|
||||||
@ -181,7 +174,7 @@ namespace UpTool2
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Program.Lib.V1.AppExtras.RunApp((App) action_run.Tag);
|
AppExtras.RunApp((App) action_run.Tag);
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
@ -191,19 +184,8 @@ namespace UpTool2
|
|||||||
|
|
||||||
private void Controls_reload_Click(object sender, EventArgs e)
|
private void Controls_reload_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Enabled = false;
|
RepoManagement.FetchRepos();
|
||||||
if (MessageBox.Show("This may take a few minutes. Are you sure?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
ReloadElements();
|
||||||
{
|
|
||||||
new Thread(() =>
|
|
||||||
{
|
|
||||||
Program.Lib.V2.RepoManagement.FetchRepos();
|
|
||||||
Invoke((Action) (() =>
|
|
||||||
{
|
|
||||||
ReloadElements();
|
|
||||||
Enabled = true;
|
|
||||||
}));
|
|
||||||
}).Start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().ShowDialog();
|
private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().ShowDialog();
|
||||||
@ -211,26 +193,23 @@ namespace UpTool2
|
|||||||
private void ClearSelection()
|
private void ClearSelection()
|
||||||
{
|
{
|
||||||
action_install.Enabled = false;
|
action_install.Enabled = false;
|
||||||
action_install.ResetBackColor();
|
|
||||||
action_remove.Enabled = false;
|
action_remove.Enabled = false;
|
||||||
action_remove.ResetBackColor();
|
|
||||||
action_update.Enabled = false;
|
action_update.Enabled = false;
|
||||||
action_update.ResetBackColor();
|
|
||||||
action_run.Enabled = false;
|
action_run.Enabled = false;
|
||||||
action_run.ResetBackColor();
|
|
||||||
infoPanel_Title.Text = "";
|
infoPanel_Title.Text = "";
|
||||||
infoPanel_Description.Text = "";
|
infoPanel_Description.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSidebarV(object sender, EventArgs e)
|
private void UpdateSidebarV(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
if (searchBox.Text == "!DEBUG:PRINT!")
|
if (searchBox.Text == "!DEBUG:PRINT!")
|
||||||
{
|
{
|
||||||
searchBox.Text = "!DEBUG:PRINT";
|
searchBox.Text = "!DEBUG:PRINT";
|
||||||
string tmpFile = Path.GetTempFileName();
|
string tmpFile = Path.GetTempFileName();
|
||||||
File.WriteAllText(tmpFile,
|
File.WriteAllText(tmpFile,
|
||||||
string.Join("\r\n\r\n",
|
string.Join("\r\n\r\n",
|
||||||
Program.Lib.V1.Apps.Values.Select(app => app.ToString()).Concat(new[]
|
GlobalVariables.Apps.Values.Select(app => app.ToString()).Concat(new[]
|
||||||
{
|
{
|
||||||
$"Assembly version: {Assembly.GetExecutingAssembly().GetName().Version}"
|
$"Assembly version: {Assembly.GetExecutingAssembly().GetName().Version}"
|
||||||
}).ToArray()));
|
}).ToArray()));
|
||||||
@ -242,16 +221,20 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(searchBox.Text);
|
#endif
|
||||||
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
|
App[] apps = AppExtras.FindApps(searchBox.Text);
|
||||||
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
|
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
|
||||||
{
|
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
|
||||||
Panel sidebarIcon = (Panel) sidebarPanel.Controls[i];
|
{
|
||||||
App app = (App) sidebarIcon.Tag;
|
Panel sidebarIcon = (Panel) sidebarPanel.Controls[i];
|
||||||
sidebarIcon.Visible = apps.Contains(app) && app.Status.Contains(Program.Online ? status : Status.Installed);
|
App app = (App) sidebarIcon.Tag;
|
||||||
}
|
sidebarIcon.Visible = apps.Contains(app) &&
|
||||||
ClearSelection();
|
((int) app.Status & (int) (Program.Online ? status : Status.Installed)) != 0;
|
||||||
}
|
}
|
||||||
|
ClearSelection();
|
||||||
|
#if DEBUG
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
@ -311,23 +294,21 @@ Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
|
|||||||
|
|
||||||
private void changesButton_Click(object sender, EventArgs e)
|
private void changesButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (TaskPreview.Show(ref _tasks, true))
|
TaskPreview.Show(ref _tasks);
|
||||||
|
progressBar1.Maximum = _tasks.Count;
|
||||||
|
progressBar1.Value = 0;
|
||||||
|
foreach (IAppTask task in _tasks)
|
||||||
{
|
{
|
||||||
progressBar1.Maximum = _tasks.Count;
|
task.Run();
|
||||||
progressBar1.Value = 0;
|
progressBar1.PerformStep();
|
||||||
foreach (AppTask task in _tasks)
|
|
||||||
{
|
|
||||||
task.Run();
|
|
||||||
progressBar1.PerformStep();
|
|
||||||
}
|
|
||||||
_tasks.Clear();
|
|
||||||
UpdateChangesLabel();
|
|
||||||
}
|
}
|
||||||
|
_tasks.Clear();
|
||||||
|
UpdateChangesLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changesLabel_Click(object sender, EventArgs e)
|
private void changesLabel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
TaskPreview.Show(ref _tasks, false);
|
TaskPreview.Show(ref _tasks);
|
||||||
UpdateChangesLabel();
|
UpdateChangesLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -9,29 +9,28 @@ using System.Windows.Forms;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
public static Form? Splash;
|
public static Form Splash;
|
||||||
private static int _splashProgress;
|
private static int _splashProgress;
|
||||||
private static string? _splashMessage;
|
private static string _splashMessage;
|
||||||
public static bool Online;
|
public static bool Online;
|
||||||
public static UpToolLibMain Lib;
|
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main(string[] args)
|
private static void Main()
|
||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
BuildSplash();
|
BuildSplash();
|
||||||
Splash.Show();
|
Splash.Show();
|
||||||
|
//new Thread(() => { Splash.ShowDialog(); }).Start();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Lib = new UpToolLibMain(new UtLibFunctions());
|
MutexLock.Lock();
|
||||||
}
|
}
|
||||||
catch (MutexLockLockedException)
|
catch (MutexLockLockedException)
|
||||||
{
|
{
|
||||||
@ -45,22 +44,27 @@ namespace UpTool2
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
ExternalFunctionalityManager.Init(new UtLibFunctions());
|
||||||
SetSplash(1, "Initializing paths");
|
SetSplash(1, "Initializing paths");
|
||||||
if (!Directory.Exists(Lib.V1.PathTool.Dir))
|
if (!Directory.Exists(PathTool.Dir))
|
||||||
Directory.CreateDirectory(Lib.V1.PathTool.Dir);
|
Directory.CreateDirectory(PathTool.Dir);
|
||||||
FixXml();
|
FixXml();
|
||||||
SetSplash(2, "Performing checks");
|
SetSplash(2, "Performing checks");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Lib.V2.UpdateChecker.Check();
|
UpToolLib.UpdateCheck.Reload();
|
||||||
Online = true;
|
Online = true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Online = false;
|
Online = false;
|
||||||
}
|
}
|
||||||
if (!Directory.Exists(Lib.V1.PathTool.GetRelative("Apps")))
|
if (Application.ExecutablePath != PathTool.GetRelative("Install", "UpTool2.dll"))
|
||||||
Directory.CreateDirectory(Lib.V1.PathTool.GetRelative("Apps"));
|
Splash.Invoke((Action) (() => MessageBox.Show(Splash,
|
||||||
|
$"WARNING!{Environment.NewLine}Running from outside the install directory is not recommended!")
|
||||||
|
));
|
||||||
|
if (!Directory.Exists(PathTool.GetRelative("Apps")))
|
||||||
|
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
|
||||||
if (!Online)
|
if (!Online)
|
||||||
SetSplash(7, "Opening");
|
SetSplash(7, "Opening");
|
||||||
if (!Online || UpdateCheck())
|
if (!Online || UpdateCheck())
|
||||||
@ -81,7 +85,7 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Lib.Dispose();
|
MutexLock.Unlock();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -141,15 +145,30 @@ namespace UpTool2
|
|||||||
g.DrawString(_splashMessage, smallFont, Brushes.White, bar,
|
g.DrawString(_splashMessage, smallFont, Brushes.White, bar,
|
||||||
new StringFormat {Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center});
|
new StringFormat {Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center});
|
||||||
};
|
};
|
||||||
|
int xOff = 0;
|
||||||
|
int yOff = 0;
|
||||||
|
bool moving = false;
|
||||||
|
Splash.MouseDown += (sender, e) =>
|
||||||
|
{
|
||||||
|
moving = true;
|
||||||
|
xOff = e.X;
|
||||||
|
yOff = e.Y;
|
||||||
|
};
|
||||||
|
Splash.MouseUp += (sender, e) => moving = false;
|
||||||
|
Splash.MouseMove += (sender, e) =>
|
||||||
|
{
|
||||||
|
if (!moving) return;
|
||||||
|
Splash.Left = Cursor.Position.X - xOff;
|
||||||
|
Splash.Top = Cursor.Position.Y - yOff;
|
||||||
|
};
|
||||||
Splash.Load += (sender, e) => Splash.BringToFront();
|
Splash.Load += (sender, e) => Splash.BringToFront();
|
||||||
Splash.FormClosed += (sender, e) => Splash.Dispose();
|
Splash.FormClosed += (sender, e) => Splash.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetSplash(int progress, string status) => Splash.Invoke(new Action(() =>
|
public static void SetSplash(int progress, string status) => Splash.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{progress} - {status}");
|
|
||||||
Debug.WriteLine($"{progress} - {status}");
|
|
||||||
_splashProgress = progress;
|
_splashProgress = progress;
|
||||||
|
Console.WriteLine(status);
|
||||||
_splashMessage = status;
|
_splashMessage = status;
|
||||||
Splash.Invoke((Action) Splash.Invalidate);
|
Splash.Invoke((Action) Splash.Invalidate);
|
||||||
}));
|
}));
|
||||||
@ -158,29 +177,25 @@ namespace UpTool2
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Lib.V1.XmlTool.FixXml();
|
XmlTool.FixXml();
|
||||||
}
|
}
|
||||||
catch (XmlException)
|
catch (XmlException)
|
||||||
{
|
{
|
||||||
if (throwOnError) throw;
|
if (throwOnError) throw;
|
||||||
MessageBox.Show("Something went wrong while trying to parse XML. Retrying...");
|
MessageBox.Show("Something went wrong while trying to parse XML. Retrying...");
|
||||||
File.Delete(Lib.V1.PathTool.InfoXml);
|
File.Delete(PathTool.InfoXml);
|
||||||
FixXml();
|
FixXml();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool UpdateCheck()
|
private static bool UpdateCheck()
|
||||||
{
|
{
|
||||||
UpdateCheck check = Lib.V2.UpdateChecker.Check();
|
|
||||||
SetSplash(3, "Comparing online version");
|
SetSplash(3, "Comparing online version");
|
||||||
if (Assembly.GetExecutingAssembly().GetName().Version >= check.OnlineVersion)
|
if (Assembly.GetExecutingAssembly().GetName().Version >= UpToolLib.UpdateCheck.OnlineVersion)
|
||||||
{
|
|
||||||
SetSplash(7, "Opening");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
byte[] dl;
|
byte[] dl;
|
||||||
SetSplash(4, "Downloading latest");
|
SetSplash(4, "Downloading latest");
|
||||||
using (DownloadDialog dlg = new DownloadDialog(check.Installer.AbsoluteUri))
|
using (DownloadDialog dlg = new DownloadDialog(UpToolLib.UpdateCheck.Installer.AbsoluteUri))
|
||||||
{
|
{
|
||||||
if (dlg.ShowDialog() != DialogResult.OK)
|
if (dlg.ShowDialog() != DialogResult.OK)
|
||||||
throw new Exception("Failed to update");
|
throw new Exception("Failed to update");
|
||||||
@ -190,29 +205,28 @@ namespace UpTool2
|
|||||||
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
||||||
if (pkgHash != check.InstallerHash)
|
if (pkgHash != UpToolLib.UpdateCheck.InstallerHash)
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
$"The hash is not equal to the one stored in the repo:\r\nPackage: {pkgHash}\r\nOnline: {check.InstallerHash}");
|
$"The hash is not equal to the one stored in the repo:\r\nPackage: {pkgHash}\r\nOnline: {UpToolLib.UpdateCheck.InstallerHash}");
|
||||||
}
|
}
|
||||||
SetSplash(9, "Installing");
|
SetSplash(9, "Installing");
|
||||||
if (Directory.Exists(Lib.V1.PathTool.GetRelative("Install", "tmp")))
|
if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
|
||||||
Directory.Delete(Lib.V1.PathTool.GetRelative("Install", "tmp"), true);
|
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
|
||||||
Directory.CreateDirectory(Lib.V1.PathTool.GetRelative("Install", "tmp"));
|
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
|
||||||
using (MemoryStream ms = new MemoryStream(dl))
|
using (MemoryStream ms = new MemoryStream(dl))
|
||||||
{
|
{
|
||||||
using ZipArchive ar = new ZipArchive(ms);
|
using ZipArchive ar = new ZipArchive(ms);
|
||||||
ar.ExtractToDirectory(Lib.V1.PathTool.GetRelative("Install", "tmp"), true);
|
ar.ExtractToDirectory(PathTool.GetRelative("Install", "tmp"), true);
|
||||||
}
|
}
|
||||||
Splash.Hide();
|
Splash.Hide();
|
||||||
Process.Start(new ProcessStartInfo
|
Process.Start(new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = Lib.V1.PathTool.GetRelative("Install", "tmp", "Installer.exe"),
|
FileName = PathTool.GetRelative("Install", "tmp", "Installer.exe"),
|
||||||
Arguments = "i -p",
|
Arguments = "i -p",
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
WorkingDirectory = Lib.V1.PathTool.GetRelative("Install")
|
WorkingDirectory = PathTool.GetRelative("Install")
|
||||||
});
|
});
|
||||||
SetSplash(7, "Installing");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,35 @@
|
|||||||
using System.Collections.Generic;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Forms;
|
using System.Xml.Linq;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
public partial class SettingsForms : Form
|
public partial class SettingsForms : Form
|
||||||
{
|
{
|
||||||
private readonly List<Repo> _repos = new List<Repo>();
|
private readonly XDocument _doc;
|
||||||
|
private readonly XElement _repos;
|
||||||
|
|
||||||
public SettingsForms()
|
public SettingsForms()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Program.FixXml();
|
Program.FixXml();
|
||||||
_repos.AddRange(Program.Lib.V2.RepoManagement.GetRepos());
|
_doc = XDocument.Load(PathTool.InfoXml);
|
||||||
|
_repos = _doc.Element("meta").Element("Repos");
|
||||||
sourceGrid.Columns.Clear();
|
sourceGrid.Columns.Clear();
|
||||||
sourceGrid.Columns.Add("name", "Name");
|
sourceGrid.Columns.Add("name", "Name");
|
||||||
sourceGrid.Columns.Add("link", "Link");
|
sourceGrid.Columns.Add("link", "Link");
|
||||||
foreach (Repo repo in _repos)
|
foreach (XElement repo in _repos.Elements("Repo"))
|
||||||
sourceGrid.Rows.Add(repo.Name, repo.Url);
|
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
|
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.Save(_repos);
|
_repos.RemoveNodes();
|
||||||
|
for (int y = 0; y < sourceGrid.Rows.Count; y++)
|
||||||
|
if (y + 1 < sourceGrid.Rows.Count)
|
||||||
|
_repos.Add(new XElement("Repo", new XElement("Name", (string) sourceGrid.Rows[y].Cells[0].Value),
|
||||||
|
new XElement("Link", (string) sourceGrid.Rows[y].Cells[1].Value)));
|
||||||
|
_doc.Save(PathTool.InfoXml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
7
UpTool2/Task/IAppTask.cs
Normal file
7
UpTool2/Task/IAppTask.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace UpTool2.Task
|
||||||
|
{
|
||||||
|
internal interface IAppTask
|
||||||
|
{
|
||||||
|
public void Run();
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,11 @@
|
|||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
namespace UpTool2.Task
|
||||||
{
|
{
|
||||||
public abstract class KnownAppTask : AppTask
|
internal abstract class IKnownAppTask : IAppTask
|
||||||
{
|
{
|
||||||
public abstract App App { get; }
|
public abstract App App { get; }
|
||||||
|
public abstract void Run();
|
||||||
|
|
||||||
public override string ToString() => $"{TrimEnd(GetType().Name, "Task")} {App.Name}";
|
public override string ToString() => $"{TrimEnd(GetType().Name, "Task")} {App.Name}";
|
||||||
|
|
||||||
@ -17,9 +18,5 @@ namespace UpToolLib.v2.TaskQueue
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KnownAppTask(IExternalFunctionality platform) : base(platform)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
namespace UpTool2.Task
|
||||||
{
|
{
|
||||||
public class InstallTask : KnownAppTask
|
internal class InstallTask : IKnownAppTask
|
||||||
{
|
{
|
||||||
private readonly AppInstall _installer;
|
|
||||||
private readonly Action? _postInstall;
|
private readonly Action? _postInstall;
|
||||||
|
|
||||||
internal InstallTask(IExternalFunctionality platform, AppInstall installer, App app, Action? postInstall) : base(platform)
|
public InstallTask(App app, Action? postInstall = null)
|
||||||
{
|
{
|
||||||
App = app;
|
App = app;
|
||||||
_installer = installer;
|
|
||||||
_postInstall = postInstall;
|
_postInstall = postInstall;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,14 +26,15 @@ namespace UpToolLib.v2.TaskQueue
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
_installer.Install(App, true);
|
AppInstall.Install(App, true);
|
||||||
_postInstall?.Invoke();
|
_postInstall?.Invoke();
|
||||||
trying = false;
|
trying = false;
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
trying = Platform.YesNoDialog("Install failed. Retry?\r\nException=" + e1, true);
|
trying = MessageBox.Show(e1.ToString(), "Install failed", MessageBoxButtons.RetryCancel) ==
|
||||||
|
DialogResult.Retry;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -1,18 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
namespace UpTool2.Task
|
||||||
{
|
{
|
||||||
public class RemoveTask : KnownAppTask
|
internal class RemoveTask : IKnownAppTask
|
||||||
{
|
{
|
||||||
private readonly AppExtras _extras;
|
|
||||||
private readonly Action? _postInstall;
|
private readonly Action? _postInstall;
|
||||||
|
|
||||||
internal RemoveTask(IExternalFunctionality platform, AppExtras extras, App app, Action? postInstall) : base(platform)
|
public RemoveTask(App app, Action? postInstall = null)
|
||||||
{
|
{
|
||||||
App = app;
|
App = app;
|
||||||
_extras = extras;
|
|
||||||
_postInstall = postInstall;
|
_postInstall = postInstall;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,13 +23,13 @@ namespace UpToolLib.v2.TaskQueue
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
_extras.Remove(App, true);
|
AppExtras.Remove(App, true);
|
||||||
_postInstall?.Invoke();
|
_postInstall?.Invoke();
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
Platform.OkDialog("Removal failed.\r\nException=" + e1);
|
MessageBox.Show(e1.ToString(), "Removal failed");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -1,18 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
namespace UpTool2.Task
|
||||||
{
|
{
|
||||||
public class UpdateTask : KnownAppTask
|
internal class UpdateTask : IKnownAppTask
|
||||||
{
|
{
|
||||||
private readonly AppExtras _extras;
|
|
||||||
private readonly Action? _postInstall;
|
private readonly Action? _postInstall;
|
||||||
|
|
||||||
internal UpdateTask(IExternalFunctionality platform, AppExtras extras, App app, Action? postInstall) : base(platform)
|
public UpdateTask(App app, Action? postInstall = null)
|
||||||
{
|
{
|
||||||
App = app;
|
App = app;
|
||||||
_extras = extras;
|
|
||||||
_postInstall = postInstall;
|
_postInstall = postInstall;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,13 +23,13 @@ namespace UpToolLib.v2.TaskQueue
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
_extras.Update(App, false);
|
AppExtras.Update(App, false);
|
||||||
_postInstall?.Invoke();
|
_postInstall?.Invoke();
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
Platform.OkDialog("Update failed.\r\nException=" + e1);
|
MessageBox.Show(e1.ToString(), "Install failed");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
49
UpTool2/Task/UploadTask.cs
Normal file
49
UpTool2/Task/UploadTask.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using UpTool2.Properties;
|
||||||
|
using UpToolLib;
|
||||||
|
using UpToolLib.DataStructures;
|
||||||
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
|
namespace UpTool2.Task
|
||||||
|
{
|
||||||
|
internal class UploadTask : IAppTask
|
||||||
|
{
|
||||||
|
private readonly string _name;
|
||||||
|
private readonly Action? _postInstall;
|
||||||
|
public readonly string ZipFile;
|
||||||
|
|
||||||
|
public UploadTask(string zipFile, string name, Action? postInstall = null)
|
||||||
|
{
|
||||||
|
ZipFile = zipFile;
|
||||||
|
_name = name;
|
||||||
|
_postInstall = postInstall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
#if !DEBUG
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
Guid id = Guid.NewGuid();
|
||||||
|
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
|
||||||
|
id = Guid.NewGuid();
|
||||||
|
App appI = new App(_name, "Locally installed package, removal only",
|
||||||
|
GlobalVariables.MinimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
||||||
|
AppInstall.InstallZip(ZipFile, appI, true);
|
||||||
|
_postInstall?.Invoke();
|
||||||
|
#if !DEBUG
|
||||||
|
}
|
||||||
|
catch (Exception e1)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e1.ToString(), "Install failed");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() => $"Install local {Path.GetFileName(ZipFile)}";
|
||||||
|
}
|
||||||
|
}
|
@ -2,31 +2,22 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using UpToolLib.v2.TaskQueue;
|
using UpTool2.Task;
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
internal static class TaskPreview
|
internal static class TaskPreview
|
||||||
{
|
{
|
||||||
public static bool Show(ref List<AppTask> tasks, bool showOk)
|
public static void Show(ref List<IAppTask> tasks)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
using Form tmp = new Form {Size = new Size(600, 300)};
|
||||||
using Form tmp = new Form {Size = new Size(600, 300), MinimumSize = new Size(300, showOk ? 138 : 133)};
|
|
||||||
using CheckedListBox list = new CheckedListBox {Dock = DockStyle.Fill};
|
using CheckedListBox list = new CheckedListBox {Dock = DockStyle.Fill};
|
||||||
using Button okButton = new Button {Dock = DockStyle.Bottom, Text = "OK"};
|
|
||||||
list.Items.AddRange(tasks.ToArray());
|
list.Items.AddRange(tasks.ToArray());
|
||||||
for (int i = 0; i < tasks.Count; i++)
|
for (int i = 0; i < tasks.Count; i++)
|
||||||
list.SetItemChecked(i, true);
|
list.SetItemChecked(i, true);
|
||||||
tmp.Controls.Add(list);
|
tmp.Controls.Add(list);
|
||||||
okButton.Click += (sender, args) =>
|
|
||||||
{
|
|
||||||
ok = true;
|
|
||||||
tmp.Close();
|
|
||||||
};
|
|
||||||
if (showOk) tmp.Controls.Add(okButton);
|
|
||||||
tmp.ShowDialog();
|
tmp.ShowDialog();
|
||||||
tasks = list.Items.OfType<AppTask>().Where((s, i) => list.GetItemChecked(i)).ToList();
|
tasks = list.Items.OfType<IAppTask>().Where((s, i) => list.GetItemChecked(i)).ToList();
|
||||||
return !showOk || ok;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<LangVersion>8</LangVersion>
|
<LangVersion>8</LangVersion>
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
@ -19,6 +19,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CC-Functions.Misc" Version="1.1.7468.32091" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\UpToolLib\UpToolLib.csproj" />
|
<ProjectReference Include="..\UpToolLib\UpToolLib.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -6,8 +6,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolCLI
|
namespace UpToolCLI
|
||||||
{
|
{
|
||||||
@ -20,16 +19,22 @@ namespace UpToolCLI
|
|||||||
Handler = CommandHandler.Create(List)
|
Handler = CommandHandler.Create(List)
|
||||||
});
|
});
|
||||||
|
|
||||||
Command search = new("search", "Search for packages")
|
Command search = new Command("search", "Search for packages")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app")
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
search.Handler = CommandHandler.Create<string>(Search);
|
search.Handler = CommandHandler.Create<string>(Search);
|
||||||
rootCommand.AddCommand(search);
|
rootCommand.AddCommand(search);
|
||||||
|
|
||||||
Command show = new("show", "Shows package info")
|
Command show = new Command("show", "Shows package info")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app")
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
show.Handler = CommandHandler.Create<string>(Show);
|
show.Handler = CommandHandler.Create<string>(Show);
|
||||||
rootCommand.AddCommand(show);
|
rootCommand.AddCommand(show);
|
||||||
@ -42,22 +47,22 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void List()
|
private static void List()
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
Console.WriteLine(Program.Lib.V1.Apps.Where(s => s.Value.Status.Contains(Status.Installed))
|
Console.WriteLine(GlobalVariables.Apps.Where(s => (s.Value.Status & Status.Installed) == Status.Installed)
|
||||||
.ToStringTable(new[]
|
.ToStringTable(new[]
|
||||||
{
|
{
|
||||||
"Name", "State", "Guid"
|
"Name", "State", "Guid"
|
||||||
},
|
},
|
||||||
u => u.Value.Name,
|
u => u.Value.Name,
|
||||||
u => u.Value.Local ? "Local" :
|
u => u.Value.Local ? "Local" :
|
||||||
u.Value.Status.Contains(Status.Updatable) ? "Updatable" : "None",
|
(u.Value.Status & Status.Updatable) == Status.Updatable ? "Updatable" : "None",
|
||||||
u => u.Key));
|
u => u.Key));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Search(string identifier)
|
private static void Search(string identifier)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
Console.WriteLine($"Found {apps.Length} app(s)");
|
Console.WriteLine($"Found {apps.Length} app(s)");
|
||||||
if (apps.Length > 0)
|
if (apps.Length > 0)
|
||||||
Console.WriteLine(apps.ToStringTable(new[]
|
Console.WriteLine(apps.ToStringTable(new[]
|
||||||
@ -70,8 +75,8 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void Show(string identifier)
|
private static void Show(string identifier)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
Console.WriteLine("Package not found.");
|
Console.WriteLine("Package not found.");
|
||||||
else
|
else
|
||||||
@ -81,21 +86,23 @@ namespace UpToolCLI
|
|||||||
private static void Update()
|
private static void Update()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Fetching Repos...");
|
Console.WriteLine("Fetching Repos...");
|
||||||
Program.Lib.V2.RepoManagement.FetchRepos();
|
RepoManagement.FetchRepos();
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
IEnumerable<App> tmp = Program.Lib.V1.Apps.Where(s =>
|
IEnumerable<App> tmp = GlobalVariables.Apps.Where(s =>
|
||||||
s.Value.Status.Contains(Status.Updatable)).Select(s => s.Value);
|
(s.Value.Status & Status.Updatable) == Status.Updatable).Select(s => s.Value);
|
||||||
IEnumerable<App> apps = tmp as App[] ?? tmp.ToArray();
|
IEnumerable<App> apps = tmp as App[] ?? tmp.ToArray();
|
||||||
int updatableCount = apps.Count();
|
int updatableCount = apps.Count();
|
||||||
Console.WriteLine(updatableCount == 0
|
Console.WriteLine(updatableCount == 0
|
||||||
? "All up-to-date"
|
? "All up-to-date"
|
||||||
: $@"Found {updatableCount} Updates:
|
: $@"Found {updatableCount} Updates:
|
||||||
{string.Join(Environment.NewLine, apps.Select(s => $"- {s.Name} ({s.Version})"))}");
|
{string.Join(Environment.NewLine, apps.Select(s => $"- {s.Name} ({s.Version})"))}");
|
||||||
|
#if !DEBUG
|
||||||
Version vLocal = Assembly.GetExecutingAssembly().GetName().Version;
|
Version vLocal = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
Version vOnline = Program.Lib.V2.UpdateChecker.Check().OnlineVersion;
|
Version vOnline = UpdateCheck.OnlineVersion;
|
||||||
if (vLocal < vOnline)
|
if (vLocal < vOnline)
|
||||||
Console.WriteLine($"uptool is outdated ({vLocal} vs {vOnline}), update using \"uptool upgrade-self\"");
|
Console.WriteLine($"uptool is outdated ({vLocal} vs {vOnline}), update using \"uptool upgrade-self\"");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,8 +9,7 @@ using System.Reflection;
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v2;
|
|
||||||
using Process = System.Diagnostics.Process;
|
using Process = System.Diagnostics.Process;
|
||||||
|
|
||||||
namespace UpToolCLI
|
namespace UpToolCLI
|
||||||
@ -19,70 +18,73 @@ namespace UpToolCLI
|
|||||||
{
|
{
|
||||||
public static void RegisterCommands(RootCommand rootCommand)
|
public static void RegisterCommands(RootCommand rootCommand)
|
||||||
{
|
{
|
||||||
Command command = new("upgrade-self", "Upgrades UpToolCLI")
|
Command command = new Command("upgrade-self", "Upgrades UpToolCLI")
|
||||||
{
|
{
|
||||||
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
||||||
};
|
};
|
||||||
command.Handler = CommandHandler.Create<bool>(UpgradeSelf);
|
command.Handler = CommandHandler.Create<bool>(UpgradeSelf);
|
||||||
rootCommand.AddCommand(command);
|
rootCommand.AddCommand(command);
|
||||||
|
|
||||||
Command start = new("start", "Starts an app")
|
Command start = new Command("start", "Starts an app")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app"),
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
new Option<string>(new[] {"--arguments", "--args", "-a"}, () => "", "The arguments to run the file with"),
|
{
|
||||||
new Option<string>(new[] {"--file", "-f"}, () => null, "The file to run instead of the MainFile"),
|
Required = true
|
||||||
new Option<bool>(new[] {"--waitForExit", "-wait"}, "Waits until the program quits")
|
},
|
||||||
|
new Option<string>(new[] {"--waitForExit", "-wait"}, "Waits until the program quits")
|
||||||
};
|
};
|
||||||
start.Handler = CommandHandler.Create<string, string, string, bool>(Start);
|
start.Handler = CommandHandler.Create<string, bool>(Start);
|
||||||
rootCommand.AddCommand(start);
|
rootCommand.AddCommand(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpgradeSelf(bool force)
|
public static void UpgradeSelf(bool force)
|
||||||
{
|
{
|
||||||
PathTool pathTool = Program.Lib.V1.PathTool;
|
#if DEBUG
|
||||||
UpdateCheck updateCheck = Program.Lib.V2.UpdateChecker.Check();
|
Console.WriteLine("Not enabled in debug builds");
|
||||||
if (!force && Assembly.GetExecutingAssembly().GetName().Version >= updateCheck.OnlineVersion)
|
#else
|
||||||
|
if (!force && Assembly.GetExecutingAssembly().GetName().Version >= UpdateCheck.OnlineVersion)
|
||||||
Console.WriteLine("Already up-to-date");
|
Console.WriteLine("Already up-to-date");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Downloading latest");
|
Console.WriteLine("Downloading latest");
|
||||||
(bool success, byte[] dl) = Program.Functions.Download(updateCheck.Installer);
|
(bool success, byte[] dl) = Program.Functions.Download(UpdateCheck.Installer);
|
||||||
if (!success)
|
if (!success)
|
||||||
throw new Exception("Failed to update");
|
throw new Exception("Failed to update");
|
||||||
Console.WriteLine("Verifying");
|
Console.WriteLine("Verifying");
|
||||||
using (SHA256CryptoServiceProvider sha256 = new())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
||||||
if (pkgHash != updateCheck.InstallerHash)
|
if (pkgHash != UpdateCheck.InstallerHash)
|
||||||
throw new Exception($@"The hash is not equal to the one stored in the repo:
|
throw new Exception($@"The hash is not equal to the one stored in the repo:
|
||||||
Package: {pkgHash}
|
Package: {pkgHash}
|
||||||
Online: {updateCheck.InstallerHash}");
|
Online: {UpdateCheck.InstallerHash}");
|
||||||
}
|
}
|
||||||
Console.WriteLine("Installing");
|
Console.WriteLine("Installing");
|
||||||
if (Directory.Exists(pathTool.GetRelative("Install", "tmp")))
|
if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
|
||||||
Directory.Delete(pathTool.GetRelative("Install", "tmp"), true);
|
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
|
||||||
Directory.CreateDirectory(pathTool.GetRelative("Install", "tmp"));
|
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
|
||||||
using (MemoryStream ms = new(dl))
|
using (MemoryStream ms = new MemoryStream(dl))
|
||||||
{
|
{
|
||||||
using ZipArchive ar = new(ms);
|
using ZipArchive ar = new ZipArchive(ms);
|
||||||
ar.ExtractToDirectory(pathTool.GetRelative("Install", "tmp"), true);
|
ar.ExtractToDirectory(PathTool.GetRelative("Install", "tmp"), true);
|
||||||
}
|
}
|
||||||
string file = pathTool.GetRelative("Install", "tmp", "Installer.exe");
|
string file = PathTool.GetRelative("Install", "tmp", "Installer.exe");
|
||||||
Console.WriteLine($"Starting {file}");
|
Console.WriteLine($"Starting {file}");
|
||||||
Process.Start(new ProcessStartInfo
|
Process.Start(new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = file,
|
FileName = file,
|
||||||
Arguments = "i",
|
Arguments = "i",
|
||||||
WorkingDirectory = pathTool.GetRelative("Install"),
|
WorkingDirectory = PathTool.GetRelative("Install"),
|
||||||
UseShellExecute = false
|
UseShellExecute = false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Start(string identifier, string arguments, string file, bool waitForExit)
|
private static void Start(string identifier, bool waitForExit)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
Console.WriteLine("Package not found.");
|
Console.WriteLine("Package not found.");
|
||||||
else
|
else
|
||||||
@ -91,7 +93,7 @@ Online: {updateCheck.InstallerHash}");
|
|||||||
if (tmp.Runnable)
|
if (tmp.Runnable)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Starting {tmp.Name}");
|
Console.WriteLine($"Starting {tmp.Name}");
|
||||||
Process tmp1 = Program.Lib.V1.AppExtras.RunApp(tmp, file ?? tmp.MainFile, arguments);
|
Process tmp1 = AppExtras.RunApp(tmp);
|
||||||
if (waitForExit)
|
if (waitForExit)
|
||||||
tmp1.WaitForExit();
|
tmp1.WaitForExit();
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolCLI
|
namespace UpToolCLI
|
||||||
{
|
{
|
||||||
@ -18,40 +16,55 @@ namespace UpToolCLI
|
|||||||
{
|
{
|
||||||
public static void RegisterCommands(RootCommand rootCommand)
|
public static void RegisterCommands(RootCommand rootCommand)
|
||||||
{
|
{
|
||||||
Command install = new("install", "Install a package")
|
Command install = new Command("install", "Install a package")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app or the file name"),
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app or the file name")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
},
|
||||||
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
||||||
};
|
};
|
||||||
install.Handler = CommandHandler.Create<string, bool>(Install);
|
install.Handler = CommandHandler.Create<string, bool>(Install);
|
||||||
rootCommand.AddCommand(install);
|
rootCommand.AddCommand(install);
|
||||||
|
|
||||||
Command upgrade = new("upgrade", "Upgrade a package")
|
Command upgrade = new Command("upgrade", "Upgrade a package")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app"),
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
},
|
||||||
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
||||||
};
|
};
|
||||||
upgrade.Handler = CommandHandler.Create<string, bool>(Upgrade);
|
upgrade.Handler = CommandHandler.Create<string, bool>(Upgrade);
|
||||||
rootCommand.AddCommand(upgrade);
|
rootCommand.AddCommand(upgrade);
|
||||||
|
|
||||||
Command reinstall = new("reinstall", "Reinstall a package")
|
Command reinstall = new Command("reinstall", "Reinstall a package")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app"),
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
},
|
||||||
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
|
||||||
};
|
};
|
||||||
reinstall.Handler = CommandHandler.Create<string, bool>(Reinstall);
|
reinstall.Handler = CommandHandler.Create<string, bool>(Reinstall);
|
||||||
rootCommand.AddCommand(reinstall);
|
rootCommand.AddCommand(reinstall);
|
||||||
|
|
||||||
Command remove = new("remove", "Remove a package")
|
Command remove = new Command("remove", "Remove a package")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app")
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
remove.Handler = CommandHandler.Create<string>(Remove);
|
remove.Handler = CommandHandler.Create<string>(Remove);
|
||||||
rootCommand.AddCommand(remove);
|
rootCommand.AddCommand(remove);
|
||||||
|
|
||||||
Command purge = new("purge", "Completely remove a package")
|
Command purge = new Command("purge", "Completely remove a package")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app")
|
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
purge.Handler = CommandHandler.Create<string>(Purge);
|
purge.Handler = CommandHandler.Create<string>(Purge);
|
||||||
rootCommand.AddCommand(purge);
|
rootCommand.AddCommand(purge);
|
||||||
@ -64,16 +77,16 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void Install(string identifier, bool force)
|
private static void Install(string identifier, bool force)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
{
|
{
|
||||||
if (File.Exists(identifier))
|
if (File.Exists(identifier))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Name:");
|
Console.WriteLine("Name:");
|
||||||
string name = Console.ReadLine();
|
string name = Console.ReadLine();
|
||||||
Program.Lib.V1.Installer.InstallZip(identifier, Program.Lib.V2.AppFactory.CreateApp(name, "Locally installed package, removal only",
|
AppInstall.InstallZip(identifier, new App(name, "Locally installed package, removal only",
|
||||||
UpToolLibV1.MinimumVer, "", true, "",
|
GlobalVariables.MinimumVer, "", true, "",
|
||||||
Guid.NewGuid(), Color.Red, "", false, ""), force);
|
Guid.NewGuid(), Color.Red, "", false, ""), force);
|
||||||
Console.WriteLine($"Successfully installed \"{name}\"");
|
Console.WriteLine($"Successfully installed \"{name}\"");
|
||||||
}
|
}
|
||||||
@ -86,12 +99,12 @@ namespace UpToolCLI
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
App tmp = apps.First();
|
App tmp = apps.First();
|
||||||
if (tmp.Status.Contains(Status.Installed))
|
if ((tmp.Status & Status.Installed) == Status.Installed)
|
||||||
Console.WriteLine("Package is already installed");
|
Console.WriteLine("Package is already installed");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Installing {tmp.Name}");
|
Console.WriteLine($"Installing {tmp.Name}");
|
||||||
Program.Lib.V1.Installer.Install(tmp, true);
|
AppInstall.Install(tmp, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine("Done!");
|
Console.WriteLine("Done!");
|
||||||
@ -99,17 +112,17 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void Upgrade(string identifier, bool force)
|
private static void Upgrade(string identifier, bool force)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
Console.WriteLine("Package not found.");
|
Console.WriteLine("Package not found.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App tmp = apps.First();
|
App tmp = apps.First();
|
||||||
if (tmp.Status.Contains(Status.Updatable))
|
if ((tmp.Status & Status.Updatable) == Status.Updatable)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Upgrading {tmp.Name}");
|
Console.WriteLine($"Upgrading {tmp.Name}");
|
||||||
Program.Lib.V1.AppExtras.Update(tmp, force);
|
AppExtras.Update(tmp, force);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.WriteLine("Package is up-to-date");
|
Console.WriteLine("Package is up-to-date");
|
||||||
@ -119,32 +132,32 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void Reinstall(string identifier, bool force)
|
private static void Reinstall(string identifier, bool force)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
Console.WriteLine("Package not found.");
|
Console.WriteLine("Package not found.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App tmp = apps.First();
|
App tmp = apps.First();
|
||||||
Console.WriteLine($"Reinstalling {tmp.Name}");
|
Console.WriteLine($"Reinstalling {tmp.Name}");
|
||||||
Program.Lib.V1.AppExtras.Update(tmp, force);
|
AppExtras.Update(tmp, force);
|
||||||
}
|
}
|
||||||
Console.WriteLine("Done!");
|
Console.WriteLine("Done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Remove(string identifier)
|
private static void Remove(string identifier)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
Console.WriteLine("Package not found.");
|
Console.WriteLine("Package not found.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App tmp = apps.First();
|
App tmp = apps.First();
|
||||||
if (tmp.Status.Contains(Status.Installed))
|
if ((tmp.Status & Status.Installed) == Status.Installed)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Removing {tmp.Name}");
|
Console.WriteLine($"Removing {tmp.Name}");
|
||||||
Program.Lib.V1.AppExtras.Remove(tmp, false);
|
AppExtras.Remove(tmp, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.WriteLine("Package is not installed");
|
Console.WriteLine("Package is not installed");
|
||||||
@ -154,17 +167,17 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void Purge(string identifier)
|
private static void Purge(string identifier)
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
App[] apps = Program.Lib.V1.AppExtras.FindApps(identifier);
|
App[] apps = AppExtras.FindApps(identifier);
|
||||||
if (apps.Length == 0)
|
if (apps.Length == 0)
|
||||||
Console.WriteLine("Package not found.");
|
Console.WriteLine("Package not found.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App tmp = apps.First();
|
App tmp = apps.First();
|
||||||
if (tmp.Status.Contains(Status.Installed))
|
if ((tmp.Status & Status.Installed) == Status.Installed)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Purging {tmp.Name}");
|
Console.WriteLine($"Purging {tmp.Name}");
|
||||||
Program.Lib.V1.AppExtras.Remove(tmp, true);
|
AppExtras.Remove(tmp, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.WriteLine("Package is not installed");
|
Console.WriteLine("Package is not installed");
|
||||||
@ -174,18 +187,20 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void DistUpgrade()
|
private static void DistUpgrade()
|
||||||
{
|
{
|
||||||
Program.Lib.V2.RepoManagement.GetReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
foreach (KeyValuePair<Guid, App> app in Program.Lib.V1.Apps.Where(s =>
|
foreach (KeyValuePair<Guid, App> app in GlobalVariables.Apps.Where(s =>
|
||||||
s.Value.Status.Contains(Status.Updatable)))
|
(s.Value.Status & Status.Updatable) == Status.Updatable))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Updating {app.Value.Name}");
|
Console.WriteLine($"Updating {app.Value.Name}");
|
||||||
Program.Lib.V1.AppExtras.Update(app.Value, false);
|
AppExtras.Update(app.Value, false);
|
||||||
}
|
}
|
||||||
if (Assembly.GetExecutingAssembly().GetName().Version < Program.Lib.V2.UpdateChecker.Check().OnlineVersion)
|
#if !DEBUG
|
||||||
|
if (Assembly.GetExecutingAssembly().GetName().Version < UpdateCheck.OnlineVersion)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Updating self");
|
Console.WriteLine("Updating self");
|
||||||
Other.UpgradeSelf(false);
|
Other.UpgradeSelf(false);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Console.WriteLine("Done!");
|
Console.WriteLine("Done!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using UpToolLib;
|
using UpToolLib;
|
||||||
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
namespace UpToolCLI
|
namespace UpToolCLI
|
||||||
{
|
{
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
public static readonly UtLibFunctions Functions = new();
|
public static readonly UtLibFunctions Functions = new UtLibFunctions();
|
||||||
public static bool Basic;
|
|
||||||
public static UpToolLibMain Lib;
|
|
||||||
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
|
MutexLock.Lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Basic = args.Length > 0 && args[0].ToLower() == "--basic";
|
XmlTool.FixXml();
|
||||||
Lib = new UpToolLibMain(Functions);
|
ExternalFunctionalityManager.Init(Functions);
|
||||||
Lib.V1.XmlTool.FixXml();
|
RootCommand rootCommand = new RootCommand();
|
||||||
RootCommand rootCommand = new();
|
|
||||||
rootCommand.AddGlobalOption(new Option<bool>("--basic", "Use only basic console functionality. Must be the first parameter in the call"));
|
|
||||||
|
|
||||||
PackageManagement.RegisterCommands(rootCommand);
|
PackageManagement.RegisterCommands(rootCommand);
|
||||||
CacheManagement.RegisterCommands(rootCommand);
|
CacheManagement.RegisterCommands(rootCommand);
|
||||||
@ -34,7 +32,7 @@ namespace UpToolCLI
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Lib?.Dispose();
|
MutexLock.Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,12 @@ using System.CommandLine;
|
|||||||
using System.CommandLine.Invocation;
|
using System.CommandLine.Invocation;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpToolLib.v1.Tool;
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
namespace UpToolCLI
|
namespace UpToolCLI
|
||||||
{
|
{
|
||||||
public class ReposManagement
|
public class ReposManagement
|
||||||
{
|
{
|
||||||
private static string InfoXml => Program.Lib.V1.PathTool.InfoXml;
|
|
||||||
public static void RegisterCommands(RootCommand rootCommand)
|
public static void RegisterCommands(RootCommand rootCommand)
|
||||||
{
|
{
|
||||||
rootCommand.AddCommand(new Command("list-repo", "Lists current repositories")
|
rootCommand.AddCommand(new Command("list-repo", "Lists current repositories")
|
||||||
@ -17,17 +16,26 @@ namespace UpToolCLI
|
|||||||
Handler = CommandHandler.Create(ListRepo)
|
Handler = CommandHandler.Create(ListRepo)
|
||||||
});
|
});
|
||||||
|
|
||||||
Command addRepo = new("add-repo", "Adds a repository")
|
Command addRepo = new Command("add-repo", "Adds a repository")
|
||||||
{
|
{
|
||||||
new Argument<string>("name", "The new repositories name"),
|
new Option<string>(new[] {"--name", "-n"}, "The new repositories name")
|
||||||
new Argument<string>("link", "A link to the repositories XML")
|
{
|
||||||
|
Required = true
|
||||||
|
},
|
||||||
|
new Option<string>(new[] {"--link", "-l"}, "A link to the repositories XML")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
addRepo.Handler = CommandHandler.Create<string, string>(AddRepo);
|
addRepo.Handler = CommandHandler.Create<string, string>(AddRepo);
|
||||||
rootCommand.AddCommand(addRepo);
|
rootCommand.AddCommand(addRepo);
|
||||||
|
|
||||||
Command removeRepo = new("remove-repo", "Removes a repository")
|
Command removeRepo = new Command("remove-repo", "Removes a repository")
|
||||||
{
|
{
|
||||||
new Argument<string>("name", "The repositories name")
|
new Option<string>(new[] {"--name", "-n"}, "The repositories name")
|
||||||
|
{
|
||||||
|
Required = true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
removeRepo.Handler = CommandHandler.Create<string>(RemoveRepo);
|
removeRepo.Handler = CommandHandler.Create<string>(RemoveRepo);
|
||||||
rootCommand.AddCommand(removeRepo);
|
rootCommand.AddCommand(removeRepo);
|
||||||
@ -35,7 +43,7 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void ListRepo()
|
private static void ListRepo()
|
||||||
{
|
{
|
||||||
XDocument doc = XDocument.Load(InfoXml);
|
XDocument doc = XDocument.Load(PathTool.InfoXml);
|
||||||
XElement repos = doc.Element("meta").Element("Repos");
|
XElement repos = doc.Element("meta").Element("Repos");
|
||||||
Console.WriteLine("Current repos:");
|
Console.WriteLine("Current repos:");
|
||||||
Console.WriteLine(repos.Elements("Repo").ToStringTable(new[]
|
Console.WriteLine(repos.Elements("Repo").ToStringTable(new[]
|
||||||
@ -48,17 +56,17 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
private static void AddRepo(string name, string link)
|
private static void AddRepo(string name, string link)
|
||||||
{
|
{
|
||||||
XDocument doc = XDocument.Load(InfoXml);
|
XDocument doc = XDocument.Load(PathTool.InfoXml);
|
||||||
XElement repos = doc.Element("meta").Element("Repos");
|
XElement repos = doc.Element("meta").Element("Repos");
|
||||||
repos.Add(new XElement("Repo", new XElement("Name", name),
|
repos.Add(new XElement("Repo", new XElement("Name", name),
|
||||||
new XElement("Link", link)));
|
new XElement("Link", link)));
|
||||||
doc.Save(InfoXml);
|
doc.Save(PathTool.InfoXml);
|
||||||
Console.WriteLine("Added repo. Remember to update the cache using \"uptool update\"");
|
Console.WriteLine("Added repo. Remember to update the cache using \"uptool update\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RemoveRepo(string name)
|
private static void RemoveRepo(string name)
|
||||||
{
|
{
|
||||||
XDocument doc = XDocument.Load(InfoXml);
|
XDocument doc = XDocument.Load(PathTool.InfoXml);
|
||||||
XElement repos = doc.Element("meta").Element("Repos");
|
XElement repos = doc.Element("meta").Element("Repos");
|
||||||
XElement[] sRepos = repos.Elements("Repo")
|
XElement[] sRepos = repos.Elements("Repo")
|
||||||
.Where(s => s.Element("Name").Value.ToLower().StartsWith(name.ToLower())).ToArray();
|
.Where(s => s.Element("Name").Value.ToLower().StartsWith(name.ToLower())).ToArray();
|
||||||
@ -77,16 +85,21 @@ namespace UpToolCLI
|
|||||||
},
|
},
|
||||||
u => u.Element("Name").Value,
|
u => u.Element("Name").Value,
|
||||||
u => u.Element("Link").Value));
|
u => u.Element("Link").Value));
|
||||||
if (!Program.Functions.YesNoDialog("Are you sure you want to delete them all?", false))
|
Console.WriteLine("Are you sure you want to delete them all? (y/n)");
|
||||||
|
ConsoleKey k;
|
||||||
|
do
|
||||||
|
k = Console.ReadKey().Key;
|
||||||
|
while (k != ConsoleKey.Y && k != ConsoleKey.N);
|
||||||
|
if (k == ConsoleKey.N || k != ConsoleKey.Y)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
foreach (XElement t in sRepos)
|
for (int i = 0; i < sRepos.Length; i++)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Removing {t.Element("Name").Value}");
|
Console.WriteLine($"Removing {sRepos[i].Element("Name").Value}");
|
||||||
t.Remove();
|
sRepos[i].Remove();
|
||||||
}
|
}
|
||||||
doc.Save(InfoXml);
|
doc.Save(PathTool.InfoXml);
|
||||||
Console.WriteLine("Removed repo. Remember to update the cache using \"uptool update\"");
|
Console.WriteLine("Removed repo. Remember to update the cache using \"uptool update\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ namespace UpToolCLI
|
|||||||
public static string ToStringTable(this string[,] arrValues)
|
public static string ToStringTable(this string[,] arrValues)
|
||||||
{
|
{
|
||||||
int[] maxColumnsWidth = GetMaxColumnsWidth(arrValues);
|
int[] maxColumnsWidth = GetMaxColumnsWidth(arrValues);
|
||||||
string headerSpliter = new('-', maxColumnsWidth.Sum(i => i + 3) - 1);
|
string headerSpliter = new string('-', maxColumnsWidth.Sum(i => i + 3) - 1);
|
||||||
|
|
||||||
StringBuilder sb = new();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int rowIndex = 0; rowIndex < arrValues.GetLength(0); rowIndex++)
|
for (int rowIndex = 0; rowIndex < arrValues.GetLength(0); rowIndex++)
|
||||||
{
|
{
|
||||||
for (int colIndex = 0; colIndex < arrValues.GetLength(1); colIndex++)
|
for (int colIndex = 0; colIndex < arrValues.GetLength(1); colIndex++)
|
||||||
|
@ -5,7 +5,6 @@ using System.Threading;
|
|||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using static UpToolCLI.Program;
|
|
||||||
|
|
||||||
namespace UpToolCLI
|
namespace UpToolCLI
|
||||||
{
|
{
|
||||||
@ -13,7 +12,7 @@ namespace UpToolCLI
|
|||||||
{
|
{
|
||||||
public Tuple<bool, byte[]> Download(Uri link)
|
public Tuple<bool, byte[]> Download(Uri link)
|
||||||
{
|
{
|
||||||
using WebClient client = new();
|
using WebClient client = new WebClient();
|
||||||
byte[] result = new byte[0];
|
byte[] result = new byte[0];
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@ -26,12 +25,9 @@ namespace UpToolCLI
|
|||||||
};
|
};
|
||||||
client.DownloadProgressChanged += (sender, e) =>
|
client.DownloadProgressChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (!Basic)
|
Console.Write(
|
||||||
{
|
$"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
|
||||||
Console.Write(
|
Console.CursorLeft = 0;
|
||||||
$"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
|
|
||||||
Console.CursorLeft = 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
client.DownloadDataAsync(link);
|
client.DownloadDataAsync(link);
|
||||||
while (!finished)
|
while (!finished)
|
||||||
@ -41,72 +37,58 @@ namespace UpToolCLI
|
|||||||
|
|
||||||
public string FetchImageB64(Uri link)
|
public string FetchImageB64(Uri link)
|
||||||
{
|
{
|
||||||
using WebClient client = new();
|
using WebClient client = new WebClient();
|
||||||
using Image image = Image.Load(client.OpenRead(link));
|
using Image image = Image.Load(client.OpenRead(link));
|
||||||
image.Mutate(x => x.Resize(70, 70));
|
image.Mutate(x => x.Resize(70, 70));
|
||||||
using MemoryStream ms = new();
|
using MemoryStream ms = new MemoryStream();
|
||||||
image.SaveAsPng(ms);
|
image.SaveAsPng(ms);
|
||||||
return Convert.ToBase64String(ms.ToArray());
|
return Convert.ToBase64String(ms.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool YesNoDialog(string text, bool defaultVal)
|
public bool YesNoDialog(string text, bool defaultVal)
|
||||||
{
|
{
|
||||||
if (Basic)
|
bool choosing = true;
|
||||||
|
bool current = defaultVal;
|
||||||
|
Console.WriteLine(text);
|
||||||
|
while (choosing)
|
||||||
{
|
{
|
||||||
Console.WriteLine(text);
|
Console.CursorLeft = 0;
|
||||||
Console.WriteLine($"Selecting: {defaultVal}");
|
Console.BackgroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
||||||
return defaultVal;
|
Console.ForegroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
||||||
}
|
Console.Write("Yes");
|
||||||
else
|
|
||||||
{
|
|
||||||
bool choosing = true;
|
|
||||||
bool current = defaultVal;
|
|
||||||
Console.WriteLine(text);
|
|
||||||
while (choosing)
|
|
||||||
{
|
|
||||||
Console.CursorLeft = 0;
|
|
||||||
Console.BackgroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
|
||||||
Console.ForegroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
|
||||||
Console.Write("Yes");
|
|
||||||
Console.ResetColor();
|
|
||||||
Console.Write(" ");
|
|
||||||
Console.BackgroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
|
||||||
Console.ForegroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
|
||||||
Console.Write("No");
|
|
||||||
Console.ResetColor();
|
|
||||||
switch (Console.ReadKey().Key)
|
|
||||||
{
|
|
||||||
case ConsoleKey.LeftArrow:
|
|
||||||
case ConsoleKey.RightArrow:
|
|
||||||
current = !current;
|
|
||||||
break;
|
|
||||||
case ConsoleKey.Enter:
|
|
||||||
choosing = false;
|
|
||||||
break;
|
|
||||||
case ConsoleKey.Escape:
|
|
||||||
current = defaultVal;
|
|
||||||
choosing = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
Console.WriteLine($" Selecting: {current}");
|
Console.Write(" ");
|
||||||
return current;
|
Console.BackgroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
||||||
|
Console.ForegroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
||||||
|
Console.Write("No");
|
||||||
|
Console.ResetColor();
|
||||||
|
switch (Console.ReadKey().Key)
|
||||||
|
{
|
||||||
|
case ConsoleKey.LeftArrow:
|
||||||
|
case ConsoleKey.RightArrow:
|
||||||
|
current = !current;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Enter:
|
||||||
|
choosing = false;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Escape:
|
||||||
|
current = defaultVal;
|
||||||
|
choosing = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Console.ResetColor();
|
||||||
|
Console.WriteLine($" Selecting: {current}");
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OkDialog(string text)
|
public void OkDialog(string text)
|
||||||
{
|
{
|
||||||
if (Basic)
|
Console.WriteLine(text);
|
||||||
Console.WriteLine(text);
|
Console.BackgroundColor = ConsoleColor.White;
|
||||||
else
|
Console.Write("OK");
|
||||||
{
|
Console.ResetColor();
|
||||||
Console.WriteLine(text);
|
Console.ReadKey();
|
||||||
Console.BackgroundColor = ConsoleColor.White;
|
|
||||||
Console.Write("OK");
|
|
||||||
Console.ResetColor();
|
|
||||||
Console.ReadKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object GetDefaultIcon() => 0;
|
public object GetDefaultIcon() => 0;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>uptool</AssemblyName>
|
<AssemblyName>uptool</AssemblyName>
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
<AssemblyVersion>1.0.*</AssemblyVersion>
|
<AssemblyVersion>1.0.*</AssemblyVersion>
|
||||||
@ -13,8 +13,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0002" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20253.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Eto.Forms;
|
|
||||||
|
|
||||||
namespace UpToolEto.Gtk
|
|
||||||
{
|
|
||||||
class MainClass
|
|
||||||
{
|
|
||||||
[STAThread]
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
new Main(new Application(Eto.Platforms.Gtk), () =>
|
|
||||||
{
|
|
||||||
|
|
||||||
}, args).Entry();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\UpToolEto\UpToolEto.csproj"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Eto.Platform.Gtk" Version="2.5.10"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Eto.Forms;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace UpToolEto.Wpf
|
|
||||||
{
|
|
||||||
class MainClass
|
|
||||||
{
|
|
||||||
[STAThread]
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
new Main(new Application(Eto.Platforms.Wpf), () =>
|
|
||||||
{
|
|
||||||
Process[] processes = Process.GetProcessesByName("UpTool2");
|
|
||||||
if (processes.Length > 0)
|
|
||||||
BringProcessToFront(processes[0]);
|
|
||||||
}, args).Entry();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void BringProcessToFront(Process process)
|
|
||||||
{
|
|
||||||
IntPtr handle = process.MainWindowHandle;
|
|
||||||
if (IsIconic(handle))
|
|
||||||
ShowWindow(handle, 9);
|
|
||||||
SetForegroundWindow(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("User32.dll")]
|
|
||||||
private static extern bool SetForegroundWindow(IntPtr handle);
|
|
||||||
|
|
||||||
[DllImport("User32.dll")]
|
|
||||||
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
|
||||||
|
|
||||||
[DllImport("User32.dll")]
|
|
||||||
private static extern bool IsIconic(IntPtr handle);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\UpToolEto\UpToolEto.csproj"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Eto.Platform.Wpf" Version="2.5.10"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,65 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public abstract class AppControlButton : Button
|
|
||||||
{
|
|
||||||
public abstract void ReloadState();
|
|
||||||
public abstract void SetApp(App app);
|
|
||||||
public abstract void Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AppControlButton<T> : AppControlButton where T : KnownAppTask
|
|
||||||
{
|
|
||||||
private readonly IList<AppTask> _tasks;
|
|
||||||
private readonly Func<App, bool> _enabledCheck;
|
|
||||||
private readonly Color _defaultColor;
|
|
||||||
private App _app;
|
|
||||||
|
|
||||||
public AppControlButton(string text, Func<App, Action?, AppTask> factory, IList<AppTask> tasks, Action reloadState, Func<App, bool> enabledCheck)
|
|
||||||
{
|
|
||||||
_tasks = tasks;
|
|
||||||
_enabledCheck = enabledCheck;
|
|
||||||
_defaultColor = BackgroundColor;
|
|
||||||
Text = text;
|
|
||||||
Click += (_, _) =>
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
for (var i = tasks.ToArray().Length - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (tasks[i] is T t && t.App == _app)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
tasks.RemoveAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
tasks.Add(factory(_app, ReloadState));
|
|
||||||
reloadState();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ReloadState()
|
|
||||||
{
|
|
||||||
Enabled = _enabledCheck(_app);
|
|
||||||
BackgroundColor = _tasks.Any(s => s is T t && t.App == _app) ? Colors.Green : _defaultColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetApp(App app)
|
|
||||||
{
|
|
||||||
_app = app;
|
|
||||||
ReloadState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Clear()
|
|
||||||
{
|
|
||||||
Enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public class AppControls : StackLayout
|
|
||||||
{
|
|
||||||
private readonly IList<AppTask> _tasks;
|
|
||||||
private readonly List<AppControlButton> _buttons;
|
|
||||||
private readonly Button _applyButton;
|
|
||||||
public AppControls(TaskFactory factory, IList<AppTask> tasks, IExternalFunctionality platform, Action update)
|
|
||||||
{
|
|
||||||
_tasks = tasks;
|
|
||||||
_buttons = new List<AppControlButton>
|
|
||||||
{
|
|
||||||
new AppControlButton<InstallTask>("Install", factory.CreateInstall, tasks, ReloadState,
|
|
||||||
app => !app.Status.Contains(Status.Installed)),
|
|
||||||
new AppControlButton<UpdateTask>("Update", factory.CreateUpdate, tasks, ReloadState,
|
|
||||||
app => app.Status.Contains(Status.Updatable)),
|
|
||||||
new AppControlButton<RemoveTask>("Remove", factory.CreateRemove, tasks, ReloadState,
|
|
||||||
app => app.Status.Contains(Status.Installed))
|
|
||||||
};
|
|
||||||
_applyButton = new Button((_, _) =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
QueueOverview overview = new(tasks);
|
|
||||||
overview.ShowModal();
|
|
||||||
if (!overview.Cancelled)
|
|
||||||
{
|
|
||||||
foreach (AppTask task in overview.TasksResulting)
|
|
||||||
{
|
|
||||||
task.Run();
|
|
||||||
_tasks.RemoveAt(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
platform.OkDialog("Failed to complete queue:\r\n" + e);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ReloadState();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Text = "Apply",
|
|
||||||
Enabled = false
|
|
||||||
};
|
|
||||||
foreach (AppControlButton button in _buttons) Items.Add(button);
|
|
||||||
Items.Add(new StackLayoutItem(_applyButton, HorizontalAlignment.Right));
|
|
||||||
if (Main.DebugColors)
|
|
||||||
BackgroundColor = Colors.Yellow;
|
|
||||||
Orientation = Orientation.Horizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetApp(App app)
|
|
||||||
{
|
|
||||||
foreach (AppControlButton button in _buttons) button.SetApp(app);
|
|
||||||
ReloadState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
foreach (AppControlButton button in _buttons) button.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadState()
|
|
||||||
{
|
|
||||||
foreach (AppControlButton button in _buttons) button.ReloadState();
|
|
||||||
_applyButton.Enabled = _tasks.Any();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Forms;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public class AppList : StackLayout
|
|
||||||
{
|
|
||||||
private readonly AppExtras _extras;
|
|
||||||
private readonly Action<Guid, App> _itemClickEvent;
|
|
||||||
private readonly StackLayout _layout;
|
|
||||||
private readonly AppListSearchProvider _searchProvider;
|
|
||||||
|
|
||||||
public AppList(AppExtras extras, Action<Guid, App> itemClickEvent, bool online, TaskFactory factory, IList<AppTask> tasks)
|
|
||||||
{
|
|
||||||
_extras = extras;
|
|
||||||
_itemClickEvent = itemClickEvent;
|
|
||||||
_searchProvider = new AppListSearchProvider(online, Update);
|
|
||||||
Items.Add(_searchProvider);
|
|
||||||
_layout = new StackLayout
|
|
||||||
{
|
|
||||||
Padding = 10,
|
|
||||||
Orientation = Orientation.Vertical,
|
|
||||||
Width = 200
|
|
||||||
};
|
|
||||||
Scrollable scrollable = new()
|
|
||||||
{
|
|
||||||
Content = _layout
|
|
||||||
};
|
|
||||||
if (Main.DebugColors)
|
|
||||||
scrollable.BackgroundColor = Colors.YellowGreen;
|
|
||||||
Items.Add(new StackLayoutItem(scrollable, VerticalAlignment.Stretch, true));
|
|
||||||
Orientation = Orientation.Vertical;
|
|
||||||
if (Main.DebugColors)
|
|
||||||
BackgroundColor = Colors.Green;
|
|
||||||
Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
_layout.Items.Clear();
|
|
||||||
foreach (App app in _extras.FindApps(_searchProvider.GetSearchTerms()))
|
|
||||||
if (_searchProvider.Matches(app))
|
|
||||||
_layout.Items.Add(new Button((_, _) => _itemClickEvent(app.Id, app))
|
|
||||||
{
|
|
||||||
Text = app.Name,
|
|
||||||
Image = (Icon)app.Icon,
|
|
||||||
ImagePosition = ButtonImagePosition.Left,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public class AppListSearchProvider : StackLayout
|
|
||||||
{
|
|
||||||
private readonly bool _online;
|
|
||||||
private readonly TextBox _search;
|
|
||||||
private readonly EnumDropDown<Status> _state;
|
|
||||||
|
|
||||||
public AppListSearchProvider(bool online, Action refresh)
|
|
||||||
{
|
|
||||||
_online = online;
|
|
||||||
_search = new SearchBox();
|
|
||||||
_state = new EnumDropDown<Status>();
|
|
||||||
_state.SelectedValue = online ? Status.NotInstalled : Status.Installed;
|
|
||||||
_state.Enabled = online;
|
|
||||||
_search.TextChanged += (_, _) => refresh();
|
|
||||||
_state.SelectedIndexChanged += (_, _) => refresh();
|
|
||||||
Orientation = Orientation.Vertical;
|
|
||||||
Items.Add(new StackLayoutItem(_search, HorizontalAlignment.Stretch));
|
|
||||||
Items.Add(_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Matches(App app) => app.Status.Contains(_online ? _state.SelectedValue : Status.Installed);
|
|
||||||
|
|
||||||
public string GetSearchTerms() => _search.Text;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public class AppPanel : Panel
|
|
||||||
{
|
|
||||||
private readonly Button _appNameLabel;
|
|
||||||
private readonly Label _appDescriptionLabel;
|
|
||||||
private readonly AppControls _appControls;
|
|
||||||
private App _app;
|
|
||||||
public AppPanel(TaskFactory factory, AppExtras extras, IList<AppTask> tasks, IExternalFunctionality platform, Action updateAppList)
|
|
||||||
{
|
|
||||||
_appDescriptionLabel = new Label();
|
|
||||||
_appNameLabel = new Button((_, _) =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
extras.RunApp(_app);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
platform.OkDialog("Failed to start\r\n" + e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_appNameLabel.Font = new Font(_appNameLabel.Font.Family, _appNameLabel.Font.Size * 2);
|
|
||||||
_appControls = new AppControls(factory, tasks, platform, () =>
|
|
||||||
{
|
|
||||||
updateAppList();
|
|
||||||
SetApp(_app);
|
|
||||||
});
|
|
||||||
Content = new StackLayout
|
|
||||||
{
|
|
||||||
Items =
|
|
||||||
{
|
|
||||||
new StackLayoutItem(_appNameLabel, HorizontalAlignment.Center),
|
|
||||||
new StackLayoutItem(_appDescriptionLabel, HorizontalAlignment.Center, true),
|
|
||||||
new StackLayoutItem(_appControls, HorizontalAlignment.Stretch)
|
|
||||||
},
|
|
||||||
Orientation = Orientation.Vertical
|
|
||||||
};
|
|
||||||
if (Main.DebugColors)
|
|
||||||
BackgroundColor = Colors.Red;
|
|
||||||
Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetApp(App app)
|
|
||||||
{
|
|
||||||
_app = app;
|
|
||||||
_appNameLabel.Text = app.Name;
|
|
||||||
_appNameLabel.Enabled = app.Status.Contains(Status.Installed) && app.Runnable;
|
|
||||||
_appDescriptionLabel.Text = app.Description;
|
|
||||||
_appControls.SetApp(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
_appNameLabel.Text = "Welcome to UpTool2";
|
|
||||||
_appNameLabel.Enabled = false;
|
|
||||||
_appDescriptionLabel.Text = "Select an app to get started";
|
|
||||||
_appControls.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public class RepoItem : StackLayout
|
|
||||||
{
|
|
||||||
public RepoItem(Repo repo, int index, Action update, IList<Repo> repos)
|
|
||||||
{
|
|
||||||
TextBox name = new()
|
|
||||||
{
|
|
||||||
Text = repo.Name
|
|
||||||
};
|
|
||||||
name.TextChanged += (_, _) => repo.Name = name.Text;
|
|
||||||
TextBox link = new()
|
|
||||||
{
|
|
||||||
Text = repo.Url
|
|
||||||
};
|
|
||||||
link.TextChanged += (_, _) => repo.Url = link.Text;
|
|
||||||
Orientation = Orientation.Horizontal;
|
|
||||||
Items.Add(name);
|
|
||||||
Items.Add(new StackLayoutItem(link, HorizontalAlignment.Stretch, true));
|
|
||||||
Items.Add(new Button((_, _) =>
|
|
||||||
{
|
|
||||||
repos.RemoveAt(index);
|
|
||||||
update();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Text = "-"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Controls
|
|
||||||
{
|
|
||||||
public class UTMenuBar : MenuBar
|
|
||||||
{
|
|
||||||
public UTMenuBar(MainForm mainForm, RepoManagement repoManagement, TaskFactory factory, IList<AppTask> tasks, AppList appList, IExternalFunctionality platform)
|
|
||||||
{
|
|
||||||
Command reloadRepos = new() {MenuText = "Reload", ToolBarText = "Reload"};
|
|
||||||
reloadRepos.Executed += (_, _) =>
|
|
||||||
{
|
|
||||||
if (platform.YesNoDialog("This may take some time. Are you sure?", true))
|
|
||||||
{
|
|
||||||
repoManagement.FetchRepos();
|
|
||||||
repoManagement.GetReposFromDisk();
|
|
||||||
appList.Update();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Command editSources = new() {MenuText = "Sources", ToolBarText = "Sources"};
|
|
||||||
editSources.Executed += (_, _) => new RepoForm(repoManagement).ShowModal();
|
|
||||||
|
|
||||||
Command addPackage = new() {MenuText = "Add Package", ToolBarText = "Add Package"};
|
|
||||||
addPackage.Executed += (_, _) =>
|
|
||||||
{
|
|
||||||
OpenFileDialog dialog = new() {MultiSelect = false, CheckFileExists = true, Filters = { new FileFilter("App package", ".zip")}};
|
|
||||||
if (dialog.ShowDialog(mainForm) == DialogResult.Ok)
|
|
||||||
{
|
|
||||||
if (!tasks.Any(s => s is UploadTask t && t.ZipFile == dialog.FileName))
|
|
||||||
{
|
|
||||||
StringDialog sd = new("Package name") {Text = "New package"};
|
|
||||||
sd.ShowModal();
|
|
||||||
tasks.Add(factory.CreateUpload(dialog.FileName, sd.Text));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Command quitCommand = new() {MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q};
|
|
||||||
quitCommand.Executed += (_, _) => Application.Instance.Quit();
|
|
||||||
|
|
||||||
Command aboutCommand = new() {MenuText = "About Eto..."};
|
|
||||||
aboutCommand.Executed += (_, _) => new AboutDialog().ShowDialog(mainForm);
|
|
||||||
|
|
||||||
Items.Add(new ButtonMenuItem
|
|
||||||
{
|
|
||||||
Text = "&File", Items =
|
|
||||||
{
|
|
||||||
reloadRepos,
|
|
||||||
editSources,
|
|
||||||
addPackage
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// File submenu
|
|
||||||
// new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
|
|
||||||
// new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
|
|
||||||
/*ApplicationItems =
|
|
||||||
{
|
|
||||||
// application (OS X) or file menu (others)
|
|
||||||
new ButtonMenuItem {Text = "&Preferences..."},
|
|
||||||
},*/
|
|
||||||
QuitItem = quitCommand;
|
|
||||||
AboutItem = aboutCommand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
|
|
||||||
namespace UpToolEto.Forms
|
|
||||||
{
|
|
||||||
public class DownloadDialog : Dialog
|
|
||||||
{
|
|
||||||
private readonly Uri _url;
|
|
||||||
private readonly Application _application;
|
|
||||||
private readonly IExternalFunctionality _platform;
|
|
||||||
public State CurrentState = State.NotStarted;
|
|
||||||
public byte[] Download = new byte[0];
|
|
||||||
private readonly ProgressBar _bar;
|
|
||||||
public DownloadDialog(Uri url, Application application, IExternalFunctionality platform)
|
|
||||||
{
|
|
||||||
_url = url;
|
|
||||||
_application = application;
|
|
||||||
_platform = platform;
|
|
||||||
Title = "Downloader";
|
|
||||||
Resizable = false;
|
|
||||||
Maximizable = false;
|
|
||||||
Minimizable = false;
|
|
||||||
WindowStyle = WindowStyle.Utility;
|
|
||||||
_bar = new();
|
|
||||||
_bar.MaxValue = 100;
|
|
||||||
Content = new StackLayout
|
|
||||||
{
|
|
||||||
Padding = 10,
|
|
||||||
Items =
|
|
||||||
{
|
|
||||||
"Downloading " + url,
|
|
||||||
new StackLayoutItem(_bar, HorizontalAlignment.Stretch, true)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Size = new Size(700, 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartDownload()
|
|
||||||
{
|
|
||||||
CurrentState = State.Downloading;
|
|
||||||
new Thread(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
WebClient client = new();
|
|
||||||
client.DownloadProgressChanged += (_, args) => _application.Invoke(() =>
|
|
||||||
{
|
|
||||||
_bar.Value = args.ProgressPercentage;
|
|
||||||
_application.RunIteration();
|
|
||||||
});
|
|
||||||
client.DownloadDataCompleted += (_, args) =>
|
|
||||||
{
|
|
||||||
CurrentState = State.Success;
|
|
||||||
Download = args.Result;
|
|
||||||
_application.Invoke(Close);
|
|
||||||
};
|
|
||||||
client.DownloadDataAsync(_url, client);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
CurrentState = State.Failed;
|
|
||||||
_application.Invoke(Close);
|
|
||||||
}
|
|
||||||
}).Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum State
|
|
||||||
{
|
|
||||||
NotStarted,
|
|
||||||
Downloading,
|
|
||||||
Failed,
|
|
||||||
Success
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
|
|
||||||
namespace UpToolEto.Forms
|
|
||||||
{
|
|
||||||
public class InitScreen : Form
|
|
||||||
{
|
|
||||||
private readonly Application _application;
|
|
||||||
private readonly IExternalFunctionality _platform;
|
|
||||||
private readonly Label _lab;
|
|
||||||
public InitScreen(Application application, IExternalFunctionality platform)
|
|
||||||
{
|
|
||||||
_application = application;
|
|
||||||
_platform = platform;
|
|
||||||
Title = "UpTool2 Init";
|
|
||||||
Resizable = false;
|
|
||||||
Maximizable = false;
|
|
||||||
Minimizable = false;
|
|
||||||
WindowStyle = WindowStyle.None;
|
|
||||||
_lab = new Label();
|
|
||||||
Label header = new();
|
|
||||||
header.Font = new Font(header.Font.Family, header.Font.Size * 2);
|
|
||||||
header.Text = "UpTool2";
|
|
||||||
Content = new StackLayout
|
|
||||||
{
|
|
||||||
Padding = 10,
|
|
||||||
Items =
|
|
||||||
{
|
|
||||||
new StackLayoutItem(header, HorizontalAlignment.Center),
|
|
||||||
new StackLayoutItem(_lab, HorizontalAlignment.Center)
|
|
||||||
},
|
|
||||||
VerticalContentAlignment = VerticalAlignment.Center
|
|
||||||
};
|
|
||||||
Shown += (_, _) => Size = new Size(700, 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetText(string text)
|
|
||||||
{
|
|
||||||
_application.Invoke(() =>
|
|
||||||
{
|
|
||||||
_platform.Log(text);
|
|
||||||
_lab.Text = text;
|
|
||||||
_application.RunIteration();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Close() => _application.Invoke(() => base.Close());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Controls;
|
|
||||||
using UpToolLib;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Forms
|
|
||||||
{
|
|
||||||
public partial class MainForm : Form
|
|
||||||
{
|
|
||||||
private readonly AppPanel _appPanel;
|
|
||||||
private readonly IList<AppTask> _tasks;
|
|
||||||
public MainForm(InitScreen init, UpToolLibMain lib, IExternalFunctionality platform, bool online)
|
|
||||||
{
|
|
||||||
_tasks = new List<AppTask>();
|
|
||||||
Title = "UpTool2";
|
|
||||||
MinimumSize = new Size(600, 100);
|
|
||||||
AppList appList = new(lib.V1.AppExtras, (_, app) => _appPanel.SetApp(app), online, lib.V2.TaskFactory, _tasks);
|
|
||||||
_appPanel = new AppPanel(lib.V2.TaskFactory, lib.V1.AppExtras, _tasks, platform, appList.Update);
|
|
||||||
|
|
||||||
Content = new StackLayout
|
|
||||||
{
|
|
||||||
Padding = 10,
|
|
||||||
Items =
|
|
||||||
{
|
|
||||||
new StackLayoutItem(appList, VerticalAlignment.Stretch),
|
|
||||||
new StackLayoutItem(_appPanel, VerticalAlignment.Stretch, true)
|
|
||||||
},
|
|
||||||
Orientation = Orientation.Horizontal
|
|
||||||
};
|
|
||||||
Menu = new UTMenuBar(this, lib.V2.RepoManagement, lib.V2.TaskFactory, _tasks, appList, platform);
|
|
||||||
Shown += (_, _) => init.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolEto.Forms
|
|
||||||
{
|
|
||||||
public class QueueOverview : Dialog
|
|
||||||
{
|
|
||||||
private readonly IList<AppTask> _tasks;
|
|
||||||
public bool Cancelled;
|
|
||||||
CheckBoxList cbl;
|
|
||||||
public List<AppTask> TasksResulting => cbl.SelectedValues.Select(s => (AppTask) s).ToList();
|
|
||||||
|
|
||||||
public QueueOverview(IList<AppTask> tasks)
|
|
||||||
{
|
|
||||||
_tasks = tasks;
|
|
||||||
StackLayout layout = new();
|
|
||||||
layout.Items.Add(new StackLayoutItem(new StackLayout()
|
|
||||||
{
|
|
||||||
Items =
|
|
||||||
{
|
|
||||||
new StackLayoutItem(new Button((_, _) =>
|
|
||||||
{
|
|
||||||
Cancelled = true;
|
|
||||||
Close();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Text = "Cancel"
|
|
||||||
}, HorizontalAlignment.Stretch),
|
|
||||||
new StackLayoutItem(new Button((_, _) =>
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Text = "OK"
|
|
||||||
}, HorizontalAlignment.Stretch)
|
|
||||||
},
|
|
||||||
Orientation = Orientation.Horizontal
|
|
||||||
}, HorizontalAlignment.Stretch));
|
|
||||||
cbl = new CheckBoxList {DataStore = tasks, SelectedValues = tasks};
|
|
||||||
layout.Items.Add(cbl);
|
|
||||||
Content = layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Controls;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolEto.Forms
|
|
||||||
{
|
|
||||||
public class RepoForm : Dialog
|
|
||||||
{
|
|
||||||
private readonly RepoManagement _management;
|
|
||||||
private List<Repo> _repos = new();
|
|
||||||
private StackLayout _layout;
|
|
||||||
public RepoForm(RepoManagement management)
|
|
||||||
{
|
|
||||||
_management = management;
|
|
||||||
_repos.AddRange(management.GetRepos());
|
|
||||||
Title = "Sources";
|
|
||||||
_layout = new StackLayout();
|
|
||||||
Content = _layout;
|
|
||||||
Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
_layout.Items.Clear();
|
|
||||||
_layout.Items.Add(new StackLayoutItem(new Button((_, _) =>
|
|
||||||
{
|
|
||||||
_repos.Add(new Repo
|
|
||||||
{
|
|
||||||
Name = "New repo",
|
|
||||||
Url = "https://example.com/repo.xml"
|
|
||||||
});
|
|
||||||
Update();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Text = "Add",
|
|
||||||
}, HorizontalAlignment.Stretch));
|
|
||||||
StackLayout reposLayout = new();
|
|
||||||
for (int i = 0; i < _repos.Count; i++)
|
|
||||||
reposLayout.Items.Add(new StackLayoutItem(new RepoItem(_repos[i], i, Update, _repos), HorizontalAlignment.Stretch));
|
|
||||||
_layout.Items.Add(new StackLayoutItem(new Scrollable{Content = reposLayout}, HorizontalAlignment.Stretch, true));
|
|
||||||
_layout.Items.Add(new StackLayoutItem(new Button((_, _) =>
|
|
||||||
{
|
|
||||||
_management.Save(_repos);
|
|
||||||
Close();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Text = "Save"
|
|
||||||
}, HorizontalAlignment.Stretch));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using Eto.Forms;
|
|
||||||
|
|
||||||
namespace UpToolEto.Forms
|
|
||||||
{
|
|
||||||
public class StringDialog : Dialog
|
|
||||||
{
|
|
||||||
private readonly TextBox _tb;
|
|
||||||
public string Text
|
|
||||||
{
|
|
||||||
get => _tb.Text;
|
|
||||||
set => _tb.Text = value;
|
|
||||||
}
|
|
||||||
public StringDialog(string title)
|
|
||||||
{
|
|
||||||
_tb = new TextBox();
|
|
||||||
Content = _tb;
|
|
||||||
Title = title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,164 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Xml;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Forms;
|
|
||||||
using UpToolLib;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolEto
|
|
||||||
{
|
|
||||||
public class Main
|
|
||||||
{
|
|
||||||
private readonly IExternalFunctionality _platform;
|
|
||||||
private readonly Application _application;
|
|
||||||
private readonly Action _activityExistsException;
|
|
||||||
private readonly InitScreen _init;
|
|
||||||
private readonly bool _skipFetch;
|
|
||||||
public static bool DebugColors { get; private set; }
|
|
||||||
|
|
||||||
public Main(Application application, Action activityExistsException, string[] args)
|
|
||||||
{
|
|
||||||
_skipFetch = args.Contains("--skip-fetch");
|
|
||||||
DebugColors = args.Contains("--debug-colors");
|
|
||||||
_platform = new UTLibFunctions(application);
|
|
||||||
_application = application;
|
|
||||||
_activityExistsException = activityExistsException;
|
|
||||||
_init = new(application, _platform);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Entry()
|
|
||||||
{
|
|
||||||
new Thread(InitThread).Start();
|
|
||||||
_application.Run(_init);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitThread()
|
|
||||||
{
|
|
||||||
UpToolLibMain lib = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
lib = new UpToolLibMain(_platform);
|
|
||||||
_init.SetText("Initializing paths");
|
|
||||||
if (!Directory.Exists(lib.V1.PathTool.Dir))
|
|
||||||
Directory.CreateDirectory(lib.V1.PathTool.Dir);
|
|
||||||
FixXml(lib.V1.XmlTool, lib.V1.PathTool);
|
|
||||||
_init.SetText("Performing checks");
|
|
||||||
bool online = false;
|
|
||||||
UpdateCheck updateCheck = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
updateCheck = lib.V2.UpdateChecker.Check();
|
|
||||||
online = true;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
_platform.Log("Could not perform update check, starting offline");
|
|
||||||
}
|
|
||||||
if (online && UpdateCheck(updateCheck, lib.V1.PathTool, _init))
|
|
||||||
_platform.Log("Quitting");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(lib.V1.PathTool.GetRelative("Apps")))
|
|
||||||
Directory.CreateDirectory(lib.V1.PathTool.GetRelative("Apps"));
|
|
||||||
if (!_skipFetch && online)
|
|
||||||
{
|
|
||||||
_init.SetText("Fetching repos");
|
|
||||||
lib.V2.RepoManagement.FetchRepos();
|
|
||||||
}
|
|
||||||
lib.V2.RepoManagement.GetReposFromDisk();
|
|
||||||
_init.SetText("Opening");
|
|
||||||
_application.Invoke(() => _application.Run(new MainForm(_init, lib, _platform, online)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (MutexLockLockedException)
|
|
||||||
{
|
|
||||||
_application.Invoke(() =>
|
|
||||||
{
|
|
||||||
_init.Close();
|
|
||||||
_platform.OkDialog("Mutex property of other process, quitting");
|
|
||||||
_activityExistsException();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
lib?.Dispose();
|
|
||||||
_platform.Log(e.ToString());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
lib?.Dispose();
|
|
||||||
_application.Invoke(() => _application.Quit());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FixXml(XmlTool xmlTool, PathTool pathTool, bool throwOnError = false)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
xmlTool.FixXml();
|
|
||||||
}
|
|
||||||
catch (XmlException)
|
|
||||||
{
|
|
||||||
if (throwOnError) throw;
|
|
||||||
_platform.OkDialog("Something went wrong while trying to parse XML. Retrying...");
|
|
||||||
File.Delete(pathTool.InfoXml);
|
|
||||||
FixXml(xmlTool, pathTool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool UpdateCheck(UpdateCheck updateCheck, PathTool pathTool, InitScreen init)
|
|
||||||
{
|
|
||||||
init.SetText("Comparing online version");
|
|
||||||
if (Assembly.GetExecutingAssembly().GetName().Version >= updateCheck.OnlineVersion) return false;
|
|
||||||
if (PlatformCheck.IsWindows)
|
|
||||||
{
|
|
||||||
init.SetText("Downloading latest");
|
|
||||||
(bool success, byte[] dl) = _platform.Download(updateCheck.Installer);
|
|
||||||
if (!success)
|
|
||||||
throw new Exception("Failed to update");
|
|
||||||
init.SetText("Verifying");
|
|
||||||
using (SHA256CryptoServiceProvider sha256 = new())
|
|
||||||
{
|
|
||||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
|
||||||
if (pkgHash != updateCheck.InstallerHash)
|
|
||||||
throw new Exception(
|
|
||||||
$"The hash is not equal to the one stored in the repo:\r\nPackage: {pkgHash}\r\nOnline: {updateCheck.InstallerHash}");
|
|
||||||
}
|
|
||||||
init.SetText("Installing");
|
|
||||||
if (Directory.Exists(pathTool.GetRelative("Install", "tmp")))
|
|
||||||
Directory.Delete(pathTool.GetRelative("Install", "tmp"), true);
|
|
||||||
Directory.CreateDirectory(pathTool.GetRelative("Install", "tmp"));
|
|
||||||
using (MemoryStream ms = new(dl))
|
|
||||||
{
|
|
||||||
using ZipArchive ar = new(ms);
|
|
||||||
ar.ExtractToDirectory(pathTool.GetRelative("Install", "tmp"), true);
|
|
||||||
}
|
|
||||||
init.Close();
|
|
||||||
Process.Start(new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = pathTool.GetRelative("Install", "tmp", "Installer.exe"),
|
|
||||||
Arguments = "i -p",
|
|
||||||
CreateNoWindow = true,
|
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
|
||||||
WorkingDirectory = pathTool.GetRelative("Install")
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_platform.OkDialog("A new version is available. Please install it");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading;
|
|
||||||
using Eto.Drawing;
|
|
||||||
using Eto.Forms;
|
|
||||||
using UpToolEto.Forms;
|
|
||||||
using UpToolLib;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
|
|
||||||
namespace UpToolEto
|
|
||||||
{
|
|
||||||
public class UTLibFunctions : IExternalFunctionality
|
|
||||||
{
|
|
||||||
private readonly Application _application;
|
|
||||||
private const int ImgSize = 32;
|
|
||||||
public Tuple<bool, byte[]> Download(Uri link)
|
|
||||||
{
|
|
||||||
DownloadDialog dlg = new(link, _application, this);
|
|
||||||
_application.AsyncInvoke(() => dlg.ShowModal());
|
|
||||||
dlg.StartDownload();
|
|
||||||
Log("Downloading " + link);
|
|
||||||
while (dlg.CurrentState == DownloadDialog.State.Downloading) Thread.Sleep(20);
|
|
||||||
Log("Download complete");
|
|
||||||
return new Tuple<bool, byte[]>(dlg.CurrentState == DownloadDialog.State.Success, dlg.Download);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string FetchImageB64(Uri link)
|
|
||||||
{
|
|
||||||
using WebClient client = new();
|
|
||||||
using Stream s = client.OpenRead(link);
|
|
||||||
using Bitmap source = new(s);
|
|
||||||
using Icon bmp = source.WithSize(ImgSize, ImgSize);
|
|
||||||
using Bitmap bitmapResized = new(bmp);
|
|
||||||
using MemoryStream ms = new();
|
|
||||||
bitmapResized.Save(ms, ImageFormat.Png);
|
|
||||||
return Convert.ToBase64String(ms.ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool YesNoDialog(string text, bool defaultVal) =>
|
|
||||||
_application.Invoke(() => MessageBox.Show(text, MessageBoxButtons.YesNo,
|
|
||||||
defaultButton: defaultVal ? MessageBoxDefaultButton.Yes : MessageBoxDefaultButton.No)) ==
|
|
||||||
DialogResult.Yes;
|
|
||||||
|
|
||||||
public void OkDialog(string text) => _application.Invoke(() => MessageBox.Show(text));
|
|
||||||
|
|
||||||
public object GetDefaultIcon() => Bitmap.FromResource("UpToolLib.C_64.ico", typeof(UpToolLibMain)).WithSize(ImgSize, ImgSize);
|
|
||||||
|
|
||||||
public object ImageFromB64(string b64) => new Bitmap(Convert.FromBase64String(b64)).WithSize(ImgSize, ImgSize);
|
|
||||||
|
|
||||||
public void Log(string text)
|
|
||||||
{
|
|
||||||
Console.WriteLine(text);
|
|
||||||
//TODO implement visual logging
|
|
||||||
}
|
|
||||||
|
|
||||||
public UTLibFunctions(Application application) => _application = application;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Eto.Forms" Version="2.5.10" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\UpToolLib\UpToolLib.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -3,11 +3,10 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.Tool;
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using static System.Environment;
|
using static System.Environment;
|
||||||
|
|
||||||
namespace UpToolLib.v2
|
namespace UpToolLib.DataStructures
|
||||||
{
|
{
|
||||||
public struct App : IEquatable<App>
|
public struct App : IEquatable<App>
|
||||||
{
|
{
|
||||||
@ -22,10 +21,9 @@ namespace UpToolLib.v2
|
|||||||
public readonly object Icon;
|
public readonly object Icon;
|
||||||
public readonly bool Runnable;
|
public readonly bool Runnable;
|
||||||
public readonly string MainFile;
|
public readonly string MainFile;
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
|
|
||||||
internal App(string name, string description, Version version, string file, bool local, string hash, Guid iD,
|
public App(string name, string description, Version version, string file, bool local, string hash, Guid iD,
|
||||||
Color color, object icon, bool runnable, string mainFile, PathTool pathTool)
|
Color color, object icon, bool runnable, string mainFile)
|
||||||
{
|
{
|
||||||
Name = name ?? throw new ArgumentNullException(nameof(name));
|
Name = name ?? throw new ArgumentNullException(nameof(name));
|
||||||
Description = description ?? throw new ArgumentNullException(nameof(description));
|
Description = description ?? throw new ArgumentNullException(nameof(description));
|
||||||
@ -38,7 +36,6 @@ namespace UpToolLib.v2
|
|||||||
Icon = icon ?? throw new ArgumentNullException(nameof(icon));
|
Icon = icon ?? throw new ArgumentNullException(nameof(icon));
|
||||||
Runnable = runnable;
|
Runnable = runnable;
|
||||||
MainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
|
MainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
|
||||||
_pathTool = pathTool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status Status
|
public Status Status
|
||||||
@ -78,8 +75,8 @@ Object Hash Code: {GetHashCode()}";
|
|||||||
|
|
||||||
public static bool operator !=(App left, App right) => !(left == right);
|
public static bool operator !=(App left, App right) => !(left == right);
|
||||||
|
|
||||||
public string AppPath => _pathTool.GetAppPath(Id);
|
public string AppPath => PathTool.GetAppPath(Id);
|
||||||
public string DataPath => _pathTool.GetDataPath(Id);
|
public string DataPath => PathTool.GetDataPath(Id);
|
||||||
public string InfoPath => _pathTool.GetInfoPath(Id);
|
public string InfoPath => PathTool.GetInfoPath(Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
namespace UpToolLib.DataStructures
|
|
||||||
{
|
|
||||||
public class Repo
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Url { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,11 +9,6 @@ namespace UpToolLib.DataStructures
|
|||||||
Updatable = 2,
|
Updatable = 2,
|
||||||
Installed = 4,
|
Installed = 4,
|
||||||
Local = 8,
|
Local = 8,
|
||||||
All = 0
|
All = 15
|
||||||
}
|
|
||||||
|
|
||||||
public static class StatusExtensions
|
|
||||||
{
|
|
||||||
public static bool Contains(this Status status, Status other) => (status & other) == other;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
14
UpToolLib/ExternalFunctionalityManager.cs
Normal file
14
UpToolLib/ExternalFunctionalityManager.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using UpToolLib.DataStructures;
|
||||||
|
|
||||||
|
namespace UpToolLib
|
||||||
|
{
|
||||||
|
public static class ExternalFunctionalityManager
|
||||||
|
{
|
||||||
|
internal static IExternalFunctionality Instance;
|
||||||
|
|
||||||
|
public static void Init(IExternalFunctionality externalFunctionality)
|
||||||
|
{
|
||||||
|
Instance = externalFunctionality;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
UpToolLib/GlobalVariables.cs
Normal file
18
UpToolLib/GlobalVariables.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UpToolLib.DataStructures;
|
||||||
|
|
||||||
|
namespace UpToolLib
|
||||||
|
{
|
||||||
|
public static class GlobalVariables
|
||||||
|
{
|
||||||
|
public const string Windows = "WINDOWS";
|
||||||
|
public const string Posix = "POSIX";
|
||||||
|
public static readonly Dictionary<Guid, App> Apps = new Dictionary<Guid, App>();
|
||||||
|
public static Version MinimumVer => Version.Parse("0.0.0.0");
|
||||||
|
|
||||||
|
public static string CurrentPlatform =>
|
||||||
|
PlatformCheck.IsWindows ? Windows :
|
||||||
|
PlatformCheck.IsPosix ? Posix : throw new Exception("Unexpeccted PlatformCheck");
|
||||||
|
}
|
||||||
|
}
|
43
UpToolLib/Lock.cs
Normal file
43
UpToolLib/Lock.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace UpToolLib
|
||||||
|
{
|
||||||
|
public static class MutexLock
|
||||||
|
{
|
||||||
|
private static Mutex _mutex;
|
||||||
|
private static bool _hasHandle;
|
||||||
|
|
||||||
|
public static void Lock()
|
||||||
|
{
|
||||||
|
_mutex = new Mutex(false,
|
||||||
|
"Global\\{c0c1e002-9e13-4e8f-a035-dbdc5128e00e}",
|
||||||
|
out bool _);
|
||||||
|
_hasHandle = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_hasHandle = _mutex.WaitOne(5000, false);
|
||||||
|
if (_hasHandle)
|
||||||
|
return;
|
||||||
|
throw new MutexLockLockedException();
|
||||||
|
}
|
||||||
|
catch (AbandonedMutexException)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Debug.WriteLine("Mutex abandoned");
|
||||||
|
#endif
|
||||||
|
_hasHandle = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Unlock()
|
||||||
|
{
|
||||||
|
if (_hasHandle)
|
||||||
|
_mutex.ReleaseMutex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MutexLockLockedException : Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace UpToolLib
|
|
||||||
{
|
|
||||||
public class MutexLockLockedException : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace UpToolLib.v1
|
namespace UpToolLib
|
||||||
{
|
{
|
||||||
public static class PlatformCheck
|
public static class PlatformCheck
|
||||||
{
|
{
|
||||||
@ -13,11 +13,5 @@ namespace UpToolLib.v1
|
|||||||
.Contains(Environment.OSVersion.Platform);
|
.Contains(Environment.OSVersion.Platform);
|
||||||
|
|
||||||
public static bool IsPosix => !IsWindows;
|
public static bool IsPosix => !IsWindows;
|
||||||
|
|
||||||
public const string Windows = "WINDOWS";
|
|
||||||
public const string Posix = "POSIX";
|
|
||||||
public static string CurrentPlatform =>
|
|
||||||
IsWindows ? Windows :
|
|
||||||
IsPosix ? Posix : throw new Exception("Unexpected PlatformCheck");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@ -4,43 +4,29 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UpToolLib.v2;
|
using UpToolLib.DataStructures;
|
||||||
|
|
||||||
namespace UpToolLib.v1.Tool
|
namespace UpToolLib.Tool
|
||||||
{
|
{
|
||||||
public class AppExtras
|
public static class AppExtras
|
||||||
{
|
{
|
||||||
private readonly AppInstall _appInstall;
|
public static Process RunApp(App app) =>
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
private readonly IDictionary<Guid, App> _apps;
|
|
||||||
|
|
||||||
internal AppExtras(AppInstall appInstall, PathTool pathTool, IDictionary<Guid, App> apps)
|
|
||||||
{
|
|
||||||
_appInstall = appInstall;
|
|
||||||
_pathTool = pathTool;
|
|
||||||
_apps = apps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Process RunApp(App app) => RunApp(app, app.MainFile, "");
|
|
||||||
public Process RunApp(App app, string arguments) => RunApp(app, app.MainFile, arguments);
|
|
||||||
public Process RunApp(App app, string file, string arguments) =>
|
|
||||||
Process.Start(
|
Process.Start(
|
||||||
new ProcessStartInfo
|
new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = Path.Combine(app.DataPath, file),
|
FileName = Path.Combine(app.DataPath, app.MainFile),
|
||||||
Arguments = arguments,
|
|
||||||
WorkingDirectory = app.DataPath
|
WorkingDirectory = app.DataPath
|
||||||
});
|
});
|
||||||
|
|
||||||
public void Update(App app, bool overwrite)
|
public static void Update(App app, bool overwrite)
|
||||||
{
|
{
|
||||||
Remove(app, overwrite);
|
Remove(app, overwrite);
|
||||||
_appInstall.Install(app, overwrite);
|
AppInstall.Install(app, overwrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(App app, bool deleteAll)
|
public static void Remove(App app, bool deleteAll)
|
||||||
{
|
{
|
||||||
string tmp = _pathTool.TempPath;
|
string tmp = PathTool.TempPath;
|
||||||
if (Directory.Exists(tmp))
|
if (Directory.Exists(tmp))
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.CreateDirectory(tmp);
|
Directory.CreateDirectory(tmp);
|
||||||
@ -57,7 +43,7 @@ namespace UpToolLib.v1.Tool
|
|||||||
}).WaitForExit();*/
|
}).WaitForExit();*/
|
||||||
int key = PlatformCheck.IsWindows ? 0 :
|
int key = PlatformCheck.IsWindows ? 0 :
|
||||||
File.Exists(Path.Combine(tmp, "Remove.sh")) ? 1 : 2;
|
File.Exists(Path.Combine(tmp, "Remove.sh")) ? 1 : 2;
|
||||||
ProcessStartInfo prc = new()
|
ProcessStartInfo prc = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = key switch
|
FileName = key switch
|
||||||
{
|
{
|
||||||
@ -92,7 +78,7 @@ namespace UpToolLib.v1.Tool
|
|||||||
Directory.Delete(app.AppPath, true);
|
Directory.Delete(app.AppPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckDirecory(string tmp, string app)
|
private static void CheckDirecory(string tmp, string app)
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.GetFiles(tmp))
|
foreach (string file in Directory.GetFiles(tmp))
|
||||||
{
|
{
|
||||||
@ -106,13 +92,12 @@ namespace UpToolLib.v1.Tool
|
|||||||
Directory.Delete(app);
|
Directory.Delete(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
public App[] FindApps(string identifier)
|
public static App[] FindApps(string identifier)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(identifier))
|
Dictionary<Guid, App> tmp = GlobalVariables.Apps;
|
||||||
return _apps.Values.ToArray();
|
IEnumerable<KeyValuePair<Guid, App>> tmp1 = tmp.Where(s => s.Key.ToString().StartsWith(identifier));
|
||||||
IEnumerable<KeyValuePair<Guid, App>> tmp1 = _apps.Where(s => s.Key.ToString().StartsWith(identifier));
|
tmp1 = tmp1.Concat(tmp.Where(s => s.Value.Name.Contains(identifier)));
|
||||||
tmp1 = tmp1.Concat(_apps.Where(s => s.Value.Name.Contains(identifier)));
|
tmp1 = tmp1.Concat(tmp.Where(s => s.Value.Description.Contains(identifier)));
|
||||||
tmp1 = tmp1.Concat(_apps.Where(s => s.Value.Description.Contains(identifier)));
|
|
||||||
return tmp1.Select(s => s.Value).ToArray();
|
return tmp1.Select(s => s.Value).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,27 +5,17 @@ using System.IO.Compression;
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolLib.v1.Tool
|
namespace UpToolLib.Tool
|
||||||
{
|
{
|
||||||
public class AppInstall
|
public static class AppInstall
|
||||||
{
|
{
|
||||||
private readonly IExternalFunctionality _platform;
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
|
|
||||||
internal AppInstall(IExternalFunctionality platform, PathTool pathTool)
|
|
||||||
{
|
|
||||||
_platform = platform;
|
|
||||||
_pathTool = pathTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Install an application
|
/// Install an application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appI">The app to install</param>
|
/// <param name="appI">The app to install</param>
|
||||||
/// <param name="force">Set to true to overwrite all old data</param>
|
/// <param name="force">Set to true to overwrite all old data</param>
|
||||||
public void Install(App appI, bool force)
|
public static void Install(App appI, bool force)
|
||||||
{
|
{
|
||||||
string app = "";
|
string app = "";
|
||||||
string tmp = "";
|
string tmp = "";
|
||||||
@ -34,7 +24,7 @@ namespace UpToolLib.v1.Tool
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
app = appI.AppPath;
|
app = appI.AppPath;
|
||||||
tmp = _pathTool.TempPath;
|
tmp = PathTool.TempPath;
|
||||||
if (Directory.Exists(tmp))
|
if (Directory.Exists(tmp))
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.CreateDirectory(tmp);
|
Directory.CreateDirectory(tmp);
|
||||||
@ -49,10 +39,10 @@ namespace UpToolLib.v1.Tool
|
|||||||
if (!Directory.Exists(app))
|
if (!Directory.Exists(app))
|
||||||
Directory.CreateDirectory(app);
|
Directory.CreateDirectory(app);
|
||||||
}
|
}
|
||||||
(bool dlSuccess, byte[] dlData) = _platform.Download(new Uri(appI.File));
|
(bool dlSuccess, byte[] dlData) = ExternalFunctionalityManager.Instance.Download(new Uri(appI.File));
|
||||||
if (!dlSuccess)
|
if (!dlSuccess)
|
||||||
throw new Exception("Download failed");
|
throw new Exception("Download failed");
|
||||||
using (SHA256CryptoServiceProvider sha256 = new())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dlData)).Replace("-", string.Empty)
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dlData)).Replace("-", string.Empty)
|
||||||
.ToUpper();
|
.ToUpper();
|
||||||
@ -81,7 +71,7 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InstallZip(string zipPath, App meta, bool force)
|
public static void InstallZip(string zipPath, App meta, bool force)
|
||||||
{
|
{
|
||||||
string app = "";
|
string app = "";
|
||||||
string tmp = "";
|
string tmp = "";
|
||||||
@ -89,7 +79,7 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
{
|
{
|
||||||
app = meta.AppPath;
|
app = meta.AppPath;
|
||||||
Directory.CreateDirectory(app);
|
Directory.CreateDirectory(app);
|
||||||
tmp = _pathTool.TempPath;
|
tmp = PathTool.TempPath;
|
||||||
if (Directory.Exists(tmp))
|
if (Directory.Exists(tmp))
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.CreateDirectory(tmp);
|
Directory.CreateDirectory(tmp);
|
||||||
@ -112,13 +102,13 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
//Use
|
//Use
|
||||||
//PowerShell -Command "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('Hello World')"
|
//PowerShell -Command "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('Hello World')"
|
||||||
//for message boxes
|
//for message boxes
|
||||||
private void CompleteInstall(App app, bool force) => CompleteInstall(app.AppPath, app.Name,
|
private static void CompleteInstall(App app, bool force) => CompleteInstall(app.AppPath, app.Name,
|
||||||
app.Description, app.Version, app.MainFile, force);
|
app.Description, app.Version, app.MainFile, force);
|
||||||
|
|
||||||
private void CompleteInstall(string appPath, string name, string description, Version version,
|
private static void CompleteInstall(string appPath, string name, string description, Version version,
|
||||||
string mainFile, bool force)
|
string mainFile, bool force)
|
||||||
{
|
{
|
||||||
string tmp = _pathTool.TempPath;
|
string tmp = PathTool.TempPath;
|
||||||
ZipFile.ExtractToDirectory(Path.Combine(appPath, "package.zip"), tmp);
|
ZipFile.ExtractToDirectory(Path.Combine(appPath, "package.zip"), tmp);
|
||||||
if (force)
|
if (force)
|
||||||
Directory.Move(Path.Combine(tmp, "Data"), Path.Combine(appPath, "app"));
|
Directory.Move(Path.Combine(tmp, "Data"), Path.Combine(appPath, "app"));
|
||||||
@ -127,7 +117,7 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
CopyAll(Path.Combine(tmp, "Data"), Path.Combine(appPath, "app"));
|
CopyAll(Path.Combine(tmp, "Data"), Path.Combine(appPath, "app"));
|
||||||
Directory.Delete(Path.Combine(tmp, "Data"), true);
|
Directory.Delete(Path.Combine(tmp, "Data"), true);
|
||||||
}
|
}
|
||||||
XElement el = new("app", new XElement("Name", name), new XElement("Description", description),
|
XElement el = new XElement("app", new XElement("Name", name), new XElement("Description", description),
|
||||||
new XElement("Version", version));
|
new XElement("Version", version));
|
||||||
if (mainFile != null)
|
if (mainFile != null)
|
||||||
el.Add(new XElement(new XElement("MainFile", mainFile)));
|
el.Add(new XElement(new XElement("MainFile", mainFile)));
|
||||||
@ -161,7 +151,7 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
}).WaitForExit();*/
|
}).WaitForExit();*/
|
||||||
int key = PlatformCheck.IsWindows ? 0 :
|
int key = PlatformCheck.IsWindows ? 0 :
|
||||||
File.Exists(Path.Combine(tmp, "Install.sh")) ? 1 : 2;
|
File.Exists(Path.Combine(tmp, "Install.sh")) ? 1 : 2;
|
||||||
ProcessStartInfo prc = new()
|
ProcessStartInfo prc = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = key switch
|
FileName = key switch
|
||||||
{
|
{
|
||||||
@ -185,7 +175,7 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
Process.Start(prc)?.WaitForExit();
|
Process.Start(prc)?.WaitForExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyAll(string source, string target)
|
private static void CopyAll(string source, string target)
|
||||||
{
|
{
|
||||||
if (string.Equals(Path.GetFullPath(source), Path.GetFullPath(target),
|
if (string.Equals(Path.GetFullPath(source), Path.GetFullPath(target),
|
||||||
StringComparison.CurrentCultureIgnoreCase))
|
StringComparison.CurrentCultureIgnoreCase))
|
25
UpToolLib/Tool/PathTool.cs
Normal file
25
UpToolLib/Tool/PathTool.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace UpToolLib.Tool
|
||||||
|
{
|
||||||
|
public static class PathTool
|
||||||
|
{
|
||||||
|
public static string Dir =>
|
||||||
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "UpTool2");
|
||||||
|
|
||||||
|
public static string TempPath => GetRelative("tmp");
|
||||||
|
public static string AppsPath => GetRelative("Apps");
|
||||||
|
public static string InfoXml => GetRelative("info.xml");
|
||||||
|
|
||||||
|
public static string GetRelative(params string[] segments) =>
|
||||||
|
Path.Combine(new[] {Dir}.Concat(segments).ToArray());
|
||||||
|
|
||||||
|
public static string GetAppPath(Guid app) => Path.Combine(AppsPath, app.ToString());
|
||||||
|
|
||||||
|
public static string GetDataPath(Guid app) => Path.Combine(GetAppPath(app), "app");
|
||||||
|
|
||||||
|
public static string GetInfoPath(Guid app) => Path.Combine(GetAppPath(app), "info.xml");
|
||||||
|
}
|
||||||
|
}
|
@ -5,93 +5,41 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
using UpToolLib.v1;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2
|
namespace UpToolLib.Tool
|
||||||
{
|
{
|
||||||
public class RepoManagement
|
public static class RepoManagement
|
||||||
{
|
{
|
||||||
private readonly IExternalFunctionality _platform;
|
public static void FetchRepos()
|
||||||
private readonly XmlTool _xmlTool;
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
private readonly AppFactory _appFactory;
|
|
||||||
private readonly IDictionary<Guid, App> _apps;
|
|
||||||
|
|
||||||
public RepoManagement(IExternalFunctionality platform, XmlTool xmlTool, PathTool pathTool, AppFactory appFactory, IDictionary<Guid, App> apps)
|
|
||||||
{
|
{
|
||||||
_platform = platform;
|
XmlTool.FixXml();
|
||||||
_xmlTool = xmlTool;
|
XElement meta = XDocument.Load(PathTool.InfoXml).Element("meta");
|
||||||
_pathTool = pathTool;
|
List<XElement> tmpAppsList = new List<XElement>();
|
||||||
_appFactory = appFactory;
|
|
||||||
_apps = apps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Save(IEnumerable<Repo> repos)
|
|
||||||
{
|
|
||||||
XDocument doc = XDocument.Load(_pathTool.InfoXml);
|
|
||||||
XElement reposEl = doc.Element("meta").Element("Repos");
|
|
||||||
reposEl.RemoveNodes();
|
|
||||||
foreach (Repo repo in repos)
|
|
||||||
reposEl.Add(new XElement("Repo", new XElement("Name", repo.Name), new XElement("Link", repo.Url)));
|
|
||||||
doc.Save(_pathTool.InfoXml);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Repo> GetRepos()
|
|
||||||
{
|
|
||||||
_xmlTool.FixXml();
|
|
||||||
XDocument doc = XDocument.Load(_pathTool.InfoXml);
|
|
||||||
XElement reposEl = doc.Element("meta").Element("Repos");
|
|
||||||
List<Repo> repos = new();
|
|
||||||
foreach (XElement repo in reposEl.Elements("Repo"))
|
|
||||||
{
|
|
||||||
repos.Add(new Repo
|
|
||||||
{
|
|
||||||
Name = repo.Element("Name").Value,
|
|
||||||
Url = repo.Element("Link").Value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return repos.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FetchRepos()
|
|
||||||
{
|
|
||||||
_xmlTool.FixXml();
|
|
||||||
XElement meta = XDocument.Load(_pathTool.InfoXml).Element("meta");
|
|
||||||
List<XElement> tmpAppsList = new();
|
|
||||||
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct()
|
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < repArr.Count)
|
while (i < repArr.Count)
|
||||||
{
|
{
|
||||||
string status = "Initializing";
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
_platform.Log($"[{i + 1}] Loading {repArr[i]}");
|
ExternalFunctionalityManager.Instance.Log($"[{i + 1}] Loading {repArr[i]}");
|
||||||
status = $"Loading {repArr[i]}";
|
XDocument repo = XDocument.Load(new Uri(repArr[i]).TryUnshorten().AbsoluteUri);
|
||||||
XDocument repo = XDocument.Load(new Uri(repArr[i]).AbsoluteUri);
|
|
||||||
status = $"Extracting repolinks";
|
|
||||||
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
|
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
|
||||||
.Where(s => !repArr.Contains(s)));
|
.Where(s => !repArr.Contains(s)));
|
||||||
status = $"Extracting apps";
|
|
||||||
XElement[] tmpApparray = repo.Element("repo").Elements("app").Where(app =>
|
XElement[] tmpApparray = repo.Element("repo").Elements("app").Where(app =>
|
||||||
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
|
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
|
||||||
!tmpAppsList
|
!tmpAppsList
|
||||||
.Where(a => a.Element("ID").Value == app.Element("ID").Value).Any(a =>
|
.Where(a => a.Element("ID").Value == app.Element("ID").Value).Any(a =>
|
||||||
GetVer(a.Element("Version")) >= GetVer(app.Element("Version")))).ToArray()
|
GetVer(a.Element("Version")) >= app.Element("Version").GetVer())).ToArray()
|
||||||
.Concat(repo.Element("repo").Elements("applink")
|
.Concat(repo.Element("repo").Elements("applink")
|
||||||
.Select(s =>
|
.Select(s =>
|
||||||
{
|
{
|
||||||
_platform.Log($"- Loading {s.Value}");
|
ExternalFunctionalityManager.Instance.Log($"- Loading {s.Value}");
|
||||||
status = $"Fetching app data tag: {s.Value}";
|
return XDocument.Load(new Uri(s.Value).TryUnshorten().AbsoluteUri).Element("app");
|
||||||
XElement ret = XDocument.Load(new Uri(s.Value).AbsoluteUri)
|
|
||||||
.Element("app");
|
|
||||||
return ret;
|
|
||||||
}))
|
}))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
status = $"Creating app cache";
|
|
||||||
foreach (XElement app in tmpApparray)
|
foreach (XElement app in tmpApparray)
|
||||||
{
|
{
|
||||||
//"Sanity check"
|
//"Sanity check"
|
||||||
@ -103,7 +51,7 @@ namespace UpToolLib.v2
|
|||||||
new XElement("Description", app.Element("Description").Value),
|
new XElement("Description", app.Element("Description").Value),
|
||||||
new XElement("Version", app.Element("Version").Value),
|
new XElement("Version", app.Element("Version").Value),
|
||||||
new XElement("ID", app.Element("ID").Value),
|
new XElement("ID", app.Element("ID").Value),
|
||||||
new XElement("File", new Uri(app.Element("File").Value).ToString()),
|
new XElement("File", app.Element("File").Value),
|
||||||
new XElement("Hash", app.Element("Hash").Value)
|
new XElement("Hash", app.Element("Hash").Value)
|
||||||
));
|
));
|
||||||
if (app.Element("MainFile") != null)
|
if (app.Element("MainFile") != null)
|
||||||
@ -113,7 +61,8 @@ namespace UpToolLib.v2
|
|||||||
{
|
{
|
||||||
tmpAppsList.Last()
|
tmpAppsList.Last()
|
||||||
.Add(new XElement("Icon",
|
.Add(new XElement("Icon",
|
||||||
_platform.FetchImageB64(new Uri(app.Element("Icon").Value))));
|
ExternalFunctionalityManager.Instance.FetchImageB64(
|
||||||
|
new Uri(app.Element("Icon").Value).TryUnshorten())));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -121,9 +70,9 @@ namespace UpToolLib.v2
|
|||||||
}
|
}
|
||||||
tmpAppsList.Last().Add(new XElement("Platform",
|
tmpAppsList.Last().Add(new XElement("Platform",
|
||||||
app.Element("Platform") == null ||
|
app.Element("Platform") == null ||
|
||||||
!new[] {PlatformCheck.Posix, PlatformCheck.Windows}.Contains(app.Element("Platform")
|
!new[] {GlobalVariables.Posix, GlobalVariables.Windows}.Contains(app.Element("Platform")
|
||||||
.Value)
|
.Value)
|
||||||
? PlatformCheck.CurrentPlatform
|
? GlobalVariables.CurrentPlatform
|
||||||
: app.Element("Platform").Value));
|
: app.Element("Platform").Value));
|
||||||
XElement app1 = app;
|
XElement app1 = app;
|
||||||
if (tmpAppsList.Count(a => a.Element("ID").Value == app1.Element("ID").Value) > 1)
|
if (tmpAppsList.Count(a => a.Element("ID").Value == app1.Element("ID").Value) > 1)
|
||||||
@ -135,8 +84,8 @@ namespace UpToolLib.v2
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_platform.OkDialog(
|
ExternalFunctionalityManager.Instance.OkDialog(
|
||||||
$"Failed to load repo: {repArr[i]}{Environment.NewLine}Last status was: {status}{Environment.NewLine}{e}");
|
$"Failed to load repo: {repArr[i]}{Environment.NewLine}{e}");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
i++;
|
i++;
|
||||||
@ -148,29 +97,29 @@ namespace UpToolLib.v2
|
|||||||
XElement repos = meta.Element("LocalRepo");
|
XElement repos = meta.Element("LocalRepo");
|
||||||
repos.RemoveNodes();
|
repos.RemoveNodes();
|
||||||
tmpAppsList.ForEach(app => repos.Add(app));
|
tmpAppsList.ForEach(app => repos.Add(app));
|
||||||
meta.Save(_pathTool.InfoXml);
|
meta.Save(PathTool.InfoXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Version GetVer(XElement el) =>
|
private static Version GetVer(this XElement el) =>
|
||||||
int.TryParse(el.Value, out int i) ? new Version(0, 0, 0, i) : Version.Parse(el.Value);
|
int.TryParse(el.Value, out int i) ? new Version(0, 0, 0, i) : Version.Parse(el.Value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load the repository cache
|
/// Load the repository cache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="errorHandler">Function to call on an exception, will ask the user whether he wants to quit</param>
|
/// <param name="errorHandler">Function to call on an exception, will ask the user whether he wants to quit</param>
|
||||||
public void GetReposFromDisk()
|
public static void GetReposFromDisk()
|
||||||
{
|
{
|
||||||
_apps.Clear();
|
GlobalVariables.Apps.Clear();
|
||||||
string xml = _pathTool.InfoXml;
|
string xml = PathTool.InfoXml;
|
||||||
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
|
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
|
||||||
{
|
{
|
||||||
if (app.Element("Platform").Value != PlatformCheck.CurrentPlatform) return;
|
if (app.Element("Platform").Value != GlobalVariables.CurrentPlatform) return;
|
||||||
Guid id = Guid.Parse(app.Element("ID").Value);
|
Guid id = Guid.Parse(app.Element("ID").Value);
|
||||||
string locInPath = _pathTool.GetInfoPath(id);
|
string locInPath = PathTool.GetInfoPath(id);
|
||||||
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
||||||
if (int.TryParse(app.Element("Version").Value, out _))
|
if (int.TryParse(app.Element("Version").Value, out _))
|
||||||
app.Element("Version").Value = UpToolLibV1.MinimumVer.ToString();
|
app.Element("Version").Value = GlobalVariables.MinimumVer.ToString();
|
||||||
_apps.Add(id, _appFactory.CreateApp(
|
GlobalVariables.Apps.Add(id, new App(
|
||||||
locIn.Element("Name").Value,
|
locIn.Element("Name").Value,
|
||||||
locIn.Element("Description").Value,
|
locIn.Element("Description").Value,
|
||||||
Version.Parse(app.Element("Version").Value),
|
Version.Parse(app.Element("Version").Value),
|
||||||
@ -180,38 +129,38 @@ namespace UpToolLib.v2
|
|||||||
id,
|
id,
|
||||||
Color.White,
|
Color.White,
|
||||||
app.Element("Icon") == null
|
app.Element("Icon") == null
|
||||||
? _platform.GetDefaultIcon()
|
? ExternalFunctionalityManager.Instance.GetDefaultIcon()
|
||||||
: _platform.ImageFromB64(app.Element("Icon").Value),
|
: ExternalFunctionalityManager.Instance.ImageFromB64(app.Element("Icon").Value),
|
||||||
locIn.Element("MainFile") != null || app.Element("MainFile") != null,
|
locIn.Element("MainFile") != null || app.Element("MainFile") != null,
|
||||||
locIn.Element("MainFile") == null
|
locIn.Element("MainFile") == null
|
||||||
? app.Element("MainFile") == null ? "" : app.Element("MainFile").Value
|
? app.Element("MainFile") == null ? "" : app.Element("MainFile").Value
|
||||||
: locIn.Element("MainFile").Value
|
: locIn.Element("MainFile").Value
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
Directory.GetDirectories(_pathTool.AppsPath)
|
Directory.GetDirectories(PathTool.AppsPath)
|
||||||
.Where(s => Guid.TryParse(Path.GetFileName(s), out Guid guid) &&
|
.Where(s => Guid.TryParse(Path.GetFileName(s), out Guid guid) &&
|
||||||
!_apps.ContainsKey(guid)).ToList().ForEach(s =>
|
!GlobalVariables.Apps.ContainsKey(guid)).ToList().ForEach(s =>
|
||||||
{
|
{
|
||||||
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XElement data = XDocument.Load(_pathTool.GetInfoPath(tmp)).Element("app");
|
XElement data = XDocument.Load(PathTool.GetInfoPath(tmp)).Element("app");
|
||||||
_apps.Add(tmp,
|
GlobalVariables.Apps.Add(tmp,
|
||||||
_appFactory.CreateApp($"(local) {data.Element("Name").Value}", data.Element("Description").Value,
|
new App($"(local) {data.Element("Name").Value}", data.Element("Description").Value,
|
||||||
UpToolLibV1.MinimumVer, "", true, "", tmp, Color.Red,
|
GlobalVariables.MinimumVer, "", true, "", tmp, Color.Red,
|
||||||
_platform.GetDefaultIcon(),
|
ExternalFunctionalityManager.Instance.GetDefaultIcon(),
|
||||||
data.Element("MainFile") != null,
|
data.Element("MainFile") != null,
|
||||||
data.Element("MainFile") == null ? "" : data.Element("MainFile").Value));
|
data.Element("MainFile") == null ? "" : data.Element("MainFile").Value));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (_platform.YesNoDialog(
|
if (ExternalFunctionalityManager.Instance.YesNoDialog(
|
||||||
$@"An error occured while loading this local repo:
|
$@"An error occured while loading this local repo:
|
||||||
{e.Message}
|
{e.Message}
|
||||||
Do you want to exit? Otherwise the folder will be deleted, possibly causeing problems later.", false))
|
Do you want to exit? Otherwise the folder will be deleted, possibly causeing problems later.", false))
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
else
|
else
|
||||||
Directory.Delete(_pathTool.GetAppPath(tmp), true);
|
Directory.Delete(PathTool.GetAppPath(tmp), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
20
UpToolLib/Tool/TryUnshorten.cs
Normal file
20
UpToolLib/Tool/TryUnshorten.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using CC_Functions.Misc;
|
||||||
|
|
||||||
|
namespace UpToolLib.Tool
|
||||||
|
{
|
||||||
|
public static class TryUnshortenExt
|
||||||
|
{
|
||||||
|
public static Uri TryUnshorten(this Uri self)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return self.Unshorten();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
UpToolLib/Tool/XmlTool.cs
Normal file
49
UpToolLib/Tool/XmlTool.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace UpToolLib.Tool
|
||||||
|
{
|
||||||
|
public static class XmlTool
|
||||||
|
{
|
||||||
|
public static void FixXml()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(PathTool.AppsPath))
|
||||||
|
Directory.CreateDirectory(PathTool.AppsPath);
|
||||||
|
if (!File.Exists(PathTool.InfoXml) || XDocument.Load(PathTool.InfoXml).Element("meta") == null)
|
||||||
|
new XElement("meta").Save(PathTool.InfoXml);
|
||||||
|
XDocument x = XDocument.Load(PathTool.InfoXml);
|
||||||
|
XElement meta = x.Element("meta");
|
||||||
|
if (meta.Element("UpdateSource") == null)
|
||||||
|
meta.Add(new XElement("UpdateSource"));
|
||||||
|
if (new[]
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
"https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
|
||||||
|
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml",
|
||||||
|
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml"
|
||||||
|
}
|
||||||
|
.Contains(meta.Element("UpdateSource").Value))
|
||||||
|
meta.Element("UpdateSource").Value =
|
||||||
|
"https://github.com/JFronny/UpTool2/releases/latest/download/meta.xml";
|
||||||
|
if (meta.Element("Repos") == null)
|
||||||
|
meta.Add(new XElement("Repos"));
|
||||||
|
if (meta.Element("Repos").Elements("Repo").Count() == 0)
|
||||||
|
meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"),
|
||||||
|
new XElement("Link",
|
||||||
|
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml")));
|
||||||
|
meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link"))
|
||||||
|
.Where(s => new[]
|
||||||
|
{
|
||||||
|
null, "https://github.com/JFronny/UpTool2/releases/download/Repo/Repo.xml",
|
||||||
|
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Repo.xml"
|
||||||
|
}.Contains(s.Value))
|
||||||
|
.ToList().ForEach(s =>
|
||||||
|
s.Value =
|
||||||
|
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml");
|
||||||
|
if (meta.Element("LocalRepo") == null)
|
||||||
|
meta.Add(new XElement("LocalRepo"));
|
||||||
|
x.Save(PathTool.InfoXml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
<AssemblyVersion>1.0.*</AssemblyVersion>
|
<AssemblyVersion>1.0.*</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="C_64.ico" />
|
<PackageReference Include="CC-Functions.Misc" Version="1.1.7468.32091" />
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="C_64.ico" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolLib
|
|
||||||
{
|
|
||||||
public class UpToolLibMain : IDisposable
|
|
||||||
{
|
|
||||||
private static Mutex _mutex;
|
|
||||||
public UpToolLibMain(IExternalFunctionality platform)
|
|
||||||
{
|
|
||||||
V1 = new UpToolLibV1(platform);
|
|
||||||
V2 = new UpToolLibV2(platform, V1.Installer, V1.AppExtras, V1.PathTool, V1.XmlTool, V1.Apps);
|
|
||||||
_mutex = new Mutex(false,
|
|
||||||
"Global\\{c0c1e002-9e13-4e8f-a035-dbdc5128e00e}",
|
|
||||||
out bool _);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_mutex.WaitOne(5000, false))
|
|
||||||
return;
|
|
||||||
throw new MutexLockLockedException();
|
|
||||||
}
|
|
||||||
catch (AbandonedMutexException)
|
|
||||||
{
|
|
||||||
#if DEBUG
|
|
||||||
_platform.Log("Mutex abandoned");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly UpToolLibV1 V1;
|
|
||||||
public readonly UpToolLibV2 V2;
|
|
||||||
public void Dispose() => _mutex.ReleaseMutex();
|
|
||||||
~UpToolLibMain() => Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
32
UpToolLib/UpdateCheck.cs
Normal file
32
UpToolLib/UpdateCheck.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using UpToolLib.Tool;
|
||||||
|
|
||||||
|
namespace UpToolLib
|
||||||
|
{
|
||||||
|
public static class UpdateCheck
|
||||||
|
{
|
||||||
|
private static XElement _meta;
|
||||||
|
|
||||||
|
private static XElement Meta
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_meta is null) Reload();
|
||||||
|
return _meta;
|
||||||
|
}
|
||||||
|
set => _meta = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Version OnlineVersion => Version.Parse(Meta.Element("Version").Value);
|
||||||
|
public static Uri Installer => new Uri(Meta.Element("Installer").Value).TryUnshorten();
|
||||||
|
public static string InstallerHash => Meta.Element("InstallerHash").Value.ToUpper();
|
||||||
|
public static Uri App => new Uri(Meta.Element("File").Value).TryUnshorten();
|
||||||
|
public static string AppHash => Meta.Element("Hash").Value.ToUpper();
|
||||||
|
|
||||||
|
public static void Reload() =>
|
||||||
|
Reload(XDocument.Load(PathTool.InfoXml).Element("meta").Element("UpdateSource").Value);
|
||||||
|
|
||||||
|
public static void Reload(string source) => Meta = XDocument.Load(source).Element("meta");
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace UpToolLib.v1.Tool
|
|
||||||
{
|
|
||||||
public class PathTool
|
|
||||||
{
|
|
||||||
public string Dir =>
|
|
||||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "UpTool2");
|
|
||||||
|
|
||||||
public string TempPath => GetRelative("tmp");
|
|
||||||
public string AppsPath => GetRelative("Apps");
|
|
||||||
public string InfoXml => GetRelative("info.xml");
|
|
||||||
|
|
||||||
public string GetRelative(params string[] segments) =>
|
|
||||||
Path.Combine(new[] {Dir}.Concat(segments).ToArray());
|
|
||||||
|
|
||||||
public string GetAppPath(Guid app) => Path.Combine(AppsPath, app.ToString());
|
|
||||||
|
|
||||||
public string GetDataPath(Guid app) => Path.Combine(GetAppPath(app), "app");
|
|
||||||
|
|
||||||
public string GetInfoPath(Guid app) => Path.Combine(GetAppPath(app), "info.xml");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
|
|
||||||
namespace UpToolLib.v1.Tool
|
|
||||||
{
|
|
||||||
public class XmlTool
|
|
||||||
{
|
|
||||||
private readonly IExternalFunctionality _platform;
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
|
|
||||||
internal XmlTool(IExternalFunctionality platform, PathTool pathTool)
|
|
||||||
{
|
|
||||||
_platform = platform;
|
|
||||||
_pathTool = pathTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FixXml()
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(_pathTool.AppsPath))
|
|
||||||
Directory.CreateDirectory(_pathTool.AppsPath);
|
|
||||||
if (!File.Exists(_pathTool.InfoXml) || XDocument.Load(_pathTool.InfoXml).Element("meta") == null)
|
|
||||||
new XElement("meta").Save(_pathTool.InfoXml);
|
|
||||||
XDocument x = XDocument.Load(_pathTool.InfoXml);
|
|
||||||
XElement meta = x.Element("meta");
|
|
||||||
if (meta.Element("UpdateSource") == null)
|
|
||||||
meta.Add(new XElement("UpdateSource"));
|
|
||||||
if (new[]
|
|
||||||
{
|
|
||||||
"",
|
|
||||||
"https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
|
|
||||||
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml",
|
|
||||||
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml",
|
|
||||||
"https://github.com/JFronny/UpTool2/releases/latest/download/meta.xml",
|
|
||||||
"https://gitlab.com/JFronny/UpTool2/-/jobs/artifacts/master/raw/meta.xml?job=uptool"
|
|
||||||
}
|
|
||||||
.Contains(meta.Element("UpdateSource").Value))
|
|
||||||
meta.Element("UpdateSource").Value =
|
|
||||||
"https://gitlab.com/uptool/UpTool2/-/jobs/artifacts/master/raw/meta.xml?job=uptool";
|
|
||||||
if (meta.Element("Repos") == null)
|
|
||||||
meta.Add(new XElement("Repos"));
|
|
||||||
if (meta.Element("Repos").Elements("Repo").Count() == 0)
|
|
||||||
{
|
|
||||||
if (_platform.YesNoDialog(
|
|
||||||
"No active repository was detected. Add the default repo?", false))
|
|
||||||
{
|
|
||||||
meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"),
|
|
||||||
new XElement("Link",
|
|
||||||
"https://gitlab.com/uptool/UpTool2/-/snippets/1988600/raw/master/Repo.xml")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link"))
|
|
||||||
.Where(s => new[]
|
|
||||||
{
|
|
||||||
null, "https://github.com/JFronny/UpTool2/releases/download/Repo/Repo.xml",
|
|
||||||
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Repo.xml",
|
|
||||||
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml",
|
|
||||||
"https://gitlab.com/JFronny/UpTool2/snippets/1988600/raw"
|
|
||||||
}.Contains(s.Value))
|
|
||||||
.ToList().ForEach(s =>
|
|
||||||
s.Value =
|
|
||||||
"https://gitlab.com/uptool/UpTool2/-/snippets/1988600/raw/master/Repo.xml");
|
|
||||||
if (meta.Element("LocalRepo") == null)
|
|
||||||
meta.Add(new XElement("LocalRepo"));
|
|
||||||
x.Save(_pathTool.InfoXml);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using UpToolLib.v2;
|
|
||||||
|
|
||||||
namespace UpToolLib.v1
|
|
||||||
{
|
|
||||||
public class UpToolLibV1
|
|
||||||
{
|
|
||||||
internal UpToolLibV1(IExternalFunctionality platform)
|
|
||||||
{
|
|
||||||
PathTool = new PathTool();
|
|
||||||
XmlTool = new XmlTool(platform, PathTool);
|
|
||||||
Installer = new AppInstall(platform, PathTool);
|
|
||||||
AppExtras = new AppExtras(Installer, PathTool, Apps);
|
|
||||||
}
|
|
||||||
public readonly AppExtras AppExtras;
|
|
||||||
public readonly AppInstall Installer;
|
|
||||||
public readonly PathTool PathTool;
|
|
||||||
public readonly XmlTool XmlTool;
|
|
||||||
|
|
||||||
public readonly IDictionary<Guid, App> Apps = new Dictionary<Guid, App>();
|
|
||||||
public static Version MinimumVer => Version.Parse("0.0.0.0");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2
|
|
||||||
{
|
|
||||||
public class AppFactory
|
|
||||||
{
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
|
|
||||||
internal AppFactory(PathTool pathTool) => _pathTool = pathTool;
|
|
||||||
|
|
||||||
public App CreateApp(string name, string description, Version version, string file, bool local, string hash,
|
|
||||||
Guid iD, Color color, object icon, bool runnable, string mainFile) =>
|
|
||||||
new(name, description, version, file, local, hash, iD, color, icon, runnable, mainFile, _pathTool);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using UpToolLib.DataStructures;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
|
||||||
{
|
|
||||||
public abstract class AppTask
|
|
||||||
{
|
|
||||||
public abstract void Run();
|
|
||||||
|
|
||||||
public AppTask(IExternalFunctionality platform) => Platform = platform;
|
|
||||||
|
|
||||||
protected IExternalFunctionality Platform { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
|
||||||
{
|
|
||||||
public class TaskFactory
|
|
||||||
{
|
|
||||||
private IExternalFunctionality _platform;
|
|
||||||
private readonly AppInstall _installer;
|
|
||||||
private readonly AppExtras _extras;
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
private readonly AppFactory _appFactory;
|
|
||||||
private readonly IDictionary<Guid, App> _apps;
|
|
||||||
|
|
||||||
internal TaskFactory(IExternalFunctionality platform, AppInstall installer, AppExtras extras, PathTool pathTool, AppFactory appFactory, IDictionary<Guid, App> apps)
|
|
||||||
{
|
|
||||||
_platform = platform;
|
|
||||||
_installer = installer;
|
|
||||||
_extras = extras;
|
|
||||||
_pathTool = pathTool;
|
|
||||||
_appFactory = appFactory;
|
|
||||||
_apps = apps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KnownAppTask CreateInstall(App app, Action? postInstall = null) => new InstallTask(_platform, _installer, app, postInstall);
|
|
||||||
|
|
||||||
public KnownAppTask CreateRemove(App app, Action? postInstall = null) => new RemoveTask(_platform, _extras, app, postInstall);
|
|
||||||
|
|
||||||
public KnownAppTask CreateUpdate(App app, Action? postInstall = null) => new UpdateTask(_platform, _extras, app, postInstall);
|
|
||||||
|
|
||||||
public AppTask CreateUpload(string zipFile, string name, Action? postInstall = null) => new UploadTask(_platform, _installer, _appFactory, _pathTool, _apps, zipFile, name, postInstall);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2.TaskQueue
|
|
||||||
{
|
|
||||||
public class UploadTask : AppTask
|
|
||||||
{
|
|
||||||
private readonly string _name;
|
|
||||||
private readonly Action? _postInstall;
|
|
||||||
private readonly AppInstall _installer;
|
|
||||||
private readonly AppFactory _appFactory;
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
private readonly IDictionary<Guid, App> _apps;
|
|
||||||
public readonly string ZipFile;
|
|
||||||
|
|
||||||
internal UploadTask(IExternalFunctionality platform, AppInstall installer, AppFactory appFactory, PathTool pathTool, IDictionary<Guid, App> apps, string zipFile, string name, Action? postInstall) : base(platform)
|
|
||||||
{
|
|
||||||
_installer = installer;
|
|
||||||
_appFactory = appFactory;
|
|
||||||
_pathTool = pathTool;
|
|
||||||
_apps = apps;
|
|
||||||
ZipFile = zipFile;
|
|
||||||
_name = name;
|
|
||||||
_postInstall = postInstall;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Run()
|
|
||||||
{
|
|
||||||
#if !DEBUG
|
|
||||||
try
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
Guid id = Guid.NewGuid();
|
|
||||||
while (_apps.ContainsKey(id) || Directory.Exists(_pathTool.GetAppPath(id)))
|
|
||||||
id = Guid.NewGuid();
|
|
||||||
App appI = _appFactory.CreateApp(_name, "Locally installed package, removal only",
|
|
||||||
UpToolLibV1.MinimumVer, "", true, "", id, Color.Red, Platform.GetDefaultIcon(), false, "");
|
|
||||||
_installer.InstallZip(ZipFile, appI, true);
|
|
||||||
_postInstall?.Invoke();
|
|
||||||
#if !DEBUG
|
|
||||||
}
|
|
||||||
catch (Exception e1)
|
|
||||||
{
|
|
||||||
Platform.OkDialog("Upload failed.\r\nException=" + e1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString() => $"Install local {Path.GetFileName(ZipFile)}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UpToolLib.DataStructures;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
using UpToolLib.v2.TaskQueue;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2
|
|
||||||
{
|
|
||||||
public class UpToolLibV2
|
|
||||||
{
|
|
||||||
internal UpToolLibV2(IExternalFunctionality platform, AppInstall install, AppExtras extras, PathTool pathTool, XmlTool xmlTool, IDictionary<Guid, App> apps)
|
|
||||||
{
|
|
||||||
AppFactory = new AppFactory(pathTool);
|
|
||||||
UpdateChecker = new UpdateChecker(pathTool);
|
|
||||||
TaskFactory = new TaskFactory(platform, install, extras, pathTool, AppFactory, apps);
|
|
||||||
RepoManagement = new RepoManagement(platform, xmlTool, pathTool, AppFactory, apps);
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly UpdateChecker UpdateChecker;
|
|
||||||
public readonly TaskFactory TaskFactory;
|
|
||||||
public readonly AppFactory AppFactory;
|
|
||||||
public readonly RepoManagement RepoManagement;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2
|
|
||||||
{
|
|
||||||
public class UpdateCheck
|
|
||||||
{
|
|
||||||
public readonly Version OnlineVersion;
|
|
||||||
public readonly Uri Installer;
|
|
||||||
public readonly string InstallerHash;
|
|
||||||
public readonly Uri App;
|
|
||||||
public readonly string AppHash;
|
|
||||||
|
|
||||||
public UpdateCheck(XElement meta)
|
|
||||||
{
|
|
||||||
OnlineVersion = Version.Parse(meta.Element("Version").Value);
|
|
||||||
Installer = new Uri(meta.Element("Installer").Value);
|
|
||||||
InstallerHash = meta.Element("InstallerHash").Value.ToUpper();
|
|
||||||
App = new Uri(meta.Element("File").Value);
|
|
||||||
AppHash = meta.Element("Hash").Value.ToUpper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System.Xml.Linq;
|
|
||||||
using UpToolLib.v1.Tool;
|
|
||||||
|
|
||||||
namespace UpToolLib.v2
|
|
||||||
{
|
|
||||||
public class UpdateChecker
|
|
||||||
{
|
|
||||||
private readonly PathTool _pathTool;
|
|
||||||
public UpdateCheck Check() => Check(XDocument.Load(_pathTool.InfoXml).Element("meta").Element("UpdateSource").Value);
|
|
||||||
public UpdateCheck Check(string source) => new(XDocument.Load(source).Element("meta"));
|
|
||||||
internal UpdateChecker(PathTool pathTool) => _pathTool = pathTool;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"config:base"
|
|
||||||
],
|
|
||||||
"hostRules": [
|
|
||||||
{
|
|
||||||
"domainName": "github.com",
|
|
||||||
"encrypted": {
|
|
||||||
"token": "o53wjvsApqgx2krTKwD5LBnbmtK7gZ4zgAYsFIxLxf3blIMY2y9tUpsVNo4thY/kTA1tDOvIiP9PNdJV/DRYqvMDQMxvKiGHE1eSrpmrICRaq4Bhdc9/QZotkliqcziynLV0vD+xXZ7tyXKhR+nZijp4K1H2euCAv8vCVAUrpXIlBf/gmHvfEjmTDKUqJTEAvzre7H7l3C7SmQ2VwyE6gEFD91K9jGbgfI6MIgjx3i3O4fxM/JLXmUR19mGVK//Hpc1GXyVePB1sdzYhsyMU/3hzR3d/lJLOrHhr40WO1vNf3aB0WVDqqsl+XwoFxBxFqhSPTVHkEsylD+l+d8fsXA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Reference in New Issue
Block a user