Skip to content

Commit

Permalink
Local package source (#169)
Browse files Browse the repository at this point in the history
* Added support for local package sources.

Closes #168.

* Updated the regression tests.

* Copy packages on a local build.

* Localization.
  • Loading branch information
pvginkel authored Dec 12, 2023
1 parent 2edf257 commit b6fe80f
Show file tree
Hide file tree
Showing 25 changed files with 185 additions and 22 deletions.
11 changes: 11 additions & 0 deletions scripts/Local-Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ Function Copy-Output([string]$From, [string]$Target)
Copy-Item "$Global:Src\$From\bin\Release\net8.0-windows\*" -Destination $Target -Recurse
}

Function Copy-Packages([string]$Target)
{
Write-Host "Copying NuGet packages"

[void](New-Item -Type directory $Target)

Get-ChildItem -Path $Global:Src -Recurse -Filter "*.nupkg" | Copy-Item -Destination $Target -Force
}

################################################################################
# ENTRY POINT
################################################################################
Expand All @@ -30,3 +39,5 @@ dotnet build -c Release -property:Version=999.0

Copy-Output -From "Tql.App" -Target "$Global:Distrib\App"
Copy-Output -From "Tql.DebugApp" -Target "$Global:Distrib\DebugApp"

Copy-Packages -Target "$Global:Distrib\Packages"
2 changes: 2 additions & 0 deletions specs/App - Quick Start/003-JIRA-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ description: Validate that the quick start tutorial will set you up with JIRA.

## Successfully setup JIRA

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| Open the app. The quick start window opens. | |
Expand Down
2 changes: 2 additions & 0 deletions specs/App - Quick Start/004-Azure-DevOps-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ description:

## Successfully setup Azure DevOps

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| Open the app. | The quick start window opens. |
Expand Down
2 changes: 2 additions & 0 deletions specs/App - Quick Start/005-GitHub-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ description: Validate that the quick start tutorial will set you up with GitHub.

## Successfully setup GitHub

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| Open the app. | The quick start window must open. |
Expand Down
4 changes: 4 additions & 0 deletions specs/App - Quick Start/007-Install-secondary-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ description:

## Setup the quick start tutorial

{% include Setup/Local-package-source.md %}

{% include Setup/App/QuickStart/Reset-quick-start.md %}

| Action | Expected result |
Expand All @@ -35,6 +37,8 @@ description:

## Configure secondary tool

{% include Setup/Local-package-source.md %}

Validate that you can restart the tutorial, configuring a secondary tool:

| Action | Expected result |
Expand Down
2 changes: 2 additions & 0 deletions specs/Plugins - Azure DevOps/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the Azure DevOps plugin.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| ---------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
2 changes: 2 additions & 0 deletions specs/Plugins - Azure/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the Azure plugin.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| ------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
2 changes: 2 additions & 0 deletions specs/Plugins - Confluence/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the Confluence plugin.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| -------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
2 changes: 2 additions & 0 deletions specs/Plugins - GitHub/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the GitHub plugin.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| ------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
2 changes: 2 additions & 0 deletions specs/Plugins - JIRA/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the JIRA plugin.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| ------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
4 changes: 4 additions & 0 deletions specs/Plugins - Microsoft Teams/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the Microsoft Teams plugin.

## Prerequisite

{% include Setup/Local-package-source.md %}

The demo plugin is necessary to get demo people directories.

| Action | Expected result |
Expand All @@ -26,6 +28,8 @@ The demo plugin is necessary to get demo people directories.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| ------------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
2 changes: 2 additions & 0 deletions specs/Plugins - Outlook/001-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: Install the Outlook plugin.

## Installation

{% include Setup/Local-package-source.md %}

| Action | Expected result |
| ------------------------------------------- | --------------- |
| Open the **Configuration** window. | |
Expand Down
4 changes: 4 additions & 0 deletions specs/_includes/Setup/Local-package-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Note:** These steps contain instructions to install a new package. If you have
a local package source configured, packages from the local source will be marked
with an orange label "Local". Use those instead of the verified one and accept
the warning. The remainder of the steps should work as usual.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ public string? Password

public PackageSourceDto()
{
AddProperty(
nameof(Url),
p => ValidateNotEmpty(p) ?? ValidateUrl(p),
CoerceEmptyStringToNull
);
AddProperty(nameof(Url), ValidateNotEmpty, CoerceEmptyStringToNull);
AddProperty(nameof(UserName), null, CoerceEmptyStringToNull);
AddProperty(nameof(Password), null, CoerceEmptyStringToNull);
}
Expand Down
25 changes: 22 additions & 3 deletions src/Tql.App/ConfigurationUI/PluginsConfigurationControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,28 @@
<TextBlock
Foreground="White"
FontSize="8pt"
Margin="0,0,6,0">
Verified
</TextBlock>
Margin="0,0,6,0"
Text="{x:Static app:Labels.PluginsConfiguration_Verified}" />
</StackPanel>
</Border>
<Border
Visibility="{Binding IsLocal, Converter={StaticResource B2VConverter}}"
Background="#f89f49"
VerticalAlignment="Center"
CornerRadius="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HeightToRadiusConverter}}"
Margin="0,0,5,0"
support:PopoverToolTipUtils.PopoverToolTip="{DynamicResource LocalToolTip}">
<StackPanel Orientation="Horizontal">
<Image
Source="{DynamicResource ResourceKey=Folder}"
Height="9"
Width="9"
Margin="5,0,3,0" />
<TextBlock
Foreground="White"
FontSize="8pt"
Margin="0,0,6,0"
Text="{x:Static app:Labels.PluginsConfiguration_Local}" />
</StackPanel>
</Border>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ IUI ui
"VerifiedToolTip",
new PopoverToolTip(null, Labels.PluginsConfiguration_VerifiedToolTip)
);
Resources.Add("Folder", Images.Folder);
Resources.Add(
"LocalToolTip",
new PopoverToolTip(null, Labels.PluginsConfiguration_LocalToolTip)
);

