mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor: make version and user_agent &'static str (#18400)
These caused a bunch of unnecessary allocations on each startup.
This commit is contained in:
parent
edab8f2fd4
commit
275dee60e7
14 changed files with 91 additions and 79 deletions
|
@ -641,7 +641,7 @@ To evaluate code in the shell:
|
||||||
/// Main entry point for parsing deno's command line flags.
|
/// Main entry point for parsing deno's command line flags.
|
||||||
pub fn flags_from_vec(args: Vec<String>) -> clap::Result<Flags> {
|
pub fn flags_from_vec(args: Vec<String>) -> clap::Result<Flags> {
|
||||||
let version = crate::version::deno();
|
let version = crate::version::deno();
|
||||||
let mut app = clap_root(&version);
|
let mut app = clap_root(version);
|
||||||
let matches = app.try_get_matches_from_mut(&args)?;
|
let matches = app.try_get_matches_from_mut(&args)?;
|
||||||
|
|
||||||
let mut flags = Flags::default();
|
let mut flags = Flags::default();
|
||||||
|
@ -712,7 +712,7 @@ fn handle_repl_flags(flags: &mut Flags, repl_flags: ReplFlags) {
|
||||||
flags.subcommand = DenoSubcommand::Repl(repl_flags);
|
flags.subcommand = DenoSubcommand::Repl(repl_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clap_root(version: &str) -> Command {
|
fn clap_root(version: &'static str) -> Command {
|
||||||
clap::Command::new("deno")
|
clap::Command::new("deno")
|
||||||
.bin_name("deno")
|
.bin_name("deno")
|
||||||
.color(ColorChoice::Never)
|
.color(ColorChoice::Never)
|
||||||
|
|
|
@ -459,6 +459,10 @@ fn main() {
|
||||||
|
|
||||||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash());
|
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash());
|
||||||
println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH");
|
println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH");
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=GIT_COMMIT_HASH_SHORT={}",
|
||||||
|
&git_commit_hash()[..7]
|
||||||
|
);
|
||||||
|
|
||||||
let ts_version = ts::version();
|
let ts_version = ts::version();
|
||||||
debug_assert_eq!(ts_version, "5.0.2"); // bump this assertion when it changes
|
debug_assert_eq!(ts_version, "5.0.2"); // bump this assertion when it changes
|
||||||
|
|
20
cli/cache/check.rs
vendored
20
cli/cache/check.rs
vendored
|
@ -58,7 +58,7 @@ impl TypeCheckCache {
|
||||||
|
|
||||||
fn from_connection(
|
fn from_connection(
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
cli_version: String,
|
cli_version: &'static str,
|
||||||
) -> Result<Self, AnyError> {
|
) -> Result<Self, AnyError> {
|
||||||
initialize(&conn, cli_version)?;
|
initialize(&conn, cli_version)?;
|
||||||
|
|
||||||
|
@ -157,7 +157,10 @@ impl TypeCheckCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> {
|
fn initialize(
|
||||||
|
conn: &Connection,
|
||||||
|
cli_version: &'static str,
|
||||||
|
) -> Result<(), AnyError> {
|
||||||
// INT doesn't store up to u64, so use TEXT for check_hash
|
// INT doesn't store up to u64, so use TEXT for check_hash
|
||||||
let query = format!(
|
let query = format!(
|
||||||
"{INITIAL_PRAGMAS}
|
"{INITIAL_PRAGMAS}
|
||||||
|
@ -184,12 +187,12 @@ fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> {
|
||||||
|row| row.get(0),
|
|row| row.get(0),
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
if data_cli_version.as_deref() != Some(&cli_version) {
|
if data_cli_version.as_deref() != Some(cli_version) {
|
||||||
conn.execute("DELETE FROM checkcache", params![])?;
|
conn.execute("DELETE FROM checkcache", params![])?;
|
||||||
conn.execute("DELETE FROM tsbuildinfo", params![])?;
|
conn.execute("DELETE FROM tsbuildinfo", params![])?;
|
||||||
let mut stmt = conn
|
let mut stmt = conn
|
||||||
.prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;
|
.prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;
|
||||||
stmt.execute(params!["CLI_VERSION", &cli_version])?;
|
stmt.execute(params!["CLI_VERSION", cli_version])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -202,8 +205,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn check_cache_general_use() {
|
pub fn check_cache_general_use() {
|
||||||
let conn = Connection::open_in_memory().unwrap();
|
let conn = Connection::open_in_memory().unwrap();
|
||||||
let cache =
|
let cache = TypeCheckCache::from_connection(conn, "1.0.0").unwrap();
|
||||||
TypeCheckCache::from_connection(conn, "1.0.0".to_string()).unwrap();
|
|
||||||
|
|
||||||
assert!(!cache.has_check_hash(1));
|
assert!(!cache.has_check_hash(1));
|
||||||
cache.add_check_hash(1);
|
cache.add_check_hash(1);
|
||||||
|
@ -217,8 +219,7 @@ mod test {
|
||||||
|
|
||||||
// try changing the cli version (should clear)
|
// try changing the cli version (should clear)
|
||||||
let conn = cache.0.unwrap();
|
let conn = cache.0.unwrap();
|
||||||
let cache =
|
let cache = TypeCheckCache::from_connection(conn, "2.0.0").unwrap();
|
||||||
TypeCheckCache::from_connection(conn, "2.0.0".to_string()).unwrap();
|
|
||||||
assert!(!cache.has_check_hash(1));
|
assert!(!cache.has_check_hash(1));
|
||||||
cache.add_check_hash(1);
|
cache.add_check_hash(1);
|
||||||
assert!(cache.has_check_hash(1));
|
assert!(cache.has_check_hash(1));
|
||||||
|
@ -228,8 +229,7 @@ mod test {
|
||||||
|
|
||||||
// recreating the cache should not remove the data because the CLI version is the same
|
// recreating the cache should not remove the data because the CLI version is the same
|
||||||
let conn = cache.0.unwrap();
|
let conn = cache.0.unwrap();
|
||||||
let cache =
|
let cache = TypeCheckCache::from_connection(conn, "2.0.0").unwrap();
|
||||||
TypeCheckCache::from_connection(conn, "2.0.0".to_string()).unwrap();
|
|
||||||
assert!(cache.has_check_hash(1));
|
assert!(cache.has_check_hash(1));
|
||||||
assert!(!cache.has_check_hash(2));
|
assert!(!cache.has_check_hash(2));
|
||||||
assert_eq!(cache.get_tsbuildinfo(&specifier1), Some("test".to_string()));
|
assert_eq!(cache.get_tsbuildinfo(&specifier1), Some("test".to_string()));
|
||||||
|
|
12
cli/cache/emit.rs
vendored
12
cli/cache/emit.rs
vendored
|
@ -22,7 +22,7 @@ struct EmitMetadata {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EmitCache {
|
pub struct EmitCache {
|
||||||
disk_cache: DiskCache,
|
disk_cache: DiskCache,
|
||||||
cli_version: String,
|
cli_version: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmitCache {
|
impl EmitCache {
|
||||||
|
@ -58,7 +58,7 @@ impl EmitCache {
|
||||||
|
|
||||||
// load and verify the emit is for the meta data
|
// load and verify the emit is for the meta data
|
||||||
let emit_bytes = self.disk_cache.get(&emit_filename).ok()?;
|
let emit_bytes = self.disk_cache.get(&emit_filename).ok()?;
|
||||||
if meta.emit_hash != compute_emit_hash(&emit_bytes, &self.cli_version) {
|
if meta.emit_hash != compute_emit_hash(&emit_bytes, self.cli_version) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ impl EmitCache {
|
||||||
// save the metadata
|
// save the metadata
|
||||||
let metadata = EmitMetadata {
|
let metadata = EmitMetadata {
|
||||||
source_hash: source_hash.to_string(),
|
source_hash: source_hash.to_string(),
|
||||||
emit_hash: compute_emit_hash(code.as_bytes(), &self.cli_version),
|
emit_hash: compute_emit_hash(code.as_bytes(), self.cli_version),
|
||||||
};
|
};
|
||||||
self
|
self
|
||||||
.disk_cache
|
.disk_cache
|
||||||
|
@ -162,7 +162,7 @@ mod test {
|
||||||
let disk_cache = DiskCache::new(temp_dir.path());
|
let disk_cache = DiskCache::new(temp_dir.path());
|
||||||
let cache = EmitCache {
|
let cache = EmitCache {
|
||||||
disk_cache: disk_cache.clone(),
|
disk_cache: disk_cache.clone(),
|
||||||
cli_version: "1.0.0".to_string(),
|
cli_version: "1.0.0",
|
||||||
};
|
};
|
||||||
|
|
||||||
let specifier1 =
|
let specifier1 =
|
||||||
|
@ -188,7 +188,7 @@ mod test {
|
||||||
// try changing the cli version (should not load previous ones)
|
// try changing the cli version (should not load previous ones)
|
||||||
let cache = EmitCache {
|
let cache = EmitCache {
|
||||||
disk_cache: disk_cache.clone(),
|
disk_cache: disk_cache.clone(),
|
||||||
cli_version: "2.0.0".to_string(),
|
cli_version: "2.0.0",
|
||||||
};
|
};
|
||||||
assert_eq!(cache.get_emit_code(&specifier1, 10), None);
|
assert_eq!(cache.get_emit_code(&specifier1, 10), None);
|
||||||
cache.set_emit_code(&specifier1, 5, &emit_code1);
|
cache.set_emit_code(&specifier1, 5, &emit_code1);
|
||||||
|
@ -196,7 +196,7 @@ mod test {
|
||||||
// recreating the cache should still load the data because the CLI version is the same
|
// recreating the cache should still load the data because the CLI version is the same
|
||||||
let cache = EmitCache {
|
let cache = EmitCache {
|
||||||
disk_cache,
|
disk_cache,
|
||||||
cli_version: "2.0.0".to_string(),
|
cli_version: "2.0.0",
|
||||||
};
|
};
|
||||||
assert_eq!(cache.get_emit_code(&specifier1, 5), Some(emit_code1));
|
assert_eq!(cache.get_emit_code(&specifier1, 5), Some(emit_code1));
|
||||||
|
|
||||||
|
|
25
cli/cache/incremental.rs
vendored
25
cli/cache/incremental.rs
vendored
|
@ -172,7 +172,7 @@ impl SqlIncrementalCache {
|
||||||
fn from_connection(
|
fn from_connection(
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
state_hash: u64,
|
state_hash: u64,
|
||||||
cli_version: String,
|
cli_version: &'static str,
|
||||||
) -> Result<Self, AnyError> {
|
) -> Result<Self, AnyError> {
|
||||||
initialize(&conn, cli_version)?;
|
initialize(&conn, cli_version)?;
|
||||||
|
|
||||||
|
@ -237,7 +237,10 @@ impl SqlIncrementalCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> {
|
fn initialize(
|
||||||
|
conn: &Connection,
|
||||||
|
cli_version: &'static str,
|
||||||
|
) -> Result<(), AnyError> {
|
||||||
// INT doesn't store up to u64, so use TEXT for source_hash
|
// INT doesn't store up to u64, so use TEXT for source_hash
|
||||||
let query = format!(
|
let query = format!(
|
||||||
"{INITIAL_PRAGMAS}
|
"{INITIAL_PRAGMAS}
|
||||||
|
@ -261,11 +264,11 @@ fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> {
|
||||||
|row| row.get(0),
|
|row| row.get(0),
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
if data_cli_version.as_deref() != Some(&cli_version) {
|
if data_cli_version.as_deref() != Some(cli_version) {
|
||||||
conn.execute("DELETE FROM incrementalcache", params![])?;
|
conn.execute("DELETE FROM incrementalcache", params![])?;
|
||||||
let mut stmt = conn
|
let mut stmt = conn
|
||||||
.prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;
|
.prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;
|
||||||
stmt.execute(params!["CLI_VERSION", &cli_version])?;
|
stmt.execute(params!["CLI_VERSION", cli_version])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -280,9 +283,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn sql_cache_general_use() {
|
pub fn sql_cache_general_use() {
|
||||||
let conn = Connection::open_in_memory().unwrap();
|
let conn = Connection::open_in_memory().unwrap();
|
||||||
let cache =
|
let cache = SqlIncrementalCache::from_connection(conn, 1, "1.0.0").unwrap();
|
||||||
SqlIncrementalCache::from_connection(conn, 1, "1.0.0".to_string())
|
|
||||||
.unwrap();
|
|
||||||
let path = PathBuf::from("/mod.ts");
|
let path = PathBuf::from("/mod.ts");
|
||||||
|
|
||||||
assert_eq!(cache.get_source_hash(&path), None);
|
assert_eq!(cache.get_source_hash(&path), None);
|
||||||
|
@ -292,8 +293,7 @@ mod test {
|
||||||
// try changing the cli version (should clear)
|
// try changing the cli version (should clear)
|
||||||
let conn = cache.conn;
|
let conn = cache.conn;
|
||||||
let mut cache =
|
let mut cache =
|
||||||
SqlIncrementalCache::from_connection(conn, 1, "2.0.0".to_string())
|
SqlIncrementalCache::from_connection(conn, 1, "2.0.0").unwrap();
|
||||||
.unwrap();
|
|
||||||
assert_eq!(cache.get_source_hash(&path), None);
|
assert_eq!(cache.get_source_hash(&path), None);
|
||||||
|
|
||||||
// add back the file to the cache
|
// add back the file to the cache
|
||||||
|
@ -310,9 +310,7 @@ mod test {
|
||||||
|
|
||||||
// recreating the cache should not remove the data because the CLI version and state hash is the same
|
// recreating the cache should not remove the data because the CLI version and state hash is the same
|
||||||
let conn = cache.conn;
|
let conn = cache.conn;
|
||||||
let cache =
|
let cache = SqlIncrementalCache::from_connection(conn, 1, "2.0.0").unwrap();
|
||||||
SqlIncrementalCache::from_connection(conn, 1, "2.0.0".to_string())
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(cache.get_source_hash(&path), Some(2));
|
assert_eq!(cache.get_source_hash(&path), Some(2));
|
||||||
|
|
||||||
// now try replacing and using another path
|
// now try replacing and using another path
|
||||||
|
@ -328,8 +326,7 @@ mod test {
|
||||||
pub async fn incremental_cache_general_use() {
|
pub async fn incremental_cache_general_use() {
|
||||||
let conn = Connection::open_in_memory().unwrap();
|
let conn = Connection::open_in_memory().unwrap();
|
||||||
let sql_cache =
|
let sql_cache =
|
||||||
SqlIncrementalCache::from_connection(conn, 1, "1.0.0".to_string())
|
SqlIncrementalCache::from_connection(conn, 1, "1.0.0").unwrap();
|
||||||
.unwrap();
|
|
||||||
let file_path = PathBuf::from("/mod.ts");
|
let file_path = PathBuf::from("/mod.ts");
|
||||||
let file_text = "test";
|
let file_text = "test";
|
||||||
let file_hash = FastInsecureHasher::new().write_str(file_text).finish();
|
let file_hash = FastInsecureHasher::new().write_str(file_text).finish();
|
||||||
|
|
2
cli/cache/node.rs
vendored
2
cli/cache/node.rs
vendored
|
@ -102,7 +102,7 @@ impl NodeAnalysisCache {
|
||||||
None => {
|
None => {
|
||||||
let maybe_inner = match NodeAnalysisCacheInner::new(
|
let maybe_inner = match NodeAnalysisCacheInner::new(
|
||||||
self.db_file_path.as_deref(),
|
self.db_file_path.as_deref(),
|
||||||
crate::version::deno(),
|
crate::version::deno().to_string(),
|
||||||
) {
|
) {
|
||||||
Ok(cache) => Some(cache),
|
Ok(cache) => Some(cache),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
23
cli/cache/parsed_source.rs
vendored
23
cli/cache/parsed_source.rs
vendored
|
@ -54,7 +54,7 @@ impl deno_graph::ParsedSourceStore for ParsedSourceCacheSources {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ParsedSourceCache {
|
pub struct ParsedSourceCache {
|
||||||
db_cache_path: Option<PathBuf>,
|
db_cache_path: Option<PathBuf>,
|
||||||
cli_version: String,
|
cli_version: &'static str,
|
||||||
sources: ParsedSourceCacheSources,
|
sources: ParsedSourceCacheSources,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ impl ParsedSourceCache {
|
||||||
pub fn reset_for_file_watcher(&self) -> Self {
|
pub fn reset_for_file_watcher(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
db_cache_path: self.db_cache_path.clone(),
|
db_cache_path: self.db_cache_path.clone(),
|
||||||
cli_version: self.cli_version.clone(),
|
cli_version: self.cli_version,
|
||||||
sources: Default::default(),
|
sources: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ impl ParsedSourceCache {
|
||||||
pub fn as_analyzer(&self) -> Box<dyn deno_graph::ModuleAnalyzer> {
|
pub fn as_analyzer(&self) -> Box<dyn deno_graph::ModuleAnalyzer> {
|
||||||
match ParsedSourceCacheModuleAnalyzer::new(
|
match ParsedSourceCacheModuleAnalyzer::new(
|
||||||
self.db_cache_path.as_deref(),
|
self.db_cache_path.as_deref(),
|
||||||
self.cli_version.clone(),
|
self.cli_version,
|
||||||
self.sources.clone(),
|
self.sources.clone(),
|
||||||
) {
|
) {
|
||||||
Ok(analyzer) => Box::new(analyzer),
|
Ok(analyzer) => Box::new(analyzer),
|
||||||
|
@ -146,7 +146,7 @@ struct ParsedSourceCacheModuleAnalyzer {
|
||||||
impl ParsedSourceCacheModuleAnalyzer {
|
impl ParsedSourceCacheModuleAnalyzer {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
db_file_path: Option<&Path>,
|
db_file_path: Option<&Path>,
|
||||||
cli_version: String,
|
cli_version: &'static str,
|
||||||
sources: ParsedSourceCacheSources,
|
sources: ParsedSourceCacheSources,
|
||||||
) -> Result<Self, AnyError> {
|
) -> Result<Self, AnyError> {
|
||||||
log::debug!("Loading cached module analyzer.");
|
log::debug!("Loading cached module analyzer.");
|
||||||
|
@ -159,7 +159,7 @@ impl ParsedSourceCacheModuleAnalyzer {
|
||||||
|
|
||||||
fn from_connection(
|
fn from_connection(
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
cli_version: String,
|
cli_version: &'static str,
|
||||||
sources: ParsedSourceCacheSources,
|
sources: ParsedSourceCacheSources,
|
||||||
) -> Result<Self, AnyError> {
|
) -> Result<Self, AnyError> {
|
||||||
initialize(&conn, cli_version)?;
|
initialize(&conn, cli_version)?;
|
||||||
|
@ -287,7 +287,10 @@ impl deno_graph::ModuleAnalyzer for ParsedSourceCacheModuleAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> {
|
fn initialize(
|
||||||
|
conn: &Connection,
|
||||||
|
cli_version: &'static str,
|
||||||
|
) -> Result<(), AnyError> {
|
||||||
let query = format!(
|
let query = format!(
|
||||||
"{INITIAL_PRAGMAS}
|
"{INITIAL_PRAGMAS}
|
||||||
-- INT doesn't store up to u64, so use TEXT for source_hash
|
-- INT doesn't store up to u64, so use TEXT for source_hash
|
||||||
|
@ -314,7 +317,7 @@ fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> {
|
||||||
|row| row.get(0),
|
|row| row.get(0),
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
if data_cli_version.as_deref() != Some(&cli_version) {
|
if data_cli_version.as_deref() != Some(cli_version) {
|
||||||
conn.execute("DELETE FROM moduleinfocache", params![])?;
|
conn.execute("DELETE FROM moduleinfocache", params![])?;
|
||||||
let mut stmt = conn
|
let mut stmt = conn
|
||||||
.prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;
|
.prepare("INSERT OR REPLACE INTO info (key, value) VALUES (?1, ?2)")?;
|
||||||
|
@ -340,7 +343,7 @@ mod test {
|
||||||
let conn = Connection::open_in_memory().unwrap();
|
let conn = Connection::open_in_memory().unwrap();
|
||||||
let cache = ParsedSourceCacheModuleAnalyzer::from_connection(
|
let cache = ParsedSourceCacheModuleAnalyzer::from_connection(
|
||||||
conn,
|
conn,
|
||||||
"1.0.0".to_string(),
|
"1.0.0",
|
||||||
Default::default(),
|
Default::default(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -403,7 +406,7 @@ mod test {
|
||||||
let conn = cache.conn;
|
let conn = cache.conn;
|
||||||
let cache = ParsedSourceCacheModuleAnalyzer::from_connection(
|
let cache = ParsedSourceCacheModuleAnalyzer::from_connection(
|
||||||
conn,
|
conn,
|
||||||
"1.0.0".to_string(),
|
"1.0.0",
|
||||||
Default::default(),
|
Default::default(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -420,7 +423,7 @@ mod test {
|
||||||
let conn = cache.conn;
|
let conn = cache.conn;
|
||||||
let cache = ParsedSourceCacheModuleAnalyzer::from_connection(
|
let cache = ParsedSourceCacheModuleAnalyzer::from_connection(
|
||||||
conn,
|
conn,
|
||||||
"1.0.1".to_string(),
|
"1.0.1",
|
||||||
Default::default(),
|
Default::default(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -1746,15 +1746,8 @@ mod tests {
|
||||||
|
|
||||||
fn create_test_client() -> HttpClient {
|
fn create_test_client() -> HttpClient {
|
||||||
HttpClient::from_client(
|
HttpClient::from_client(
|
||||||
create_http_client(
|
create_http_client("test_client", None, vec![], None, None, None)
|
||||||
"test_client".to_string(),
|
.unwrap(),
|
||||||
None,
|
|
||||||
vec![],
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,10 +258,10 @@ fn create_web_worker_callback(
|
||||||
location: Some(args.main_module.clone()),
|
location: Some(args.main_module.clone()),
|
||||||
no_color: !colors::use_color(),
|
no_color: !colors::use_color(),
|
||||||
is_tty: colors::is_tty(),
|
is_tty: colors::is_tty(),
|
||||||
runtime_version: version::deno(),
|
runtime_version: version::deno().to_string(),
|
||||||
ts_version: version::TYPESCRIPT.to_string(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: ps.options.unstable(),
|
unstable: ps.options.unstable(),
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent().to_string(),
|
||||||
inspect: ps.options.is_inspecting(),
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions: ops::cli_exts(ps.clone()),
|
extensions: ops::cli_exts(ps.clone()),
|
||||||
|
@ -347,10 +347,10 @@ pub async fn run(
|
||||||
location: metadata.location,
|
location: metadata.location,
|
||||||
no_color: !colors::use_color(),
|
no_color: !colors::use_color(),
|
||||||
is_tty: colors::is_tty(),
|
is_tty: colors::is_tty(),
|
||||||
runtime_version: version::deno(),
|
runtime_version: version::deno().to_string(),
|
||||||
ts_version: version::TYPESCRIPT.to_string(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: metadata.unstable,
|
unstable: metadata.unstable,
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent().to_string(),
|
||||||
inspect: ps.options.is_inspecting(),
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions: ops::cli_exts(ps.clone()),
|
extensions: ops::cli_exts(ps.clone()),
|
||||||
|
|
|
@ -226,7 +226,7 @@ pub fn check_for_upgrades(http_client: HttpClient, cache_file_path: PathBuf) {
|
||||||
"{}",
|
"{}",
|
||||||
colors::italic_gray("Run `deno upgrade` to install it.")
|
colors::italic_gray("Run `deno upgrade` to install it.")
|
||||||
);
|
);
|
||||||
print_release_notes(&version::deno(), &upgrade_version);
|
print_release_notes(version::deno(), &upgrade_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_checker.store_prompted();
|
update_checker.store_prompted();
|
||||||
|
@ -330,7 +330,7 @@ pub async fn upgrade(
|
||||||
let latest_hash = latest_version.clone();
|
let latest_hash = latest_version.clone();
|
||||||
crate::version::GIT_COMMIT_HASH == latest_hash
|
crate::version::GIT_COMMIT_HASH == latest_hash
|
||||||
} else if !crate::version::is_canary() {
|
} else if !crate::version::is_canary() {
|
||||||
let current = Version::parse_standard(&crate::version::deno()).unwrap();
|
let current = Version::parse_standard(crate::version::deno()).unwrap();
|
||||||
let latest = Version::parse_standard(&latest_version).unwrap();
|
let latest = Version::parse_standard(&latest_version).unwrap();
|
||||||
current >= latest
|
current >= latest
|
||||||
} else {
|
} else {
|
||||||
|
@ -344,7 +344,7 @@ pub async fn upgrade(
|
||||||
log::info!(
|
log::info!(
|
||||||
"Local deno version {} is the most recent release",
|
"Local deno version {} is the most recent release",
|
||||||
if upgrade_flags.canary {
|
if upgrade_flags.canary {
|
||||||
crate::version::GIT_COMMIT_HASH.to_string()
|
crate::version::GIT_COMMIT_HASH
|
||||||
} else {
|
} else {
|
||||||
crate::version::deno()
|
crate::version::deno()
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ pub async fn upgrade(
|
||||||
fs::remove_file(&new_exe_path)?;
|
fs::remove_file(&new_exe_path)?;
|
||||||
log::info!("Upgraded successfully (dry run)");
|
log::info!("Upgraded successfully (dry run)");
|
||||||
if !upgrade_flags.canary {
|
if !upgrade_flags.canary {
|
||||||
print_release_notes(&version::deno(), &install_version);
|
print_release_notes(version::deno(), &install_version);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let output_exe_path =
|
let output_exe_path =
|
||||||
|
@ -422,7 +422,7 @@ pub async fn upgrade(
|
||||||
}
|
}
|
||||||
log::info!("Upgraded successfully");
|
log::info!("Upgraded successfully");
|
||||||
if !upgrade_flags.canary {
|
if !upgrade_flags.canary {
|
||||||
print_release_notes(&version::deno(), &install_version);
|
print_release_notes(version::deno(), &install_version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,30 @@
|
||||||
pub const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH");
|
pub const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH");
|
||||||
pub const TYPESCRIPT: &str = env!("TS_VERSION");
|
pub const TYPESCRIPT: &str = env!("TS_VERSION");
|
||||||
|
|
||||||
pub fn deno() -> String {
|
pub fn deno() -> &'static str {
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
if is_canary() {
|
||||||
option_env!("DENO_CANARY")
|
concat!(
|
||||||
.map(|_| format!("{}+{}", version, &GIT_COMMIT_HASH[..7]))
|
env!("CARGO_PKG_VERSION"),
|
||||||
.unwrap_or_else(|| version.to_string())
|
"+",
|
||||||
|
env!("GIT_COMMIT_HASH_SHORT")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep this in sync with `deno()` above
|
||||||
|
pub fn get_user_agent() -> &'static str {
|
||||||
|
if is_canary() {
|
||||||
|
concat!(
|
||||||
|
"Deno/",
|
||||||
|
env!("CARGO_PKG_VERSION"),
|
||||||
|
"+",
|
||||||
|
env!("GIT_COMMIT_HASH_SHORT")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
concat!("Deno/", env!("CARGO_PKG_VERSION"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_canary() -> bool {
|
pub fn is_canary() -> bool {
|
||||||
|
@ -21,7 +40,3 @@ pub fn release_version_or_canary_commit_hash() -> &'static str {
|
||||||
env!("CARGO_PKG_VERSION")
|
env!("CARGO_PKG_VERSION")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_user_agent() -> String {
|
|
||||||
format!("Deno/{}", deno())
|
|
||||||
}
|
|
||||||
|
|
|
@ -517,10 +517,10 @@ async fn create_main_worker_internal(
|
||||||
location: ps.options.location_flag().clone(),
|
location: ps.options.location_flag().clone(),
|
||||||
no_color: !colors::use_color(),
|
no_color: !colors::use_color(),
|
||||||
is_tty: colors::is_tty(),
|
is_tty: colors::is_tty(),
|
||||||
runtime_version: version::deno(),
|
runtime_version: version::deno().to_string(),
|
||||||
ts_version: version::TYPESCRIPT.to_string(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: ps.options.unstable(),
|
unstable: ps.options.unstable(),
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent().to_string(),
|
||||||
inspect: ps.options.is_inspecting(),
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions,
|
extensions,
|
||||||
|
@ -685,10 +685,10 @@ fn create_web_worker_callback(
|
||||||
location: Some(args.main_module.clone()),
|
location: Some(args.main_module.clone()),
|
||||||
no_color: !colors::use_color(),
|
no_color: !colors::use_color(),
|
||||||
is_tty: colors::is_tty(),
|
is_tty: colors::is_tty(),
|
||||||
runtime_version: version::deno(),
|
runtime_version: version::deno().to_string(),
|
||||||
ts_version: version::TYPESCRIPT.to_string(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: ps.options.unstable(),
|
unstable: ps.options.unstable(),
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent().to_string(),
|
||||||
inspect: ps.options.is_inspecting(),
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions,
|
extensions,
|
||||||
|
|
|
@ -114,7 +114,7 @@ deno_core::extension!(deno_fetch,
|
||||||
state.put::<Options>(options.options.clone());
|
state.put::<Options>(options.options.clone());
|
||||||
state.put::<reqwest::Client>({
|
state.put::<reqwest::Client>({
|
||||||
create_http_client(
|
create_http_client(
|
||||||
options.options.user_agent,
|
&options.options.user_agent,
|
||||||
options.options.root_cert_store,
|
options.options.root_cert_store,
|
||||||
vec![],
|
vec![],
|
||||||
options.options.proxy,
|
options.options.proxy,
|
||||||
|
@ -631,7 +631,7 @@ where
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let client = create_http_client(
|
let client = create_http_client(
|
||||||
options.user_agent.clone(),
|
&options.user_agent,
|
||||||
options.root_cert_store.clone(),
|
options.root_cert_store.clone(),
|
||||||
ca_certs,
|
ca_certs,
|
||||||
args.proxy,
|
args.proxy,
|
||||||
|
@ -646,7 +646,7 @@ where
|
||||||
/// Create new instance of async reqwest::Client. This client supports
|
/// Create new instance of async reqwest::Client. This client supports
|
||||||
/// proxies and doesn't follow redirects.
|
/// proxies and doesn't follow redirects.
|
||||||
pub fn create_http_client(
|
pub fn create_http_client(
|
||||||
user_agent: String,
|
user_agent: &str,
|
||||||
root_cert_store: Option<RootCertStore>,
|
root_cert_store: Option<RootCertStore>,
|
||||||
ca_certs: Vec<Vec<u8>>,
|
ca_certs: Vec<Vec<u8>>,
|
||||||
proxy: Option<Proxy>,
|
proxy: Option<Proxy>,
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub struct InspectorServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InspectorServer {
|
impl InspectorServer {
|
||||||
pub fn new(host: SocketAddr, name: String) -> Self {
|
pub fn new(host: SocketAddr, name: &'static str) -> Self {
|
||||||
let (register_inspector_tx, register_inspector_rx) =
|
let (register_inspector_tx, register_inspector_rx) =
|
||||||
mpsc::unbounded::<InspectorInfo>();
|
mpsc::unbounded::<InspectorInfo>();
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ async fn server(
|
||||||
host: SocketAddr,
|
host: SocketAddr,
|
||||||
register_inspector_rx: UnboundedReceiver<InspectorInfo>,
|
register_inspector_rx: UnboundedReceiver<InspectorInfo>,
|
||||||
shutdown_server_rx: oneshot::Receiver<()>,
|
shutdown_server_rx: oneshot::Receiver<()>,
|
||||||
name: String,
|
name: &str,
|
||||||
) {
|
) {
|
||||||
let inspector_map_ =
|
let inspector_map_ =
|
||||||
Rc::new(RefCell::new(HashMap::<Uuid, InspectorInfo>::new()));
|
Rc::new(RefCell::new(HashMap::<Uuid, InspectorInfo>::new()));
|
||||||
|
|
Loading…
Reference in a new issue