refactor!: preparing for mono repository

This commit is contained in:
D. Moonfire 2023-07-09 22:34:19 -05:00
parent a2619d4ed0
commit 65fafcc4da
21 changed files with 111 additions and 158 deletions

View file

@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"gitversion.tool": {
"version": "5.9.0",
"version": "5.12.0",
"commands": [
"dotnet-gitversion"
]

View file

@ -1,36 +1,36 @@
clone:
git:
image: woodpeckerci/plugin-git
settings:
tags: true
# clone:
# git:
# image: woodpeckerci/plugin-git
# settings:
# tags: true
pipeline:
build:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
commands:
- nix develop --command scripts/build.sh
when:
event: [push, pull_request, tag]
tag: v*
# pipeline:
# build:
# image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
# commands:
# - nix develop --command scripts/build.sh
# when:
# event: [push, pull_request, tag]
# tag: v*
test:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
commands:
- nix develop --command scripts/test.sh
when:
event: [push, pull_request]
#paths:
# - ./**/*test-result.xml
# - ./coverage/Cobertura.xml
# - ./coverage/Summary.*
# - ./**/*.nupkg
# test:
# image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
# commands:
# - nix develop --command scripts/test.sh
# when:
# event: [push, pull_request]
# #paths:
# # - ./**/*test-result.xml
# # - ./coverage/Cobertura.xml
# # - ./coverage/Summary.*
# # - ./**/*.nupkg
release-main:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
commands:
- nix develop --command scripts/release.sh
secrets:
- gitea_token
when:
event: push
branch: main
# release-main:
# image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
# commands:
# - nix develop --command scripts/release.sh
# secrets:
# - gitea_token
# when:
# event: push
# branch: main

29
Justfile Normal file
View file

@ -0,0 +1,29 @@
@_default:
just --choose
# Builds all of the components of this repository.
build:
dotnet build
# Runs all the known tests in the repository.
test: restore-tools
dotnet test \
--test-adapter-path:. \
--logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" \
--collect:"XPlat Code Coverage"
dotnet tool run reportgenerator \
-reports:tests/*/TestResults/*/coverage.cobertura.xml \
-targetdir:./coverage \
"-reporttypes:Cobertura;TextSummary"
grep "Line coverage" coverage/Summary.txt
# Restores all the tools and NuGet packages.
restore: restore-tools restore-packages
# Restores all the dotnet tools used.
restore-tools:
dotnet tool restore
# Restores all the NuGet packages.
restore-packages:
dotnet restore

View file

@ -1,6 +1,6 @@
# The MIT License (MIT)
Copyright © 2021-2022 Dylan Moonfire
Copyright © 2021-2023 Dylan Moonfire
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) Moonfire Games
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.

View file

@ -1,16 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mfgames.com" value="https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json" protocolVersion="3" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
<packageSource key="mfgames.com">
<package pattern="MfGames.*" />
</packageSource>
</packageSourceMapping>
</configuration>

View file

@ -12,7 +12,7 @@
in {
devShell = pkgs.mkShell {
buildInputs =
[ pkgs.dotnet-sdk pkgs.lefthook pkgs.convco pkgs.nixfmt pkgs.jq ];
[ pkgs.dotnet-sdk pkgs.lefthook pkgs.convco pkgs.nixfmt pkgs.jq pkgs.just ];
};
});
}

View file

@ -1,7 +0,0 @@
#!/usr/bin/env sh
cd $(dirname $0)/..
./scripts/setup.sh || exit 1
echo "$(basename $0): building project"
dotnet build

View file

@ -1,4 +0,0 @@
#!/usr/bin/env sh
cd $(dirname $0)/..
lefthook run pre-commit

View file

@ -1,28 +0,0 @@
#!/usr/bin/env sh
# Normalize our environment.
cd $(dirname $0)/..
# Make sure we have the needed executables installed.
for e in dotnet lefthook nixfmt
do
if ! which $e >& /dev/null
then
echo "Cannot find '$e' in the path"
exit 1
fi
done
# Make sure we have lefthook is installed.
if [ ! -f .git/hooks/pre-commit ]
then
echo "$(basename $0): installing lefthook"
lefthook install
fi
# Make sure our tools are installed.
echo "$(basename $0): install .NET tools"
dotnet tool restore
# Everything is good.
exit 0

