aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-06 15:16:07 +0900
committernsfisis <nsfisis@gmail.com>2026-06-06 15:17:00 +0900
commit1e7aabcae1b2139aa20a80fbf303c74388933f55 (patch)
tree07c5f4e7502841fef21909b2aa8269e6e71fb2a3 /crates/shirabe/src/command
parentadba8b1969a3f40245324d7feb5905693ca65d5e (diff)
downloadphp-shirabe-1e7aabcae1b2139aa20a80fbf303c74388933f55.tar.gz
php-shirabe-1e7aabcae1b2139aa20a80fbf303c74388933f55.tar.zst
php-shirabe-1e7aabcae1b2139aa20a80fbf303c74388933f55.zip
fix(array-dumper): emit package links and require Link pretty constraint
Resolve the phase-b TODO that left the supported-link-types loop as dead code (links were always an empty Vec), so requires/conflicts/provides/ replaces/require-dev are dumped again via PackageInterface::get_links_for_type, matching the PHP magic-call loop. Every Link in production is constructed with a pretty constraint (all ArrayLoader/AliasPackage/PlatformRepository/InstalledRepository sites pass one), so make Link::pretty_constraint a required String instead of Option<String>. get_pretty_constraint() now returns &str directly rather than anyhow::Result<&str>, dropping the unreachable UnexpectedValueException guard, and all call sites are updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/base_dependency_command.rs8
-rw-r--r--crates/shirabe/src/command/bump_command.rs2
-rw-r--r--crates/shirabe/src/command/check_platform_reqs_command.rs6
-rw-r--r--crates/shirabe/src/command/create_project_command.rs2
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs6
-rw-r--r--crates/shirabe/src/command/show_command.rs12
6 files changed, 15 insertions, 21 deletions
diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs
index 5dfb13f..4f929c8 100644
--- a/crates/shirabe/src/command/base_dependency_command.rs
+++ b/crates/shirabe/src/command/base_dependency_command.rs
@@ -357,11 +357,7 @@ pub trait BaseDependencyCommand: BaseCommand {
name_with_link,
version,
link.get_description().to_string(),
- format!(
- "{} ({})",
- link.get_target(),
- link.get_pretty_constraint().unwrap_or("")
- ),
+ format!("{} ({})", link.get_target(), link.get_pretty_constraint()),
]);
if let Some(children_vec) = children {
queue.extend(children_vec);
@@ -438,7 +434,7 @@ pub trait BaseDependencyCommand: BaseCommand {
prev_color,
link.get_target(),
prev_color,
- link.get_pretty_constraint().unwrap_or("")
+ link.get_pretty_constraint(),
);
let circular_warn = if children.is_none() {
"(circular dependency aborted here)"
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index f322ec0..d477747 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -236,7 +236,7 @@ impl BumpCommand {
if PlatformRepository::is_platform_package(pkg_name) {
continue;
}
- let current_constraint = link.get_pretty_constraint()?;
+ let current_constraint = link.get_pretty_constraint();
let package_opt = repo.find_package(
pkg_name,
diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs
index 5225f7e..05f7e9b 100644
--- a/crates/shirabe/src/command/check_platform_reqs_command.rs
+++ b/crates/shirabe/src/command/check_platform_reqs_command.rs
@@ -287,9 +287,7 @@ impl CheckPlatformReqsCommand {
);
failed_req.insert(
"constraint".to_string(),
- Box::new(PhpMixed::String(
- link.get_pretty_constraint().unwrap_or("").to_string(),
- )),
+ Box::new(PhpMixed::String(link.get_pretty_constraint().to_string())),
);
row.insert(
"failed_requirement".to_string(),
@@ -327,7 +325,7 @@ impl CheckPlatformReqsCommand {
link.get_source(),
link.get_description(),
link.get_target(),
- link.get_pretty_constraint().unwrap_or(""),
+ link.get_pretty_constraint(),
))
} else {
PhpMixed::String(String::new())
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index 8485069..b13a3d0 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -517,7 +517,7 @@ impl CreateProjectCommand {
let _method = format!("get{}", meta.method);
let links: Vec<crate::package::Link> = vec![];
for link in links {
- if link.get_pretty_constraint().as_deref().ok() == Some("self.version") {
+ if link.get_pretty_constraint() == "self.version" {
config_source.add_link(
r#type,
link.get_target(),
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index 1f2ef5b..72b635f 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -887,7 +887,7 @@ pub trait PackageDiscoveryTrait {
candidate.get_pretty_name(),
candidate.get_pretty_version(),
link.get_target(),
- link.get_pretty_constraint().unwrap_or(""),
+ link.get_pretty_constraint(),
link.get_target(),
));
} else {
@@ -896,7 +896,7 @@ pub trait PackageDiscoveryTrait {
candidate.get_pretty_name(),
candidate.get_pretty_version(),
link.get_target(),
- link.get_pretty_constraint().unwrap_or(""),
+ link.get_pretty_constraint(),
));
}
continue;
@@ -930,7 +930,7 @@ pub trait PackageDiscoveryTrait {
candidate.get_pretty_name(),
candidate.get_pretty_version(),
link.get_target(),
- link.get_pretty_constraint().unwrap_or(""),
+ link.get_pretty_constraint(),
platform_pkg_version,
));
}
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index 9592f4e..299ba1e 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -1811,7 +1811,7 @@ impl ShowCommand {
io.write(&format!(
"{} <comment>{}</comment>",
link.1.get_target(),
- link.1.get_pretty_constraint().unwrap_or("")
+ link.1.get_pretty_constraint(),
));
}
}
@@ -2173,7 +2173,7 @@ impl ShowCommand {
for link in links.iter() {
m.insert(
link.1.get_target().to_string(),
- PhpMixed::String(link.1.get_pretty_constraint().unwrap_or("").to_string()),
+ PhpMixed::String(link.1.get_pretty_constraint().to_string()),
);
}
json.insert(
@@ -2309,7 +2309,7 @@ impl ShowCommand {
tree_child_desc.insert("name".to_string(), PhpMixed::String(require_name.clone()));
tree_child_desc.insert(
"version".to_string(),
- PhpMixed::String(require.get_pretty_constraint().unwrap_or("").to_string()),
+ PhpMixed::String(require.get_pretty_constraint().to_string()),
);
let deep_children = self
@@ -2452,11 +2452,11 @@ impl ShowCommand {
packages_in_tree: &[PhpMixed],
) -> anyhow::Result<Vec<IndexMap<String, PhpMixed>>> {
let mut children: Vec<IndexMap<String, PhpMixed>> = Vec::new();
- let version_arg: PhpMixed = if link.get_pretty_constraint().ok() == Some("self.version") {
+ let version_arg: PhpMixed = if link.get_pretty_constraint() == "self.version" {
// pass the ConstraintInterface object — signal via Null in this scalar shape
PhpMixed::Null
} else {
- PhpMixed::String(link.get_pretty_constraint().unwrap_or("").to_string())
+ PhpMixed::String(link.get_pretty_constraint().to_string())
};
let (package, _) = self.get_package(installed_repo, remote_repos, name, version_arg)?;
if let Some(package) = package {
@@ -2469,7 +2469,7 @@ impl ShowCommand {
tree_child_desc.insert("name".to_string(), PhpMixed::String(require_name.clone()));
tree_child_desc.insert(
"version".to_string(),
- PhpMixed::String(require.get_pretty_constraint().unwrap_or("").to_string()),
+ PhpMixed::String(require.get_pretty_constraint().to_string()),
);
if !in_array(