@@ -66,18 +66,22 @@ if (-not $WorkingDirectory)
6666}
6767# endregion Handle Working Directory Defaults
6868
69+ Write-PSFMessage - Level Host - Message ' Starting Build: Client Module'
6970$parentModule = ' þnameþ'
7071if (-not $ModuleName ) { $ModuleName = ' þnameþ.Client' }
72+ Write-PSFMessage - Level Host - Message ' Creating Folder Structure'
7173$workingRoot = New-Item - Path $WorkingDirectory - Name $ModuleName - ItemType Directory
7274$publishRoot = Join-Path - Path $WorkingDirectory - ChildPath ' publish\þnameþ'
73- $functionFolder = Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\functions" - Destination " $ ( $workingRoot.FullName ) \" - Recurse - PassThru
75+ Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\functions" - Destination " $ ( $workingRoot.FullName ) \" - Recurse
7476Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\internal" - Destination " $ ( $workingRoot.FullName ) \" - Recurse
7577Copy-Item - Path " $ ( $publishRoot ) \en-us" - Destination " $ ( $workingRoot.FullName ) \" - Recurse
78+ $functionFolder = Get-Item - Path " $ ( $workingRoot.FullName ) \functions"
7679
7780# region Create Functions
7881$encoding = [PSFEncoding ]' utf8'
7982$functionsText = Get-Content - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\function.ps1" - Raw
8083
84+ Write-PSFMessage - Level Host - Message ' Creating Functions'
8185foreach ($functionSourceFile in (Get-ChildItem - Path " $ ( $publishRoot ) \functions" - Recurse - Filter ' *.ps1' ))
8286{
8387 Write-PSFMessage - Level Host - Message " Processing function: $ ( $functionSourceFile.BaseName ) "
@@ -106,9 +110,17 @@ foreach ($functionSourceFile in (Get-ChildItem -Path "$($publishRoot)\functions"
106110 Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\functionOverride\$ ( $functionSourceFile.BaseName ) .ps1" - Destination $functionFolder.FullName
107111 continue
108112 }
113+
114+ # Figure out the Rest Method to use
115+ $methodName = ' Post'
116+ if ($override.RestMethods )
117+ {
118+ $methodName = $override.RestMethods | Where-Object { $_ -ne ' Get' } | Select-Object - First 1
119+ }
120+
109121 # endregion Load Overrides
110122
111- $currentFunctionsText = $functionsText -replace ' %functionname%' , $functionSourceFile.BaseName -replace ' %condensedname%' , $condensedName
123+ $currentFunctionsText = $functionsText -replace ' %functionname%' , $functionSourceFile.BaseName -replace ' %condensedname%' , $condensedName -replace ' %method% ' , $methodName
112124
113125 $parsedFunction = Read-PSMDScript - Path $functionSourceFile.FullName
114126 $functionAst = $parsedFunction.Ast.EndBlock.Statements | Where-Object {
@@ -119,6 +131,7 @@ foreach ($functionSourceFile in (Get-ChildItem -Path "$($publishRoot)\functions"
119131 $start = $functionAst.Body.Extent.StartOffSet + 1
120132 $currentFunctionsText = $currentFunctionsText.Replace (' %parameter%' , $functionAst.Body.Extent.Text.SubString (1 , ($end - $start )))
121133
134+ Write-PSFMessage - Level Host - Message " Creating file: $ ( $functionFolder.FullName ) \$ ( $functionSourceFile.Name ) "
122135 [System.IO.File ]::WriteAllText(" $ ( $functionFolder.FullName ) \$ ( $functionSourceFile.Name ) " , $currentFunctionsText , $encoding )
123136}
124137$functionsToExport = (Get-ChildItem - Path $functionFolder.FullName - Recurse - Filter * .ps1).BaseName | Sort-Object
@@ -136,22 +149,25 @@ $paramNewModuleManifest = @{
136149 FunctionsToExport = $functionsToExport
137150 CompanyName = $originalManifestData.CompanyName
138151 Author = $originalManifestData.Author
152+ Description = $originalManifestData.Description
153+ ModuleVersion = $originalManifestData.ModuleVersion
139154 RootModule = (' {0}.psm1' -f $ModuleName )
140155 Copyright = $originalManifestData.Copyright
141156 TypesToProcess = @ ()
142157 FormatsToProcess = @ ()
143158 RequiredAssemblies = @ ()
144159 RequiredModules = @ ($prereqHash )
145160 CompatiblePSEditions = ' Core' , ' Desktop'
146- PowerShellVersion = 5.0
161+ PowerShellVersion = ' 5.1 '
147162}
148163
149164if ($IncludeAssembly ) { $paramNewModuleManifest.RequiredAssemblies = $originalManifestData.RequiredAssemblies }
150165if ($IncludeFormat ) { $paramNewModuleManifest.FormatsToProcess = $originalManifestData.FormatsToProcess }
151166if ($IncludeType ) { $paramNewModuleManifest.TypesToProcess = $originalManifestData.TypesToProcess }
152-
167+ Write-PSFMessage - Level Host - Message " Creating Module Manifest for module: $ModuleName "
153168New-ModuleManifest @paramNewModuleManifest
154169
170+ Write-PSFMessage - Level Host - Message " Copying additional module files"
155171Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\moduleroot.psm1" - Destination " $ ( $workingRoot.FullName ) \$ ( $ModuleName ) .psm1"
156172Copy-Item - Path " $ ( $WorkingDirectory ) \LICENSE" - Destination " $ ( $workingRoot.FullName ) \"
157173# endregion Create Core Module Files
@@ -172,14 +188,14 @@ if ($LocalRepo)
172188{
173189 # Dependencies must go first
174190 Write-PSFMessage - Level Important - Message " Creating Nuget Package for module: PSFramework"
175- New-PSMDModuleNugetPackage - ModulePath (Get-Module - Name PSFramework).ModuleBase - PackagePath .
191+ New-PSMDModuleNugetPackage - ModulePath (Get-Module - Name PSFramework).ModuleBase - PackagePath . - WarningAction SilentlyContinue
176192 Write-PSFMessage - Level Important - Message " Creating Nuget Package for module: þnameþ"
177- New-PSMDModuleNugetPackage - ModulePath " $ ( $publishDir .FullName ) \þnameþ " - PackagePath .
193+ New-PSMDModuleNugetPackage - ModulePath $workingRoot .FullName - PackagePath . - EnableException
178194}
179195else
180196{
181197 # Publish to Gallery
182198 Write-PSFMessage - Level Important - Message " Publishing the þnameþ module to $ ( $Repository ) "
183- Publish-Module - Path " $ ( $publishDir .FullName ) \þnameþ " - NuGetApiKey $ApiKey - Force - Repository $Repository
199+ Publish-Module - Path $workingRoot .FullName - NuGetApiKey $ApiKey - Force - Repository $Repository
184200}
185201# endregion Publish
0 commit comments