SetSelectedTab(Tab.Browse);
}
Expand Down
1 change: 1 addition & 0 deletions src/Tql.App/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ private static DrawingImage LoadImage(string resourceName, Color? color)
"Arrow Left.svg",
Color.FromRgb(20, 79, 162)
);
public static readonly DrawingImage Folder = GetImage("Folder.svg");
}
27 changes: 27 additions & 0 deletions src/Tql.App/Labels.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/Tql.App/Labels.nl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -822,4 +822,16 @@ Do you want to restart TQL to see if this resolves the issue?</comment>
<value>Bestanden worden opgeschoond…</value>
<comment>Original: Deleting unused files...</comment>
</data>
<data name="PluginsConfiguration_Local" xml:space="preserve">
<value>Lokaal</value>
<comment>Original: Local</comment>
</data>
<data name="PluginsConfiguration_LocalToolTip" xml:space="preserve">
<value>De plug-in komt van een lokale pakketbron.</value>
<comment>Original: This plugin comes from a local package source.</comment>
</data>
<data name="PluginsConfiguration_Verified" xml:space="preserve">
<value>Geverifieerd</value>
<comment>Original: Verified</comment>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Tql.App/Labels.resx
Original file line number Diff line number Diff line change
Expand Up @@ -741,4 +741,13 @@ Do you want to restart TQL to see if this resolves the issue?</value>
<data name="PackageStoreManager_DeletingUnusedFiles" xml:space="preserve">
<value>Deleting unused files...</value>
</data>
<data name="PluginsConfiguration_Local" xml:space="preserve">
<value>Local</value>
</data>
<data name="PluginsConfiguration_LocalToolTip" xml:space="preserve">
<value>This plugin comes from a local package source.</value>
</data>
<data name="PluginsConfiguration_Verified" xml:space="preserve">
<value>Verified</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Tql.App/Resources/Folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions src/Tql.App/Services/Packages/NuGet/NuGetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace Tql.App.Services.Packages.NuGet;

using PackageSource = global::NuGet.Configuration.PackageSource;

// Heavily based on https://gist.github.com/cpyfferoen/74092a74b165e85aed5ca1d51973b9d2.

internal class NuGetClient : IDisposable
Expand Down Expand Up @@ -48,7 +50,7 @@ ImmutableArray<string> systemPackageIds

foreach (var source in configuration.Sources)
{
var packageSource = new global::NuGet.Configuration.PackageSource(source.Source)
var packageSource = new PackageSource(source.Source)
{
Credentials = source.Credentials
};
Expand Down Expand Up @@ -90,7 +92,7 @@ ImmutableArray<string> systemPackageIds
};
}

public async Task<ImmutableArray<IPackageSearchMetadata>> SearchPackages(
public async Task<ImmutableArray<NuGetSearchResult>> SearchPackages(
string nuGetOrgSearchTerm,
string otherSearchTerm,
bool includePrerelease,
Expand All @@ -99,7 +101,7 @@ public async Task<ImmutableArray<IPackageSearchMetadata>> SearchPackages(
CancellationToken cancellationToken = default
)
{
var packages = ImmutableArray.CreateBuilder<IPackageSearchMetadata>();
var packages = ImmutableArray.CreateBuilder<NuGetSearchResult>();

foreach (var remoteNuGetFeed in _remoteSourceRepositories)
{
Expand All @@ -117,14 +119,15 @@ public async Task<ImmutableArray<IPackageSearchMetadata>> SearchPackages(
};

packages.AddRange(
await searchResource.SearchAsync(
from package in await searchResource.SearchAsync(
searchTerm,
searchFilter,
0,
maxResults,
_logger,
cancellationToken
)
select new NuGetSearchResult(package, remoteNuGetFeed.PackageSource)
);
}
else
Expand All @@ -146,7 +149,9 @@ await searchResource.SearchAsync(

while (await enumerator.MoveNextAsync())
{
packages.Add(enumerator.Current);
packages.Add(
new NuGetSearchResult(enumerator.Current, remoteNuGetFeed.PackageSource)
);
}
}
}
Expand Down Expand Up @@ -397,3 +402,5 @@ public void PackageInstalled(object? sender, PackageIdentityEventArgs e)
}
}
}

internal record NuGetSearchResult(IPackageSearchMetadata Package, PackageSource Source);
3 changes: 2 additions & 1 deletion src/Tql.App/Services/Packages/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ internal record Package(
string Authors,
ImageSource Icon,
bool IsInstalled,
bool IsVerified
bool IsVerified,
bool IsLocal
);
Loading

0 comments on commit b6fe80f

Please sign in to comment.