diff --git a/README.md b/README.md index d0a03ec..c22a4b2 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,19 @@ Extensao Chrome Manifest V3 que adiciona o botao `Arch panel` ao header da pagin - `manifest.json`: define a extensao e o carregamento do content script - `content-script.js`: valida a URL, encontra o header e injeta o botao + +## Controle de versao + +A versao oficial da extensao fica em `manifest.json`. + +Toda alteracao funcional, visual ou tecnica na extensao deve incrementar a terceira casa da versao antes da entrega: + +```powershell +powershell -ExecutionPolicy Bypass -File tools/bump-extension-version.ps1 +``` + +Quando uma versao especifica for solicitada, informe o valor explicitamente: + +```powershell +powershell -ExecutionPolicy Bypass -File tools/bump-extension-version.ps1 -Version 1.0.25 +``` diff --git a/content-script.js b/content-script.js index 9ba06c8..b29df45 100644 --- a/content-script.js +++ b/content-script.js @@ -794,6 +794,13 @@ Updated by Refresh data + +
+

Extension version

+
+ v${escapeHtml(getExtensionVersion())} +
+
@@ -833,6 +840,14 @@ `; } + function getExtensionVersion() { + try { + return chrome.runtime.getManifest()?.version || "0.0.0"; + } catch { + return "0.0.0"; + } + } + function renderMetricCard(label, value, detail) { return `
diff --git a/manifest.json b/manifest.json index 6373d7a..26b46fc 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ -{ +{ "manifest_version": 3, "name": "Arch Panel Injector", - "version": "1.0.0", + "version": "1.0.3", "description": "Insere o botao Arch panel no header do Oracle Workload Workbench.", "permissions": [ "cookies", @@ -36,3 +36,7 @@ } ] } + + + + diff --git a/tools/bump-extension-version.ps1 b/tools/bump-extension-version.ps1 new file mode 100644 index 0000000..b1c5d20 --- /dev/null +++ b/tools/bump-extension-version.ps1 @@ -0,0 +1,65 @@ +param( + [string]$Version +) + +$ErrorActionPreference = "Stop" + +$repoRoot = Split-Path -Parent $PSScriptRoot +$manifestPath = Join-Path $repoRoot "manifest.json" + +function Test-ExtensionVersion { + param([string]$Value) + + if ($Value -notmatch '^\d+\.\d+\.\d+$') { + throw "Invalid version '$Value'. Expected format N.N.N, for example 1.0.7." + } + + foreach ($part in $Value.Split(".")) { + $number = [int64]$part + + if ($number -lt 0 -or $number -gt 65535) { + throw "Invalid version '$Value'. Each part must be between 0 and 65535." + } + } +} + +if (!(Test-Path -LiteralPath $manifestPath)) { + throw "manifest.json not found at $manifestPath" +} + +$rawManifest = Get-Content -LiteralPath $manifestPath -Raw +$manifest = $rawManifest | ConvertFrom-Json +$currentVersion = [string]$manifest.version + +Test-ExtensionVersion -Value $currentVersion + +if ($Version) { + $nextVersion = $Version.Trim() + Test-ExtensionVersion -Value $nextVersion +} else { + $parts = $currentVersion.Split(".") + $patch = [int64]$parts[2] + 1 + + if ($patch -gt 65535) { + throw "Cannot increment patch version beyond 65535." + } + + $nextVersion = "$($parts[0]).$($parts[1]).$patch" +} + +$versionPattern = '("version"\s*:\s*")([^"]+)(")' +$matches = [regex]::Matches($rawManifest, $versionPattern) + +if ($matches.Count -ne 1) { + throw "Expected exactly one version field in manifest.json, found $($matches.Count)." +} + +$updatedManifest = [regex]::Replace( + $rawManifest, + $versionPattern, + "`${1}$nextVersion`${3}", + 1 +) + +Set-Content -LiteralPath $manifestPath -Value $updatedManifest -Encoding UTF8 +Write-Output "Extension version updated: $currentVersion -> $nextVersion"