Skip to content

Commit

Permalink
test new generator
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Aug 23, 2024
1 parent 7c19aeb commit d3b19f7
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions generate-readme.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()

Expand All @@ -20,7 +23,10 @@ foreach ($file in $userJsFiles) {
$i = 0
$endOfCommentBlock = $false
$autoUpdate = $false
$name = ""
$name = $file.Name
$version = "Beta"
$author = ""
$match = ""
$description = ""

do {
Expand All @@ -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
}
}

Expand All @@ -46,18 +58,31 @@ 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 += "<table>`n"
$scriptList += " <tr><th>Version</th><td>$version</td></tr>`n"
if ($author) {
$scriptList += " <tr><th>Author</th><td>$author</td></tr>`n"
}
$scriptList += "<tr><th>Match</th><td>$match</td></tr>`n"
$scriptList += "<tr><th>Description</th><td>$description</td></tr>`n"
$scriptList += "</table>`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"
}

#$tableRows | ForEach-Object { Write-Output $_ }

$template = Get-Content .\ReadmeTemplate.md
$template -replace '{scriptlist}', $tableRows
$template -replace '{scriptlist}', $scriptList

0 comments on commit d3b19f7

Please sign in to comment.