8000 Updated all functions with prefix. Added back functions that where re… · ModuleBuild/ModuleBuild@0b36e44 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b36e44

Browse files
committed
Updated all functions with prefix. Added back functions that where removed from ModuleBuildToolsTemp. Bumped version of ModuleBuildToolsTemp. Updated build scripts to fix issues with building modules that are also a dependency
1 parent dca36c8 commit 0b36e44

File tree

81 files changed

+6331
-1461
lines changed

Some content is hidden

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

81 files changed

+6331
-1461
lines changed

ModuleBuild.build.ps1

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,36 @@ task RunIntergrationTests LoadRequiredModules, {
293293
task CreateMarkdownHelp GetPublicFunctions, {
294294
Write-Description White 'Creating markdown documentation with PlatyPS' -accent
295295

296+
$BuildToolPath = Join-Path $BuildRoot $Script:BuildEnv.BuildToolFolder
296297
$ScratchPath = Join-Path $BuildRoot $Script:BuildEnv.ScratchFolder
297298
$StageReleasePath = Join-Path $ScratchPath $Script:BuildEnv.BaseReleaseFolder
298299
Copy-Item -Path (Join-Path $ScratchPath "en-US") -Recurse -Destination $StageReleasePath -Force
299300
$OnlineModuleLocation = "$($Script:BuildEnv.ModuleWebsite)/$($Script:BuildEnv.BaseReleaseFolder)"
300301
$FwLink = "$($OnlineModuleLocation)/$($Script:BuildEnv.ModuleToBuild)/docs/$($Script:BuildEnv.ModuleToBuild).md"
301302
$ModulePage = "$($StageReleasePath)\docs\$($Script:BuildEnv.ModuleToBuild).md"
302303

304+
# If the current module we are building is also loaded as a dependency with PSDepend,
305+
# Unload it temporally and reload it from the scratchpath to build markdown files from.
306+
if (Get-Module $Script:BuildEnv.ModuleToBuild | Where-Object {$_.Path -like "*PSDepend\$($Script:BuildEnv.ModuleToBuild)*"}) {
307+
$TempDeload = $true
308+
#Write-Verbose "$($(Get-Module $Script:BuildEnv.ModuleToBuild).Path)"
309+
#Get-Command | Where-Object { $_.source -eq 'ModuleBuildToolsTemp'} | ForEach-Object {
310+
# Remove-Item -Path Function:\$($_.Name)
311+
#}
312+
#while ($(Get-Module $Script:BuildEnv.ModuleToBuild)) {
313+
Get-Module $Script:BuildEnv.ModuleToBuild | Remove-Module
314+
#}
315+
$TempModule = Join-Path $ScratchPath "$($Script:BuildEnv.ModuleToBuild).psd1"
316+
try {
317+
[void](Import-Module $TempModule -Force)
318+
}
319+
catch {
320+
throw "Unable to load the project module: $($TempModule)"
321+
}
322+
Write-Verbose $($(Get-Module $Script:BuildEnv.ModuleToBuild).Path)
323+
324+
}
325+
303326
# Create the function .md files and the generic module page md as well for the distributable module
304327
$null = New-MarkdownHelp -module $Script:BuildEnv.ModuleToBuild -OutputFolder "$($StageReleasePath)\docs\" -Force -WithModulePage -Locale 'en-US' -FwLink $FwLink -HelpVersion $Script:BuildEnv.ModuleVersion -Encoding ([System.Text.Encoding]::($Script:BuildEnv.Encoding))
305328
$null = Update-MarkdownHelpModule -Path "$($StageReleasePath)\docs\" -Force -RefreshModulePage
@@ -327,6 +350,13 @@ task CreateMarkdownHelp GetPublicFunctions, {
327350

328351
throw 'Missing documentation. Please review and rebuild.'
329352
}
353+
# If modules where unloaded, reload them with PSDepend
354+
if ($TempDeload) {
355+
while ($(Get-Module $Script:BuildEnv.ModuleToBuild)) {
356+
Get-Module $Script:BuildEnv.ModuleToBuild | Remove-Module
357+
}
358+
Invoke-PSDepend -Path $(Join-Path $BuildToolPath 'dependencies\PSDepend\build.depend.psd1') -Import -Force
359+
}
330360
}
331361

332362
# Synopsis: Build the markdown help files with PlatyPS
@@ -360,11 +390,42 @@ task CreateUpdateableHelpCAB {
360390
# Synopsis: Build the markdown help for the functions using PlatyPS for the core project docs.
361391
task BuildProjectHelpFiles {
362392
Write-Description White 'Creating markdown documentation with PlatyPS for the core project' -accent
393+
$BuildToolPath = Join-Path $BuildRoot $Script:BuildEnv.BuildToolFolder
394+
$ScratchPath = Join-Path $BuildRoot $Script:BuildEnv.ScratchFolder
395+
363396
$OnlineModuleLocation = "$($Script:BuildEnv.ModuleWebsite)/$($Script:BuildEnv.BaseReleaseFolder)"
364397
$FwLink = "$($OnlineModuleLocation)/docs/Functions/$($Script:BuildEnv.ModuleToBuild).md"
365398

399+
# If the current module we are building is also loaded as a dependency with PSDepend,
400+
# Unload it temporally and reload it from the scratchpath to build markdown files from.
401+
if (Get-Module $Script:BuildEnv.ModuleToBuild | Where-Object {$_.Path -like "*PSDepend\$($Script:BuildEnv.ModuleToBuild)*"}) {
402+
$TempDeload = $true
403+
#Write-Verbose "$($(Get-Module $Script:BuildEnv.ModuleToBuild).Path)"
404+
#Get-Command | Where-Object { $_.source -eq 'ModuleBuildToolsTemp'} | ForEach-Object {
405+
# Remove-Item -Path Function:\$($_.Name)
406+
#}
407+
#while ($(Get-Module $Script:BuildEnv.ModuleToBuild)) {
408+
Get-Module $Script:BuildEnv.ModuleToBuild | Remove-Module
409+
#}
410+
$TempModule = Join-Path $ScratchPath "$($Script:BuildEnv.ModuleToBuild).psd1"
411+
try {
412+
[void](Import-Module $TempModule -Force)
413+
}
414+
catch {
415+
throw "Unable to load the project module: $($TempModule)"
416+
}
417+
}
418+
366419
# Create the function .md files for the core project documentation
367420
$null = New-MarkdownHelp -module $Script:BuildEnv.ModuleToBuild -OutputFolder "$($BuildRoot)\docs\Functions\" -Force -Locale 'en-US' -FwLink $FwLink -HelpVersion $Script:BuildEnv.ModuleVersion -Encoding ([System.Text.Encoding]::($Script:BuildEnv.Encoding)) #-OnlineVersionUrl "$($Script:BuildEnv.ModuleWebsite)/docs/Functions"
421+
422+
# If modules where unloaded, reload them with PSDepend
423+
if ($TempDeload) {
424+
while ($(Get-Module $Script:BuildEnv.ModuleToBuild)) {
425+
Get-Module $Script:BuildEnv.ModuleToBuild | Remove-Module
426+
}
427+
Invoke-PSDepend -Path $(Join-Path $BuildToolPath 'dependencies\PSDepend\build.depend.psd1') -Import -Force
428+
}
368429
}
369430

370431
# Synopsis: Add additional doc files to the final project document folder

build/ModuleBuild.buildenvironment.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if ((Get-Variable 'BuildEnv' -ErrorAction:SilentlyContinue) -eq $null) {
6161
FunctionTemplates = "src\templates" # Location of function template files (*.tem)
6262

6363
# If you will be publishing to the PowerShell Gallery you will need a Nuget API key (can get from the website)
64-
# You should NOT enter this key here but rather manually enter it in the ModuleBuild.buildenvironment.json file with: Set-MBTBuildEnvironment -NugetAPIKey '<key>'
64+
# You should NOT enter this key here but rather manually enter it in the ModuleBuild.buildenvironment.json file with: Set-MBBuildEnvironment -NugetAPIKey '<key>'
6565

6666
NugetAPIKey = ''
6767
}

build/dependencies/PSDepend/build.depend.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
source = 'PSGalleryModule'
2121
}
2222
ModuleBuildToolsTemp = @{
23-
version = '0.0.6'
23+
version = '0.0.7'
2424
source = 'PSGalleryModule'
2525
}
2626
}

