Install dev dependencies:
Install-Module Pester -Force Import-Module Pester -PassThru Install-Module PSScriptAnalyzer -Force Import-Module PSScriptAnalyzer -PassThru
To load the module from the project directory:
. SetupDev.ps1Repeat the command to reload module.
To see debug log messages, set:
$VerbosePreference = "Continue"To run tests:
make checkContainer based development is only tested on Linux.
Build the container:
podman build --platform linux/amd64 -t tririga-manage-ps1-dev .
Start container:
podman run --network host -v .:/workspace -it tririga-manage-ps1-dev
Initialize:
. ./SetupDev.ps1 Initialize-TririgaConfiguration . ~/.config/powershell/Microsoft.PowerShell_profile.ps1 Set-TririgaCredential LOCAL -Username system -Password badadmin
Verify:
Get-TririgaEnvironment Get-TririgaAgent LOCAL
We have commands that:
By default, operate on all instances in an environment, but can optionally operate on a single instance.
Use this model for changes that can be uniquely set on each server, such as a Property
Get-PropertyandSet-Property)[CmdletBinding()] param( # The TRIRIGA environment to use. [Parameter(Mandatory, Position=0)] [ValidateNotNullOrEmpty()] [Alias("Env", "E")] [string]$environment, # The TRIRIGA instance within the environment to use. # If omitted, command will act on all instances. [Alias("Inst", "I")] [Parameter(Position=1)] [string]$instance, ... )
If the command has other mandatory parameters, remove Position from
$instance.[CmdletBinding()] param( # The TRIRIGA environment to use. [Parameter(Mandatory, Position=0)] [ValidateNotNullOrEmpty()] [Alias("Env", "E")] [string]$environment, # The TRIRIGA instance within the environment to use. # If omitted, command will act on all instances. [Alias("Inst", "I")] [Parameter()] [string]$instance, ... [Parameter(Mandatory, Position=1)] [string]$someArg ... )
You may also want to remove Position from
$instanceto be consistent with same nouns. Eg:Set-WorkflowInstanceandGet-WorkflowInstancemust have the same semantics.By default operate on the first instance in an environment, but can optionally operate on any specific instance or all instances with the
-Allswitch (only where it makes sense).Use this models for commands that are ultimately database bound, such as
Get-AgentorStart-Agent.[CmdletBinding()] param( # The TRIRIGA environment to use. [Parameter(Mandatory, Position=0)] [ValidateNotNullOrEmpty()] [Alias("Env", "E")] [string]$environment, # The TRIRIGA instance within the environment to use. # If omitted, command will act on the first instance. [Alias("Inst", "I")] [string]$instance, # By default only one instance is queried. Set this switch to query all instances. [switch]$all ... $apiCall = @{ ... OnlyOnAnyOneInstance = !$all ... }
Any commands that will modify the system must implement the SupportsShouldProcess interface:
[CmdletBinding(SupportsShouldProcess)] param( ...
In most cases, all you need to do is pass
OperationLabeltoCallTririgaApito activate confirmation. User will be asked to confirm change to each instance.
To publish the modules to Gitea
Make sure all tests pass:
make check
Edit
install.ps1and update the version.Build dist. This will update README and module definitions:
make dist
Commmit changes
Create a tag:
make git-tag
Push all changes:
git push && git push --tags git push gitea && git push gitea --tags
Check for issues:
make release-check
Release:
make release
- https://learn.microsoft.com/en-us/powershell/gallery/concepts/publishing-guidelines
- https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands
- https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/required-development-guidelines
- https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/windows-powershell-cmdlet-concepts
- https://learn.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest
- https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-shouldprocess
- https://learn.microsoft.com/en-us/powershell/scripting/samples/using-format-commands-to-change-output-view
- https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/using-scriptanalyzer
- https://pester.dev/docs/quick-start