feat: add AppImageHub provider support
This commit is contained in:
parent
1ad2f8a532
commit
f8ffb95376
23 changed files with 1636 additions and 50 deletions
|
|
@ -109,7 +109,27 @@ pub fn dispatch_with_reporter(
|
|||
if let Some(query) = cli.query {
|
||||
let requested_scope = resolve_requested_scope(cli.system, cli.user, is_effective_root());
|
||||
let transport = aim_core::source::github::default_transport();
|
||||
let mut plan = build_add_plan_with_reporter(&query, transport.as_ref(), reporter)?;
|
||||
let plan_result = build_add_plan_with_reporter(&query, transport.as_ref(), reporter);
|
||||
let mut plan = match plan_result {
|
||||
Ok(plan) => plan,
|
||||
Err(
|
||||
aim_core::app::add::BuildAddPlanError::Query(
|
||||
aim_core::app::query::ResolveQueryError::Unsupported,
|
||||
)
|
||||
| aim_core::app::add::BuildAddPlanError::NoInstallableArtifact { .. },
|
||||
) => {
|
||||
reporter.report(&OperationEvent::Started {
|
||||
kind: OperationKind::Search,
|
||||
label: query.clone(),
|
||||
});
|
||||
let results = build_search_results(&SearchQuery::new(&query), &apps)?;
|
||||
reporter.report(&OperationEvent::Finished {
|
||||
summary: format!("search complete: {} remote hits", results.remote_hits.len()),
|
||||
});
|
||||
return Ok(DispatchResult::Search(results));
|
||||
}
|
||||
Err(error) => return Err(error.into()),
|
||||
};
|
||||
if !plan.interactions.is_empty() {
|
||||
match ui::prompt::resolve_add_plan_interactions(plan.clone())? {
|
||||
Some(resolved) => {
|
||||
|
|
|
|||
|
|
@ -200,6 +200,75 @@ fn cli_add_installs_and_renders_resolved_mode() {
|
|||
.stdout(contains("Completed steps").not());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn positional_query_falls_back_to_search_for_plain_name_queries() {
|
||||
let dir = tempdir().unwrap();
|
||||
let registry_path = dir.path().join("registry.toml");
|
||||
let mut cmd = Command::cargo_bin("aim").unwrap();
|
||||
|
||||
cmd.arg("firefox")
|
||||
.env("AIM_REGISTRY_PATH", ®istry_path)
|
||||
.env(FIXTURE_MODE_ENV, "1")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(contains("Search Results"))
|
||||
.stdout(contains(
|
||||
"[appimagehub] Firefox by Mozilla - Official AppImage Edition",
|
||||
))
|
||||
.stdout(contains("Install query: appimagehub/2338455"))
|
||||
.stdout(contains("Installed firefox").not())
|
||||
.stdout(contains("unsupported source query").not());
|
||||
|
||||
assert!(!registry_path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn positional_query_falls_back_to_empty_search_when_direct_item_has_no_appimage() {
|
||||
let dir = tempdir().unwrap();
|
||||
let registry_path = dir.path().join("registry.toml");
|
||||
let mut cmd = Command::cargo_bin("aim").unwrap();
|
||||
|
||||
cmd.arg("appimagehub/2337998")
|
||||
.env("AIM_REGISTRY_PATH", ®istry_path)
|
||||
.env(FIXTURE_MODE_ENV, "1")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(contains("Search Results"))
|
||||
.stdout(contains("No remote matches"))
|
||||
.stdout(contains("No installed matches"))
|
||||
.stdout(contains("unsupported source query").not())
|
||||
.stdout(contains("no installable artifact").not());
|
||||
|
||||
assert!(!registry_path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_add_installs_appimagehub_source_with_truthful_origin() {
|
||||
let dir = tempdir().unwrap();
|
||||
let registry_path = dir.path().join("registry.toml");
|
||||
let mut cmd = Command::cargo_bin("aim").unwrap();
|
||||
|
||||
cmd.arg("appimagehub/2338455")
|
||||
.env("AIM_REGISTRY_PATH", ®istry_path)
|
||||
.env(FIXTURE_MODE_ENV, "1")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(contains(
|
||||
"Installed Firefox by Mozilla - Official AppImage Edition (user)",
|
||||
))
|
||||
.stdout(contains(
|
||||
"Source: appimagehub https://www.appimagehub.com/p/2338455",
|
||||
))
|
||||
.stdout(contains(
|
||||
"Artifact: https://files06.pling.com/api/files/download/firefox-x86-64.AppImage",
|
||||
));
|
||||
|
||||
let contents = std::fs::read_to_string(®istry_path).unwrap();
|
||||
assert!(contents.contains("display_name = \"Firefox by Mozilla - Official AppImage Edition\""));
|
||||
assert!(contents.contains("kind = \"AppImageHub\""));
|
||||
assert!(contents.contains("canonical_locator = \"2338455\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_add_installs_gitlab_source_with_truthful_origin() {
|
||||
let dir = tempdir().unwrap();
|
||||
|
|
@ -329,9 +398,13 @@ fn cli_reports_unsupported_source_queries_distinctly() {
|
|||
|
||||
cmd.arg("https://gitlab.com/example")
|
||||
.env("AIM_REGISTRY_PATH", ®istry_path)
|
||||
.env(FIXTURE_MODE_ENV, "1")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains("unsupported source query"));
|
||||
.success()
|
||||
.stdout(contains("Search Results"))
|
||||
.stdout(contains("No remote matches"))
|
||||
.stdout(contains("No installed matches"))
|
||||
.stderr(contains("unsupported source query").not());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -342,10 +415,13 @@ fn cli_reports_supported_sources_without_installable_artifacts_distinctly() {
|
|||
|
||||
cmd.arg("https://sourceforge.net/projects/team-app/")
|
||||
.env("AIM_REGISTRY_PATH", ®istry_path)
|
||||
.env(FIXTURE_MODE_ENV, "1")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains("no installable artifact found"))
|
||||
.stderr(contains("sourceforge"));
|
||||
.success()
|
||||
.stdout(contains("Search Results"))
|
||||
.stdout(contains("No remote matches"))
|
||||
.stdout(contains("No installed matches"))
|
||||
.stderr(contains("no installable artifact found").not());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -151,3 +151,21 @@ fn search_command_keeps_empty_results_in_plain_text_mode() {
|
|||
.stdout(contains("Search Results"))
|
||||
.stdout(contains("No remote matches"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn search_command_renders_appimagehub_results() {
|
||||
let dir = tempdir().unwrap();
|
||||
let registry_path = dir.path().join("registry.toml");
|
||||
let mut cmd = Command::cargo_bin("aim").unwrap();
|
||||
|
||||
cmd.args(["search", "firefox"])
|
||||
.env("AIM_REGISTRY_PATH", ®istry_path)
|
||||
.env(FIXTURE_MODE_ENV, "1")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(contains("Search Results"))
|
||||
.stdout(contains(
|
||||
"[appimagehub] Firefox by Mozilla - Official AppImage Edition",
|
||||
))
|
||||
.stdout(contains("Install query: appimagehub/2338455"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue