diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index f22e1761c3..4bcf191f2a 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -159,9 +159,9 @@ jobs: . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactFeed.ps1') #Prioritizing the bicep file - $TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.bicep' + $TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.bicep' if (-not (Test-Path $TemplateFilePath)) { - $TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.json' + $TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.json' } $functionInput = @{ @@ -218,9 +218,9 @@ jobs: . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToTemplateSpec.ps1') #Prioritizing the bicep file - $TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.bicep' + $TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.bicep' if (-not (Test-Path $TemplateFilePath)) { - $TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.json' + $TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.json' } $functionInput = @{ @@ -278,9 +278,9 @@ jobs: . (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToPrivateBicepRegistry.ps1') #Prioritizing the bicep file - $TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.bicep' + $TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.bicep' if (-not (Test-Path $TemplateFilePath)) { - $TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.json' + $TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.json' } $functionInput = @{ diff --git a/.azuredevops/platformPipelines/platform.updateReadMe.yml b/.azuredevops/platformPipelines/platform.updateReadMe.yml index 50da9cdbad..f305261308 100644 --- a/.azuredevops/platformPipelines/platform.updateReadMe.yml +++ b/.azuredevops/platformPipelines/platform.updateReadMe.yml @@ -69,7 +69,7 @@ jobs: $functionInput = @{ ModulesPath = Join-Path '$(System.DefaultWorkingDirectory)' 'modules' - FilePath = Join-Path '$(System.DefaultWorkingDirectory)' 'modules/README.md' + FilePath = Join-Path '$(System.DefaultWorkingDirectory)' 'modules' 'README.md' Organization = '$(System.CollectionUri)'.Split('/')[3] RepositoryName = '$(Build.Repository.Name)' ColumnsInOrder = @('Name', 'ProviderNamespace','ResourceType') diff --git a/.github/workflows/platform.updateReadMe.yml b/.github/workflows/platform.updateReadMe.yml index 6625950b23..2a865cda47 100644 --- a/.github/workflows/platform.updateReadMe.yml +++ b/.github/workflows/platform.updateReadMe.yml @@ -59,7 +59,7 @@ jobs: $functionInput = @{ ModulesPath = Join-Path $env:GITHUB_WORKSPACE 'modules' - FilePath = Join-Path $env:GITHUB_WORKSPACE 'modules/README.md' + FilePath = Join-Path $env:GITHUB_WORKSPACE 'modules' 'README.md' Organization = ($env:GITHUB_REPOSITORY).split('/')[0] RepositoryName = ($env:GITHUB_REPOSITORY).split('/')[1] ColumnsInOrder = @('Name', 'ProviderNamespace','ResourceType') diff --git a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 index 7993734f5a..ff468a5b3c 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 @@ -103,9 +103,9 @@ function Find-TemplateFile { } #Prioritizing the bicep file - $TemplateFilePath = Join-Path -Path $FolderPath -ChildPath 'deploy.bicep' + $TemplateFilePath = Join-Path $FolderPath 'deploy.bicep' if (-not (Test-Path $TemplateFilePath)) { - $TemplateFilePath = Join-Path -Path $FolderPath -ChildPath 'deploy.json' + $TemplateFilePath = Join-Path $FolderPath 'deploy.json' } if (-not (Test-Path $TemplateFilePath)) { @@ -211,9 +211,9 @@ function Get-ParentModuleTemplateFile { $ParentFolderPath = Split-Path $ModuleFolderPath -Parent #Prioritizing the bicep file - $ParentTemplateFilePath = Join-Path -Path $ParentFolderPath -ChildPath 'deploy.bicep' + $ParentTemplateFilePath = Join-Path $ParentFolderPath 'deploy.bicep' if (-not (Test-Path $TemplateFilePath)) { - $ParentTemplateFilePath = Join-Path -Path $ParentFolderPath -ChildPath 'deploy.json' + $ParentTemplateFilePath = Join-Path $ParentFolderPath 'deploy.json' } if (-not (Test-Path -Path $ParentTemplateFilePath)) { @@ -283,7 +283,7 @@ function Get-ModuleVersionFromFile { ) $ModuleFolder = Split-Path -Path $TemplateFilePath -Parent - $VersionFilePath = Join-Path -Path $ModuleFolder -ChildPath 'version.json' + $VersionFilePath = Join-Path $ModuleFolder 'version.json' if (-not (Test-Path -Path $VersionFilePath)) { throw "No version file found at: [$VersionFilePath]" diff --git a/utilities/pipelines/staticValidation/module.tests.ps1 b/utilities/pipelines/staticValidation/module.tests.ps1 index de04af02c2..7d5ce030a5 100644 --- a/utilities/pipelines/staticValidation/module.tests.ps1 +++ b/utilities/pipelines/staticValidation/module.tests.ps1 @@ -32,7 +32,7 @@ $script:jsonTemplateLoadFailedException = "Unable to load the deploy.json templa $script:templateNotFoundException = 'No template file found in folder [{0}]' # -f $moduleFolderPath # Import any helper function used in this test script -Import-Module (Join-Path $PSScriptRoot 'helper\helper.psm1') -Force +Import-Module (Join-Path $PSScriptRoot 'helper' 'helper.psm1') -Force Describe 'File/folder tests' -Tag Modules { diff --git a/utilities/pipelines/tokensReplacement/Convert-TokensInFileList.ps1 b/utilities/pipelines/tokensReplacement/Convert-TokensInFileList.ps1 index 6d6edf2a75..684936a663 100644 --- a/utilities/pipelines/tokensReplacement/Convert-TokensInFileList.ps1 +++ b/utilities/pipelines/tokensReplacement/Convert-TokensInFileList.ps1 @@ -25,7 +25,7 @@ Optional. A string for a custom output directory of the modified parameter file .NOTES - Make sure you provide the right information in the objects that contain tokens. This is in the form of - @( +@( @{ Name = 'deploymentSpId'; Value = '12345678-1234-1234-1234-123456789123' } @{ Name = 'tenantId'; Value = '12345678-1234-1234-1234-123456789123' } @@ -60,7 +60,7 @@ function Convert-TokensInFileList { begin { # Load used funtions - . (Join-Path $PSScriptRoot './helper/Convert-TokenInFile.ps1') + . (Join-Path $PSScriptRoot 'helper' 'Convert-TokenInFile.ps1') } process { diff --git a/utilities/pipelines/tokensReplacement/helper/Convert-TokenInFile.ps1 b/utilities/pipelines/tokensReplacement/helper/Convert-TokenInFile.ps1 index bb7be0eb72..0491a78f0c 100644 --- a/utilities/pipelines/tokensReplacement/helper/Convert-TokenInFile.ps1 +++ b/utilities/pipelines/tokensReplacement/helper/Convert-TokenInFile.ps1 @@ -81,7 +81,7 @@ function Convert-TokenInFile { # Set Content if ($OutputDirectory -and (Test-Path -Path $OutputDirectory -PathType Container)) { # If Specific Output Directory Provided - $Path = (Join-Path -Path $OutputDirectory -ChildPath $FileName) + $Path = Join-Path $OutputDirectory $FileName } # Set Content $File | Set-Content -Path $Path diff --git a/utilities/tools/ConvertTo-ARMTemplate.ps1 b/utilities/tools/ConvertTo-ARMTemplate.ps1 index 90fe651023..a6860a15c5 100644 --- a/utilities/tools/ConvertTo-ARMTemplate.ps1 +++ b/utilities/tools/ConvertTo-ARMTemplate.ps1 @@ -56,7 +56,7 @@ param ( ) $rootPath = Get-Item -Path $Path | Select-Object -ExpandProperty 'FullName' -$modulesFolderPath = Join-Path -Path $rootPath -ChildPath 'modules' +$modulesFolderPath = Join-Path $rootPath 'modules' if ($ConvertChildren) { $BicepFilesToConvert = Get-ChildItem -Path $modulesFolderPath -Filter 'deploy.bicep' -Recurse -Force } else { @@ -66,7 +66,7 @@ if ($ConvertChildren) { #region Remove existing deploy.json files Write-Verbose 'Remove existing deploy.json files' -if (Test-Path -Path (Join-Path -Path $modulesFolderPath -ChildPath 'deploy.bicep')) { +if (Test-Path -Path (Join-Path $modulesFolderPath 'deploy.bicep')) { $JsonFilesToRemove = Get-ChildItem -Path $modulesFolderPath -Filter 'deploy.json' -Recurse -Force -File Write-Verbose "Remove existing deploy.json files - Remove [$($JsonFilesToRemove.count)] file(s)" if ($PSCmdlet.ShouldProcess("[$($JsonFilesToRemove.count)] deploy.json files(s) in path [$modulesFolderPath]", 'Remove-Item')) { @@ -132,7 +132,7 @@ if (-not $SkipMetadataCleanup) { } $moduleFolderPath = $_.Directory.FullName - $JSONFilePath = Join-Path -Path $moduleFolderPath -ChildPath 'deploy.json' + $JSONFilePath = Join-Path $moduleFolderPath 'deploy.json' if (Test-Path -Path $JSONFilePath) { $JSONFileContent = Get-Content -Path $JSONFilePath $JSONObj = $JSONFileContent | ConvertFrom-Json @@ -174,7 +174,7 @@ if (-not $SkipPipelineUpdate) { Write-Verbose 'Update pipeline files' # GitHub workflow files - $ghWorkflowFolderPath = Join-Path -Path $rootPath -ChildPath '.github\workflows' + $ghWorkflowFolderPath = Join-Path -Path $rootPath '.github' 'workflows' if (Test-Path -Path $ghWorkflowFolderPath) { $ghWorkflowFilesToUpdate = Get-ChildItem -Path $ghWorkflowFolderPath -Filter 'ms.*.yml' -File -Force Write-Verbose ('Update workflow files - Processing [{0}] file(s)' -f $ghWorkflowFilesToUpdate.count) @@ -190,7 +190,7 @@ if (-not $SkipPipelineUpdate) { } # Azure DevOps Pipelines - $adoPipelineFolderPath = Join-Path -Path $rootPath -ChildPath '.azuredevops\modulePipelines' + $adoPipelineFolderPath = Join-Path -Path $rootPath '.azuredevops' 'modulePipelines' if (Test-Path -Path $adoPipelineFolderPath) { $adoPipelineFilesToUpdate = Get-ChildItem -Path $adoPipelineFolderPath -Filter 'ms.*.yml' -File -Force Write-Verbose ('Update Azure DevOps pipeline files - Processing [{0}] file(s)' -f $adoPipelineFilesToUpdate.count) diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index f30170f48c..527ca3926b 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -838,7 +838,7 @@ function Set-ModuleReadMe { ) # Load external functions - . (Join-Path $PSScriptRoot 'helper/Merge-FileWithNewContent.ps1') + . (Join-Path $PSScriptRoot 'helper' 'Merge-FileWithNewContent.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1') # Check template & make full path diff --git a/utilities/tools/Test-ModuleLocally.ps1 b/utilities/tools/Test-ModuleLocally.ps1 index be56b7c2f4..4425705df8 100644 --- a/utilities/tools/Test-ModuleLocally.ps1 +++ b/utilities/tools/Test-ModuleLocally.ps1 @@ -138,12 +138,13 @@ function Test-ModuleLocally { begin { $repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent $ModuleName = Split-Path (Split-Path $TemplateFilePath -Parent) -Leaf + $utilitiesFolderPath = Split-Path $PSScriptRoot -Parent Write-Verbose "Running local tests for [$ModuleName]" # Load Tokens Converter Scripts - . (Join-Path $PSScriptRoot '../pipelines/tokensReplacement/Convert-TokensInFileList.ps1') + . (Join-Path $utilitiesFolderPath 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1') # Load Modules Validation / Deployment Scripts - . (Join-Path $PSScriptRoot '../pipelines/resourceDeployment/New-TemplateDeployment.ps1') - . (Join-Path $PSScriptRoot '../pipelines/resourceDeployment/Test-TemplateDeployment.ps1') + . (Join-Path $utilitiesFolderPath 'pipelines' 'resourceDeployment' 'New-TemplateDeployment.ps1') + . (Join-Path $utilitiesFolderPath 'pipelines' 'resourceDeployment' 'Test-TemplateDeployment.ps1') } process { @@ -156,7 +157,7 @@ function Test-ModuleLocally { } # Construct Token Configuration Input - $GlobalVariablesObject = Get-Content -Path (Join-Path $PSScriptRoot '..\..\settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables + $GlobalVariablesObject = Get-Content -Path (Join-Path $repoRootPath 'settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables $tokenConfiguration = @{ FilePathList = $moduleTestFiles Tokens = @{} diff --git a/utilities/tools/Test-NamePrefixAvailability.ps1 b/utilities/tools/Test-NamePrefixAvailability.ps1 index 0b5b36e5da..f0e9ea45de 100644 --- a/utilities/tools/Test-NamePrefixAvailability.ps1 +++ b/utilities/tools/Test-NamePrefixAvailability.ps1 @@ -42,8 +42,8 @@ function Test-NamePrefixAvailability { Write-Debug ('{0} entered' -f $MyInvocation.MyCommand) # Load helper Scripts - . (Join-Path $PSScriptRoot '../pipelines/tokensReplacement/Convert-TokensInFileList.ps1') - $root = (Get-Item $PSScriptRoot).Parent.Parent.FullName + $repoRoot = (Get-Item $PSScriptRoot).Parent.Parent.FullName + . (Join-Path $repoRoot 'utilities' 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1') } process { @@ -56,14 +56,14 @@ function Test-NamePrefixAvailability { 'Microsoft.ContainerRegistry/registries' 'Microsoft.KeyVault/vaults' ) - $parameterFiles = (Get-ChildItem -Path $root -Recurse -Filter '*.json').FullName | ForEach-Object { $_.Replace('\', '/') } + $parameterFiles = (Get-ChildItem -Path $repoRoot -Recurse -Filter '*.json').FullName | ForEach-Object { $_.Replace('\', '/') } $parameterFiles = $parameterFiles | Where-Object { $_ -match '(?:{0}).*parameters\.json' -f ($relevantResourceTypes -join '|' -replace '/', '\/+') } # Replace parameter file tokens # ----------------------------- # Tokens in settings.yml - $GlobalVariablesObject = Get-Content -Path (Join-Path $PSScriptRoot '..\..\settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables + $GlobalVariablesObject = Get-Content -Path (Join-Path $repoRoot 'settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables # Construct Token Configuration Input $tokenConfiguration = @{