Skip to content

Commit

Permalink
Merge pull request #9 from paralexm/master
Browse files Browse the repository at this point in the history
Changed branding, filename comparer and added readme
  • Loading branch information
biohazard999 authored Apr 8, 2024
2 parents 81a8342 + f7e0f3f commit d5ccdc1
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 106 deletions.
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Product>Xenial</Product>
<Product>Vertiq</Product>
<MinVerTagPrefix>v</MinVerTagPrefix>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -9,9 +9,9 @@
<IncludeSource>True</IncludeSource>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Copyright>Copyright $([System.Char]::ConvertFromUtf32(169)) Xenial 2019-$([System.DateTime]::Today.ToString('yyyy'))</Copyright>
<Copyright>Copyright $([System.Char]::ConvertFromUtf32(169)) Vertiq 2019-$([System.DateTime]::Today.ToString('yyyy'))</Copyright>
<Authors>Vertiq</Authors>
<RepositoryUrl>https://github.com/xenial-io/Xenial.BTool</RepositoryUrl>
<RepositoryUrl>https://github.com/vertiq-io/Vertiq.BTool</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>
Expand Down
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# Vertiq
# Vertiq.BTool

**Vertiq.BTool** is a dotnet global tool
that enables fast and efficient build script execution from any location on the commandline.

## Description

Whenever you need to locate and execute a build script within a repo subdirectory, Vertiq.BTool is there to help.
Simply issue `b` command,
and it will search the current directory and its subfolders for your build script, and execute it.
No more navigating to build scripts!

## Installation

