Skip to content

Commit

Permalink
added Set-DescriptionFromReadme
Browse files Browse the repository at this point in the history
  • Loading branch information
majkinetor committed Sep 19, 2017
1 parent ed7ee79 commit 040063b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
35 changes: 35 additions & 0 deletions AU/Public/Set-DescriptionFromReadme.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<#
.SYNOPSIS
Updates nuspec file description from README.md
.DESCRIPTION
This script should be called in au_AfterUpdate to put the text in the README.md
into description tag of the Nuspec file. The current description will be replaced.
Function will throw an error if README.md is not found.
.PARAMETER SkipFirst
Number of start lines to skip from the README.md, by default 0.
.PARAMETER SkipLast
Number of end lines to skip from the README.md, by default 0.
.EXAMPLE
function global:au_AfterUpdate { Set-DescriptionFromReadme -SkipFirst 2 }
#>
function Set-DescriptionFromReadme([int]$SkipFirst=0, [int]$SkipLast=0) {
if (!(Test-Path README.md)) { throw 'Set-DescriptionFromReadme: README.md not found' }

Write-Host 'Setting README.md to Nuspec description tag'
$description = gc README.md -Encoding UTF8
$endIdx = $description.Length - $SkipLast
$description = $description | select -Index ($SkipFirst..$endIdx) | Out-String

$nuspecFileName = $Latest.PackageName + ".nuspec"
$nu = gc $nuspecFileName -Raw -Encoding UTF8
$nu = $nu -replace "(?smi)(\<description\>).*?(\</description\>)", "`${1}$($description)`$2"

$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
$NuPath = (Resolve-Path $NuspecFileName)
[System.IO.File]::WriteAllText($NuPath, $nu, $Utf8NoBomEncoding)
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# AU Project Changelog

## Next

- Added new function `Set-DescriptionFromReadme`.

## 2017.8.30

- `Update-AUPackages`
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To see AU in action see [video tutorial](https://www.youtube.com/watch?v=m2XpV2L
- Use only PowerShell to create automatic update script for given package.
- Automatically downloads installers and provides/verifies checksums for x32 and x64 versions.
- Verifies URLs, nuspec versions, remote repository existence etc.
- Keep nuspec descriptions in README.md files.
- Can use global variables to change functionality.
- Sugar functions for Chocolatey package maintainers.
- Update single package or any subset of previously created AU packages with a single command.
Expand Down

0 comments on commit 040063b

Please sign in to comment.