Files
warframe-bilder/wireframe-system/scripts/system/init-workspace.ps1
T
Vadim Flowed 1c7f9161f1 Added to Git
2026-05-10 19:01:57 +03:00

71 lines
2.2 KiB
PowerShell

param(
[Parameter(Mandatory = $false)]
[string]$WorkspaceDir = "workspace",
[Parameter(Mandatory = $false)]
[string]$ArtifactDir = "workspace/artifacts/wireframe-gen",
[Parameter(Mandatory = $false)]
[string]$LegacyArtifactDir = "artifacts/wireframe-gen"
)
$ErrorActionPreference = "Stop"
function Get-RepoRoot {
return (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
}
function Resolve-RepoPath {
param(
[string]$Root,
[string]$Path
)
if ([System.IO.Path]::IsPathRooted($Path)) { return $Path }
return Join-Path $Root $Path
}
function New-Directory {
param([string]$Path)
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Force -Path $Path | Out-Null
}
}
function Test-DirectoryHasFiles {
param([string]$Path)
if (-not (Test-Path -LiteralPath $Path)) { return $false }
return $null -ne (Get-ChildItem -LiteralPath $Path -Force -Recurse -File | Select-Object -First 1)
}
$root = Get-RepoRoot
$workspacePath = Resolve-RepoPath -Root $root -Path $WorkspaceDir
$artifactPath = Resolve-RepoPath -Root $root -Path $ArtifactDir
$legacyArtifactPath = Resolve-RepoPath -Root $root -Path $LegacyArtifactDir
New-Directory -Path $workspacePath
New-Directory -Path $artifactPath
New-Directory -Path (Join-Path $workspacePath "system-feedback/bug-reports")
New-Directory -Path (Join-Path $workspacePath ".hot-update/backups")
$targetHadFiles = Test-DirectoryHasFiles -Path $artifactPath
$legacyExists = Test-Path -LiteralPath $legacyArtifactPath
$copiedLegacy = $false
if ($legacyExists -and -not $targetHadFiles) {
Get-ChildItem -LiteralPath $legacyArtifactPath -Force | ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination $artifactPath -Recurse -Force
}
$copiedLegacy = $true
}
if (-not (Test-DirectoryHasFiles -Path $artifactPath)) {
$initArtifactsScript = Join-Path $root "scripts/wireframe/init-artifacts.ps1"
powershell -NoProfile -ExecutionPolicy Bypass -File $initArtifactsScript -ArtifactDir $artifactPath | Out-Null
}
Write-Output "Workspace initialized: $workspacePath"
Write-Output "Artifact dir: $artifactPath"
if ($copiedLegacy) {
Write-Output "Copied legacy artifacts from $legacyArtifactPath. Legacy artifacts were not deleted."
}