diff --git a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 index 910a36f..828e6cc 100644 --- a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 +++ b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 @@ -1,4 +1,6 @@ +$TOOLS_RELATIVE_PATH = "tools" + function TestingHelperTest_AssertAddSection_throwOnNull{ # All asserts here has a pattern # This test will confirm tht the pattern will not miss a false negative @@ -27,20 +29,6 @@ function Assert-AddDevContainerJson{ } } -# Git Repository -function Assert-AddGitRepository{ - param( - [Parameter(Mandatory,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)] - [Alias("PSPath")][ValidateNotNullOrEmpty()] - [string] $Path - ) - process{ - $Path = $Path | Convert-Path - - Assert-ItemExist -Path ($Path | Join-Path -ChildPath ".git") -Comment ".git" - } -} - # License function Assert-AddLicense{ @@ -119,10 +107,10 @@ function Assert-AddDeployScript{ process{ $Path = $Path | Convert-Path - $toolsPath = $Path | Join-Path -ChildPath "tools" + $toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH Assert-ItemExist -Path ($Path | Join-Path -ChildPath "deploy.ps1") -Comment "deploy.ps1" - Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "deploy-helper.ps1") -Comment "deploy-helper.ps1" + Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "deploy.Helper.ps1") -Comment "deploy.Helper.ps1" } } @@ -150,8 +138,10 @@ function Assert-AddSyncScript{ process{ $Path = $Path | Convert-Path + $toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH + Assert-ItemExist -Path ($Path | Join-Path -ChildPath "sync.ps1") -Comment "sync.ps1" - Assert-ItemExist -Path (($Path | Join-Path -ChildPath "tools") | Join-Path -ChildPath "sync-helper.ps1") -Comment "sync-helper.ps1" + Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "sync.Helper.ps1") -Comment "sync.Helper.ps1" } } diff --git a/deploy.ps1 b/deploy.ps1 index efdd3af..bf66cfb 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -43,11 +43,12 @@ param( $MODULE_PATH = $PSScriptRoot $MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" +$MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools" # Load helper # We dot souce the ps1 to allow all code to be in the same scope as the script # Easier to inject for testing with DependecyInjection parameter -. ($MODULE_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1") +. ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/docs/structure-of-a-module.md b/docs/structure-of-a-module.md index 28ea493..f57502c 100644 --- a/docs/structure-of-a-module.md +++ b/docs/structure-of-a-module.md @@ -20,10 +20,10 @@ ## Tools Scripts 1. publish.ps1 - 1. publish-helper.ps1 + 1. deploy.Helper.ps1er.ps1 2. release.ps1 3. sync.ps1 - 1. sync-helper.ps1 + 1. sync.Helper.ps1 ## Workflows diff --git a/private/templates/template.v3.deploy-helper.ps1 b/private/templates/template.v3.deploy.Helper.ps1 similarity index 95% rename from private/templates/template.v3.deploy-helper.ps1 rename to private/templates/template.v3.deploy.Helper.ps1 index db5a17a..16eeea5 100644 --- a/private/templates/template.v3.deploy-helper.ps1 +++ b/private/templates/template.v3.deploy.Helper.ps1 @@ -11,7 +11,9 @@ It is not intended to be used directly. .LINK - https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy-helper.ps1 + https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy.Helper.ps1 + https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy.Helper.ps1 + https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1 #> diff --git a/private/templates/template.v3.deploy.ps1 b/private/templates/template.v3.deploy.ps1 index efdd3af..bf66cfb 100644 --- a/private/templates/template.v3.deploy.ps1 +++ b/private/templates/template.v3.deploy.ps1 @@ -43,11 +43,12 @@ param( $MODULE_PATH = $PSScriptRoot $MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" +$MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools" # Load helper # We dot souce the ps1 to allow all code to be in the same scope as the script # Easier to inject for testing with DependecyInjection parameter -. ($MODULE_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1") +. ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/private/templates/template.v3.sync-helper.ps1 b/private/templates/template.v3.sync.Helper.ps1 similarity index 100% rename from private/templates/template.v3.sync-helper.ps1 rename to private/templates/template.v3.sync.Helper.ps1 diff --git a/private/templates/template.v3.sync.ps1 b/private/templates/template.v3.sync.ps1 index 8046fa7..6bacded 100644 --- a/private/templates/template.v3.sync.ps1 +++ b/private/templates/template.v3.sync.ps1 @@ -17,17 +17,17 @@ $MODULE_PATH = $PSScriptRoot $TOOLS_PATH = $MODULE_PATH | Join-Path -ChildPath "tools" $WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows" -. ($TOOLS_PATH | Join-Path -ChildPath "sync-helper.ps1") +. ($TOOLS_PATH | Join-Path -ChildPath "sync.Helper.ps1") -Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' -Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' -Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' +Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' +Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' +Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' -Save-UrlContentToFile -File 'deploy-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1' -Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' +Save-UrlContentToFile -File 'deploy.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1' +Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' -Save-UrlContentToFile -File 'sync-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1' -Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' +Save-UrlContentToFile -File 'sync.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.Helper.ps1' +Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' -Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' -Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file +Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' +Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file diff --git a/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index 6b70122..3903a43 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -5,6 +5,8 @@ # -Force: If the file already exists, it will be overwritten withe the default values # The output will be the Path of the module updated. This way we may pipe with next Add-ToModule* function +$TOOLS_RELATIVE_PATH = "tools" + function Add-ToModuleSampleCode{ [CmdletBinding(SupportsShouldProcess)] param( @@ -142,8 +144,10 @@ function Add-ToModuleDeployScript{ process{ $Path = NormalizePath -Path:$Path ?? return $null + $toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH + Import-Template -Force:$Force -Path $Path -File "deploy.ps1" -Template "template.v3.deploy.ps1" - Import-Template -Force:$Force -Path ($Path | Join-path -ChildPath "tools") -File "deploy-helper.ps1" -Template "template.v3.deploy-helper.ps1" + Import-Template -Force:$Force -Path $toolsPath -File "deploy.Helper.ps1" -Template "template.v3.deploy.Helper.ps1" return ReturnValue -Path $Path -Force:$Force -Passthru:$Passthru } @@ -184,8 +188,10 @@ function Add-ToModuleSyncScript{ process{ $Path = NormalizePath -Path:$Path ?? return $null + $toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH + Import-Template -Force:$Force -Path $Path -File "sync.ps1" -Template "template.v3.sync.ps1" - Import-Template -Force:$Force -Path ($Path | Join-Path -ChildPath "tools") -File "sync-helper.ps1" -Template "template.v3.sync-helper.ps1" + Import-Template -Force:$Force -Path $toolsPath -File "sync.Helper.ps1" -Template "template.v3.sync.Helper.ps1" return ReturnValue -Path $Path -Force:$Force -Passthru:$Passthru } diff --git a/sync.ps1 b/sync.ps1 index 8046fa7..6bacded 100644 --- a/sync.ps1 +++ b/sync.ps1 @@ -17,17 +17,17 @@ $MODULE_PATH = $PSScriptRoot $TOOLS_PATH = $MODULE_PATH | Join-Path -ChildPath "tools" $WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows" -. ($TOOLS_PATH | Join-Path -ChildPath "sync-helper.ps1") +. ($TOOLS_PATH | Join-Path -ChildPath "sync.Helper.ps1") -Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' -Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' -Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' +Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' +Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' +Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' -Save-UrlContentToFile -File 'deploy-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1' -Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' +Save-UrlContentToFile -File 'deploy.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1' +Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' -Save-UrlContentToFile -File 'sync-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1' -Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' +Save-UrlContentToFile -File 'sync.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.Helper.ps1' +Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' -Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' -Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file +Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' +Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file diff --git a/tools/deploy-helper.ps1 b/tools/deploy.Helper.ps1 similarity index 97% rename from tools/deploy-helper.ps1 rename to tools/deploy.Helper.ps1 index 97d1cba..9742c33 100644 --- a/tools/deploy-helper.ps1 +++ b/tools/deploy.Helper.ps1 @@ -11,9 +11,9 @@ It is not intended to be used directly. .LINK - https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy-helper.ps1 - https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy-helper.ps1 - https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1 + https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy.Helper.ps1 + https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy.Helper.ps1 + https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1 #> diff --git a/tools/sync-helper.ps1 b/tools/sync.Helper.ps1 similarity index 100% rename from tools/sync-helper.ps1 rename to tools/sync.Helper.ps1