1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

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 <ashersaupingomez@gmail.com>
This commit is contained in:
Bartek Iwańczuk 2024-08-28 04:23:51 +01:00 committed by GitHub
parent 511d13abaf
commit efcabce1c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 11 additions and 166 deletions

View file

@ -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,
@ -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()),

View file

@ -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();

View file

@ -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());
}

View file

@ -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())

View file

@ -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": [

View file

@ -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

View file

@ -1,6 +0,0 @@
try {
await Deno.open(Deno.args[0]);
Deno.exit(0);
} catch (_e) {
Deno.exit(1);
}

View file

@ -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");