Skip to content

Commit

Permalink
fix(publish): rename --no-fast-check to --no-zap (#22214)
Browse files Browse the repository at this point in the history
Also prints an information about the flag when there are `zap` errors.
  • Loading branch information
bartlomieju authored Feb 1, 2024
1 parent fddbb01 commit 830d096
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
10 changes: 5 additions & 5 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ pub struct VendorFlags {
pub struct PublishFlags {
pub token: Option<String>,
pub dry_run: bool,
pub no_fast_check: bool,
pub no_zap: bool,
}

#[derive(Clone, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -2386,9 +2386,9 @@ fn publish_subcommand() -> Command {
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("no-fast-check")
.long("no-fast-check")
.help("Skip Fast Check compatibility validation")
Arg::new("no-zap")
.long("no-zap")
.help("Skip Zap compatibility validation")
.action(ArgAction::SetTrue),
)
})
Expand Down Expand Up @@ -3824,7 +3824,7 @@ 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"),
no_fast_check: matches.get_flag("no-fast-check"),
no_zap: matches.get_flag("no-zap"),
});
}

Expand Down
6 changes: 3 additions & 3 deletions cli/tests/integration/publish_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ itest!(invalid_fast_check {
exit_code: 1,
});

itest!(no_fast_check {
args: "publish --no-fast-check --token 'sadfasdf'",
output: "publish/no_fast_check.out",
itest!(no_zap {
args: "publish --no-zap --token 'sadfasdf'",
output: "publish/no_zap.out",
cwd: Some("publish/invalid_fast_check"),
exit_code: 1,
});
Expand Down
4 changes: 4 additions & 0 deletions cli/tests/testdata/publish/invalid_fast_check.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ error[zap-missing-explicit-return-type]: missing explicit return type in the pub
info: all functions in the public API must have an explicit return type
docs: https://jsr.io/go/zap-missing-explicit-return-type

This package contains Zap errors. Although conforming to Zap will
significantly improve the type checking performance of your library,
you can choose to skip it by providing the --no-zap flag.

error: Found 1 problem
File renamed without changes.
13 changes: 13 additions & 0 deletions cli/tools/registry/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,28 @@ impl PublishDiagnosticsCollector {
sources: &dyn ParsedSourceStore,
) -> Result<(), AnyError> {
let mut errors = 0;
let mut has_zap_errors = false;
let diagnostics = self.diagnostics.lock().unwrap().take();
let sources = SourceTextParsedSourceStore(sources);
for diagnostic in diagnostics {
eprint!("{}", diagnostic.display(&sources));
if matches!(diagnostic.level(), DiagnosticLevel::Error) {
errors += 1;
}
if matches!(diagnostic, PublishDiagnostic::FastCheck(..)) {
has_zap_errors = true;
}
}
if errors > 0 {
if has_zap_errors {
eprintln!(
"This package contains Zap errors. Although conforming to Zap will"
);
eprintln!("significantly improve the type checking performance of your library,");
eprintln!("you can choose to skip it by providing the --no-zap flag.");
eprintln!();
}

Err(anyhow!(
"Found {} problem{}",
errors,
Expand Down
12 changes: 6 additions & 6 deletions cli/tools/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ async fn publish_package(

async fn prepare_packages_for_publishing(
cli_factory: &CliFactory,
no_fast_check: bool,
no_zap: bool,
diagnostics_collector: &PublishDiagnosticsCollector,
deno_json: ConfigFile,
import_map: Arc<ImportMap>,
Expand All @@ -664,7 +664,7 @@ async fn prepare_packages_for_publishing(
module_graph_builder,
type_checker,
cli_options,
no_fast_check,
no_zap,
diagnostics_collector,
&[MemberRoots {
name: get_deno_json_package_name(&deno_json)?,
Expand Down Expand Up @@ -695,7 +695,7 @@ async fn prepare_packages_for_publishing(
module_graph_builder,
type_checker,
cli_options,
no_fast_check,
no_zap,
diagnostics_collector,
&roots,
)
Expand Down Expand Up @@ -740,7 +740,7 @@ async fn build_and_check_graph_for_publish(
module_graph_builder: &ModuleGraphBuilder,
type_checker: &TypeChecker,
cli_options: &CliOptions,
no_fast_check: bool,
no_zap: bool,
diagnostics_collector: &PublishDiagnosticsCollector,
packages: &[MemberRoots],
) -> Result<Arc<deno_graph::ModuleGraph>, deno_core::anyhow::Error> {
Expand All @@ -764,7 +764,7 @@ async fn build_and_check_graph_for_publish(
collect_invalid_external_imports(&graph, diagnostics_collector);

let mut has_fast_check_diagnostics = false;
if !no_fast_check {
if !no_zap {
log::info!("Checking fast check type graph for errors...");
has_fast_check_diagnostics = collect_fast_check_type_graph_diagnostics(
&graph,
Expand Down Expand Up @@ -831,7 +831,7 @@ pub async fn publish(
let (publish_order_graph, prepared_package_by_name) =
prepare_packages_for_publishing(
&cli_factory,
publish_flags.no_fast_check,
publish_flags.no_zap,
&diagnostics_collector,
config_file.clone(),
import_map,
Expand Down

0 comments on commit 830d096

Please sign in to comment.