Skip to content

Commit 34a5a15

Browse files
committed
Layout changes for major version locking
1 parent 5697456 commit 34a5a15

File tree

4 files changed

+375
-46
lines changed

4 files changed

+375
-46
lines changed

Compress-Tasks.ps1

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
[CmdletBinding()]
22
param(
33
[Parameter(Mandatory = $true)]
4-
[string]$IndividualZipStagingPath,
4+
[string]$SourceRoot,
55

66
[Parameter(Mandatory = $true)]
7-
[string]$WrapperZipStagingPath,
7+
[string]$TargetPath,
88

9-
[Parameter(Mandatory = $true)]
10-
[string]$ZipPath)
9+
[switch]$Individually)
1110

1211
$ErrorActionPreference = 'Stop'
1312
Add-Type -Assembly 'System.IO.Compression.FileSystem'
14-
Get-ChildItem -LiteralPath $IndividualZipStagingPath |
15-
ForEach-Object {
16-
$sourceDir = $_.FullName
17-
$targetDir = [System.IO.Path]::Combine($WrapperZipStagingPath, $_.Name)
18-
Write-Host "Compressing $($_.Name)"
19-
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourceDir, "$targetDir\task.zip")
13+
if ($Individually) {
14+
# Create the target root directory.
15+
if (!(Test-Path -LiteralPath $TargetPath -PathType Container)) {
16+
$null = New-Item -Path $TargetPath -ItemType Directory
17+
}
18+
19+
# Create each task zip.
20+
Get-ChildItem -LiteralPath $SourceRoot |
21+
ForEach-Object {
22+
$sourceDir = $_.FullName
23+
$targetDir = [System.IO.Path]::Combine($TargetPath, $_.Name)
24+
Write-Host "Compressing $($_.Name)"
25+
$null = New-Item -Path $targetDir -ItemType Directory
26+
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourceDir, "$targetDir\task.zip")
27+
}
28+
} else {
29+
# Create the target directory.
30+
$targetDir = [System.IO.Path]::GetDirectoryName($TargetPath)
31+
if (!(Test-Path -LiteralPath $targetDir -PathType Container)) {
32+
$null = New-Item -Path $targetDir -ItemType Directory
2033
}
2134

22-
Write-Host "Creating $([System.IO.Path]::GetFileName($ZipPath))"
23-
$null = New-Item -Path ([System.IO.Path]::GetDirectoryName($ZipPath)) -ItemType Directory
24-
[System.IO.Compression.ZipFile]::CreateFromDirectory($WrapperZipStagingPath, $ZipPath)
35+
# Create the zip.
36+
[System.IO.Compression.ZipFile]::CreateFromDirectory($SourceRoot, $TargetPath)
37+
}

Expand-Tasks.ps1

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[CmdletBinding()]
2+
param(
3+
[Parameter(Mandatory = $true)]
4+
[string]$ZipPath,
5+
6+
[Parameter(Mandatory = $true)]
7+
[string]$TargetPath)
8+
9+
$ErrorActionPreference = 'Stop'
10+
Add-Type -Assembly 'System.IO.Compression.FileSystem'
11+
12+
# Create the target directory.
13+
if (!(Test-Path -LiteralPath $TargetPath -PathType Container)) {
14+
$null = New-Item -Path $TargetPath -ItemType Directory
15+
}
16+
17+
# Create the zip.
18+
[System.IO.Compression.ZipFile]::ExtractToDirectory($ZipPath, $TargetPath)

0 commit comments

Comments
 (0)