Skip to content

Commit e20e409

Browse files
Merge branch 'main' into switch-symver-to-semver
Signed-off-by: Gilbert Sanchez <me@gilbertsanchez.com>
2 parents 0749c55 + 16113c8 commit e20e409

68 files changed

Lines changed: 315 additions & 282 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"**/*.code-search": true,
1717
"**/.ruby-lsp": true,
1818
"Output/**": true
19-
}
20-
}
19+
},
20+
"snyk.advanced.autoSelectOrganization": true
21+
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
<!-- cspell:ignore parenthesization yess -->
4+
35
All notable changes to this project will be documented in this file.
46

57
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

Examples/ModuleDependencies.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Handling Module Dependencies
22

3+
<!-- cspell:ignore azcopy msiexec -->
4+
35
`Install-Module` handles dependencies declared in a module manifest's `RequiredModules` section, but it only covers the PowerShell Gallery. PSDepend lets you declare dependencies from multiple sources — Gallery modules, Git repos, and file downloads — in one place.
46

57
This walkthrough demonstrates embedding a `requirements.psd1` in a module so dependencies are resolved automatically on import.
@@ -22,7 +24,7 @@ Invoke-PSDepend -Path $PSScriptRoot\Requirements.psd1 -Target $PSScriptRoot\Depe
2224
2325
Import-Module Posh-SSH
2426
25-
Function Test-PSDependExample {
27+
function Test-PSDependExample {
2628
Get-ChildItem $PSScriptRoot\Dependencies -Recurse -Depth 1 | Select-Object -ExpandProperty FullName
2729
Get-Module | Select-Object Name, Path
2830
}

PSDepend/PSDepend.Format.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ListItem>
2222
<ListItem>
2323
<Label>Tags</Label>
24-
<ScriptBlock>Try { ($_.Tags | Out-String ).trimend("`n")} Catch {$_.Tags} </ScriptBlock>
24+
<ScriptBlock>Try { ($_.Tags | Out-String ).TrimEnd("`n")} Catch {$_.Tags} </ScriptBlock>
2525
</ListItem>
2626
</ListItems>
2727
</ListEntry>

PSDepend/PSDependScripts/Chocolatey.ps1

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<#
1+
# cspell:ignore lessmsi
2+
<#
23
.SYNOPSIS
34
Installs a package from a Chocolatey repository.
45
@@ -91,8 +92,7 @@ function Get-ChocoVersion {
9192
# Strip prerelease/build metadata (e.g. 2.2.2-beta) before parsing
9293
if ([System.Version]::TryParse(($rawVersion -replace '[-+].*$'), [ref]$parsedVersion)) {
9394
$parsedVersion
94-
}
95-
else {
95+
} else {
9696
# Assume a modern CLI when the version cannot be determined
9797
[System.Version]'2.0'
9898
}
@@ -243,8 +243,7 @@ if (-not (Get-Command -Name 'choco.exe' -ErrorAction SilentlyContinue)) {
243243
try {
244244
Invoke-WebRequest -UseBasicParsing -Uri $ChocoInstallScriptUrl -OutFile $scriptPath
245245
& $scriptPath
246-
}
247-
catch {
246+
} catch {
248247
throw "Unable to install Chocolatey from '$ChocoInstallScriptUrl'."
249248
}
250249
}
@@ -274,8 +273,7 @@ Write-Verbose "Getting package [$Name] version, if it is installed."
274273
$existingVersion = (Get-ChocoInstalledPackage -Name $Name).Version
275274
if ($existingVersion) {
276275
Write-Verbose "Found package [$Name] installed with version [$existingVersion]."
277-
}
278-
else {
276+
} else {
279277
Write-Verbose "Package [$Name] not installed."
280278
}
281279

@@ -302,8 +300,7 @@ Write-Verbose "Getting latest package [$Name] version from source [$Source]."
302300
$repositoryVersion = (Get-ChocoLatestPackage @repoParams).Version
303301
if ($repositoryVersion) {
304302
Write-Verbose "Found package [$Name] version [$repositoryVersion] on source [$Source]."
305-
}
306-
else {
303+
} else {
307304
Write-Verbose "Package [$Name] not found on source [$Source]. Nothing more can be done."
308305
return # cannot continue
309306
}
@@ -318,14 +315,12 @@ $haveLatest = if (
318315
[System.Management.Automation.SemanticVersion]::TryParse([string]$existingVersion, [ref]$parsedExistingSemanticVersion)
319316
) {
320317
$parsedRepositorySemanticVersion -le $parsedExistingSemanticVersion
321-
}
322-
elseif (
318+
} elseif (
323319
[System.Version]::TryParse([string]$repositoryVersion, [ref]$parsedRepositoryVersion) -and
324320
[System.Version]::TryParse([string]$existingVersion, [ref]$parsedExistingVersion)
325321
) {
326322
$parsedRepositoryVersion -le $parsedExistingVersion
327-
}
328-
else {
323+
} else {
329324
$false
330325
}
331326
if ($Version -eq 'latest' -and $haveLatest) {
@@ -353,7 +348,6 @@ if ($PSDependAction -contains 'Install') {
353348
}
354349

355350
Invoke-ChocoInstallPackage @params
356-
}
357-
elseif ($PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
351+
} elseif ($PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
358352
return $false
359353
}

PSDepend/PSDependScripts/Command.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
}
3434
}
3535
36-
# Run some aribtrary PowerShell code that assigns a variable and uses it in a string
36+
# Run some arbitrary PowerShell code that assigns a variable and uses it in a string
3737
# Output: Running a command on WJ-LAB
3838
#>
39-
[cmdletbinding()]
39+
[CmdletBinding()]
4040
param (
4141
[PSTypeName('PSDepend.Dependency')]
42-
[psobject[]]$Dependency,
42+
[PSObject[]]$Dependency,
4343

4444
[switch]$FailOnError,
4545

PSDepend/PSDependScripts/DotnetSdk.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
}
4545
4646
# Simple syntax
47-
# The .NET SDK will be installed with the latest verion from the LTS channel, globally.
47+
# The .NET SDK will be installed with the latest version from the LTS channel, globally.
4848
4949
#>
5050
[CmdletBinding()]
5151
param(
5252
[PSTypeName('PSDepend.Dependency')]
53-
[psobject[]]
53+
[PSObject[]]
5454
$Dependency,
5555

5656
[ValidateSet('Test', 'Install', 'Import')]
@@ -60,7 +60,7 @@ param(
6060

6161
# Users can specify 'Global which will use the default global path of
6262
# "$env:LocalAppData\Microsoft\dotnet" on Windows or "$env:HOME/.dotnet" elsewhere
63-
# Since Global is the default behavior, we ingore the fact that the Target was set.
63+
# Since Global is the default behavior, we ignore the fact that the Target was set.
6464
$InstallDir = if ($Dependency.Target -and $Dependency.Target -ne 'Global') { $Dependency.Target }
6565
$Version = $Dependency.Version
6666
$Channel = if ($Dependency.DependencyName) { $Dependency.DependencyName } else { "release" }

PSDepend/PSDependScripts/FileDownload.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<#
1+
# cspell:ignore extensionless sqllite
2+
<#
23
.SYNOPSIS
34
Download a file
45
@@ -35,18 +36,18 @@
3536
3637
# Downloads System.Data.SQLite.dll to C:\temp\sqlite.dll
3738
#>
38-
[cmdletbinding()]
39+
[CmdletBinding()]
3940
param(
4041
[PSTypeName('PSDepend.Dependency')]
41-
[psobject[]]
42+
[PSObject[]]
4243
$Dependency,
4344

4445
[ValidateSet('Test', 'Install')]
4546
[string[]]$PSDependAction = @('Install')
4647
)
4748

4849
function Parse-URLForFile {
49-
[cmdletbinding()]
50+
[CmdletBinding()]
5051
param($URL)
5152
# This will need work. Assume leaf is file. If CGI exists in leaf, assume it is after the file
5253
$FileName = $URL.split('/')[-1]

PSDepend/PSDependScripts/FileSystem.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<#
1+
# cspell:ignore psams
2+
<#
23
.SYNOPSIS
34
EXPERIMENTAL: Use Robocopy or Copy-Item for folder and file dependencies, respectively.
45
@@ -59,10 +60,10 @@
5960
# Copy psams module to C:\ProjectX\psams
6061
6162
#>
62-
[cmdletbinding()]
63+
[CmdletBinding()]
6364
param (
6465
[PSTypeName('PSDepend.Dependency')]
65-
[psobject[]]
66+
[PSObject[]]
6667
$Dependency,
6768

6869
[ValidateSet('Test', 'Install', 'Import')]

PSDepend/PSDependScripts/Git.ps1

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<#
1+
# cspell:ignore jdoe TrimEnd
2+
<#
23
.SYNOPSIS
34
Clone a git repository
45
@@ -53,14 +54,14 @@
5354
5455
# Simple syntax
5556
# First example shows cloning PSDeploy from ramblingcookiemonster's GitHub repo
56-
# Second example shows clonging BuildHelpers from jdoe's internal GitLab account and checking out a specific commit
57+
# Second example shows cloning BuildHelpers from jdoe's internal GitLab account and checking out a specific commit
5758
# Both are cloned to the current path (e.g. .\<repo name>)
5859
# This syntax assumes git as a source. The right hand side is the version (branch, commit, tags/<tag name>, etc.)
5960
#>
60-
[cmdletbinding()]
61+
[CmdletBinding()]
6162
param(
6263
[PSTypeName('PSDepend.Dependency')]
63-
[psobject[]]$Dependency,
64+
[PSObject[]]$Dependency,
6465

6566
[switch]$Force,
6667

@@ -84,16 +85,14 @@ if (-not $Name) {
8485
if ($Name -match "^[a-zA-Z0-9]+/[a-zA-Z0-9_-]+$") {
8586
$Name = "https://github.com/$Name.git"
8687
}
87-
$GitName = $Name.trimend('/').split('/')[-1] -replace "\.git$", ''
88+
$GitName = $Name.TrimEnd('/').split('/')[-1] -replace "\.git$", ''
8889
if ($Dependency.Target -and ($Target = (Get-Item $Dependency.Target -ErrorAction SilentlyContinue).FullName)) {
8990
Write-Debug "Target resolved to $Target"
90-
}
91-
else {
91+
} else {
9292
if ($Dependency.Target) {
9393
$Target = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Dependency.Target)
9494
Write-Debug "Target $($Dependency.Target) does not exist yet, will be created"
95-
}
96-
else {
95+
} else {
9796
$Target = $PWD.Path
9897
Write-Debug "Target defaulted to current dir: $Target"
9998
}
@@ -111,8 +110,8 @@ if (-not (Test-Path $RepoPath)) {
111110
if ( $PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
112111
return $False
113112
}
114-
}
115-
else { # Target exists
113+
} else {
114+
# Target exists
116115
$GottaTest = $True
117116
}
118117

@@ -129,28 +128,25 @@ if (-not $Version) {
129128
if ($GottaTest) {
130129
Push-Location
131130
Set-Location $RepoPath
132-
$Branch = Invoke-ExternalCommand git -Arguments (Write-Output rev-parse --abbrev-ref HEAD) -Passthru
133-
$Commit = Invoke-ExternalCommand git -Arguments (Write-Output rev-parse HEAD) -Passthru
131+
$Branch = Invoke-ExternalCommand git -Arguments (Write-Output rev-parse --abbrev-ref HEAD) -PassThru
132+
$Commit = Invoke-ExternalCommand git -Arguments (Write-Output rev-parse HEAD) -PassThru
134133
Pop-Location
135134
if (-not $Branch) {
136135
Write-Warning "[$RepoPath] exists but does not appear to be a valid git repository. Skipping [$DependencyName]."
137136
if ($PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
138137
return $false
139138
}
140139
$GottaInstall = $False
141-
}
142-
elseif ($Version -eq $Branch -or $Version -eq $Commit) {
140+
} elseif ($Version -eq $Branch -or $Version -eq $Commit) {
143141
Write-Verbose "[$RepoPath] exists and is already at version [$Version]"
144142
if ($PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
145143
return $true
146144
}
147145
$GottaInstall = $False
148-
}
149-
elseif ($PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
146+
} elseif ($PSDependAction -contains 'Test' -and $PSDependAction.count -eq 1) {
150147
Write-Verbose "[$RepoPath] exists and is at branch [$Branch], commit [$Commit].`nWe don't currently support moving to the requested version [$Version]"
151148
return $false
152-
}
153-
else {
149+
} else {
154150
Write-Verbose "[$RepoPath] exists and is at branch [$Branch], commit [$Commit].`nWe don't currently support moving to the requested version [$Version]"
155151
$GottaInstall = $False
156152
}
@@ -171,8 +167,7 @@ if ($GottaInstall -and !$ExtractProject) {
171167
Write-Verbose -Message "Checking out [$Version] of [$Name] from [$RepoPath]"
172168
Invoke-ExternalCommand git 'checkout', $Version
173169
Pop-Location
174-
}
175-
elseif ($GottaInstall -and $ExtractProject) {
170+
} elseif ($GottaInstall -and $ExtractProject) {
176171
$OutPath = Join-Path ([System.IO.Path]::GetTempPath()) ([guid]::NewGuid().guid)
177172
$RepoFolder = Join-Path -Path $OutPath -ChildPath $GitName
178173

0 commit comments

Comments
 (0)