Skip to content

Commit 35bd928

Browse files
committed
Initial push
1 parent cbca31f commit 35bd928

11 files changed

Lines changed: 1109 additions & 25 deletions

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.ps1 -crlf
2+
*.psm1 -crlf
3+
*.psd1 -crlf
4+
5+
VirtualEngine.Compression.Tests.ps1 export-ignore
6+
VirtualEngine.Compression.png export-ignore
7+
Build.ps1 export-ignore
8+
.gitignore export-ignore
9+
.gitattributes export-ignore
10+
ChocolateyInstall.ps1 export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Releases/
2+
Release.ps1

Build.ps1

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
$Properties = @{
2+
CertificateThumbprint = 'D10BB31E5CE3048A7D4DA0A4DD681F05A85504D3';
3+
ReleaseDirectory = '.\Releases';
4+
TimeStampServer = 'http://timestamp.verisign.com/scripts/timestamp.dll';
5+
LicenseUrl = 'https://raw.githubusercontent.com/VirtualEngine/ZipArchive/master/LICENSE';
6+
DownloadBaseUrl = 'http://virtualengine.co.uk/wp-content/uploads';
7+
}
8+
9+
Import-Module VirtualEngine.Build -ErrorAction Stop;
10+
#Import-Module Posh-SSH -ErrorAction Stop;
11+
12+
$module = Get-ModuleManifest;
13+
$packageName = "$($module.Name.Replace('.','-'))-$($module.Version.ToString())";
14+
$tempDirectory = Join-Path $env:TEMP $module.Name;
15+
$zipDirectory = Join-Path $tempDirectory $module.Name;
16+
17+
task default -depends CreateReleaseZip, CreateChocolateyReleasePackage, RemoveReleaseDirectory
18+
19+
task CreateReleaseZipDirectory {
20+
Remove-Item -Path $tempDirectory -Recurse -Force -ErrorAction SilentlyContinue;
21+
[ref] $null = New-Item -Path $zipDirectory -ItemType Container;
22+
}
23+
24+
task StageReleaseZipFiles -depends CreateReleaseZipDirectory {
25+
26+
$codeSigningCert = Get-ChildItem Cert:\ -CodeSigningCert -Recurse | Where Thumbprint -eq $Properties.CertificateThumbprint;
27+
28+
foreach ($moduleFile in Get-ModuleFiles) {
29+
Copy-Item -Path $moduleFile.FullName -Destination $zipDirectory -Force;
30+
31+
if ($moduleFile.Extension -in '.ps1','.psm1') {
32+
$moduleFilePath = Join-Path $zipDirectory $moduleFile.Name;
33+
Write-Verbose ("Signing file '{0}'." -f $moduleFilePath);
34+
$signResult = Set-ScriptSigntaure -Path $moduleFilePath -Thumbprint $Properties.CertificateThumbprint -TimeStampServer $Properties.TimeStampServer;
35+
}
36+
}
37+
}
38+
39+
task CreateReleaseZip -depends StageReleaseZipFiles {
40+
$releaseDirectory = Resolve-Path (Join-Path . $Properties.ReleaseDirectory);
41+
$zipFileName = Join-Path $releaseDirectory ("{0}.zip" -f $packageName);
42+
Write-Verbose ("Zip release path '{0}'." -f $zipFileName);
43+
$zipFile = New-ZipArchive -Path $tempDirectory -DestinationPath $zipFileName;
44+
Write-Verbose ("Zip archive '{0}' created." -f $zipFile.FullName);
45+
}
46+
47+
task CreateChocolateyReleaseDirectory {
48+
Remove-Item -Path $tempDirectory -Recurse -Force -ErrorAction SilentlyContinue;
49+
[ref] $null = New-Item -Path $tempDirectory -ItemType Container;
50+
[ref] $null = New-Item -Path "$tempDirectory\tools" -ItemType Container;
51+
}
52+
53+
task StageChocolateyReleaseFiles -depends CreateChocolateyReleaseDirectory {
54+
## Create .nuspec
55+
$nuspec = $module | New-NugetNuspec -LicenseUrl $Properties.LicenseUrl;
56+
$nuspecFilename = "$($module.Name).nuspec";
57+
$nuspecPath = Join-Path $tempDirectory $nuspecFilename;
58+
$nuspec.Save($nuspecPath);
59+
60+
## Create \Tools\ChocolateyInstall.ps1
61+
$chocolateyInstallPath = Join-Path (Get-Location) 'ChocolateyInstall.ps1';
62+
Copy-Item -Path $chocolateyInstallPath -Destination "$tempDirectory\tools\" -Force;
63+
64+
## Add Install-ChocolateyZipPackage to the ChocolateyInstall.ps1 file with the relevant download link
65+
$downloadUrl = "$($Properties.DownloadBaseUrl)/$packageName.zip";
66+
$installChocolateyZipPackage = "Install-ChocolateyZipPackage '{0}' '{1}' '$userPSModulePath';" -f $packageName, $downloadUrl;
67+
Add-Content -Path "$tempDirectory\tools\ChocolateyInstall.ps1" -Value $installChocolateyZipPackage;
68+
}
69+
70+
task CreateChocolateyReleasePackage -depends StageChocolateyReleaseFiles {
71+
72+
$releaseDirectory = Resolve-Path (Join-Path . $Properties.ReleaseDirectory);
73+
Push-Location $tempDirectory;
74+
Invoke-Expression -Command ('Nuget Pack "{0}" -OutputDirectory "{1}"' -f $nuspecFileName, $releaseDirectory);
75+
Pop-Location;
76+
}
77+
78+
task PushReleaseZip -depends CreateReleaseZip {
79+
Import-Module Posh-SSH;
80+
81+
}
82+
83+
task RemoveReleaseDirectory {
84+
Remove-Item -Path $tempDirectory -Recurse -Force -ErrorAction SilentlyContinue;
85+
}

