powershell

package
v2.56.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package powershell generates the PSc8y PowerShell module cmdlets and Pester tests from the api/spec/json specifications and packages the module. It is a port of the PowerShell scripts under scripts/build-powershell and reproduces their output byte-for-byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildModule

func BuildModule(moduleRoot string, version GitVersion) (string, error)

BuildModule ports Export-ProductionModule: it updates the exported function list of the source manifest, assembles the distributable module under <moduleRoot>/dist/PSc8y and packages it as <moduleRoot>/dist/PSc8y.zip. It returns the path of the created module directory.

Types

type GeneratedFile

type GeneratedFile struct {
	// RelPath is the file path relative to the module root (tools/PSc8y),
	// e.g. "Public/Get-Alarm.ps1".
	RelPath string
	// Content is the full file content including BOM and trailing newline.
	// It is nil when Remove is set.
	Content []byte
	// Remove marks the file of a deprecated command for deletion
	// (PowerShell commands do not get deprecation notices).
	Remove bool
}

GeneratedFile is one output file operation of a specification. The operations apply in order: commands sharing a cmdlet alias overwrite each other (the last command of a specification wins), exactly like the sequential file writes of the original script.

func Generate

func Generate(specDir string) ([]GeneratedFile, error)

Generate generates the file operations of all specification files in a directory, reduced to the final state per file (the last operation of a path wins).

func GenerateSpec

func GenerateSpec(data []byte) ([]GeneratedFile, error)

GenerateSpec generates the cmdlet and test file operations of one specification document.

func GenerateSpecFile

func GenerateSpecFile(specPath string) ([]GeneratedFile, error)

GenerateSpecFile generates the cmdlet and test file operations of one specification file.

type GitVersion

type GitVersion struct {
	Version      string
	Prerelease   string
	IsPrerelease bool
}

GitVersion is the module version derived from git describe (the port of Get-GitVersion).

func ResolveVersion

func ResolveVersion(dir string) (GitVersion, error)

ResolveVersion ports Get-GitVersion: git describe with a GITHUB_REF fallback, defaulting to 0.0.0.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL