This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Add the converter for text tables to the repository #29
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
21e9af4
Incorporate ConvertTextTable code into module.
JamesWTruher 3669a38
Remove commented out code.
JamesWTruher 76d8eb5
Update yml files for new build script.
JamesWTruher 6582c30
Install Pester 4.10.1 if it is not available.
JamesWTruher 0578174
Get some information about the test environment.
JamesWTruher 36bf7a4
Add some debugging output in case the test fails.
JamesWTruher 2f49085
Change the expected text for compare-text.
JamesWTruher 7d85284
Small change to expected string for side-by-side.
JamesWTruher e5dd55e
Another small change to side-by-side expected value.
JamesWTruher 36deecc
Update src/Microsoft.PowerShell.TextUtility.psd1
JamesWTruher 24c0ca9
Change to use netstandard2.0
JamesWTruher e4468b4
Be sure to check the proper location for the assembly for publishing.
JamesWTruher 44afeb6
Change the tests slightly to hopefully handler different versions of PS.
JamesWTruher 1092661
Mark side-by-side test to be pending because ps versions are not cons…
JamesWTruher 3b140f8
Mark the side-by-side test as pending on the filed issue.
JamesWTruher 63695d8
Address comments in PR.
JamesWTruher 01fdf7f
reduce the text lines in df test.
JamesWTruher cdb8fb3
Change parameter ColumnWidth to ColumnOffset since that's what it is.
JamesWTruher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,185 @@ | ||
## Copyright (c) Microsoft Corporation. | ||
## Licensed under the MIT License. | ||
|
||
[CmdletBinding()] | ||
# default behavior is build only | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
param ( | ||
[Parameter()] | ||
[string] | ||
$Configuration = "Debug", | ||
|
||
[Parameter()] | ||
[switch] | ||
$Clean | ||
[switch]$Publish, | ||
|
||
[Parameter()] | ||
[switch]$Test, | ||
|
||
[Parameter()] | ||
[switch]$NoBuild, | ||
|
||
[Parameter()] | ||
[switch]$Clean | ||
) | ||
|
||
try { | ||
Push-Location "$PSScriptRoot/src/code" | ||
$moduleName = "Microsoft.PowerShell.TextUtility" | ||
$projectRoot = $PSScriptRoot | ||
|
||
$srcRoot = Join-Path $ProjectRoot src | ||
$codeRoot = Join-Path $srcRoot code | ||
$tstRoot = Join-Path $ProjectRoot test | ||
$modManifest = Join-Path $srcRoot "${ModuleName}.psd1" | ||
|
||
$outPath = "$PSScriptRoot/out/Microsoft.PowerShell.TextUtility" | ||
|
||
if ($Clean) { | ||
if (Test-Path $outPath) { | ||
Write-Verbose "Deleting $outPath" | ||
Remove-Item -recurse -force -path $outPath | ||
function AssertFile { | ||
param ( | ||
[Parameter(Mandatory=$true)] | ||
[string]$Path | ||
) | ||
|
||
if (-not (Test-Path $Path)) { | ||
JamesWTruher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw "File not found: $Path" | ||
} | ||
} | ||
|
||
function Assert { | ||
param ([Parameter(Mandatory=$true)][bool]$Condition, [Parameter(Mandatory=$true)][string]$Message) | ||
if (! $Condition) { | ||
throw $Message | ||
} | ||
} | ||
|
||
foreach ($path in $srcRoot, $codeRoot, $tstRoot, $modManifest) { | ||
AssertFile $path | ||
} | ||
|
||
$modInfo = Import-PowerShellDataFile $modManifest | ||
$modVersion = $modInfo.ModuleVersion | ||
Assert ($null -ne $modVersion) "ModuleVersion is null" | ||
$pubRoot = "${PSScriptRoot}/out/${ModuleName}/${modVersion}" | ||
|
||
function Build-Assembly { | ||
if (Test-ShouldBuild) { | ||
try { | ||
Push-Location $codeRoot | ||
if($PSCmdlet.ShouldProcess($Configuration)) { | ||
dotnet build --configuration $Configuration | ||
} | ||
} | ||
finally { | ||
Pop-Location | ||
} | ||
} | ||
else { | ||
Write-Verbose -Verbose "No changes to build" | ||
} | ||
} | ||
|
||
dotnet clean | ||
function Test-ShouldBuild { | ||
$latestSourceTime = Get-LatestSourceTime | ||
$latestBuildTime = Get-LatestBuildTime | ||
return ($latestBuildTime -lt $latestSourceTime) | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
function Get-LatestFile { | ||
param ([string[]]$Path) | ||
Get-ChildItem -ErrorAction Ignore -File -Path $Path | Sort-Object LastWriteTime | Select-Object -Last 1 | ||
} | ||
|
||
function Get-LatestSourceTime { | ||
$latestFile = Get-LatestFile -path $codeRoot,"${srcRoot}/${moduleName}*" | ||
($null -eq $latestFile) ? ([datetime]0) : $latestFile.LastWriteTime | ||
} | ||
|
||
function Get-LatestPublishTime { | ||
$latestFile = Get-LatestFile $pubRoot | ||
($null -eq $latestFile) ? ([datetime]0) : $latestFile.LastWriteTime | ||
} | ||
|
||
function Get-TargetFramework { | ||
[xml]$x = Get-Content "${codeRoot}/${ModuleName}.csproj" | ||
$x.Project.PropertyGroup.TargetFramework | ||
} | ||
|
||
function Get-LatestBuildTime { | ||
$targetFramework = Get-TargetFramework | ||
$dllLocation = "${codeRoot}/bin/${Configuration}/${targetFramework}/${ModuleName}.dll" | ||
$latestFile = Get-LatestFile "${dllLocation}" | ||
($null -eq $latestFile) ? ([datetime]0) : $latestFile.LastWriteTime | ||
} | ||
|
||
# determine if the sources are younger than the published | ||
function Test-ShouldPublish { | ||
if (-not (Test-Path $pubRoot)) { | ||
return $true | ||
} | ||
$latestSourceTime = Get-LatestSourceTime | ||
$latestPublishTime = Get-LatestPublishTime | ||
return ($latestPublishTime -lt $latestSourceTime) | ||
} | ||
|
||
function Test-Module { | ||
if (Test-ShouldPublish) { | ||
Publish-Assembly | ||
} | ||
else { | ||
Write-Verbose -Verbose "No changes to publish" | ||
} | ||
try { | ||
$PSVersionTable | Out-String -Stream | Write-Verbose -Verbose | ||
$pesterInstallations = Get-Module -ListAvailable -Name Pester | ||
if ($pesterInstallations.Version -notcontains "4.10.1") { | ||
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force -Scope CurrentUser | ||
} | ||
$command = "Import-Module ${PSScriptRoot}/out/${ModuleName}; Import-Module Pester -Max 4.10.1; Invoke-Pester -OutputFormat NUnitXml -EnableExit -OutputFile ../Microsoft.PowerShell.TextUtility.xml" | ||
Push-Location $tstRoot | ||
pwsh -noprofile -command $command | ||
} | ||
finally { | ||
Pop-Location | ||
} | ||
} | ||
|
||
function Publish-Assembly { | ||
Build-Assembly # check again - the user may have used -noBuild | ||
if (Test-ShouldPublish) { | ||
if (-not (test-path $pubRoot)) { | ||
$null = New-Item -ItemType Directory -Force -Path $pubRoot | ||
} | ||
$targetFramework = Get-TargetFramework | ||
|
||
# this needs to be the list of assemblies | ||
Copy-Item "${codeRoot}/bin/${Configuration}/${targetFramework}/${ModuleName}.dll" $pubRoot -Force | ||
# module manifest and formatting | ||
Copy-Item "${SrcRoot}/dictionary.txt" $pubRoot -Force | ||
Copy-Item "${SrcRoot}/${ModuleName}.psd1" $pubRoot -Force | ||
Copy-Item "${SrcRoot}/${ModuleName}.*.ps1xml" $pubRoot -Force | ||
Write-Verbose -Verbose "Module published to $pubRoot" | ||
} | ||
else { | ||
Write-Verbose -Verbose "No changes to publish" | ||
} | ||
} | ||
|
||
if ( $Clean ) { | ||
$dirsToRemove = "${PSScriptRoot}/out", | ||
"${codeRoot}/bin", | ||
"${codeRoot}/obj" | ||
|
||
foreach ( $dir in $dirsToRemove ) { | ||
if ( Test-Path $dir ) { | ||
Remove-Item -Force -Recurse $dir | ||
} | ||
} | ||
} | ||
|
||
dotnet publish --output $outPath --configuration $Configuration | ||
if (-not $NoBuild ) { | ||
Build-Assembly | ||
} | ||
finally { | ||
Pop-Location | ||
|
||
if ( $Publish ) { | ||
Publish-Assembly | ||
} | ||
|
||
if ( $Test ) { | ||
Test-Module | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-*"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.Text.Json" Version="6.0.6" > | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this module supports PS 5.1 ensure that |
||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the xml help generated during build? we should just exclude the build folder than this specific file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it's generated by
Invoke-Pester
when-test
is used with build