From d3b19f71a13e254f7043992107b1155fcc9850ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Andreas=20Nilsen?= Date: Fri, 23 Aug 2024 10:08:54 +0200 Subject: [PATCH] test new generator --- generate-readme.ps1 | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/generate-readme.ps1 b/generate-readme.ps1 index a657981..d8ab03a 100644 --- a/generate-readme.ps1 +++ b/generate-readme.ps1 @@ -6,6 +6,9 @@ $userJsFiles = Get-ChildItem -Path $UserScripts -Filter "*.user.js" | Sort-Objec $regEx = [regex]'\/\/\s+@(\w+)\s+(.+)' + +$scriptList = @() + # Initialize an array to hold the table rows $tableRows = @() @@ -20,7 +23,10 @@ foreach ($file in $userJsFiles) { $i = 0 $endOfCommentBlock = $false $autoUpdate = $false - $name = "" + $name = $file.Name + $version = "Beta" + $author = "" + $match = "" $description = "" do { @@ -36,6 +42,12 @@ foreach ($file in $userJsFiles) { $description = $value } elseif ($key -eq 'updateURL') { $autoUpdate = $true + } elseif ($key -eq 'version') { + $version = $value + } elseif ($key -eq 'author') { + $author = $value + } elseif ($key -eq 'match') { + $match = $value } } @@ -46,13 +58,26 @@ foreach ($file in $userJsFiles) { $i++ } while (($i -lt $content.Length) -and (-not $endOfCommentBlock)) + $endOfCommentBlock = $false + if ($autoUpdate) { $autoUpdateText = "✅" } else { $autoUpdateText = "" } + $scriptList += " ## $name`n`n" + $scriptList += "`n" + $scriptList += " `n" + if ($author) { + $scriptList += " `n" + } + $scriptList += "`n" + $scriptList += "`n" + $scriptList += "
Version$version
Author$author
Match$match
Description$description
`n`n" + + # Add the row to the table $tableRows += "| [$($file.Name)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/$($file.Name)) | $name | $description | $autoUpdateText |`n" } @@ -60,4 +85,4 @@ foreach ($file in $userJsFiles) { #$tableRows | ForEach-Object { Write-Output $_ } $template = Get-Content .\ReadmeTemplate.md -$template -replace '{scriptlist}', $tableRows \ No newline at end of file +$template -replace '{scriptlist}', $scriptList \ No newline at end of file