|
2 | 2 | # |
3 | 3 | # Feature Flags management module |
4 | 4 | # |
5 | | -# Include design description |
6 | | -# This module depends on Config Include |
7 | 5 | # This module will allow set Feature Flags to the module to quicker release |
8 | 6 | # features with less risk |
9 | 7 | # |
| 8 | +# Include design description |
| 9 | +# This module depends on Config Include |
| 10 | +# Config module will depend on invokeCommand.helper.ps1, MyWrite.ps1, config.ps1, module.helper.ps1 |
| 11 | +# |
| 12 | +# As you se features keys they will be recorded on a config file. |
| 13 | +# Deprecate the FF to have it removed from the config file when the FF is released (aka set functionality to GA with now FF. |
| 14 | +# Use Clear-FeatureFlagsRegistered to remove deprecated FF from config |
| 15 | + |
10 | 16 |
|
11 | 17 | $MODULE_NAME_PATH = ($PSScriptRoot | Split-Path -Parent | Get-ChildItem -Filter *.psd1 | Select-Object -First 1) | Split-Path -Parent |
| 18 | +$MODULE_NAME = $MODULE_NAME_PATH | Split-Path -LeafBase |
12 | 19 |
|
13 | 20 | function Get-FeatureFlags{ |
14 | 21 | [CmdletBinding()] |
@@ -86,31 +93,46 @@ function Clear-FeatureFlag{ |
86 | 93 |
|
87 | 94 | } |
88 | 95 |
|
| 96 | +function Clear-FeatureFlagsRegistered{ |
| 97 | + [cmdletbinding()] |
| 98 | + param() |
| 99 | + |
| 100 | + $rffs = Get-ModuleNameRegisteredFeatureFlags |
| 101 | + $ffs = (Get-FeatureFlags).Clone() |
| 102 | + |
| 103 | + $rffs.deprecated | ForEach-Object { |
| 104 | + $ffs.Remove($_) |
| 105 | + } |
| 106 | + |
| 107 | + Save-FeatureFlags $ffs |
| 108 | + |
| 109 | +} |
| 110 | + |
89 | 111 | ###### |
90 | 112 |
|
91 | | -# function Get-ModuleNameRegisteredFeatureFlags{ |
92 | | -# [cmdletbinding()] |
93 | | -# param() |
| 113 | +function Get-ModuleNameRegisteredFeatureFlags{ |
| 114 | + [cmdletbinding()] |
| 115 | + param() |
94 | 116 |
|
95 | | -# $ffPath = $MODULE_NAME_PATH | Join-Path -ChildPath "featureflags.json" |
| 117 | + $ffPath = $MODULE_NAME_PATH | Join-Path -ChildPath "featureflags.json" |
96 | 118 |
|
97 | | -# if(! ($ffPath | Test-Path)){ |
98 | | -# return |
99 | | -# } |
| 119 | + if(! ($ffPath | Test-Path)){ |
| 120 | + return |
| 121 | + } |
100 | 122 |
|
101 | | -# $Json = Get-Content $ffPath |
| 123 | + $Json = Get-Content $ffPath |
102 | 124 |
|
103 | | -# $ff = $Json | ConvertFrom-Json |
| 125 | + $ff = $Json | ConvertFrom-Json |
104 | 126 |
|
105 | | -# return $ff |
| 127 | + return $ff |
106 | 128 |
|
107 | | -# } |
108 | | -# $function = "Get-ModuleNameRegisteredFeatureFlags" |
109 | | -# $destFunction = $function -replace "ModuleName", $MODULE_NAME |
110 | | -# if( -not (Test-Path function:$destFunction )){ |
111 | | -# Rename-Item -path Function:$function -NewName $destFunction |
112 | | -# Export-ModuleMember -Function $destFunction |
113 | | -# } |
| 129 | +} |
| 130 | +$function = "Get-ModuleNameRegisteredFeatureFlags" |
| 131 | +$destFunction = $function -replace "ModuleName", $MODULE_NAME |
| 132 | +if( -not (Test-Path function:$destFunction )){ |
| 133 | + Copy-Item -path Function:$function -Destination Function:$destFunction |
| 134 | + Export-ModuleMember -Function $destFunction |
| 135 | +} |
114 | 136 |
|
115 | 137 | function Get-ModuleNameFeatureFlags{ |
116 | 138 | [cmdletbinding()] |
@@ -142,3 +164,4 @@ if( -not (Test-Path function:$destFunction )){ |
142 | 164 | Rename-Item -path Function:$function -NewName $destFunction |
143 | 165 | Export-ModuleMember -Function $destFunction |
144 | 166 | } |
| 167 | + |
0 commit comments