Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions crates/vite_install/src/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct PublishCommandOptions<'a> {
pub no_git_checks: bool,
pub publish_branch: Option<&'a str>,
pub report_summary: bool,
pub provenance: bool,
pub force: bool,
pub json: bool,
pub recursive: bool,
Expand Down Expand Up @@ -99,6 +100,10 @@ impl PackageManager {
args.push("--report-summary".into());
}

if options.provenance {
args.push("--provenance".into());
}

if options.force {
args.push("--force".into());
}
Expand Down Expand Up @@ -152,6 +157,10 @@ impl PackageManager {
args.push(otp.to_string());
}

if options.provenance {
args.push("--provenance".into());
}

if options.force {
args.push("--force".into());
}
Expand Down Expand Up @@ -208,6 +217,10 @@ impl PackageManager {
output::warn("--report-summary not supported by bun, ignoring flag");
}

if options.provenance {
output::warn("--provenance not supported by bun publish, ignoring flag");
}

if options.force {
output::warn("--force not supported by bun publish, ignoring flag");
}
Expand Down Expand Up @@ -429,6 +442,50 @@ mod tests {
assert_eq!(result.args, vec!["publish"]);
}

#[test]
fn test_pnpm_publish_provenance() {
let pm = create_mock_package_manager(PackageManagerType::Pnpm, "10.0.0");
let result = pm.resolve_publish_command(&PublishCommandOptions {
provenance: true,
..Default::default()
});
assert_eq!(result.bin_path, "pnpm");
assert_eq!(result.args, vec!["publish", "--provenance"]);
}

#[test]
fn test_npm_publish_provenance() {
let pm = create_mock_package_manager(PackageManagerType::Npm, "11.0.0");
let result = pm.resolve_publish_command(&PublishCommandOptions {
provenance: true,
..Default::default()
});
assert_eq!(result.bin_path, "npm");
assert_eq!(result.args, vec!["publish", "--provenance"]);
}

#[test]
fn test_yarn_publish_provenance() {
let pm = create_mock_package_manager(PackageManagerType::Yarn, "4.0.0");
let result = pm.resolve_publish_command(&PublishCommandOptions {
provenance: true,
..Default::default()
});
assert_eq!(result.bin_path, "npm");
assert_eq!(result.args, vec!["publish", "--provenance"]);
}

#[test]
fn test_bun_publish_provenance_ignored() {
let pm = create_mock_package_manager(PackageManagerType::Bun, "1.2.0");
let result = pm.resolve_publish_command(&PublishCommandOptions {
provenance: true,
..Default::default()
});
assert_eq!(result.bin_path, "bun");
assert_eq!(result.args, vec!["publish"]);
}

#[test]
fn test_pnpm_publish_otp() {
let pm = create_mock_package_manager(PackageManagerType::Pnpm, "10.0.0");
Expand Down
4 changes: 4 additions & 0 deletions crates/vite_pm_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ pub enum PmCommands {
#[arg(long)]
report_summary: bool,

/// Publish with provenance
#[arg(long)]
provenance: bool,

/// Force publish
#[arg(long)]
force: bool,
Expand Down
2 changes: 2 additions & 0 deletions crates/vite_pm_cli/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ pub async fn run_pm_subcommand(
no_git_checks,
publish_branch,
report_summary,
provenance,
force,
json,
recursive,
Expand All @@ -287,6 +288,7 @@ pub async fn run_pm_subcommand(
no_git_checks,
publish_branch: publish_branch.as_deref(),
report_summary,
provenance,
force,
json,
recursive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Options:
--no-git-checks Skip git checks
--publish-branch <BRANCH> Set the branch name to publish from
--report-summary Save publish summary
--provenance Publish with provenance
--force Force publish
--json Output in JSON format
-r, --recursive Publish all workspace packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Options:
--no-git-checks Skip git checks
--publish-branch <BRANCH> Set the branch name to publish from
--report-summary Save publish summary
--provenance Publish with provenance
--force Force publish
--json Output in JSON format
-r, --recursive Publish all workspace packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Options:
--no-git-checks Skip git checks
--publish-branch <BRANCH> Set the branch name to publish from
--report-summary Save publish summary
--provenance Publish with provenance
--force Force publish
--json Output in JSON format
-r, --recursive Publish all workspace packages
Expand Down
Loading