Skip to content

Commit

Permalink
Merge branch 'master' into 99129-theme-colour-git-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
mwood77 committed Sep 28, 2020
2 parents 536652a + 772aa07 commit b8c953d
Show file tree
Hide file tree
Showing 216 changed files with 2,893 additions and 2,546 deletions.
6 changes: 3 additions & 3 deletions .github/classifier.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vscode-github-triage-actions/master/classifier-deep/apply/apply-labels/deep-classifier-config.schema.json",
"vacation": ["joaomoreno"],
"vacation": ["joaomoreno"],
"assignees": {
"JacksonKearl": {"accuracy": 0.5}
},
Expand All @@ -20,8 +20,8 @@
"context-keys": {"assign": []},
"css-less-scss": {"assign": ["aeschli"]},
"custom-editors": {"assign": ["mjbvz"]},
"debug": {"assign": ["weinand"]},
"debug-console": {"assign": ["weinand"]},
"debug": {"assign": ["isidorn"]},
"debug-console": {"assign": ["isidorn"]},
"dialogs": {"assign": ["sbatten"]},
"diff-editor": {"assign": []},
"dropdown": {"assign": []},
Expand Down
4 changes: 3 additions & 1 deletion build/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.js
azure-pipelines/**/*.js
darwin/**/*.js
lib/**/*.js
2 changes: 1 addition & 1 deletion build/gulpfile.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const i18n = require('./lib/i18n');
const standalone = require('./lib/standalone');
const cp = require('child_process');
const compilation = require('./lib/compilation');
const monacoapi = require('./monaco/api');
const monacoapi = require('./lib/monaco-api');
const fs = require('fs');
const webpack = require('webpack');
const webpackGulp = require('webpack-stream');
Expand Down
70 changes: 45 additions & 25 deletions build/lib/builtInExtensions.js → build/lib/builtInExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,54 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

'use strict';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import * as rimraf from 'rimraf';
import * as es from 'event-stream';
import * as rename from 'gulp-rename';
import * as vfs from 'vinyl-fs';
import * as ext from './extensions';
import * as fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors';
import { Stream } from 'stream';

const fs = require('fs');
const path = require('path');
const os = require('os');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
const es = require('event-stream');
const rename = require('gulp-rename');
const vfs = require('vinyl-fs');
const ext = require('./extensions');
const fancyLog = require('fancy-log');
const ansiColors = require('ansi-colors');

interface IExtensionDefinition {
name: string;
version: string;
repo: string;
metadata: {
id: string;
publisherId: {
publisherId: string;
publisherName: string;
displayName: string;
flags: string;
};
publisherDisplayName: string;
}
}

const root = path.dirname(path.dirname(__dirname));
const productjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8'));
const builtInExtensions = productjson.builtInExtensions;
const webBuiltInExtensions = productjson.webBuiltInExtensions;
const builtInExtensions = <IExtensionDefinition[]>productjson.builtInExtensions;
const webBuiltInExtensions = <IExtensionDefinition[]>productjson.webBuiltInExtensions;
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
const ENABLE_LOGGING = !process.env['VSCODE_BUILD_BUILTIN_EXTENSIONS_SILENCE_PLEASE'];

function log() {
function log(...messages: string[]): void {
if (ENABLE_LOGGING) {
fancyLog.apply(this, arguments);
fancyLog(...messages);
}
}

function getExtensionPath(extension) {
function getExtensionPath(extension: IExtensionDefinition): string {
return path.join(root, '.build', 'builtInExtensions', extension.name);
}

function isUpToDate(extension) {
function isUpToDate(extension: IExtensionDefinition): boolean {
const packagePath = path.join(getExtensionPath(extension), 'package.json');

if (!fs.existsSync(packagePath)) {
Expand All @@ -51,7 +67,7 @@ function isUpToDate(extension) {
}
}

function syncMarketplaceExtension(extension) {
function syncMarketplaceExtension(extension: IExtensionDefinition): Stream {
if (isUpToDate(extension)) {
log(ansiColors.blue('[marketplace]'), `${extension.name}@${extension.version}`, ansiColors.green('✔︎'));
return es.readArray([]);
Expand All @@ -65,7 +81,7 @@ function syncMarketplaceExtension(extension) {
.on('end', () => log(ansiColors.blue('[marketplace]'), extension.name, ansiColors.green('✔︎')));
}

function syncExtension(extension, controlState) {
function syncExtension(extension: IExtensionDefinition, controlState: 'disabled' | 'marketplace'): Stream {
switch (controlState) {
case 'disabled':
log(ansiColors.blue('[disabled]'), ansiColors.gray(extension.name));
Expand All @@ -89,25 +105,29 @@ function syncExtension(extension, controlState) {
}
}

function readControlFile() {
interface IControlFile {
[name: string]: 'disabled' | 'marketplace';
}

function readControlFile(): IControlFile {
try {
return JSON.parse(fs.readFileSync(controlFilePath, 'utf8'));
} catch (err) {
return {};
}
}

function writeControlFile(control) {
function writeControlFile(control: IControlFile): void {
mkdirp.sync(path.dirname(controlFilePath));
fs.writeFileSync(controlFilePath, JSON.stringify(control, null, 2));
}

exports.getBuiltInExtensions = function getBuiltInExtensions() {
export function getBuiltInExtensions(): Promise<void> {
log('Syncronizing built-in extensions...');
log(`You can manage built-in extensions with the ${ansiColors.cyan('--builtin')} flag`);

const control = readControlFile();
const streams = [];
const streams: Stream[] = [];

for (const extension of [...builtInExtensions, ...webBuiltInExtensions]) {
let controlState = control[extension.name] || 'marketplace';
Expand All @@ -123,10 +143,10 @@ exports.getBuiltInExtensions = function getBuiltInExtensions() {
.on('error', reject)
.on('end', resolve);
});
};
}

if (require.main === module) {
exports.getBuiltInExtensions().then(() => process.exit(0)).catch(err => {
getBuiltInExtensions().then(() => process.exit(0)).catch(err => {
console.error(err);
process.exit(1);
});
Expand Down
2 changes: 1 addition & 1 deletion build/lib/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as bom from 'gulp-bom';
import * as sourcemaps from 'gulp-sourcemaps';
import * as tsb from 'gulp-tsb';
import * as path from 'path';
import * as monacodts from '../monaco/api';
import * as monacodts from './monaco-api';
import * as nls from './nls';
import { createReporter } from './reporter';
import * as util from './util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

'use strict';

import * as eslint from 'eslint';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import * as ESTree from 'estree';

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -50,29 +54,29 @@ module.exports = {
]
},

create(context) {
create(context: eslint.Rule.RuleContext) {
const config = context.options[0] || {},
allowShortCircuit = config.allowShortCircuit || false,
allowTernary = config.allowTernary || false,
allowTaggedTemplates = config.allowTaggedTemplates || false;

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node any node
* @returns {boolean} whether the given node structurally represents a directive
*/
function looksLikeDirective(node) {
/**
* @param node any node
* @returns whether the given node structurally represents a directive
*/
function looksLikeDirective(node: TSESTree.Node): boolean {
return node.type === 'ExpressionStatement' &&
node.expression.type === 'Literal' && typeof node.expression.value === 'string';
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {Function} predicate ([a] -> Boolean) the function used to make the determination
* @param {a[]} list the input list
* @returns {a[]} the leading sequence of members in the given list that pass the given predicate
*/
function takeWhile(predicate, list) {
/**
* @param predicate ([a] -> Boolean) the function used to make the determination
* @param list the input list
* @returns the leading sequence of members in the given list that pass the given predicate
*/
function takeWhile<T>(predicate: (item: T) => boolean, list: T[]): T[] {
for (let i = 0; i < list.length; ++i) {
if (!predicate(list[i])) {
return list.slice(0, i);
Expand All @@ -82,21 +86,21 @@ module.exports = {
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node a Program or BlockStatement node
* @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
*/
function directives(node) {
/**
* @param node a Program or BlockStatement node
* @returns the leading sequence of directive nodes in the given node's body
*/
function directives(node: TSESTree.Program | TSESTree.BlockStatement): TSESTree.Node[] {
return takeWhile(looksLikeDirective, node.body);
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node any node
* @param {ASTNode[]} ancestors the given node's ancestors
* @returns {boolean} whether the given node is considered a directive in its current position
*/
function isDirective(node, ancestors) {
/**
* @param node any node
* @param ancestors the given node's ancestors
* @returns whether the given node is considered a directive in its current position
*/
function isDirective(node: TSESTree.Node, ancestors: TSESTree.Node[]): boolean {
const parent = ancestors[ancestors.length - 1],
grandparent = ancestors[ancestors.length - 2];

Expand All @@ -105,12 +109,12 @@ module.exports = {
directives(parent).indexOf(node) >= 0;
}

/**
* Determines whether or not a given node is a valid expression. Recurses on short circuit eval and ternary nodes if enabled by flags.
* @param {ASTNode} node any node
* @returns {boolean} whether the given node is a valid expression
*/
function isValidExpression(node) {
/**
* Determines whether or not a given node is a valid expression. Recurses on short circuit eval and ternary nodes if enabled by flags.
* @param node any node
* @returns whether the given node is a valid expression
*/
function isValidExpression(node: TSESTree.Node): boolean {
if (allowTernary) {

// Recursive check for ternary and logical expressions
Expand All @@ -134,9 +138,9 @@ module.exports = {
}

return {
ExpressionStatement(node) {
if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) {
context.report({ node, message: 'Expected an assignment or function call and instead saw an expression.' });
ExpressionStatement(node: TSESTree.ExpressionStatement) {
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.getAncestors())) {
context.report({ node: <ESTree.Node>node, message: 'Expected an assignment or function call and instead saw an expression.' });
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion build/monaco/api.ts → build/lib/monaco-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const dtsv = '3';
const tsfmt = require('../../tsfmt.json');

const SRC = path.join(__dirname, '../../src');
export const RECIPE_PATH = path.join(__dirname, './monaco.d.ts.recipe');
export const RECIPE_PATH = path.join(__dirname, '../monaco/monaco.d.ts.recipe');
const DECLARATION_PATH = path.join(__dirname, '../../src/vs/monaco.d.ts');

function logErr(message: any, ...rest: any[]): void {
Expand Down
File renamed without changes.
Loading

0 comments on commit b8c953d

Please sign in to comment.