Better logging for debugging, partially reworked interface for UpToolCLI

This commit is contained in:
JFronny 2020-08-31 18:58:15 +02:00
parent 73669e16ea
commit c5de2e6886
9 changed files with 42 additions and 199 deletions

View File

@ -1,145 +0,0 @@
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

View File

@ -2,9 +2,6 @@
tags:
- windows
before_script:
- dotnet restore
uptool:
extends:
- .shared_windows_runners

View File

@ -8,9 +8,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9841227C-3F1B-4C32-8123-3DB2CF4E15EE}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.github\workflows\main.yml = .github\workflows\main.yml
README.md = README.md
CLI.md = CLI.md
.gitlab-ci.yml = .gitlab-ci.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UpTool build tool", "UpTool build tool\UpTool build tool.csproj", "{AAB8D6BA-3A43-4DC4-95EE-6757482B77FD}"

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
using UpTool2.Task;
using UpToolLib;
@ -30,7 +31,10 @@ namespace UpTool2
HelpRequested += _help;
filterBox.DataSource = Enum.GetValues(typeof(Status));
if (Program.Online)
{
Program.SetSplash(8, "Fetching repositories");
RepoManagement.FetchRepos();
}
else
{
MessageBox.Show("Starting in offline mode!");
@ -38,7 +42,7 @@ namespace UpTool2
filterBox.Enabled = false;
filterBox.SelectedIndex = 2;
}
Program.SetSplash(8, "Reloading data");
Program.SetSplash(9, "Reloading data");
ReloadElements();
if (!Directory.Exists(PathTool.AppsPath))
Directory.CreateDirectory(PathTool.AppsPath);
@ -190,8 +194,19 @@ namespace UpTool2
private void Controls_reload_Click(object sender, EventArgs e)
{
RepoManagement.FetchRepos();
ReloadElements();
Enabled = false;
if (MessageBox.Show("This may take a few minutes. Are you sure?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
new Thread(() =>
{
RepoManagement.FetchRepos();
Invoke((Action) (() =>
{
ReloadElements();
Enabled = true;
}));
}).Start();
}
}
private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().ShowDialog();

View File

@ -21,20 +21,14 @@ namespace UpToolCLI
Command search = new Command("search", "Search for packages")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
}
new Argument<string>("identifier", "Something to identify the app")
};
search.Handler = CommandHandler.Create<string>(Search);
rootCommand.AddCommand(search);
Command show = new Command("show", "Shows package info")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
}
new Argument<string>("identifier", "Something to identify the app")
};
show.Handler = CommandHandler.Create<string>(Show);
rootCommand.AddCommand(show);

View File

@ -27,10 +27,7 @@ namespace UpToolCLI
Command start = new Command("start", "Starts an app")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
},
new Argument<string>("identifier", "Something to identify the app"),
new Option<string>(new[] {"--waitForExit", "-wait"}, "Waits until the program quits")
};
start.Handler = CommandHandler.Create<string, bool>(Start);

View File

@ -18,10 +18,7 @@ namespace UpToolCLI
{
Command install = new Command("install", "Install a package")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app or the file name")
{
Required = true
},
new Argument<string>("identifier", "Something to identify the app or the file name"),
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
};
install.Handler = CommandHandler.Create<string, bool>(Install);
@ -29,10 +26,7 @@ namespace UpToolCLI
Command upgrade = new Command("upgrade", "Upgrade a package")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
},
new Argument<string>("identifier", "Something to identify the app"),
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
};
upgrade.Handler = CommandHandler.Create<string, bool>(Upgrade);
@ -40,10 +34,7 @@ namespace UpToolCLI
Command reinstall = new Command("reinstall", "Reinstall a package")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
},
new Argument<string>("identifier", "Something to identify the app"),
new Option<bool>(new[] {"--force", "-f"}, "Overwrites older files")
};
reinstall.Handler = CommandHandler.Create<string, bool>(Reinstall);
@ -51,20 +42,14 @@ namespace UpToolCLI
Command remove = new Command("remove", "Remove a package")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
}
new Argument<string>("identifier", "Something to identify the app")
};
remove.Handler = CommandHandler.Create<string>(Remove);
rootCommand.AddCommand(remove);
Command purge = new Command("purge", "Completely remove a package")
{
new Option<string>(new[] {"--identifier", "-i"}, "Something to identify the app")
{
Required = true
}
new Argument<string>("identifier", "Something to identify the app")
};
purge.Handler = CommandHandler.Create<string>(Purge);
rootCommand.AddCommand(purge);

View File

@ -18,24 +18,15 @@ namespace UpToolCLI
Command addRepo = new Command("add-repo", "Adds a repository")
{
new Option<string>(new[] {"--name", "-n"}, "The new repositories name")
{
Required = true
},
new Option<string>(new[] {"--link", "-l"}, "A link to the repositories XML")
{
Required = true
}
new Argument<string>("name", "The new repositories name"),
new Argument<string>("link", "A link to the repositories XML")
};
addRepo.Handler = CommandHandler.Create<string, string>(AddRepo);
rootCommand.AddCommand(addRepo);
Command removeRepo = new Command("remove-repo", "Removes a repository")
{
new Option<string>(new[] {"--name", "-n"}, "The repositories name")
{
Required = true
}
new Argument<string>("name", "The repositories name")
};
removeRepo.Handler = CommandHandler.Create<string>(RemoveRepo);
rootCommand.AddCommand(removeRepo);

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using CC_Functions.Misc;
using UpToolLib.DataStructures;
namespace UpToolLib.Tool
@ -20,14 +21,18 @@ namespace UpToolLib.Tool
int i = 0;
while (i < repArr.Count)
{
string status = "Initializing";
#if !DEBUG
try
{
#endif
ExternalFunctionalityManager.Instance.Log($"[{i + 1}] Loading {repArr[i]}");
status = $"Loading {repArr[i]}";
XDocument repo = XDocument.Load(new Uri(repArr[i]).TryUnshorten().AbsoluteUri);
status = $"Extracting repolinks";
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
.Where(s => !repArr.Contains(s)));
status = $"Extracting apps";
XElement[] tmpApparray = repo.Element("repo").Elements("app").Where(app =>
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
!tmpAppsList
@ -37,9 +42,13 @@ namespace UpToolLib.Tool
.Select(s =>
{
ExternalFunctionalityManager.Instance.Log($"- Loading {s.Value}");
return XDocument.Load(new Uri(s.Value).TryUnshorten().AbsoluteUri).Element("app");
status = $"Fetching app data tag: {s.Value}";
XElement ret = XDocument.Load(new Uri(s.Value).TryUnshorten().AbsoluteUri)
.Element("app");
return ret;
}))
.ToArray();
status = $"Creating app cache";
foreach (XElement app in tmpApparray)
{
//"Sanity check"
@ -51,7 +60,7 @@ namespace UpToolLib.Tool
new XElement("Description", app.Element("Description").Value),
new XElement("Version", app.Element("Version").Value),
new XElement("ID", app.Element("ID").Value),
new XElement("File", app.Element("File").Value),
new XElement("File", new Uri(app.Element("File").Value).Unshorten().ToString()),
new XElement("Hash", app.Element("Hash").Value)
));
if (app.Element("MainFile") != null)
@ -85,7 +94,7 @@ namespace UpToolLib.Tool
catch (Exception e)
{
ExternalFunctionalityManager.Instance.OkDialog(
$"Failed to load repo: {repArr[i]}{Environment.NewLine}{e}");
$"Failed to load repo: {repArr[i]}{Environment.NewLine}Last status was: {status}{Environment.NewLine}{e}");
}
#endif
i++;