build/docs/Additional/ChangeLog.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe
88
- Fixed issue with Make.ps1 By adding --tags --always
99
- Fixed issue with Make.ps1. Write-Description -level 3 should be used instead of Write-Output
1010
- Fixed issue with Get-SpecialPaths function by adding LoadBuildTools on InstallAndTestModule
11-
- Fixed issue with -SourceModule parameter on Initialize-ModuleBuild
11+
- Fixed issue with -SourceModule parameter on Initialize-MBModuleBuild
1212
- Fixed issue with the -AddCBH when there are no Params.
1313
- Fixed issue with URLS in README.md. It was missing links to VSCode and the PS Extension.
1414
- Fixed issue with the link to ChangeLog. ChangeLog in index.md was plural.
@@ -32,15 +32,15 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe
3232

3333
## Version 0.2.3
3434

35-
- Added ability to pull in some basic information about an existing module manifest files when running initialize-modulebuild.
35+
- Added ability to pull in some basic information about an existing module manifest files when running Initialize-MBModuleBuild.
3636
- Fixed ReadTheDocs generation issues by updating the template to include build\docs\ReadTheDocs in the initialization process.
3737
- Eliminated any customization requirements within the modulename.build.ps1 script to help pave the way for easier modulebuild upgrades to projects.
3838
- Removed some superfluous code in the base build environment script around the RequiredModules variable.
3939

