From c389dac7b6daf1fcaf12ff902c919d2b98db02c7 Mon Sep 17 00:00:00 2001 From: rulasg Date: Fri, 30 Jun 2023 10:07:26 +0200 Subject: [PATCH 1/9] Move scripts to tools --- .../Add-ModuleSections.Tests.Asserts.ps1 | 20 ++++------------- deploy.ps1 | 2 +- private/templates/template.v3.deploy.ps1 | 2 +- private/templates/template.v3.sync-helper.ps1 | 14 +++++++----- private/templates/template.v3.sync.ps1 | 22 +++++++++++-------- public/Add-ToModule.ps1 | 8 +++++-- sync.ps1 | 22 +++++++++++-------- deploy-helper.ps1 => tools/deploy-helper.ps1 | 3 ++- sync-helper.ps1 => tools/sync-helper.ps1 | 13 ++++++----- 9 files changed, 57 insertions(+), 49 deletions(-) rename deploy-helper.ps1 => tools/deploy-helper.ps1 (95%) rename sync-helper.ps1 => tools/sync-helper.ps1 (79%) diff --git a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 index a34c118..eadf30b 100644 --- a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 +++ b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 @@ -27,20 +27,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,8 +105,10 @@ function Assert-AddDeployScript{ process{ $Path = $Path | Convert-Path - Assert-ItemExist -Path ($Path | Join-Path -ChildPath "deploy.ps1") -Comment "deploy.ps1" - Assert-ItemExist -Path ($Path | Join-Path -ChildPath "deploy-helper.ps1") -Comment "deploy-helper.ps1" + $toolsPath = $Path | Join-Path -ChildPath "tools" + + 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" } } diff --git a/deploy.ps1 b/deploy.ps1 index 8c5fc0c..97bade7 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -43,7 +43,7 @@ param( # 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 -. ($PSScriptRoot | Join-Path -ChildPath "deploy-helper.ps1") +. ($PSScriptRoot | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/private/templates/template.v3.deploy.ps1 b/private/templates/template.v3.deploy.ps1 index d33a969..4304f25 100644 --- a/private/templates/template.v3.deploy.ps1 +++ b/private/templates/template.v3.deploy.ps1 @@ -43,7 +43,7 @@ param( # 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 -. ($PSScriptRoot | Join-Path -ChildPath "deploy-helper.ps1") +. ($PSScriptRoot | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/private/templates/template.v3.sync-helper.ps1 b/private/templates/template.v3.sync-helper.ps1 index 28354cb..792b05f 100644 --- a/private/templates/template.v3.sync-helper.ps1 +++ b/private/templates/template.v3.sync-helper.ps1 @@ -32,6 +32,7 @@ function Out-ContentToFile { ) process{ + if ($PSCmdlet.ShouldProcess($filePath, "Save content [{0}] to file" -f $content.Length)) { $content | Out-File -FilePath $filePath -Force } @@ -39,10 +40,11 @@ function Out-ContentToFile { } function Save-UrlContentToFile { - [cmdletbinding()] + [cmdletbinding(SupportsShouldProcess)] param( [Parameter(Mandatory=$true)][string]$Url, - [Parameter(Mandatory=$true)][string]$FilePath + [Parameter(Mandatory=$true)][string]$File, + [Parameter()][string]$Folder ) $fileContent = Get-UrlContent -Url $url @@ -50,8 +52,10 @@ function Save-UrlContentToFile { if ([string]::IsNullOrWhiteSpace($fileContent)) { Write-Error -Message "Content from [$url] is empty" return - } else { - $fileContent | Out-ContentToFile -FilePath $filePath - Write-Information -MessageData "Saved content to [$filePath] from [$url]" } + + $filePath = $Folder ? (Join-Path -Path $Folder -ChildPath $File) : $File + + Set-Content -Path $filePath -Value $fileContent + Write-Information -MessageData "Saved content to [$filePath] from [$url]" } \ No newline at end of file diff --git a/private/templates/template.v3.sync.ps1 b/private/templates/template.v3.sync.ps1 index 4db95c9..df63243 100644 --- a/private/templates/template.v3.sync.ps1 +++ b/private/templates/template.v3.sync.ps1 @@ -15,15 +15,19 @@ param() . ($PSScriptRoot | Join-Path -ChildPath "sync-helper.ps1") -Save-UrlContentToFile -FilePath 'deploy_module_on_release.yml' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' -Save-UrlContentToFile -FilePath 'powershell.yml' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' -Save-UrlContentToFile -FilePath 'test_with_TestingHelper.yml' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' +$modulePath = $PSScriptRoot +$toolsPath = $PSScriptRoot | Join-Path -ChildPath "tools" +$workflowPath = $toolsPath | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows" -Save-UrlContentToFile -FilePath 'deploy-helper.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1' -Save-UrlContentToFile -FilePath 'deploy.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' +Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' +Save-UrlContentToFile -File 'powershell.yml' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' +Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' -Save-UrlContentToFile -FilePath 'sync-helper.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1' -Save-UrlContentToFile -FilePath 'sync.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' +Save-UrlContentToFile -File 'deploy-helper.ps1' -Folder $toolsPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1' +Save-UrlContentToFile -File 'deploy.ps1' -Folder $modulePath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' -Save-UrlContentToFile -FilePath 'release.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' -Save-UrlContentToFile -FilePath 'test.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file +Save-UrlContentToFile -File 'sync-helper.ps1' -Folder $toolsPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1' +Save-UrlContentToFile -File 'sync.ps1' -Folder $modulePath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' + +Save-UrlContentToFile -File 'release.ps1' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' +Save-UrlContentToFile -File 'test.ps1' -Folder $modulePath -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 94c9709..43a0179 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -195,8 +195,10 @@ function Add-ToModuleDeployScript{ process{ $Path = NormalizePath -Path:$Path ?? return $null + $toolsPath = $Path | Join-Path -ChildPath "tools" + Import-Template -Force:$Force -Path $Path -File "deploy.ps1" -Template "template.v3.deploy.ps1" - Import-Template -Force:$Force -Path $Path -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 } @@ -237,8 +239,10 @@ function Add-ToModuleSyncScript{ process{ $Path = NormalizePath -Path:$Path ?? return $null + $toolsPath = $Path | Join-Path -ChildPath "tools" + Import-Template -Force:$Force -Path $Path -File "sync.ps1" -Template "template.v3.sync.ps1" - Import-Template -Force:$Force -Path $Path -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 04f60a1..df63243 100644 --- a/sync.ps1 +++ b/sync.ps1 @@ -15,15 +15,19 @@ param() . ($PSScriptRoot | Join-Path -ChildPath "sync-helper.ps1") -Save-UrlContentToFile -FilePath 'deploy_module_on_release.yml' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' -Save-UrlContentToFile -FilePath 'powershell.yml' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' -Save-UrlContentToFile -FilePath 'test_with_TestingHelper.yml' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' +$modulePath = $PSScriptRoot +$toolsPath = $PSScriptRoot | Join-Path -ChildPath "tools" +$workflowPath = $toolsPath | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows" -Save-UrlContentToFile -FilePath 'deploy-helper.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1' -Save-UrlContentToFile -FilePath 'deploy.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' +Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml' +Save-UrlContentToFile -File 'powershell.yml' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml' +Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml' -Save-UrlContentToFile -FilePath 'sync-helper.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1' -Save-UrlContentToFile -FilePath 'sync.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' +Save-UrlContentToFile -File 'deploy-helper.ps1' -Folder $toolsPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1' +Save-UrlContentToFile -File 'deploy.ps1' -Folder $modulePath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1' -Save-UrlContentToFile -FilePath 'release.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' -Save-UrlContentToFile -FilePath 'test.ps1' -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file +Save-UrlContentToFile -File 'sync-helper.ps1' -Folder $toolsPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1' +Save-UrlContentToFile -File 'sync.ps1' -Folder $modulePath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1' + +Save-UrlContentToFile -File 'release.ps1' -Folder $workflowPath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1' +Save-UrlContentToFile -File 'test.ps1' -Folder $modulePath -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1' \ No newline at end of file diff --git a/deploy-helper.ps1 b/tools/deploy-helper.ps1 similarity index 95% rename from deploy-helper.ps1 rename to tools/deploy-helper.ps1 index cb29901..01ea0b7 100644 --- a/deploy-helper.ps1 +++ b/tools/deploy-helper.ps1 @@ -11,7 +11,8 @@ 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 #> diff --git a/sync-helper.ps1 b/tools/sync-helper.ps1 similarity index 79% rename from sync-helper.ps1 rename to tools/sync-helper.ps1 index 7fe6558..792b05f 100644 --- a/sync-helper.ps1 +++ b/tools/sync-helper.ps1 @@ -40,10 +40,11 @@ function Out-ContentToFile { } function Save-UrlContentToFile { - [cmdletbinding()] + [cmdletbinding(SupportsShouldProcess)] param( [Parameter(Mandatory=$true)][string]$Url, - [Parameter(Mandatory=$true)][string]$FilePath + [Parameter(Mandatory=$true)][string]$File, + [Parameter()][string]$Folder ) $fileContent = Get-UrlContent -Url $url @@ -51,8 +52,10 @@ function Save-UrlContentToFile { if ([string]::IsNullOrWhiteSpace($fileContent)) { Write-Error -Message "Content from [$url] is empty" return - } else { - $fileContent | Out-ContentToFile -FilePath $filePath - Write-Information -MessageData "Saved content to [$filePath] from [$url]" } + + $filePath = $Folder ? (Join-Path -Path $Folder -ChildPath $File) : $File + + Set-Content -Path $filePath -Value $fileContent + Write-Information -MessageData "Saved content to [$filePath] from [$url]" } \ No newline at end of file From 6c32e42caa1afb5af5df1f71796a9cf2c5037a70 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 11:49:54 +0200 Subject: [PATCH 2/9] ScriptAnalyzer suggestion --- private/templates/template.v3.sync.ps1 | 18 +++++++++--------- public/Add-ToModule.ps1 | 4 ++-- sync.ps1 | 18 +++++++++--------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/private/templates/template.v3.sync.ps1 b/private/templates/template.v3.sync.ps1 index d5ab406..19cd74c 100644 --- a/private/templates/template.v3.sync.ps1 +++ b/private/templates/template.v3.sync.ps1 @@ -19,15 +19,15 @@ $WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChild . ($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' +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 b993d40..49e30f7 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -145,7 +145,7 @@ function Add-ToModuleDeployScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" 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 } @@ -189,7 +189,7 @@ function Add-ToModuleSyncScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" 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 d5ab406..19cd74c 100644 --- a/sync.ps1 +++ b/sync.ps1 @@ -19,15 +19,15 @@ $WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChild . ($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' +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 From 18015803051650e93c5c0c81253f24512e97d757 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 12:44:55 +0200 Subject: [PATCH 3/9] Rename deploy-helper.ps1 to deploy.helper.ps1 --- .../private/Add-ModuleSections.Tests.Asserts.ps1 | 2 +- deploy.ps1 | 2 +- ...e.v3.deploy-helper.ps1 => template.v3.deploy.helper.ps1} | 2 +- private/templates/template.v3.deploy.ps1 | 2 +- private/templates/template.v3.sync.ps1 | 2 +- public/Add-ToModule.ps1 | 2 +- sync.ps1 | 2 +- tools/{deploy-helper.ps1 => deploy.helper.ps1} | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) rename private/templates/{template.v3.deploy-helper.ps1 => template.v3.deploy.helper.ps1} (99%) rename tools/{deploy-helper.ps1 => deploy.helper.ps1} (97%) diff --git a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 index d1e317e..985856e 100644 --- a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 +++ b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 @@ -108,7 +108,7 @@ function Assert-AddDeployScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" 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" } } diff --git a/deploy.ps1 b/deploy.ps1 index efdd3af..9e3b5a0 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -47,7 +47,7 @@ $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" # 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_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy.helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/private/templates/template.v3.deploy-helper.ps1 b/private/templates/template.v3.deploy.helper.ps1 similarity index 99% rename from private/templates/template.v3.deploy-helper.ps1 rename to private/templates/template.v3.deploy.helper.ps1 index db5a17a..751c7ba 100644 --- a/private/templates/template.v3.deploy-helper.ps1 +++ b/private/templates/template.v3.deploy.helper.ps1 @@ -11,7 +11,7 @@ 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 #> diff --git a/private/templates/template.v3.deploy.ps1 b/private/templates/template.v3.deploy.ps1 index efdd3af..9e3b5a0 100644 --- a/private/templates/template.v3.deploy.ps1 +++ b/private/templates/template.v3.deploy.ps1 @@ -47,7 +47,7 @@ $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" # 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_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy.helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/private/templates/template.v3.sync.ps1 b/private/templates/template.v3.sync.ps1 index 19cd74c..ef7b135 100644 --- a/private/templates/template.v3.sync.ps1 +++ b/private/templates/template.v3.sync.ps1 @@ -23,7 +23,7 @@ Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PAT 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.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' diff --git a/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index 49e30f7..6ed943a 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -145,7 +145,7 @@ function Add-ToModuleDeployScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" Import-Template -Force:$Force -Path $Path -File "deploy.ps1" -Template "template.v3.deploy.ps1" - Import-Template -Force:$Force -Path $toolsPath -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 } diff --git a/sync.ps1 b/sync.ps1 index 19cd74c..ef7b135 100644 --- a/sync.ps1 +++ b/sync.ps1 @@ -23,7 +23,7 @@ Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PAT 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.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' 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..920fe69 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 #> From 30ad00f10d40facdec372a88688393bc289299d0 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 12:48:31 +0200 Subject: [PATCH 4/9] rename to sync.helper.ps1 --- .../private/Add-ModuleSections.Tests.Asserts.ps1 | 2 +- docs/structure-of-a-module.md | 2 +- ...emplate.v3.sync-helper.ps1 => template.v3.sync.Helper.ps1} | 0 private/templates/template.v3.sync.ps1 | 4 ++-- public/Add-ToModule.ps1 | 2 +- sync.ps1 | 4 ++-- tools/{sync-helper.ps1 => sync.Helper.ps1} | 0 7 files changed, 7 insertions(+), 7 deletions(-) rename private/templates/{template.v3.sync-helper.ps1 => template.v3.sync.Helper.ps1} (100%) rename tools/{sync-helper.ps1 => sync.Helper.ps1} (100%) diff --git a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 index 985856e..3c75ffe 100644 --- a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 +++ b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 @@ -137,7 +137,7 @@ function Assert-AddSyncScript{ $Path = $Path | Convert-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 (($Path | Join-Path -ChildPath "tools") | Join-Path -ChildPath "sync.Helper.ps1") -Comment "sync.Helper.ps1" } } diff --git a/docs/structure-of-a-module.md b/docs/structure-of-a-module.md index 28ea493..cc36f15 100644 --- a/docs/structure-of-a-module.md +++ b/docs/structure-of-a-module.md @@ -23,7 +23,7 @@ 1. publish-helper.ps1 2. release.ps1 3. sync.ps1 - 1. sync-helper.ps1 + 1. sync.Helper.ps1 ## Workflows 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 ef7b135..d5a2e70 100644 --- a/private/templates/template.v3.sync.ps1 +++ b/private/templates/template.v3.sync.ps1 @@ -17,7 +17,7 @@ $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' @@ -26,7 +26,7 @@ Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PAT 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.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' diff --git a/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index 6ed943a..f46c0aa 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -189,7 +189,7 @@ function Add-ToModuleSyncScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" Import-Template -Force:$Force -Path $Path -File "sync.ps1" -Template "template.v3.sync.ps1" - Import-Template -Force:$Force -Path $toolsPath -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 ef7b135..d5a2e70 100644 --- a/sync.ps1 +++ b/sync.ps1 @@ -17,7 +17,7 @@ $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' @@ -26,7 +26,7 @@ Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PAT 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.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' 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 From a96bd96ce7cd4ec56e139545f7b905794c4a919a Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 12:52:30 +0200 Subject: [PATCH 5/9] Rename deploy.Helper.ps1 Missing second commit with file items case. --- .../private/Add-ModuleSections.Tests.Asserts.ps1 | 2 +- deploy.ps1 | 2 +- docs/structure-of-a-module.md | 2 +- ....v3.deploy.helper.ps1 => template.v3.deploy.Helper2.ps1} | 2 +- private/templates/template.v3.deploy.ps1 | 2 +- private/templates/template.v3.sync.ps1 | 2 +- public/Add-ToModule.ps1 | 2 +- sync.ps1 | 2 +- tools/{deploy.helper.ps1 => deploy.Helper2.ps1} | 6 +++--- 9 files changed, 11 insertions(+), 11 deletions(-) rename private/templates/{template.v3.deploy.helper.ps1 => template.v3.deploy.Helper2.ps1} (99%) rename tools/{deploy.helper.ps1 => deploy.Helper2.ps1} (97%) diff --git a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 index 3c75ffe..aaa9d18 100644 --- a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 +++ b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 @@ -108,7 +108,7 @@ function Assert-AddDeployScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" 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" } } diff --git a/deploy.ps1 b/deploy.ps1 index 9e3b5a0..7d237e9 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -47,7 +47,7 @@ $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" # 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_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy.Helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/docs/structure-of-a-module.md b/docs/structure-of-a-module.md index cc36f15..f57502c 100644 --- a/docs/structure-of-a-module.md +++ b/docs/structure-of-a-module.md @@ -20,7 +20,7 @@ ## Tools Scripts 1. publish.ps1 - 1. publish-helper.ps1 + 1. deploy.Helper.ps1er.ps1 2. release.ps1 3. sync.ps1 1. sync.Helper.ps1 diff --git a/private/templates/template.v3.deploy.helper.ps1 b/private/templates/template.v3.deploy.Helper2.ps1 similarity index 99% rename from private/templates/template.v3.deploy.helper.ps1 rename to private/templates/template.v3.deploy.Helper2.ps1 index 751c7ba..bed1864 100644 --- a/private/templates/template.v3.deploy.helper.ps1 +++ b/private/templates/template.v3.deploy.Helper2.ps1 @@ -11,7 +11,7 @@ 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 #> diff --git a/private/templates/template.v3.deploy.ps1 b/private/templates/template.v3.deploy.ps1 index 9e3b5a0..7d237e9 100644 --- a/private/templates/template.v3.deploy.ps1 +++ b/private/templates/template.v3.deploy.ps1 @@ -47,7 +47,7 @@ $MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1" # 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_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy.Helper.ps1") if ($DependencyInjection) { . $DependencyInjection } diff --git a/private/templates/template.v3.sync.ps1 b/private/templates/template.v3.sync.ps1 index d5a2e70..6bacded 100644 --- a/private/templates/template.v3.sync.ps1 +++ b/private/templates/template.v3.sync.ps1 @@ -23,7 +23,7 @@ Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PAT 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.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' diff --git a/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index f46c0aa..60985f7 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -145,7 +145,7 @@ function Add-ToModuleDeployScript{ $toolsPath = $Path | Join-Path -ChildPath "tools" Import-Template -Force:$Force -Path $Path -File "deploy.ps1" -Template "template.v3.deploy.ps1" - Import-Template -Force:$Force -Path $toolsPath -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 } diff --git a/sync.ps1 b/sync.ps1 index d5a2e70..6bacded 100644 --- a/sync.ps1 +++ b/sync.ps1 @@ -23,7 +23,7 @@ Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PAT 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.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' diff --git a/tools/deploy.helper.ps1 b/tools/deploy.Helper2.ps1 similarity index 97% rename from tools/deploy.helper.ps1 rename to tools/deploy.Helper2.ps1 index 920fe69..9742c33 100644 --- a/tools/deploy.helper.ps1 +++ b/tools/deploy.Helper2.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 #> From 06d4b416ccf70fcc1812380e7db274f8d90df5c7 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 12:52:57 +0200 Subject: [PATCH 6/9] Rename case file deploy.Helper.ps1 --- ...mplate.v3.deploy.Helper2.ps1 => template.v3.deploy.Helper.ps1} | 0 tools/{deploy.Helper2.ps1 => deploy.Helper.ps1} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename private/templates/{template.v3.deploy.Helper2.ps1 => template.v3.deploy.Helper.ps1} (100%) rename tools/{deploy.Helper2.ps1 => deploy.Helper.ps1} (100%) diff --git a/private/templates/template.v3.deploy.Helper2.ps1 b/private/templates/template.v3.deploy.Helper.ps1 similarity index 100% rename from private/templates/template.v3.deploy.Helper2.ps1 rename to private/templates/template.v3.deploy.Helper.ps1 diff --git a/tools/deploy.Helper2.ps1 b/tools/deploy.Helper.ps1 similarity index 100% rename from tools/deploy.Helper2.ps1 rename to tools/deploy.Helper.ps1 From fc1b6a498bcdeaf6e58ef6501506dee9e8012771 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 13:13:02 +0200 Subject: [PATCH 7/9] ref: Tools path management --- .../private/Add-ModuleSections.Tests.Asserts.ps1 | 8 ++++++-- deploy.ps1 | 3 ++- private/templates/template.v3.deploy.Helper.ps1 | 2 ++ private/templates/template.v3.deploy.ps1 | 3 ++- public/Add-ToModule.ps1 | 8 +++++--- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 b/TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1 index aaa9d18..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 @@ -105,7 +107,7 @@ 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" @@ -136,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 7d237e9..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/private/templates/template.v3.deploy.Helper.ps1 b/private/templates/template.v3.deploy.Helper.ps1 index bed1864..16eeea5 100644 --- a/private/templates/template.v3.deploy.Helper.ps1 +++ b/private/templates/template.v3.deploy.Helper.ps1 @@ -12,6 +12,8 @@ .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 #> diff --git a/private/templates/template.v3.deploy.ps1 b/private/templates/template.v3.deploy.ps1 index 7d237e9..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/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index 60985f7..316f71a 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,10 +144,10 @@ function Add-ToModuleDeployScript{ process{ $Path = NormalizePath -Path:$Path ?? return $null - $toolsPath = $Path | Join-Path -ChildPath "tools" + $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 $toolsPath -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 } @@ -186,7 +188,7 @@ function Add-ToModuleSyncScript{ process{ $Path = NormalizePath -Path:$Path ?? return $null - $toolsPath = $Path | Join-Path -ChildPath "tools" + $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 $toolsPath -File "sync.Helper.ps1" -Template "template.v3.sync.Helper.ps1" From 54c3f59acffd1c1a62379911166d6dfc3e080465 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 14:04:59 +0200 Subject: [PATCH 8/9] Fix case bug --- public/Add-ToModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index 316f71a..62f5552 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -147,7 +147,7 @@ function Add-ToModuleDeployScript{ $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 $toolsPath -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 } From 95896277a169c476279663adc5c649a3735d2af6 Mon Sep 17 00:00:00 2001 From: rulasg Date: Mon, 3 Jul 2023 14:19:52 +0200 Subject: [PATCH 9/9] Fix case bug --- public/Add-ToModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/Add-ToModule.ps1 b/public/Add-ToModule.ps1 index 62f5552..3903a43 100644 --- a/public/Add-ToModule.ps1 +++ b/public/Add-ToModule.ps1 @@ -147,7 +147,7 @@ function Add-ToModuleDeployScript{ $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 $toolsPath -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 }