@@ -7,6 +7,7 @@ pub mod cat_index;
77pub mod config;
88pub mod create;
99pub mod dedupe;
10+ pub mod deploy;
1011pub mod dist_tag;
1112pub mod dlx;
1213pub mod exec;
@@ -57,6 +58,7 @@ use clap::{Parser, Subcommand, ValueEnum};
5758use config:: ConfigArgs ;
5859use create:: CreateArgs ;
5960use dedupe:: DedupeArgs ;
61+ use deploy:: DeployArgs ;
6062use dist_tag:: DistTagArgs ;
6163use dlx:: DlxArgs ;
6264use exec:: ExecArgs ;
@@ -282,6 +284,8 @@ pub enum CliCommand {
282284 Import ( ImportArgs ) ,
283285 /// Deduplicate packages in the lockfile
284286 Dedupe ( DedupeArgs ) ,
287+ /// Deploy a package from a workspace
288+ Deploy ( DeployArgs ) ,
285289 /// Remove extraneous packages
286290 Prune ( PruneArgs ) ,
287291 /// Fetch packages from the lockfile into the virtual store
@@ -376,6 +380,7 @@ impl CliArgs {
376380 | CliCommand :: Link ( _)
377381 | CliCommand :: Import ( _)
378382 | CliCommand :: Dedupe ( _)
383+ | CliCommand :: Deploy ( _)
379384 | CliCommand :: Prune ( _)
380385 | CliCommand :: Fetch ( _)
381386 | CliCommand :: Unlink ( _)
@@ -721,30 +726,7 @@ impl CliArgs {
721726 // mutable through `Config::leak`'s
722727 // `&'static mut Config` return.
723728 let cfg = config ( ) ?;
724- cfg. offline = cfg. offline || args. offline ;
725- cfg. prefer_offline = cfg. prefer_offline || args. prefer_offline ;
726- cfg. frozen_store = cfg. frozen_store || args. frozen_store ;
727- // `--ignore-scripts` enables (never toggles off) the
728- // config value, matching the "enable" CLI flags above.
729- cfg. ignore_scripts = cfg. ignore_scripts || args. ignore_scripts ;
730- cfg. workspace_concurrency =
731- args. resolve_workspace_concurrency ( cfg. workspace_concurrency ) ;
732- // Network overrides: a passed `--network-concurrency` /
733- // `--fetch-timeout` / `--user-agent` replaces the
734- // config-resolved value for this invocation, matching
735- // pnpm's "CLI wins" precedence.
736- if let Some ( network_concurrency) = args. network_concurrency {
737- cfg. network_concurrency = network_concurrency;
738- }
739- if let Some ( fetch_timeout) = args. fetch_timeout {
740- cfg. fetch_timeout = fetch_timeout;
741- }
742- if let Some ( user_agent) = args. user_agent . clone ( ) {
743- cfg. user_agent = user_agent;
744- }
745- if let Some ( pnpr_server) = args. pnpr_server . clone ( ) {
746- cfg. pnpr_server = Some ( pnpr_server) ;
747- }
729+ apply_install_cli_config ( cfg, & args) ;
748730 let require_lockfile = args. frozen_lockfile ;
749731 let frozen_lockfile = args. frozen_lockfile ;
750732 // Config dependencies are workspace-level state: their
@@ -788,6 +770,33 @@ impl CliArgs {
788770 }
789771 Ok ( ( ) )
790772 } ) ,
773+ CliCommand :: Deploy ( args) => Box :: pin ( async move {
774+ #[ allow(
775+ clippy:: large_stack_frames,
776+ reason = "the three monomorphized deploy futures would otherwise each reserve their full size in this frame"
777+ ) ]
778+ {
779+ let cfg = config ( ) ?;
780+ apply_install_cli_config ( cfg, & args. install_args ) ;
781+ let ( config_root, package_manager_to_sync) =
782+ derive_config_root_and_package_manager_to_sync ( cfg, dir_ref)
783+ . wrap_err ( "derive workspace root and package manager policy" ) ?;
784+ let pipeline =
785+ DeployPipeline { args, cfg, config_root, package_manager_to_sync } ;
786+ match reporter {
787+ ReporterType :: Default | ReporterType :: AppendOnly => {
788+ Box :: pin ( pipeline. run :: < DefaultReporter > ( dir_ref) ) . await ?;
789+ }
790+ ReporterType :: Ndjson => {
791+ Box :: pin ( pipeline. run :: < NdjsonReporter > ( dir_ref) ) . await ?;
792+ }
793+ ReporterType :: Silent => {
794+ Box :: pin ( pipeline. run :: < SilentReporter > ( dir_ref) ) . await ?;
795+ }
796+ }
797+ }
798+ Ok ( ( ) )
799+ } ) ,
791800 CliCommand :: Test => {
792801 let manifest = PackageManifest :: from_path ( manifest_path_ref. clone ( ) )
793802 . wrap_err ( "getting the package.json in current directory" ) ?;
@@ -1079,6 +1088,33 @@ impl InstallPipeline {
10791088 }
10801089}
10811090
1091+ struct DeployPipeline {
1092+ args : DeployArgs ,
1093+ cfg : & ' static mut Config ,
1094+ config_root : PathBuf ,
1095+ package_manager_to_sync : Option < PackageManagerToSync > ,
1096+ }
1097+
1098+ impl DeployPipeline {
1099+ async fn run < Reporter : self :: Reporter + ' static > ( self , dir_ref : & Path ) -> miette:: Result < ( ) > {
1100+ let DeployPipeline { args, cfg, config_root, package_manager_to_sync } = self ;
1101+ if let Some ( pm) = package_manager_to_sync. as_ref ( ) {
1102+ config_deps:: sync_package_manager_dependencies (
1103+ cfg,
1104+ & config_root,
1105+ & pm. specifier ,
1106+ & pm. version ,
1107+ false ,
1108+ )
1109+ . await ?;
1110+ }
1111+ config_deps:: install_config_deps :: < Reporter > ( cfg, & config_root, false ) . await ?;
1112+ config_deps:: run_update_config_hooks :: < Reporter > ( cfg, & config_root) . await ?;
1113+ let cfg: & ' static Config = cfg;
1114+ Box :: pin ( args. run :: < Reporter > ( cfg, dir_ref) ) . await
1115+ }
1116+ }
1117+
10821118/// Shared workspace-root and package-manager policy derivation used by the
10831119/// install, dedupe, and prune dispatch paths.
10841120fn derive_config_root_and_package_manager_to_sync (
@@ -1092,6 +1128,26 @@ fn derive_config_root_and_package_manager_to_sync(
10921128 Ok ( ( config_root, package_manager_to_sync) )
10931129}
10941130
1131+ fn apply_install_cli_config ( cfg : & mut Config , args : & InstallArgs ) {
1132+ cfg. offline = cfg. offline || args. offline ;
1133+ cfg. prefer_offline = cfg. prefer_offline || args. prefer_offline ;
1134+ cfg. frozen_store = cfg. frozen_store || args. frozen_store ;
1135+ cfg. ignore_scripts = cfg. ignore_scripts || args. ignore_scripts ;
1136+ cfg. workspace_concurrency = args. resolve_workspace_concurrency ( cfg. workspace_concurrency ) ;
1137+ if let Some ( network_concurrency) = args. network_concurrency {
1138+ cfg. network_concurrency = network_concurrency;
1139+ }
1140+ if let Some ( fetch_timeout) = args. fetch_timeout {
1141+ cfg. fetch_timeout = fetch_timeout;
1142+ }
1143+ if let Some ( user_agent) = args. user_agent . clone ( ) {
1144+ cfg. user_agent = user_agent;
1145+ }
1146+ if let Some ( pnpr_server) = args. pnpr_server . clone ( ) {
1147+ cfg. pnpr_server = Some ( pnpr_server) ;
1148+ }
1149+ }
1150+
10951151/// The reporter-generic body of `pacquet dedupe`: snapshots the lockfile
10961152/// (when `--check`), runs config-dependency installation and `updateConfig`
10971153/// hooks, then dispatches to the install pipeline. The snapshot wraps the
0 commit comments