0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

fix(publish): rename --no-fast-check to --no-zap (#22214)

Also prints an information about the flag when there are `zap` errors.
This commit is contained in:
Bartek Iwańczuk 2024-02-01 03:16:52 +01:00 committed by GitHub
parent fddbb018c1
commit 830d096b66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 31 additions and 14 deletions

View file

@ -301,7 +301,7 @@ pub struct VendorFlags {
pub struct PublishFlags { pub struct PublishFlags {
pub token: Option<String>, pub token: Option<String>,
pub dry_run: bool, pub dry_run: bool,
pub no_fast_check: bool, pub no_zap: bool,
} }
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
@ -2386,9 +2386,9 @@ fn publish_subcommand() -> Command {
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new("no-fast-check") Arg::new("no-zap")
.long("no-fast-check") .long("no-zap")
.help("Skip Fast Check compatibility validation") .help("Skip Zap compatibility validation")
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
}) })
@ -3824,7 +3824,7 @@ fn publish_parse(flags: &mut Flags, matches: &mut ArgMatches) {
flags.subcommand = DenoSubcommand::Publish(PublishFlags { flags.subcommand = DenoSubcommand::Publish(PublishFlags {
token: matches.remove_one("token"), token: matches.remove_one("token"),
dry_run: matches.get_flag("dry-run"), dry_run: matches.get_flag("dry-run"),
no_fast_check: matches.get_flag("no-fast-check"), no_zap: matches.get_flag("no-zap"),
}); });
} }

View file

@ -36,9 +36,9 @@ itest!(invalid_fast_check {
exit_code: 1, exit_code: 1,
}); });
itest!(no_fast_check { itest!(no_zap {
args: "publish --no-fast-check --token 'sadfasdf'", args: "publish --no-zap --token 'sadfasdf'",
output: "publish/no_fast_check.out", output: "publish/no_zap.out",
cwd: Some("publish/invalid_fast_check"), cwd: Some("publish/invalid_fast_check"),
exit_code: 1, exit_code: 1,
}); });

View file

@ -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 info: all functions in the public API must have an explicit return type
docs: https://jsr.io/go/zap-missing-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 error: Found 1 problem

View file

@ -36,6 +36,7 @@ impl PublishDiagnosticsCollector {
sources: &dyn ParsedSourceStore, sources: &dyn ParsedSourceStore,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
let mut errors = 0; let mut errors = 0;
let mut has_zap_errors = false;
let diagnostics = self.diagnostics.lock().unwrap().take(); let diagnostics = self.diagnostics.lock().unwrap().take();
let sources = SourceTextParsedSourceStore(sources); let sources = SourceTextParsedSourceStore(sources);
for diagnostic in diagnostics { for diagnostic in diagnostics {
@ -43,8 +44,20 @@ impl PublishDiagnosticsCollector {
if matches!(diagnostic.level(), DiagnosticLevel::Error) { if matches!(diagnostic.level(), DiagnosticLevel::Error) {
errors += 1; errors += 1;
} }
if matches!(diagnostic, PublishDiagnostic::FastCheck(..)) {
has_zap_errors = true;
}
} }
if errors > 0 { 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!( Err(anyhow!(
"Found {} problem{}", "Found {} problem{}",
errors, errors,

View file

@ -641,7 +641,7 @@ async fn publish_package(
async fn prepare_packages_for_publishing( async fn prepare_packages_for_publishing(
cli_factory: &CliFactory, cli_factory: &CliFactory,
no_fast_check: bool, no_zap: bool,
diagnostics_collector: &PublishDiagnosticsCollector, diagnostics_collector: &PublishDiagnosticsCollector,
deno_json: ConfigFile, deno_json: ConfigFile,
import_map: Arc<ImportMap>, import_map: Arc<ImportMap>,
@ -664,7 +664,7 @@ async fn prepare_packages_for_publishing(
module_graph_builder, module_graph_builder,
type_checker, type_checker,
cli_options, cli_options,
no_fast_check, no_zap,
diagnostics_collector, diagnostics_collector,
&[MemberRoots { &[MemberRoots {
name: get_deno_json_package_name(&deno_json)?, name: get_deno_json_package_name(&deno_json)?,
@ -695,7 +695,7 @@ async fn prepare_packages_for_publishing(
module_graph_builder, module_graph_builder,
type_checker, type_checker,
cli_options, cli_options,
no_fast_check, no_zap,
diagnostics_collector, diagnostics_collector,
&roots, &roots,
) )
@ -740,7 +740,7 @@ async fn build_and_check_graph_for_publish(
module_graph_builder: &ModuleGraphBuilder, module_graph_builder: &ModuleGraphBuilder,
type_checker: &TypeChecker, type_checker: &TypeChecker,
cli_options: &CliOptions, cli_options: &CliOptions,
no_fast_check: bool, no_zap: bool,
diagnostics_collector: &PublishDiagnosticsCollector, diagnostics_collector: &PublishDiagnosticsCollector,
packages: &[MemberRoots], packages: &[MemberRoots],
) -> Result<Arc<deno_graph::ModuleGraph>, deno_core::anyhow::Error> { ) -> Result<Arc<deno_graph::ModuleGraph>, deno_core::anyhow::Error> {
@ -764,7 +764,7 @@ async fn build_and_check_graph_for_publish(
collect_invalid_external_imports(&graph, diagnostics_collector); collect_invalid_external_imports(&graph, diagnostics_collector);
let mut has_fast_check_diagnostics = false; let mut has_fast_check_diagnostics = false;
if !no_fast_check { if !no_zap {
log::info!("Checking fast check type graph for errors..."); log::info!("Checking fast check type graph for errors...");
has_fast_check_diagnostics = collect_fast_check_type_graph_diagnostics( has_fast_check_diagnostics = collect_fast_check_type_graph_diagnostics(
&graph, &graph,
@ -831,7 +831,7 @@ pub async fn publish(
let (publish_order_graph, prepared_package_by_name) = let (publish_order_graph, prepared_package_by_name) =
prepare_packages_for_publishing( prepare_packages_for_publishing(
&cli_factory, &cli_factory,
publish_flags.no_fast_check, publish_flags.no_zap,
&diagnostics_collector, &diagnostics_collector,
config_file.clone(), config_file.clone(),
import_map, import_map,