ci / verifier-pack (push) Successful in 1m29s
- packs/essentiels : 20 prompts en 4 catégories (Général, Écriture, Code, Analyse), en-têtes conformes au parseur, variables déclarées = utilisées - tests/run_tests.ahk : suites Frontmatter, Variables, JSON, Recherche, encodage UTF-8 (à exécuter sous Windows avec AutoHotkey v2) - scripts/check_pack.py + .gitea/workflows/ci.yml : cohérence du pack - build.ps1 : tests puis compilation Ahk2Exe et zip portable - docs : document d'architecture et de conception v1.0
86 lines
3.9 KiB
PowerShell
86 lines
3.9 KiB
PowerShell
# PromptKey — compilation et assemblage de l'archive portable.
|
|
#
|
|
# Usage : .\build.ps1
|
|
#
|
|
# Étapes :
|
|
# 1. Vérifie la présence d'AutoHotkey v2 et du compilateur Ahk2Exe.
|
|
# 2. Lance les scripts de tests\ s'il y en a (échec = arrêt du build).
|
|
# 3. Compile PromptKey.ahk en dist\PromptKey.exe.
|
|
# 4. Assemble dist\PromptKey-portable.zip (exe + packs + README + LICENSE).
|
|
# 5. Affiche la somme SHA256 de l'exécutable.
|
|
#
|
|
# Prérequis : AutoHotkey v2.0 (64 bits) installé, Ahk2Exe fourni avec
|
|
# (dossier Compiler\ de l'installation AutoHotkey).
|
|
|
|
#Requires -Version 5.1
|
|
$ErrorActionPreference = 'Stop'
|
|
$Racine = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
Set-Location $Racine
|
|
|
|
function Echouer($Message) {
|
|
Write-Host "ERREUR : $Message" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# --- 1. Localiser AutoHotkey v2 et Ahk2Exe ----------------------------------
|
|
$AhkExe = $null
|
|
$Ahk2Exe = $null
|
|
$Candidats = @(
|
|
"$env:ProgramFiles\AutoHotkey",
|
|
"${env:ProgramFiles(x86)}\AutoHotkey",
|
|
"$env:LOCALAPPDATA\Programs\AutoHotkey"
|
|
)
|
|
foreach ($Dossier in $Candidats) {
|
|
if (Test-Path $Dossier) {
|
|
$Trouve = Get-ChildItem -Path $Dossier -Recurse -Filter 'AutoHotkey64.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($Trouve) { $AhkExe = $Trouve.FullName }
|
|
$Trouve = Get-ChildItem -Path $Dossier -Recurse -Filter 'Ahk2Exe.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($Trouve) { $Ahk2Exe = $Trouve.FullName }
|
|
}
|
|
}
|
|
if (-not $AhkExe) { Echouer "AutoHotkey v2 introuvable. Installez AutoHotkey v2.0 (64 bits) depuis https://www.autohotkey.com/" }
|
|
if (-not $Ahk2Exe) { Echouer "Ahk2Exe introuvable. Il est fourni avec AutoHotkey v2 (dossier Compiler\) ; réinstallez en incluant l'option de compilation." }
|
|
|
|
# Vérifier qu'il s'agit bien de la v2 (le champ FileVersion commence par 2.)
|
|
$Version = (Get-Item $AhkExe).VersionInfo.FileVersion
|
|
if ($Version -notmatch '^2\.') { Echouer "AutoHotkey v2 requis, version trouvée : $Version ($AhkExe)" }
|
|
Write-Host "AutoHotkey $Version : $AhkExe"
|
|
Write-Host "Ahk2Exe : $Ahk2Exe"
|
|
|
|
# --- 2. Tests (si présents) --------------------------------------------------
|
|
$DossierTests = Join-Path $Racine 'tests'
|
|
if (Test-Path $DossierTests) {
|
|
$Scripts = Get-ChildItem -Path $DossierTests -Filter '*.ahk'
|
|
foreach ($Script in $Scripts) {
|
|
Write-Host "Test : $($Script.Name)"
|
|
& $AhkExe /ErrorStdOut $Script.FullName
|
|
if ($LASTEXITCODE -ne 0) { Echouer "Échec du test $($Script.Name) (code $LASTEXITCODE). Build interrompu." }
|
|
}
|
|
if ($Scripts.Count -eq 0) { Write-Host "Aucun script de test dans tests\ — étape sautée." }
|
|
}
|
|
|
|
# --- 3. Compilation ----------------------------------------------------------
|
|
$Dist = Join-Path $Racine 'dist'
|
|
if (-not (Test-Path $Dist)) { New-Item -ItemType Directory -Path $Dist | Out-Null }
|
|
$Source = Join-Path $Racine 'PromptKey.ahk'
|
|
if (-not (Test-Path $Source)) { Echouer "Fichier source introuvable : $Source" }
|
|
$Exe = Join-Path $Dist 'PromptKey.exe'
|
|
if (Test-Path $Exe) { Remove-Item $Exe -Force }
|
|
|
|
Write-Host "Compilation de PromptKey.ahk ..."
|
|
& $Ahk2Exe /in $Source /out $Exe /base $AhkExe
|
|
if ($LASTEXITCODE -ne 0 -or -not (Test-Path $Exe)) { Echouer "La compilation a échoué." }
|
|
Write-Host "Exécutable produit : $Exe"
|
|
|
|
# --- 4. Archive portable -----------------------------------------------------
|
|
$Zip = Join-Path $Dist 'PromptKey-portable.zip'
|
|
if (Test-Path $Zip) { Remove-Item $Zip -Force }
|
|
$AInclure = @($Exe, (Join-Path $Racine 'README.md'), (Join-Path $Racine 'LICENSE'), (Join-Path $Racine 'CHANGELOG.md'), (Join-Path $Racine 'packs'))
|
|
Compress-Archive -Path $AInclure -DestinationPath $Zip
|
|
Write-Host "Archive portable : $Zip"
|
|
|
|
# --- 5. Somme de contrôle ----------------------------------------------------
|
|
$Hash = Get-FileHash -Algorithm SHA256 $Exe
|
|
Write-Host "SHA256 de l'exe : $($Hash.Hash)"
|
|
Write-Host "Build terminé."
|