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
2 changes: 1 addition & 1 deletion .github/copilot-commit-message-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ More Examples:
- `chore`: (updating grunt tasks etc; no production code change)

References:
- https://gist.githubusercontent.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716/raw/e75b1b9536ee5ee82e2ec0ba8948d8f8238488c3/semantic-commit-messages.md

- https://www.conventionalcommits.org/
- https://seesparkbox.com/foundry/semantic_commit_messages
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html
8 changes: 6 additions & 2 deletions Test/include/callPrivateContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
function Invoke-PrivateContext {
param (
[Parameter(Mandatory, Position = 0)]
[scriptblock]$ScriptBlock
[scriptblock]$ScriptBlock,
[string]$ModulePath
)

$modulePath = $MODULE_PATH | Split-Path -Parent
if ([string]::IsNullOrEmpty($ModulePath)) {
$modulePath = $MODULE_PATH | Split-Path -Parent
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$module = Import-Module -Name $modulePath -PassThru

if ($null -eq $module) {
Expand Down
25 changes: 18 additions & 7 deletions Test/include/config.mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,40 @@
if(-not $MODULE_NAME){ throw "Missing MODULE_NAME varaible initialization. Check for module.helerp.ps1 file." }

$MOCK_CONFIG_PATH = "test_config_path"
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-$($MODULE_NAME)GetConfigRootPath"
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-ProjectHelperGetConfigRootPath"

function Mock_Config{
param(
[Parameter(Position=0)][string] $key = "config",
[Parameter(Position=1)][object] $Config
[Parameter(Position=1)][object] $Config,
[Parameter(Position=2)][string] $ModuleName,
[Parameter(Position=3)][string] $MockPath = $MOCK_CONFIG_PATH
)

# Remove mock config path if exists
if(Test-Path $MOCK_CONFIG_PATH){
Remove-Item -Path $MOCK_CONFIG_PATH -ErrorAction SilentlyContinue -Recurse -Force
if(Test-Path $MockPath){
Remove-Item -Path $fullpath -ErrorAction SilentlyContinue -Recurse -Force
}

# create mock config path
New-Item -Path $MOCK_CONFIG_PATH -ItemType Directory -Force
New-Item -Path $MockPath -ItemType Directory -Force

# make full and not relative path
$fullpath = $MockPath | Resolve-Path

# if $config is not null save it to a file
if($null -ne $Config){
$configfile = Join-Path -Path $MOCK_CONFIG_PATH -ChildPath "$key.json"
$configfile = Join-Path -Path $fullpath -ChildPath "$key.json"
$Config | ConvertTo-Json -Depth 10 | Set-Content $configfile
}

if([string]::IsNullOrWhiteSpace($ModuleName)){
$moduleName = $MODULE_NAME
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$invokefunction = $CONFIG_INVOKE_GET_ROOT_PATH_CMD -replace "ProjectHelper", $moduleName

# Mock invoke call
MockCallToString $CONFIG_INVOKE_GET_ROOT_PATH_CMD -OutString $MOCK_CONFIG_PATH
MockCallToString $invokefunction -OutString $fullpath

}
12 changes: 6 additions & 6 deletions include/MyWrite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ function Enable-ModuleNameVerbose{
$moduleDebugVarName = $MODULE_NAME + "_VERBOSE"
[System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $flag)
}
Rename-Item -path Function:Enable-ModuleNameVerbose -NewName "Set-$($MODULE_NAME)Verbose"
Export-ModuleMember -Function "Set-$($MODULE_NAME)Verbose"
Copy-Item -path Function:Enable-ModuleNameVerbose -Destination Function:"Enable-$($MODULE_NAME)Verbose"
Export-ModuleMember -Function "Enable-$($MODULE_NAME)Verbose"

function Disable-ModuleNameVerbose{
param()

$moduleDebugVarName = $MODULE_NAME + "_VERBOSE"
[System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $null)
}
Rename-Item -path Function:Disable-ModuleNameVerbose -NewName "Clear-$($MODULE_NAME)Verbose"
Export-ModuleMember -Function "Clear-$($MODULE_NAME)Verbose"
Copy-Item -path Function:Disable-ModuleNameVerbose -Destination Function:"Disable-$($MODULE_NAME)Verbose"
Export-ModuleMember -Function "Disable-$($MODULE_NAME)Verbose"

function Test-MyDebug {
param(
Expand Down Expand Up @@ -173,7 +173,7 @@ function Enable-ModuleNameDebug{
$moduleDebugVarName = $MODULE_NAME + "_DEBUG"
[System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $flag)
}
Rename-Item -path Function:Enable-ModuleNameDebug -NewName "Enable-$($MODULE_NAME)Debug"
Copy-Item -path Function:Enable-ModuleNameDebug -Destination Function:"Enable-$($MODULE_NAME)Debug"
Export-ModuleMember -Function "Enable-$($MODULE_NAME)Debug"

function Disable-ModuleNameDebug {
Expand All @@ -182,7 +182,7 @@ function Disable-ModuleNameDebug {
$moduleDebugVarName = $MODULE_NAME + "_DEBUG"
[System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $null)
}
Rename-Item -path Function:Disable-ModuleNameDebug -NewName "Disable-$($MODULE_NAME)Debug"
Copy-Item -path Function:Disable-ModuleNameDebug -Destination Function:"Disable-$($MODULE_NAME)Debug"
Export-ModuleMember -Function "Disable-$($MODULE_NAME)Debug"

function Get-ObjetString {
Expand Down
10 changes: 6 additions & 4 deletions include/config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#

# MODULE_NAME
$MODULE_NAME = ($PSScriptRoot | Split-Path -Parent | Get-ChildItem -Filter *.psd1 | Select-Object -First 1).BaseName
$MODULE_NAME_PATH = ($PSScriptRoot | Split-Path -Parent | Get-ChildItem -Filter *.psd1 | Select-Object -First 1) | Split-Path -Parent
$MODULE_NAME = $MODULE_NAME_PATH | Split-Path -LeafBase

if(-Not $MODULE_NAME){ throw "Module name not found. Please check the module structure." }

$CONFIG_ROOT = [System.Environment]::GetFolderPath('UserProfile') | Join-Path -ChildPath ".helpers" -AdditionalChildPath $MODULE_NAME, "config"
Expand Down Expand Up @@ -126,7 +128,7 @@ function Invoke-ModuleNameGetConfigRootPath {
$function = "Invoke-ModuleNameGetConfigRootPath"
$destFunction = $function -replace "ModuleName", $MODULE_NAME
if( -not (Test-Path function:$destFunction )){
Rename-Item -path Function:$function -NewName $destFunction
Copy-Item -path Function:$function -Destination Function:$destFunction
Export-ModuleMember -Function $destFunction
}

Expand All @@ -143,7 +145,7 @@ function Get-ModuleNameConfig{
$function = "Get-ModuleNameConfig"
$destFunction = $function -replace "ModuleName", $MODULE_NAME
if( -not (Test-Path function:$destFunction )){
Rename-Item -path Function:$function -NewName $destFunction
Copy-Item -path Function:$function -Destination Function:$destFunction
Export-ModuleMember -Function $destFunction
}

Expand All @@ -158,7 +160,7 @@ function Open-ModuleNameConfig{
$function = "Open-ModuleNameConfig"
$destFunction = $function -replace "ModuleName", $MODULE_NAME
if( -not (Test-Path function:$destFunction )){
Rename-Item -path Function:$function -NewName $destFunction
Copy-Item -path Function:$function -Destination Function:$destFunction
Export-ModuleMember -Function $destFunction
}

Expand Down
61 changes: 42 additions & 19 deletions include/featureflag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
#
# Feature Flags management module
#
# Include design description
# This module depends on Config Include
# This module will allow set Feature Flags to the module to quicker release
# features with less risk
#
# Include design description
# This module depends on Config Include
# Config module will depend on invokeCommand.helper.ps1, MyWrite.ps1, config.ps1, module.helper.ps1
#
# As you se features keys they will be recorded on a config file.
# Deprecate the FF to have it removed from the config file when the FF is released (aka set functionality to GA with now FF.
# Use Clear-FeatureFlagsRegistered to remove deprecated FF from config


$MODULE_NAME_PATH = ($PSScriptRoot | Split-Path -Parent | Get-ChildItem -Filter *.psd1 | Select-Object -First 1) | Split-Path -Parent
$MODULE_NAME = $MODULE_NAME_PATH | Split-Path -LeafBase

function Get-FeatureFlags{
[CmdletBinding()]
Expand Down Expand Up @@ -86,31 +93,46 @@

}

function Clear-FeatureFlagsRegistered{
[cmdletbinding()]
param()

$rffs = Get-ModuleNameRegisteredFeatureFlags
$ffs = (Get-FeatureFlags).Clone()

$rffs.deprecated | ForEach-Object {
$ffs.Remove($_)
}

Save-FeatureFlags $ffs

}

######

# function Get-ModuleNameRegisteredFeatureFlags{
# [cmdletbinding()]
# param()
function Get-ModuleNameRegisteredFeatureFlags{

Check warning

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-ModuleNameRegisteredFeatureFlags' uses a plural noun. A singular noun should be used instead. Warning

The cmdlet 'Get-ModuleNameRegisteredFeatureFlags' uses a plural noun. A singular noun should be used instead.
[cmdletbinding()]
param()

# $ffPath = $MODULE_NAME_PATH | Join-Path -ChildPath "featureflags.json"
$ffPath = $MODULE_NAME_PATH | Join-Path -ChildPath "featureflags.json"

# if(! ($ffPath | Test-Path)){
# return
# }
if(! ($ffPath | Test-Path)){
return
}

# $Json = Get-Content $ffPath
$Json = Get-Content $ffPath

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

# $ff = $Json | ConvertFrom-Json
$ff = $Json | ConvertFrom-Json

# return $ff
return $ff

# }
# $function = "Get-ModuleNameRegisteredFeatureFlags"
# $destFunction = $function -replace "ModuleName", $MODULE_NAME
# if( -not (Test-Path function:$destFunction )){
# Rename-Item -path Function:$function -NewName $destFunction
# Export-ModuleMember -Function $destFunction
# }
}
$function = "Get-ModuleNameRegisteredFeatureFlags"
$destFunction = $function -replace "ModuleName", $MODULE_NAME
if( -not (Test-Path function:$destFunction )){
Copy-Item -path Function:$function -Destination Function:$destFunction
Export-ModuleMember -Function $destFunction
}

function Get-ModuleNameFeatureFlags{
[cmdletbinding()]
Expand Down Expand Up @@ -142,3 +164,4 @@
Rename-Item -path Function:$function -NewName $destFunction
Export-ModuleMember -Function $destFunction
}

Loading