feat: Add GitRepoRegistration cmdlets #5

Merged
pascal_nulah merged 69 commits from feature/git-provider into dev 2026-09-06 09:33:36 +10:00
5 changed files with 73 additions and 32 deletions
Showing only changes of commit 6193d30029 - Show all commits

feat(git-provider): add Sqlite to PowershellModule

- add CopyLocalLockFileAssemblies to PowershellModule.csproj
- add postbuild script to copy Sqlite files and remove unneeded files in debug output
- add sqlite-net-pcl 1.11.285
Scott 2026-08-07 11:05:14 +10:00

View file

@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageVersion Include="sqlite-net-pcl" Version="1.11.285" />
<PackageVersion Include="System.IO.Packaging" Version="10.0.10" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="10.0.10" />
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.6.4" />

View file

@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Management.Automation;
using System.Management.Automation.Provider;
@ -66,35 +65,4 @@ public class GitProvider : NavigationCmdletProvider
{
throw new System.NotImplementedException();
}
}
[Cmdlet(VerbsCommon.New, Noun)]
public class RegisterGitRepo : PSCmdlet
{
private const string Noun = "GitRepo";
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipeline = true,
HelpMessage = "Reference name for the repo")]
public string Name { get; set; }
protected override void BeginProcessing()
{
var pwd = this.SessionState.Path.CurrentLocation.Path;
WriteObject("Checking if current directory is a git repository...");
var ps = new ProcessStartInfo( //$"git -C \"{pwd}\" rev-parse --show-toplevel")
"git", ["rev-parse", "--show-toplevel"])
{
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = pwd
};
var a = Process.Start(ps);
Console.WriteLine(a.StandardOutput.ReadToEnd());
Console.WriteLine(a.StandardError.ReadToEnd());
base.BeginProcessing();
}
}

View file

@ -0,0 +1,39 @@
using System;
using System.Diagnostics;
using System.Management.Automation;
using SQLite;
namespace PowershellModule.Git;
[Cmdlet(VerbsCommon.New, Noun)]
public class NewGitRepoCommand : PSCmdlet
{
private const string Noun = "GitRepo";
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipeline = true,
HelpMessage = "Reference name for the repo")]
public string Name { get; set; }
protected override void BeginProcessing()
{
using var conn = new SQLiteConnection("./test.db");
var pwd = this.SessionState.Path.CurrentLocation.Path;
WriteObject("Checking if current directory is a git repository...");
var ps = new ProcessStartInfo( //$"git -C \"{pwd}\" rev-parse --show-toplevel")
"git", ["rev-parse", "--show-toplevel"])
{
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = pwd
};
var a = Process.Start(ps);
Console.WriteLine(a.StandardOutput.ReadToEnd());
Console.WriteLine(a.StandardError.ReadToEnd());
base.BeginProcessing();
}
}

View file

@ -0,0 +1,27 @@
<#
.SYNOPSIS
Removes all non-core files from build output
#>
param(
[Parameter(ValueFromPipeline = $true, Position = 0, Mandatory = $true)]
$targetDir
)
$nativeSqliteDllLocation = "$( $targetDir )runtimes\win-x64\native\e_sqlite3.dll";
if ($false -eq (Test-Path $nativeSqliteDllLocation))
{
Write-Error "POST BUILD FAILED: Unable to locate $nativeSqliteDllLocation"
}
Write-Host "Copying '$nativeSqliteDllLocation' to '$targetDir'"
Copy-Item -Path $nativeSqliteDllLocation -Destination $targetDir
# Because we use CopyLocalLockFileAssemblies Files that are needed for the module
$allowList = @(
"ModuleCore*"
"PowershellModule*"
"*SQLite*"
)
Write-Host "Removing all non-module required files from '$targetDir'"
Get-ChildItem -Path $targetDir -exclude $allowList | Remove-Item -Recurse

View file

@ -5,16 +5,22 @@
<AssemblyName>PowershellModule</AssemblyName>
<LangVersion>latestmajor</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" >
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="sqlite-net-pcl" />
<PackageReference Include="System.Management.Automation" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModuleCore\ModuleCore.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="pwsh.exe -file &quot;$(ProjectDir)PostBuild.ps1&quot; $(TargetDir)" />
</Target>
</Project>