From 1bad9993176ac909c48ffe2734c7e37db700a08c Mon Sep 17 00:00:00 2001 From: James Ruskin Date: Wed, 7 Aug 2024 17:18:51 +0100 Subject: [PATCH] (#230) Change "files" directory to "packages" directory The manifest folders lived in a folder named after one in the Ansible project. This didn't make sense here, where it often lives inside a /files/ directory already. This has been changed. --- OfflineInstallPreparation.ps1 | 22 +++++++++++----------- Start-C4bCcmSetup.ps1 | 2 +- Start-C4bJenkinsSetup.ps1 | 6 +++--- Start-C4bNexusSetup.ps1 | 2 +- Start-C4bSetup.ps1 | 10 +++++----- {files => packages}/chocolatey.json | 0 {files => packages}/jenkins.json | 0 scripts/Create-ChocoLicensePkg.ps1 | 2 +- tests/jenkins.test.ps1 | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) rename {files => packages}/chocolatey.json (100%) rename {files => packages}/jenkins.json (100%) diff --git a/OfflineInstallPreparation.ps1 b/OfflineInstallPreparation.ps1 index 10e71ff..a1c7d4e 100644 --- a/OfflineInstallPreparation.ps1 +++ b/OfflineInstallPreparation.ps1 @@ -90,8 +90,8 @@ if (-not $Licensed) { } Copy-Item $LicensePath $InstalledLicensePath -Force } - $ExtensionSource = if (Test-Path $PSScriptRoot\files\chocolatey.extension.*.nupkg) { - Convert-Path $PSScriptRoot\files\ + $ExtensionSource = if (Test-Path $PSScriptRoot\packages\chocolatey.extension.*.nupkg) { + Convert-Path $PSScriptRoot\packages\ } else { 'https://licensedpackages.chocolatey.org/api/v2/' } @@ -103,7 +103,7 @@ $PackageWorkingDirectory = Join-Path $WorkingDirectory "Packages" if (-not (Test-Path $PackageWorkingDirectory)) { $null = New-Item -Path $PackageWorkingDirectory -ItemType Directory -Force } -foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertFrom-Json).packages) { +foreach ($Package in (Get-Content $PSScriptRoot\packages\chocolatey.json | ConvertFrom-Json).packages) { $ChocoArgs = @( "download", "$($Package.Name)" "--output-directory", $PackageWorkingDirectory @@ -118,7 +118,7 @@ foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertF } try { - if (-not (Get-ChocolateyPackageMetadata -Path $PackageWorkingDirectory -Id $Package.Name) -and -not (Get-ChocolateyPackageMetadata -Path "$PSScriptRoot\files\" -Id $Package.Name)) { + if (-not (Get-ChocolateyPackageMetadata -Path $PackageWorkingDirectory -Id $Package.Name) -and -not (Get-ChocolateyPackageMetadata -Path "$PSScriptRoot\packages\" -Id $Package.Name)) { Write-Host "Downloading '$($Package.Name)'" while ((Get-ChildItem $PackageWorkingDirectory -Filter *.nupkg).Where{$_.CreationTime -gt (Get-Date).AddMinutes(-1)}.Count -gt 5) { @@ -132,18 +132,18 @@ foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertF throw $_ } } -Move-Item -Path $PackageWorkingDirectory\*.nupkg -Destination $PSScriptRoot\files\ +Move-Item -Path $PackageWorkingDirectory\*.nupkg -Destination $PSScriptRoot\packages\ # Jenkins Plugins $PluginsWorkingDirectory = Join-Path $WorkingDirectory "JenkinsPlugins" if (-not (Test-Path $PluginsWorkingDirectory)) { $null = New-Item -Path $PluginsWorkingDirectory -ItemType Directory -Force } -if (Test-Path $PSScriptRoot\files\JenkinsPlugins.zip) { - Expand-Archive -Path $PSScriptRoot\files\JenkinsPlugins.zip -DestinationPath $PluginsWorkingDirectory -Force +if (Test-Path $PSScriptRoot\packages\JenkinsPlugins.zip) { + Expand-Archive -Path $PSScriptRoot\packages\JenkinsPlugins.zip -DestinationPath $PluginsWorkingDirectory -Force } $ProgressPreference = "Ignore" -foreach ($Plugin in (Get-Content $PSScriptRoot\files\jenkins.json | ConvertFrom-Json).plugins) { +foreach ($Plugin in (Get-Content $PSScriptRoot\packages\jenkins.json | ConvertFrom-Json).plugins) { $RestArgs = @{ Uri = "https://updates.jenkins-ci.org/latest/$($Plugin.Name).hpi" OutFile = Join-Path $PluginsWorkingDirectory "$($Plugin.Name).hpi" @@ -155,12 +155,12 @@ foreach ($Plugin in (Get-Content $PSScriptRoot\files\jenkins.json | ConvertFrom- Invoke-WebRequest @RestArgs -UseBasicParsing } } -Compress-Archive -Path $PluginsWorkingDirectory\* -Destination $PSScriptRoot\files\JenkinsPlugins.zip -Force +Compress-Archive -Path $PluginsWorkingDirectory\* -Destination $PSScriptRoot\packages\JenkinsPlugins.zip -Force # BCryptDll $null = Get-BcryptDll # License -if ($LicensePath -ne "$PSScriptRoot\files\chocolatey.license.xml") { - Copy-Item -Path (Convert-Path $LicensePath) -Destination $PSScriptRoot\files\chocolatey.license.xml +if ($LicensePath -ne "$PSScriptRoot\packages\chocolatey.license.xml") { + Copy-Item -Path (Convert-Path $LicensePath) -Destination $PSScriptRoot\packages\chocolatey.license.xml } \ No newline at end of file diff --git a/Start-C4bCcmSetup.ps1 b/Start-C4bCcmSetup.ps1 index 0d448a9..4ff7cbb 100644 --- a/Start-C4bCcmSetup.ps1 +++ b/Start-C4bCcmSetup.ps1 @@ -39,7 +39,7 @@ process { # Dot-source helper functions . .\scripts\Get-Helpers.ps1 - $Packages = (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertFrom-Json).packages + $Packages = (Get-Content $PSScriptRoot\packages\chocolatey.json | ConvertFrom-Json).packages # DB Setup Write-Host "Installing SQL Server Express" diff --git a/Start-C4bJenkinsSetup.ps1 b/Start-C4bJenkinsSetup.ps1 index b225ce6..be25d6e 100644 --- a/Start-C4bJenkinsSetup.ps1 +++ b/Start-C4bJenkinsSetup.ps1 @@ -77,10 +77,10 @@ process { Stop-Service -Name Jenkins #region Jenkins Plugin Install & Update - $JenkinsPlugins = (Get-Content $PSScriptRoot\files\jenkins.json | ConvertFrom-Json).plugins + $JenkinsPlugins = (Get-Content $PSScriptRoot\packages\jenkins.json | ConvertFrom-Json).plugins - if (Test-Path $PSScriptRoot\files\JenkinsPlugins.zip) { - Expand-Archive -Path $PSScriptRoot\files\JenkinsPlugins.zip -DestinationPath $jenkinsHome\plugins\ -Force + if (Test-Path $PSScriptRoot\packages\JenkinsPlugins.zip) { + Expand-Archive -Path $PSScriptRoot\packages\JenkinsPlugins.zip -DestinationPath $jenkinsHome\plugins\ -Force } # Performance is killed by Invoke-WebRequest's progress bars, turning them off to speed this up diff --git a/Start-C4bNexusSetup.ps1 b/Start-C4bNexusSetup.ps1 index 3736f5e..21297ac 100644 --- a/Start-C4bNexusSetup.ps1 +++ b/Start-C4bNexusSetup.ps1 @@ -65,7 +65,7 @@ process { $NuGetApiKey = (Get-NexusNuGetApiKey -Credential $Credential).apikey # Push all packages from previous steps to NuGet repo - Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\files" -Filter *.nupkg | ForEach-Object { + Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\packages" -Filter *.nupkg | ForEach-Object { choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --apikey $NugetApiKey --force } diff --git a/Start-C4bSetup.ps1 b/Start-C4bSetup.ps1 index 85c6121..24cfad0 100644 --- a/Start-C4bSetup.ps1 +++ b/Start-C4bSetup.ps1 @@ -21,9 +21,9 @@ param( [Parameter(ParameterSetName='Attended')] [string] $LicenseFile = $( - if (Test-Path $PSScriptRoot\files\chocolatey.license.xml) { + if (Test-Path $PSScriptRoot\packages\chocolatey.license.xml) { # Offline setup has been run, we should use that license. - Join-Path $PSScriptRoot "files\chocolatey.license.xml" + Join-Path $PSScriptRoot "packages\chocolatey.license.xml" } elseif (Test-Path $env:ChocolateyInstall\license\chocolatey.license.xml) { # Chocolatey is already installed, we can use that license. Join-Path $env:ChocolateyInstall "license\chocolatey.license.xml" @@ -106,7 +106,7 @@ try { Write-Host "Setting up initial directories in"$env:SystemDrive\choco-setup"" -ForegroundColor Green $ChocoPath = "$env:SystemDrive\choco-setup" $FilesDir = Join-Path $ChocoPath "files" - $PkgsDir = Join-Path $FilesDir "files" + $PkgsDir = Join-Path $FilesDir "packages" $TempDir = Join-Path $ChocoPath "temp" $TestDir = Join-Path $ChocoPath "tests" @($ChocoPath, $FilesDir, $PkgsDir, $TempDir, $TestDir) | ForEach-Object { @@ -133,8 +133,8 @@ try { & $FilesDir\OfflineInstallPreparation.ps1 -LicensePath $LicenseFile - if (Test-Path $FilesDir\files\*.nupkg) { - choco source add --name LocalChocolateySetup --source $FilesDir\files\ --Priority 1 + if (Test-Path $FilesDir\packages\*.nupkg) { + choco source add --name LocalChocolateySetup --source $FilesDir\packages\ --Priority 1 } # Set Choco Server Chocolatey Configuration diff --git a/files/chocolatey.json b/packages/chocolatey.json similarity index 100% rename from files/chocolatey.json rename to packages/chocolatey.json diff --git a/files/jenkins.json b/packages/jenkins.json similarity index 100% rename from files/jenkins.json rename to packages/jenkins.json diff --git a/scripts/Create-ChocoLicensePkg.ps1 b/scripts/Create-ChocoLicensePkg.ps1 index 3cc11f4..2eb1938 100644 --- a/scripts/Create-ChocoLicensePkg.ps1 +++ b/scripts/Create-ChocoLicensePkg.ps1 @@ -13,7 +13,7 @@ param( # Local path used to build the license package. [Parameter()] [string] - $PackagesPath = "$env:SystemDrive\choco-setup\files\files", + $PackagesPath = "$env:SystemDrive\choco-setup\files\packages", # Path to the license file. [Parameter()] diff --git a/tests/jenkins.test.ps1 b/tests/jenkins.test.ps1 index 7c48dc4..6a7c990 100644 --- a/tests/jenkins.test.ps1 +++ b/tests/jenkins.test.ps1 @@ -74,7 +74,7 @@ Describe "Jenkins Configuration" { Context "Required Plugins" { BeforeDiscovery { - $ExpectedPlugins = (Get-Content $PSScriptRoot\..\files\jenkins.json | ConvertFrom-Json).plugins.name + $ExpectedPlugins = (Get-Content $PSScriptRoot\..\packages\jenkins.json | ConvertFrom-Json).plugins.name } BeforeAll {