aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/command/create_project_command.rs4
-rw-r--r--crates/shirabe/src/command/show_command.rs6
-rw-r--r--crates/shirabe/src/package/dumper/array_dumper.rs4
-rw-r--r--crates/shirabe/src/package/package_interface.rs13
4 files changed, 11 insertions, 16 deletions
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index a2b44713..7f85b17d 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -392,8 +392,8 @@ impl CreateProjectCommand {
)?)),
false,
);
- for (r#type, _meta) in SUPPORTED_LINK_TYPES.iter() {
- for link in package.get_links_for_type(r#type).values() {
+ for (r#type, meta) in SUPPORTED_LINK_TYPES.iter() {
+ for link in package.get_links_for_type(meta.method).values() {
if link.get_pretty_constraint() == "self.version" {
config_source.add_link(
r#type,
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index f1123e14..a4177b1d 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -594,9 +594,6 @@ impl ShowCommand {
) {
let title = title.unwrap_or(link_type);
let io = self.get_io();
- // TODO(port): `get_links_for_type` matches the composer.json key names ("require",
- // "require-dev", ...), not the `Link::TYPE_*` values passed here, so it always returns
- // an empty map and these sections never print. PHP dispatches on `Link::$TYPES`.
let links = package.get_links_for_type(link_type);
if !links.is_empty() {
io.write(&format!("\n<info>{}</info>", title));
@@ -844,9 +841,6 @@ impl ShowCommand {
package: CompletePackageInterfaceHandle,
link_type: &str,
) {
- // TODO(port): `get_links_for_type` matches the composer.json key names ("require",
- // "require-dev", ...), not the `Link::TYPE_*` values passed here, so it always returns
- // an empty map and these keys never reach the JSON. PHP dispatches on `Link::$TYPES`.
let links = package.get_links_for_type(link_type);
if !links.is_empty() {
diff --git a/crates/shirabe/src/package/dumper/array_dumper.rs b/crates/shirabe/src/package/dumper/array_dumper.rs
index 303a5871..336c96b0 100644
--- a/crates/shirabe/src/package/dumper/array_dumper.rs
+++ b/crates/shirabe/src/package/dumper/array_dumper.rs
@@ -92,8 +92,8 @@ impl ArrayDumper {
data.insert("dist".to_string(), PhpMixed::Array(dist));
}
- for type_name in SUPPORTED_LINK_TYPES.keys() {
- let links = package.get_links_for_type(type_name);
+ for (type_name, opts) in SUPPORTED_LINK_TYPES.iter() {
+ let links = package.get_links_for_type(opts.method);
if links.is_empty() {
continue;
}
diff --git a/crates/shirabe/src/package/package_interface.rs b/crates/shirabe/src/package/package_interface.rs
index d138fd83..c3cb1c56 100644
--- a/crates/shirabe/src/package/package_interface.rs
+++ b/crates/shirabe/src/package/package_interface.rs
@@ -191,17 +191,18 @@ pub trait PackageInterface: std::fmt::Display + std::fmt::Debug {
/// @return array An array of package suggestions with descriptions
fn get_suggests(&self) -> IndexMap<String, String>;
- /// PHP helper that switches on the link kind (require/require-dev/conflict/etc.).
+ /// Stands in for PHP's `$package->{'get'.ucfirst($linkType)}()`, so `link_type` is one of the
+ /// `Link::TYPE_*` values.
fn get_links_for_type(
&self,
link_type: &str,
) -> std::rc::Rc<IndexMap<String, crate::package::Link>> {
match link_type {
- "require" => self.get_requires(),
- "require-dev" => self.get_dev_requires(),
- "conflict" => self.get_conflicts(),
- "provide" => self.get_provides(),
- "replace" => self.get_replaces(),
+ crate::package::Link::TYPE_REQUIRE => self.get_requires(),
+ crate::package::Link::TYPE_DEV_REQUIRE => self.get_dev_requires(),
+ crate::package::Link::TYPE_CONFLICT => self.get_conflicts(),
+ crate::package::Link::TYPE_PROVIDE => self.get_provides(),
+ crate::package::Link::TYPE_REPLACE => self.get_replaces(),
_ => std::rc::Rc::new(IndexMap::new()),
}
}