From 0b5d333083f1317391338d3aa67b1290e93922cc Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 10:09:58 +0900 Subject: 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 --- crates/mozart/src/commands/init.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'crates/mozart/src/commands/init.rs') 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 { -- cgit v1.3.1