@@ -66,18 +66,22 @@ if (-not $WorkingDirectory)
66
66
}
67
67
# endregion Handle Working Directory Defaults
68
68
69
+ Write-PSFMessage - Level Host - Message ' Starting Build: Client Module'
69
70
$parentModule = ' þnameþ'
70
71
if (-not $ModuleName ) { $ModuleName = ' þnameþ.Client' }
72
+ Write-PSFMessage - Level Host - Message ' Creating Folder Structure'
71
73
$workingRoot = New-Item - Path $WorkingDirectory - Name $ModuleName - ItemType Directory
72
74
$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
74
76
Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\internal" - Destination " $ ( $workingRoot.FullName ) \" - Recurse
75
77
Copy-Item - Path " $ ( $publishRoot ) \en-us" - Destination " $ ( $workingRoot.FullName ) \" - Recurse
78
+ $functionFolder = Get-Item - Path " $ ( $workingRoot.FullName ) \functions"
76
79
77
80
# region Create Functions
78
81
$encoding = [PSFEncoding ]' utf8'
79
82
$functionsText = Get-Content - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\function.ps1" - Raw
80
83
84
+ Write-PSFMessage - Level Host - Message ' Creating Functions'
81
85
foreach ($functionSourceFile in (Get-ChildItem - Path " $ ( $publishRoot ) \functions" - Recurse - Filter ' *.ps1' ))
82
86
{
83
87
Write-PSFMessage - Level Host - Message " Processing function: $ ( $functionSourceFile.BaseName ) "
@@ -106,9 +110,17 @@ foreach ($functionSourceFile in (Get-ChildItem -Path "$($publishRoot)\functions"
106
110
Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\functionOverride\$ ( $functionSourceFile.BaseName ) .ps1" - Destination $functionFolder.FullName
107
111
continue
108
112
}
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
+
109
121
# endregion Load Overrides
110
122
111
- $currentFunctionsText = $functionsText -replace ' %functionname%' , $functionSourceFile.BaseName -replace ' %condensedname%' , $condensedName
123
+ $currentFunctionsText = $functionsText -replace ' %functionname%' , $functionSourceFile.BaseName -replace ' %condensedname%' , $condensedName -replace ' %method% ' , $methodName
112
124
113
125
$parsedFunction = Read-PSMDScript - Path $functionSourceFile.FullName
114
126
$functionAst = $parsedFunction.Ast.EndBlock.Statements | Where-Object {
@@ -119,6 +131,7 @@ foreach ($functionSourceFile in (Get-ChildItem -Path "$($publishRoot)\functions"
119
131
$start = $functionAst.Body.Extent.StartOffSet + 1
120
132
$currentFunctionsText = $currentFunctionsText.Replace (' %parameter%' , $functionAst.Body.Extent.Text.SubString (1 , ($end - $start )))
121
133
134
+ Write-PSFMessage - Level Host - Message " Creating file: $ ( $functionFolder.FullName ) \$ ( $functionSourceFile.Name ) "
122
135
[System.IO.File ]::WriteAllText(" $ ( $functionFolder.FullName ) \$ ( $functionSourceFile.Name ) " , $currentFunctionsText , $encoding )
123
136
}
124
137
$functionsToExport = (Get-ChildItem - Path $functionFolder.FullName - Recurse - Filter * .ps1).BaseName | Sort-Object
@@ -136,22 +149,25 @@ $paramNewModuleManifest = @{
136
149
FunctionsToExport = $functionsToExport
137
150
CompanyName = $originalManifestData.CompanyName
138
151
Author = $originalManifestData.Author
152
+ Description = $originalManifestData.Description
153
+ ModuleVersion = $originalManifestData.ModuleVersion
139
154
RootModule = (' {0}.psm1' -f $ModuleName )
140
155
Copyright = $originalManifestData.Copyright
141
156
TypesToProcess = @ ()
142
157
FormatsToProcess = @ ()
143
158
RequiredAssemblies = @ ()
144
159
RequiredModules = @ ($prereqHash )
145
160
CompatiblePSEditions = ' Core' , ' Desktop'
146
- PowerShellVersion = 5.0
161
+ PowerShellVersion = ' 5.1 '
147
162
}
148
163
149
164
if ($IncludeAssembly ) { $paramNewModuleManifest.RequiredAssemblies = $originalManifestData.RequiredAssemblies }
150
165
if ($IncludeFormat ) { $paramNewModuleManifest.FormatsToProcess = $originalManifestData.FormatsToProcess }
151
166
if ($IncludeType ) { $paramNewModuleManifest.TypesToProcess = $originalManifestData.TypesToProcess }
152
-
167
+ Write-PSFMessage - Level Host - Message " Creating Module Manifest for module: $ModuleName "
153
168
New-ModuleManifest @paramNewModuleManifest
154
169
170
+ Write-PSFMessage - Level Host - Message " Copying additional module files"
155
171
Copy-Item - Path " $ ( $WorkingDirectory ) \azFunctionResources\clientModule\moduleroot.psm1" - Destination " $ ( $workingRoot.FullName ) \$ ( $ModuleName ) .psm1"
156
172
Copy-Item - Path " $ ( $WorkingDirectory ) \LICENSE" - Destination " $ ( $workingRoot.FullName ) \"
157
173
# endregion Create Core Module Files
@@ -172,14 +188,14 @@ if ($LocalRepo)
172
188
{
173
189
# Dependencies must go first
174
190
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
176
192
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
178
194
}
179
195
else
180
196
{
181
197
# Publish to Gallery
182
198
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
184
200
}
185
201
# endregion Publish
0 commit comments