feat: Add GitRepoRegistration cmdlets #5
1 changed files with 46 additions and 0 deletions
build(git-provider): Generate initial import script
commit
5cfc4819fe
|
|
@ -122,5 +122,51 @@ public class CopyOutputTask : FrostingTask<BuildContext>
|
|||
}
|
||||
|
||||
context.Log.Information($"Bundle files copied");
|
||||
|
||||
GenerateModuleImportScript(bundleOutputLocation, context);
|
||||
// TODO: zip the bundle directory contents to NulahModule.zip, and have a top level folder inside that called NulahModule.
|
||||
// The intent is that users will drop this zip next to their $profile, and then extract the contents directly so everything
|
||||
// is contained as it should be
|
||||
}
|
||||
|
||||
private static void GenerateModuleImportScript(string bundleLocation, BuildContext context)
|
||||
{
|
||||
context.Log.Information($"Generating module import script");
|
||||
|
||||
using var scriptFile = File.Create(Path.Combine(bundleLocation, "NulahPowershell.ps1"));
|
||||
using var fileWriter = new StreamWriter(scriptFile);
|
||||
// TODO: Document the set up function
|
||||
// TODO: Create a ticket for fleshing out the set up function (or just do that work later)
|
||||
fileWriter.Write(
|
||||
"""
|
||||
# To use, first copy all files to the same location as your $profile under ./NulahModule, then open your powershell profile located at $profile and add the following:
|
||||
|
||||
# Script setup style: Using the setup script to import as needed (this method will also set custom prompts and other alias functions)
|
||||
# . "$PSScriptRoot/NulahModule/NulahPowershell.ps1"
|
||||
# SetupNulahPowershell
|
||||
# Just the module: Use the following to just import just the powershell module
|
||||
# Import-Module -Name "$PSScriptRoot/NulahModule/PowershellModule"
|
||||
|
||||
function SetupNulahPowershell
|
||||
{
|
||||
# only add to our module path once
|
||||
# The intent for this is that a user will have copied this bundle folder alongside their $profile
|
||||
# location, eg, they'll have a folder called NulahModule that will contain everything within the bundle zip
|
||||
$testBundleDirectory = $PSScriptRoot
|
||||
$bundleInPath = ($Env:PSModulePath -split ';').TrimEnd('\') -contains $testBundleDirectory;
|
||||
|
||||
if ($false -eq $bundleInPath)
|
||||
{
|
||||
$env:PSModulePath = @(
|
||||
$env:PSModulePath
|
||||
$testBundleDirectory
|
||||
) -Join [System.IO.Path]::PathSeparator
|
||||
}
|
||||
|
||||
Import-Module "PowershellModule"
|
||||
}
|
||||
"""
|
||||
);
|
||||
context.Log.Information($"Module import script created");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue