Skip to content

Commit

Permalink
Merge pull request #1 from microsoft/main
Browse files Browse the repository at this point in the history
Adding the `VSCode-sessionId` header to extension query request
  • Loading branch information
prashantvc authored Jun 27, 2022
2 parents 334795d + ebaa253 commit 68ec3ef
Show file tree
Hide file tree
Showing 285 changed files with 6,024 additions and 2,456 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/no-yarn-lock-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
run: |
echo "user: ${{ github.event.pull_request.user.login }}"
echo "role: ${{ fromJson(steps.get_permissions.outputs.data).permission }}"
echo "is dependabot: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}"
echo "should_run: ${{ !contains(fromJson('["admin", "write"]'), fromJson(steps.get_permissions.outputs.data).permission) }}"
echo "::set-output name=should_run::${{ !contains(fromJson('["admin", "write"]'), fromJson(steps.get_permissions.outputs.data).permission) }}"
echo "::set-output name=should_run::${{ !contains(fromJson('["admin", "write"]'), fromJson(steps.get_permissions.outputs.data).permission) && github.event.pull_request.user.login != 'dependabot[bot]' }}"
- name: Get file changes
uses: trilom/file-changes-action@ce38c8ce2459ca3c303415eec8cb0409857b4272
if: ${{ steps.control.outputs.should_run == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
disturl "https://electronjs.org/headers"
target "18.3.4"
target "18.3.5"
runtime "electron"
build_from_source "true"
8 changes: 7 additions & 1 deletion build/azure-pipelines/upload-nlsmetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const vfs = require("vinyl-fs");
const merge = require("gulp-merge-json");
const gzip = require("gulp-gzip");
const identity_1 = require("@azure/identity");
const path = require("path");
const fs_1 = require("fs");
const azure = require('gulp-azure-storage');
const commit = process.env['VSCODE_DISTRO_COMMIT'] || process.env['BUILD_SOURCEVERSION'];
const credential = new identity_1.ClientSecretCredential(process.env['AZURE_TENANT_ID'], process.env['AZURE_CLIENT_ID'], process.env['AZURE_CLIENT_SECRET']);
Expand Down Expand Up @@ -62,7 +64,11 @@ function main() {
break;
}
}
const key = 'vscode.' + file.relative.split('/')[0];
// Get extension id and use that as the key
const folderPath = path.join(file.base, file.relative.split('/')[0]);
const manifest = (0, fs_1.readFileSync)(path.join(folderPath, 'package.json'), 'utf-8');
const manifestJson = JSON.parse(manifest);
const key = manifestJson.publisher + '.' + manifestJson.name;
return { [key]: parsedJson };
},
}))
Expand Down
9 changes: 8 additions & 1 deletion build/azure-pipelines/upload-nlsmetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import * as vfs from 'vinyl-fs';
import * as merge from 'gulp-merge-json';
import * as gzip from 'gulp-gzip';
import { ClientSecretCredential } from '@azure/identity';
import path = require('path');
import { readFileSync } from 'fs';
const azure = require('gulp-azure-storage');

const commit = process.env['VSCODE_DISTRO_COMMIT'] || process.env['BUILD_SOURCEVERSION'];
Expand Down Expand Up @@ -79,7 +81,12 @@ function main(): Promise<void> {
break;
}
}
const key = 'vscode.' + file.relative.split('/')[0];

// Get extension id and use that as the key
const folderPath = path.join(file.base, file.relative.split('/')[0]);
const manifest = readFileSync(path.join(folderPath, 'package.json'), 'utf-8');
const manifestJson = JSON.parse(manifest);
const key = manifestJson.publisher + '.' + manifestJson.name;
return { [key]: parsedJson };
},
}))
Expand Down
2 changes: 1 addition & 1 deletion build/gulpfile.compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const compileBuildTask = task.define('compile-build',
task.series(
util.rimraf('out-build'),
util.buildWebNodePaths('out-build'),
compilation.compileTask('src', 'out-build', true, false)
compilation.compileTask('src', 'out-build', true)
)
);
gulp.task(compileBuildTask);
Expand Down
2 changes: 1 addition & 1 deletion build/gulpfile.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
});
});

const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true, false));
const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true));