ChocolateyInstall.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Try all user module paths and return first one
2+
foreach ($modulePath in $env:PSModulePath.Split(';')) {
3+
if ($modulePath -inotlike '*\Program Files\*' -and $modulePath -inotlike '*\Windows\*') {
4+
$userPSModulePath = $modulePath;
5+
break;
6+
}
7+
}
8+

LICENSE

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
The MIT License (MIT)
2-
3-
Copyright (c) 2014 Virtual Engine
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Virtual Engine Limited
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1-
ziparchive
2-
==========
3-
4-
PowerShell module for compressing and decompressing .ZIP archives
1+
## VirtualEngine.Compression ##
2+
A PowerShell module for compressing and decompressing archive files using only native .NET Framework 4.5 classes.
3+
4+
* Create a .zip archive.
5+
* Add files to an existing .zip archive.
6+
* Extract all files from a .zip archive.
7+
* Extract individual files from a .zip archive.
8+
9+
Requires __Powershell 3.0 or above__ and the __.NET Framework v4.5 or higher__.
10+
11+
If you find it useful, unearth any bugs or have any suggestions for improvements, feel free to add an <a href="https://github.com/virtualengine/Compression/issues">issue</a> or place a comment at the project home page</a>.
12+
13+
##### Screenshots
14+
![ScreenShot](./VirtualEngine.Compression.png?raw=true)
15+
16+
##### Installation
17+
18+
* Automatic (via Chocolatey):
19+
* Run 'cinst VirtualEngine-Compression'.
20+
* Run 'Import-Module VirtualEngine-Compression'.
21+
* Manual:
22+
* Download the latest release .zip.
23+
* Extract the .zip to your somewhere in the $PSModulePath, e.g. \Document\WindowsPowerShell\Modules\.
24+
* Run 'Import-Module VirtualEngine-Compression'.
25+
* If you want it to be loaded automatically when PowerShell starts, add the line above to your PowerShell profile (see $profile).
26+
27+
#### Usage
28+
Refer to the built-in cmdlet help.
29+
30+
* <b>Get a list of available cmdlets:</b> Get-Command -Module VirtualEngine.Compression
31+
* <b>Get an individual's cmdlet help:</b> Get-Help New-ZipArchive -Full
32+
33+
##### Why?
34+
35+
Because we couldn't find a PowerShell module that doesn't require 3rd party assemblies and we needed the ability to build .zip archives with <a href="https://github.com/psake/psake">Psake</a>. In addition, this module will become a dependency for other Virtual Engine modules and DSC resources in the near future.
36+
37+
##### Implementation details
38+
Written in PowerShell :)

0 commit comments

Comments
 (0)