Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .build/template/Template.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ if (Test-Path -Path $classesDataFilePath) {

#endregion Classes

#region Enums

$enumsPath = "$PSScriptRoot\enums"

if (Test-Path -Path $enumsPath) {
Get-ChildItem -Path $enumsPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
. $_.FullName
}
}

#endregion Enums

#region Private

$privatePath = "$PSScriptRoot\private"
Expand All @@ -81,3 +93,15 @@ if (Test-Path -Path $publicPath) {
}

#endregion Public

#region Completers

$completersPath = "$PSScriptRoot\completers"

if (Test-Path -Path $completersPath) {
Get-ChildItem -Path $completersPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
. $_.FullName
}
}

#region Completers
File renamed without changes.
Empty file added .build/template/enums/.gitkeep
Empty file.
46 changes: 14 additions & 32 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Deploy to GitHub Pages
on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
Expand Down Expand Up @@ -117,20 +118,11 @@ jobs:
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root{
--bg-page:#f6f8fa;--bg-content:#fff;--bg-header:#fff;--bg-code:#f6f8fa;
--text-primary:#24292f;--text-secondary:#57606a;--text-muted:#8b949e;
--border:#d0d7de;--link:#0969da;--accent:#fd8c73;
--badge-bg:#dafbe1;--badge-text:#1a7f37;
--inline-code-bg:#eff1f3;--inline-code-text:#24292f;
}
@media(prefers-color-scheme:dark){
:root{
--bg-page:#0d1117;--bg-content:#161b22;--bg-header:#161b22;--bg-code:#1c2129;
--text-primary:#e6edf3;--text-secondary:#8b949e;--text-muted:#6e7681;
--border:#30363d;--link:#58a6ff;--accent:#f78166;
--badge-bg:#1b3826;--badge-text:#3fb950;
--inline-code-bg:#343942;--inline-code-text:#e6edf3;
}
--bg-page:#0d1117;--bg-content:#161b22;--bg-header:#161b22;--bg-code:#1c2129;
--text-primary:#e6edf3;--text-secondary:#8b949e;--text-muted:#6e7681;
--border:#30363d;--link:#58a6ff;--accent:#f78166;
--badge-bg:#1b3826;--badge-text:#3fb950;
--inline-code-bg:#343942;--inline-code-text:#e6edf3;
}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'IBM Plex Sans',-apple-system,sans-serif;color:var(--text-primary);background:var(--bg-page);line-height:1.7}
Expand Down Expand Up @@ -163,24 +155,14 @@ jobs:
pre[class*="language-"]{background:var(--bg-code) !important;padding:12px 16px;margin:8px 0 16px;color:var(--text-primary)}
pre[class*="language-"] code,code[class*="language-"]{background:transparent !important;color:inherit !important}
.token{background:none !important;text-shadow:none !important}
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#6a737d !important;font-style:italic}
.token.punctuation{color:#24292f !important}
.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#005cc5 !important}
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#032f62 !important}
.token.operator,.token.entity,.token.url{color:#d73a49 !important}
.token.atrule,.token.attr-value,.token.keyword{color:#d73a49 !important}
.token.function,.token.class-name{color:#6f42c1 !important}
.token.regex,.token.important,.token.variable{color:#e36209 !important}
@media(prefers-color-scheme:dark){
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#8b949e !important}
.token.punctuation{color:#c9d1d9 !important}
.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#ff7b72 !important}
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#a5d6ff !important}
.token.operator,.token.entity,.token.url{color:#79c0ff !important}
.token.atrule,.token.attr-value,.token.keyword{color:#d2a8ff !important}
.token.function,.token.class-name{color:#d2a8ff !important}
.token.regex,.token.important,.token.variable{color:#ffa657 !important}
}
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#8b949e !important;font-style:italic}
.token.punctuation{color:#c9d1d9 !important}
.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#ff7b72 !important}
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#a5d6ff !important}
.token.operator,.token.entity,.token.url{color:#79c0ff !important}
.token.atrule,.token.attr-value,.token.keyword{color:#d2a8ff !important}
.token.function,.token.class-name{color:#d2a8ff !important}
.token.regex,.token.important,.token.variable{color:#ffa657 !important}
details>summary{list-style:none}
details>summary::-webkit-details-marker{display:none}
.collapsible{border:1px solid var(--border);border-radius:6px;margin-bottom:8px}
Expand Down
132 changes: 132 additions & 0 deletions PSModuleTemplate/PSModuleTemplate.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#
# Module manifest for module 'PSModuleTemplate'
#
# Generated by: jdarcyryan
#
# Generated on: 22/02/2026
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'PSModuleTemplate.psm1'

# Version number of this module.
ModuleVersion = '0.3.0'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '3101ef4b-0651-47b8-ac62-adbe531f52fe'

# Author of this module
Author = 'jdarcyryan'

# Company or vendor of this module
CompanyName = 'jdarcyryan'

# Copyright statement for this module
Copyright = 'Apache 2.0 License'

# Description of the functionality provided by this module
Description = 'PSModuleTemplate'

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# 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.
FunctionsToExport = @('Get-Greeting', 'Set-SimpleMessage', 'Invoke-ClassDemo')

# 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.
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = @()

# 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.
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# 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.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

107 changes: 107 additions & 0 deletions PSModuleTemplate/PSModuleTemplate.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#region Authoring

###########################################################################
# PSModuleTemplate
# Author: James D'Arcy Ryan
# GitHub: https://github.com/jdarcyryan/PSModuleTemplate
# License: https://github.com/jdarcyryan/PSModuleTemplate/blob/main/LICENSE
#
# A standardized template for creating PowerShell modules with support for
# classes (PowerShell and C#), private functions, and public functions with
# automatic discovery and export of commands and aliases.
#
# LEGAL NOTICE:
# The license referenced above applies to the PSModuleTemplate repository
# and template structure only. Any module created using this template is
# subject to its own license as specified in the module's LICENSE file,
# which supersedes the template license for that specific module.
###########################################################################

#region Authoring

#region Classes

$classesPath = "$PSScriptRoot\classes"
$classesDataFilePath = "$classesPath\classes.psd1"

if (Test-Path -Path $classesDataFilePath) {
$classes = (Import-PowerShellDataFile -Path $classesDataFilePath).classes

$classes | foreach {
$currentClassPath = "$classesPath\$_"

if (!(Test-Path -Path $currentClassPath)) {
throw "Class '$_' does not exist."
}

$extension = (Get-Item -Path $currentClassPath).Extension

switch ($extension) {
'.ps1' {
# Process standard classes
. $currentClassPath
}
'.cs' {
# Process CSharp classes
Add-Type -Path $currentClassPath
}
'.dll' {
# Process DLLs
Add-Type -Path $currentClassPath
}
default {
throw "Unable to process class '$_', $extension is an unsupported file type."
}
}
}
}

#endregion Classes

#region Enums

$enumsPath = "$PSScriptRoot\enums"

if (Test-Path -Path $enumsPath) {
Get-ChildItem -Path $enumsPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
. $_.FullName
}
}

#endregion Enums

#region Private

$privatePath = "$PSScriptRoot\private"

if (Test-Path -Path $privatePath) {
Get-ChildItem -Path $privatePath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
. $_.FullName
}
}

#endregion Private

#region Public

$publicPath = "$PSScriptRoot\public"

if (Test-Path -Path $publicPath) {
Get-ChildItem -Path $publicPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
. $_.FullName
}
}

#endregion Public

#region Completers

$completersPath = "$PSScriptRoot\completers"

if (Test-Path -Path $completersPath) {
Get-ChildItem -Path $completersPath -Filter '*.ps1' | where PSIsContainer -eq $false | foreach {
. $_.FullName
}
}

#region Completers
29 changes: 29 additions & 0 deletions PSModuleTemplate/classes/SimpleCalculator.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<#
.SYNOPSIS
A simple PowerShell class for basic arithmetic operations.

.DESCRIPTION
This class provides basic arithmetic functionality including addition and subtraction.
It demonstrates PowerShell class implementation within the module template.
#>
class SimpleCalculator {
[int] $LastResult

SimpleCalculator() {
$this.LastResult = 0
}

[int] Add([int] $a, [int] $b) {
$this.LastResult = $a + $b
return $this.LastResult
}

[int] Subtract([int] $a, [int] $b) {
$this.LastResult = $a - $b
return $this.LastResult
}

[int] GetLastResult() {
return $this.LastResult
}
}
Loading