Skip to content

Commit

Permalink
feat: remove --lock-write flag (#25214)
Browse files Browse the repository at this point in the history
This commit remove `--lock-write` that was deprecated in v1.45 release.

Closes #24167.

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
bartlomieju and iuioiua authored Aug 28, 2024
1 parent 511d13a commit efcabce
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 166 deletions.
145 changes: 6 additions & 139 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,6 @@ pub struct Flags {
pub inspect_wait: Option<SocketAddr>,
pub inspect: Option<SocketAddr>,
pub location: Option<Url>,
// TODO(bartlomieju): deprecated, to be removed in Deno 2.
pub lock_write: bool,
pub lock: Option<String>,
pub log_level: Option<Level>,
pub no_remote: bool,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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()),
Expand Down Expand Up @@ -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 {
Expand All @@ -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()),
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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"],
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 {
Expand All @@ -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()),
Expand Down
10 changes: 1 addition & 9 deletions cli/args/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions cli/tools/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/npm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/lockfile/no_declaration_files/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
1 change: 0 additions & 1 deletion tests/specs/lockfile/no_declaration_files/main.cache.out
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions tests/testdata/run/lock_write_fetch/file_exists.ts

This file was deleted.

7 changes: 3 additions & 4 deletions tests/testdata/run/lock_write_fetch/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down Expand Up @@ -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");

0 comments on commit efcabce

Please sign in to comment.