mirror of
https://github.com/denoland/deno.git
synced 2025-10-01 22:51:14 +00:00
BREAKING: Remove --unstable
flag (#25522)
This commit effectively removes the --unstable flag. It's still being parsed, but it only prints a warning that a granular flag should be used instead and doesn't actually enable any unstable feature. Closes https://github.com/denoland/deno/issues/25485 Closes https://github.com/denoland/deno/issues/23237
This commit is contained in:
parent
560ad0331b
commit
064a73f7a0
15 changed files with 60 additions and 179 deletions
|
@ -570,6 +570,7 @@ fn parse_packages_allowed_scripts(s: &str) -> Result<String, AnyError> {
|
|||
Clone, Default, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize,
|
||||
)]
|
||||
pub struct UnstableConfig {
|
||||
// TODO(bartlomieju): remove in Deno 2.5
|
||||
pub legacy_flag_enabled: bool, // --unstable
|
||||
pub bare_node_builtins: bool, // --unstable-bare-node-builts
|
||||
pub sloppy_imports: bool,
|
||||
|
@ -5476,6 +5477,7 @@ fn unstable_args_parse(
|
|||
matches: &mut ArgMatches,
|
||||
cfg: UnstableArgsConfig,
|
||||
) {
|
||||
// TODO(bartlomieju): remove in Deno 2.5
|
||||
if matches.get_flag("unstable") {
|
||||
flags.unstable_config.legacy_flag_enabled = true;
|
||||
}
|
||||
|
@ -8765,7 +8767,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_with_flags() {
|
||||
#[rustfmt::skip]
|
||||
let r = flags_from_vec(svec!["deno", "test", "--unstable", "--no-npm", "--no-remote", "--trace-leaks", "--no-run", "--filter", "- foo", "--coverage=cov", "--clean", "--location", "https:foo", "--allow-net", "--permit-no-files", "dir1/", "dir2/", "--", "arg1", "arg2"]);
|
||||
let r = flags_from_vec(svec!["deno", "test", "--no-npm", "--no-remote", "--trace-leaks", "--no-run", "--filter", "- foo", "--coverage=cov", "--clean", "--location", "https:foo", "--allow-net", "--permit-no-files", "dir1/", "dir2/", "--", "arg1", "arg2"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
|
@ -8789,10 +8791,6 @@ mod tests {
|
|||
junit_path: None,
|
||||
hide_stacktraces: false,
|
||||
}),
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: true,
|
||||
..Default::default()
|
||||
},
|
||||
no_npm: true,
|
||||
no_remote: true,
|
||||
location: Some(Url::parse("https://foo/").unwrap()),
|
||||
|
@ -10200,7 +10198,6 @@ mod tests {
|
|||
"deno",
|
||||
"bench",
|
||||
"--json",
|
||||
"--unstable",
|
||||
"--no-npm",
|
||||
"--no-remote",
|
||||
"--no-run",
|
||||
|
@ -10228,10 +10225,6 @@ mod tests {
|
|||
},
|
||||
watch: Default::default(),
|
||||
}),
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: true,
|
||||
..Default::default()
|
||||
},
|
||||
no_npm: true,
|
||||
no_remote: true,
|
||||
type_check_mode: TypeCheckMode::Local,
|
||||
|
@ -10802,10 +10795,10 @@ mod tests {
|
|||
conn_file: None,
|
||||
}),
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: false,
|
||||
bare_node_builtins: true,
|
||||
sloppy_imports: false,
|
||||
features: svec!["ffi", "worker-options"],
|
||||
..Default::default()
|
||||
},
|
||||
..Flags::default()
|
||||
}
|
||||
|
|
|
@ -1548,10 +1548,6 @@ impl CliOptions {
|
|||
&self.flags.unsafely_ignore_certificate_errors
|
||||
}
|
||||
|
||||
pub fn legacy_unstable_flag(&self) -> bool {
|
||||
self.flags.unstable_config.legacy_flag_enabled
|
||||
}
|
||||
|
||||
pub fn unstable_bare_node_builtins(&self) -> bool {
|
||||
self.flags.unstable_config.bare_node_builtins
|
||||
|| self.workspace().has_unstable("bare-node-builtins")
|
||||
|
|
|
@ -714,10 +714,6 @@ impl CliFactory {
|
|||
let mut checker = FeatureChecker::default();
|
||||
checker.set_exit_cb(Box::new(crate::unstable_exit_cb));
|
||||
checker.set_warn_cb(Box::new(crate::unstable_warn_cb));
|
||||
if cli_options.legacy_unstable_flag() {
|
||||
checker.enable_legacy_unstable();
|
||||
checker.warn_on_legacy_unstable();
|
||||
}
|
||||
let unstable_features = cli_options.unstable_features();
|
||||
for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
|
||||
if unstable_features.contains(&granular_flag.name.to_string()) {
|
||||
|
@ -856,7 +852,6 @@ impl CliFactory {
|
|||
unsafely_ignore_certificate_errors: cli_options
|
||||
.unsafely_ignore_certificate_errors()
|
||||
.clone(),
|
||||
unstable: cli_options.legacy_unstable_flag(),
|
||||
create_hmr_runner,
|
||||
create_coverage_collector,
|
||||
node_ipc: cli_options.node_ipc_fd(),
|
||||
|
|
25
cli/main.rs
25
cli/main.rs
|
@ -478,25 +478,14 @@ fn resolve_flags_and_init(
|
|||
Err(err) => exit_for_error(AnyError::from(err)),
|
||||
};
|
||||
|
||||
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
||||
// TODO(bartlomieju): remove in Deno v2.5 and hard error then.
|
||||
if flags.unstable_config.legacy_flag_enabled {
|
||||
#[allow(clippy::print_stderr)]
|
||||
if matches!(flags.subcommand, DenoSubcommand::Check(_)) {
|
||||
// can't use log crate because that's not setup yet
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
colors::yellow(
|
||||
"The `--unstable` flag is not needed for `deno check` anymore."
|
||||
)
|
||||
);
|
||||
} else {
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
colors::yellow(
|
||||
"The `--unstable` flag is deprecated and will be removed in Deno 2.0. Use granular `--unstable-*` flags instead.\nLearn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags"
|
||||
)
|
||||
);
|
||||
}
|
||||
log::warn!(
|
||||
"⚠️ {}",
|
||||
colors::yellow(
|
||||
"The `--unstable` flag has been removed in Deno 2.0. Use granular `--unstable-*` flags instead.\nLearn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
let default_v8_flags = match flags.subcommand {
|
||||
|
|
|
@ -624,7 +624,7 @@ impl<'a> DenoCompileBinaryWriter<'a> {
|
|||
},
|
||||
node_modules,
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: cli_options.legacy_unstable_flag(),
|
||||
legacy_flag_enabled: false,
|
||||
bare_node_builtins: cli_options.unstable_bare_node_builtins(),
|
||||
sloppy_imports: cli_options.unstable_sloppy_imports(),
|
||||
features: cli_options.unstable_features(),
|
||||
|
|
|
@ -682,12 +682,6 @@ pub async fn run(
|
|||
let feature_checker = Arc::new({
|
||||
let mut checker = FeatureChecker::default();
|
||||
checker.set_exit_cb(Box::new(crate::unstable_exit_cb));
|
||||
// TODO(bartlomieju): enable, once we deprecate `--unstable` in favor
|
||||
// of granular --unstable-* flags.
|
||||
// feature_checker.set_warn_cb(Box::new(crate::unstable_warn_cb));
|
||||
if metadata.unstable_config.legacy_flag_enabled {
|
||||
checker.enable_legacy_unstable();
|
||||
}
|
||||
for feature in metadata.unstable_config.features {
|
||||
// `metadata` is valid for the whole lifetime of the program, so we
|
||||
// can leak the string here.
|
||||
|
@ -733,7 +727,6 @@ pub async fn run(
|
|||
seed: metadata.seed,
|
||||
unsafely_ignore_certificate_errors: metadata
|
||||
.unsafely_ignore_certificate_errors,
|
||||
unstable: metadata.unstable_config.legacy_flag_enabled,
|
||||
create_hmr_runner: None,
|
||||
create_coverage_collector: None,
|
||||
node_ipc: None,
|
||||
|
|
|
@ -490,10 +490,6 @@ async fn resolve_shim_data(
|
|||
TypeCheckMode::Local => executable_args.push("--check".to_string()),
|
||||
}
|
||||
|
||||
if flags.unstable_config.legacy_flag_enabled {
|
||||
executable_args.push("--unstable".to_string());
|
||||
}
|
||||
|
||||
for feature in &flags.unstable_config.features {
|
||||
executable_args.push(format!("--unstable-{}", feature));
|
||||
}
|
||||
|
@ -822,13 +818,7 @@ mod tests {
|
|||
|
||||
create_install_shim(
|
||||
&HttpClientProvider::new(None, None),
|
||||
&Flags {
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Flags::default()
|
||||
},
|
||||
&Flags::default(),
|
||||
InstallFlagsGlobal {
|
||||
module_url: "http://localhost:4545/echo_server.ts".to_string(),
|
||||
args: vec![],
|
||||
|
@ -850,12 +840,11 @@ mod tests {
|
|||
let content = fs::read_to_string(file_path).unwrap();
|
||||
if cfg!(windows) {
|
||||
assert!(content.contains(
|
||||
r#""run" "--unstable" "--no-config" "http://localhost:4545/echo_server.ts""#
|
||||
r#""run" "--no-config" "http://localhost:4545/echo_server.ts""#
|
||||
));
|
||||
} else {
|
||||
assert!(content.contains(
|
||||
r#"run --unstable --no-config 'http://localhost:4545/echo_server.ts'"#
|
||||
));
|
||||
assert!(content
|
||||
.contains(r#"run --no-config 'http://localhost:4545/echo_server.ts'"#));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -886,13 +875,7 @@ mod tests {
|
|||
async fn install_unstable_legacy() {
|
||||
let shim_data = resolve_shim_data(
|
||||
&HttpClientProvider::new(None, None),
|
||||
&Flags {
|
||||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
&Default::default(),
|
||||
&InstallFlagsGlobal {
|
||||
module_url: "http://localhost:4545/echo_server.ts".to_string(),
|
||||
args: vec![],
|
||||
|
@ -907,12 +890,7 @@ mod tests {
|
|||
assert_eq!(shim_data.name, "echo_server");
|
||||
assert_eq!(
|
||||
shim_data.args,
|
||||
vec![
|
||||
"run",
|
||||
"--unstable",
|
||||
"--no-config",
|
||||
"http://localhost:4545/echo_server.ts",
|
||||
]
|
||||
vec!["run", "--no-config", "http://localhost:4545/echo_server.ts",]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,6 @@ pub struct CliMainWorkerOptions {
|
|||
pub origin_data_folder_path: Option<PathBuf>,
|
||||
pub seed: Option<u64>,
|
||||
pub unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||
pub unstable: bool,
|
||||
pub skip_op_registration: bool,
|
||||
pub create_hmr_runner: Option<CreateHmrRunnerCb>,
|
||||
pub create_coverage_collector: Option<CreateCoverageCollectorCb>,
|
||||
|
@ -580,7 +579,6 @@ impl CliMainWorkerFactory {
|
|||
is_stdout_tty: deno_terminal::is_stdout_tty(),
|
||||
is_stderr_tty: deno_terminal::is_stderr_tty(),
|
||||
color_level: colors::get_color_level(),
|
||||
unstable: shared.options.unstable,
|
||||
unstable_features,
|
||||
user_agent: version::DENO_VERSION_INFO.user_agent.to_string(),
|
||||
inspect: shared.options.is_inspecting,
|
||||
|
@ -775,7 +773,6 @@ fn create_web_worker_callback(
|
|||
color_level: colors::get_color_level(),
|
||||
is_stdout_tty: deno_terminal::is_stdout_tty(),
|
||||
is_stderr_tty: deno_terminal::is_stderr_tty(),
|
||||
unstable: shared.options.unstable,
|
||||
unstable_features,
|
||||
user_agent: version::DENO_VERSION_INFO.user_agent.to_string(),
|
||||
inspect: shared.options.is_inspecting,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue