Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/cmd/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ pub fn format_info(pkg: &Package, platform: &Platform, nu: Option<&NuVersion>) -
let mut out = String::new();
out.push_str(&format!("Package: {}/{}\n", pkg.id.owner, pkg.id.name));
out.push_str(&format!("Type: {}\n", pkg.package_type));
match pkg.package_type {
crate::core::package::PackageType::Script
| crate::core::package::PackageType::Completion => {
out.push_str(
"Activation: install-only (activation deferred; install does not wire Nu)\n",
);
}
_ => {}
}
out.push_str("Status: verified upstream artifact\n");
out.push_str(&format!("Description: {}\n", pkg.description));
out.push_str(&format!("Repository: {}\n", pkg.repo));
Expand Down Expand Up @@ -157,16 +166,21 @@ mod tests {
}

#[test]
fn format_info_includes_verified_status_and_disclaimer() {
let pkg = sample_plugin(false);
let nu = NuVersion::parse("0.113.1").unwrap();
let out = format_info(&pkg, &linux_platform(), Some(&nu));
assert!(
out.contains("Status: verified upstream artifact"),
"{out}"
);
assert!(out.contains("has not security-audited"), "{out}");
assert!(!out.to_lowercase().contains("approved"), "{out}");
fn format_info_marks_script_install_only() {
let mut pkg = sample_plugin(false);
pkg.package_type = PackageType::Script;
let out = format_info(&pkg, &linux_platform(), None);
assert!(out.contains("Activation: install-only"), "{out}");
assert!(out.contains("Type: script"), "{out}");
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

#[test]
fn format_info_marks_completion_install_only() {
let mut pkg = sample_plugin(false);
pkg.package_type = PackageType::Completion;
let out = format_info(&pkg, &linux_platform(), None);
assert!(out.contains("Activation: install-only"), "{out}");
assert!(out.contains("Type: completion"), "{out}");
}

#[test]
Expand Down
31 changes: 25 additions & 6 deletions src/cmd/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub fn execute(args: &SearchArgs, root: &Path) -> Result<()> {

// Status when Nu is known and the row needs a verdict: incompatibles,
// --all listings, and all non-plugin compatible rows (asymmetric label).
// Install-only labels do not depend on Nu detection, so script/completion
// rows stay labeled even when the resolver is absent.
let status = if resolver.is_some() {
format_row_status(
&pkg.package_type,
Expand All @@ -91,7 +93,12 @@ pub fn execute(args: &SearchArgs, root: &Path) -> Result<()> {
verified_with,
)
} else {
String::new()
match pkg.package_type {
PackageType::Script | PackageType::Completion => {
format_row_status(&pkg.package_type, true, args.all, None, verified_with)
}
PackageType::Plugin | PackageType::Module => String::new(),
}
};

println!(
Expand Down Expand Up @@ -135,8 +142,8 @@ fn format_search_header(nu: Option<&NuVersion>, triple: &str) -> String {

/// Row status suffix (leading space + brackets), or empty.
///
/// Plugins get a hard evaluated verdict. Non-plugins never use `[compatible]`;
/// they use not-ABI-locked wording and surface `verified_with` when present.
/// Plugins get a hard evaluated verdict. Modules use not-ABI-locked wording.
/// Scripts and completions are install-only until activation contracts land.
fn format_row_status(
pkg_type: &PackageType,
compatible: bool,
Expand All @@ -159,7 +166,17 @@ fn format_row_status(
String::new()
}
}
_ => {
PackageType::Script | PackageType::Completion => {
Comment thread
tonythethompson marked this conversation as resolved.
if verified_with.is_empty() {
" [install-only; activation deferred]".to_string()
} else {
format!(
" [install-only; activation deferred; verified with {}]",
verified_with.join(", ")
)
}
}
PackageType::Module => {
if verified_with.is_empty() {
" [not ABI-locked]".to_string()
} else {
Expand Down Expand Up @@ -297,11 +314,13 @@ mod tests {
}

#[test]
fn script_and_completion_use_module_style_labels() {
fn script_and_completion_use_install_only_labels() {
for ty in [PackageType::Script, PackageType::Completion] {
let status = format_row_status(&ty, true, true, None, &["0.113.1".to_string()]);
assert!(status.contains("not ABI-locked"), "{ty}");
assert!(status.contains("install-only"), "{ty}");
assert!(status.contains("activation deferred"), "{ty}");
assert!(!status.contains("[compatible]"), "{ty}");
assert!(!status.contains("not ABI-locked"), "{ty}");
}
}

Expand Down
Loading
Loading