4040
## Version 0.2.2
4141

4242
- Updated vscode tasks.json to fix depreciated syntax.
43-
- Fixed `-Force` switch processing on Add-PublicFunction to still create the function if the provided name is detected as plural.
43+
- Fixed `-Force` switch processing on Add-MBPublicFunction to still create the function if the provided name is detected as plural.
4444
- Fixed [cleanup script modulebuild execution issue](https://github.com/zloeber/ModuleBuild/issues/5) by separating out the postbuildtask into its own Invoke-Build code block (I had done this a while ago and never rolled up the changes into the Plaster template).
4545
- Fixed a glaring issue with the PlatyPS output where any Guids were 00000000-0000-0000-0000-000000000000 instead of the actual module manifest Guid [reported via issue #6](https://github.com/zloeber/ModuleBuild/issues/6). This happens because we build the module help from the psm1 load of the module in memory, not the psd1 file as that psd1 manifest gets recreated at build time with the appropriate exported functions and such. Basically a chicken/egg scenario. For now we just manually replace the output markdown files with the correct Guid before moving on to the help file packaging.
4646

@@ -57,7 +57,7 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe
5757

5858
## Version 0.1.9
5959

60-
- Removed plaster option to choose to combine the module source at build time (and simply made that behavior the default that can be changed later via Set-MBTBuildEnvironment -OptionCombineFiles $false)
60+
- Removed plaster option to choose to combine the module source at build time (and simply made that behavior the default that can be changed later via Set-MBBuildEnvironment -OptionCombineFiles $false)
6161
- Added option to run a code health report (via PSCodeHealth) against your public and private function directories prior to starting the build
6262
- Added 'Module plugin' capability. This adds base functionality to the module project itself. The first included module plugin is the nlogmodule logging functionality.
6363

@@ -70,7 +70,7 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe
7070

7171
- Fixed awful .gitignore settings included in the default scaffolding
7272
- Fixed documentation links to be self-referencing
73-
- Removed AdditionalModulePaths from initial plaster manifest (can just set this with Set-MBTBuildEnvironment after creation)
73+
- Removed AdditionalModulePaths from initial plaster manifest (can just set this with Set-MBBuildEnvironment after creation)
7474

7575
## Version 0.1.4
7676

@@ -85,13 +85,13 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe
8585
## Version 0.1.2
8686

8787
- Updated vs code task names
88-
- Fixed an issue with a null build environment variable causing dynamic parameters in Set-MBTBuildEnvironment to fail
88+
- Fixed an issue with a null build environment variable causing dynamic parameters in Set-MBBuildEnvironment to fail
8989
- Several small scaffolding clean ups.
9090

9191
## Version 0.1.1
9292

93-
- Removed prompts for the nuget api key when running initialize-modulebuild.
94-
- Initialize-ModuleBuild now automatically runs the build environment powershell script for the first time to create the modulebuild json settings file.
93+
- Removed prompts for the nuget api key when running Initialize-MBModuleBuild.
94+
- Initialize-MBModuleBuild now automatically runs the build environment powershell script for the first time to create the modulebuild json settings file.
9595
- More documentation.
9696
- Fixed some minor scaffolding creation issues.
9797
- Added a 'ForceInstallModule' setting to eliminate build prompt when running the install and test module build tasks when the module is already installed.

build/docs/ReadTheDocs/Usage/1 - Initialization.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Step 1 - Initialization
2-
Simply download this project and run the Initialize-ModuleBuild exported function. You will be prompted for a destination folder and the rest of the project settings. The destination folder will be the home of your future project but is completely portable. This is simply a wrapper for a custom version of Plaster that calls a template file I created for the project. It is fairly simple to deconstruct and use plaster directly via invoke-plaster and pass all the parameters via command line if desired.
2+
Simply download this project and run the Initialize-MBModuleBuild exported function. You will be prompted for a destination folder and the rest of the project settings. The destination folder will be the home of your future project but is completely portable. This is simply a wrapper for a custom version of Plaster that calls a template file I created for the project. It is fairly simple to deconstruct and use plaster directly via invoke-plaster and pass all the parameters via command line if desired.
33

44
`Import-Module ModuleBuild`
55

6-
`Initialize-ModuleBuild`
6+
`Initialize-MBModuleBuild`
77

88
or
99

10-
`Initialize-ModuleBuild -Path 'c:\temp\mymodule'`
10+
`Initialize-MBModuleBuild -Path 'c:\temp\mymodule'`
1111

1212

1313
Once this has been kicked off and all answers have been entered, the initialization of your new project directory will start. Several template files are copied out to appropriate locations. Additionally, the default module manifest file gets created.
@@ -17,7 +17,7 @@ Once this has been kicked off and all answers have been entered, the initializat
1717
## Quick Start
1818
With your new module folder all created there are several steps still left to take in order to make your new project more world class. There are several sections of the following documentation that go over fleshing out the module with public functions, building a release, testing things, out and starting another release. Here are some quick next step tips if you aren't feeling like reading all of that.
1919

20-
1. Add public functions, one per file, to .\src\public (You can use the ModuleBuild function 'Add-PublicFunction' for this task)
20+
1. Add public functions, one per file, to .\src\public (You can use the ModuleBuild function 'Add-MBPublicFunction' for this task)
2121
2. Update your default readme.md file at the root project directory
2222
3. Update the about_ModuleName.help.txt file within .\build\docs\en-US
2323
4. Doing ReadTheDocs integration? Cool, update .\build\docs\ReadTheDocs by creating folders representing sections and putting markdown files within them for the pages within those sections.

build/docs/ReadTheDocs/Usage/10 - Converting To ModuleBuild.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
If you want to convert your existing module to a modulebuild based project then there are a few functions that have been created to help you along. These are a bit new and should be considered a feature in testing.
44

5-
## Public Functions: Import-ModulePublicFunction
5+
## Public Functions: Import-MBModulePublicFunction
66

77
Assuming your existing module is loadable it is pretty simple to determine public functions and then search through all of the module code for them. That is what this function will do. Once the public function has been found it will then (by default) attempt to insert the bare minimum comment based help necessary for PlatyPS to be able to autogenerate the module documentation and save the file into your ModuleBuild project public directory (as defined by your modulebuild project definition file).
88

99
This will not overwrite any files that exist by the same name.
1010

11-
## Private Functions: Import-ModulePrivateFunction
11+
## Private Functions: Import-MBModulePrivateFunction
1212

13-
Private functions within a module are infinately more tricky to isolate. But based on what is exported and what we find within the module source directory, it is not impossible to guess some of the private functions at least. That is what Import-ModulePrivateFunction command will do. It will always prompt you before importing any found top-level function (that isn't in the list of exported functions).
13+
Private functions within a module are infinately more tricky to isolate. But based on what is exported and what we find within the module source directory, it is not impossible to guess some of the private functions at least. That is what Import-MBModulePrivateFunction command will do. It will always prompt you before importing any found top-level function (that isn't in the list of exported functions).
1414

1515
Like the public function import, this will not overwrite any files that exist in your public source directory.
1616

@@ -20,8 +20,8 @@ So in order to convert an existing project to a modulebuild project you will fol
2020

2121
1. Initialize a new ModuleBuild project folder
2222
2. ~~**Build** the project (**and it will fail the first time**). This ensures that your modulebuild project settings have been exported at least once.~~
23-
3. From your new modulebuild project folder run the Import-ModulePrivateFunction command against your existing module.
24-
4. From your new modulebuild project folder run the Import-ModulePublicFunction command against your existing module.
23+
3. From your new modulebuild project folder run the Import-MBModulePrivateFunction command against your existing module.
24+
4. From your new modulebuild project folder run the Import-MBModulePublicFunction command against your existing module.
2525
5. Add any required preload or postload code in src\other\preload.ps1 or src\other\postload.ps1
2626

2727
## Very Important Notes

build/docs/ReadTheDocs/Usage/2 - Make Your Module.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ After the initialization has completed this directory should be all setup and 'b
66

77
Any exportable/public functions for your module should be dropped into the .\src\public folder. Ideally each function will be self contained with a file name that matches the function name. Any other private functions can be dropped into .\src\private.
88

9-
You can easily add a new public function using templates of your own devising with the `Add-PublicFunction` command. To add a new public function with a rather bare template function run the following:
9+
You can easily add a new public function using templates of your own devising with the `Add-MBPublicFunction` command. To add a new public function with a rather bare template function run the following:
1010

11-
`Add-PublicFunction -Name 'New-TestFunction' -TemplateName:PlainPublicFunction`
11+
`Add-MBPublicFunction -Name 'New-TestFunction' -TemplateName:PlainPublicFunction`
1212

1313
The allowed template names are dynamically pulled directly from the module src\templates directory. Look in this folder for an example template and feel free to add more of your own to suit your project needs.
1414

0 commit comments

Comments
 (0)
0