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
24 changes: 7 additions & 17 deletions TestingHelperTest/private/Add-ModuleSections.Tests.Asserts.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

$TOOLS_RELATIVE_PATH = "tools"

function TestingHelperTest_AssertAddSection_throwOnNull{
# All asserts here has a pattern
# This test will confirm tht the pattern will not miss a false negative
Expand Down Expand Up @@ -27,20 +29,6 @@ function Assert-AddDevContainerJson{
}
}

# Git Repository
function Assert-AddGitRepository{
param(
[Parameter(Mandatory,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Alias("PSPath")][ValidateNotNullOrEmpty()]
[string] $Path
)
process{
$Path = $Path | Convert-Path

Assert-ItemExist -Path ($Path | Join-Path -ChildPath ".git") -Comment ".git"
}
}


# License
function Assert-AddLicense{
Expand Down Expand Up @@ -119,10 +107,10 @@ function Assert-AddDeployScript{
process{
$Path = $Path | Convert-Path

$toolsPath = $Path | Join-Path -ChildPath "tools"
$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH

Assert-ItemExist -Path ($Path | Join-Path -ChildPath "deploy.ps1") -Comment "deploy.ps1"
Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "deploy-helper.ps1") -Comment "deploy-helper.ps1"
Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "deploy.Helper.ps1") -Comment "deploy.Helper.ps1"
}
}

Expand Down Expand Up @@ -150,8 +138,10 @@ function Assert-AddSyncScript{
process{
$Path = $Path | Convert-Path

$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH

Assert-ItemExist -Path ($Path | Join-Path -ChildPath "sync.ps1") -Comment "sync.ps1"
Assert-ItemExist -Path (($Path | Join-Path -ChildPath "tools") | Join-Path -ChildPath "sync-helper.ps1") -Comment "sync-helper.ps1"
Assert-ItemExist -Path ($toolsPath | Join-Path -ChildPath "sync.Helper.ps1") -Comment "sync.Helper.ps1"
}
}

Expand Down
3 changes: 2 additions & 1 deletion deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ param(
$MODULE_PATH = $PSScriptRoot
$MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase
$MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1"
$MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools"

# Load helper
# We dot souce the ps1 to allow all code to be in the same scope as the script
# Easier to inject for testing with DependecyInjection parameter
. ($MODULE_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1")
. ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1")
if ($DependencyInjection) {
. $DependencyInjection
}
Expand Down
4 changes: 2 additions & 2 deletions docs/structure-of-a-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
## Tools Scripts

1. publish.ps1
1. publish-helper.ps1
1. deploy.Helper.ps1er.ps1
2. release.ps1
3. sync.ps1
1. sync-helper.ps1
1. sync.Helper.ps1

## Workflows

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
It is not intended to be used directly.

.LINK
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy-helper.ps1
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy.Helper.ps1
https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy.Helper.ps1
https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1

#>

Expand Down
3 changes: 2 additions & 1 deletion private/templates/template.v3.deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ param(
$MODULE_PATH = $PSScriptRoot
$MODULE_NAME = $MODULE_PATH | Split-Path -LeafBase
$MODULE_PSD1 = Join-Path -Path $MODULE_PATH -ChildPath "$MODULE_NAME.psd1"
$MODULE_TOOLS = Join-Path -Path $MODULE_PATH -ChildPath "tools"

# Load helper
# We dot souce the ps1 to allow all code to be in the same scope as the script
# Easier to inject for testing with DependecyInjection parameter
. ($MODULE_PATH | Join-Path -ChildPath "tools" -AdditionalChildPath "deploy-helper.ps1")
. ($MODULE_TOOLS | Join-Path -ChildPath "deploy.Helper.ps1")
if ($DependencyInjection) {
. $DependencyInjection
}
Expand Down
20 changes: 10 additions & 10 deletions private/templates/template.v3.sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ $MODULE_PATH = $PSScriptRoot
$TOOLS_PATH = $MODULE_PATH | Join-Path -ChildPath "tools"
$WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows"

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

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'
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
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'
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'
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
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'

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

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

Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'
Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'
10 changes: 8 additions & 2 deletions public/Add-ToModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# -Force: If the file already exists, it will be overwritten withe the default values
# The output will be the Path of the module updated. This way we may pipe with next Add-ToModule* function

$TOOLS_RELATIVE_PATH = "tools"

function Add-ToModuleSampleCode{
[CmdletBinding(SupportsShouldProcess)]
param(
Expand Down Expand Up @@ -142,8 +144,10 @@ function Add-ToModuleDeployScript{
process{
$Path = NormalizePath -Path:$Path ?? return $null

$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH

Import-Template -Force:$Force -Path $Path -File "deploy.ps1" -Template "template.v3.deploy.ps1"
Import-Template -Force:$Force -Path ($Path | Join-path -ChildPath "tools") -File "deploy-helper.ps1" -Template "template.v3.deploy-helper.ps1"
Import-Template -Force:$Force -Path $toolsPath -File "deploy.Helper.ps1" -Template "template.v3.deploy.Helper.ps1"

return ReturnValue -Path $Path -Force:$Force -Passthru:$Passthru
}
Expand Down Expand Up @@ -184,8 +188,10 @@ function Add-ToModuleSyncScript{
process{
$Path = NormalizePath -Path:$Path ?? return $null

$toolsPath = $Path | Join-Path -ChildPath $TOOLS_RELATIVE_PATH

Import-Template -Force:$Force -Path $Path -File "sync.ps1" -Template "template.v3.sync.ps1"
Import-Template -Force:$Force -Path ($Path | Join-Path -ChildPath "tools") -File "sync-helper.ps1" -Template "template.v3.sync-helper.ps1"
Import-Template -Force:$Force -Path $toolsPath -File "sync.Helper.ps1" -Template "template.v3.sync.Helper.ps1"

return ReturnValue -Path $Path -Force:$Force -Passthru:$Passthru
}
Expand Down
20 changes: 10 additions & 10 deletions sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ $MODULE_PATH = $PSScriptRoot
$TOOLS_PATH = $MODULE_PATH | Join-Path -ChildPath "tools"
$WORKFLOW_PATH = $MODULE_PATH | Join-Path -ChildPath ".github" -AdditionalChildPath "workflows"

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

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'
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
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'
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'
Save-UrlContentToFile -File 'powershell.yml' -Folder $WORKFLOW_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.powershell.yml'
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'

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

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

Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'
Save-UrlContentToFile -File 'release.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.release.ps1'
Save-UrlContentToFile -File 'test.ps1' -Folder $MODULE_PATH -Url 'https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.test.ps1'
6 changes: 3 additions & 3 deletions tools/deploy-helper.ps1 → tools/deploy.Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
It is not intended to be used directly.

.LINK
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy-helper.ps1
https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy-helper.ps1
https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy-helper.ps1
https://raw.githubusercontent.com/rulasg/DemoPsModule/main/deploy.Helper.ps1
https://github.com/rulasg/TestingHelper/blob/main/private/templates/template.v3.deploy.Helper.ps1
https://raw.githubusercontent.com/rulasg/TestingHelper/main/private/templates/template.v3.deploy.Helper.ps1


#>
Expand Down
File renamed without changes.