View file

@ -1,12 +0,0 @@
#!/usr/bin/env sh
cd $(dirname $0)/..
if ls ./tests/*/*.csproj >& /dev/null
then
./scripts/setup.sh || exit 1
dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" --collect:"XPlat Code Coverage"
dotnet tool run reportgenerator -reports:tests/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary"
grep "Line coverage" coverage/Summary.txt
fi

View file

@ -1,4 +0,0 @@
#!/usr/bin/env sh
cd $(dirname $0)/..
git pull template main --no-rebase

View file

@ -1,14 +0,0 @@
<Project>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Dylan Moonfire</Authors>
<Company>Moonfire Games</Company>
<RepositoryUrl>https://gitlab.com/mfgames-cil/mfgames-toolbuilder-cil</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>cli</PackageTags>
<PackageProjectUrl>https://gitlab.com/mfgames-cil/mfgames-toolbuilder-cil</PackageProjectUrl>
<PackageLicense>MIT</PackageLicense>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,13 @@
mode: ContinuousDelivery
increment: Inherit
continuous-delivery-fallback-tag: ci
major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:"
patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
assembly-informational-format: "{InformationalVersion}"
tag-prefix: "MfGames.ToolBuilder.Tables-"

View file

@ -7,6 +7,17 @@
<Description>Provides a tool service for creating tools that output tabular data to the console.</Description>
</PropertyGroup>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Dylan Moonfire</Authors>
<Company>Moonfire Games</Company>
<RepositoryUrl>https://src.mfgames.com/mfgames-cil/mfgames-cil</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>cli</PackageTags>
<PackageProjectUrl>https://src.mfgames.com/mfgames-cil/mfgames-cil</PackageProjectUrl>
<PackageLicense>MIT</PackageLicense>
</PropertyGroup>
<PropertyGroup>
<!-- System.CommandLine is pre-release and will be for a while. -->
<NoWarn>$(NoWarn);NU5104</NoWarn>
@ -17,6 +28,10 @@
<PackageReference Include="ConsoleTableExt" Version="3.2.0" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="FluentResults" Version="3.15.2" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Glob" Version="1.1.9" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

View file

@ -10,4 +10,4 @@ assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
assembly-informational-format: "{InformationalVersion}"
tag-prefix: "[vV]"
tag-prefix: "MfGames.ToolBuilder-"

View file

@ -1,22 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Description>A framework for easily creating command line tools using System.CommandLine, Autofac, and Serilog.</Description>
<GitVersionUseSolutionDir>True</GitVersionUseSolutionDir>
</PropertyGroup>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Dylan Moonfire</Authors>
<Company>Moonfire Games</Company>
<RepositoryUrl>https://src.mfgames.com/mfgames-cil/mfgames-cil</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>cli</PackageTags>
<PackageProjectUrl>https://src.mfgames.com/mfgames-cil/mfgames-cil</PackageProjectUrl>
<PackageLicense>MIT</PackageLicense>
</PropertyGroup>
<PropertyGroup>
<!-- System.CommandLine is pre-release and will be for a while. -->
<NoWarn>$(NoWarn);NU5104</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="ConsoleTableExt" Version="3.2.0" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="FluentResults" Version="3.15.2" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Glob" Version="1.1.9" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="MfGames.IO" Version="1.2.8" />
@ -48,5 +60,4 @@
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
</ItemGroup>
</Project>

View file

@ -4,26 +4,6 @@ _An opinionated library for easily creating command-line tools in C#._
MfGames.ToolBuilder is a library to encapsulate the setup and running of tools, CLI components arranged with verbs (like `git`). It includes some opinionated decisions on default setup.
## Building
To make sure the environment is correctly set up for build:
```sh
./scripts/setup.sh
```
To build the project:
```sh
./scripts/build.sh
```
To test the project:
```sh
./scripts/test.sh
```
## Commands
This library is built on top of [System.CommandLine](https://github.com/dotnet/command-line-api) and .NET 6 generic hosting. The commands are combined together using dependency injection (see below) which allows for them to be included as parameters for the constructor or dynamically discovered.

View file

@ -1 +0,0 @@
# Source Directories