Skip to content

Commit 02663f2

Browse files
authored
Merge pull request #29 from jdarcyryan/jdr/trigger_release
jdr/trigger_release
2 parents 7f1c31a + eabc3e3 commit 02663f2

14 files changed

Lines changed: 695 additions & 0 deletions
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#
2+
# Module manifest for module 'PSModuleTemplate'
3+
#
4+
# Generated by: jdarcyryan
5+
#
6+
# Generated on: 22/02/2026
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'PSModuleTemplate.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.3.0'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
19+
20+
# ID used to uniquely identify this module
21+
GUID = '3101ef4b-0651-47b8-ac62-adbe531f52fe'
22+
23+
# Author of this module
24+
Author = 'jdarcyryan'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'jdarcyryan'
28+
29+
# Copyright statement for this module
30+
Copyright = 'Apache 2.0 License'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'PSModuleTemplate'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
# PowerShellVersion = ''
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# ClrVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
# RequiredModules = @()
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @()
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
# FormatsToProcess = @()
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72+
FunctionsToExport = @('Get-Greeting', 'Set-SimpleMessage', 'Invoke-ClassDemo')
73+
74+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75+
CmdletsToExport = @()
76+
77+
# Variables to export from this module
78+
VariablesToExport = @()
79+
80+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81+
AliasesToExport = @()
82+
83+
# DSC resources to export from this module
84+
# DscResourcesToExport = @()
85+
86+
# List of all modules packaged with this module
87+
# ModuleList = @()
88+
89+
# List of all files packaged with this module
90+
# FileList = @()
91+
92+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93+
PrivateData = @{
94+
95+
PSData = @{
96+
97+
# Tags applied to this module. These help with module discovery in online galleries.
98+
# Tags = @()
99+
100+
# A URL to the license for this module.
101+
# LicenseUri = ''
102+
103+
# A URL to the main website for this project.
104+
# ProjectUri = ''
105+
106+
# A URL to an icon representing this module.
107+
# IconUri = ''
108+
109+
# ReleaseNotes of this module
110+
# ReleaseNotes = ''
111+
112+
# Prerelease string of this module
113+
# Prerelease = ''
114+
115+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
116+
# RequireLicenseAcceptance = $false
117+
118+
# External dependent modules of this module
119+
# ExternalModuleDependencies = @()
120+
121+
} # End of PSData hashtable
122+
123+
} # End of PrivateData hashtable
124+
125+
# HelpInfo URI of this module
126+
# HelpInfoURI = ''
127+
128+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129+
# DefaultCommandPrefix = ''
130+
131+
}
132+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#region Authoring
2+
3+
###########################################################################
4+
# PSModuleTemplate
5+
# Author: James D'Arcy Ryan
6+
# GitHub: https://github.com/jdarcyryan/PSModuleTemplate
7+
# License: https://github.com/jdarcyryan/PSModuleTemplate/blob/main/LICENSE
8+
#
9+
# A standardized template for creating PowerShell modules with support for
10+
# classes (PowerShell and C#), private functions, and public functions with
11+
# automatic discovery and export of commands and aliases.
12+
#
13+
# LEGAL NOTICE:
14+
# The license referenced above applies to the PSModuleTemplate repository
15+
# and template structure only. Any module created using this template is
16+
# subject to its own license as specified in the module's LICENSE file,
17+
# which supersedes the template license for that specific module.
18+
###########################################################################
19+
20+
#region Authoring
21+
22+
#region Classes
23+
24+
$classesPath = "$PSScriptRoot\classes"
25+
$classesDataFilePath = "$classesPath\classes.psd1"
26+
27+
if (Test-Path -Path $classesDataFilePath) {
28+
$classes = (Import-PowerShellDataFile -Path $classesDataFilePath).classes
29+
30+
$classes | foreach {
31+
$currentClassPath = "$classesPath\$_"
32+
33+
if (!(Test-Path -Path $currentClassPath)) {
34+
throw "Class '$_' does not exist."
35+
}
36+
37+
$extension = (Get-Item -Path $currentClassPath).Extension
38+
39+
switch ($extension) {
40+
'.ps1' {
41+
# Process standard classes
42+
. $currentClassPath
43+
}
44+
'.cs' {
45+
# Process CSharp classes
46+
Add-Type -Path $currentClassPath
47+
}
48+
default {
49+
throw "Unable to process class '$_', $extension is an unsupported file type."
50+
}
51+
}
52+
}
53+
}
54+
55+
#endregion Classes
56+
57+
#region Private
58+
59+
$privatePath = "$PSScriptRoot\private"
60+
61+
if (Test-Path -Path $privatePath) {
62+
Get-ChildItem -Path $privatePath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
63+
. $_.FullName
64+
}
65+
}
66+
67+
#endregion Private
68+
69+
#region Public
70+
71+
$publicPath = "$PSScriptRoot\public"
72+
73+
if (Test-Path -Path $publicPath) {
74+
Get-ChildItem -Path $publicPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
75+
. $_.FullName
76+
}
77+
}
78+
79+
#endregion Public
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<#
2+
.SYNOPSIS
3+
A simple PowerShell class for basic arithmetic operations.
4+
5+
.DESCRIPTION
6+
This class provides basic arithmetic functionality including addition and subtraction.
7+
It demonstrates PowerShell class implementation within the module template.
8+
#>
9+
class SimpleCalculator {
10+
[int] $LastResult
11+
12+
SimpleCalculator() {
13+
$this.LastResult = 0
14+
}
15+
16+
[int] Add([int] $a, [int] $b) {
17+
$this.LastResult = $a + $b
18+
return $this.LastResult
19+
}
20+
21+
[int] Subtract([int] $a, [int] $b) {
22+
$this.LastResult = $a - $b
23+
return $this.LastResult
24+
}
25+
26+
[int] GetLastResult() {
27+
return $this.LastResult
28+
}
29+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
3+
namespace PSModuleTemplate
4+
{
5+
/// <summary>
6+
/// A simple C# class for string manipulation operations.
7+
/// </summary>
8+
public class StringHelper
9+
{
10+
/// <summary>
11+
/// Reverses the characters in a string.
12+
/// </summary>
13+
/// <param name="input">The string to reverse.</param>
14+
/// <returns>The reversed string.</returns>
15+
public static string ReverseString(string input)
16+
{
17+
if (string.IsNullOrEmpty(input))
18+
return input;
19+
20+
char[] charArray = input.ToCharArray();
21+
Array.Reverse(charArray);
22+
return new string(charArray);
23+
}
24+
25+
/// <summary>
26+
/// Counts the number of words in a string.
27+
/// </summary>
28+
/// <param name="input">The string to count words in.</param>
29+
/// <returns>The number of words.</returns>
30+
public static int CountWords(string input)
31+
{
32+
if (string.IsNullOrWhiteSpace(input))
33+
return 0;
34+
35+
string[] words = input.Split(new char[] { ' ', '\t', '\n', '\r' },
36+
StringSplitOptions.RemoveEmptyEntries);
37+
return words.Length;
38+
}
39+
}
40+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
classes = @(
3+
,'SimpleCalculator.ps1'
4+
,'StringHelper.cs'
5+
)
6+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the current user's name from the environment.
4+
5+
.DESCRIPTION
6+
This private function retrieves the current user's name from the Windows environment variables.
7+
It provides a simple way to get the logged-in user's identity.
8+
9+
.EXAMPLE
10+
Get-CurrentUser
11+
12+
Returns the current user's name, e.g., "JohnDoe"
13+
14+
.NOTES
15+
This is a private helper function used internally by the module.
16+
#>
17+
function Get-CurrentUser {
18+
[CmdletBinding()]
19+
param()
20+
21+
return $env:USERNAME
22+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<#
2+
.SYNOPSIS
3+
Tests if a string meets the specified length requirements.
4+
5+
.DESCRIPTION
6+
This private function validates whether a given string meets minimum and maximum length requirements.
7+
It returns a boolean value indicating whether the string passes the length validation.
8+
9+
.PARAMETER InputString
10+
The string to test for length requirements.
11+
12+
.PARAMETER MinLength
13+
The minimum required length for the string. Default is 1.
14+
15+
.PARAMETER MaxLength
16+
The maximum allowed length for the string. Default is 100.
17+
18+
.EXAMPLE
19+
Test-StringLength -InputString "Hello" -MinLength 3 -MaxLength 10
20+
21+
Returns: $true
22+
23+
.EXAMPLE
24+
Test-StringLength -InputString "Hi" -MinLength 5
25+
26+
Returns: $false
27+
28+
.NOTES
29+
This is a private helper function for string validation within the module.
30+
#>
31+
function Test-StringLength {
32+
[CmdletBinding()]
33+
param(
34+
[Parameter(Mandatory = $true)]
35+
[AllowEmptyString()]
36+
[string]
37+
$InputString,
38+
39+
[int]
40+
$MinLength = 1,
41+
42+
[int]
43+
$MaxLength = 100
44+
)
45+
46+
$length = $InputString.Length
47+
return ($length -ge $MinLength -and $length -le $MaxLength)
48+
}

0 commit comments

Comments
 (0)