From 61753c421a15416570d6ef3d16183b61098d1e03 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Souza Santos Date: Wed, 4 Nov 2026 00:32:23 -0300 Subject: [PATCH] =?UTF-8?q?feat(plugins):=20ping=20no=20cat=C3=A1logo,=20a?= =?UTF-8?q?usente=20n=C3=A3o=20interrompe=20o=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A entrada fica no mesmo registro. Sem o build nesta máquina o comando segue só com os plugins que existem. Co-authored-by: Cursor --- plugins.registry.json | 7 +++++++ scripts/pitiupi.cmd | 2 +- scripts/pitiupi.sh | 28 ++++++++++++++++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/plugins.registry.json b/plugins.registry.json index 94da93f..886ae2c 100644 --- a/plugins.registry.json +++ b/plugins.registry.json @@ -13,6 +13,13 @@ "build": "ant", "jar": "dist/pitiupi.screenCast.jar", "menuCategory": "Streaming" + }, + { + "id": "ping", + "dir": "plugins/ping", + "build": "ant", + "jar": "dist/pitiupi.ping.jar", + "menuCategory": "Social" } ] } diff --git a/scripts/pitiupi.cmd b/scripts/pitiupi.cmd index be4043a..86a1ae4 100644 --- a/scripts/pitiupi.cmd +++ b/scripts/pitiupi.cmd @@ -25,7 +25,7 @@ del /q "%CD%\.pitiupi\plugins\*.jar" 2>nul set "PITIUPI_REPO=%CD%" set "PITIUPI_PLUGINS=%CD%\.pitiupi\plugins" -powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$repo = $env:PITIUPI_REPO; $dest = $env:PITIUPI_PLUGINS; $reg = Get-Content -Raw (Join-Path $repo 'plugins.registry.json') | ConvertFrom-Json; foreach ($p in $reg.plugins) { $dir = Join-Path $repo ($p.dir -replace '/','\'); if ($p.build -ne 'ant') { Write-Error ('build nao suportado neste prompt: ' + $p.build); exit 1 }; & ant -f (Join-Path $dir 'build.xml') jar; if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; $src = Join-Path $dir ($p.jar -replace '/','\'); if (-not (Test-Path -LiteralPath $src)) { Write-Error ('JAR ausente: ' + $src); exit 1 }; Copy-Item -LiteralPath $src -Destination (Join-Path $dest ($p.id + '.jar')) -Force }" +powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$repo = $env:PITIUPI_REPO; $dest = $env:PITIUPI_PLUGINS; $reg = Get-Content -Raw (Join-Path $repo 'plugins.registry.json') | ConvertFrom-Json; foreach ($p in @($reg.plugins)) { $dir = Join-Path $repo ($p.dir -replace '/','\'); $marker = Join-Path $dir 'build.xml'; if ($p.build -eq 'make') { $marker = Join-Path $dir 'Makefile' }; if (-not (Test-Path -LiteralPath $marker)) { Write-Host ('Plugin ' + $p.id + ' ausente nesta maquina; nao sera carregado.'); continue }; if ($p.build -ne 'ant') { Write-Error ('build nao suportado neste prompt: ' + $p.build); exit 1 }; & ant -f (Join-Path $dir 'build.xml') jar; if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; $src = Join-Path $dir ($p.jar -replace '/','\'); if (-not (Test-Path -LiteralPath $src)) { Write-Error ('JAR ausente: ' + $src); exit 1 }; Copy-Item -LiteralPath $src -Destination (Join-Path $dest ($p.id + '.jar')) -Force }" if errorlevel 1 exit /b 1 powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0lib\launch-windows.ps1" -PitiupiHome "%CD%\.pitiupi" -Jar "%CD%\pitiupi\dist\pitiupi.jar" diff --git a/scripts/pitiupi.sh b/scripts/pitiupi.sh index fa79528..3828f31 100755 --- a/scripts/pitiupi.sh +++ b/scripts/pitiupi.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # Build, instala plugins em PITIUPI_HOME/plugins e executa o núcleo (catálogo: plugins.registry.json). +# Plugin do catálogo sem build.xml ou Makefile nesta máquina é ignorado. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -49,7 +50,7 @@ repo = Path(sys.argv[2]) mode = sys.argv[3] data = json.loads(registry_path.read_text(encoding="utf-8")) -plugins = data.get("plugins", []) +plugins = list(data.get("plugins", [])) def by_id(pid): for p in plugins: @@ -179,17 +180,25 @@ build_core() { build_one_plugin() { local id="$1" - local dir build_cmd + local dir build_cmd marker dir="$(registry_python field "$id" dir)" build_cmd="$(registry_python field "$id" build)" case "$build_cmd" in - ant) (cd "${REPO_ROOT}/${dir}" && ant jar) ;; - make) (cd "${REPO_ROOT}/${dir}" && make) ;; + ant) marker="${REPO_ROOT}/${dir}/build.xml" ;; + make) marker="${REPO_ROOT}/${dir}/Makefile" ;; *) printf 'ERRO: build desconhecido para %s: %s\n' "$id" "$build_cmd" >&2 exit 1 ;; esac + if [[ ! -f "${marker}" ]]; then + printf 'Plugin %s ausente nesta máquina; não será carregado.\n' "$id" + return 0 + fi + case "$build_cmd" in + ant) (cd "${REPO_ROOT}/${dir}" && ant jar) ;; + make) (cd "${REPO_ROOT}/${dir}" && make) ;; + esac } build_plugins_from_selection() { @@ -232,6 +241,17 @@ link_plugins_from_selection() { link_name="${id}.jar" src_abs="${REPO_ROOT}/${dir}/${jar_rel}" if [[ ! -f "${src_abs}" ]]; then + local marker="" + local build_cmd + build_cmd="$(registry_python field "$id" build)" + case "$build_cmd" in + ant) marker="${REPO_ROOT}/${dir}/build.xml" ;; + make) marker="${REPO_ROOT}/${dir}/Makefile" ;; + esac + if [[ -z "${marker}" || ! -f "${marker}" ]]; then + printf 'Plugin %s ausente nesta máquina; não será carregado.\n' "$id" + continue + fi printf 'ERRO: JAR ausente: %s\n' "${src_abs}" >&2 exit 1 fi