Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
enginelesscc committed Nov 22, 2022
2 parents 9caafec + bf2973f commit b61d116
Show file tree
Hide file tree
Showing 194 changed files with 2,456 additions and 1,202 deletions.
20 changes: 12 additions & 8 deletions build/azure-pipelines/cli/prepare.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions build/azure-pipelines/cli/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as packageJson from '../../../package.json';

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

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


console.log('Loading product.json from', productJsonPath);
console.error('Loading product.json from', productJsonPath);
const product = readJSON(productJsonPath);
const allProductsAndQualities = isOSS ? [product] : fs.readdirSync(path.join(root, 'quality'))
.map(quality => ({ quality, json: readJSON(path.join(root, 'quality', quality, 'product.json')) }));
Expand Down Expand Up @@ -50,7 +49,7 @@ const setLauncherEnvironmentVars = () => {
['VSCODE_CLI_NAME_LONG', product.nameLong],
['VSCODE_CLI_QUALITYLESS_PRODUCT_NAME', product.nameLong.replace(/ - [a-z]+$/i, '')],
['VSCODE_CLI_APPLICATION_NAME', product.applicationName],
['VSCODE_CLI_EDITOR_WEB_URL', product.editorWebUrl],
['VSCODE_CLI_EDITOR_WEB_URL', product.tunnelApplicationConfig?.editorWebUrl],
['VSCODE_CLI_COMMIT', commit],
[
'VSCODE_CLI_WIN32_APP_IDS',
Expand Down Expand Up @@ -78,13 +77,16 @@ const setLauncherEnvironmentVars = () => {
],
]);

console.log(JSON.stringify([...vars].reduce((obj, kv) => ({ ...obj, [kv[0]]: kv[1] }), {})));

