Skip to content

Commit cf7a159

Browse files
committed
Clean information output.
1 parent 390706e commit cf7a159

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

tools/GenerateModules.ps1

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ if($ModulePreviewNumber -eq -1) {
5454
# Install module locally in order to specify it as a dependency for other modules down the generation pipeline.
5555
# https://stackoverflow.com/questions/46216038/how-do-i-define-requiredmodules-in-a-powershell-module-manifest-psd1.
5656
$ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication" -Repository $RepositoryName -AllowPrerelease:$AllowPreRelease
57-
Write-Warning "Auth Module: $ExistingAuthModule.Name"
58-
Write-Warning "Auth Module: $ExistingAuthModule.Version"
57+
Write-Host -ForegroundColor Green "Auth Module: $($ExistingAuthModule.Name), $($ExistingAuthModule.Version)"
5958
if (!(Get-Module -Name $ExistingAuthModule.Name -ListAvailable)) {
6059
Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -Force -AllowClobber -AllowPrerelease:$AllowPreRelease
6160
}
@@ -83,7 +82,8 @@ $ModuleMapping.Keys | ForEach-Object -ThrottleLimit $ModuleMapping.Keys.Count -P
8382
}
8483

8584
$ModuleName = $_
86-
Write-Warning "Generating $ModuleName"
85+
$FullyQualifiedModuleName = "$using:ModulePrefix.$ModuleName"
86+
Write-Host -ForegroundColor Green "Generating '$FullyQualifiedModuleName' module..."
8787
$ModuleProjectDir = Join-Path $Using:ModulesOutputDir "$ModuleName\$ModuleName"
8888

8989
# Copy AutoRest readme.md config is none exists.
@@ -98,37 +98,36 @@ $ModuleMapping.Keys | ForEach-Object -ThrottleLimit $ModuleMapping.Keys.Count -P
9898
$ModuleVersion = & $Using:ReadModuleReadMePS1 -ReadMePath $ModuleLevelReadMePath -FieldToRead "module-version"
9999
if ($ModuleVersion -eq $null) {
100100
# Module version not set in readme.md.
101-
Write-Error "Version number is not set on $Using:ModulePrefix.$ModuleName module. Please set 'module-version' in $ModuleLevelReadMePath."
101+
Write-Error "Version number is not set on $FullyQualifiedModuleName module. Please set 'module-version' in $ModuleLevelReadMePath."
102102
}
103103

104104
# Validate module version with the one on PSGallery.
105-
[VersionState] $VersionState = & $Using:ValidateUpdatedModuleVersionPS1 -ModuleName "$Using:ModulePrefix.$ModuleName" -NextVersion $ModuleVersion -PSRepository RepositoryName -ModulePreviewNumber $ModulePreviewNumber
105+
[VersionState] $VersionState = & $Using:ValidateUpdatedModuleVersionPS1 -ModuleName "$FullyQualifiedModuleName" -NextVersion $ModuleVersion -PSRepository RepositoryName -ModulePreviewNumber $ModulePreviewNumber
106106