Download and install one of the currently supported [.NET SDKs](https://www.microsoft.com/net/download).
Once installed, you can install the tool globally using the following command:

```shell
dotnet tool install --global vertiq.btool
```

### Update

If you already have a previous version of **Vertiq.BTool** installed,
you can upgrade to the latest version using the following command:

```shell
dotnet tool update --global vertiq.btool
```

### Uninstall

If you want to remove the tool, you can do it using the following command:

```shell
dotnet tool uninstall --global vertiq.btool
```

## Usage

Running `b` without any parameters will locate and execute the build script in its default mode.

```shell
b
```

All command-line arguments are passed to the build script.

```shell
b --configuration=Release --platform=x64
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.IO.Abstractions;

using Xenial.BTool;
using Xenial.BTool.Tests;

namespace Xenial.Tests.BTool;
namespace Vertiq.BTool.Tests;

public sealed class BuildExecutorTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO.Abstractions.TestingHelpers;
using System.Runtime.InteropServices;

namespace Xenial.BTool.Tests;
namespace Vertiq.BTool.Tests;

public sealed class BuildLocatorTests
{
Expand All @@ -27,7 +27,7 @@ public void LocateBuildScript()
{ @$"{root}sub{s}image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
{ @$"{root}sub{s}sub{s}image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
{ @$"{root}sub{s}sub{s}sub{s}image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
{ @$"{root}sub{s}b{ext}", new MockFileData("")}
{ @$"{root}sub{s}b{ext}", new MockFileData("")},
});

var locator = new BuildLocator(fileSystem);
Expand All @@ -37,7 +37,7 @@ public void LocateBuildScript()
}

[IgnoreUnixFact]
public void LocateBuildScriptInvariant()
public void LocateBuildScriptOrdinalIgnoreCase()
{
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
Expand All @@ -46,7 +46,7 @@ public void LocateBuildScriptInvariant()
{ @"c:\demo\sub\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
{ @"c:\demo\sub\sub\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
{ @"c:\demo\sub\sub\sub\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
{ @"c:\demo\sub\B.BaT", new MockFileData("")}
{ @"c:\demo\sub\B.BaT", new MockFileData("")},
});

var locator = new BuildLocator(fileSystem);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.InteropServices;

namespace Xenial.BTool.Tests;
namespace Vertiq.BTool.Tests;

public sealed class IgnoreUnixFact : FactAttribute
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>Xenial.Tests.BTool</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Vertiq.BTool.Tests</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -13,15 +13,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="17.2.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="20.0.15" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Xenial.BTool\Xenial.BTool.csproj" />
<ProjectReference Include="..\Vertiq.BTool\Vertiq.BTool.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions Xenial.BTool.sln → Vertiq.BTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33020.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenial.BTool", "Xenial.BTool\Xenial.BTool.csproj", "{B8A77C11-DE01-4CF0-8EAD-6818EDA46742}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vertiq.BTool", "Vertiq.BTool\Vertiq.BTool.csproj", "{B8A77C11-DE01-4CF0-8EAD-6818EDA46742}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xenial.BTool.Tests", "Xenial.BTool.Tests\Xenial.BTool.Tests.csproj", "{031877A2-4388-4483-8D4E-2CE7BAE83BEE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vertiq.BTool.Tests", "Vertiq.BTool.Tests\Vertiq.BTool.Tests.csproj", "{031877A2-4388-4483-8D4E-2CE7BAE83BEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build\build.csproj", "{C66D229F-2957-4D70-9E13-3F6D6E23FF41}"
EndProject
Expand All @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.sh = build.sh
Directory.Build.props = Directory.Build.props
README.md = README.md
global.json = global.json
nuget.config = nuget.config
EndProjectSection
EndProject
Global
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using static SimpleExec.Command;
namespace Xenial.BTool;
namespace Vertiq.BTool;

public sealed record BuildExecutor(BuildLocator BuildLocator)
{
Expand Down
48 changes: 48 additions & 0 deletions Vertiq.BTool/BuildLocator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.IO.Abstractions;

namespace Vertiq.BTool;

public sealed record BuildLocator(IFileSystem FileSystem)
{
private static HashSet<string> Extensions { get; } =
OperatingSystem.IsWindows() ? new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
".bat", ".cmd", ".ps1",
} :
OperatingSystem.IsMacOS() || OperatingSystem.IsLinux() ? new HashSet<string>(StringComparer.Ordinal)
{
".sh",
} :
[];

private static HashSet<string> Filenames { get; } = new(StringComparer.OrdinalIgnoreCase)
{
"b", "build",
};

public string? LocateBuildScript(string? cd = null)
{
cd ??= Environment.CurrentDirectory;
var directoryInfo = FileSystem.DirectoryInfo.New(cd);

return Locate(directoryInfo);
}

private string? Locate(IDirectoryInfo? directoryInfo)
{
if(directoryInfo is null)
{
return null;
}

foreach (var file in directoryInfo.EnumerateFiles("*.*", SearchOption.TopDirectoryOnly))
{
if (Extensions.Contains(file.Extension) && Filenames.Contains(FileSystem.Path.GetFileNameWithoutExtension(file.Name)))
{
return file.FullName;
}
}

return Locate(directoryInfo.Parent);
}
}
2 changes: 1 addition & 1 deletion Xenial.BTool/Program.cs → Vertiq.BTool/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO.Abstractions;

using Xenial.BTool;
using Vertiq.BTool;

var executor = new BuildExecutor(new BuildLocator(new FileSystem()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<MinVerTagPrefix>v</MinVerTagPrefix>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>b-tool</PackageId>
Expand All @@ -12,16 +12,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MinVer" Version="4.2.0">
<PackageReference Include="MinVer" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslyn.System.IO.Abstractions.Analyzers" Version="12.2.19">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SimpleExec" Version="11.0.0" />
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
<PackageReference Include="SimpleExec" Version="12.0.0" />
<PackageReference Include="System.IO.Abstractions" Version="20.0.15" />
</ItemGroup>

<ItemGroup Condition="'$(GITHUB_ACTIONS)' != ''">
Expand Down
66 changes: 0 additions & 66 deletions Xenial.BTool/BuildLocator.cs

This file was deleted.

4 changes: 0 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
set -euo pipefail
$HOME/.dotnet/dotnet run --project "./build/build.csproj" --no-launch-profile -- "$@"




4 changes: 2 additions & 2 deletions build/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var sln = "./Xenial.BTool.sln";
var sln = "./Vertiq.BTool.sln";

Target("restore", () => RunAsync("dotnet", $"restore {sln}"));

Expand All @@ -20,7 +20,7 @@

foreach (var file in files)
{
await RunAsync("dotnet", $"nuget push {file} --skip-duplicate -s https://api.nuget.org/v3/index.json -k {Environment.GetEnvironmentVariable("NUGET_AUTH_TOKEN")}",
await RunAsync("dotnet", $"nuget push {file} --skip-duplicate -k {Environment.GetEnvironmentVariable("NUGET_AUTH_TOKEN")}",
noEcho: true
);
}
Expand Down
Loading

0 comments on commit d5ccdc1

Please sign in to comment.