Skip to content

Commit

Permalink
Merge pull request #11 from Sarafian/develop
Browse files Browse the repository at this point in the history
Release 1.1
  • Loading branch information
Sarafian authored Feb 6, 2017
2 parents a906632 + e085ed0 commit 7130445
Show file tree
Hide file tree
Showing 49 changed files with 905 additions and 220 deletions.
33 changes: 19 additions & 14 deletions Automation/Pester/Test-SDLHeaders.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,28 @@
# limitations under the License.
#>

$sourcePath=Resolve-Path "$PSScriptRoot\..\.."
$repositoryPath=Resolve-Path "$PSScriptRoot\..\.."
$modulePath=Resolve-Path "$repositoryPath\Tools\Modules"

Import-Module "$sourcePath\Tools\Modules\SDLDevTools\0.1\SDLDevTools.psm1" -Force
Import-Module "$modulePath\SDLDevTools" -Force

# Must convert to array of hash to drive the It -Testcases parameter
$filesToValidate=@()
Get-ChildItem -Path $sourcePath -Recurse -File -Exclude ".git" |Select-Object Name,FullName|ForEach-Object {
$hash=@{
Name=$_.Name
FullName=$_.FullName
}
$filesToValidate+=$hash
}
$reportToValidate=@()
Test-SDLOpenSourceHeader -ExcludeFolder ".git" -FolderPath $repositoryPath -PassThru | ForEach-Object {
$hash=@{}
$hash.FilePath=$_.FilePath
$hash.Format=$_.Format
$hash.Error=$_.Error
$hash.IsValid=$_.IsValid

$reportToValidate+=$hash
}
Describe "Verify open source headers" {
It "Test-SDLOpenSourceHeader <Name>" -TestCases $filesToValidate {
param ($Name,$FullName)
Test-SDLOpenSourceHeader -FilePath $FullName
It "Test-SDLOpenSourceHeader <FilePath>" -TestCases $reportToValidate {
param ($FilePath,$Format,$Error,$IsValid)
if(-not $IsValid)
{
Write-Warning "$Error in $FilePath"
}
$IsValid | Should BeExactly $true
}
}
116 changes: 70 additions & 46 deletions Automation/Publish-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ param(
[string]$NuGetApiKey=$null,
[Parameter(Mandatory=$true,ParameterSetName="KC2016+Dev")]
[ValidateScript({$_ -ne "PSGallery"})]
[string]$DevRepository,
[string]$DevRepository #,
<#
[Parameter(Mandatory=$true,ParameterSetName="KC2016")]
[Parameter(Mandatory=$false,ParameterSetName="KC2016+Dev")]
[switch]$ISH12=$false,
[Parameter(Mandatory=$true,ParameterSetName="KC2016+Dev")]
[Parameter(Mandatory=$false,ParameterSetName="KC2016+Dev")]
[switch]$ISH13=$false
#>
)
Set-StrictMode -Version latest

$moduleNamesToPublish=@()
switch ($PSCmdlet.ParameterSetName)
Expand All @@ -40,10 +43,7 @@ switch ($PSCmdlet.ParameterSetName)
'KC2016+Dev' {
$publishDebug=$true
$repository=$DevRepository
if($ISH12)
{
$moduleNamesToPublish+="ISHServer.12"
}
$moduleNamesToPublish+="ISHServer.12"
$moduleNamesToPublish+="ISHServer.13"
break
}
Expand All @@ -54,14 +54,14 @@ if((& "$PSScriptRoot\Test-All.ps1") -ne 0)
Write-Warning "Tests failed. Stopping..."
return
}

$changeLogPath="$PSScriptRoot\..\CHANGELOG.md"
$changeLog=Get-Content -Path $changeLogPath
if($publishDebug)
{
$revision=0
$date=(Get-Date).ToUniversalTime()
$build=[string](1200 * ($date.Year -2015)+$date.Month*100+$date.Day)
$build+=$date.ToString("HHmm")
$sourceVersion+=".$build.$revision"
}


Expand All @@ -88,7 +88,7 @@ foreach($moduleName in $moduleNamesToPublish)
New-Item -Path $modulePath -ItemType Directory|Out-Null
Write-Verbose "Temporary working folder $modulePath is ready"

