mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
chore(publish): add --dry-run flag (#21895)
This commit is contained in:
parent
9268df5f34
commit
f45ceb2320
4 changed files with 30 additions and 0 deletions
|
@ -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"),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
4
cli/tests/testdata/publish/dry_run.out
vendored
Normal file
4
cli/tests/testdata/publish/dry_run.out
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
Checking fast check type graph for errors...
|
||||
Ensuring type checks...
|
||||
Check [WILDCARD]
|
||||
Warning Aborting due to --dry-run
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue