summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/flags.rs6
-rw-r--r--cli/main.rs39
-rw-r--r--cli/standalone.rs2
-rw-r--r--cli/tests/041_info_flag.out1
-rw-r--r--cli/tests/041_info_flag_location.out6
-rw-r--r--cli/tests/info_json.out3
-rw-r--r--cli/tests/info_json_location.out8
-rw-r--r--cli/tests/integration_tests.rs10
-rw-r--r--extensions/webstorage/lib.rs10
-rw-r--r--runtime/examples/hello_runtime.rs2
-rw-r--r--runtime/worker.rs6
11 files changed, 75 insertions, 18 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",
diff --git a/extensions/webstorage/lib.rs b/extensions/webstorage/lib.rs
index 8b3e206fb..d2170890e 100644
--- a/extensions/webstorage/lib.rs
+++ b/extensions/webstorage/lib.rs
@@ -13,9 +13,9 @@ use std::fmt;
use std::path::PathBuf;
#[derive(Clone)]
-struct LocationDataDir(PathBuf);
+struct OriginStorageDir(PathBuf);
-pub fn init(location_data_dir: Option<PathBuf>) -> Extension {
+pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
Extension::builder()
.js(include_js_files!(
prefix "deno:extensions/webstorage",
@@ -34,8 +34,8 @@ pub fn init(location_data_dir: Option<PathBuf>) -> Extension {
),
])
.state(move |state| {
- if let Some(location_data_dir) = location_data_dir.clone() {
- state.put(LocationDataDir(location_data_dir));
+ if let Some(origin_storage_dir) = origin_storage_dir.clone() {
+ state.put(OriginStorageDir(origin_storage_dir));
}
Ok(())
})
@@ -55,7 +55,7 @@ fn get_webstorage(
) -> Result<&Connection, AnyError> {
let conn = if persistent {
if state.try_borrow::<LocalStorage>().is_none() {
- let path = state.try_borrow::<LocationDataDir>().ok_or_else(|| {
+ let path = state.try_borrow::<OriginStorageDir>().ok_or_else(|| {
DomExceptionNotSupportedError::new(
"LocalStorage is not supported in this context.",
)
diff --git a/runtime/examples/hello_runtime.rs b/runtime/examples/hello_runtime.rs
index 34b249e0b..95a82a25f 100644
--- a/runtime/examples/hello_runtime.rs
+++ b/runtime/examples/hello_runtime.rs
@@ -41,7 +41,7 @@ async fn main() -> Result<(), AnyError> {
no_color: false,
get_error_class_fn: Some(&get_error_class_name),
location: None,
- location_data_dir: None,
+ origin_storage_dir: None,
blob_url_store: BlobUrlStore::default(),
broadcast_channel: InMemoryBroadcastChannel::default(),
};
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 57f4b532f..971449859 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -69,7 +69,7 @@ pub struct WorkerOptions {
pub no_color: bool,
pub get_error_class_fn: Option<GetErrorClassFn>,
pub location: Option<Url>,
- pub location_data_dir: Option<std::path::PathBuf>,
+ pub origin_storage_dir: Option<std::path::PathBuf>,
pub blob_url_store: BlobUrlStore,
pub broadcast_channel: InMemoryBroadcastChannel,
}
@@ -106,7 +106,7 @@ impl MainWorker {
options.user_agent.clone(),
options.ca_data.clone(),
),
- deno_webstorage::init(options.location_data_dir.clone()),
+ deno_webstorage::init(options.origin_storage_dir.clone()),
deno_crypto::init(options.seed),
deno_broadcast_channel::init(
options.broadcast_channel.clone(),
@@ -307,7 +307,7 @@ mod tests {
no_color: true,
get_error_class_fn: None,
location: None,
- location_data_dir: None,
+ origin_storage_dir: None,
blob_url_store: BlobUrlStore::default(),
broadcast_channel: InMemoryBroadcastChannel::default(),
};