aKode: comando akode update e avviso di nuova versione
- Nuovo crate akode-update: legge l'ultima release dal repository Gitea configurato ([update] repo_url, predefinito git.difonzo.net/andrea/aKode; 404 = nessun aggiornamento), confronta la semver, scarica akode-<versione>-<target>.tar.gz solo dallo stesso host, verifica lo SHA-256 e sostituisce il binario in modo atomico tenendo akode.old (nel layout a pacchetto aggiorna anche akode-package.json o l'intero pacchetto). - `akode update [--check]` con messaggi in italiano; mai installazioni automatiche. - TUI: controllo in background all'avvio al massimo ogni 24 h (update-check.json in AKODE_HOME), avviso su una riga, disattivabile con [update] check_on_startup = false. - Rimossi il prompt di aggiornamento e le azioni npm/brew/installer di OpenAI ormai inutilizzati; il doctor mostra sorgente e ultimo controllo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,23 +2,62 @@ use anyhow::Result;
|
||||
use predicates::str::contains;
|
||||
use std::path::Path;
|
||||
use tempfile::TempDir;
|
||||
use wiremock::Mock;
|
||||
use wiremock::MockServer;
|
||||
use wiremock::ResponseTemplate;
|
||||
use wiremock::matchers::method;
|
||||
use wiremock::matchers::path;
|
||||
|
||||
fn codex_command(codex_home: &Path) -> Result<assert_cmd::Command> {
|
||||
const LATEST_PATH: &str = "/api/v1/repos/andrea/aKode/releases/latest";
|
||||
|
||||
fn akode_update(akode_home: &Path, server: &MockServer) -> Result<assert_cmd::Command> {
|
||||
let mut cmd = assert_cmd::Command::new(akode_utils_cargo_bin::cargo_bin("akode")?);
|
||||
cmd.env("AKODE_HOME", codex_home);
|
||||
cmd.env("AKODE_HOME", akode_home).args([
|
||||
"-c",
|
||||
&format!("update.repo_url=\"{}/andrea/aKode\"", server.uri()),
|
||||
"update",
|
||||
]);
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
#[tokio::test]
|
||||
async fn update_does_not_start_interactive_prompt() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
async fn update_without_published_release_reports_up_to_date() -> Result<()> {
|
||||
let server = MockServer::start().await;
|
||||
Mock::given(method("GET"))
|
||||
.and(path(LATEST_PATH))
|
||||
.respond_with(ResponseTemplate::new(404))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
let akode_home = TempDir::new()?;
|
||||
|
||||
codex_command(codex_home.path())?
|
||||
.arg("update")
|
||||
akode_update(akode_home.path(), &server)?
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains("`akode update` is not available in debug builds"));
|
||||
.success()
|
||||
.stdout(contains("Nessuna release pubblicata"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn update_check_reports_newer_release_without_installing() -> Result<()> {
|
||||
let server = MockServer::start().await;
|
||||
Mock::given(method("GET"))
|
||||
.and(path(LATEST_PATH))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"tag_name": "v999.0.0",
|
||||
"assets": [],
|
||||
})))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
let akode_home = TempDir::new()?;
|
||||
|
||||
akode_update(akode_home.path(), &server)?
|
||||
.arg("--check")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(contains("È disponibile aKode 999.0.0"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user