107107
if ($VersionState.Equals([VersionState]::Invalid) -and !$Using:SkipVersionCheck) {
108-
Write-Warning "The specified version in $Using:ModulePrefix.$ModuleName module is either higher or lower than what's on $Using:RepositoryName. Update the 'module-version' in $ModuleLevelReadMePath"
108+
Write-Warning "The specified version in $FullyQualifiedModuleName module is either higher or lower than what's on $Using:RepositoryName. Update the 'module-version' in $ModuleLevelReadMePath"
109109
}
110110
elseif ($VersionState.Equals([VersionState]::EqualToFeed) -and !$SkipVersionCheck) {
111-
Write-Warning "$Using:ModulePrefix.$ModuleName module skipped. Version has not changed and is equal to what's on $Using:RepositoryName."
111+
Write-Warning "$FullyQualifiedModuleName module skipped. Version has not changed and is equal to what's on $Using:RepositoryName."
112112
}
113113
elseif ($VersionState.Equals([VersionState]::Valid) -or $VersionState.Equals([VersionState]::NotOnFeed) -or $Using:SkipVersionCheck) {
114114
# Read release notes from readme.
115115
$ModuleReleaseNotes = & $Using:ReadModuleReadMePS1 -ReadMePath $ModuleLevelReadMePath -FieldToRead "release-notes"
116116
if ($ModuleReleaseNotes -eq $null) {
117117
# Release notes not set in readme.md.
118-
Write-Error "Release notes not set on $Using:ModulePrefix.$ModuleName module. Please set 'release-notes' in $ModuleLevelReadMePath."
118+
Write-Error "Release notes not set on $FullyQualifiedModuleName module. Please set 'release-notes' in $ModuleLevelReadMePath."
119119
}
120120

121121
try {
122122
# Generate PowerShell modules.
123-
Write-Host -ForegroundColor Green "Generating '$Using:ModulePrefix.$ModuleName' module..."
124123
& autorest --module-version:$ModuleVersion --service-name:$ModuleName $ModuleLevelReadMePath --verbose
125124
if ($LASTEXITCODE) {
126125
Write-Error "Failed to generate '$ModuleName' module."
127126
}
128-
Write-Host -ForegroundColor Green "AutoRest generated '$Using:ModulePrefix.$ModuleName' successfully."
127+
Write-Host -ForegroundColor Green "AutoRest generated '$FullyQualifiedModuleName' successfully."
129128

130129
# Manage generated module.
131-
Write-Host -ForegroundColor Green "Managing '$Using:ModulePrefix.$ModuleName' module..."
130+
Write-Host -ForegroundColor Green "Managing '$FullyQualifiedModuleName' module..."
132131
& $Using:ManageGeneratedModulePS1 -Module $ModuleName -ModulePrefix $Using:ModulePrefix
133132

134133
if ($Using:Build) {
@@ -146,12 +145,12 @@ $ModuleMapping.Keys | ForEach-Object -ThrottleLimit $ModuleMapping.Keys.Count -P
146145
$Profiles = Get-ChildItem -Path $ModuleExportsPath -Directory | %{ $_.Name}
147146

148147
# Update module manifest wiht profiles.
149-
$ModuleManifestPath = Join-Path $ModuleProjectDir "$Using:ModulePrefix.$ModuleName.psd1"
148+
$ModuleManifestPath = Join-Path $ModuleProjectDir "$FullyQualifiedModuleName.psd1"
150149
[HashTable]$PrivateData = @{ Profiles = $Profiles }
151150
Update-ModuleManifest -Path $ModuleManifestPath -PrivateData $PrivateData
152151

153152
# Update module psm1 with Graph session profile name.
154-
$ModulePsm1 = Join-Path $ModuleProjectDir "/$Using:ModulePrefix.$ModuleName.psm1"
153+
$ModulePsm1 = Join-Path $ModuleProjectDir "/$FullyQualifiedModuleName.psm1"
155154
(Get-Content -Path $ModulePsm1) | ForEach-Object{
156155
if ($_ -match '\$instance = \[Microsoft.Graph.PowerShell.Module\]::Instance') {
157156
# Update main psm1 with Graph session profile name and module name.
@@ -161,13 +160,15 @@ $ModuleMapping.Keys | ForEach-Object -ThrottleLimit $ModuleMapping.Keys.Count -P
161160
# Rename all Azure instances in psm1 to `Microsoft Graph`.
162161
$updatedLine = $_ -replace 'Azure', 'Microsoft Graph'
163162
# Replace all 'instance.Name' declarations with fully qualified module name.
164-
$updatedLine = $updatedLine -replace '\$\(\$instance.Name\)', "$ModulePrefix.$ModuleName"
163+
$updatedLine = $updatedLine -replace '\$\(\$instance.Name\)', "$FullyQualifiedModuleName"
164+
# Replace Write-Information with Write-Debug
165+
$updatedLine = $updatedLine -replace 'Write\-Information', 'Write-Debug'
165166
$updatedLine
166167
}
167168
} | Set-Content $ModulePsm1
168169

169170
# Address AutoREST bug where it looks for exports in the wrong directory.
170-
$InternalModulePsm1 = Join-Path $ModuleProjectDir "/internal/$Using:ModulePrefix.$ModuleName.internal.psm1"
171+
$InternalModulePsm1 = Join-Path $ModuleProjectDir "/internal/$FullyQualifiedModuleName.internal.psm1"
171172
(Get-Content -Path $InternalModulePsm1) | ForEach-Object{
172173
$updatedLine = $_
173174
# Address AutoREST bug where it looks for exports in the wrong directory.

0 commit comments

Comments
 (0)