Skip to content

Commit 16be1e4

Browse files
Rollback class sorting in build pipeline
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent edc5b8c commit 16be1e4

3 files changed

Lines changed: 16 additions & 147 deletions

File tree

.github/actions/Build-PSModule/src/helpers/Build/Add-ContentFromItem.ps1

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ function Add-ContentFromItem {
2020

2121
# The root path of the module.
2222
[Parameter(Mandatory)]
23-
[string] $RootPath,
24-
25-
# Whether the folder should be loaded using dependency ordering (class/enum aware).
26-
[Parameter()]
27-
[switch] $DependencyAware
23+
[string] $RootPath
2824
)
2925
$separators = [char[]]@([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar)
3026

@@ -37,12 +33,7 @@ function Add-ContentFromItem {
3733
Write-Debug "[`$scriptName] - $relativeFolderPath - Processing folder"
3834
"@
3935

40-
if ($DependencyAware) {
41-
$files = $Path | Get-ChildItem -Recurse -File -Force -Filter '*.ps1' | Sort-Object -Property FullName
42-
$files = Get-DependencyOrderedScriptFile -Files $files
43-
} else {
44-
$files = $Path | Get-ChildItem -File -Force -Filter '*.ps1' | Sort-Object -Property FullName
45-
}
36+
$files = $Path | Get-ChildItem -File -Force -Filter '*.ps1' | Sort-Object -Property FullName
4637

4738
foreach ($file in $files) {
4839
$relativeFilePath = [System.IO.Path]::GetRelativePath($RootPath, $file.FullName)
@@ -61,11 +52,9 @@ Write-Debug "[`$scriptName] - $relativeFilePath - Done"
6152
"@
6253
}
6354

64-
if (-not $DependencyAware) {
65-
$subFolders = $Path | Get-ChildItem -Directory -Force | Sort-Object -Property Name
66-
foreach ($subFolder in $subFolders) {
67-
Add-ContentFromItem -Path $subFolder.FullName -RootModuleFilePath $RootModuleFilePath -RootPath $RootPath
68-
}
55+
$subFolders = $Path | Get-ChildItem -Directory -Force | Sort-Object -Property Name
56+
foreach ($subFolder in $subFolders) {
57+
Add-ContentFromItem -Path $subFolder.FullName -RootModuleFilePath $RootModuleFilePath -RootPath $RootPath
6958
}
7059
Add-Content -Path $RootModuleFilePath -Force -Value @"
7160
Write-Debug "[`$scriptName] - $relativeFolderPath - Done"

.github/actions/Build-PSModule/src/helpers/Build/Build-PSModuleRootModule.ps1

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
1111
1. Module header from header.ps1 file. Usually to suppress code analysis warnings/errors and to add [CmdletBinding()] to the module.
1212
2. Data loader is added if data files are available.
13-
3. Combines *.ps1 files from the following folders:
13+
3. Combines *.ps1 files from the following folders in alphabetical order from each folder:
1414
1. init
15-
2. classes (dependency-aware ordering for class/enum references)
16-
3. functions/private
17-
4. functions/public
18-
5. variables/private
19-
6. variables/public
20-
7. Any remaining *.ps1 on module root.
15+
2. classes/private
16+
3. classes/public
17+
4. functions/private
18+
5. functions/public
19+
6. variables/private
20+
7. variables/public
21+
8. Any remaining *.ps1 on module root.
2122
4. Adds a class loader for classes found in the classes/public folder.
2223
5. Export-ModuleMember by using the functions, cmdlets, variables and aliases found in the source files.
2324
- `Functions` will only contain functions that are from the `functions/public` folder.
@@ -174,26 +175,20 @@ Write-Debug "[$scriptName] - [data] - Done"
174175
#region - Add content from subfolders
175176
$scriptFoldersToProcess = @(
176177
'init',
177-
'classes',
178+
'classes/private',
179+
'classes/public',
178180
'functions/private',
179181
'functions/public',
180182
'variables/private',
181183
'variables/public'
182184
)
183185

184186
foreach ($scriptFolder in $scriptFoldersToProcess) {
185-
$dependencyAware = $scriptFolder -eq 'classes'
186187
$scriptFolderPath = Join-Path -Path $ModuleOutputFolder -ChildPath $scriptFolder
187188
if (-not (Test-Path -Path $scriptFolderPath)) {
188189
continue
189190
}
190-
$addContentParams = @{
191-
Path = $scriptFolderPath
192-
RootModuleFilePath = $rootModuleFile
193-
RootPath = $ModuleOutputFolder
194-
DependencyAware = $dependencyAware
195-
}
196-
Add-ContentFromItem @addContentParams
191+
Add-ContentFromItem -Path $scriptFolderPath -RootModuleFilePath $rootModuleFile -RootPath $ModuleOutputFolder
197192
Remove-Item -Path $scriptFolderPath -Force -Recurse
198193
}
199194
#endregion - Add content from subfolders

.github/actions/Build-PSModule/src/helpers/Build/Get-DependencyOrderedScriptFile.ps1

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)