Copy-Item -Path "$PSScriptRoot\..\Source\Modules\ISHServer\*.*" -Destination $modulePath -Recurse
Copy-Item -Path "$PSScriptRoot\..\Source\Modules\ISHServer\*" -Destination $modulePath -Recurse
switch ($moduleName)
{
'ISHServer.12' {
Expand Down Expand Up @@ -158,50 +158,74 @@ foreach($moduleName in $moduleNamesToPublish)
}
#endregion

if($shouldTryPublish)
{
#region manifest
Write-Debug "Generating manifest"
#region manifest
Write-Debug "Generating manifest"

Import-Module $psm1Path -Force
$exportedNames=Get-Command -Module $moduleName | Select-Object -ExcludeProperty Name

$psm1Name=$moduleName+".psm1"
$psd1Path=Join-Path $modulePath "$moduleName.psd1"
$guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd"
$hash=@{
"Author"="SDL plc"
"CompanyName" = "SDL plc"
"Copyright"="SDL plc. All rights reserved."
"RootModule"=$psm1Name
"Description"="Prerequisite automation module for SDL Knowledge Center Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
"ModuleVersion"=$sourceVersion
"Path"=$psd1Path
"LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE'
"ProjectUri"= 'https://github.com/Sarafian/ISHServer/'
"ReleaseNotes"= 'https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md'
"CmdletsToExport" = $exportedNames
"FunctionsToExport" = $exportedNames
}
switch ($moduleName)
{
'ISHServer.12' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center 2016 Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="469894fc-530e-47dd-9158-ed5148815712"
break
Import-Module $psm1Path -Force
$exportedNames=Get-Command -Module $moduleName | Select-Object -ExcludeProperty Name
$psm1Name=$moduleName+".psm1"
$psd1Path=Join-Path $modulePath "$moduleName.psd1"
$guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd"

$possition = "None"
$releaseNotes=foreach ($line in $changelogContent) {
if ($line.StartsWith("**")){
if($possition -eq "None"){
$possition="This Version"
}
'ISHServer.13' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center Content Manager 13.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="c73125ea-0914-4a1c-958b-05eccd6c2c29"
break
else
{
$possition="Next Version"
}
continue
}
If($possition -eq "This Version"){
if($line)
{
$line
}
}
}
$releaseNotes+=@(
""
"https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md"
)

$hash=@{
"Author"="SDL plc"
"CompanyName" = "SDL plc"
"Copyright"="SDL plc. All rights reserved."
"RootModule"=$psm1Name
"Description"="Prerequisite automation module for SDL Knowledge Center Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
"ModuleVersion"=$sourceVersion
"Path"=$psd1Path
"LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE'
"ProjectUri"= 'https://github.com/Sarafian/ISHServer/'
"ReleaseNotes"= $releaseNotes -join [System.Environment]::NewLine
"CmdletsToExport" = $exportedNames
"FunctionsToExport" = $exportedNames
}
switch ($moduleName)
{
'ISHServer.12' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center 2016 Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="469894fc-530e-47dd-9158-ed5148815712"
break
}
'ISHServer.13' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center Content Manager 13.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="c73125ea-0914-4a1c-958b-05eccd6c2c29"
break
}
}

New-ModuleManifest @hash
New-ModuleManifest @hash

Write-Verbose "Generated manifest"
#endregion
Write-Verbose "Generated manifest"
#endregion

if($shouldTryPublish)
{
#region publish
Write-Debug "Publishing $moduleName"
Write-Progress -Activity $progressActivity -Status "Publishing..."
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
**1.1**

- Upgraded the SDLDevTools PowerShell module to version 0.2
- `Get-ISHPrerequisites` now supports S3 buckets as source.
- `Set-ISHToolAntennaHouseLicense` now supports S3 buckets as source.
- `Test-RunningAsElevated` is now a private function in the module.
- New `Get-ISHCD` cmdlet:
- Downloads a CD from FTP or AWS S3 bucket.
- Returns the available CDs
- New `Expand-ISHCD` cmdlet expands a CD into `C:\ISHCD`.

**1.0**

- Split from [ISHBootstrap](https://github.com/Sarafian/ISHBootstrap).
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ A PowerShell module to help automate installation of prerequisites for **Knowled

The module requires elevated privileges for most of its cmdlets.

## Prerequisite and CD sources

The module can retrieve files from the following type of sources:

- FTP.
- Amazon Web Services S3 bucket.

For each different type of credentials are required.

## Preparation

To test if the operating system is compatible execute first `Test-ISHServerCompliance`.
Expand Down Expand Up @@ -38,10 +47,7 @@ NETFramework2013_4.5_MicrosoftVisualC++Redistributable_(vcredist_x64).exe
```

If you want to manually make the files available to the module then copy them to the location provided by `Get-ISHServerFolderPath`.
As an alternative, the `Get-ISHPrerequisites` cmdlet offers the option to download the files from a known location and will take care of everything.
Current options are:

- FTP. Just provide the ftp hostname, a relative folder path containing the above files and the credentials. e.g. `Get-ISHPrerequisites -Credential $Credential -FTPFolder $folderPath -FTPHost $host`.
As an alternative, the `Get-ISHPrerequisites` cmdlet offers the option to download the files will take care of everything.

## Installing and configuring

Expand All @@ -50,6 +56,16 @@ The module is structured in manner that represents the steps described in the pr
Understanding the prerequisites and how to configure them will be helpful but it is not a requirement.
An example of how to use the sequence the installation and configuration is available in [ISHBootstrap](https://github.com/Sarafian/ISHBootstrap).

## CD Management

ISHServer offers two cmdlets to download and expand the ISHCD. **Notice that it will not install a CD!**
- `Get-ISHCD` can download a CD or show the ones already downloaded and expanded.
- `Expand-ISHCD` will expand the CD.

The target path is always `C:\ISHCD\X.0.Z` where `X` is the major version and `Y` the revision.
- For `12.0.1` it's `C:\ISHCD\12.0.1`
- For `12.0.3` it's `C:\ISHCD\12.0.3`

## Maintenance

For installation and maintenance reasons, the module offers a couple of general purpose cmdlets:
Expand Down
103 changes: 103 additions & 0 deletions Source/Modules/ISHServer/Expand-ISHCD.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<#
# Copyright (c) 2014 All Rights Reserved by the SDL Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#>

function Expand-ISHCD
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[ValidatePattern(".+\.[0-9]+\.0\.[0-9]+\.[0-9]+.*\.exe")]
[string]$FileName,
[Parameter(Mandatory=$false)]
[switch]$Force=$false
)

begin
{
. $PSScriptRoot\Private\Test-RunningAsElevated.ps1
Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet

. $PSScriptRoot\Get-ISHServerFolderPath.ps1
. $PSScriptRoot\Get-ISHCD.ps1
}

process
{
$ishCDPath="C:\IshCD"

$localPath=Get-ISHServerFolderPath
$cdPath=Join-Path $localPath $FileName
if(-not (Test-Path $cdPath))
{
Write-Error "$FileName doesn't exist."
return
}
$regEx=".+\.(?<Major>[0-9]+)\.0\.(?<Build>[0-9]+)\.(?<Revision>[0-9]+).+\.exe"
if($FileName -notmatch $regEx)
{
Write-Error "$FileName has unknown format."
return
}

$major=[int]$Matches["Major"]
$build=[int]$Matches["Build"]
$revision=[int]$Matches["Revision"]

$ishVersion="$($major).0.$($revision)"
Write-Debug "ishVersion=$ishVersion"
$expandPath="$ishCDPath\$ishVersion"
Write-Debug "expandPath=$expandPath"

if($major -lt 12)
{
Write-Error "Only CD's with major version 12 or higher are supported."
}
if(Get-ISHCD -ListAvailable |Where-Object -Property Name -EQ $FileName|Where-Object -Property IsExpanded -EQ $true)
{
if(-not $Force)
{
Write-Warning "$Filename is already expanded. Skipping ..."
return
}
}

if($major -eq "12")
{
#CD is compressed with WinRar
$arguments=@("-d$expandPath","-s")
}
else
{
#CD is compressed with 7Zip
$arguments=@(
"-y"
"-gm2"
"-InstallPath=`"$($expandPath.Replace('\','\\'))`""
)
}
Write-Debug "arguments=$($arguments -join " ")"

Write-Debug "Unzipping $cdPath in $expandPath"
Start-Process $cdPath -ArgumentList $arguments -Wait
Write-Verbose "Unzipped $cdPath in $expandPath"

}

end
{

}
}
Loading

0 comments on commit 7130445

Please sign in to comment.