Skip to content

Commit f204d31

Browse files
authored
81-ref-move-helpersps1-to-toolshelperps1 (#95)
* Move scripts to tools * ScriptAnalyzer suggestion * Rename deploy-helper.ps1 to deploy.helper.ps1 * rename to sync.helper.ps1 * ref: Tools path management
1 parent fb1a1af commit f204d31

File tree

11 files changed

+47
-47
lines changed

11 files changed

+47
-47
lines changed

TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
$TOOLS_RELATIVE_PATH = "tools"
3+
24
function TestingHelperTest_AssertAddSection_throwOnNull{
35
# All asserts here has a pattern
46
# This test will confirm tht the pattern will not miss a false negative
@@ -27,20 +29,6 @@ function Assert-AddDevContainerJson{
2729
}
2830
}
2931

30-
# Git Repository
31-
function Assert-AddGitRepository{
32-
param(
33-
[Parameter(Mandatory,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
34-
[Alias("PSPath")][ValidateNotNullOrEmpty()]
35-
[string] $Path
36-
)
37-
process{
38-
$Path = $Path | Convert-Path
39-
40-
Assert-ItemExist -Path ($Path | Join-Path -ChildPath ".git") -Comment ".git"
41-
}
42-
}
43-
4432

4533
# License
4634
function Assert-AddLicense{
@@ -119,10 +107,10 @@ function Assert-AddDeployScript{
119107
process{
120108
$Path = $Path | Convert-Path
121109

122-
$toolsPath = $Path | Join-Path -ChildPath "tools"
110+
$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH
123111

124112
Assert-ItemExist -Path ($Path | Join-Path -ChildPath "deploy.ps1") -Comment "deploy.ps1"
125-
Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "deploy-helper.ps1") -Comment "deploy-helper.ps1"
113+
Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "deploy.Helper.ps1") -Comment "deploy.Helper.ps1"
126114
}
127115
}
128116

@@ -150,8 +138,10 @@ function Assert-AddSyncScript{
150138
process{
151139
$Path = $Path | Convert-Path
152140

141+
$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH
142+
153143
Assert-ItemExist -Path ($Path | Join-Path -ChildPath "sync.ps1") -Comment "sync.ps1"
154-
Assert-ItemExist -Path (($Path | Join-Path -ChildPath "tools") | Join-Path -ChildPath "sync-helper.ps1") -Comment "sync-helper.ps1"
144+
Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "sync.Helper.ps1") -Comment "sync.Helper.ps1"
155145
}
156146
}
157147

deploy.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ param(
4343
$MODULE_PATH = $PSScriptRoot
4444
$MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase
4545
$MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1"
46+
$MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools"
4647

4748
# Load helper
4849
# We dot souce the ps1 to allow all code to be in the same scope as the script
4950
# Easier to inject for testing with DependecyInjection parameter
50-
. ($MODULE_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1")
51+
. ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1")
5152
if ($DependencyInjection) {
5253
. $DependencyInjection
5354
}

docs/structure-of-a-module.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
## Tools Scripts
2121

2222
1. publish.ps1
23-
1. publish-helper.ps1
23+
1. deploy.Helper.ps1er.ps1
2424
2. release.ps1
2525
3. sync.ps1
26-
1. sync-helper.ps1
26+
1. sync.Helper.ps1
2727

2828
## Workflows
2929

private/templates/template.v3.deploy-helper.ps1 renamed to private/templates/template.v3.deploy.Helper.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
It is not intended to be used directly.
1212
1313
.LINK
14-
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy-helper.ps1
14+
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy.Helper.ps1
15+
https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy.Helper.ps1
16+
https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1
1517
1618
#>
1719

private/templates/template.v3.deploy.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ param(
4343
$MODULE_PATH = $PSScriptRoot
4444
$MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase
4545
$MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1"
46+
$MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools"
4647

4748
# Load helper
4849
# We dot souce the ps1 to allow all code to be in the same scope as the script
4950
# Easier to inject for testing with DependecyInjection parameter
50-
. ($MODULE_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1")
51+
. ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1")
5152
if ($DependencyInjection) {
5253
. $DependencyInjection
5354
}

private/templates/template.v3.sync.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ $MODULE_PATH = $PSScriptRoot
1717
$TOOLS_PATH = $MODULE_PATH | Join-Path -ChildPath "tools"
1818
$WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows"
1919

20-
. ($TOOLS_PATH | Join-Path -ChildPath "sync-helper.ps1")
20+
. ($TOOLS_PATH | Join-Path -ChildPath "sync.Helper.ps1")
2121

22-
Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml'
23-
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
24-
Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml'
22+
Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml'
23+
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
24+
Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml'
2525

26-
Save-UrlContentToFile -File 'deploy-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1'
27-
Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1'
26+
Save-UrlContentToFile -File 'deploy.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1'
27+
Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1'
2828

29-
Save-UrlContentToFile -File 'sync-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1'
30-
Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1'
29+
Save-UrlContentToFile -File 'sync.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.Helper.ps1'
30+
Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1'
3131

32-
Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
33-
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'
32+
Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
33+
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'

public/Add-ToModule.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# -Force: If the file already exists, it will be overwritten withe the default values
66
# The output will be the Path of the module updated. This way we may pipe with next Add-ToModule* function
77

8+
$TOOLS_RELATIVE_PATH = "tools"
9+
810
function Add-ToModuleSampleCode{
911
[CmdletBinding(SupportsShouldProcess)]
1012
param(
@@ -142,8 +144,10 @@ function Add-ToModuleDeployScript{
142144
process{
143145
$Path = NormalizePath -Path:$Path ?? return $null
144146

147+
$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH
148+
145149
Import-Template -Force:$Force -Path $Path -File "deploy.ps1" -Template "template.v3.deploy.ps1"
146-
Import-Template -Force:$Force -Path ($Path | Join-path -ChildPath "tools") -File "deploy-helper.ps1" -Template "template.v3.deploy-helper.ps1"
150+
Import-Template -Force:$Force -Path $toolsPath -File "deploy.Helper.ps1" -Template "template.v3.deploy.Helper.ps1"
147151

148152
return ReturnValue -Path $Path -Force:$Force -Passthru:$Passthru
149153
}
@@ -184,8 +188,10 @@ function Add-ToModuleSyncScript{
184188
process{
185189
$Path = NormalizePath -Path:$Path ?? return $null
186190

191+
$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH
192+
187193
Import-Template -Force:$Force -Path $Path -File "sync.ps1" -Template "template.v3.sync.ps1"
188-
Import-Template -Force:$Force -Path ($Path | Join-Path -ChildPath "tools") -File "sync-helper.ps1" -Template "template.v3.sync-helper.ps1"
194+
Import-Template -Force:$Force -Path $toolsPath -File "sync.Helper.ps1" -Template "template.v3.sync.Helper.ps1"
189195

190196
return ReturnValue -Path $Path -Force:$Force -Passthru:$Passthru
191197
}

sync.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ $MODULE_PATH = $PSScriptRoot
1717
$TOOLS_PATH = $MODULE_PATH | Join-Path -ChildPath "tools"
1818
$WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows"
1919

20-
. ($TOOLS_PATH | Join-Path -ChildPath "sync-helper.ps1")
20+
. ($TOOLS_PATH | Join-Path -ChildPath "sync.Helper.ps1")
2121

22-
Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml'
23-
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
24-
Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml'
22+
Save-UrlContentToFile -File 'deploy_module_on_release.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy_module_on_release.yml'
23+
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
24+
Save-UrlContentToFile -File 'test_with_TestingHelper.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test_with_TestingHelper.yml'
2525

26-
Save-UrlContentToFile -File 'deploy-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1'
27-
Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1'
26+
Save-UrlContentToFile -File 'deploy.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1'
27+
Save-UrlContentToFile -File 'deploy.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.ps1'
2828

29-
Save-UrlContentToFile -File 'sync-helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync-helper.ps1'
30-
Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1'
29+
Save-UrlContentToFile -File 'sync.Helper.ps1' -Folder $TOOLS_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.Helper.ps1'
30+
Save-UrlContentToFile -File 'sync.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.sync.ps1'
3131

32-
Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
33-
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'
32+
Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
33+
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'

tools/deploy-helper.ps1 renamed to tools/deploy.Helper.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
It is not intended to be used directly.
1212
1313
.LINK
14-
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy-helper.ps1
15-
https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy-helper.ps1
16-
https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1
14+
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy.Helper.ps1
15+
https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy.Helper.ps1
16+
https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1
1717
1818
1919
#>

0 commit comments

Comments
 (0)