All Downloads are FREE. Search and download functionalities are using the official Maven repository.

powershell.Build.ps1.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{> partial_header}}
function Get-FunctionsToExport {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [ValidateNotNullOrEmpty()]
        [Alias('FullName')]
        $Path
    )

    Process {
        $Token = $null
        $ParserErr = $null

        $Ast = [System.Management.Automation.Language.Parser]::ParseFile(
            $Path,
            [ref]$Token,
            [ref]$ParserErr
        )

        if ($ParserErr) {
            throw $ParserErr
        } else {
            foreach ($name in 'Begin', 'Process', 'End') {
                foreach ($Statement in $Ast."${name}Block".Statements) {
                    if (
                        [String]::IsNullOrWhiteSpace($Statement.Name) -or
                        $Statement.Extent.ToString() -notmatch
                        ('function\W+{0}' -f $Statement.Name)
                    ) {
                        continue
                    }

                    $Statement.Name
                }
            }
        }
    }
}

$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\{{{packageName}}}\" $_}

$Manifest = @{
    Path = "$ScriptDir\src\{{{packageName}}}\{{{packageName}}}.psd1"

    Author = '{{{author}}}'
    CompanyName = '{{{companyName}}}'
    Description = '{{{packageName}}} - the PowerShell module for {{{appName}}}'
    {{#tags}}
    Tags = {{{.}}}
    {{/tags}}
    {{#projectUri}}
    ProjectUri = '{{{.}}}'
    {{/projectUri}}
    {{#licenseUri}}
    LicenseUri = '{{{.}}}'
    {{/licenseUri}}
    {{#iconUri}}
    IconUri = '{{{.}}}'
    {{/iconUri}}
    {{#releaseNotes}}
    ReleaseNotes = '{{{.}}}'
    {{/releaseNotes}}

    {{#psData}}
    PrivateData = @{
        PSData = @{
            {{{.}}}
        }
    }

    {{/psData}}
    ModuleVersion = '{{{packageVersion}}}'

    RootModule = '{{{packageName}}}.psm1'
    Guid = '{{packageGuid}}' # Has to be static, otherwise each new build will be considered different module

    PowerShellVersion = '{{{powershellVersion}}}'

    FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport

    VariablesToExport = @()
    AliasesToExport = @()
    CmdletsToExport = @()

}

New-ModuleManifest @Manifest




© 2015 - 2024 Weber Informatics LLC | Privacy Policy