const optimizeEditorAMDTask = task.define('optimize-editor-amd', common.optimizeTask({
src: 'out-editor-build',
Expand Down
6 changes: 3 additions & 3 deletions build/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require('events').EventEmitter.defaultMaxListeners = 100;
const gulp = require('gulp');
const util = require('./lib/util');
const task = require('./lib/task');
const { compileTask, watchTask, compileApiProposalNamesTask, watchApiProposalNamesTask } = require('./lib/compilation');
const { transpileTask, compileTask, watchTask, compileApiProposalNamesTask, watchApiProposalNamesTask } = require('./lib/compilation');
const { monacoTypecheckTask/* , monacoTypecheckWatchTask */ } = require('./gulpfile.editor');
const { compileExtensionsTask, watchExtensionsTask, compileExtensionMediaTask } = require('./gulpfile.extensions');

Expand All @@ -20,11 +20,11 @@ gulp.task(compileApiProposalNamesTask);
gulp.task(watchApiProposalNamesTask);

// Transpile only
const transpileClientTask = task.define('transpile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compileTask('src', 'out', false, true)));
const transpileClientTask = task.define('transpile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), transpileTask('src', 'out')));
gulp.task(transpileClientTask);

// Fast compile for development time
const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compileApiProposalNamesTask, compileTask('src', 'out', false, false)));
const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compileApiProposalNamesTask, compileTask('src', 'out', false)));
gulp.task(compileClientTask);

const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(watchTask('out', false), watchApiProposalNamesTask)));
Expand Down
21 changes: 15 additions & 6 deletions build/lib/compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchApiProposalNamesTask = exports.compileApiProposalNamesTask = exports.watchTask = exports.compileTask = void 0;
exports.watchApiProposalNamesTask = exports.compileApiProposalNamesTask = exports.watchTask = exports.compileTask = exports.transpileTask = void 0;
const es = require("event-stream");
const fs = require("fs");
const gulp = require("gulp");
Expand All @@ -18,7 +18,6 @@ const ansiColors = require("ansi-colors");
const os = require("os");
const File = require("vinyl");
const task = require("./task");
const tsb = require("./tsb");
const watch = require('./watch');
const reporter = (0, reporter_1.createReporter)();
function getTypeScriptCompilerOptions(src) {
Expand All @@ -36,7 +35,7 @@ function getTypeScriptCompilerOptions(src) {
return options;
}
function createCompile(src, build, emitError, transpileOnly) {
// const tsb = require('./tsb') as typeof import('./tsb');
const tsb = require('./tsb');
const sourcemaps = require('gulp-sourcemaps');
const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) };
Expand All @@ -60,7 +59,7 @@ function createCompile(src, build, emitError, transpileOnly) {
.pipe(noDeclarationsFilter)
.pipe(build ? nls.nls() : es.through())
.pipe(noDeclarationsFilter.restore)
.pipe(sourcemaps.write('.', {
.pipe(transpileOnly ? es.through() : sourcemaps.write('.', {
addComment: false,
includeContent: !!build,
sourceRoot: overrideOptions.sourceRoot
Expand All @@ -74,12 +73,22 @@ function createCompile(src, build, emitError, transpileOnly) {
};
return pipeline;
}
function compileTask(src, out, build, transpileOnly) {
function transpileTask(src, out) {
return function () {
const transpile = createCompile(src, false, true, true);
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
return srcPipe
.pipe(transpile())
.pipe(gulp.dest(out));
};
}
exports.transpileTask = transpileTask;
function compileTask(src, out, build) {
return function () {
if (os.totalmem() < 4000000000) {
throw new Error('compilation requires 4GB of RAM');
}
const compile = createCompile(src, build, true, transpileOnly);
const compile = createCompile(src, build, true, false);
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
const generator = new MonacoGenerator(false);
if (src === 'src') {
Expand Down
22 changes: 17 additions & 5 deletions build/lib/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import * as os from 'os';
import ts = require('typescript');
import * as File from 'vinyl';
import * as task from './task';
import * as tsb from './tsb';

const watch = require('./watch');

Expand All @@ -39,7 +38,7 @@ function getTypeScriptCompilerOptions(src: string): ts.CompilerOptions {
}

function createCompile(src: string, build: boolean, emitError: boolean, transpileOnly: boolean) {
// const tsb = require('./tsb') as typeof import('./tsb');
const tsb = require('./tsb') as typeof import('./tsb');
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');


Expand Down Expand Up @@ -69,7 +68,7 @@ function createCompile(src: string, build: boolean, emitError: boolean, transpil
.pipe(noDeclarationsFilter)
.pipe(build ? nls.nls() : es.through())
.pipe(noDeclarationsFilter.restore)
.pipe(sourcemaps.write('.', {
.pipe(transpileOnly ? es.through() : sourcemaps.write('.', {
addComment: false,
includeContent: !!build,
sourceRoot: overrideOptions.sourceRoot
Expand All @@ -85,15 +84,28 @@ function createCompile(src: string, build: boolean, emitError: boolean, transpil
return pipeline;
}

export function compileTask(src: string, out: string, build: boolean, transpileOnly: boolean): () => NodeJS.ReadWriteStream {
export function transpileTask(src: string, out: string): () => NodeJS.ReadWriteStream {

return function () {

const transpile = createCompile(src, false, true, true);
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });

return srcPipe
.pipe(transpile())
.pipe(gulp.dest(out));
};
}

export function compileTask(src: string, out: string, build: boolean): () => NodeJS.ReadWriteStream {

return function () {

if (os.totalmem() < 4_000_000_000) {
throw new Error('compilation requires 4GB of RAM');
}

const compile = createCompile(src, build, true, transpileOnly);
const compile = createCompile(src, build, true, false);
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
const generator = new MonacoGenerator(false);
if (src === 'src') {
Expand Down
2 changes: 1 addition & 1 deletion build/lib/tsb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function create(projectPath, existingOptions, config, onError = _defaultOnError)
}
let result;
if (config.transpileOnly) {
const transpiler = new transpiler_1.Transpiler(logFn, printDiagnostic, cmdLine);
const transpiler = new transpiler_1.Transpiler(logFn, printDiagnostic, projectPath, cmdLine);
result = (() => createTranspileStream(transpiler));
}
else {
Expand Down
2 changes: 1 addition & 1 deletion build/lib/tsb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function create(

let result: IncrementalCompiler;
if (config.transpileOnly) {
const transpiler = new Transpiler(logFn, printDiagnostic, cmdLine);
const transpiler = new Transpiler(logFn, printDiagnostic, projectPath, cmdLine);
result = <any>(() => createTranspileStream(transpiler));
} else {
const _builder = builder.createTypeScriptBuilder({ logFn }, projectPath, cmdLine);
Expand Down
35 changes: 18 additions & 17 deletions build/lib/tsb/transpiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,29 @@ class TranspileWorker {
}
TranspileWorker.pool = 1;
class Transpiler {
constructor(logFn, _onError, _cmdLine) {
constructor(logFn, _onError, configFilePath, _cmdLine) {
this._onError = _onError;
this._cmdLine = _cmdLine;
this._workerPool = [];
this._queue = [];
this._allJobs = [];
this._tsApiInternalOutfileName = new class {
constructor(parsedCmd) {
const host = ts.createCompilerHost(parsedCmd.options);
const program = ts.createProgram({ options: parsedCmd.options, rootNames: parsedCmd.fileNames, host });
const emitHost = {
getCompilerOptions: () => parsedCmd.options,
getCurrentDirectory: () => host.getCurrentDirectory(),
getCanonicalFileName: file => host.getCanonicalFileName(file),
getCommonSourceDirectory: () => program.getCommonSourceDirectory()
};
this.getForInfile = file => {
return ts.getOwnEmitOutputFilePath(file, emitHost, '.js');
};
}
}(this._cmdLine);
logFn('Transpile', `will use ${Transpiler.P} transpile worker`);
this._getOutputFileName = (file) => {
if (!_cmdLine.options.configFilePath) {
// this is needed for the INTERNAL getOutputFileNames-call below...
_cmdLine.options.configFilePath = configFilePath;
}
const isDts = file.endsWith('.d.ts');
if (isDts) {
file = file.slice(0, -5) + '.ts';
_cmdLine.fileNames.push(file);
}
const outfile = ts.getOutputFileNames(_cmdLine, file, true)[0];
if (isDts) {
_cmdLine.fileNames.pop();
}
return outfile;
};
}
async join() {
// wait for all penindg jobs
Expand Down Expand Up @@ -163,7 +164,7 @@ class Transpiler {
// kinda LAZYily create workers
if (this._workerPool.length === 0) {
for (let i = 0; i < Transpiler.P; i++) {
this._workerPool.push(new TranspileWorker(file => this._tsApiInternalOutfileName.getForInfile(file)));
this._workerPool.push(new TranspileWorker(file => this._getOutputFileName(file)));
}
}
const freeWorker = this._workerPool.filter(w => !w.isBusy);
Expand Down
57 changes: 27 additions & 30 deletions build/lib/tsb/transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export class Transpiler {

static P = Math.floor(cpus().length * .5);

private readonly _getOutputFileName: (name: string) => string;

public onOutfile?: (file: Vinyl) => void;

private _workerPool: TranspileWorker[] = [];
Expand All @@ -155,9 +157,33 @@ export class Transpiler {
constructor(
logFn: (topic: string, message: string) => void,
private readonly _onError: (err: any) => void,
configFilePath: string,
private readonly _cmdLine: ts.ParsedCommandLine
) {
logFn('Transpile', `will use ${Transpiler.P} transpile worker`);


// very complicated logic to re-use TS internal functions to know the output path
// given a TS input path and its config
type InternalTsApi = typeof ts & {
getOutputFileNames(commandLine: ts.ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[];
};
this._getOutputFileName = (file) => {
if (!_cmdLine.options.configFilePath) {
// this is needed for the INTERNAL getOutputFileNames-call below...
_cmdLine.options.configFilePath = configFilePath;
}
const isDts = file.endsWith('.d.ts');
if (isDts) {
file = file.slice(0, -5) + '.ts';
_cmdLine.fileNames.push(file);
}
const outfile = (<InternalTsApi>ts).getOutputFileNames(_cmdLine, file, true)[0];
if (isDts) {
_cmdLine.fileNames.pop();
}
return outfile;
};
}

async join() {
Expand Down Expand Up @@ -195,7 +221,7 @@ export class Transpiler {
// kinda LAZYily create workers
if (this._workerPool.length === 0) {
for (let i = 0; i < Transpiler.P; i++) {
this._workerPool.push(new TranspileWorker(file => this._tsApiInternalOutfileName.getForInfile(file)));
this._workerPool.push(new TranspileWorker(file => this._getOutputFileName(file)));
}
}

Expand Down Expand Up @@ -237,35 +263,6 @@ export class Transpiler {
this._allJobs.push(job);
}
}

private _tsApiInternalOutfileName = new class {

getForInfile: (file: string) => string;

constructor(parsedCmd: ts.ParsedCommandLine) {

type InternalTsHost = {
getCompilerOptions(): ts.CompilerOptions;
getCurrentDirectory(): string;
getCommonSourceDirectory(): string;
getCanonicalFileName(file: string): string;
};
type InternalTsApi = { getOwnEmitOutputFilePath(fileName: string, host: InternalTsHost, extension: string): string } & typeof ts;

const host = ts.createCompilerHost(parsedCmd.options);
const program = ts.createProgram({ options: parsedCmd.options, rootNames: parsedCmd.fileNames, host });
const emitHost: InternalTsHost = {
getCompilerOptions: () => parsedCmd.options,
getCurrentDirectory: () => host.getCurrentDirectory(),
getCanonicalFileName: file => host.getCanonicalFileName(file),
getCommonSourceDirectory: () => (<any>program).getCommonSourceDirectory()
};

this.getForInfile = file => {
return (<InternalTsApi>ts).getOwnEmitOutputFilePath(file, emitHost, '.js');
};
}
}(this._cmdLine);
}

function _isDefaultEmpty(src: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"esbuild": "^0.14.2",
"extract-zip": "^2.0.1",
"fs-extra": "^9.1.0",
"got": "11.8.1",
"got": "11.8.5",
"gulp-merge-json": "^2.1.1",
"gulp-shell": "^0.8.0",
"jsonc-parser": "^2.3.0",
Expand Down
Loading

0 comments on commit 68ec3ef

Please sign in to comment.