summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/flags.rs8
-rw-r--r--cli/tests/integration/publish_tests.rs10
-rw-r--r--cli/tests/testdata/publish/dry_run.out4
-rw-r--r--cli/tools/registry/mod.rs8
4 files changed, 30 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 0e4e88764..738bf9948 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -328,6 +328,7 @@ pub struct VendorFlags {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PublishFlags {
pub token: Option<String>,
+ pub dry_run: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -2379,6 +2380,12 @@ fn publish_subcommand() -> Command {
.long("token")
.help("The API token to use when publishing. If unset, interactive authentication is be used")
)
+ .arg(
+ Arg::new("dry-run")
+ .long("dry-run")
+ .help("Prepare the package for publishing performing all checks and validations without uploading")
+ .action(ArgAction::SetTrue),
+ )
})
}
@@ -3812,6 +3819,7 @@ fn vendor_parse(flags: &mut Flags, matches: &mut ArgMatches) {
fn publish_parse(flags: &mut Flags, matches: &mut ArgMatches) {
flags.subcommand = DenoSubcommand::Publish(PublishFlags {
token: matches.remove_one("token"),
+ dry_run: matches.get_flag("dry-run"),
});
}
diff --git a/cli/tests/integration/publish_tests.rs b/cli/tests/integration/publish_tests.rs
index c0569e506..cee5545d2 100644
--- a/cli/tests/integration/publish_tests.rs
+++ b/cli/tests/integration/publish_tests.rs
@@ -89,6 +89,16 @@ itest!(workspace_individual {
temp_cwd: true,
});
+itest!(dry_run {
+ args: "publish --token 'sadfasdf' --dry-run",
+ cwd: Some("publish/successful"),
+ copy_temp_dir: Some("publish/successful"),
+ output: "publish/dry_run.out",
+ envs: env_vars_for_registry(),
+ http_server: true,
+ temp_cwd: true,
+});
+
#[test]
fn ignores_directories() {
let context = publish_context_builder().build();
diff --git a/cli/tests/testdata/publish/dry_run.out b/cli/tests/testdata/publish/dry_run.out
new file mode 100644
index 000000000..f9f4df72e
--- /dev/null
+++ b/cli/tests/testdata/publish/dry_run.out
@@ -0,0 +1,4 @@
+Checking fast check type graph for errors...
+Ensuring type checks...
+Check [WILDCARD]
+Warning Aborting due to --dry-run
diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs
index 8293a87fe..2be90bf52 100644
--- a/cli/tools/registry/mod.rs
+++ b/cli/tools/registry/mod.rs
@@ -836,6 +836,14 @@ pub async fn publish(
bail!("No packages to publish");
}
+ if publish_flags.dry_run {
+ log::warn!(
+ "{} Aborting due to --dry-run",
+ crate::colors::yellow("Warning")
+ );
+ return Ok(());
+ }
+
perform_publish(
cli_factory.http_client(),
publish_order_graph,