Version 2.0.1 :

liens Markdown cliquables dans le README et corrections de la gestion des mises a jour de scripts

Détail :
- Badge "Nouveau" persistant tant qu'un script n'est pas réellement à jour
- Popup de mise à jour limité à une fois par script/session
- Bouton manuel "Mise à jour disponible" dans le panneau README
- Liens Markdown convertis en vrais liens HTML, ouverts dans le navigateur par défaut
- Synchronisation de $CADMASTER_VERSION avec version.txt (2.0.1)
This commit is contained in:
2026-07-06 03:37:17 +02:00
parent f9ef170872
commit f1b05f282e
2 changed files with 83 additions and 14 deletions
+75 -6
View File
@@ -8,7 +8,7 @@ $GITEA_ORG = "ScriptPowerShell" # Nom de l'organisation Gitea
$GITEA_BRANCH = "main"
$LOCAL_CACHE_DIR = "$PSScriptRoot\scripts"
$CADMASTER_VERSION = "2.0.0"
$CADMASTER_VERSION = "2.0.1"
$CADMASTER_UPDATE_ORG = "DistechControls" # Organisation Gitea hebergeant cadMasterCLI lui-meme
$CADMASTER_UPDATE_REPO = "cadMasterCLI"
$CADMASTER_CONFIG_PATH = "$PSScriptRoot\cadmastercli.config.json"
@@ -43,6 +43,7 @@ $script:I18N = @{
"detail.switchEnable" = "Activer"
"detail.noParams" = "Ce script ne necessite aucun parametre."
"detail.noReadme" = "Aucune documentation disponible."
"detail.updateAvailable" = "Mise a jour disponible - cliquer pour installer"
"log.header" = "Journal d'execution"
"log.placeholder" = "En attente d'execution..."
"log.starting" = "Demarrage du script..."
@@ -82,6 +83,7 @@ $script:I18N = @{
"detail.switchEnable" = "Enable"
"detail.noParams" = "This script does not require any parameters."
"detail.noReadme" = "No documentation available."
"detail.updateAvailable" = "Update available - click to install"
"log.header" = "Execution log"
"log.placeholder" = "Waiting for execution..."
"log.starting" = "Starting script..."
@@ -570,11 +572,13 @@ function ConvertTo-SimpleHtml {
"table{border-collapse:collapse;width:100%;margin:8px 0;font-size:12px}" +
"th{background:#1565C0;color:#fff;padding:6px 10px;text-align:left}" +
"td{padding:5px 10px;border-bottom:1px solid #eee}" +
"tr:nth-child(even) td{background:#f5f5f5}"
"tr:nth-child(even) td{background:#f5f5f5}" +
"a{color:#1565C0;text-decoration:underline;cursor:pointer}"
# Formate gras, italique et code inline sur une chaine deja encodee HTML
$applyInline = {
param([string]$s)
$s = $s -replace "\[([^\]]+)\]\(([^)\s]+)\)", "<a href='`$2'>`$1</a>"
$s = $s -replace "\*\*(.+?)\*\*", "<strong>`$1</strong>"
$s = $s -replace "\*(.+?)\*", "<em>`$1</em>"
$s = $s -replace "``(.+?)``", "<code>`$1</code>"
@@ -1104,6 +1108,12 @@ function Show-MainWindow {
$execState = $execState
$grayBrush = $grayBrush
$greenBrush = $greenBrush
# Auto-reference (pour le bouton de MAJ du README, qui doit rappeler
# cette meme fonction) : $MyInvocation.MyCommand.ScriptBlock pointe
# sur le scriptblock en cours d'execution, donc pas besoin de passer
# par la variable exterieure $ShowScriptDetail (qui, elle, subirait
# le meme probleme de capture que $lv/$execState ci-dessus).
$selfShowScriptDetail = $MyInvocation.MyCommand.ScriptBlock
& $StopRunningExecution
$detailHost.ColumnDefinitions.Clear()
@@ -1116,6 +1126,8 @@ function Show-MainWindow {
Select-Object -First 1 -ExpandProperty FullName
$scriptBranch = $ScriptData.DefaultBranch
$justUpdated = $false
if (-not $localPs1) {
Write-Log "Telechargement initial de $scriptName..."
$ok = Invoke-ScriptDownload -ScriptName $scriptName -Branch $scriptBranch
@@ -1125,13 +1137,21 @@ function Show-MainWindow {
return
}
$ScriptData.MajDispo = $false
$justUpdated = $true
}
elseif ($ScriptData.MajDispo) {
elseif ($ScriptData.MajDispo -and -not $ScriptData.UpdatePromptShown) {
$ScriptData.UpdatePromptShown = $true
$rep = Show-MessageBox -Message "$(T 'msg.updateAvailableScript') '$scriptName'.`n$(T 'msg.updateConfirm')" `
-Title (T "msg.updateAvailableTitle") -Type "Question"
if ($rep -eq "Yes") { Invoke-ScriptDownload -ScriptName $scriptName -Branch $scriptBranch | Out-Null }
if ($rep -eq "Yes") {
Invoke-ScriptDownload -ScriptName $scriptName -Branch $scriptBranch | Out-Null
$justUpdated = $true
$ScriptData.MajDispo = $false
}
# Si "Non" : MajDispo reste $true (le badge "Nouveau" persiste tant
# que le script n'est pas reellement a jour), mais on ne repropose
# plus le popup pour ce script durant cette session de l'app.
}
Update-ScriptBadge -ScriptItem $ScriptData
$ps1NameFile = "$LOCAL_CACHE_DIR\$scriptName\.ps1name"
@@ -1139,11 +1159,20 @@ function Show-MainWindow {
$cachedScriptPath = "$LOCAL_CACHE_DIR\$scriptName\$ps1FileName"
# --- README : section langue courante (Feature 6) ---
$readmeContent = $ScriptData.ReadmeFull
# Si l'utilisateur a refuse la mise a jour (ou qu'elle etait deja a
# jour), on affiche le README LOCAL - celui qui correspond reellement
# au code qui sera execute - plutot que la version Gitea la plus
# recente, pour eviter toute confusion entre doc affichee et code lance.
$localReadmePath = "$LOCAL_CACHE_DIR\$scriptName\README.md"
if (-not $justUpdated -and (Test-Path $localReadmePath)) {
$readmeContent = Get-Content $localReadmePath -Raw -Encoding UTF8
}
else {
$readmeContent = $ScriptData.ReadmeFull
if (-not $readmeContent -and (Test-Path $localReadmePath)) {
$readmeContent = Get-Content $localReadmePath -Raw -Encoding UTF8
}
}
$readmeSection = Get-ReadmeSection -Markdown $readmeContent -Lang (Get-CurrentLang)
$htmlContent = ConvertTo-SimpleHtml -Markdown $readmeSection
@@ -1195,8 +1224,47 @@ function Show-MainWindow {
[System.Windows.Controls.Grid]::SetColumn($readmeBorder, 0)
$detailHost.Children.Add($readmeBorder) | Out-Null
$readmeDock = New-Object System.Windows.Controls.DockPanel
$readmeBorder.Child = $readmeDock
$btnScriptUpdate = New-Object System.Windows.Controls.Button
$btnScriptUpdate.Content = T "detail.updateAvailable"
$btnScriptUpdate.Margin = New-Object System.Windows.Thickness(10, 10, 10, 6)
$btnScriptUpdate.Padding = New-Object System.Windows.Thickness(10, 6, 10, 6)
$btnScriptUpdate.Background = New-Object System.Windows.Media.SolidColorBrush([System.Windows.Media.Color]::FromRgb(245, 124, 0))
$btnScriptUpdate.Foreground = [System.Windows.Media.Brushes]::White
$btnScriptUpdate.FontWeight = [System.Windows.FontWeights]::Bold
$btnScriptUpdate.Cursor = [System.Windows.Input.Cursors]::Hand
$btnScriptUpdate.HorizontalContentAlignment = "Center"
$btnScriptUpdate.Visibility = if ($ScriptData.MajDispo) { [System.Windows.Visibility]::Visible } else { [System.Windows.Visibility]::Collapsed }
[System.Windows.Controls.DockPanel]::SetDock($btnScriptUpdate, [System.Windows.Controls.Dock]::Top)
$readmeDock.Children.Add($btnScriptUpdate) | Out-Null
$btnScriptUpdate.Add_Click({
$rep = Show-MessageBox -Message "$(T 'msg.updateAvailableScript') '$scriptName'.`n$(T 'msg.updateConfirm')" `
-Title (T "msg.updateAvailableTitle") -Type "Question"
if ($rep -eq "Yes") {
Invoke-ScriptDownload -ScriptName $scriptName -Branch $scriptBranch | Out-Null
$ScriptData.MajDispo = $false
Update-ScriptBadge -ScriptItem $ScriptData
& $selfShowScriptDetail -ScriptData $ScriptData
}
}.GetNewClosure())
$wb = New-Object System.Windows.Controls.WebBrowser
$readmeBorder.Child = $wb
$readmeDock.Children.Add($wb) | Out-Null
# Un clic sur un lien du README ne doit pas naviguer DANS le petit
# panneau integre (qui perdrait la doc affichee), mais ouvrir le lien
# dans le navigateur par defaut de l'utilisateur.
$wb.Add_Navigating({
param($sender, $e)
if ($e.Uri -and $e.Uri.IsAbsoluteUri -and ($e.Uri.Scheme -eq "http" -or $e.Uri.Scheme -eq "https")) {
$e.Cancel = $true
Start-Process -FilePath $e.Uri.AbsoluteUri
}
}.GetNewClosure())
$wb.NavigateToString($htmlContent)
$splitter2 = New-Object System.Windows.Controls.GridSplitter
@@ -1737,6 +1805,7 @@ $scripts = @($rawList) | ForEach-Object {
DateGitea = $date
MajDispo = $majDispo
DefaultBranch = $branch
UpdatePromptShown = $false
}
}
+1 -1
View File
@@ -1 +1 @@
2.0.0
2.0.1