Skip to content

Commit 9ede543

Browse files
authored
Merge branch 'main' into aamunger/scrollOutputWithKeys
2 parents 2e902f0 + 0231286 commit 9ede543

File tree

75 files changed

+1855
-1257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1855
-1257
lines changed

build/azure-pipelines/cli/prepare.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/azure-pipelines/cli/prepare.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const setLauncherEnvironmentVars = () => {
5454
['VSCODE_CLI_TUNNEL_SERVICE_MUTEX', product.win32TunnelServiceMutex],
5555
['VSCODE_CLI_TUNNEL_CLI_MUTEX', product.win32TunnelMutex],
5656
['VSCODE_CLI_COMMIT', commit],
57+
['VSCODE_CLI_DEFAULT_PARENT_DATA_DIR', product.dataFolderName],
5758
[
5859
'VSCODE_CLI_WIN32_APP_IDS',
5960
!isOSS && JSON.stringify(

cli/src/bin/code/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async fn main() -> Result<(), std::convert::Infallible> {
3636
});
3737

3838
let core = parsed.core();
39-
let context_paths = LauncherPaths::new(&core.global_options.cli_data_dir).unwrap();
39+
let context_paths = LauncherPaths::migrate(core.global_options.cli_data_dir.clone()).unwrap();
4040
let context_args = core.clone();
4141

4242
// gets a command context without installing the global logger

cli/src/constants.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ pub const TUNNEL_ACTIVITY_NAME: &str = concatcp!(PRODUCT_NAME_LONG, " Tunnel");
7575

7676
const NONINTERACTIVE_VAR: &str = "VSCODE_CLI_NONINTERACTIVE";
7777

78+
/// Default data CLI data directory.
79+
pub const DEFAULT_DATA_PARENT_DIR: &str = match option_env!("VSCODE_CLI_DEFAULT_PARENT_DATA_DIR") {
80+
Some(n) => n,
81+
None => ".vscode-oss",
82+
};
83+
7884
pub fn get_default_user_agent() -> String {
7985
format!(
8086
"vscode-server-launcher/{}",

cli/src/state.rs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
extern crate dirs;
77

88
use std::{
9-
fs::{create_dir, read_to_string, remove_dir_all, write},
9+
fs::{create_dir_all, read_to_string, remove_dir_all, write},
1010
path::{Path, PathBuf},
1111
sync::{Arc, Mutex},
1212
};
1313

1414
use serde::{de::DeserializeOwned, Serialize};
1515

1616
use crate::{
17-
constants::VSCODE_CLI_QUALITY,
17+
constants::{DEFAULT_DATA_PARENT_DIR, VSCODE_CLI_QUALITY},
1818
download_cache::DownloadCache,
1919
util::errors::{wrap, AnyError, NoHomeForLauncherError, WrappedError},
2020
};
@@ -107,8 +107,38 @@ where
107107
}
108108

109109
impl LauncherPaths {
110-
pub fn new(root: &Option<String>) -> Result<LauncherPaths, AnyError> {
111-
let root = root.as_deref().unwrap_or("~/.vscode-cli");
110+
/// todo@conno4312: temporary migration from the old CLI data directory
111+
pub fn migrate(root: Option<String>) -> Result<LauncherPaths, AnyError> {
112+
if root.is_some() {
113+
return Self::new(root);
114+
}
115+
116+
let home_dir = match dirs::home_dir() {
117+
None => return Self::new(root),
118+
Some(d) => d,
119+
};
120+
121+
let old_dir = home_dir.join(".vscode-cli");
122+
let mut new_dir = home_dir;
123+
new_dir.push(DEFAULT_DATA_PARENT_DIR);
124+
new_dir.push("cli");
125+
if !old_dir.exists() || new_dir.exists() {
126+
return Self::new_for_path(new_dir);
127+
}
128+
129+
if let Err(e) = std::fs::rename(&old_dir, &new_dir) {
130+
// no logger exists at this point in the lifecycle, so just log to stderr
131+
eprintln!(
132+
"Failed to migrate old CLI data directory, will create a new one ({})",
133+
e
134+
);
135+
}
136+
137+
Self::new_for_path(new_dir)
138+
}
139+
140+
pub fn new(root: Option<String>) -> Result<LauncherPaths, AnyError> {
141+
let root = root.unwrap_or_else(|| format!("~/{}/cli", DEFAULT_DATA_PARENT_DIR));
112142
let mut replaced = root.to_owned();
113143
for token in HOME_DIR_ALTS {
114144
if root.contains(token) {
@@ -120,14 +150,16 @@ impl LauncherPaths {
120150
}
121151
}
122152

123-
if !Path::new(&replaced).exists() {
124-
create_dir(&replaced)
125-
.map_err(|e| wrap(e, format!("error creating directory {}", &replaced)))?;
153+
Self::new_for_path(PathBuf::from(replaced))
154+
}
155+
156+
fn new_for_path(root: PathBuf) -> Result<LauncherPaths, AnyError> {
157+
if !root.exists() {
158+
create_dir_all(&root)
159+
.map_err(|e| wrap(e, format!("error creating directory {}", root.display())))?;
126160
}
127161

128-
Ok(LauncherPaths::new_without_replacements(PathBuf::from(
129-
replaced,
130-
)))
162+
Ok(LauncherPaths::new_without_replacements(root))
131163
}
132164

133165
pub fn new_without_replacements(root: PathBuf) -> LauncherPaths {

extensions/emmet/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,10 @@
482482
"@types/node": "16.x"
483483
},
484484
"dependencies": {
485-
"@emmetio/abbreviation": "^2.2.0",
486485
"@emmetio/css-parser": "ramya-rao-a/css-parser#vscode",
487486
"@emmetio/html-matcher": "^0.3.3",
488-
"@emmetio/math-expression": "^1.0.4",
489-
"@vscode/emmet-helper": "^2.3.0",
487+
"@emmetio/math-expression": "^1.0.5",
488+
"@vscode/emmet-helper": "^2.8.8",
490489
"image-size": "~1.0.0",
491490
"vscode-languageserver-textdocument": "^1.0.1"
492491
},

0 commit comments

Comments
 (0)