diff --git a/src/ALZ/Private/New-FolderStructure.ps1 b/src/ALZ/Private/New-FolderStructure.ps1 index 4f618399..45c357e0 100644 --- a/src/ALZ/Private/New-FolderStructure.ps1 +++ b/src/ALZ/Private/New-FolderStructure.ps1 @@ -14,17 +14,38 @@ function New-FolderStructure { [string] $targetFolder, [Parameter(Mandatory = $false)] - [string] $sourceFolder + [string] $sourceFolder, + + [Parameter(Mandatory = $false)] + [string] $overrideSourceDirectoryPath = "" ) if ($PSCmdlet.ShouldProcess("ALZ-Terraform module configuration", "modify")) { Write-Verbose "Downloading modules to $targetDirectory" + if(!($release.StartsWith("v")) -and ($release -ne "latest")) { $release = "v$release" } - $releaseTag = Get-GithubRelease -githubRepoUrl $url -targetDirectory $targetDirectory -moduleSourceFolder $sourceFolder -moduleTargetFolder $targetFolder -release $release - $path = Join-Path $targetDirectory $targetFolder $releaseTag + $releaseTag = "" + $path = "" + + if($overrideSourceDirectoryPath -ne "") { + $releaseTag = "local" + $path = Join-Path $targetDirectory $targetFolder $releaseTag + + if(Test-Path $path) { + Write-Verbose "Folder $path already exists, so not copying files." + } else { + Write-InformationColored "Copying files from $overrideSourceDirectoryPath to $path" -ForegroundColor Green -InformationAction Continue + New-Item -Path $path -ItemType "Directory" + Copy-Item -Path "$overrideSourceDirectoryPath/$sourceFolder/*" -Destination "$path" -Recurse | Out-String | Write-Verbose + } + + } else { + $releaseTag = Get-GithubRelease -githubRepoUrl $url -targetDirectory $targetDirectory -moduleSourceFolder $sourceFolder -moduleTargetFolder $targetFolder -release $release + $path = Join-Path $targetDirectory $targetFolder $releaseTag + } Write-Verbose "Version $releaseTag is located in $path" diff --git a/src/ALZ/Public/New-ALZEnvironment.ps1 b/src/ALZ/Public/New-ALZEnvironment.ps1 index 5ca6005d..241ea89f 100644 --- a/src/ALZ/Public/New-ALZEnvironment.ps1 +++ b/src/ALZ/Public/New-ALZEnvironment.ps1 @@ -142,11 +142,11 @@ function New-ALZEnvironment { } # Download the bootstrap modules - $bootstrapReleaseTag = "local" - $bootstrapPath = $bootstrapModuleOverrideFolderPath + $bootstrapReleaseTag = "" + $bootstrapPath = "" $bootstrapTargetFolder = "bootstrap" - if($bootstrapModuleOverrideFolderPath -eq "" -and !$isLegacyBicep) { + if(!$isLegacyBicep) { $versionAndPath = $null Write-InformationColored "Checking and Downloading the bootstrap module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue @@ -159,7 +159,8 @@ function New-ALZEnvironment { -url $bootstrapModuleUrl ` -release $bootstrapRelease ` -targetFolder $bootstrapTargetFolder ` - -sourceFolder $bootstrapSourceFolder + -sourceFolder $bootstrapSourceFolder ` + -overrideSourceDirectoryPath $bootstrapModuleOverrideFolderPath } $bootstrapReleaseTag = $versionAndPath.releaseTag $bootstrapPath = $versionAndPath.path @@ -234,10 +235,10 @@ function New-ALZEnvironment { } # Download the starter modules - $starterReleaseTag = "local" - $starterPath = $starterModuleOverrideFolderPath + $starterReleaseTag = "" + $starterPath = "" - if($starterModuleOverrideFolderPath -eq "" -and ($hasStarterModule -or $isLegacyBicep)) { + if(($hasStarterModule -or $isLegacyBicep)) { $versionAndPath = $null Write-InformationColored "Checking and Downloading the starter module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue @@ -250,7 +251,8 @@ function New-ALZEnvironment { -url $starterModuleUrl ` -release $starterRelease ` -targetFolder $starterModuleTargetFolder ` - -sourceFolder $starterModuleSourceFolder + -sourceFolder $starterModuleSourceFolder ` + -overrideSourceDirectoryPath $starterModuleOverrideFolderPath } $starterReleaseTag = $versionAndPath.releaseTag