diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/flags.rs | 6 | ||||
-rw-r--r-- | cli/main.rs | 39 | ||||
-rw-r--r-- | cli/standalone.rs | 2 | ||||
-rw-r--r-- | cli/tests/041_info_flag.out | 1 | ||||
-rw-r--r-- | cli/tests/041_info_flag_location.out | 6 | ||||
-rw-r--r-- | cli/tests/info_json.out | 3 | ||||
-rw-r--r-- | cli/tests/info_json_location.out | 8 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 10 |
8 files changed, 66 insertions, 9 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 3b49d6b59..745aa7013 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -791,6 +791,11 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.", .arg(Arg::with_name("file").takes_value(true).required(false)) .arg(reload_arg().requires("file")) .arg(ca_file_arg()) + .arg( + location_arg() + .conflicts_with("file") + .help("Show files used for origin bound APIs like the Web Storage API when running a script with '--location=<HREF>'") + ) // TODO(lucacasonato): remove for 2.0 .arg(no_check_arg().hidden(true)) .arg(import_map_arg()) @@ -1577,6 +1582,7 @@ fn fmt_parse(flags: &mut Flags, matches: &clap::ArgMatches) { fn info_parse(flags: &mut Flags, matches: &clap::ArgMatches) { reload_arg_parse(flags, matches); import_map_arg_parse(flags, matches); + location_arg_parse(flags, matches); ca_file_arg_parse(flags, matches); let json = matches.is_present("json"); flags.subcommand = DenoSubcommand::Info { diff --git a/cli/main.rs b/cli/main.rs index c44c002b2..47bc52981 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -204,11 +204,12 @@ pub fn create_main_worker( no_color: !colors::use_color(), get_error_class_fn: Some(&crate::errors::get_error_class_name), location: program_state.flags.location.clone(), - location_data_dir: program_state.flags.location.clone().map(|loc| { + origin_storage_dir: program_state.flags.location.clone().map(|loc| { program_state .dir .root .clone() + // TODO(@crowlKats): change to origin_data for 2.0 .join("location_data") .join(checksum::gen(&[loc.to_string().as_bytes()])) }), @@ -267,19 +268,34 @@ where fn print_cache_info( state: &Arc<ProgramState>, json: bool, + location: Option<deno_core::url::Url>, ) -> Result<(), AnyError> { let deno_dir = &state.dir.root; let modules_cache = &state.file_fetcher.get_http_cache_location(); let typescript_cache = &state.dir.gen_cache.location; let registry_cache = &state.dir.root.join(lsp::language_server::REGISTRIES_PATH); + let mut origin_dir = state.dir.root.join("location_data"); + + if let Some(location) = &location { + origin_dir = + origin_dir.join(&checksum::gen(&[location.to_string().as_bytes()])); + } + if json { - let output = json!({ - "denoDir": deno_dir, - "modulesCache": modules_cache, - "typescriptCache": typescript_cache, - "registryCache": registry_cache, + let mut output = json!({ + "denoDir": deno_dir, + "modulesCache": modules_cache, + "typescriptCache": typescript_cache, + "registryCache": registry_cache, + "originStorage": origin_dir, }); + + if location.is_some() { + output["localStorage"] = + serde_json::to_value(origin_dir.join("local_storage"))?; + } + write_json_to_stdout(&output) } else { println!("{} {:?}", colors::bold("DENO_DIR location:"), deno_dir); @@ -298,6 +314,14 @@ fn print_cache_info( colors::bold("Language server registries cache:"), registry_cache, ); + println!("{} {:?}", colors::bold("Origin storage:"), origin_dir); + if location.is_some() { + println!( + "{} {:?}", + colors::bold("Local Storage:"), + origin_dir.join("local_storage"), + ); + } Ok(()) } } @@ -393,6 +417,7 @@ async fn info_command( maybe_specifier: Option<String>, json: bool, ) -> Result<(), AnyError> { + let location = flags.location.clone(); let program_state = ProgramState::build(flags).await?; if let Some(specifier) = maybe_specifier { let specifier = resolve_url_or_path(&specifier)?; @@ -420,7 +445,7 @@ async fn info_command( } } else { // If it was just "deno info" print location of caches and exit - print_cache_info(&program_state, json) + print_cache_info(&program_state, json, location) } } diff --git a/cli/standalone.rs b/cli/standalone.rs index f79adb510..e69ca971b 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -193,7 +193,7 @@ pub async fn run( no_color: !colors::use_color(), get_error_class_fn: Some(&get_error_class_name), location: metadata.location, - location_data_dir: None, + origin_storage_dir: None, blob_url_store, broadcast_channel, }; diff --git a/cli/tests/041_info_flag.out b/cli/tests/041_info_flag.out index 4376c8156..ded795339 100644 --- a/cli/tests/041_info_flag.out +++ b/cli/tests/041_info_flag.out @@ -2,3 +2,4 @@ DENO_DIR location: "[WILDCARD]" Remote modules cache: "[WILDCARD]deps" Emitted modules cache: "[WILDCARD]gen" Language server registries cache: "[WILDCARD]registries" +Origin storage: "[WILDCARD]location_data" diff --git a/cli/tests/041_info_flag_location.out b/cli/tests/041_info_flag_location.out new file mode 100644 index 000000000..207065012 --- /dev/null +++ b/cli/tests/041_info_flag_location.out @@ -0,0 +1,6 @@ +DENO_DIR location: "[WILDCARD]" +Remote modules cache: "[WILDCARD]deps" +Emitted modules cache: "[WILDCARD]gen" +Language server registries cache: "[WILDCARD]registries" +Origin storage: "[WILDCARD]location_data[WILDCARD]" +Local Storage: "[WILDCARD]location_data[WILDCARD]local_storage" diff --git a/cli/tests/info_json.out b/cli/tests/info_json.out index d7be26375..a0d316307 100644 --- a/cli/tests/info_json.out +++ b/cli/tests/info_json.out @@ -2,5 +2,6 @@ "denoDir": "[WILDCARD]", "modulesCache": "[WILDCARD]deps", "typescriptCache": "[WILDCARD]gen", - "registryCache": "[WILDCARD]registries" + "registryCache": "[WILDCARD]registries", + "originStorage": "[WILDCARD]location_data" }
\ No newline at end of file diff --git a/cli/tests/info_json_location.out b/cli/tests/info_json_location.out new file mode 100644 index 000000000..dd9377d3b --- /dev/null +++ b/cli/tests/info_json_location.out @@ -0,0 +1,8 @@ +{ + "denoDir": "[WILDCARD]", + "modulesCache": "[WILDCARD]deps", + "typescriptCache": "[WILDCARD]gen", + "registryCache": "[WILDCARD]registries", + "originStorage": "[WILDCARD]location_data[WILDCARD]", + "localStorage": "[WILDCARD]location_data[WILDCARD]local_storage" +}
\ No newline at end of file diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index dcde0d057..5188c60ba 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2846,11 +2846,21 @@ console.log("finish"); output: "041_info_flag.out", }); + itest!(_042_info_flag_location { + args: "info --location https://deno.land", + output: "041_info_flag_location.out", + }); + itest!(info_json { args: "info --json --unstable", output: "info_json.out", }); + itest!(info_json_location { + args: "info --json --unstable --location https://deno.land", + output: "info_json_location.out", + }); + itest!(_042_dyn_import_evalcontext { args: "run --quiet --allow-read --reload 042_dyn_import_evalcontext.ts", output: "042_dyn_import_evalcontext.ts.out", |