Skip to content

Commit

Permalink
Cleanup and documentation (#67)
Browse files Browse the repository at this point in the history
Remove json support for RepositoryActions. Cleanup, documentation.

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
coenm and actions-user authored Aug 16, 2023
1 parent 29322b9 commit 38e2c2e
Show file tree
Hide file tree
Showing 219 changed files with 1,638 additions and 2,349 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ The `RepositoryActions.yaml` file also contains a section to define tags per rep

## Ordering and Filtering

[Filtering](docs/Filtering.md) [Ordering](docs/Ordering.md)
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name. Read more about ordering [here](docs/Ordering.md).

The repositories shown in RepoM are filtered using the search box in RepoM. But the default set can also be configured using different presets. [This page](docs/Filtering.md) describes how to create custom filter presets.

## Global configuration

Expand Down
4 changes: 3 additions & 1 deletion README.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ The `RepositoryActions.yaml` file also contains a section to define tags per rep

## Ordering and Filtering

[Filtering](docs/Filtering.md) [Ordering](docs/Ordering.md)
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name. Read more about ordering [here](docs/Ordering.md).

The repositories shown in RepoM are filtered using the search box in RepoM. But the default set can also be configured using different presets. [This page](docs/Filtering.md) describes how to create custom filter presets.

## Global configuration

Expand Down
6 changes: 3 additions & 3 deletions _ref/RepoM.Sorting.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Work:
type: composition@1
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
Expand All @@ -19,7 +19,7 @@ Work:
property: Name
weight: 1
Work Dynamic:
type: composition@1
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
Expand Down Expand Up @@ -58,7 +58,7 @@ Work Dynamic:
property: Name
weight: 1
Prive:
type: composition@1
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
Expand Down
97 changes: 96 additions & 1 deletion docs/Ordering.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,98 @@
# Ordering

todo.
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name.

Orderings are defined in yaml using repository-`comparers` and repository-`scorers`. You can switch at any given time between orderings using the hamburgermenu in RepoM.

## Definitions

A [`comparer`](#comparers) compares two repositories resulting in an order between the two. The comparison is defined by the type of comparer. It is possible to compare by repository name (assending order) or to compare repositories by the timestamp of the last action performed by RepoM.

[`Scorers`](#scorers) however calculate a score over exactly one repository. It does not compare repositories. Comparing repositories by score, use the `score-comparer@1`.

## Comparers

- [`az-comparer@1`](#az-comparer1)<!-- include: RepositoriesComparerConfigurationTests.CoreComparersMarkdown.verified.md -->
- [`composition-comparer@1`](#composition-comparer1)
- [`score-comparer@1`](#score-comparer1)
- [`sum-comparer@1`](#sum-comparer1)

These comparers are available by using the corresponding plugin.
- [`last-opened-comparer@1`](#last-opened-comparer1)

### `az-comparer@1`

Compares two repositories by a given property alphabetically in ascending order.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_AlphabetComparerConfigurationV1.verified.md -->

Properties:

- `property`: Repository property. Currently, only `Name`, and `Location` are supported. Otherwise, comparison will always result in `0`. (optional)
- `weight`: The weight of this comparer. The higher the weight, the higher the impact.<!-- endInclude -->

### `composition-comparer@1`

Compares two repositories by a composition of comparers.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_CompositionComparerConfigurationV1.verified.md -->

Properties:

- `comparers`: List of comparers. The first comparer not resulting in `0` will be used as final result.<!-- endInclude -->

### `score-comparer@1`

Compares two repositories by a repository score. The calculation of the repository score is defined in the score provider.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_ScoreComparerConfigurationV1.verified.md -->

Properties:

- `score-provider`: The score provider to calculate a score for a repository. (optional)<!-- endInclude -->

### `sum-comparer@1`

Compares two repositories by the sum of the results of the comparers.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_SumComparerConfigurationV1.verified.md -->

Properties:

- `comparers`: A list of comparers. The sum of the results of the comparers will be used as final result.<!-- endInclude -->

### `last-opened-comparer@1`

Compares two repositories by the timestamp of the last action RepoM performed on the repository.<!-- include: RepositoriesComparerConfigurationTests.DocsRepositoriesComparerConfiguration_LastOpenedConfigurationV1.verified.md -->

Properties:

- `weight`: The weight of this comparer. The higher the weight, the higher the impact.<!-- endInclude -->
<!-- endInclude -->

## Scorers

- [`is-pinned-scorer@1`](#is-pinned-scorer1)<!-- include: RepositoriesScorerConfigurationTests.CoreScorersMarkdown.verified.md -->
- [`tag-scorer@1`](#tag-scorer1)

These scorers are available by using the corresponding plugin.
- [`usage-scorer@1`](#usage-scorer1)

### `is-pinned-scorer@1`

Repository scorer based on the pinned state of a repository.<!-- include: RepositoriesScorerConfigurationTests.DocsRepositoriesScorerConfiguration_IsPinnedScorerConfigurationV1.verified.md -->

Properties:

- `weight`: The weight of this scorer. The higher the weight, the higher the impact.<!-- endInclude -->

### `tag-scorer@1`

Repository scorer based on the tags of a repository.<!-- include: RepositoriesScorerConfigurationTests.DocsRepositoriesScorerConfiguration_TagScorerConfigurationV1.verified.md -->

Properties:

- `weight`: The weight of this scorer. The higher the weight, the higher the impact.
- `tag`: The tag to match on. If the repository has this tag, the score will return the weight, otherwise, `0`. (optional)<!-- endInclude -->

### `usage-scorer@1`

Repository scorer based on it's usage by RepoM. The more it's used, the higher the score.<!-- include: RepositoriesScorerConfigurationTests.DocsRepositoriesScorerConfiguration_UsageScorerConfigurationV1.verified.md -->

Properties:

- `windows`: Specific 'windows' to calculate the score for.
- `max-score`: The maximum score a repository can get.<!-- endInclude -->
<!-- endInclude -->
2 changes: 1 addition & 1 deletion docs/RepoM.Plugin.Heidi.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Heidi

This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves it's database configuration in a portable configuration file.
This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves its database configuration in a portable configuration file.
This module monitors this file and provides an action menu and a variable provider to access this information.

To use this module, make sure it is enabled in RepoM by opening the menu and navigate to 'Plugins'. When enabling or disabling a plugin, you should restart RepoM.<!-- singleLineInclude: _plugin_enable. path: /docs/mdsource/_plugin_enable.include.md -->
Expand Down
4 changes: 0 additions & 4 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ This is the default configuration.
},
"ReposRootDirectories": [],
"EnabledSearchProviders": [],
"SonarCloudPersonalAccessToken": null,
"AzureDevOps": null,
"Plugins": []
}
```
Expand All @@ -38,6 +36,4 @@ Properties:<!-- include: DocsAppSettingsTests.AppSettingsDocumentationGeneration
- `MenuSize`: The menu size of RepoM. This is set when the window is resized. (optional, UI configured)
- `ReposRootDirectories`: List of root directories where RepoM will search for git repositories. If null or empty, all fixed drives will be searched from the root. (optional, Manual configured)
- `EnabledSearchProviders`: List of search providers. Search providers can be added by plugins. (optional, UI configured)
- `SonarCloudPersonalAccessToken`: SonarCloud PAT. (<span style="color: red;">Obsolete, moved to plugin config</span>)
- `AzureDevOps`: Azure DevOps config. (<span style="color: red;">Obsolete, moved to plugin config</span>)
- `Plugins`: List of plugins. (optional, UI configured)<!-- endInclude -->
18 changes: 17 additions & 1 deletion docs/mdsource/Ordering.source.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Ordering

todo.
The order of the repositories shown in RepoM is customizable. The default is alphabetical on the repository name.

Orderings are defined in yaml using repository-`comparers` and repository-`scorers`. You can switch at any given time between orderings using the hamburgermenu in RepoM.

## Definitions

A [`comparer`](#comparers) compares two repositories resulting in an order between the two. The comparison is defined by the type of comparer. It is possible to compare by repository name (assending order) or to compare repositories by the timestamp of the last action performed by RepoM.

[`Scorers`](#scorers) however calculate a score over exactly one repository. It does not compare repositories. Comparing repositories by score, use the `score-comparer@1`.

## Comparers

include: RepositoriesComparerConfigurationTests.CoreComparersMarkdown.verified.md

## Scorers

include: RepositoriesScorerConfigurationTests.CoreScorersMarkdown.verified.md
2 changes: 1 addition & 1 deletion docs/mdsource/RepoM.Plugin.Heidi.source.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Heidi

This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves it's database configuration in a portable configuration file.
This module integrates with a portable [HeidiSQL](https://www.heidisql.com/) installation. The portable Heidi DB saves its database configuration in a portable configuration file.
This module monitors this file and provides an action menu and a variable provider to access this information.

include: _plugin_enable
Expand Down
42 changes: 42 additions & 0 deletions src/RepoM.Api/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace RepoM.Api;
using System.Threading.Tasks;
using System;
using RepoM.Api.Plugins.SimpleInjector;
using RepoM.Core.Plugin;
using RepoM.Core.Plugin.Common;
using RepoM.Core.Plugin.RepositoryOrdering.Configuration;

public class CoreBootstrapper
{
Expand All @@ -21,6 +23,8 @@ public class CoreBootstrapper
private readonly IAppDataPathProvider _appDataProvider;
private readonly ILoggerFactory _loggerFactory;

private static readonly Assembly _thisAssembly = typeof(CoreBootstrapper).Assembly;

public CoreBootstrapper(IPluginFinder pluginFinder, IFileSystem fileSystem, IAppDataPathProvider appDataProvider, ILoggerFactory loggerFactory)
{
_pluginFinder = pluginFinder ?? throw new ArgumentNullException(nameof(pluginFinder));
Expand All @@ -29,6 +33,22 @@ public CoreBootstrapper(IPluginFinder pluginFinder, IFileSystem fileSystem, IApp
_loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
}

public static void RegisterRepositoryScorerConfigurationsTypes(Container container)
{
foreach (Type type in GetNonAbstractNonGenericInheritedExportedTypesFrom<IRepositoryScorerConfiguration>(_thisAssembly))
{
container.RegisterScorerConfigurationForType(type);
}
}

public static void RegisterRepositoryComparerConfigurationsTypes(Container container)
{
foreach (Type type in GetNonAbstractNonGenericInheritedExportedTypesFrom<IRepositoriesComparerConfiguration>(_thisAssembly))
{
container.RegisterComparerConfigurationForType(type);
}
}

public async Task LoadAndRegisterPluginsAsync(Container container, string baseDirectory)
{
_ = container ?? throw new ArgumentNullException(nameof(container));
Expand Down Expand Up @@ -79,4 +99,26 @@ private static PluginSettings ConvertToPluginSettings(PluginInfo pluginInfo, str
{
return new PluginSettings(pluginInfo.Name, pluginInfo.AssemblyPath.Replace(baseDir, string.Empty), enabled);
}

static IEnumerable<Type> GetExportedTypesFrom(Assembly assembly)
{
try
{
return assembly.DefinedTypes.Select(info => info.AsType());
}
catch (NotSupportedException)
{
// A type load exception would typically happen on an Anonymously Hosted DynamicMethods
// Assembly and it would be safe to skip this exception.
return Enumerable.Empty<Type>();
}
}

static IEnumerable<Type> GetNonAbstractNonGenericInheritedExportedTypesFrom<T>(Assembly assembly)
{
return GetExportedTypesFrom(assembly)
.Where(t => typeof(T).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()))
.Where(t => t.GetTypeInfo() is { IsAbstract: false, IsGenericTypeDefinition: false, });

}
}
36 changes: 3 additions & 33 deletions src/RepoM.Api/Common/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ public sealed class AppSettings
[UiConfigured]
public List<string> EnabledSearchProviders { get; set; } = new();

/// <summary>
/// SonarCloud PAT.
/// </summary>
[Obsolete("This is done using plugin.")]
public string? SonarCloudPersonalAccessToken { get; set; } = string.Empty;

/// <summary>
/// Azure DevOps config.
/// </summary>
[Obsolete("This is done using plugin.")]
public AzureDevOpsOptions? AzureDevOps { get; set; } = AzureDevOpsOptions.Default;

/// <summary>
/// List of plugins.
/// </summary>
Expand All @@ -82,8 +70,6 @@ public sealed class AppSettings
MenuSize = Size.Default,
ReposRootDirectories = new(),
EnabledSearchProviders = new List<string>(1),
SonarCloudPersonalAccessToken = null,
AzureDevOps = AzureDevOpsOptions.Default,
Plugins = new List<PluginOptions>(),
};
}
Expand All @@ -94,15 +80,6 @@ public sealed class UiConfiguredAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class ManualConfiguredAttribute : Attribute { }

public class AzureDevOpsOptions
{
public string? PersonalAccessToken { get; set; } = string.Empty;

public string? BaseUrl { get; set; } = string.Empty;

public static AzureDevOpsOptions? Default => null;
}

public class Size
{
public double Height { get; set; }
Expand All @@ -118,16 +95,9 @@ public class Size

public class PluginOptions
{
public PluginOptions()
{
Name = string.Empty;
DllName = string.Empty;
Enabled = false;
}

public string Name { get; init; }
public string Name { get; init; } = string.Empty;

public string DllName { get; init; }
public string DllName { get; init; } = string.Empty;

public bool Enabled { get; init; }
public bool Enabled { get; init; } = false;
}
Loading

0 comments on commit 38e2c2e

Please sign in to comment.