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
34 changes: 34 additions & 0 deletions .github/copilot-commit-message-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: `<type>(<scope>): <subject>`

`<scope>` is optional

## Example

```
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
```

More Examples:

- `feat`: (new feature for the user, not a new feature for build script)
- `fix`: (bug fix for the user, not a fix to a build script)
- `docs`: (changes to the documentation)
- `style`: (formatting, missing semi colons, etc; no production code change)
- `refactor`: (refactoring production code, eg. renaming a variable)
- `test`: (adding missing tests, refactoring tests; no production code change)
- `chore`: (updating grunt tasks etc; no production code change)

References:

- https://www.conventionalcommits.org/
- https://seesparkbox.com/foundry/semantic_commit_messages
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html
44 changes: 44 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copilot Instructions

## Powershell Modules Code Instructions

### PowerShell Functions Instructions

Every powershell function will contain the `CmdletBinding` attribute and the `parm`iven if there are no parameters.
If the function is on the public folder of the module, we will add the Èxport-ModuleFunction` statement in the same line as the closing `}` of the function

Sample of function will be:

```powershell

function Get-UserName{
[CmdletBinding()]
param()

#Logic of the function
} Export-ModuleFunction -FunctionName 'Get-UserName'
```

### PowerShell Test Instructions

Every public function on the Test module will have the following format

- Name will start with `Test_` will follow the name of the function that we are testing with no '-'. It will follow the intention of the test splited with a '_'
- Every time we create a new function with no body we will add the `Assert-NotImplemented` statement at the end
- We will add the 3 sections as with comments `Arrange`, `Act` and `Assert` to make the test more readable.
- Sample of a test function to test `Get-UserName` function will be `Test_GetUserName_UserNotFound`

Full sample will be as follows

```powershell
function Test_GetUserName_UserNotFound{

# Arrange

# Act

# Assert

Assert-NotImplemented
}
```
2 changes: 1 addition & 1 deletion .github/workflows/powershell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion CsvHelper.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Copyright = '(c) rulasg. All rights reserved.'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
RequiredModules = @(@{ModuleName="InvokeHelper"; ModuleVersion="1.2.2"})

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
Expand Down
26 changes: 6 additions & 20 deletions CsvHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,11 @@ Write-Information -Message ("Loading {0} ..." -f ($PSCommandPath | Split-Path -L
#Module path is where resides the RootModule file. This file. :)
$MODULE_PATH = $PSScriptRoot

#Get public and private function definition files.
$Public = @( Get-ChildItem -Path $MODULE_PATH\public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $MODULE_PATH\private\*.ps1 -ErrorAction SilentlyContinue )
# Load ps1 files on code folders in order
"config","helper","include","private","public" | ForEach-Object {

#Dot source the files
Foreach($import in @($Public + $Private))
{
Try
{
. $import.fullname
Get-ChildItem -Path $MODULE_PATH\$_\*.ps1 -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
try { . $_.fullname }
catch { Write-Error -Message "Failed to import function $($import.fullname): $_" }
}
Catch
{
Write-Error -Message "Failed to import function $($import.fullname): $_"
}
}

# Here I might...
# Read in or create an initial config file and variable
# Export Public functions ($Public.BaseName) for WIP modules
# Set variables visible to the module and its functions only

}
6 changes: 3 additions & 3 deletions Test/Test.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: rulasg
#
# Generated on: 19/3/2025
# Generated on: 9/3/2025
#

@{
Expand All @@ -18,7 +18,7 @@ ModuleVersion = '0.0.1'
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '170ed18a-e725-462b-8236-3eadd3adcb79'
GUID = '6b1a63eb-2d81-4424-8b7f-9f72e3979319'

# Author of this module
Author = 'rulasg'
Expand All @@ -30,7 +30,7 @@ CompanyName = 'Unknown'
Copyright = '(c) rulasg. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''
Description = 'Module for testing and hosting shared functionality between modules'

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''
Expand Down
25 changes: 7 additions & 18 deletions Test/Test.psm1
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
Write-Information -Message ("Loading {0} ..." -f ($PSCommandPath | Split-Path -LeafBase)) -InformationAction continue
Write-Information -Message ("Loading {0} ..." -f ($PSScriptRoot | Split-Path -Leaf)) -InformationAction continue

Check warning

Code scanning / PSScriptAnalyzer

Cmdlet 'Write-Information' may be used incorrectly. Please check that all mandatory parameters are supplied. Warning

Cmdlet 'Write-Information' may be used incorrectly. Please check that all mandatory parameters are supplied.

#Module path is where resides the RootModule file. This file. :)
$MODULE_PATH = $PSScriptRoot

#Get public and private function definition files.
$Public = @( Get-ChildItem -Path $MODULE_PATH\public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $MODULE_PATH\private\*.ps1 -ErrorAction SilentlyContinue )
# Load ps1 files on code folders in order
"config","helper","include","private","public" | ForEach-Object {

#Dot source the files
Foreach($import in @($Public + $Private))
{
Try
{
. $import.fullname
}
Catch
{
Write-Error -Message "Failed to import function $($import.fullname): $_"
Get-ChildItem -Path $MODULE_PATH\$_\*.ps1 -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
try { . $_.fullname }
catch { Write-Error -Message "Failed to import function $($import.fullname): $_" }
}
}

# Here I might...
# Read in or create an initial config file and variable
# Export Public functions ($Public.BaseName) for WIP modules
# Set variables visible to the module and its functions only
Export-ModuleMember -Function Test_*

20 changes: 0 additions & 20 deletions en-US/about_CsvHelper.help.txt

This file was deleted.

6 changes: 6 additions & 0 deletions helper/mySetInvokeCommandAlias.config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# This file is required for include mySetInvokeCommandAlias to work
# The value need to be unique to avoid collisions with other modules
#

$MODULE_INVOKATION_TAG = "CsvHelperModule"

Check warning

Code scanning / PSScriptAnalyzer

The variable 'MODULE_INVOKATION_TAG' is assigned but never used. Warning

The variable 'MODULE_INVOKATION_TAG' is assigned but never used.
25 changes: 25 additions & 0 deletions helper/mySetInvokeCommandAlias.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# SET MY INVOKE COMMAND ALIAS
#
# Allows calling constitely InvokeHelper with the module tag
# Need to define a variable called $MODULE_INVOKATION_TAG
#
# Sample:
# $MODULE_INVOKATION_TAG = "SfHelperModule"

function Set-MyInvokeCommandAlias{
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory,Position=0)][string]$Alias,
[Parameter(Mandatory,Position=1)][string]$Command
)

# throw if MODULE_INVOKATION_TAG is not set or is "MyModuleModule"
if (-not $MODULE_INVOKATION_TAG -or $MODULE_INVOKATION_TAG -eq "MyModuleModule") {
throw "MODULE_INVOKATION_TAG is not set or has an invalid value ('MyModuleModule'). Please set it to a unique value before calling Set-MyInvokeCommandAlias."
}

if ($PSCmdlet.ShouldProcess("InvokeCommandAliasList", ("Add Command Alias [{0}] = [{1}]" -f $Alias, $Command))) {
InvokeHelper\Set-InvokeCommandAlias -Alias $Alias -Command $Command -Tag $MODULE_INVOKATION_TAG
}
}
91 changes: 91 additions & 0 deletions include/config.config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# CONFIG - PUBLIC
#
# This script defines aliases and functions for configuration management specific to "MyModule".
# It is intended to be included in public-facing scripts.

# Define unique aliases for "MyModule"
$CONFIG_INVOKE_GET_ROOT_PATH_ALIAS = "CsvGetConfigRootPath"
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-CsvGetConfigRootPath"

# Set the alias for the root path command
Set-MyInvokeCommandAlias -Alias $CONFIG_INVOKE_GET_ROOT_PATH_ALIAS -Command $CONFIG_INVOKE_GET_ROOT_PATH_CMD

# Define the function to get the configuration root path
function Invoke-CsvHelperGetConfigRootPath {

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Invoke-CsvHelperGetConfigRootPath' does not have a help comment. Note

The cmdlet 'Invoke-CsvHelperGetConfigRootPath' does not have a help comment.
[CmdletBinding()]
param()

$configRoot = GetConfigRootPath
return $configRoot
}

Export-ModuleMember -Function Invoke-CsvHelperGetConfigRootPath

# Extra functions not needed by INCLUDE CONFIG

function Get-CsvHelperConfig{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-CsvHelperConfig' does not have a help comment. Note

The cmdlet 'Get-CsvHelperConfig' does not have a help comment.
[CmdletBinding()]
param()

$config = Get-Configuration

return $config
} Export-ModuleMember -Function Get-CsvHelperConfig

function Save-CsvHelperConfig{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Save-CsvHelperConfig' does not have a help comment. Note

The cmdlet 'Save-CsvHelperConfig' does not have a help comment.
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeline, Position = 0)][Object]$Config

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
)

return Save-Configuration -Config $Config
} Export-ModuleMember -Function Save-CsvHelperConfig

function Open-CsvHelperConfig{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Open-CsvHelperConfig' does not have a help comment. Note

The cmdlet 'Open-CsvHelperConfig' does not have a help comment.
[CmdletBinding()]
param()

$path = GetConfigFile -Key "config"

code $path

} Export-ModuleMember -Function Open-CsvHelperConfig

function Add-CsvHelperConfigAttribute{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Add-CsvHelperConfigAttribute' does not have a help comment. Note

The cmdlet 'Add-CsvHelperConfigAttribute' does not have a help comment.
[CmdletBinding()]
param(
[Parameter(Mandatory,Position=0)][ValidateSet("Account", "User", "Opportunity")][string]$objectType,

[Parameter(Mandatory, ValueFromPipeline, Position = 1)][string]$Attribute

)

begin{
$config = Get-Configuration
$configAttribute = ($objectType + "_attributes").ToLower()

if(-Not $config){
$config = @{}
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
if(-Not $config.$configAttribute){
$config.$configAttribute = @()
}
}

process{
$config.$configAttribute += $Attribute
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
End{
$ret = Save-Configuration -Config $config
if(-Not $ret){
throw "Error saving configuration"
}

$config = Get-CsvHelperConfig
Write-Output $config.$configAttribute

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
}

} Export-ModuleMember -Function Add-CsvHelperConfigAttribute
Loading