Skip to content

Commit 5bb4cd1

Browse files
authored
Merge branch 'main' into merogge/quick-fix-api
2 parents 0c48cab + c646be0 commit 5bb4cd1

File tree

281 files changed

+3702
-1958
lines changed

Some content is hidden

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

281 files changed

+3702
-1958
lines changed

build/azure-pipelines/cli/prepare.js

Lines changed: 26 additions & 7 deletions
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: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as fs from 'fs';
88
import * as path from 'path';
99
import * as packageJson from '../../../package.json';
1010

11-
const root = path.dirname(path.dirname(path.dirname(__dirname)));
11+
const root = process.env.VSCODE_CLI_PREPARE_ROOT || path.dirname(path.dirname(path.dirname(__dirname)));
1212
const readJSON = (path: string) => JSON.parse(fs.readFileSync(path, 'utf8'));
1313

1414
let productJsonPath: string;
@@ -19,8 +19,7 @@ if (isOSS) {
1919
productJsonPath = path.join(root, 'quality', process.env.VSCODE_QUALITY!, 'product.json');
2020
}
2121

22-
23-
console.log('Loading product.json from', productJsonPath);
22+
console.error('Loading product.json from', productJsonPath);
2423
const product = readJSON(productJsonPath);
2524
const allProductsAndQualities = isOSS ? [product] : fs.readdirSync(path.join(root, 'quality'))
2625
.map(quality => ({ quality, json: readJSON(path.join(root, 'quality', quality, 'product.json')) }));
@@ -48,7 +47,10 @@ const setLauncherEnvironmentVars = () => {
4847
['VSCODE_CLI_QUALITY', product.quality],
4948
['VSCODE_CLI_NAME_SHORT', product.nameShort],
5049
['VSCODE_CLI_NAME_LONG', product.nameLong],
50+
['VSCODE_CLI_QUALITYLESS_PRODUCT_NAME', product.nameLong.replace(/ - [a-z]+$/i, '')],
51+
['VSCODE_CLI_DOCUMENTATION_URL', product.documentationUrl],
5152
['VSCODE_CLI_APPLICATION_NAME', product.applicationName],
53+
['VSCODE_CLI_EDITOR_WEB_URL', product.tunnelApplicationConfig?.editorWebUrl],
5254
['VSCODE_CLI_COMMIT', commit],
5355
[
5456
'VSCODE_CLI_WIN32_APP_IDS',
@@ -58,19 +60,34 @@ const setLauncherEnvironmentVars = () => {
5860
.map(([, value]) => String(value).replace(/[{}]/g, ''))),
5961
),
6062
],
63+
[
64+
'VSCODE_CLI_NAME_LONG_MAP',
65+
!isOSS && JSON.stringify(makeQualityMap(json => json.nameLong)),
66+
],
67+
[
68+
'VSCODE_CLI_APPLICATION_NAME_MAP',
69+
!isOSS && JSON.stringify(makeQualityMap(json => json.applicationName)),
70+
],
71+
[
72+
'VSCODE_CLI_SERVER_NAME_MAP',
73+
!isOSS && JSON.stringify(makeQualityMap(json => json.serverApplicationName)),
74+
],
6175
[
6276
'VSCODE_CLI_QUALITY_DOWNLOAD_URIS',
6377
!isOSS && JSON.stringify(makeQualityMap(json => json.downloadUrl)),
6478
],
6579
]);
6680

67-
console.log(JSON.stringify([...vars].reduce((obj, kv) => ({...obj, [kv[0]]: kv[1]}), {})));
68-
69-
for (const [key, value] of vars) {
70-
if (value) {
71-
console.log(`##vso[task.setvariable variable=${key}]${value}`);
81+
if (process.env.VSCODE_CLI_PREPARE_OUTPUT === 'json') {
82+
console.log(JSON.stringify([...vars].filter(([, v]) => !!v)));
83+
} else {
84+
for (const [key, value] of vars) {
85+
if (value) {
86+
console.log(`##vso[task.setvariable variable=${key}]${value}`);
87+
}
7288
}
7389
}
90+
7491
};
7592

7693
if (require.main === module) {

build/gulpfile.reh.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ function tweakProductForServerWeb(product) {
378378
// TODO: we cannot inline `product.json` because
379379
// it is being changed during build time at a later
380380
// point in time (such as `checksums`)
381-
'../product.json'
381+
'../product.json',
382+
'../package.json'
382383
]
383384
}
384385
}

