diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 68a00d36..8f3d8e60 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -524,64 +524,66 @@ jobs: pip install mkdocs-git-revision-date-localized-plugin pip install mkdocs-git-committers-plugin-2 - - name: Run Script - shell: pwsh - run: | - $ModuleName = '${{ inputs.Name }}' - - if (-not $ModuleName) { - $ModuleName = $env:GITHUB_REPOSITORY -replace '.+/' - } - Write-Verbose "Module name: $ModuleName" - - $ModuleSourcePath = Join-Path (Get-Location) -ChildPath '${{ inputs.Path }}' - $DocsOutputPath = Join-Path (Get-Location) -ChildPath "${{ inputs.DocsOutputPath }}/$ModuleName" - $SiteOutputPath = Join-Path (Get-Location) -ChildPath '${{ inputs.SiteOutputPath }}' - - $functionDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' - $functionDocsFolder = New-Item -Path $functionDocsFolderPath -ItemType Directory -Force - Get-ChildItem -Path $DocsOutputPath -Recurse -Force -Include '*.md' | Copy-Item -Destination $functionDocsFolder -Recurse -Force - Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { - $fileName = $_.Name - $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash - Start-LogGroup " - [$fileName] - [$hash]" - Show-FileContent -Path $_ - Stop-LogGroup - } - - Start-LogGroup 'Build docs - Process about topics' - $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About' - $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force - $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' } - Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru | - Rename-Item -NewName { $_.Name -replace '.txt', '.md' } - Stop-LogGroup + - name: Structure site + uses: PSModule/GitHub-Script@v1 + with: + Script: | + $ModuleName = '${{ inputs.Name }}' - Start-LogGroup 'Build docs - Copy icon to assets' - $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets' - $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png' - Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose - - Start-LogGroup 'Build docs - Copy readme.md' - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md' - $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md' - Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose - Stop-LogGroup + if (-not $ModuleName) { + $ModuleName = $env:GITHUB_REPOSITORY -replace '.+/' + } + Write-Verbose "Module name: $ModuleName" + + $ModuleSourcePath = Join-Path (Get-Location) -ChildPath '${{ inputs.Path }}' + $DocsOutputPath = Join-Path (Get-Location) -ChildPath "${{ inputs.DocsOutputPath }}/$ModuleName" + $SiteOutputPath = Join-Path (Get-Location) -ChildPath '${{ inputs.SiteOutputPath }}' + + $functionDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' + $functionDocsFolder = New-Item -Path $functionDocsFolderPath -ItemType Directory -Force + Copy-Item -Path $DocsOutputPath -Destination $functionDocsFolder -Recurse -Force + Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { + $fileName = $_.Name + $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash + LogGroup " - [$fileName] - [$hash]" { + Show-FileContent -Path $_ + } + } - Start-LogGroup 'Build docs - Create mkdocs.yml' - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - # This should be moved to an action so that we can use a default one, and not have to copy it from the repo. - $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml' - $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml' - $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw - $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName) - $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER) - $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force - Show-FileContent -Path $mkdocsTargetPath - Stop-LogGroup + LogGroup 'Build docs - Process about topics' { + $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About' + $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force + $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' } + Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru | + Rename-Item -NewName { $_.Name -replace '.txt', '.md' } + } + + LogGroup 'Build docs - Copy icon to assets' { + $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets' + $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png' + Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose + } + + LogGroup 'Build docs - Copy readme.md' { + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md' + $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md' + Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose + } + + LogGroup 'Build docs - Create mkdocs.yml' { + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + # This should be moved to an action so that we can use a default one, and not have to copy it from the repo. + $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml' + $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml' + $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw + $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName) + $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER) + $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force + Show-FileContent -Path $mkdocsTargetPath + } - name: Debug File system shell: pwsh diff --git a/tests/src/functions/public/Get-PSModuleTest.ps1 b/tests/src/functions/public/PSModule/Get-PSModuleTest.ps1 similarity index 62% rename from tests/src/functions/public/Get-PSModuleTest.ps1 rename to tests/src/functions/public/PSModule/Get-PSModuleTest.ps1 index 0e9aacfe..73a5c620 100644 --- a/tests/src/functions/public/Get-PSModuleTest.ps1 +++ b/tests/src/functions/public/PSModule/Get-PSModuleTest.ps1 @@ -1,4 +1,7 @@ #Requires -Modules Utilities +#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } +#Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } +#Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' } function Get-PSModuleTest { <# diff --git a/tests/src/functions/public/New-PSModuleTest.ps1 b/tests/src/functions/public/PSModule/New-PSModuleTest.ps1 similarity index 100% rename from tests/src/functions/public/New-PSModuleTest.ps1 rename to tests/src/functions/public/PSModule/New-PSModuleTest.ps1 diff --git a/tests/src/functions/public/PSModule/PSModule.md b/tests/src/functions/public/PSModule/PSModule.md new file mode 100644 index 00000000..79741cf4 --- /dev/null +++ b/tests/src/functions/public/PSModule/PSModule.md @@ -0,0 +1 @@ +# This is PSModule diff --git a/tests/src/functions/public/Set-PSModuleTest.ps1 b/tests/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 similarity index 100% rename from tests/src/functions/public/Set-PSModuleTest.ps1 rename to tests/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 diff --git a/tests/src/functions/public/SomethingElse/SomethingElse.md b/tests/src/functions/public/SomethingElse/SomethingElse.md new file mode 100644 index 00000000..d9f7e9ee --- /dev/null +++ b/tests/src/functions/public/SomethingElse/SomethingElse.md @@ -0,0 +1 @@ +# This is SomethingElse diff --git a/tests/srcWithManifest/functions/public/Get-PSModuleTest.ps1 b/tests/srcWithManifest/functions/public/PSModule/Get-PSModuleTest.ps1 similarity index 62% rename from tests/srcWithManifest/functions/public/Get-PSModuleTest.ps1 rename to tests/srcWithManifest/functions/public/PSModule/Get-PSModuleTest.ps1 index 0e9aacfe..73a5c620 100644 --- a/tests/srcWithManifest/functions/public/Get-PSModuleTest.ps1 +++ b/tests/srcWithManifest/functions/public/PSModule/Get-PSModuleTest.ps1 @@ -1,4 +1,7 @@ #Requires -Modules Utilities +#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } +#Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } +#Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' } function Get-PSModuleTest { <# diff --git a/tests/srcWithManifest/functions/public/New-PSModuleTest.ps1 b/tests/srcWithManifest/functions/public/PSModule/New-PSModuleTest.ps1 similarity index 100% rename from tests/srcWithManifest/functions/public/New-PSModuleTest.ps1 rename to tests/srcWithManifest/functions/public/PSModule/New-PSModuleTest.ps1 diff --git a/tests/srcWithManifest/functions/public/PSModule/PSModule.md b/tests/srcWithManifest/functions/public/PSModule/PSModule.md new file mode 100644 index 00000000..79741cf4 --- /dev/null +++ b/tests/srcWithManifest/functions/public/PSModule/PSModule.md @@ -0,0 +1 @@ +# This is PSModule diff --git a/tests/srcWithManifest/functions/public/Set-PSModuleTest.ps1 b/tests/srcWithManifest/functions/public/SomethingElse/Set-PSModuleTest.ps1 similarity index 100% rename from tests/srcWithManifest/functions/public/Set-PSModuleTest.ps1 rename to tests/srcWithManifest/functions/public/SomethingElse/Set-PSModuleTest.ps1 diff --git a/tests/srcWithManifest/functions/public/SomethingElse/SomethingElse.md b/tests/srcWithManifest/functions/public/SomethingElse/SomethingElse.md new file mode 100644 index 00000000..d9f7e9ee --- /dev/null +++ b/tests/srcWithManifest/functions/public/SomethingElse/SomethingElse.md @@ -0,0 +1 @@ +# This is SomethingElse