Files
azuredatastudio/build/lib/tsb/index.js
Cheena Malhotra 2c07c09d0d Compile build folder (#22811)
* Compile build folder

* Fix build compile issues (#22813)

* Revert changes

* Update gulp-shell

* Test

* Update

* Update modifiers

* Try reverting minimist

* Generates linux deb artifact (#22922)

* Remove deb files that were brought in with the latest merge.

* Add debian back to linux gulp file

* Remove async from anonymous function.

* Remove run core integration tests build step in pipeline

* Revert "Remove async from anonymous function."

This reverts commit 7ad1ce2942954fce58939b9965343b46b9311a7e.

* Revert "Add debian back to linux gulp file"

This reverts commit 96b7c0f0995c8024ef67ed886da34255a5caa325.

* Revert "Remove deb files that were brought in with the latest merge."

This reverts commit bf3aae233b8da1f9111a149a96d77cc78d376094.

* Removes dependency checks

* Fix dependency gen errors

* Reenable "Build Deb" step

* Reenable publish deb

* Run core integration tests

* Revert "Run core integration tests"

This reverts commit 7cafbada194feebe771862af796fb3416b5dd686.

* Revert "Try reverting minimist"

This reverts commit 38fd843c1d5c33318a92f4bbc7057e951c5a9f71.

* Disable code coverage step intermin

---------

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
Co-authored-by: Lewis Sanchez <87730006+lewis-sanchez@users.noreply.github.com>
2023-05-02 19:32:46 -07:00

131 lines
5.1 KiB
JavaScript

"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
const Vinyl = require("vinyl");
const through = require("through");
const builder = require("./builder");
const ts = require("typescript");
const stream_1 = require("stream");
const path_1 = require("path");
const utils_1 = require("./utils");
const fs_1 = require("fs");
const log = require("fancy-log");
const colors = require("ansi-colors");
const transpiler_1 = require("./transpiler");
class EmptyDuplex extends stream_1.Duplex {
_write(_chunk, _encoding, callback) { callback(); }
_read() { this.push(null); }
}
function createNullCompiler() {
const result = function () { return new EmptyDuplex(); };
result.src = () => new EmptyDuplex();
return result;
}
const _defaultOnError = (err) => console.log(JSON.stringify(err, null, 4));
function create(projectPath, existingOptions, config, onError = _defaultOnError) {
function printDiagnostic(diag) {
if (!diag.file || !diag.start) {
onError(ts.flattenDiagnosticMessageText(diag.messageText, '\n'));
}
else {
const lineAndCh = diag.file.getLineAndCharacterOfPosition(diag.start);
onError(utils_1.strings.format('{0}({1},{2}): {3}', diag.file.fileName, lineAndCh.line + 1, lineAndCh.character + 1, ts.flattenDiagnosticMessageText(diag.messageText, '\n')));
}
}
const parsed = ts.readConfigFile(projectPath, ts.sys.readFile);
if (parsed.error) {
printDiagnostic(parsed.error);
return createNullCompiler();
}
const cmdLine = ts.parseJsonConfigFileContent(parsed.config, ts.sys, (0, path_1.dirname)(projectPath), existingOptions);
if (cmdLine.errors.length > 0) {
cmdLine.errors.forEach(printDiagnostic);
return createNullCompiler();
}
function logFn(topic, message) {
if (config.verbose) {
log(colors.cyan(topic), message);
}
}
// FULL COMPILE stream doing transpile, syntax and semantic diagnostics
function createCompileStream(builder, token) {
return through(function (file) {
// give the file to the compiler
if (file.isStream()) {
this.emit('error', 'no support for streams');
return;
}
builder.file(file);
}, function () {
// start the compilation process
builder.build(file => this.queue(file), printDiagnostic, token).catch(e => console.error(e)).then(() => this.queue(null));
});
}
// TRANSPILE ONLY stream doing just TS to JS conversion
function createTranspileStream(transpiler) {
return through(function (file) {
// give the file to the compiler
if (file.isStream()) {
this.emit('error', 'no support for streams');
return;
}
if (!file.contents) {
return;
}
if (!config.transpileOnlyIncludesDts && file.path.endsWith('.d.ts')) {
return;
}
if (!transpiler.onOutfile) {
transpiler.onOutfile = file => this.queue(file);
}
transpiler.transpile(file);
}, function () {
transpiler.join().then(() => {
this.queue(null);
transpiler.onOutfile = undefined;
});
});
}
let result;
if (config.transpileOnly) {
const transpiler = new transpiler_1.Transpiler(logFn, printDiagnostic, projectPath, cmdLine);
result = (() => createTranspileStream(transpiler));
}
else {
const _builder = builder.createTypeScriptBuilder({ logFn }, projectPath, cmdLine);
result = ((token) => createCompileStream(_builder, token));
}
result.src = (opts) => {
let _pos = 0;
const _fileNames = cmdLine.fileNames.slice(0);
return new class extends stream_1.Readable {
constructor() {
super({ objectMode: true });
}
_read() {
let more = true;
let path;
for (; more && _pos < _fileNames.length; _pos++) {
path = _fileNames[_pos];
more = this.push(new Vinyl({
path,
contents: (0, fs_1.readFileSync)(path),
stat: (0, fs_1.statSync)(path),
cwd: opts && opts.cwd,
base: opts && opts.base || (0, path_1.dirname)(projectPath)
}));
}
if (_pos >= _fileNames.length) {
this.push(null);
}
}
};
};
return result;
}
exports.create = create;