build/gulpfile.vscode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
119119
// TODO: we cannot inline `product.json` because
120120
// it is being changed during build time at a later
121121
// point in time (such as `checksums`)
122-
'../product.json'
122+
'../product.json',
123+
'../package.json',
123124
]
124125
},
125126
manual: [

cli/Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ clap_lex = "0.2"
4646
url = "2.3"
4747
async-trait = "0.1"
4848
log = "0.4"
49+
const_format = "0.2"
50+
51+
[build-dependencies]
52+
serde = { version = "1.0" }
53+
serde_json = { version = "1.0" }
4954

5055
[target.'cfg(windows)'.dependencies]
5156
windows-service = "0.5"

cli/build.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,54 @@
55

66
const FILE_HEADER: &str = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/";
77

8-
use std::{env, fs, io, path::PathBuf, process};
8+
use std::{
9+
env, fs, io,
10+
path::PathBuf,
11+
process::{self, Command},
12+
str::FromStr,
13+
};
914

1015
fn main() {
1116
let files = enumerate_source_files().expect("expected to enumerate files");
1217
ensure_file_headers(&files).expect("expected to ensure file headers");
18+
apply_build_environment_variables();
19+
}
20+
21+
fn apply_build_environment_variables() {
22+
// only do this for local, debug builds
23+
if env::var("PROFILE").unwrap() != "debug" {
24+
return;
25+
}
26+
27+
let pkg_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
28+
let mut cmd = Command::new("node");
29+
cmd.arg("../build/azure-pipelines/cli/prepare.js");
30+
cmd.current_dir(&pkg_dir);
31+
cmd.env("VSCODE_CLI_PREPARE_OUTPUT", "json");
32+
33+
let mut distro_location = PathBuf::from_str(&pkg_dir).unwrap();
34+
distro_location.pop(); // vscode dir
35+
distro_location.pop(); // parent dir
36+
distro_location.push("vscode-distro"); // distro dir, perhaps?
37+
if distro_location.exists() {
38+
cmd.env("VSCODE_CLI_PREPARE_ROOT", distro_location);
39+
cmd.env("VSCODE_QUALITY", "insider");
40+
}
41+
42+
let output = cmd.output().expect("expected to run prepare script");
43+
if !output.status.success() {
44+
eprint!(
45+
"error running prepare script: {}",
46+
String::from_utf8_lossy(&output.stderr)
47+
);
48+
process::exit(output.status.code().unwrap_or(1));
49+
}
50+
51+
let vars = serde_json::from_slice::<Vec<(String, String)>>(&output.stdout)
52+
.expect("expected to deserialize output");
53+
for (key, value) in vars {
54+
println!("cargo:rustc-env={}={}", key, value);
55+
}
1356
}
1457

1558
fn ensure_file_headers(files: &[PathBuf]) -> Result<(), io::Error> {

cli/src/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
use crate::{
7-
constants::get_default_user_agent,
7+
constants::{get_default_user_agent, PRODUCT_NAME_LONG},
88
info, log,
99
state::{LauncherPaths, PersistedState},
1010
trace,
@@ -500,7 +500,7 @@ impl Auth {
500500
}
501501

502502
let provider = prompt_options(
503-
"How would you like to log in to VS Code?",
503+
format!("How would you like to log in to {}?", PRODUCT_NAME_LONG),
504504
&[AuthProvider::Microsoft, AuthProvider::Github],
505505
)?;
506506

cli/src/bin/code/main.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ async fn start_code(context: CommandContext, args: Vec<String>) -> Result<i32, A
157157
.args(args)
158158
.status()
159159
.map(|s| s.code().unwrap_or(1))
160-
.map_err(|e| {
161-
wrap(
162-
e,
163-
format!("error running VS Code from {}", binary.display()),
164-
)
165-
})?;
160+
.map_err(|e| wrap(e, format!("error running editor from {}", binary.display())))?;
166161

167162
Ok(code)
168163
}

0 commit comments

Comments
 (0)