diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 85a6557..1e3c6f9 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -11,18 +11,24 @@ $SRC_PATH = (Get-Location).Path function create_folder { param ( [string]$base_path, - [string]$folder_name + [string]$folder_name, + [switch]$recreate ) $target_path = Join-Path -Path $base_path -ChildPath $folder_name - if (-not (Test-Path -Path $target_path)){ + $target_path_exists = Test-Path -Path $target_path + if (-not $target_path_exists){ Write-Output "[PWSH] Folder >$folder_name< not existing. Create..." New-Item -Path $target_path -ItemType Directory } + elseif ($target_path_exists -and $recreate){ + Write-Output "[PWSH] Folder >$folder_name< exists, but should be recreated..." + Remove-Item -Path $target_path -Recurse -Force + New-Item -Path $target_path -ItemType Directory + } else { Write-Output "Folder >$folder_name< already exists." } - } Write-Output "Build Pipeline for d-opt Wattana (wattanalyse) project" @@ -38,7 +44,7 @@ Write-Output "Deleted outstanding artifacts successfully" Write-Output "Create folders..." -create_folder -base_path $ENV_PATH -folder_name 'data' +create_folder -base_path $ENV_PATH -folder_name 'data' -recreate create_folder -base_path $ENV_PATH -folder_name 'data/logs' create_folder -base_path $ENV_PATH -folder_name 'config' @@ -62,22 +68,22 @@ if ($? -eq $false){ } Write-Output "Built package successfully" -# TODO documentation -# Write-Output "Generate docs..." -# .\scripts\cvt_docs.ps1 -# if ($? -eq $false){ -# Write-Output "[PWSH] Exiting script because there errors while generating the doc files" -# Exit -# } -# Write-Output "Generated doc files successfully" -# Write-Output "Copying doc files..." -# $docs_src_path = Join-Path -Path $SRC_PATH -ChildPath 'docs\*.pdf' -# Copy-Item -Path $docs_src_path -Destination $ENV_PATH -Force -# if ($? -eq $false){ -# Write-Output "[PWSH] Exiting script because there were errors while copying the doc files" -# Exit -# } -# Write-Output "Copied doc files successfully" +# docs +Write-Output "Generate docs..." +.\scripts\cvt_docs.ps1 +if ($? -eq $false){ + Write-Output "[PWSH] Exiting script because there errors while generating the doc files" + Exit +} +Write-Output "Generated doc files successfully" +Write-Output "Copying doc files..." +$docs_src_path = Join-Path -Path $SRC_PATH -ChildPath 'docs\*.pdf' +Copy-Item -Path $docs_src_path -Destination $ENV_PATH -Force +if ($? -eq $false){ + Write-Output "[PWSH] Exiting script because there were errors while copying the doc files" + Exit +} +Write-Output "Copied doc files successfully" Write-Output "Go into env directory..." @@ -90,6 +96,7 @@ if ($? -eq $false){ } Write-Output "Successfully installed package" +# TODO check removal # copy database file # Write-Output "Copying database files..." # $copy_file = Join-Path -Path $SRC_PATH -ChildPath 'data/db/wce_grunderfassung.db' @@ -129,16 +136,16 @@ if ($? -eq $false){ } Write-Output "Copied config file successfully" -# TODO check needed? + # copy startup script files -# Write-Output "Copying startup scripts..." -# $copy_file = Join-Path -Path $SRC_PATH -ChildPath 'scripts/start.bat' -# Copy-Item -Path $copy_file -Destination $ENV_PATH -Force -# if ($? -eq $false){ -# Write-Output "[PWSH] Exiting script because there were errors while copying startup scripts" -# Exit -# } -# Write-Output "Copied startup scripts successfully" +Write-Output "Copying startup scripts..." +$copy_file = Join-Path -Path $SRC_PATH -ChildPath 'deployment/startup*' +Copy-Item -Path $copy_file -Destination $ENV_PATH -Force +if ($? -eq $false){ + Write-Output "[PWSH] Exiting script because there were errors while copying startup scripts" + Exit +} +Write-Output "Copied startup scripts successfully" # env preparation