for (const [key, value] of vars) {
if (value) {
console.log(`##vso[task.setvariable variable=${key}]${value}`);
if (process.env.VSCODE_CLI_PREPARE_OUTPUT === 'json') {
console.log(JSON.stringify([...vars].filter(([, v]) => !!v)));
} else {
for (const [key, value] of vars) {
if (value) {
console.log(`##vso[task.setvariable variable=${key}]${value}`);
}
}
}

};

if (require.main === module) {
Expand Down
3 changes: 2 additions & 1 deletion build/gulpfile.reh.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ function tweakProductForServerWeb(product) {
// TODO: we cannot inline `product.json` because
// it is being changed during build time at a later
// point in time (such as `checksums`)
'../product.json'
'../product.json',
'../package.json'
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion build/gulpfile.vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
// TODO: we cannot inline `product.json` because
// it is being changed during build time at a later
// point in time (such as `checksums`)
'../product.json'
'../product.json',
'../package.json',
]
},
manual: [
Expand Down
4 changes: 4 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ async-trait = "0.1"
log = "0.4"
const_format = "0.2"

[build-dependencies]
serde = { version = "1.0" }
serde_json = { version = "1.0" }

[target.'cfg(windows)'.dependencies]
windows-service = "0.5"
winreg = "0.10"
Expand Down
45 changes: 44 additions & 1 deletion cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,54 @@

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 *--------------------------------------------------------------------------------------------*/";

use std::{env, fs, io, path::PathBuf, process};
use std::{
env, fs, io,
path::PathBuf,
process::{self, Command},
str::FromStr,
};

fn main() {
let files = enumerate_source_files().expect("expected to enumerate files");
ensure_file_headers(&files).expect("expected to ensure file headers");
apply_build_environment_variables();
}

fn apply_build_environment_variables() {
// only do this for local, debug builds
if env::var("PROFILE").unwrap() != "debug" {
return;
}

let pkg_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let mut cmd = Command::new("node");
cmd.arg("../build/azure-pipelines/cli/prepare.js");
cmd.current_dir(&pkg_dir);
cmd.env("VSCODE_CLI_PREPARE_OUTPUT", "json");

let mut distro_location = PathBuf::from_str(&pkg_dir).unwrap();
distro_location.pop(); // vscode dir
distro_location.pop(); // parent dir
distro_location.push("vscode-distro"); // distro dir, perhaps?
if distro_location.exists() {
cmd.env("VSCODE_CLI_PREPARE_ROOT", distro_location);
cmd.env("VSCODE_QUALITY", "insider");
}

let output = cmd.output().expect("expected to run prepare script");
if !output.status.success() {
eprint!(
"error running prepare script: {}",
String::from_utf8_lossy(&output.stderr)
);
process::exit(output.status.code().unwrap_or(1));
}

let vars = serde_json::from_slice::<Vec<(String, String)>>(&output.stdout)
.expect("expected to deserialize output");
for (key, value) in vars {
println!("cargo:rustc-env={}={}", key, value);
}
}

fn ensure_file_headers(files: &[PathBuf]) -> Result<(), io::Error> {
Expand Down
5 changes: 5 additions & 0 deletions extensions/csharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"update-grammar": "node ../node_modules/vscode-grammar-updater/bin dotnet/csharp-tmLanguage grammars/csharp.tmLanguage ./syntaxes/csharp.tmLanguage.json"
},
"contributes": {
"configurationDefaults": {
"[csharp]": {
"editor.maxTokenizationLineLength": 2500
}
},
"languages": [
{
"id": "csharp",
Expand Down
15 changes: 15 additions & 0 deletions extensions/extension-editing/src/extensionLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const product = JSON.parse(fs.readFileSync(path.join(env.appRoot, 'product.json'
const allowedBadgeProviders: string[] = (product.extensionAllowedBadgeProviders || []).map((s: string) => s.toLowerCase());
const allowedBadgeProvidersRegex: RegExp[] = (product.extensionAllowedBadgeProvidersRegex || []).map((r: string) => new RegExp(r));
const extensionEnabledApiProposals: Record<string, string[]> = product.extensionEnabledApiProposals ?? {};
const reservedImplicitActivationEventPrefixes = ['onNotebookSerializer:'];

function isTrustedSVGSource(uri: Uri): boolean {
return allowedBadgeProviders.includes(uri.authority.toLowerCase()) || allowedBadgeProvidersRegex.some(r => r.test(uri.toString()));
Expand All @@ -29,6 +30,7 @@ const relativeUrlRequiresHttpsRepository = l10n.t("Relative image URLs require a
const relativeIconUrlRequiresHttpsRepository = l10n.t("An icon requires a repository with HTTPS protocol to be specified in this package.json.");
const relativeBadgeUrlRequiresHttpsRepository = l10n.t("Relative badge URLs require a repository with HTTPS protocol to be specified in this package.json.");
const apiProposalNotListed = l10n.t("This proposal cannot be used because for this extension the product defines a fixed set of API proposals. You can test your extension but before publishing you MUST reach out to the VS Code team.");
const implicitActivationEvent = l10n.t("This activation event cannot be explicitly listed by your extension.");

enum Context {
ICON,
Expand Down Expand Up @@ -145,6 +147,19 @@ export class ExtensionLinter {
}
}
}
const activationEventsNode = findNodeAtLocation(tree, ['activationEvents']);
if (Array.isArray(activationEventsNode) && activationEventsNode.children) {
for (const activationEventNode of activationEventsNode.children) {
const activationEvent = getNodeValue(activationEventNode);
for (const implicitActivationEventPrefix of reservedImplicitActivationEventPrefixes) {
if (activationEvent.startsWith(implicitActivationEventPrefix)) {
const start = document.positionAt(activationEventNode.offset);
const end = document.positionAt(activationEventNode.offset + activationEventNode.length);
diagnostics.push(new Diagnostic(new Range(start, end), implicitActivationEvent, DiagnosticSeverity.Error));
}
}
}
}
}

}
Expand Down
Loading

0 comments on commit b61d116

Please sign in to comment.