From efcabce1c117a2e0fed8604d887695a0a19a37ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 28 Aug 2024 04:23:51 +0100 Subject: [PATCH] feat: remove `--lock-write` flag (#25214) This commit remove `--lock-write` that was deprecated in v1.45 release. Closes https://github.com/denoland/deno/issues/24167. --------- Co-authored-by: Asher Gomez --- cli/args/flags.rs | 145 +----------------- cli/args/lockfile.rs | 10 +- cli/tools/installer.rs | 4 - tests/integration/npm_tests.rs | 2 - .../no_declaration_files/__test__.jsonc | 2 +- .../no_declaration_files/main.cache.out | 1 - .../run/lock_write_fetch/file_exists.ts | 6 - tests/testdata/run/lock_write_fetch/main.ts | 7 +- 8 files changed, 11 insertions(+), 166 deletions(-) delete mode 100644 tests/testdata/run/lock_write_fetch/file_exists.ts diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 877b26de22..ca8a0a82fa 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -613,8 +613,6 @@ pub struct Flags { pub inspect_wait: Option, pub inspect: Option, pub location: Option, - // TODO(bartlomieju): deprecated, to be removed in Deno 2. - pub lock_write: bool, pub lock: Option, pub log_level: Option, pub no_remote: bool, @@ -2362,7 +2360,6 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.", .arg(no_remote_arg()) .arg(no_npm_arg()) .arg(lock_arg()) - .arg(lock_write_arg()) .arg(no_lock_arg()) .arg(config_arg()) .arg(import_map_arg()) @@ -3249,7 +3246,6 @@ fn compile_args_without_check_args(app: Command) -> Command { .arg(no_config_arg()) .arg(reload_arg()) .arg(lock_arg()) - .arg(lock_write_arg()) .arg(no_lock_arg()) .arg(ca_file_arg()) .arg(unsafely_ignore_certificate_errors_arg()) @@ -3875,16 +3871,6 @@ fn lock_arg() -> Arg { .help_heading(DEPENDENCY_MANAGEMENT_HEADING) } -// TODO(bartlomieju): deprecated, to be removed in Deno 2. -fn lock_write_arg() -> Arg { - Arg::new("lock-write") - .action(ArgAction::SetTrue) - .long("lock-write") - .help("Force overwriting the lock file") - .conflicts_with("no-lock") - .hide(true) -} - fn no_lock_arg() -> Arg { Arg::new("no-lock") .long("no-lock") @@ -5288,10 +5274,6 @@ fn check_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) { fn lock_args_parse(flags: &mut Flags, matches: &mut ArgMatches) { lock_arg_parse(flags, matches); no_lock_arg_parse(flags, matches); - // TODO(bartlomieju): deprecated, to be removed in Deno 2. - if matches.get_flag("lock-write") { - flags.lock_write = true; - } } fn lock_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) { @@ -7111,7 +7093,7 @@ mod tests { #[test] fn eval_with_flags() { #[rustfmt::skip] - let r = flags_from_vec(svec!["deno", "eval", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--reload", "--lock", "lock.json", "--lock-write", "--cert", "example.crt", "--cached-only", "--location", "https:foo", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--env=.example.env", "42"]); + let r = flags_from_vec(svec!["deno", "eval", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--reload", "--lock", "lock.json", "--cert", "example.crt", "--cached-only", "--location", "https:foo", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--env=.example.env", "42"]); assert_eq!( r.unwrap(), Flags { @@ -7125,7 +7107,6 @@ mod tests { type_check_mode: TypeCheckMode::None, reload: true, lock: Some(String::from("lock.json")), - lock_write: true, ca_data: Some(CaData::File("example.crt".to_string())), cached_only: true, location: Some(Url::parse("https://foo/").unwrap()), @@ -7234,7 +7215,7 @@ mod tests { #[test] fn repl_with_flags() { #[rustfmt::skip] - let r = flags_from_vec(svec!["deno", "repl", "-A", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--reload", "--lock", "lock.json", "--lock-write", "--cert", "example.crt", "--cached-only", "--location", "https:foo", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--unsafely-ignore-certificate-errors", "--env=.example.env"]); + let r = flags_from_vec(svec!["deno", "repl", "-A", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--reload", "--lock", "lock.json", "--cert", "example.crt", "--cached-only", "--location", "https:foo", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--unsafely-ignore-certificate-errors", "--env=.example.env"]); assert_eq!( r.unwrap(), Flags { @@ -7249,7 +7230,6 @@ mod tests { type_check_mode: TypeCheckMode::None, reload: true, lock: Some(String::from("lock.json")), - lock_write: true, ca_data: Some(CaData::File("example.crt".to_string())), cached_only: true, location: Some(Url::parse("https://foo/").unwrap()), @@ -7901,13 +7881,8 @@ mod tests { #[test] fn bundle_with_lock() { - let r = flags_from_vec(svec![ - "deno", - "bundle", - "--lock-write", - "--lock=lock.json", - "source.ts" - ]); + let r = + flags_from_vec(svec!["deno", "bundle", "--lock=lock.json", "source.ts"]); assert_eq!( r.unwrap(), Flags { @@ -7917,7 +7892,6 @@ mod tests { watch: Default::default(), }), type_check_mode: TypeCheckMode::Local, - lock_write: true, lock: Some(String::from("lock.json")), ..Flags::default() } @@ -8281,7 +8255,7 @@ mod tests { #[test] fn install_with_flags() { #[rustfmt::skip] - let r = flags_from_vec(svec!["deno", "install", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--unsafely-ignore-certificate-errors", "--reload", "--lock", "lock.json", "--lock-write", "--cert", "example.crt", "--cached-only", "--allow-read", "--allow-net", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--name", "file_server", "--root", "/foo", "--force", "--env=.example.env", "jsr:@std/http/file-server", "foo", "bar"]); + let r = flags_from_vec(svec!["deno", "install", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--unsafely-ignore-certificate-errors", "--reload", "--lock", "lock.json", "--cert", "example.crt", "--cached-only", "--allow-read", "--allow-net", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--name", "file_server", "--root", "/foo", "--force", "--env=.example.env", "jsr:@std/http/file-server", "foo", "bar"]); assert_eq!( r.unwrap(), Flags { @@ -8301,7 +8275,6 @@ mod tests { type_check_mode: TypeCheckMode::None, reload: true, lock: Some(String::from("lock.json")), - lock_write: true, ca_data: Some(CaData::File("example.crt".to_string())), cached_only: true, v8_flags: svec!["--help", "--random-seed=1"], @@ -8878,111 +8851,6 @@ mod tests { ); } - #[test] - fn lock_write() { - let r = flags_from_vec(svec![ - "deno", - "run", - "--lock-write", - "--lock=lock.json", - "script.ts" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Run(RunFlags::new_default( - "script.ts".to_string(), - )), - lock_write: true, - lock: Some(String::from("lock.json")), - code_cache_enabled: true, - ..Flags::default() - } - ); - - let r = flags_from_vec(svec!["deno", "--no-lock", "script.ts"]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Run(RunFlags { - script: "script.ts".to_string(), - watch: None, - bare: true, - }), - no_lock: true, - code_cache_enabled: true, - ..Flags::default() - } - ); - - let r = flags_from_vec(svec![ - "deno", - "run", - "--lock", - "--lock-write", - "script.ts" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Run(RunFlags::new_default( - "script.ts".to_string(), - )), - lock_write: true, - lock: Some(String::from("./deno.lock")), - code_cache_enabled: true, - ..Flags::default() - } - ); - - let r = flags_from_vec(svec![ - "deno", - "run", - "--lock-write", - "--lock", - "lock.json", - "script.ts" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Run(RunFlags::new_default( - "script.ts".to_string(), - )), - lock_write: true, - lock: Some(String::from("lock.json")), - code_cache_enabled: true, - ..Flags::default() - } - ); - - let r = flags_from_vec(svec!["deno", "run", "--lock-write", "script.ts"]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Run(RunFlags::new_default( - "script.ts".to_string(), - )), - lock_write: true, - code_cache_enabled: true, - ..Flags::default() - } - ); - - let r = - flags_from_vec(svec!["deno", "run", "--lock", "--no-lock", "script.ts"]); - assert!(r.is_err(),); - - let r = flags_from_vec(svec![ - "deno", - "run", - "--lock-write", - "--no-lock", - "script.ts" - ]); - assert!(r.is_err(),); - } - #[test] fn test_no_colon_in_value_name() { let app = @@ -10108,7 +9976,7 @@ mod tests { #[test] fn compile_with_flags() { #[rustfmt::skip] - let r = flags_from_vec(svec!["deno", "compile", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--unsafely-ignore-certificate-errors", "--reload", "--lock", "lock.json", "--lock-write", "--cert", "example.crt", "--cached-only", "--location", "https:foo", "--allow-read", "--allow-net", "--v8-flags=--help", "--seed", "1", "--no-terminal", "--icon", "favicon.ico", "--output", "colors", "--env=.example.env", "https://examples.deno.land/color-logging.ts", "foo", "bar", "-p", "8080"]); + let r = flags_from_vec(svec!["deno", "compile", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--unsafely-ignore-certificate-errors", "--reload", "--lock", "lock.json", "--cert", "example.crt", "--cached-only", "--location", "https:foo", "--allow-read", "--allow-net", "--v8-flags=--help", "--seed", "1", "--no-terminal", "--icon", "favicon.ico", "--output", "colors", "--env=.example.env", "https://examples.deno.land/color-logging.ts", "foo", "bar", "-p", "8080"]); assert_eq!( r.unwrap(), Flags { @@ -10128,7 +9996,6 @@ mod tests { type_check_mode: TypeCheckMode::None, reload: true, lock: Some(String::from("lock.json")), - lock_write: true, ca_data: Some(CaData::File("example.crt".to_string())), cached_only: true, location: Some(Url::parse("https://foo/").unwrap()), diff --git a/cli/args/lockfile.rs b/cli/args/lockfile.rs index 30db49b7ac..8817975cf1 100644 --- a/cli/args/lockfile.rs +++ b/cli/args/lockfile.rs @@ -157,15 +157,7 @@ impl CliLockfile { .unwrap_or(false) }); - let lockfile = if flags.lock_write { - log::warn!( - "{} \"--lock-write\" flag is deprecated and will be removed in Deno 2.", - crate::colors::yellow("Warning") - ); - CliLockfile::new(Lockfile::new_empty(filename, true), frozen) - } else { - Self::read_from_path(filename, frozen)? - }; + let lockfile = Self::read_from_path(filename, frozen)?; // initialize the lockfile with the workspace's configuration let root_url = workspace.root_dir(); diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 1809e1f16a..c3f415dc7f 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -464,10 +464,6 @@ async fn resolve_shim_data( executable_args.push("--no-npm".to_string()); } - if flags.lock_write { - executable_args.push("--lock-write".to_string()); - } - if flags.cached_only { executable_args.push("--cached-only".to_string()); } diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index 7f5145a423..2babcb21e2 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -1209,7 +1209,6 @@ fn lock_file_missing_top_level_package() { #[test] fn lock_file_lock_write() { // https://github.com/denoland/deno/issues/16666 - // Ensure that --lock-write still adds npm packages to the lockfile let _server = http_server(); let deno_dir = util::new_deno_dir(); @@ -1396,7 +1395,6 @@ fn lock_file_lock_write() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("cache") - .arg("--lock-write") .arg("--quiet") .arg("npm:cowsay@1.5.0") .envs(env_vars_for_npm_tests()) diff --git a/tests/specs/lockfile/no_declaration_files/__test__.jsonc b/tests/specs/lockfile/no_declaration_files/__test__.jsonc index 8bbb558251..3238416b0d 100644 --- a/tests/specs/lockfile/no_declaration_files/__test__.jsonc +++ b/tests/specs/lockfile/no_declaration_files/__test__.jsonc @@ -1,7 +1,7 @@ { "tempDir": true, "steps": [{ - "args": "cache --lock --lock-write main.ts", + "args": "cache --lock --frozen=false main.ts", "output": "main.cache.out" }, { "args": [ diff --git a/tests/specs/lockfile/no_declaration_files/main.cache.out b/tests/specs/lockfile/no_declaration_files/main.cache.out index 84e728d662..ee8ad33ab7 100644 --- a/tests/specs/lockfile/no_declaration_files/main.cache.out +++ b/tests/specs/lockfile/no_declaration_files/main.cache.out @@ -1,3 +1,2 @@ -Warning "--lock-write" flag is deprecated and will be removed in Deno 2. Download http://localhost:4545/lockfile/no_dts/mod.js Download http://localhost:4545/lockfile/no_dts/mod.d.ts diff --git a/tests/testdata/run/lock_write_fetch/file_exists.ts b/tests/testdata/run/lock_write_fetch/file_exists.ts deleted file mode 100644 index 20de4d4f2f..0000000000 --- a/tests/testdata/run/lock_write_fetch/file_exists.ts +++ /dev/null @@ -1,6 +0,0 @@ -try { - await Deno.open(Deno.args[0]); - Deno.exit(0); -} catch (_e) { - Deno.exit(1); -} diff --git a/tests/testdata/run/lock_write_fetch/main.ts b/tests/testdata/run/lock_write_fetch/main.ts index 57bc54d029..4ce6313119 100644 --- a/tests/testdata/run/lock_write_fetch/main.ts +++ b/tests/testdata/run/lock_write_fetch/main.ts @@ -11,7 +11,6 @@ const fetchProc = await new Deno.Command(Deno.execPath(), { "cache", "--reload", "--lock=lock_write_fetch.json", - "--lock-write", "--cert=tls/RootCA.pem", "run/https_import.ts", ], @@ -40,13 +39,13 @@ const runProc = await new Deno.Command(Deno.execPath(), { args: [ "run", "--lock=lock_write_fetch.json", - "--lock-write", "--allow-read", - "run/lock_write_fetch/file_exists.ts", - "lock_write_fetch.json", + "--cert=tls/RootCA.pem", + "run/https_import.ts", ], }).output(); console.log(`run code: ${runProc.code}`); +await Deno.stat("./lock_write_fetch.json"); Deno.removeSync("./lock_write_fetch.json");