Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ jobs:
- name: Rehydrate native folder
shell: bash
run: |
mkdir -p node_version/dist/native release
mkdir -p node_version/dist/native dotnet_version/native release

for artifact in artifacts/*; do
[ -d "$artifact" ] || continue
target="$(basename "$artifact")"

mkdir -p "node_version/dist/native/$target"
mkdir -p "dotnet_version/native/$target"

cp "$artifact"/explainthisrepo* "node_version/dist/native/$target/"
cp "$artifact"/explainthisrepo* "dotnet_version/native/$target/"
cp "$artifact"/explainthisrepo* release/
done

Expand Down Expand Up @@ -134,6 +136,26 @@ jobs:
working-directory: node_version
run: npm pack --dry-run

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Build and Pack .NET Global Tool
working-directory: dotnet_version
run: dotnet pack -c Release

- name: Add .NET Tool Package to Release
shell: bash
run: cp dotnet_version/nupkg/*.nupkg release/

- name: Publish to NuGet (Optional)
working-directory: dotnet_version
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
if: ${{ env.NUGET_API_KEY != '' }}
run: dotnet nuget push nupkg/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate

- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,8 @@ artifacts/

# macOS debug
*.dSYM

# .NET
dotnet_version/bin/
dotnet_version/obj/
dotnet_version/nupkg/
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: setup install dev test build publish clean lint format doctor build-node build-binaries run-node doctor-node
.PHONY: setup install dev test build publish clean lint format doctor build-node build-binaries run-node doctor-node build-dotnet pack-dotnet

setup: install dev

Expand Down Expand Up @@ -41,8 +41,16 @@ run-node:
doctor-node:
node node_version/dist/cli.js --doctor

# .NET targets
build-dotnet:
cd dotnet_version && dotnet build

pack-dotnet:
cd dotnet_version && dotnet pack -c Release

clean:
rm -rf dist build *.egg-info
rm -rf __pycache__ explain_this_repo/__pycache__
rm -rf node_version/dist node_version/node_modules
rm -f node_version/*.tgz *.tgz
rm -f node_version/*.tgz *.tgz
rm -rf dotnet_version/bin dotnet_version/obj dotnet_version/nupkg
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,19 @@ ExplainThisRepo uses a hybrid architecture:

> The npm and pip versions run the same core engine.

### Option 3: Download standalone binary
### Option 3: Install with .NET Tool (C# Global Tool)

Install globally and use forever (requires .NET 8, 9, or 10):

```bash
dotnet tool install -g ExplainThisRepo
explainthisrepo owner/repo

# dotnet tool install -g ExplainThisRepo
# explainthisrepo .
```

### Option 4: Download standalone binary

Prebuilt standalone binaries are available for macOS, Linux, and Windows.

Expand Down
22 changes: 22 additions & 0 deletions dotnet_version/ExplainThisRepo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<ToolCommandName>explainthisrepo</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Version>0.25.3</Version>

<Authors>Caleb Wodi</Authors>
<Description>The fastest way to understand any codebase in plain English.</Description>
<RepositoryUrl>https://github.com/calchiwo/ExplainThisRepo</RepositoryUrl>
<PackageProjectUrl>https://explainthisrepo.com/</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Update="native\**\*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
78 changes: 78 additions & 0 deletions dotnet_version/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

namespace ExplainThisRepo
{
class Program
{
static int Main(string[] args)
{
try
{
string binaryPath = GetBinaryPath();

var processInfo = new ProcessStartInfo
{
FileName = binaryPath,
UseShellExecute = false,
CreateNoWindow = true
};

foreach (var arg in args)
{
processInfo.ArgumentList.Add(arg);
}

using var process = Process.Start(processInfo);
if (process != null)
{
process.WaitForExit();
return process.ExitCode;
}

return 1;
}
catch (Exception ex)
{
Console.Error.WriteLine($"error: {ex.Message}");
return 1;
}
}

static string GetBinaryPath()
{
string targetKey = GetTargetKey();
string binaryName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "explainthisrepo.exe" : "explainthisrepo";

string launcherDir = AppContext.BaseDirectory;
string binaryPath = Path.Combine(launcherDir, "native", targetKey, binaryName);

if (!File.Exists(binaryPath))
{
throw new FileNotFoundException($"Bundled binary not found: {binaryPath}");
}

return binaryPath;
}

static string GetTargetKey()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "darwin-arm64" : "darwin-x64";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "linux-arm64" : "linux-x64";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return "win-x64";
}

throw new PlatformNotSupportedException($"Unsupported platform: {RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture}");
}
}
}