aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/init.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-21 10:09:58 +0900
committernsfisis <nsfisis@gmail.com>2026-02-21 10:09:58 +0900
commit0b5d333083f1317391338d3aa67b1290e93922cc (patch)
tree3842907fc1b2ac64c925b477b4daf33f529a5869 /crates/mozart/src/commands/init.rs
parent999fc4157cf631f967a5adedeccb83ae6d0cb0f8 (diff)
downloadphp-mozart-0b5d333083f1317391338d3aa67b1290e93922cc.tar.gz
php-mozart-0b5d333083f1317391338d3aa67b1290e93922cc.tar.zst
php-mozart-0b5d333083f1317391338d3aa67b1290e93922cc.zip
feat(require): implement require command with Packagist version resolution
Add the require command that updates composer.json with new package dependencies. When no version constraint is specified, the best version is resolved from the Packagist p2 API based on minimum-stability. Includes packagist API client, version comparison/stability detection, and RawPackageData deserialization support for roundtrip editing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/init.rs')
-rw-r--r--crates/mozart/src/commands/init.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/mozart/src/commands/init.rs b/crates/mozart/src/commands/init.rs
index 64a0263..fb7520f 100644
--- a/crates/mozart/src/commands/init.rs
+++ b/crates/mozart/src/commands/init.rs
@@ -1,14 +1,12 @@
-use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
-use std::process::Command;
+use crate::console;
+use crate::package::{self, RawAuthor, RawAutoload, RawPackageData, RawRepository};
+use crate::validation;
use anyhow::{Context, bail};
use clap::Args;
use colored::Colorize;
-use crate::console;
-use crate::package::{
- self, RawAuthor, RawAutoload, RawPackageData, RawRepository,
-};
-use crate::validation;
+use std::collections::BTreeMap;
+use std::path::{Path, PathBuf};
+use std::process::Command;
#[derive(Args)]
pub struct InitArgs {
@@ -103,8 +101,7 @@ pub fn execute(args: &InitArgs, cli: &super::Cli) -> anyhow::Result<()> {
console.info(&format!("Writing {}", composer_file.display()));
}
- package::write_to_file(&composer, &composer_file)
- .context("Failed to write composer.json")?;
+ package::write_to_file(&composer, &composer_file).context("Failed to write composer.json")?;
// Create autoload directory if specified
if let Some(ref autoload) = composer.autoload {