mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
chore: cleanup code for deprecation notices in JS code (#25368)
This code hasn't been used in some time, so I cleaned as much of it as possible.
This commit is contained in:
parent
5f08d634f7
commit
e49d80e500
7 changed files with 9 additions and 164 deletions
|
@ -780,8 +780,6 @@ pub struct CliOptions {
|
|||
maybe_lockfile: Option<Arc<CliLockfile>>,
|
||||
overrides: CliOptionOverrides,
|
||||
pub start_dir: Arc<WorkspaceDirectory>,
|
||||
pub disable_deprecated_api_warning: bool,
|
||||
pub verbose_deprecated_api_warning: bool,
|
||||
pub deno_dir_provider: Arc<DenoDirProvider>,
|
||||
}
|
||||
|
||||
|
@ -824,13 +822,6 @@ impl CliOptions {
|
|||
|
||||
load_env_variables_from_env_file(flags.env_file.as_ref());
|
||||
|
||||
let disable_deprecated_api_warning = flags.log_level
|
||||
== Some(log::Level::Error)
|
||||
|| std::env::var("DENO_NO_DEPRECATION_WARNINGS").ok().is_some();
|
||||
|
||||
let verbose_deprecated_api_warning =
|
||||
std::env::var("DENO_VERBOSE_WARNINGS").ok().is_some();
|
||||
|
||||
Ok(Self {
|
||||
flags,
|
||||
initial_cwd,
|
||||
|
@ -839,8 +830,6 @@ impl CliOptions {
|
|||
maybe_node_modules_folder,
|
||||
overrides: Default::default(),
|
||||
start_dir,
|
||||
disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning,
|
||||
deno_dir_provider,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -866,10 +866,6 @@ impl CliFactory {
|
|||
node_ipc: cli_options.node_ipc_fd(),
|
||||
serve_port: cli_options.serve_port(),
|
||||
serve_host: cli_options.serve_host(),
|
||||
// TODO(bartlomieju): temporarily disabled
|
||||
disable_deprecated_api_warning: true,
|
||||
verbose_deprecated_api_warning: cli_options
|
||||
.verbose_deprecated_api_warning,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,6 @@ pub struct Metadata {
|
|||
pub workspace_resolver: SerializedWorkspaceResolver,
|
||||
pub entrypoint_key: String,
|
||||
pub node_modules: Option<NodeModules>,
|
||||
pub disable_deprecated_api_warning: bool,
|
||||
pub unstable_config: UnstableConfig,
|
||||
}
|
||||
|
||||
|
@ -624,8 +623,6 @@ impl<'a> DenoCompileBinaryWriter<'a> {
|
|||
pkg_json_resolution: self.workspace_resolver.pkg_json_dep_resolution(),
|
||||
},
|
||||
node_modules,
|
||||
disable_deprecated_api_warning: cli_options
|
||||
.disable_deprecated_api_warning,
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: cli_options.legacy_unstable_flag(),
|
||||
bare_node_builtins: cli_options.unstable_bare_node_builtins(),
|
||||
|
|
|
@ -737,9 +737,6 @@ pub async fn run(
|
|||
node_ipc: None,
|
||||
serve_port: None,
|
||||
serve_host: None,
|
||||
// TODO(bartlomieju): temporarily disabled
|
||||
disable_deprecated_api_warning: true,
|
||||
verbose_deprecated_api_warning: false,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -119,8 +119,6 @@ pub struct CliMainWorkerOptions {
|
|||
pub node_ipc: Option<i64>,
|
||||
pub serve_port: Option<u16>,
|
||||
pub serve_host: Option<String>,
|
||||
pub disable_deprecated_api_warning: bool,
|
||||
pub verbose_deprecated_api_warning: bool,
|
||||
}
|
||||
|
||||
struct SharedWorkerState {
|
||||
|
@ -593,12 +591,6 @@ impl CliMainWorkerFactory {
|
|||
argv0: shared.options.argv0.clone(),
|
||||
node_debug: shared.options.node_debug.clone(),
|
||||
node_ipc_fd: shared.options.node_ipc,
|
||||
disable_deprecated_api_warning: shared
|
||||
.options
|
||||
.disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning: shared
|
||||
.options
|
||||
.verbose_deprecated_api_warning,
|
||||
future: shared.enable_future_features,
|
||||
mode,
|
||||
serve_port: shared.options.serve_port,
|
||||
|
@ -795,12 +787,6 @@ fn create_web_worker_callback(
|
|||
argv0: shared.options.argv0.clone(),
|
||||
node_debug: shared.options.node_debug.clone(),
|
||||
node_ipc_fd: None,
|
||||
disable_deprecated_api_warning: shared
|
||||
.options
|
||||
.disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning: shared
|
||||
.options
|
||||
.verbose_deprecated_api_warning,
|
||||
future: shared.enable_future_features,
|
||||
mode: WorkerExecutionMode::Worker,
|
||||
serve_port: shared.options.serve_port,
|
||||
|
|
|
@ -26,8 +26,6 @@ const {
|
|||
ArrayPrototypeFilter,
|
||||
ArrayPrototypeIncludes,
|
||||
ArrayPrototypeMap,
|
||||
ArrayPrototypePop,
|
||||
ArrayPrototypeShift,
|
||||
DateNow,
|
||||
Error,
|
||||
ErrorPrototype,
|
||||
|
@ -43,11 +41,7 @@ const {
|
|||
ObjectValues,
|
||||
PromisePrototypeThen,
|
||||
PromiseResolve,
|
||||
SafeSet,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypePadEnd,
|
||||
StringPrototypeSplit,
|
||||
StringPrototypeTrim,
|
||||
Symbol,
|
||||
SymbolIterator,
|
||||
TypeError,
|
||||
|
@ -116,104 +110,8 @@ ObjectDefineProperties(Symbol, {
|
|||
let windowIsClosing = false;
|
||||
let globalThis_;
|
||||
|
||||
let verboseDeprecatedApiWarning = false;
|
||||
let deprecatedApiWarningDisabled = false;
|
||||
const ALREADY_WARNED_DEPRECATED = new SafeSet();
|
||||
|
||||
function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
|
||||
if (deprecatedApiWarningDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
const logError = console.error;
|
||||
|
||||
if (!verboseDeprecatedApiWarning) {
|
||||
if (ALREADY_WARNED_DEPRECATED.has(apiName)) {
|
||||
return;
|
||||
}
|
||||
ALREADY_WARNED_DEPRECATED.add(apiName);
|
||||
logError(
|
||||
`%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2. Run again with DENO_VERBOSE_WARNINGS=1 to get more details.`,
|
||||
"color: yellow;",
|
||||
"font-weight: bold;",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ALREADY_WARNED_DEPRECATED.has(apiName + stack)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we haven't warned yet, let's do some processing of the stack trace
|
||||
// to make it more useful.
|
||||
const stackLines = StringPrototypeSplit(stack, "\n");
|
||||
ArrayPrototypeShift(stackLines);
|
||||
while (stackLines.length > 0) {
|
||||
// Filter out internal frames at the top of the stack - they are not useful
|
||||
// to the user.
|
||||
if (
|
||||
StringPrototypeIncludes(stackLines[0], "(ext:") ||
|
||||
StringPrototypeIncludes(stackLines[0], "(node:") ||
|
||||
StringPrototypeIncludes(stackLines[0], "<anonymous>")
|
||||
) {
|
||||
ArrayPrototypeShift(stackLines);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Now remove the last frame if it's coming from "ext:core" - this is most likely
|
||||
// event loop tick or promise handler calling a user function - again not
|
||||
// useful to the user.
|
||||
if (
|
||||
stackLines.length > 0 &&
|
||||
StringPrototypeIncludes(stackLines[stackLines.length - 1], "(ext:core/")
|
||||
) {
|
||||
ArrayPrototypePop(stackLines);
|
||||
}
|
||||
|
||||
let isFromRemoteDependency = false;
|
||||
const firstStackLine = stackLines[0];
|
||||
if (firstStackLine && !StringPrototypeIncludes(firstStackLine, "file:")) {
|
||||
isFromRemoteDependency = true;
|
||||
}
|
||||
|
||||
ALREADY_WARNED_DEPRECATED.add(apiName + stack);
|
||||
logError(
|
||||
`%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2.`,
|
||||
"color: yellow;",
|
||||
"font-weight: bold;",
|
||||
);
|
||||
|
||||
logError();
|
||||
logError(
|
||||
"See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations",
|
||||
);
|
||||
logError();
|
||||
if (stackLines.length > 0) {
|
||||
logError("Stack trace:");
|
||||
for (let i = 0; i < stackLines.length; i++) {
|
||||
logError(` ${StringPrototypeTrim(stackLines[i])}`);
|
||||
}
|
||||
logError();
|
||||
}
|
||||
|
||||
for (let i = 0; i < suggestions.length; i++) {
|
||||
const suggestion = suggestions[i];
|
||||
logError(
|
||||
`%chint: ${suggestion}`,
|
||||
"font-weight: bold;",
|
||||
);
|
||||
}
|
||||
|
||||
if (isFromRemoteDependency) {
|
||||
logError(
|
||||
`%chint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.`,
|
||||
"font-weight: bold;",
|
||||
);
|
||||
}
|
||||
logError();
|
||||
}
|
||||
// TODO(2.0): remove once all deprecated APIs are removed.
|
||||
function warnOnDeprecatedApi() {}
|
||||
|
||||
function windowClose() {
|
||||
if (!windowIsClosing) {
|
||||
|
@ -699,14 +597,12 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
|
|||
6: hasNodeModulesDir,
|
||||
7: argv0,
|
||||
8: nodeDebug,
|
||||
9: shouldDisableDeprecatedApiWarning,
|
||||
10: shouldUseVerboseDeprecatedApiWarning,
|
||||
11: future,
|
||||
12: mode,
|
||||
13: servePort,
|
||||
14: serveHost,
|
||||
15: serveIsMain,
|
||||
16: serveWorkerCount,
|
||||
9: future,
|
||||
10: mode,
|
||||
11: servePort,
|
||||
12: serveHost,
|
||||
13: serveIsMain,
|
||||
14: serveWorkerCount,
|
||||
} = runtimeOptions;
|
||||
|
||||
if (mode === executionModes.serve) {
|
||||
|
@ -797,8 +693,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
|
|||
|
||||
removeImportedOps();
|
||||
|
||||
deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
|
||||
verboseDeprecatedApiWarning = shouldUseVerboseDeprecatedApiWarning;
|
||||
performance.setTimeOrigin(DateNow());
|
||||
globalThis_ = globalThis;
|
||||
|
||||
|
@ -980,9 +874,7 @@ function bootstrapWorkerRuntime(
|
|||
6: hasNodeModulesDir,
|
||||
7: argv0,
|
||||
8: nodeDebug,
|
||||
9: shouldDisableDeprecatedApiWarning,
|
||||
10: shouldUseVerboseDeprecatedApiWarning,
|
||||
11: future,
|
||||
9: future,
|
||||
} = runtimeOptions;
|
||||
|
||||
// TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete
|
||||
|
@ -990,8 +882,6 @@ function bootstrapWorkerRuntime(
|
|||
// within the Deno namespace.
|
||||
internals.future = future;
|
||||
|
||||
deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
|
||||
verboseDeprecatedApiWarning = shouldUseVerboseDeprecatedApiWarning;
|
||||
performance.setTimeOrigin(DateNow());
|
||||
globalThis_ = globalThis;
|
||||
|
||||
|
|
|
@ -116,8 +116,6 @@ pub struct BootstrapOptions {
|
|||
pub argv0: Option<String>,
|
||||
pub node_debug: Option<String>,
|
||||
pub node_ipc_fd: Option<i64>,
|
||||
pub disable_deprecated_api_warning: bool,
|
||||
pub verbose_deprecated_api_warning: bool,
|
||||
pub future: bool,
|
||||
pub mode: WorkerExecutionMode,
|
||||
// Used by `deno serve`
|
||||
|
@ -155,8 +153,6 @@ impl Default for BootstrapOptions {
|
|||
argv0: None,
|
||||
node_debug: None,
|
||||
node_ipc_fd: None,
|
||||
disable_deprecated_api_warning: false,
|
||||
verbose_deprecated_api_warning: false,
|
||||
future: false,
|
||||
mode: WorkerExecutionMode::None,
|
||||
serve_port: Default::default(),
|
||||
|
@ -194,10 +190,6 @@ struct BootstrapV8<'a>(
|
|||
Option<&'a str>,
|
||||
// node_debug
|
||||
Option<&'a str>,
|
||||
// disable_deprecated_api_warning,
|
||||
bool,
|
||||
// verbose_deprecated_api_warning
|
||||
bool,
|
||||
// future
|
||||
bool,
|
||||
// mode
|
||||
|
@ -232,8 +224,6 @@ impl BootstrapOptions {
|
|||
self.has_node_modules_dir,
|
||||
self.argv0.as_deref(),
|
||||
self.node_debug.as_deref(),
|
||||
self.disable_deprecated_api_warning,
|
||||
self.verbose_deprecated_api_warning,
|
||||
self.future,
|
||||
self.mode.discriminant() as _,
|
||||
self.serve_port.unwrap_or_default(),
|
||||
|
|
Loading…
Reference in a new issue