mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
Merge branch 'main' into repl_restart
This commit is contained in:
commit
d49ba657d5
23 changed files with 93 additions and 63 deletions
|
@ -44,7 +44,7 @@ use std::net::SocketAddr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::deno_dir::DenoDir;
|
use crate::cache::DenoDir;
|
||||||
use crate::file_fetcher::get_root_cert_store;
|
use crate::file_fetcher::get_root_cert_store;
|
||||||
use crate::file_fetcher::CacheSetting;
|
use crate::file_fetcher::CacheSetting;
|
||||||
use crate::fs_util;
|
use crate::fs_util;
|
||||||
|
|
|
@ -351,7 +351,7 @@ fn main() {
|
||||||
panic!("Cross compiling with snapshot is not supported.");
|
panic!("Cross compiling with snapshot is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let symbols_path = std::path::Path::new(
|
let symbols_path = std::path::Path::new("napi").join(
|
||||||
format!("generated_symbol_exports_list_{}.def", env::consts::OS).as_str(),
|
format!("generated_symbol_exports_list_{}.def", env::consts::OS).as_str(),
|
||||||
)
|
)
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
|
|
46
cli/deno_dir.rs → cli/cache/deno_dir.rs
vendored
46
cli/deno_dir.rs → cli/cache/deno_dir.rs
vendored
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::cache::DiskCache;
|
use super::DiskCache;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ use std::path::PathBuf;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DenoDir {
|
pub struct DenoDir {
|
||||||
/// Example: /Users/rld/.deno/
|
/// Example: /Users/rld/.deno/
|
||||||
pub root: PathBuf,
|
/// Note: This is not exposed in order to encourage using re-usable methods.
|
||||||
|
root: PathBuf,
|
||||||
/// Used by TsCompiler to cache compiler output.
|
/// Used by TsCompiler to cache compiler output.
|
||||||
pub gen_cache: DiskCache,
|
pub gen_cache: DiskCache,
|
||||||
}
|
}
|
||||||
|
@ -46,6 +47,11 @@ impl DenoDir {
|
||||||
Ok(deno_dir)
|
Ok(deno_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The root directory of the DENO_DIR for display purposes only.
|
||||||
|
pub fn root_path_for_display(&self) -> std::path::Display {
|
||||||
|
self.root.display()
|
||||||
|
}
|
||||||
|
|
||||||
/// Path for the incremental cache used for formatting.
|
/// Path for the incremental cache used for formatting.
|
||||||
pub fn fmt_incremental_cache_db_file_path(&self) -> PathBuf {
|
pub fn fmt_incremental_cache_db_file_path(&self) -> PathBuf {
|
||||||
// bump this version name to invalidate the entire cache
|
// bump this version name to invalidate the entire cache
|
||||||
|
@ -75,6 +81,42 @@ impl DenoDir {
|
||||||
// bump this version name to invalidate the entire cache
|
// bump this version name to invalidate the entire cache
|
||||||
self.root.join("check_cache_v1")
|
self.root.join("check_cache_v1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Path to the registries cache, used for the lps.
|
||||||
|
pub fn registries_folder_path(&self) -> PathBuf {
|
||||||
|
self.root.join("registries")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Path to the dependencies cache folder.
|
||||||
|
pub fn deps_folder_path(&self) -> PathBuf {
|
||||||
|
self.root.join("deps")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Path to the origin data cache folder.
|
||||||
|
pub fn origin_data_folder_path(&self) -> PathBuf {
|
||||||
|
// TODO(@crowlKats): change to origin_data for 2.0
|
||||||
|
self.root.join("location_data")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// File used for the upgrade checker.
|
||||||
|
pub fn upgrade_check_file_path(&self) -> PathBuf {
|
||||||
|
self.root.join("latest.txt")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Folder used for the npm cache.
|
||||||
|
pub fn npm_folder_path(&self) -> PathBuf {
|
||||||
|
self.root.join("npm")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Path used for the REPL history file.
|
||||||
|
pub fn repl_history_file_path(&self) -> PathBuf {
|
||||||
|
self.root.join("deno_history.txt")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Folder path used for downloading new versions of deno.
|
||||||
|
pub fn dl_folder_path(&self) -> PathBuf {
|
||||||
|
self.root.join("dl")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// To avoid the poorly managed dirs crate
|
/// To avoid the poorly managed dirs crate
|
2
cli/cache/mod.rs
vendored
2
cli/cache/mod.rs
vendored
|
@ -16,6 +16,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
mod check;
|
mod check;
|
||||||
mod common;
|
mod common;
|
||||||
|
mod deno_dir;
|
||||||
mod disk_cache;
|
mod disk_cache;
|
||||||
mod emit;
|
mod emit;
|
||||||
mod incremental;
|
mod incremental;
|
||||||
|
@ -24,6 +25,7 @@ mod parsed_source;
|
||||||
|
|
||||||
pub use check::TypeCheckCache;
|
pub use check::TypeCheckCache;
|
||||||
pub use common::FastInsecureHasher;
|
pub use common::FastInsecureHasher;
|
||||||
|
pub use deno_dir::DenoDir;
|
||||||
pub use disk_cache::DiskCache;
|
pub use disk_cache::DiskCache;
|
||||||
pub use emit::EmitCache;
|
pub use emit::EmitCache;
|
||||||
pub use incremental::IncrementalCache;
|
pub use incremental::IncrementalCache;
|
||||||
|
|
|
@ -63,8 +63,7 @@ use crate::args::Flags;
|
||||||
use crate::args::FmtConfig;
|
use crate::args::FmtConfig;
|
||||||
use crate::args::LintConfig;
|
use crate::args::LintConfig;
|
||||||
use crate::args::TsConfig;
|
use crate::args::TsConfig;
|
||||||
use crate::deno_dir;
|
use crate::cache::DenoDir;
|
||||||
use crate::deno_dir::DenoDir;
|
|
||||||
use crate::file_fetcher::get_root_cert_store;
|
use crate::file_fetcher::get_root_cert_store;
|
||||||
use crate::file_fetcher::get_source_from_data_url;
|
use crate::file_fetcher::get_source_from_data_url;
|
||||||
use crate::file_fetcher::CacheSetting;
|
use crate::file_fetcher::CacheSetting;
|
||||||
|
@ -80,9 +79,6 @@ use crate::progress_bar::ProgressBar;
|
||||||
use crate::tools::fmt::format_file;
|
use crate::tools::fmt::format_file;
|
||||||
use crate::tools::fmt::format_parsed_source;
|
use crate::tools::fmt::format_parsed_source;
|
||||||
|
|
||||||
pub const REGISTRIES_PATH: &str = "registries";
|
|
||||||
const CACHE_PATH: &str = "deps";
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct LanguageServer(Arc<tokio::sync::Mutex<Inner>>);
|
pub struct LanguageServer(Arc<tokio::sync::Mutex<Inner>>);
|
||||||
|
|
||||||
|
@ -267,14 +263,14 @@ fn create_lsp_npm_resolver(
|
||||||
impl Inner {
|
impl Inner {
|
||||||
fn new(client: Client) -> Self {
|
fn new(client: Client) -> Self {
|
||||||
let maybe_custom_root = env::var("DENO_DIR").map(String::into).ok();
|
let maybe_custom_root = env::var("DENO_DIR").map(String::into).ok();
|
||||||
let dir = deno_dir::DenoDir::new(maybe_custom_root)
|
let dir =
|
||||||
.expect("could not access DENO_DIR");
|
DenoDir::new(maybe_custom_root).expect("could not access DENO_DIR");
|
||||||
let module_registries_location = dir.root.join(REGISTRIES_PATH);
|
let module_registries_location = dir.registries_folder_path();
|
||||||
let http_client = HttpClient::new(None, None).unwrap();
|
let http_client = HttpClient::new(None, None).unwrap();
|
||||||
let module_registries =
|
let module_registries =
|
||||||
ModuleRegistry::new(&module_registries_location, http_client.clone())
|
ModuleRegistry::new(&module_registries_location, http_client.clone())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let location = dir.root.join(CACHE_PATH);
|
let location = dir.deps_folder_path();
|
||||||
let documents = Documents::new(&location);
|
let documents = Documents::new(&location);
|
||||||
let cache_metadata = cache::CacheMetadata::new(&location);
|
let cache_metadata = cache::CacheMetadata::new(&location);
|
||||||
let performance = Arc::new(Performance::default());
|
let performance = Arc::new(Performance::default());
|
||||||
|
@ -521,7 +517,7 @@ impl Inner {
|
||||||
let maybe_custom_root = new_cache_path
|
let maybe_custom_root = new_cache_path
|
||||||
.clone()
|
.clone()
|
||||||
.or_else(|| env::var("DENO_DIR").map(String::into).ok());
|
.or_else(|| env::var("DENO_DIR").map(String::into).ok());
|
||||||
let dir = deno_dir::DenoDir::new(maybe_custom_root)?;
|
let dir = DenoDir::new(maybe_custom_root)?;
|
||||||
let workspace_settings = self.config.get_workspace_settings();
|
let workspace_settings = self.config.get_workspace_settings();
|
||||||
let maybe_root_path = self
|
let maybe_root_path = self
|
||||||
.config
|
.config
|
||||||
|
@ -537,13 +533,13 @@ impl Inner {
|
||||||
root_cert_store,
|
root_cert_store,
|
||||||
workspace_settings.unsafely_ignore_certificate_errors,
|
workspace_settings.unsafely_ignore_certificate_errors,
|
||||||
)?;
|
)?;
|
||||||
let module_registries_location = dir.root.join(REGISTRIES_PATH);
|
let module_registries_location = dir.registries_folder_path();
|
||||||
self.module_registries =
|
self.module_registries =
|
||||||
ModuleRegistry::new(&module_registries_location, client.clone())?;
|
ModuleRegistry::new(&module_registries_location, client.clone())?;
|
||||||
self.module_registries_location = module_registries_location;
|
self.module_registries_location = module_registries_location;
|
||||||
self.npm_resolver = create_lsp_npm_resolver(&dir, client);
|
self.npm_resolver = create_lsp_npm_resolver(&dir, client);
|
||||||
// update the cache path
|
// update the cache path
|
||||||
let location = dir.root.join(CACHE_PATH);
|
let location = dir.deps_folder_path();
|
||||||
self.documents.set_location(&location);
|
self.documents.set_location(&location);
|
||||||
self.cache_metadata.set_location(&location);
|
self.cache_metadata.set_location(&location);
|
||||||
self.maybe_cache_path = new_cache_path;
|
self.maybe_cache_path = new_cache_path;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use super::path_to_regex::StringOrNumber;
|
||||||
use super::path_to_regex::StringOrVec;
|
use super::path_to_regex::StringOrVec;
|
||||||
use super::path_to_regex::Token;
|
use super::path_to_regex::Token;
|
||||||
|
|
||||||
use crate::deno_dir;
|
use crate::cache::DenoDir;
|
||||||
use crate::file_fetcher::CacheSetting;
|
use crate::file_fetcher::CacheSetting;
|
||||||
use crate::file_fetcher::FileFetcher;
|
use crate::file_fetcher::FileFetcher;
|
||||||
use crate::http_cache::HttpCache;
|
use crate::http_cache::HttpCache;
|
||||||
|
@ -422,8 +422,8 @@ impl Default for ModuleRegistry {
|
||||||
// This only gets used when creating the tsc runtime and for testing, and so
|
// This only gets used when creating the tsc runtime and for testing, and so
|
||||||
// it shouldn't ever actually access the DenoDir, so it doesn't support a
|
// it shouldn't ever actually access the DenoDir, so it doesn't support a
|
||||||
// custom root.
|
// custom root.
|
||||||
let dir = deno_dir::DenoDir::new(None).unwrap();
|
let dir = DenoDir::new(None).unwrap();
|
||||||
let location = dir.root.join("registries");
|
let location = dir.registries_folder_path();
|
||||||
let http_client = HttpClient::new(None, None).unwrap();
|
let http_client = HttpClient::new(None, None).unwrap();
|
||||||
Self::new(&location, http_client).unwrap()
|
Self::new(&location, http_client).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
mod args;
|
mod args;
|
||||||
mod auth_tokens;
|
mod auth_tokens;
|
||||||
mod cache;
|
mod cache;
|
||||||
mod cdp;
|
|
||||||
mod checksum;
|
mod checksum;
|
||||||
mod deno_dir;
|
|
||||||
mod deno_std;
|
mod deno_std;
|
||||||
mod diff;
|
mod diff;
|
||||||
mod display;
|
mod display;
|
||||||
|
@ -695,7 +693,7 @@ To grant permissions, set them before the script argument. For example:
|
||||||
|
|
||||||
// Run a background task that checks for available upgrades. If an earlier
|
// Run a background task that checks for available upgrades. If an earlier
|
||||||
// run of this background task found a new version of Deno.
|
// run of this background task found a new version of Deno.
|
||||||
tools::upgrade::check_for_upgrades(ps.dir.root.clone());
|
tools::upgrade::check_for_upgrades(ps.dir.upgrade_check_file_path());
|
||||||
|
|
||||||
let main_module = if NpmPackageReference::from_str(&run_flags.script).is_ok()
|
let main_module = if NpmPackageReference::from_str(&run_flags.script).is_ok()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//! To add a new napi function:
|
//! To add a new napi function:
|
||||||
//! 1. Place `#[napi_sym]` on top of your implementation.
|
//! 1. Place `#[napi_sym]` on top of your implementation.
|
||||||
//! 2. Add the function's identifier to this JSON list.
|
//! 2. Add the function's identifier to this JSON list.
|
||||||
//! 3. Finally, run `./tools/napi/generate_symbols_list.js` to update `cli/generated_symbol_exports_list_*.def`.
|
//! 3. Finally, run `tools/napi/generate_symbols_list.js` to update `cli/napi/generated_symbol_exports_list_*.def`.
|
||||||
|
|
||||||
pub mod r#async;
|
pub mod r#async;
|
||||||
pub mod env;
|
pub mod env;
|
||||||
|
|
|
@ -11,7 +11,7 @@ use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
|
|
||||||
use crate::deno_dir::DenoDir;
|
use crate::cache::DenoDir;
|
||||||
use crate::file_fetcher::CacheSetting;
|
use crate::file_fetcher::CacheSetting;
|
||||||
use crate::fs_util;
|
use crate::fs_util;
|
||||||
use crate::http_util::HttpClient;
|
use crate::http_util::HttpClient;
|
||||||
|
@ -146,7 +146,7 @@ impl Default for ReadonlyNpmCache {
|
||||||
// This only gets used when creating the tsc runtime and for testing, and so
|
// This only gets used when creating the tsc runtime and for testing, and so
|
||||||
// it shouldn't ever actually access the DenoDir, so it doesn't support a
|
// it shouldn't ever actually access the DenoDir, so it doesn't support a
|
||||||
// custom root.
|
// custom root.
|
||||||
Self::from_deno_dir(&crate::deno_dir::DenoDir::new(None).unwrap())
|
Self::from_deno_dir(&DenoDir::new(None).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ impl ReadonlyNpmCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_deno_dir(dir: &DenoDir) -> Self {
|
pub fn from_deno_dir(dir: &DenoDir) -> Self {
|
||||||
Self::new(dir.root.join("npm"))
|
Self::new(dir.npm_folder_path())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn package_folder_for_id(
|
pub fn package_folder_for_id(
|
||||||
|
@ -510,7 +510,8 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_get_package_folder() {
|
fn should_get_package_folder() {
|
||||||
let root_dir = crate::deno_dir::DenoDir::new(None).unwrap().root;
|
let deno_dir = crate::cache::DenoDir::new(None).unwrap();
|
||||||
|
let root_dir = deno_dir.npm_folder_path();
|
||||||
let cache = ReadonlyNpmCache::new(root_dir.clone());
|
let cache = ReadonlyNpmCache::new(root_dir.clone());
|
||||||
let registry_url = Url::parse("https://registry.npmjs.org/").unwrap();
|
let registry_url = Url::parse("https://registry.npmjs.org/").unwrap();
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ use crate::args::TsConfigType;
|
||||||
use crate::args::TsTypeLib;
|
use crate::args::TsTypeLib;
|
||||||
use crate::args::TypeCheckMode;
|
use crate::args::TypeCheckMode;
|
||||||
use crate::cache;
|
use crate::cache;
|
||||||
|
use crate::cache::DenoDir;
|
||||||
use crate::cache::EmitCache;
|
use crate::cache::EmitCache;
|
||||||
use crate::cache::FastInsecureHasher;
|
use crate::cache::FastInsecureHasher;
|
||||||
use crate::cache::NodeAnalysisCache;
|
use crate::cache::NodeAnalysisCache;
|
||||||
use crate::cache::ParsedSourceCache;
|
use crate::cache::ParsedSourceCache;
|
||||||
use crate::cache::TypeCheckCache;
|
use crate::cache::TypeCheckCache;
|
||||||
use crate::deno_dir;
|
|
||||||
use crate::emit::emit_parsed_source;
|
use crate::emit::emit_parsed_source;
|
||||||
use crate::file_fetcher::FileFetcher;
|
use crate::file_fetcher::FileFetcher;
|
||||||
use crate::graph_util::graph_lock_or_exit;
|
use crate::graph_util::graph_lock_or_exit;
|
||||||
|
@ -73,7 +73,7 @@ use std::sync::Arc;
|
||||||
pub struct ProcState(Arc<Inner>);
|
pub struct ProcState(Arc<Inner>);
|
||||||
|
|
||||||
pub struct Inner {
|
pub struct Inner {
|
||||||
pub dir: deno_dir::DenoDir,
|
pub dir: DenoDir,
|
||||||
pub file_fetcher: FileFetcher,
|
pub file_fetcher: FileFetcher,
|
||||||
pub options: Arc<CliOptions>,
|
pub options: Arc<CliOptions>,
|
||||||
pub emit_cache: EmitCache,
|
pub emit_cache: EmitCache,
|
||||||
|
@ -152,7 +152,7 @@ impl ProcState {
|
||||||
let shared_array_buffer_store = SharedArrayBufferStore::default();
|
let shared_array_buffer_store = SharedArrayBufferStore::default();
|
||||||
let compiled_wasm_module_store = CompiledWasmModuleStore::default();
|
let compiled_wasm_module_store = CompiledWasmModuleStore::default();
|
||||||
let dir = cli_options.resolve_deno_dir()?;
|
let dir = cli_options.resolve_deno_dir()?;
|
||||||
let deps_cache_location = dir.root.join("deps");
|
let deps_cache_location = dir.deps_folder_path();
|
||||||
let http_cache = http_cache::HttpCache::new(&deps_cache_location);
|
let http_cache = http_cache::HttpCache::new(&deps_cache_location);
|
||||||
let root_cert_store = cli_options.resolve_root_cert_store()?;
|
let root_cert_store = cli_options.resolve_root_cert_store()?;
|
||||||
let cache_usage = cli_options.cache_setting();
|
let cache_usage = cli_options.cache_setting();
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use encoding_rs::*;
|
use encoding_rs::*;
|
||||||
use std::{
|
use std::borrow::Cow;
|
||||||
borrow::Cow,
|
use std::io::Error;
|
||||||
io::{Error, ErrorKind},
|
use std::io::ErrorKind;
|
||||||
};
|
|
||||||
|
|
||||||
pub const BOM_CHAR: char = '\u{FEFF}';
|
pub const BOM_CHAR: char = '\u{FEFF}';
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ use crate::args::Flags;
|
||||||
use crate::args::InfoFlags;
|
use crate::args::InfoFlags;
|
||||||
use crate::checksum;
|
use crate::checksum;
|
||||||
use crate::display;
|
use crate::display;
|
||||||
use crate::lsp;
|
|
||||||
use crate::npm::NpmPackageId;
|
use crate::npm::NpmPackageId;
|
||||||
use crate::npm::NpmPackageReference;
|
use crate::npm::NpmPackageReference;
|
||||||
use crate::npm::NpmPackageReq;
|
use crate::npm::NpmPackageReq;
|
||||||
|
@ -58,13 +57,12 @@ fn print_cache_info(
|
||||||
json: bool,
|
json: bool,
|
||||||
location: Option<&deno_core::url::Url>,
|
location: Option<&deno_core::url::Url>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let deno_dir = &state.dir.root;
|
let deno_dir = &state.dir.root_path_for_display();
|
||||||
let modules_cache = &state.file_fetcher.get_http_cache_location();
|
let modules_cache = &state.file_fetcher.get_http_cache_location();
|
||||||
let npm_cache = &state.npm_cache.as_readonly().get_cache_location();
|
let npm_cache = &state.npm_cache.as_readonly().get_cache_location();
|
||||||
let typescript_cache = &state.dir.gen_cache.location;
|
let typescript_cache = &state.dir.gen_cache.location;
|
||||||
let registry_cache =
|
let registry_cache = &state.dir.registries_folder_path();
|
||||||
&state.dir.root.join(lsp::language_server::REGISTRIES_PATH);
|
let mut origin_dir = state.dir.origin_data_folder_path();
|
||||||
let mut origin_dir = state.dir.root.join("location_data");
|
|
||||||
|
|
||||||
if let Some(location) = &location {
|
if let Some(location) = &location {
|
||||||
origin_dir =
|
origin_dir =
|
||||||
|
@ -75,7 +73,7 @@ fn print_cache_info(
|
||||||
|
|
||||||
if json {
|
if json {
|
||||||
let mut output = json!({
|
let mut output = json!({
|
||||||
"denoDir": deno_dir,
|
"denoDir": deno_dir.to_string(),
|
||||||
"modulesCache": modules_cache,
|
"modulesCache": modules_cache,
|
||||||
"npmCache": npm_cache,
|
"npmCache": npm_cache,
|
||||||
"typescriptCache": typescript_cache,
|
"typescriptCache": typescript_cache,
|
||||||
|
@ -89,11 +87,7 @@ fn print_cache_info(
|
||||||
|
|
||||||
display::write_json_to_stdout(&output)
|
display::write_json_to_stdout(&output)
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!("{} {}", colors::bold("DENO_DIR location:"), deno_dir);
|
||||||
"{} {}",
|
|
||||||
colors::bold("DENO_DIR location:"),
|
|
||||||
deno_dir.display()
|
|
||||||
);
|
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
colors::bold("Remote modules cache:"),
|
colors::bold("Remote modules cache:"),
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::cdp;
|
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use deno_ast::swc::parser::error::SyntaxError;
|
use deno_ast::swc::parser::error::SyntaxError;
|
||||||
use deno_ast::swc::parser::token::Token;
|
use deno_ast::swc::parser::token::Token;
|
||||||
|
@ -32,6 +31,7 @@ use std::sync::atomic::AtomicBool;
|
||||||
use std::sync::atomic::Ordering::Relaxed;
|
use std::sync::atomic::Ordering::Relaxed;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use super::cdp;
|
||||||
use super::channel::RustylineSyncMessageSender;
|
use super::channel::RustylineSyncMessageSender;
|
||||||
|
|
||||||
// Provides helpers to the editor like validation for multi-line edits, completion candidates for
|
// Provides helpers to the editor like validation for multi-line edits, completion candidates for
|
||||||
|
|
|
@ -11,6 +11,7 @@ use deno_core::OpState;
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
|
|
||||||
|
mod cdp;
|
||||||
mod channel;
|
mod channel;
|
||||||
mod editor;
|
mod editor;
|
||||||
mod session;
|
mod session;
|
||||||
|
@ -196,7 +197,7 @@ pub async fn run(
|
||||||
sync_sender: rustyline_channel.0,
|
sync_sender: rustyline_channel.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let history_file_path = ps.dir.root.join("deno_history.txt");
|
let history_file_path = ps.dir.repl_history_file_path();
|
||||||
let editor = ReplEditor::new(helper, history_file_path)?;
|
let editor = ReplEditor::new(helper, history_file_path)?;
|
||||||
|
|
||||||
println!("Deno {}", crate::version::deno());
|
println!("Deno {}", crate::version::deno());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::cdp;
|
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::lsp::ReplLanguageServer;
|
use crate::lsp::ReplLanguageServer;
|
||||||
use deno_ast::DiagnosticsError;
|
use deno_ast::DiagnosticsError;
|
||||||
|
@ -12,6 +11,8 @@ use deno_core::serde_json::Value;
|
||||||
use deno_core::LocalInspectorSession;
|
use deno_core::LocalInspectorSession;
|
||||||
use deno_runtime::worker::MainWorker;
|
use deno_runtime::worker::MainWorker;
|
||||||
|
|
||||||
|
use super::cdp;
|
||||||
|
|
||||||
static PRELUDE: &str = r#"
|
static PRELUDE: &str = r#"
|
||||||
Object.defineProperty(globalThis, "_", {
|
Object.defineProperty(globalThis, "_", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::args::DenoSubcommand;
|
||||||
use crate::args::Flags;
|
use crate::args::Flags;
|
||||||
use crate::args::RunFlags;
|
use crate::args::RunFlags;
|
||||||
use crate::args::TypeCheckMode;
|
use crate::args::TypeCheckMode;
|
||||||
use crate::deno_dir::DenoDir;
|
use crate::cache::DenoDir;
|
||||||
use crate::fs_util;
|
use crate::fs_util;
|
||||||
use crate::standalone::Metadata;
|
use crate::standalone::Metadata;
|
||||||
use crate::standalone::MAGIC_TRAILER;
|
use crate::standalone::MAGIC_TRAILER;
|
||||||
|
@ -50,7 +50,7 @@ pub async fn get_base_binary(
|
||||||
format!("release/v{}/{}", env!("CARGO_PKG_VERSION"), binary_name)
|
format!("release/v{}/{}", env!("CARGO_PKG_VERSION"), binary_name)
|
||||||
};
|
};
|
||||||
|
|
||||||
let download_directory = deno_dir.root.join("dl");
|
let download_directory = deno_dir.dl_folder_path();
|
||||||
let binary_path = download_directory.join(&binary_path_suffix);
|
let binary_path = download_directory.join(&binary_path_suffix);
|
||||||
|
|
||||||
if !binary_path.exists() {
|
if !binary_path.exists() {
|
||||||
|
|
|
@ -31,7 +31,6 @@ const RELEASE_URL: &str = "https://github.com/denoland/deno/releases";
|
||||||
|
|
||||||
// How often query server for new version. In hours.
|
// How often query server for new version. In hours.
|
||||||
const UPGRADE_CHECK_INTERVAL: i64 = 24;
|
const UPGRADE_CHECK_INTERVAL: i64 = 24;
|
||||||
const UPGRADE_CHECK_FILE_NAME: &str = "latest.txt";
|
|
||||||
|
|
||||||
const UPGRADE_CHECK_FETCH_DELAY: Duration = Duration::from_millis(500);
|
const UPGRADE_CHECK_FETCH_DELAY: Duration = Duration::from_millis(500);
|
||||||
|
|
||||||
|
@ -47,14 +46,14 @@ trait UpdateCheckerEnvironment: Clone + Send + Sync {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct RealUpdateCheckerEnvironment {
|
struct RealUpdateCheckerEnvironment {
|
||||||
cache_dir: PathBuf,
|
cache_file_path: PathBuf,
|
||||||
current_time: chrono::DateTime<chrono::Utc>,
|
current_time: chrono::DateTime<chrono::Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RealUpdateCheckerEnvironment {
|
impl RealUpdateCheckerEnvironment {
|
||||||
pub fn new(cache_dir: PathBuf) -> Self {
|
pub fn new(cache_file_path: PathBuf) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cache_dir,
|
cache_file_path,
|
||||||
// cache the current time
|
// cache the current time
|
||||||
current_time: chrono::Utc::now(),
|
current_time: chrono::Utc::now(),
|
||||||
}
|
}
|
||||||
|
@ -79,12 +78,11 @@ impl UpdateCheckerEnvironment for RealUpdateCheckerEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_check_file(&self) -> String {
|
fn read_check_file(&self) -> String {
|
||||||
std::fs::read_to_string(self.cache_dir.join(UPGRADE_CHECK_FILE_NAME))
|
std::fs::read_to_string(&self.cache_file_path).unwrap_or_default()
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_check_file(&self, text: &str) {
|
fn write_check_file(&self, text: &str) {
|
||||||
let _ = std::fs::write(self.cache_dir.join(UPGRADE_CHECK_FILE_NAME), text);
|
let _ = std::fs::write(&self.cache_file_path, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_time(&self) -> chrono::DateTime<chrono::Utc> {
|
fn current_time(&self) -> chrono::DateTime<chrono::Utc> {
|
||||||
|
@ -160,12 +158,12 @@ impl<TEnvironment: UpdateCheckerEnvironment> UpdateChecker<TEnvironment> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_for_upgrades(cache_dir: PathBuf) {
|
pub fn check_for_upgrades(cache_file_path: PathBuf) {
|
||||||
if env::var("DENO_NO_UPDATE_CHECK").is_ok() {
|
if env::var("DENO_NO_UPDATE_CHECK").is_ok() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let env = RealUpdateCheckerEnvironment::new(cache_dir);
|
let env = RealUpdateCheckerEnvironment::new(cache_file_path);
|
||||||
let update_checker = UpdateChecker::new(env);
|
let update_checker = UpdateChecker::new(env);
|
||||||
|
|
||||||
if update_checker.should_check_for_new_version() {
|
if update_checker.should_check_for_new_version() {
|
||||||
|
|
|
@ -500,9 +500,7 @@ async fn create_main_worker_internal(
|
||||||
let maybe_storage_key = ps.options.resolve_storage_key(&main_module);
|
let maybe_storage_key = ps.options.resolve_storage_key(&main_module);
|
||||||
let origin_storage_dir = maybe_storage_key.as_ref().map(|key| {
|
let origin_storage_dir = maybe_storage_key.as_ref().map(|key| {
|
||||||
ps.dir
|
ps.dir
|
||||||
.root
|
.origin_data_folder_path()
|
||||||
// TODO(@crowlKats): change to origin_data for 2.0
|
|
||||||
.join("location_data")
|
|
||||||
.join(checksum::gen(&[key.as_bytes()]))
|
.join(checksum::gen(&[key.as_bytes()]))
|
||||||
});
|
});
|
||||||
let cache_storage_dir = maybe_storage_key.map(|key| {
|
let cache_storage_dir = maybe_storage_key.map(|key| {
|
||||||
|
|
|
@ -17,7 +17,7 @@ const symbolExportLists = {
|
||||||
|
|
||||||
for await (const [os, def] of Object.entries(symbolExportLists)) {
|
for await (const [os, def] of Object.entries(symbolExportLists)) {
|
||||||
const defUrl = new URL(
|
const defUrl = new URL(
|
||||||
`../../cli/generated_symbol_exports_list_${os}.def`,
|
`../../cli/napi/generated_symbol_exports_list_${os}.def`,
|
||||||
import.meta.url,
|
import.meta.url,
|
||||||
);
|
);
|
||||||
await Deno.writeTextFile(defUrl.pathname, def, { create: true });
|
await Deno.writeTextFile(defUrl.pathname, def, { create: true });
|
||||||
|
|
Loading…
Reference in a new issue