build: switch `build/tsconfig.json` to `module: nodenext` (#238426)

* build/tsconfig: switch to module: nodenext for bun compat

* build: rewrite imports for nodenext compat

* build: re-generate
This commit is contained in:
Aman Karmani 2025-01-22 11:12:39 -08:00 committed by GitHub
parent 02ea21a23d
commit e76c50f20e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
122 changed files with 1907 additions and 1202 deletions

View File

@ -3,12 +3,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const crypto = require("crypto"); const crypto_1 = __importDefault(require("crypto"));
const productjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../product.json'), 'utf8')); const productjson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../../product.json'), 'utf8'));
const shasum = crypto.createHash('sha256'); const shasum = crypto_1.default.createHash('sha256');
for (const ext of productjson.builtInExtensions) { for (const ext of productjson.builtInExtensions) {
shasum.update(`${ext.name}@${ext.version}`); shasum.update(`${ext.name}@${ext.version}`);
} }

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as crypto from 'crypto'; import crypto from 'crypto';
const productjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../product.json'), 'utf8')); const productjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../product.json'), 'utf8'));
const shasum = crypto.createHash('sha256'); const shasum = crypto.createHash('sha256');

View File

@ -3,21 +3,24 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const crypto = require("crypto"); const crypto_1 = __importDefault(require("crypto"));
const { dirs } = require('../../npm/dirs'); const { dirs } = require('../../npm/dirs');
const ROOT = path.join(__dirname, '../../../'); const ROOT = path_1.default.join(__dirname, '../../../');
const shasum = crypto.createHash('sha256'); const shasum = crypto_1.default.createHash('sha256');
shasum.update(fs.readFileSync(path.join(ROOT, 'build/.cachesalt'))); shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, 'build/.cachesalt')));
shasum.update(fs.readFileSync(path.join(ROOT, '.npmrc'))); shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, '.npmrc')));
shasum.update(fs.readFileSync(path.join(ROOT, 'build', '.npmrc'))); shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, 'build', '.npmrc')));
shasum.update(fs.readFileSync(path.join(ROOT, 'remote', '.npmrc'))); shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, 'remote', '.npmrc')));
// Add `package.json` and `package-lock.json` files // Add `package.json` and `package-lock.json` files
for (const dir of dirs) { for (const dir of dirs) {
const packageJsonPath = path.join(ROOT, dir, 'package.json'); const packageJsonPath = path_1.default.join(ROOT, dir, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()); const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath).toString());
const relevantPackageJsonSections = { const relevantPackageJsonSections = {
dependencies: packageJson.dependencies, dependencies: packageJson.dependencies,
devDependencies: packageJson.devDependencies, devDependencies: packageJson.devDependencies,
@ -26,8 +29,8 @@ for (const dir of dirs) {
distro: packageJson.distro distro: packageJson.distro
}; };
shasum.update(JSON.stringify(relevantPackageJsonSections)); shasum.update(JSON.stringify(relevantPackageJsonSections));
const packageLockPath = path.join(ROOT, dir, 'package-lock.json'); const packageLockPath = path_1.default.join(ROOT, dir, 'package-lock.json');
shasum.update(fs.readFileSync(packageLockPath)); shasum.update(fs_1.default.readFileSync(packageLockPath));
} }
// Add any other command line arguments // Add any other command line arguments
for (let i = 2; i < process.argv.length; i++) { for (let i = 2; i < process.argv.length; i++) {

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as crypto from 'crypto'; import crypto from 'crypto';
const { dirs } = require('../../npm/dirs'); const { dirs } = require('../../npm/dirs');
const ROOT = path.join(__dirname, '../../../'); const ROOT = path.join(__dirname, '../../../');

View File

@ -3,16 +3,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
if (process.argv.length !== 3) { if (process.argv.length !== 3) {
console.error('Usage: node listNodeModules.js OUTPUT_FILE'); console.error('Usage: node listNodeModules.js OUTPUT_FILE');
process.exit(-1); process.exit(-1);
} }
const ROOT = path.join(__dirname, '../../../'); const ROOT = path_1.default.join(__dirname, '../../../');
function findNodeModulesFiles(location, inNodeModules, result) { function findNodeModulesFiles(location, inNodeModules, result) {
const entries = fs.readdirSync(path.join(ROOT, location)); const entries = fs_1.default.readdirSync(path_1.default.join(ROOT, location));
for (const entry of entries) { for (const entry of entries) {
const entryPath = `${location}/${entry}`; const entryPath = `${location}/${entry}`;
if (/(^\/out)|(^\/src$)|(^\/.git$)|(^\/.build$)/.test(entryPath)) { if (/(^\/out)|(^\/src$)|(^\/.git$)|(^\/.build$)/.test(entryPath)) {
@ -20,7 +23,7 @@ function findNodeModulesFiles(location, inNodeModules, result) {
} }
let stat; let stat;
try { try {
stat = fs.statSync(path.join(ROOT, entryPath)); stat = fs_1.default.statSync(path_1.default.join(ROOT, entryPath));
} }
catch (err) { catch (err) {
continue; continue;
@ -37,5 +40,5 @@ function findNodeModulesFiles(location, inNodeModules, result) {
} }
const result = []; const result = [];
findNodeModulesFiles('', false, result); findNodeModulesFiles('', false, result);
fs.writeFileSync(process.argv[2], result.join('\n') + '\n'); fs_1.default.writeFileSync(process.argv[2], result.join('\n') + '\n');
//# sourceMappingURL=listNodeModules.js.map //# sourceMappingURL=listNodeModules.js.map

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
if (process.argv.length !== 3) { if (process.argv.length !== 3) {
console.error('Usage: node listNodeModules.js OUTPUT_FILE'); console.error('Usage: node listNodeModules.js OUTPUT_FILE');

View File

@ -3,21 +3,57 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const stream_1 = require("stream"); const stream_1 = require("stream");
const promises_1 = require("node:stream/promises"); const promises_1 = require("node:stream/promises");
const yauzl = require("yauzl"); const yauzl_1 = __importDefault(require("yauzl"));
const crypto = require("crypto"); const crypto_1 = __importDefault(require("crypto"));
const retry_1 = require("./retry"); const retry_1 = require("./retry");
const cosmos_1 = require("@azure/cosmos"); const cosmos_1 = require("@azure/cosmos");
const cp = require("child_process"); const child_process_1 = __importDefault(require("child_process"));
const os = require("os"); const os_1 = __importDefault(require("os"));
const node_worker_threads_1 = require("node:worker_threads"); const node_worker_threads_1 = require("node:worker_threads");
const msal_node_1 = require("@azure/msal-node"); const msal_node_1 = require("@azure/msal-node");
const storage_blob_1 = require("@azure/storage-blob"); const storage_blob_1 = require("@azure/storage-blob");
const jws = require("jws"); const jws = __importStar(require("jws"));
const node_timers_1 = require("node:timers"); const node_timers_1 = require("node:timers");
function e(name) { function e(name) {
const result = process.env[name]; const result = process.env[name];
@ -28,7 +64,7 @@ function e(name) {
} }
function hashStream(hashName, stream) { function hashStream(hashName, stream) {
return new Promise((c, e) => { return new Promise((c, e) => {
const shasum = crypto.createHash(hashName); const shasum = crypto_1.default.createHash(hashName);
stream stream
.on('data', shasum.update.bind(shasum)) .on('data', shasum.update.bind(shasum))
.on('error', e) .on('error', e)
@ -50,38 +86,38 @@ function getCertificateBuffer(input) {
} }
function getThumbprint(input, algorithm) { function getThumbprint(input, algorithm) {
const buffer = getCertificateBuffer(input); const buffer = getCertificateBuffer(input);
return crypto.createHash(algorithm).update(buffer).digest(); return crypto_1.default.createHash(algorithm).update(buffer).digest();
} }
function getKeyFromPFX(pfx) { function getKeyFromPFX(pfx) {
const pfxCertificatePath = path.join(os.tmpdir(), 'cert.pfx'); const pfxCertificatePath = path_1.default.join(os_1.default.tmpdir(), 'cert.pfx');
const pemKeyPath = path.join(os.tmpdir(), 'key.pem'); const pemKeyPath = path_1.default.join(os_1.default.tmpdir(), 'key.pem');
try { try {
const pfxCertificate = Buffer.from(pfx, 'base64'); const pfxCertificate = Buffer.from(pfx, 'base64');
fs.writeFileSync(pfxCertificatePath, pfxCertificate); fs_1.default.writeFileSync(pfxCertificatePath, pfxCertificate);
cp.execSync(`openssl pkcs12 -in "${pfxCertificatePath}" -nocerts -nodes -out "${pemKeyPath}" -passin pass:`); child_process_1.default.execSync(`openssl pkcs12 -in "${pfxCertificatePath}" -nocerts -nodes -out "${pemKeyPath}" -passin pass:`);
const raw = fs.readFileSync(pemKeyPath, 'utf-8'); const raw = fs_1.default.readFileSync(pemKeyPath, 'utf-8');
const result = raw.match(/-----BEGIN PRIVATE KEY-----[\s\S]+?-----END PRIVATE KEY-----/g)[0]; const result = raw.match(/-----BEGIN PRIVATE KEY-----[\s\S]+?-----END PRIVATE KEY-----/g)[0];
return result; return result;
} }
finally { finally {
fs.rmSync(pfxCertificatePath, { force: true }); fs_1.default.rmSync(pfxCertificatePath, { force: true });
fs.rmSync(pemKeyPath, { force: true }); fs_1.default.rmSync(pemKeyPath, { force: true });
} }
} }
function getCertificatesFromPFX(pfx) { function getCertificatesFromPFX(pfx) {
const pfxCertificatePath = path.join(os.tmpdir(), 'cert.pfx'); const pfxCertificatePath = path_1.default.join(os_1.default.tmpdir(), 'cert.pfx');
const pemCertificatePath = path.join(os.tmpdir(), 'cert.pem'); const pemCertificatePath = path_1.default.join(os_1.default.tmpdir(), 'cert.pem');
try { try {
const pfxCertificate = Buffer.from(pfx, 'base64'); const pfxCertificate = Buffer.from(pfx, 'base64');
fs.writeFileSync(pfxCertificatePath, pfxCertificate); fs_1.default.writeFileSync(pfxCertificatePath, pfxCertificate);
cp.execSync(`openssl pkcs12 -in "${pfxCertificatePath}" -nokeys -out "${pemCertificatePath}" -passin pass:`); child_process_1.default.execSync(`openssl pkcs12 -in "${pfxCertificatePath}" -nokeys -out "${pemCertificatePath}" -passin pass:`);
const raw = fs.readFileSync(pemCertificatePath, 'utf-8'); const raw = fs_1.default.readFileSync(pemCertificatePath, 'utf-8');
const matches = raw.match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g); const matches = raw.match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g);
return matches ? matches.reverse() : []; return matches ? matches.reverse() : [];
} }
finally { finally {
fs.rmSync(pfxCertificatePath, { force: true }); fs_1.default.rmSync(pfxCertificatePath, { force: true });
fs.rmSync(pemCertificatePath, { force: true }); fs_1.default.rmSync(pemCertificatePath, { force: true });
} }
} }
class ESRPReleaseService { class ESRPReleaseService {
@ -122,7 +158,7 @@ class ESRPReleaseService {
this.containerClient = containerClient; this.containerClient = containerClient;
} }
async createRelease(version, filePath, friendlyFileName) { async createRelease(version, filePath, friendlyFileName) {
const correlationId = crypto.randomUUID(); const correlationId = crypto_1.default.randomUUID();
const blobClient = this.containerClient.getBlockBlobClient(correlationId); const blobClient = this.containerClient.getBlockBlobClient(correlationId);
this.log(`Uploading ${filePath} to ${blobClient.url}`); this.log(`Uploading ${filePath} to ${blobClient.url}`);
await blobClient.uploadFile(filePath); await blobClient.uploadFile(filePath);
@ -161,8 +197,8 @@ class ESRPReleaseService {
} }
} }
async submitRelease(version, filePath, friendlyFileName, correlationId, blobClient) { async submitRelease(version, filePath, friendlyFileName, correlationId, blobClient) {
const size = fs.statSync(filePath).size; const size = fs_1.default.statSync(filePath).size;
const hash = await hashStream('sha256', fs.createReadStream(filePath)); const hash = await hashStream('sha256', fs_1.default.createReadStream(filePath));
const message = { const message = {
customerCorrelationId: correlationId, customerCorrelationId: correlationId,
esrpCorrelationId: correlationId, esrpCorrelationId: correlationId,
@ -192,7 +228,7 @@ class ESRPReleaseService {
intent: 'filedownloadlinkgeneration' intent: 'filedownloadlinkgeneration'
}, },
files: [{ files: [{
name: path.basename(filePath), name: path_1.default.basename(filePath),
friendlyFileName, friendlyFileName,
tenantFileLocation: blobClient.url, tenantFileLocation: blobClient.url,
tenantFileLocationType: 'AzureBlob', tenantFileLocationType: 'AzureBlob',
@ -268,19 +304,19 @@ class State {
set = new Set(); set = new Set();
constructor() { constructor() {
const pipelineWorkspacePath = e('PIPELINE_WORKSPACE'); const pipelineWorkspacePath = e('PIPELINE_WORKSPACE');
const previousState = fs.readdirSync(pipelineWorkspacePath) const previousState = fs_1.default.readdirSync(pipelineWorkspacePath)
.map(name => /^artifacts_processed_(\d+)$/.exec(name)) .map(name => /^artifacts_processed_(\d+)$/.exec(name))
.filter((match) => !!match) .filter((match) => !!match)
.map(match => ({ name: match[0], attempt: Number(match[1]) })) .map(match => ({ name: match[0], attempt: Number(match[1]) }))
.sort((a, b) => b.attempt - a.attempt)[0]; .sort((a, b) => b.attempt - a.attempt)[0];
if (previousState) { if (previousState) {
const previousStatePath = path.join(pipelineWorkspacePath, previousState.name, previousState.name + '.txt'); const previousStatePath = path_1.default.join(pipelineWorkspacePath, previousState.name, previousState.name + '.txt');
fs.readFileSync(previousStatePath, 'utf8').split(/\n/).filter(name => !!name).forEach(name => this.set.add(name)); fs_1.default.readFileSync(previousStatePath, 'utf8').split(/\n/).filter(name => !!name).forEach(name => this.set.add(name));
} }
const stageAttempt = e('SYSTEM_STAGEATTEMPT'); const stageAttempt = e('SYSTEM_STAGEATTEMPT');
this.statePath = path.join(pipelineWorkspacePath, `artifacts_processed_${stageAttempt}`, `artifacts_processed_${stageAttempt}.txt`); this.statePath = path_1.default.join(pipelineWorkspacePath, `artifacts_processed_${stageAttempt}`, `artifacts_processed_${stageAttempt}.txt`);
fs.mkdirSync(path.dirname(this.statePath), { recursive: true }); fs_1.default.mkdirSync(path_1.default.dirname(this.statePath), { recursive: true });
fs.writeFileSync(this.statePath, [...this.set.values()].map(name => `${name}\n`).join('')); fs_1.default.writeFileSync(this.statePath, [...this.set.values()].map(name => `${name}\n`).join(''));
} }
get size() { get size() {
return this.set.size; return this.set.size;
@ -290,7 +326,7 @@ class State {
} }
add(name) { add(name) {
this.set.add(name); this.set.add(name);
fs.appendFileSync(this.statePath, `${name}\n`); fs_1.default.appendFileSync(this.statePath, `${name}\n`);
} }
[Symbol.iterator]() { [Symbol.iterator]() {
return this.set[Symbol.iterator](); return this.set[Symbol.iterator]();
@ -336,7 +372,7 @@ async function downloadArtifact(artifact, downloadPath) {
if (!res.ok) { if (!res.ok) {
throw new Error(`Unexpected status code: ${res.status}`); throw new Error(`Unexpected status code: ${res.status}`);
} }
await (0, promises_1.pipeline)(stream_1.Readable.fromWeb(res.body), fs.createWriteStream(downloadPath)); await (0, promises_1.pipeline)(stream_1.Readable.fromWeb(res.body), fs_1.default.createWriteStream(downloadPath));
} }
finally { finally {
clearTimeout(timeout); clearTimeout(timeout);
@ -344,7 +380,7 @@ async function downloadArtifact(artifact, downloadPath) {
} }
async function unzip(packagePath, outputPath) { async function unzip(packagePath, outputPath) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
yauzl.open(packagePath, { lazyEntries: true, autoClose: true }, (err, zipfile) => { yauzl_1.default.open(packagePath, { lazyEntries: true, autoClose: true }, (err, zipfile) => {
if (err) { if (err) {
return reject(err); return reject(err);
} }
@ -358,9 +394,9 @@ async function unzip(packagePath, outputPath) {
if (err) { if (err) {
return reject(err); return reject(err);
} }
const filePath = path.join(outputPath, entry.fileName); const filePath = path_1.default.join(outputPath, entry.fileName);
fs.mkdirSync(path.dirname(filePath), { recursive: true }); fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
const ostream = fs.createWriteStream(filePath); const ostream = fs_1.default.createWriteStream(filePath);
ostream.on('finish', () => { ostream.on('finish', () => {
result.push(filePath); result.push(filePath);
zipfile.readEntry(); zipfile.readEntry();
@ -523,7 +559,7 @@ async function processArtifact(artifact, filePath) {
const { cosmosDBAccessToken, blobServiceAccessToken } = JSON.parse(e('PUBLISH_AUTH_TOKENS')); const { cosmosDBAccessToken, blobServiceAccessToken } = JSON.parse(e('PUBLISH_AUTH_TOKENS'));
const quality = e('VSCODE_QUALITY'); const quality = e('VSCODE_QUALITY');
const version = e('BUILD_SOURCEVERSION'); const version = e('BUILD_SOURCEVERSION');
const friendlyFileName = `${quality}/${version}/${path.basename(filePath)}`; const friendlyFileName = `${quality}/${version}/${path_1.default.basename(filePath)}`;
const blobServiceClient = new storage_blob_1.BlobServiceClient(`https://${e('VSCODE_STAGING_BLOB_STORAGE_ACCOUNT_NAME')}.blob.core.windows.net/`, { getToken: async () => blobServiceAccessToken }); const blobServiceClient = new storage_blob_1.BlobServiceClient(`https://${e('VSCODE_STAGING_BLOB_STORAGE_ACCOUNT_NAME')}.blob.core.windows.net/`, { getToken: async () => blobServiceAccessToken });
const leasesContainerClient = blobServiceClient.getContainerClient('leases'); const leasesContainerClient = blobServiceClient.getContainerClient('leases');
await leasesContainerClient.createIfNotExists(); await leasesContainerClient.createIfNotExists();
@ -546,8 +582,8 @@ async function processArtifact(artifact, filePath) {
const isLegacy = artifact.name.includes('_legacy'); const isLegacy = artifact.name.includes('_legacy');
const platform = getPlatform(product, os, arch, unprocessedType, isLegacy); const platform = getPlatform(product, os, arch, unprocessedType, isLegacy);
const type = getRealType(unprocessedType); const type = getRealType(unprocessedType);
const size = fs.statSync(filePath).size; const size = fs_1.default.statSync(filePath).size;
const stream = fs.createReadStream(filePath); const stream = fs_1.default.createReadStream(filePath);
const [hash, sha256hash] = await Promise.all([hashStream('sha1', stream), hashStream('sha256', stream)]); // CodeQL [SM04514] Using SHA1 only for legacy reasons, we are actually only respecting SHA256 const [hash, sha256hash] = await Promise.all([hashStream('sha1', stream), hashStream('sha256', stream)]); // CodeQL [SM04514] Using SHA1 only for legacy reasons, we are actually only respecting SHA256
const asset = { platform, type, url, hash: hash.toString('hex'), sha256hash: sha256hash.toString('hex'), size, supportsFastUpdate: true }; const asset = { platform, type, url, hash: hash.toString('hex'), sha256hash: sha256hash.toString('hex'), size, supportsFastUpdate: true };
log('Creating asset...'); log('Creating asset...');
@ -627,12 +663,12 @@ async function main() {
continue; continue;
} }
console.log(`[${artifact.name}] Found new artifact`); console.log(`[${artifact.name}] Found new artifact`);
const artifactZipPath = path.join(e('AGENT_TEMPDIRECTORY'), `${artifact.name}.zip`); const artifactZipPath = path_1.default.join(e('AGENT_TEMPDIRECTORY'), `${artifact.name}.zip`);
await (0, retry_1.retry)(async (attempt) => { await (0, retry_1.retry)(async (attempt) => {
const start = Date.now(); const start = Date.now();
console.log(`[${artifact.name}] Downloading (attempt ${attempt})...`); console.log(`[${artifact.name}] Downloading (attempt ${attempt})...`);
await downloadArtifact(artifact, artifactZipPath); await downloadArtifact(artifact, artifactZipPath);
const archiveSize = fs.statSync(artifactZipPath).size; const archiveSize = fs_1.default.statSync(artifactZipPath).size;
const downloadDurationS = (Date.now() - start) / 1000; const downloadDurationS = (Date.now() - start) / 1000;
const downloadSpeedKBS = Math.round((archiveSize / 1024) / downloadDurationS); const downloadSpeedKBS = Math.round((archiveSize / 1024) / downloadDurationS);
console.log(`[${artifact.name}] Successfully downloaded after ${Math.floor(downloadDurationS)} seconds(${downloadSpeedKBS} KB/s).`); console.log(`[${artifact.name}] Successfully downloaded after ${Math.floor(downloadDurationS)} seconds(${downloadSpeedKBS} KB/s).`);

View File

@ -3,17 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import { Readable } from 'stream'; import { Readable } from 'stream';
import type { ReadableStream } from 'stream/web'; import type { ReadableStream } from 'stream/web';
import { pipeline } from 'node:stream/promises'; import { pipeline } from 'node:stream/promises';
import * as yauzl from 'yauzl'; import yauzl from 'yauzl';
import * as crypto from 'crypto'; import crypto from 'crypto';
import { retry } from './retry'; import { retry } from './retry';
import { CosmosClient } from '@azure/cosmos'; import { CosmosClient } from '@azure/cosmos';
import * as cp from 'child_process'; import cp from 'child_process';
import * as os from 'os'; import os from 'os';
import { Worker, isMainThread, workerData } from 'node:worker_threads'; import { Worker, isMainThread, workerData } from 'node:worker_threads';
import { ConfidentialClientApplication } from '@azure/msal-node'; import { ConfidentialClientApplication } from '@azure/msal-node';
import { BlobClient, BlobServiceClient, BlockBlobClient, ContainerClient } from '@azure/storage-blob'; import { BlobClient, BlobServiceClient, BlockBlobClient, ContainerClient } from '@azure/storage-blob';

View File

@ -3,13 +3,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const sign_1 = require("./sign"); const sign_1 = require("./sign");
const path = require("path"); const path_1 = __importDefault(require("path"));
(0, sign_1.main)([ (0, sign_1.main)([
process.env['EsrpCliDllPath'], process.env['EsrpCliDllPath'],
'sign-windows', 'sign-windows',
path.dirname(process.argv[2]), path_1.default.dirname(process.argv[2]),
path.basename(process.argv[2]) path_1.default.basename(process.argv[2])
]); ]);
//# sourceMappingURL=sign-win32.js.map //# sourceMappingURL=sign-win32.js.map

View File

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { main } from './sign'; import { main } from './sign';
import * as path from 'path'; import path from 'path';
main([ main([
process.env['EsrpCliDllPath']!, process.env['EsrpCliDllPath']!,

View File

@ -3,25 +3,28 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.Temp = void 0; exports.Temp = void 0;
exports.main = main; exports.main = main;
const cp = require("child_process"); const child_process_1 = __importDefault(require("child_process"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const crypto = require("crypto"); const crypto_1 = __importDefault(require("crypto"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const os = require("os"); const os_1 = __importDefault(require("os"));
class Temp { class Temp {
_files = []; _files = [];
tmpNameSync() { tmpNameSync() {
const file = path.join(os.tmpdir(), crypto.randomBytes(20).toString('hex')); const file = path_1.default.join(os_1.default.tmpdir(), crypto_1.default.randomBytes(20).toString('hex'));
this._files.push(file); this._files.push(file);
return file; return file;
} }
dispose() { dispose() {
for (const file of this._files) { for (const file of this._files) {
try { try {
fs.unlinkSync(file); fs_1.default.unlinkSync(file);
} }
catch (err) { catch (err) {
// noop // noop
@ -126,20 +129,20 @@ function getParams(type) {
function main([esrpCliPath, type, folderPath, pattern]) { function main([esrpCliPath, type, folderPath, pattern]) {
const tmp = new Temp(); const tmp = new Temp();
process.on('exit', () => tmp.dispose()); process.on('exit', () => tmp.dispose());
const key = crypto.randomBytes(32); const key = crypto_1.default.randomBytes(32);
const iv = crypto.randomBytes(16); const iv = crypto_1.default.randomBytes(16);
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); const cipher = crypto_1.default.createCipheriv('aes-256-cbc', key, iv);
const encryptedToken = cipher.update(process.env['SYSTEM_ACCESSTOKEN'].trim(), 'utf8', 'hex') + cipher.final('hex'); const encryptedToken = cipher.update(process.env['SYSTEM_ACCESSTOKEN'].trim(), 'utf8', 'hex') + cipher.final('hex');
const encryptionDetailsPath = tmp.tmpNameSync(); const encryptionDetailsPath = tmp.tmpNameSync();
fs.writeFileSync(encryptionDetailsPath, JSON.stringify({ key: key.toString('hex'), iv: iv.toString('hex') })); fs_1.default.writeFileSync(encryptionDetailsPath, JSON.stringify({ key: key.toString('hex'), iv: iv.toString('hex') }));
const encryptedTokenPath = tmp.tmpNameSync(); const encryptedTokenPath = tmp.tmpNameSync();
fs.writeFileSync(encryptedTokenPath, encryptedToken); fs_1.default.writeFileSync(encryptedTokenPath, encryptedToken);
const patternPath = tmp.tmpNameSync(); const patternPath = tmp.tmpNameSync();
fs.writeFileSync(patternPath, pattern); fs_1.default.writeFileSync(patternPath, pattern);
const paramsPath = tmp.tmpNameSync(); const paramsPath = tmp.tmpNameSync();
fs.writeFileSync(paramsPath, JSON.stringify(getParams(type))); fs_1.default.writeFileSync(paramsPath, JSON.stringify(getParams(type)));
const dotnetVersion = cp.execSync('dotnet --version', { encoding: 'utf8' }).trim(); const dotnetVersion = child_process_1.default.execSync('dotnet --version', { encoding: 'utf8' }).trim();
const adoTaskVersion = path.basename(path.dirname(path.dirname(esrpCliPath))); const adoTaskVersion = path_1.default.basename(path_1.default.dirname(path_1.default.dirname(esrpCliPath)));
const federatedTokenData = { const federatedTokenData = {
jobId: process.env['SYSTEM_JOBID'], jobId: process.env['SYSTEM_JOBID'],
planId: process.env['SYSTEM_PLANID'], planId: process.env['SYSTEM_PLANID'],
@ -149,7 +152,7 @@ function main([esrpCliPath, type, folderPath, pattern]) {
managedIdentityId: process.env['VSCODE_ESRP_CLIENT_ID'], managedIdentityId: process.env['VSCODE_ESRP_CLIENT_ID'],
managedIdentityTenantId: process.env['VSCODE_ESRP_TENANT_ID'], managedIdentityTenantId: process.env['VSCODE_ESRP_TENANT_ID'],
serviceConnectionId: process.env['VSCODE_ESRP_SERVICE_CONNECTION_ID'], serviceConnectionId: process.env['VSCODE_ESRP_SERVICE_CONNECTION_ID'],
tempDirectory: os.tmpdir(), tempDirectory: os_1.default.tmpdir(),
systemAccessToken: encryptedTokenPath, systemAccessToken: encryptedTokenPath,
encryptionKey: encryptionDetailsPath encryptionKey: encryptionDetailsPath
}; };
@ -188,7 +191,7 @@ function main([esrpCliPath, type, folderPath, pattern]) {
'-federatedTokenData', JSON.stringify(federatedTokenData) '-federatedTokenData', JSON.stringify(federatedTokenData)
]; ];
try { try {
cp.execFileSync('dotnet', args, { stdio: 'inherit' }); child_process_1.default.execFileSync('dotnet', args, { stdio: 'inherit' });
} }
catch (err) { catch (err) {
console.error('ESRP failed'); console.error('ESRP failed');

View File

@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process'; import cp from 'child_process';
import * as fs from 'fs'; import fs from 'fs';
import * as crypto from 'crypto'; import crypto from 'crypto';
import * as path from 'path'; import path from 'path';
import * as os from 'os'; import os from 'os';
export class Temp { export class Temp {
private _files: string[] = []; private _files: string[] = [];

View File

@ -3,24 +3,27 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const { dirs } = require('../../npm/dirs'); const { dirs } = require('../../npm/dirs');
function log(...args) { function log(...args) {
console.log(`[${new Date().toLocaleTimeString('en', { hour12: false })}]`, '[distro]', ...args); console.log(`[${new Date().toLocaleTimeString('en', { hour12: false })}]`, '[distro]', ...args);
} }
function mixin(mixinPath) { function mixin(mixinPath) {
if (!fs.existsSync(`${mixinPath}/node_modules`)) { if (!fs_1.default.existsSync(`${mixinPath}/node_modules`)) {
log(`Skipping distro npm dependencies: ${mixinPath} (no node_modules)`); log(`Skipping distro npm dependencies: ${mixinPath} (no node_modules)`);
return; return;
} }
log(`Mixing in distro npm dependencies: ${mixinPath}`); log(`Mixing in distro npm dependencies: ${mixinPath}`);
const distroPackageJson = JSON.parse(fs.readFileSync(`${mixinPath}/package.json`, 'utf8')); const distroPackageJson = JSON.parse(fs_1.default.readFileSync(`${mixinPath}/package.json`, 'utf8'));
const targetPath = path.relative('.build/distro/npm', mixinPath); const targetPath = path_1.default.relative('.build/distro/npm', mixinPath);
for (const dependency of Object.keys(distroPackageJson.dependencies)) { for (const dependency of Object.keys(distroPackageJson.dependencies)) {
fs.rmSync(`./${targetPath}/node_modules/${dependency}`, { recursive: true, force: true }); fs_1.default.rmSync(`./${targetPath}/node_modules/${dependency}`, { recursive: true, force: true });
fs.cpSync(`${mixinPath}/node_modules/${dependency}`, `./${targetPath}/node_modules/${dependency}`, { recursive: true, force: true, dereference: true }); fs_1.default.cpSync(`${mixinPath}/node_modules/${dependency}`, `./${targetPath}/node_modules/${dependency}`, { recursive: true, force: true, dereference: true });
} }
log(`Mixed in distro npm dependencies: ${mixinPath} ✔︎`); log(`Mixed in distro npm dependencies: ${mixinPath} ✔︎`);
} }

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
const { dirs } = require('../../npm/dirs') as { dirs: string[] }; const { dirs } = require('../../npm/dirs') as { dirs: string[] };
function log(...args: any[]): void { function log(...args: any[]): void {

View File

@ -3,9 +3,12 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
function log(...args) { function log(...args) {
console.log(`[${new Date().toLocaleTimeString('en', { hour12: false })}]`, '[distro]', ...args); console.log(`[${new Date().toLocaleTimeString('en', { hour12: false })}]`, '[distro]', ...args);
} }
@ -16,12 +19,12 @@ function main() {
} }
log(`Mixing in distro quality...`); log(`Mixing in distro quality...`);
const basePath = `.build/distro/mixin/${quality}`; const basePath = `.build/distro/mixin/${quality}`;
for (const name of fs.readdirSync(basePath)) { for (const name of fs_1.default.readdirSync(basePath)) {
const distroPath = path.join(basePath, name); const distroPath = path_1.default.join(basePath, name);
const ossPath = path.relative(basePath, distroPath); const ossPath = path_1.default.relative(basePath, distroPath);
if (ossPath === 'product.json') { if (ossPath === 'product.json') {
const distro = JSON.parse(fs.readFileSync(distroPath, 'utf8')); const distro = JSON.parse(fs_1.default.readFileSync(distroPath, 'utf8'));
const oss = JSON.parse(fs.readFileSync(ossPath, 'utf8')); const oss = JSON.parse(fs_1.default.readFileSync(ossPath, 'utf8'));
let builtInExtensions = oss.builtInExtensions; let builtInExtensions = oss.builtInExtensions;
if (Array.isArray(distro.builtInExtensions)) { if (Array.isArray(distro.builtInExtensions)) {
log('Overwriting built-in extensions:', distro.builtInExtensions.map(e => e.name)); log('Overwriting built-in extensions:', distro.builtInExtensions.map(e => e.name));
@ -41,10 +44,10 @@ function main() {
log('Inheriting OSS built-in extensions', builtInExtensions.map(e => e.name)); log('Inheriting OSS built-in extensions', builtInExtensions.map(e => e.name));
} }
const result = { webBuiltInExtensions: oss.webBuiltInExtensions, ...distro, builtInExtensions }; const result = { webBuiltInExtensions: oss.webBuiltInExtensions, ...distro, builtInExtensions };
fs.writeFileSync(ossPath, JSON.stringify(result, null, '\t'), 'utf8'); fs_1.default.writeFileSync(ossPath, JSON.stringify(result, null, '\t'), 'utf8');
} }
else { else {
fs.cpSync(distroPath, ossPath, { force: true, recursive: true }); fs_1.default.cpSync(distroPath, ossPath, { force: true, recursive: true });
} }
log(distroPath, '✔︎'); log(distroPath, '✔︎');
} }

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
interface IBuiltInExtension { interface IBuiltInExtension {
readonly name: string; readonly name: string;

View File

@ -3,11 +3,14 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const cp = require("child_process"); const child_process_1 = __importDefault(require("child_process"));
let tag = ''; let tag = '';
try { try {
tag = cp tag = child_process_1.default
.execSync('git describe --tags `git rev-list --tags --max-count=1`') .execSync('git describe --tags `git rev-list --tags --max-count=1`')
.toString() .toString()
.trim(); .trim();

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process'; import cp from 'child_process';
let tag = ''; let tag = '';
try { try {

View File

@ -3,19 +3,22 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const cp = require("child_process"); const child_process_1 = __importDefault(require("child_process"));
const path = require("path"); const path_1 = __importDefault(require("path"));
let tag = ''; let tag = '';
try { try {
tag = cp tag = child_process_1.default
.execSync('git describe --tags `git rev-list --tags --max-count=1`') .execSync('git describe --tags `git rev-list --tags --max-count=1`')
.toString() .toString()
.trim(); .trim();
const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vscode-dts/vscode.d.ts`; const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vscode-dts/vscode.d.ts`;
const outPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts'); const outPath = path_1.default.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts');
cp.execSync(`curl ${dtsUri} --output ${outPath}`); child_process_1.default.execSync(`curl ${dtsUri} --output ${outPath}`);
updateDTSFile(outPath, tag); updateDTSFile(outPath, tag);
console.log(`Done updating vscode.d.ts at ${outPath}`); console.log(`Done updating vscode.d.ts at ${outPath}`);
} }
@ -25,9 +28,9 @@ catch (err) {
process.exit(1); process.exit(1);
} }
function updateDTSFile(outPath, tag) { function updateDTSFile(outPath, tag) {
const oldContent = fs.readFileSync(outPath, 'utf-8'); const oldContent = fs_1.default.readFileSync(outPath, 'utf-8');
const newContent = getNewFileContent(oldContent, tag); const newContent = getNewFileContent(oldContent, tag);
fs.writeFileSync(outPath, newContent); fs_1.default.writeFileSync(outPath, newContent);
} }
function repeat(str, times) { function repeat(str, times) {
const result = new Array(times); const result = new Array(times);

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as cp from 'child_process'; import cp from 'child_process';
import * as path from 'path'; import path from 'path';
let tag = ''; let tag = '';
try { try {

View File

@ -3,13 +3,49 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const es = require("event-stream"); const es = __importStar(require("event-stream"));
const Vinyl = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const vfs = require("vinyl-fs"); const vfs = __importStar(require("vinyl-fs"));
const filter = require("gulp-filter"); const gulp_filter_1 = __importDefault(require("gulp-filter"));
const gzip = require("gulp-gzip"); const gulp_gzip_1 = __importDefault(require("gulp-gzip"));
const mime = require("mime"); const mime = __importStar(require("mime"));
const identity_1 = require("@azure/identity"); const identity_1 = require("@azure/identity");
const azure = require('gulp-azure-storage'); const azure = require('gulp-azure-storage');
const commit = process.env['BUILD_SOURCEVERSION']; const commit = process.env['BUILD_SOURCEVERSION'];
@ -83,13 +119,13 @@ async function main() {
} }
}); });
const all = vfs.src('**', { cwd: '../vscode-web', base: '../vscode-web', dot: true }) const all = vfs.src('**', { cwd: '../vscode-web', base: '../vscode-web', dot: true })
.pipe(filter(f => !f.isDirectory())); .pipe((0, gulp_filter_1.default)(f => !f.isDirectory()));
const compressed = all const compressed = all
.pipe(filter(f => MimeTypesToCompress.has(mime.lookup(f.path)))) .pipe((0, gulp_filter_1.default)(f => MimeTypesToCompress.has(mime.lookup(f.path))))
.pipe(gzip({ append: false })) .pipe((0, gulp_gzip_1.default)({ append: false }))
.pipe(azure.upload(options(true))); .pipe(azure.upload(options(true)));
const uncompressed = all const uncompressed = all
.pipe(filter(f => !MimeTypesToCompress.has(mime.lookup(f.path)))) .pipe((0, gulp_filter_1.default)(f => !MimeTypesToCompress.has(mime.lookup(f.path))))
.pipe(azure.upload(options(false))); .pipe(azure.upload(options(false)));
const out = es.merge(compressed, uncompressed) const out = es.merge(compressed, uncompressed)
.pipe(es.through(function (f) { .pipe(es.through(function (f) {
@ -99,13 +135,13 @@ async function main() {
})); }));
console.log(`Uploading files to CDN...`); // debug console.log(`Uploading files to CDN...`); // debug
await wait(out); await wait(out);
const listing = new Vinyl({ const listing = new vinyl_1.default({
path: 'files.txt', path: 'files.txt',
contents: Buffer.from(files.join('\n')), contents: Buffer.from(files.join('\n')),
stat: { mode: 0o666 } stat: { mode: 0o666 }
}); });
const filesOut = es.readArray([listing]) const filesOut = es.readArray([listing])
.pipe(gzip({ append: false })) .pipe((0, gulp_gzip_1.default)({ append: false }))
.pipe(azure.upload(options(true))); .pipe(azure.upload(options(true)));
console.log(`Uploading: files.txt (${files.length} files)`); // debug console.log(`Uploading: files.txt (${files.length} files)`); // debug
await wait(filesOut); await wait(filesOut);

View File

@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import * as es from 'event-stream';
import * as Vinyl from 'vinyl'; import Vinyl from 'vinyl';
import * as vfs from 'vinyl-fs'; import * as vfs from 'vinyl-fs';
import * as filter from 'gulp-filter'; import filter from 'gulp-filter';
import * as gzip from 'gulp-gzip'; import gzip from 'gulp-gzip';
import * as mime from 'mime'; import * as mime from 'mime';
import { ClientAssertionCredential } from '@azure/identity'; import { ClientAssertionCredential } from '@azure/identity';
const azure = require('gulp-azure-storage'); const azure = require('gulp-azure-storage');

View File

@ -3,11 +3,47 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const es = require("event-stream"); const es = __importStar(require("event-stream"));
const vfs = require("vinyl-fs"); const vfs = __importStar(require("vinyl-fs"));
const merge = require("gulp-merge-json"); const gulp_merge_json_1 = __importDefault(require("gulp-merge-json"));
const gzip = require("gulp-gzip"); const gulp_gzip_1 = __importDefault(require("gulp-gzip"));
const identity_1 = require("@azure/identity"); const identity_1 = require("@azure/identity");
const path = require("path"); const path = require("path");
const fs_1 = require("fs"); const fs_1 = require("fs");
@ -21,7 +57,7 @@ function main() {
// it includes metadata for translators for `keys`. but for our purpose // it includes metadata for translators for `keys`. but for our purpose
// we want only the `keys` and `messages` as `string`. // we want only the `keys` and `messages` as `string`.
es.merge(vfs.src('out-build/nls.keys.json', { base: 'out-build' }), vfs.src('out-build/nls.messages.json', { base: 'out-build' })) es.merge(vfs.src('out-build/nls.keys.json', { base: 'out-build' }), vfs.src('out-build/nls.messages.json', { base: 'out-build' }))
.pipe(merge({ .pipe((0, gulp_merge_json_1.default)({
fileName: 'vscode.json', fileName: 'vscode.json',
jsonSpace: '', jsonSpace: '',
concatArrays: true, concatArrays: true,
@ -37,7 +73,7 @@ function main() {
} }
})), })),
// extensions // extensions
vfs.src('.build/extensions/**/nls.metadata.json', { base: '.build/extensions' }), vfs.src('.build/extensions/**/nls.metadata.header.json', { base: '.build/extensions' }), vfs.src('.build/extensions/**/package.nls.json', { base: '.build/extensions' })).pipe(merge({ vfs.src('.build/extensions/**/nls.metadata.json', { base: '.build/extensions' }), vfs.src('.build/extensions/**/nls.metadata.header.json', { base: '.build/extensions' }), vfs.src('.build/extensions/**/package.nls.json', { base: '.build/extensions' })).pipe((0, gulp_merge_json_1.default)({
fileName: 'combined.nls.metadata.json', fileName: 'combined.nls.metadata.json',
jsonSpace: '', jsonSpace: '',
concatArrays: true, concatArrays: true,
@ -95,7 +131,7 @@ function main() {
})); }));
const nlsMessagesJs = vfs.src('out-build/nls.messages.js', { base: 'out-build' }); const nlsMessagesJs = vfs.src('out-build/nls.messages.js', { base: 'out-build' });
es.merge(combinedMetadataJson, nlsMessagesJs) es.merge(combinedMetadataJson, nlsMessagesJs)
.pipe(gzip({ append: false })) .pipe((0, gulp_gzip_1.default)({ append: false }))
.pipe(vfs.dest('./nlsMetadata')) .pipe(vfs.dest('./nlsMetadata'))
.pipe(es.through(function (data) { .pipe(es.through(function (data) {
console.log(`Uploading ${data.path}`); console.log(`Uploading ${data.path}`);

View File

@ -6,8 +6,8 @@
import * as es from 'event-stream'; import * as es from 'event-stream';
import * as Vinyl from 'vinyl'; import * as Vinyl from 'vinyl';
import * as vfs from 'vinyl-fs'; import * as vfs from 'vinyl-fs';
import * as merge from 'gulp-merge-json'; import merge from 'gulp-merge-json';
import * as gzip from 'gulp-gzip'; import gzip from 'gulp-gzip';
import { ClientAssertionCredential } from '@azure/identity'; import { ClientAssertionCredential } from '@azure/identity';
import path = require('path'); import path = require('path');
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';

View File

@ -3,23 +3,59 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path"); const path_1 = __importDefault(require("path"));
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const vfs = require("vinyl-fs"); const vinyl_fs_1 = __importDefault(require("vinyl-fs"));
const util = require("../lib/util"); const util = __importStar(require("../lib/util"));
// @ts-ignore // @ts-ignore
const deps = require("../lib/dependencies"); const deps = __importStar(require("../lib/dependencies"));
const identity_1 = require("@azure/identity"); const identity_1 = require("@azure/identity");
const azure = require('gulp-azure-storage'); const azure = require('gulp-azure-storage');
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
const commit = process.env['BUILD_SOURCEVERSION']; const commit = process.env['BUILD_SOURCEVERSION'];
const credential = new identity_1.ClientAssertionCredential(process.env['AZURE_TENANT_ID'], process.env['AZURE_CLIENT_ID'], () => Promise.resolve(process.env['AZURE_ID_TOKEN'])); const credential = new identity_1.ClientAssertionCredential(process.env['AZURE_TENANT_ID'], process.env['AZURE_CLIENT_ID'], () => Promise.resolve(process.env['AZURE_ID_TOKEN']));
// optionally allow to pass in explicit base/maps to upload // optionally allow to pass in explicit base/maps to upload
const [, , base, maps] = process.argv; const [, , base, maps] = process.argv;
function src(base, maps = `${base}/**/*.map`) { function src(base, maps = `${base}/**/*.map`) {
return vfs.src(maps, { base }) return vinyl_fs_1.default.src(maps, { base })
.pipe(es.mapSync((f) => { .pipe(event_stream_1.default.mapSync((f) => {
f.path = `${f.base}/core/${f.relative}`; f.path = `${f.base}/core/${f.relative}`;
return f; return f;
})); }));
@ -31,12 +67,12 @@ function main() {
const vs = src('out-vscode-min'); // client source-maps only const vs = src('out-vscode-min'); // client source-maps only
sources.push(vs); sources.push(vs);
const productionDependencies = deps.getProductionDependencies(root); const productionDependencies = deps.getProductionDependencies(root);
const productionDependenciesSrc = productionDependencies.map(d => path.relative(root, d)).map(d => `./${d}/**/*.map`); const productionDependenciesSrc = productionDependencies.map(d => path_1.default.relative(root, d)).map(d => `./${d}/**/*.map`);
const nodeModules = vfs.src(productionDependenciesSrc, { base: '.' }) const nodeModules = vinyl_fs_1.default.src(productionDependenciesSrc, { base: '.' })
.pipe(util.cleanNodeModules(path.join(root, 'build', '.moduleignore'))) .pipe(util.cleanNodeModules(path_1.default.join(root, 'build', '.moduleignore')))
.pipe(util.cleanNodeModules(path.join(root, 'build', `.moduleignore.${process.platform}`))); .pipe(util.cleanNodeModules(path_1.default.join(root, 'build', `.moduleignore.${process.platform}`)));
sources.push(nodeModules); sources.push(nodeModules);
const extensionsOut = vfs.src(['.build/extensions/**/*.js.map', '!**/node_modules/**'], { base: '.build' }); const extensionsOut = vinyl_fs_1.default.src(['.build/extensions/**/*.js.map', '!**/node_modules/**'], { base: '.build' });
sources.push(extensionsOut); sources.push(extensionsOut);
} }
// specific client base/maps // specific client base/maps
@ -44,8 +80,8 @@ function main() {
sources.push(src(base, maps)); sources.push(src(base, maps));
} }
return new Promise((c, e) => { return new Promise((c, e) => {
es.merge(...sources) event_stream_1.default.merge(...sources)
.pipe(es.through(function (data) { .pipe(event_stream_1.default.through(function (data) {
console.log('Uploading Sourcemap', data.relative); // debug console.log('Uploading Sourcemap', data.relative); // debug
this.emit('data', data); this.emit('data', data);
})) }))

View File

@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as es from 'event-stream'; import es from 'event-stream';
import * as Vinyl from 'vinyl'; import Vinyl from 'vinyl';
import * as vfs from 'vinyl-fs'; import vfs from 'vinyl-fs';
import * as util from '../lib/util'; import * as util from '../lib/util';
// @ts-ignore // @ts-ignore
import * as deps from '../lib/dependencies'; import * as deps from '../lib/dependencies';

View File

@ -3,24 +3,27 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path"); const path_1 = __importDefault(require("path"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const minimatch = require("minimatch"); const minimatch_1 = __importDefault(require("minimatch"));
const vscode_universal_bundler_1 = require("vscode-universal-bundler"); const vscode_universal_bundler_1 = require("vscode-universal-bundler");
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
async function main(buildDir) { async function main(buildDir) {
const arch = process.env['VSCODE_ARCH']; const arch = process.env['VSCODE_ARCH'];
if (!buildDir) { if (!buildDir) {
throw new Error('Build dir not provided'); throw new Error('Build dir not provided');
} }
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8')); const product = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'product.json'), 'utf8'));
const appName = product.nameLong + '.app'; const appName = product.nameLong + '.app';
const x64AppPath = path.join(buildDir, 'VSCode-darwin-x64', appName); const x64AppPath = path_1.default.join(buildDir, 'VSCode-darwin-x64', appName);
const arm64AppPath = path.join(buildDir, 'VSCode-darwin-arm64', appName); const arm64AppPath = path_1.default.join(buildDir, 'VSCode-darwin-arm64', appName);
const asarRelativePath = path.join('Contents', 'Resources', 'app', 'node_modules.asar'); const asarRelativePath = path_1.default.join('Contents', 'Resources', 'app', 'node_modules.asar');
const outAppPath = path.join(buildDir, `VSCode-darwin-${arch}`, appName); const outAppPath = path_1.default.join(buildDir, `VSCode-darwin-${arch}`, appName);
const productJsonPath = path.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json'); const productJsonPath = path_1.default.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json');
const filesToSkip = [ const filesToSkip = [
'**/CodeResources', '**/CodeResources',
'**/Credits.rtf', '**/Credits.rtf',
@ -37,18 +40,18 @@ async function main(buildDir) {
x64ArchFiles: '*/kerberos.node', x64ArchFiles: '*/kerberos.node',
filesToSkipComparison: (file) => { filesToSkipComparison: (file) => {
for (const expected of filesToSkip) { for (const expected of filesToSkip) {
if (minimatch(file, expected)) { if ((0, minimatch_1.default)(file, expected)) {
return true; return true;
} }
} }
return false; return false;
} }
}); });
const productJson = JSON.parse(fs.readFileSync(productJsonPath, 'utf8')); const productJson = JSON.parse(fs_1.default.readFileSync(productJsonPath, 'utf8'));
Object.assign(productJson, { Object.assign(productJson, {
darwinUniversalAssetId: 'darwin-universal' darwinUniversalAssetId: 'darwin-universal'
}); });
fs.writeFileSync(productJsonPath, JSON.stringify(productJson, null, '\t')); fs_1.default.writeFileSync(productJsonPath, JSON.stringify(productJson, null, '\t'));
} }
if (require.main === module) { if (require.main === module) {
main(process.argv[2]).catch(err => { main(process.argv[2]).catch(err => {

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as fs from 'fs'; import fs from 'fs';
import * as minimatch from 'minimatch'; import minimatch from 'minimatch';
import { makeUniversalApp } from 'vscode-universal-bundler'; import { makeUniversalApp } from 'vscode-universal-bundler';
const root = path.dirname(path.dirname(__dirname)); const root = path.dirname(path.dirname(__dirname));

View File

@ -3,14 +3,17 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const codesign = require("electron-osx-sign"); const electron_osx_sign_1 = __importDefault(require("electron-osx-sign"));
const cross_spawn_promise_1 = require("@malept/cross-spawn-promise"); const cross_spawn_promise_1 = require("@malept/cross-spawn-promise");
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
function getElectronVersion() { function getElectronVersion() {
const npmrc = fs.readFileSync(path.join(root, '.npmrc'), 'utf8'); const npmrc = fs_1.default.readFileSync(path_1.default.join(root, '.npmrc'), 'utf8');
const target = /^target="(.*)"$/m.exec(npmrc)[1]; const target = /^target="(.*)"$/m.exec(npmrc)[1];
return target; return target;
} }
@ -24,25 +27,25 @@ async function main(buildDir) {
if (!tempDir) { if (!tempDir) {
throw new Error('$AGENT_TEMPDIRECTORY not set'); throw new Error('$AGENT_TEMPDIRECTORY not set');
} }
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8')); const product = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'product.json'), 'utf8'));
const baseDir = path.dirname(__dirname); const baseDir = path_1.default.dirname(__dirname);
const appRoot = path.join(buildDir, `VSCode-darwin-${arch}`); const appRoot = path_1.default.join(buildDir, `VSCode-darwin-${arch}`);
const appName = product.nameLong + '.app'; const appName = product.nameLong + '.app';
const appFrameworkPath = path.join(appRoot, appName, 'Contents', 'Frameworks'); const appFrameworkPath = path_1.default.join(appRoot, appName, 'Contents', 'Frameworks');
const helperAppBaseName = product.nameShort; const helperAppBaseName = product.nameShort;
const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app'; const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app';
const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app'; const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app';
const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app'; const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app';
const infoPlistPath = path.resolve(appRoot, appName, 'Contents', 'Info.plist'); const infoPlistPath = path_1.default.resolve(appRoot, appName, 'Contents', 'Info.plist');
const defaultOpts = { const defaultOpts = {
app: path.join(appRoot, appName), app: path_1.default.join(appRoot, appName),
platform: 'darwin', platform: 'darwin',
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'app-entitlements.plist'), entitlements: path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'app-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'app-entitlements.plist'), 'entitlements-inherit': path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'app-entitlements.plist'),
hardenedRuntime: true, hardenedRuntime: true,
'pre-auto-entitlements': false, 'pre-auto-entitlements': false,
'pre-embed-provisioning-profile': false, 'pre-embed-provisioning-profile': false,
keychain: path.join(tempDir, 'buildagent.keychain'), keychain: path_1.default.join(tempDir, 'buildagent.keychain'),
version: getElectronVersion(), version: getElectronVersion(),
identity, identity,
'gatekeeper-assess': false 'gatekeeper-assess': false
@ -58,21 +61,21 @@ async function main(buildDir) {
}; };
const gpuHelperOpts = { const gpuHelperOpts = {
...defaultOpts, ...defaultOpts,
app: path.join(appFrameworkPath, gpuHelperAppName), app: path_1.default.join(appFrameworkPath, gpuHelperAppName),
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'), entitlements: path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'), 'entitlements-inherit': path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'),
}; };
const rendererHelperOpts = { const rendererHelperOpts = {
...defaultOpts, ...defaultOpts,
app: path.join(appFrameworkPath, rendererHelperAppName), app: path_1.default.join(appFrameworkPath, rendererHelperAppName),
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'), entitlements: path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'), 'entitlements-inherit': path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'),
}; };
const pluginHelperOpts = { const pluginHelperOpts = {
...defaultOpts, ...defaultOpts,
app: path.join(appFrameworkPath, pluginHelperAppName), app: path_1.default.join(appFrameworkPath, pluginHelperAppName),
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'), entitlements: path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'), 'entitlements-inherit': path_1.default.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'),
}; };
// Only overwrite plist entries for x64 and arm64 builds, // Only overwrite plist entries for x64 and arm64 builds,
// universal will get its copy from the x64 build. // universal will get its copy from the x64 build.
@ -99,10 +102,10 @@ async function main(buildDir) {
`${infoPlistPath}` `${infoPlistPath}`
]); ]);
} }
await codesign.signAsync(gpuHelperOpts); await electron_osx_sign_1.default.signAsync(gpuHelperOpts);
await codesign.signAsync(rendererHelperOpts); await electron_osx_sign_1.default.signAsync(rendererHelperOpts);
await codesign.signAsync(pluginHelperOpts); await electron_osx_sign_1.default.signAsync(pluginHelperOpts);
await codesign.signAsync(appOpts); await electron_osx_sign_1.default.signAsync(appOpts);
} }
if (require.main === module) { if (require.main === module) {
main(process.argv[2]).catch(err => { main(process.argv[2]).catch(err => {

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as codesign from 'electron-osx-sign'; import codesign from 'electron-osx-sign';
import { spawn } from '@malept/cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
const root = path.dirname(path.dirname(__dirname)); const root = path.dirname(path.dirname(__dirname));

View File

@ -3,9 +3,45 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert"); const assert_1 = __importDefault(require("assert"));
const path = require("path"); const path = __importStar(require("path"));
const promises_1 = require("fs/promises"); const promises_1 = require("fs/promises");
const cross_spawn_promise_1 = require("@malept/cross-spawn-promise"); const cross_spawn_promise_1 = require("@malept/cross-spawn-promise");
const MACHO_PREFIX = 'Mach-O '; const MACHO_PREFIX = 'Mach-O ';
@ -78,7 +114,7 @@ async function checkMachOFiles(appPath, arch) {
} }
else if (header_magic === MACHO_UNIVERSAL_MAGIC_LE) { else if (header_magic === MACHO_UNIVERSAL_MAGIC_LE) {
const num_binaries = header.readUInt32BE(4); const num_binaries = header.readUInt32BE(4);
assert.equal(num_binaries, 2); assert_1.default.equal(num_binaries, 2);
const file_entries_size = file_header_entry_size * num_binaries; const file_entries_size = file_header_entry_size * num_binaries;
const file_entries = Buffer.alloc(file_entries_size); const file_entries = Buffer.alloc(file_entries_size);
read(p, file_entries, 0, file_entries_size, 8).then(_ => { read(p, file_entries, 0, file_entries_size, 8).then(_ => {
@ -103,8 +139,8 @@ async function checkMachOFiles(appPath, arch) {
return invalidFiles; return invalidFiles;
} }
const archToCheck = process.argv[2]; const archToCheck = process.argv[2];
assert(process.env['APP_PATH'], 'APP_PATH not set'); (0, assert_1.default)(process.env['APP_PATH'], 'APP_PATH not set');
assert(archToCheck === 'x64' || archToCheck === 'arm64' || archToCheck === 'universal', `Invalid architecture ${archToCheck} to check`); (0, assert_1.default)(archToCheck === 'x64' || archToCheck === 'arm64' || archToCheck === 'universal', `Invalid architecture ${archToCheck} to check`);
checkMachOFiles(process.env['APP_PATH'], archToCheck).then(invalidFiles => { checkMachOFiles(process.env['APP_PATH'], archToCheck).then(invalidFiles => {
if (invalidFiles.length > 0) { if (invalidFiles.length > 0) {
console.error('\x1b[31mThe following files are built for the wrong architecture:\x1b[0m'); console.error('\x1b[31mThe following files are built for the wrong architecture:\x1b[0m');

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import assert from 'assert';
import * as path from 'path'; import * as path from 'path';
import { open, stat, readdir, realpath } from 'fs/promises'; import { open, stat, readdir, realpath } from 'fs/promises';
import { spawn, ExitCodeError } from '@malept/cross-spawn-promise'; import { spawn, ExitCodeError } from '@malept/cross-spawn-promise';

View File

@ -3,18 +3,21 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.createAsar = createAsar; exports.createAsar = createAsar;
const path = require("path"); const path_1 = __importDefault(require("path"));
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const pickle = require('chromium-pickle-js'); const pickle = require('chromium-pickle-js');
const Filesystem = require('asar/lib/filesystem'); const Filesystem = require('asar/lib/filesystem');
const VinylFile = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const minimatch = require("minimatch"); const minimatch_1 = __importDefault(require("minimatch"));
function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFilename) { function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFilename) {
const shouldUnpackFile = (file) => { const shouldUnpackFile = (file) => {
for (let i = 0; i < unpackGlobs.length; i++) { for (let i = 0; i < unpackGlobs.length; i++) {
if (minimatch(file.relative, unpackGlobs[i])) { if ((0, minimatch_1.default)(file.relative, unpackGlobs[i])) {
return true; return true;
} }
} }
@ -22,7 +25,7 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
}; };
const shouldSkipFile = (file) => { const shouldSkipFile = (file) => {
for (const skipGlob of skipGlobs) { for (const skipGlob of skipGlobs) {
if (minimatch(file.relative, skipGlob)) { if ((0, minimatch_1.default)(file.relative, skipGlob)) {
return true; return true;
} }
} }
@ -32,7 +35,7 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
// node_modules.asar and node_modules // node_modules.asar and node_modules
const shouldDuplicateFile = (file) => { const shouldDuplicateFile = (file) => {
for (const duplicateGlob of duplicateGlobs) { for (const duplicateGlob of duplicateGlobs) {
if (minimatch(file.relative, duplicateGlob)) { if ((0, minimatch_1.default)(file.relative, duplicateGlob)) {
return true; return true;
} }
} }
@ -75,7 +78,7 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
// Create a closure capturing `onFileInserted`. // Create a closure capturing `onFileInserted`.
filesystem.insertFile(relativePath, shouldUnpack, { stat: stat }, {}).then(() => onFileInserted(), () => onFileInserted()); filesystem.insertFile(relativePath, shouldUnpack, { stat: stat }, {}).then(() => onFileInserted(), () => onFileInserted());
}; };
return es.through(function (file) { return event_stream_1.default.through(function (file) {
if (file.stat.isDirectory()) { if (file.stat.isDirectory()) {
return; return;
} }
@ -83,7 +86,7 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
throw new Error(`unknown item in stream!`); throw new Error(`unknown item in stream!`);
} }
if (shouldSkipFile(file)) { if (shouldSkipFile(file)) {
this.queue(new VinylFile({ this.queue(new vinyl_1.default({
base: '.', base: '.',
path: file.path, path: file.path,
stat: file.stat, stat: file.stat,
@ -92,7 +95,7 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
return; return;
} }
if (shouldDuplicateFile(file)) { if (shouldDuplicateFile(file)) {
this.queue(new VinylFile({ this.queue(new vinyl_1.default({
base: '.', base: '.',
path: file.path, path: file.path,
stat: file.stat, stat: file.stat,
@ -103,10 +106,10 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
insertFile(file.relative, { size: file.contents.length, mode: file.stat.mode }, shouldUnpack); insertFile(file.relative, { size: file.contents.length, mode: file.stat.mode }, shouldUnpack);
if (shouldUnpack) { if (shouldUnpack) {
// The file goes outside of xx.asar, in a folder xx.asar.unpacked // The file goes outside of xx.asar, in a folder xx.asar.unpacked
const relative = path.relative(folderPath, file.path); const relative = path_1.default.relative(folderPath, file.path);
this.queue(new VinylFile({ this.queue(new vinyl_1.default({
base: '.', base: '.',
path: path.join(destFilename + '.unpacked', relative), path: path_1.default.join(destFilename + '.unpacked', relative),
stat: file.stat, stat: file.stat,
contents: file.contents contents: file.contents
})); }));
@ -129,7 +132,7 @@ function createAsar(folderPath, unpackGlobs, skipGlobs, duplicateGlobs, destFile
} }
const contents = Buffer.concat(out); const contents = Buffer.concat(out);
out.length = 0; out.length = 0;
this.queue(new VinylFile({ this.queue(new vinyl_1.default({
base: '.', base: '.',
path: destFilename, path: destFilename,
contents: contents contents: contents

View File

@ -3,12 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as es from 'event-stream'; import es from 'event-stream';
const pickle = require('chromium-pickle-js'); const pickle = require('chromium-pickle-js');
const Filesystem = <typeof AsarFilesystem>require('asar/lib/filesystem'); const Filesystem = <typeof AsarFilesystem>require('asar/lib/filesystem');
import * as VinylFile from 'vinyl'; import VinylFile from 'vinyl';
import * as minimatch from 'minimatch'; import minimatch from 'minimatch';
declare class AsarFilesystem { declare class AsarFilesystem {
readonly header: unknown; readonly header: unknown;

View File

@ -3,39 +3,75 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getExtensionStream = getExtensionStream; exports.getExtensionStream = getExtensionStream;
exports.getBuiltInExtensions = getBuiltInExtensions; exports.getBuiltInExtensions = getBuiltInExtensions;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const os = require("os"); const os_1 = __importDefault(require("os"));
const rimraf = require("rimraf"); const rimraf_1 = __importDefault(require("rimraf"));
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const rename = require("gulp-rename"); const gulp_rename_1 = __importDefault(require("gulp-rename"));
const vfs = require("vinyl-fs"); const vinyl_fs_1 = __importDefault(require("vinyl-fs"));
const ext = require("./extensions"); const ext = __importStar(require("./extensions"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
const productjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')); const productjson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../product.json'), 'utf8'));
const builtInExtensions = productjson.builtInExtensions || []; const builtInExtensions = productjson.builtInExtensions || [];
const webBuiltInExtensions = productjson.webBuiltInExtensions || []; const webBuiltInExtensions = productjson.webBuiltInExtensions || [];
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json'); const controlFilePath = path_1.default.join(os_1.default.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
const ENABLE_LOGGING = !process.env['VSCODE_BUILD_BUILTIN_EXTENSIONS_SILENCE_PLEASE']; const ENABLE_LOGGING = !process.env['VSCODE_BUILD_BUILTIN_EXTENSIONS_SILENCE_PLEASE'];
function log(...messages) { function log(...messages) {
if (ENABLE_LOGGING) { if (ENABLE_LOGGING) {
fancyLog(...messages); (0, fancy_log_1.default)(...messages);
} }
} }
function getExtensionPath(extension) { function getExtensionPath(extension) {
return path.join(root, '.build', 'builtInExtensions', extension.name); return path_1.default.join(root, '.build', 'builtInExtensions', extension.name);
} }
function isUpToDate(extension) { function isUpToDate(extension) {
const packagePath = path.join(getExtensionPath(extension), 'package.json'); const packagePath = path_1.default.join(getExtensionPath(extension), 'package.json');
if (!fs.existsSync(packagePath)) { if (!fs_1.default.existsSync(packagePath)) {
return false; return false;
} }
const packageContents = fs.readFileSync(packagePath, { encoding: 'utf8' }); const packageContents = fs_1.default.readFileSync(packagePath, { encoding: 'utf8' });
try { try {
const diskVersion = JSON.parse(packageContents).version; const diskVersion = JSON.parse(packageContents).version;
return (diskVersion === extension.version); return (diskVersion === extension.version);
@ -47,71 +83,71 @@ function isUpToDate(extension) {
function getExtensionDownloadStream(extension) { function getExtensionDownloadStream(extension) {
const galleryServiceUrl = productjson.extensionsGallery?.serviceUrl; const galleryServiceUrl = productjson.extensionsGallery?.serviceUrl;
return (galleryServiceUrl ? ext.fromMarketplace(galleryServiceUrl, extension) : ext.fromGithub(extension)) return (galleryServiceUrl ? ext.fromMarketplace(galleryServiceUrl, extension) : ext.fromGithub(extension))
.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`)); .pipe((0, gulp_rename_1.default)(p => p.dirname = `${extension.name}/${p.dirname}`));
} }
function getExtensionStream(extension) { function getExtensionStream(extension) {
// if the extension exists on disk, use those files instead of downloading anew // if the extension exists on disk, use those files instead of downloading anew
if (isUpToDate(extension)) { if (isUpToDate(extension)) {
log('[extensions]', `${extension.name}@${extension.version} up to date`, ansiColors.green('✔︎')); log('[extensions]', `${extension.name}@${extension.version} up to date`, ansi_colors_1.default.green('✔︎'));
return vfs.src(['**'], { cwd: getExtensionPath(extension), dot: true }) return vinyl_fs_1.default.src(['**'], { cwd: getExtensionPath(extension), dot: true })
.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`)); .pipe((0, gulp_rename_1.default)(p => p.dirname = `${extension.name}/${p.dirname}`));
} }
return getExtensionDownloadStream(extension); return getExtensionDownloadStream(extension);
} }
function syncMarketplaceExtension(extension) { function syncMarketplaceExtension(extension) {
const galleryServiceUrl = productjson.extensionsGallery?.serviceUrl; const galleryServiceUrl = productjson.extensionsGallery?.serviceUrl;
const source = ansiColors.blue(galleryServiceUrl ? '[marketplace]' : '[github]'); const source = ansi_colors_1.default.blue(galleryServiceUrl ? '[marketplace]' : '[github]');
if (isUpToDate(extension)) { if (isUpToDate(extension)) {
log(source, `${extension.name}@${extension.version}`, ansiColors.green('✔︎')); log(source, `${extension.name}@${extension.version}`, ansi_colors_1.default.green('✔︎'));
return es.readArray([]); return event_stream_1.default.readArray([]);
} }
rimraf.sync(getExtensionPath(extension)); rimraf_1.default.sync(getExtensionPath(extension));
return getExtensionDownloadStream(extension) return getExtensionDownloadStream(extension)
.pipe(vfs.dest('.build/builtInExtensions')) .pipe(vinyl_fs_1.default.dest('.build/builtInExtensions'))
.on('end', () => log(source, extension.name, ansiColors.green('✔︎'))); .on('end', () => log(source, extension.name, ansi_colors_1.default.green('✔︎')));
} }
function syncExtension(extension, controlState) { function syncExtension(extension, controlState) {
if (extension.platforms) { if (extension.platforms) {
const platforms = new Set(extension.platforms); const platforms = new Set(extension.platforms);
if (!platforms.has(process.platform)) { if (!platforms.has(process.platform)) {
log(ansiColors.gray('[skip]'), `${extension.name}@${extension.version}: Platform '${process.platform}' not supported: [${extension.platforms}]`, ansiColors.green('✔︎')); log(ansi_colors_1.default.gray('[skip]'), `${extension.name}@${extension.version}: Platform '${process.platform}' not supported: [${extension.platforms}]`, ansi_colors_1.default.green('✔︎'));
return es.readArray([]); return event_stream_1.default.readArray([]);
} }
} }
switch (controlState) { switch (controlState) {
case 'disabled': case 'disabled':
log(ansiColors.blue('[disabled]'), ansiColors.gray(extension.name)); log(ansi_colors_1.default.blue('[disabled]'), ansi_colors_1.default.gray(extension.name));
return es.readArray([]); return event_stream_1.default.readArray([]);
case 'marketplace': case 'marketplace':
return syncMarketplaceExtension(extension); return syncMarketplaceExtension(extension);
default: default:
if (!fs.existsSync(controlState)) { if (!fs_1.default.existsSync(controlState)) {
log(ansiColors.red(`Error: Built-in extension '${extension.name}' is configured to run from '${controlState}' but that path does not exist.`)); log(ansi_colors_1.default.red(`Error: Built-in extension '${extension.name}' is configured to run from '${controlState}' but that path does not exist.`));
return es.readArray([]); return event_stream_1.default.readArray([]);
} }
else if (!fs.existsSync(path.join(controlState, 'package.json'))) { else if (!fs_1.default.existsSync(path_1.default.join(controlState, 'package.json'))) {
log(ansiColors.red(`Error: Built-in extension '${extension.name}' is configured to run from '${controlState}' but there is no 'package.json' file in that directory.`)); log(ansi_colors_1.default.red(`Error: Built-in extension '${extension.name}' is configured to run from '${controlState}' but there is no 'package.json' file in that directory.`));
return es.readArray([]); return event_stream_1.default.readArray([]);
} }
log(ansiColors.blue('[local]'), `${extension.name}: ${ansiColors.cyan(controlState)}`, ansiColors.green('✔︎')); log(ansi_colors_1.default.blue('[local]'), `${extension.name}: ${ansi_colors_1.default.cyan(controlState)}`, ansi_colors_1.default.green('✔︎'));
return es.readArray([]); return event_stream_1.default.readArray([]);
} }
} }
function readControlFile() { function readControlFile() {
try { try {
return JSON.parse(fs.readFileSync(controlFilePath, 'utf8')); return JSON.parse(fs_1.default.readFileSync(controlFilePath, 'utf8'));
} }
catch (err) { catch (err) {
return {}; return {};
} }
} }
function writeControlFile(control) { function writeControlFile(control) {
fs.mkdirSync(path.dirname(controlFilePath), { recursive: true }); fs_1.default.mkdirSync(path_1.default.dirname(controlFilePath), { recursive: true });
fs.writeFileSync(controlFilePath, JSON.stringify(control, null, 2)); fs_1.default.writeFileSync(controlFilePath, JSON.stringify(control, null, 2));
} }
function getBuiltInExtensions() { function getBuiltInExtensions() {
log('Synchronizing built-in extensions...'); log('Synchronizing built-in extensions...');
log(`You can manage built-in extensions with the ${ansiColors.cyan('--builtin')} flag`); log(`You can manage built-in extensions with the ${ansi_colors_1.default.cyan('--builtin')} flag`);
const control = readControlFile(); const control = readControlFile();
const streams = []; const streams = [];
for (const extension of [...builtInExtensions, ...webBuiltInExtensions]) { for (const extension of [...builtInExtensions, ...webBuiltInExtensions]) {
@ -121,7 +157,7 @@ function getBuiltInExtensions() {
} }
writeControlFile(control); writeControlFile(control);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
es.merge(streams) event_stream_1.default.merge(streams)
.on('error', reject) .on('error', reject)
.on('end', resolve); .on('end', resolve);
}); });

View File

@ -3,16 +3,16 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as os from 'os'; import os from 'os';
import * as rimraf from 'rimraf'; import rimraf from 'rimraf';
import * as es from 'event-stream'; import es from 'event-stream';
import * as rename from 'gulp-rename'; import rename from 'gulp-rename';
import * as vfs from 'vinyl-fs'; import vfs from 'vinyl-fs';
import * as ext from './extensions'; import * as ext from './extensions';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
import { Stream } from 'stream'; import { Stream } from 'stream';
export interface IExtensionDefinition { export interface IExtensionDefinition {

View File

@ -3,14 +3,17 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const url = require("url"); const url_1 = __importDefault(require("url"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
const rootCG = path.join(root, 'extensionsCG'); const rootCG = path_1.default.join(root, 'extensionsCG');
const productjson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')); const productjson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../product.json'), 'utf8'));
const builtInExtensions = productjson.builtInExtensions || []; const builtInExtensions = productjson.builtInExtensions || [];
const webBuiltInExtensions = productjson.webBuiltInExtensions || []; const webBuiltInExtensions = productjson.webBuiltInExtensions || [];
const token = process.env['GITHUB_TOKEN']; const token = process.env['GITHUB_TOKEN'];
@ -18,7 +21,7 @@ const contentBasePath = 'raw.githubusercontent.com';
const contentFileNames = ['package.json', 'package-lock.json']; const contentFileNames = ['package.json', 'package-lock.json'];
async function downloadExtensionDetails(extension) { async function downloadExtensionDetails(extension) {
const extensionLabel = `${extension.name}@${extension.version}`; const extensionLabel = `${extension.name}@${extension.version}`;
const repository = url.parse(extension.repo).path.substr(1); const repository = url_1.default.parse(extension.repo).path.substr(1);
const repositoryContentBaseUrl = `https://${token ? `${token}@` : ''}${contentBasePath}/${repository}/v${extension.version}`; const repositoryContentBaseUrl = `https://${token ? `${token}@` : ''}${contentBasePath}/${repository}/v${extension.version}`;
async function getContent(fileName) { async function getContent(fileName) {
try { try {
@ -42,16 +45,16 @@ async function downloadExtensionDetails(extension) {
const results = await Promise.all(promises); const results = await Promise.all(promises);
for (const result of results) { for (const result of results) {
if (result.body) { if (result.body) {
const extensionFolder = path.join(rootCG, extension.name); const extensionFolder = path_1.default.join(rootCG, extension.name);
fs.mkdirSync(extensionFolder, { recursive: true }); fs_1.default.mkdirSync(extensionFolder, { recursive: true });
fs.writeFileSync(path.join(extensionFolder, result.fileName), result.body); fs_1.default.writeFileSync(path_1.default.join(extensionFolder, result.fileName), result.body);
console.log(` - ${result.fileName} ${ansiColors.green('✔︎')}`); console.log(` - ${result.fileName} ${ansi_colors_1.default.green('✔︎')}`);
} }
else if (result.body === undefined) { else if (result.body === undefined) {
console.log(` - ${result.fileName} ${ansiColors.yellow('⚠️')}`); console.log(` - ${result.fileName} ${ansi_colors_1.default.yellow('⚠️')}`);
} }
else { else {
console.log(` - ${result.fileName} ${ansiColors.red('🛑')}`); console.log(` - ${result.fileName} ${ansi_colors_1.default.red('🛑')}`);
} }
} }
// Validation // Validation
@ -68,10 +71,10 @@ async function main() {
} }
} }
main().then(() => { main().then(() => {
console.log(`Built-in extensions component data downloaded ${ansiColors.green('✔︎')}`); console.log(`Built-in extensions component data downloaded ${ansi_colors_1.default.green('✔︎')}`);
process.exit(0); process.exit(0);
}, err => { }, err => {
console.log(`Built-in extensions component data could not be downloaded ${ansiColors.red('🛑')}`); console.log(`Built-in extensions component data could not be downloaded ${ansi_colors_1.default.red('🛑')}`);
console.error(err); console.error(err);
process.exit(1); process.exit(1);
}); });

View File

@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as url from 'url'; import url from 'url';
import ansiColors = require('ansi-colors'); import ansiColors from 'ansi-colors';
import { IExtensionDefinition } from './builtInExtensions'; import { IExtensionDefinition } from './builtInExtensions';
const root = path.dirname(path.dirname(__dirname)); const root = path.dirname(path.dirname(__dirname));

View File

@ -3,12 +3,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.bundle = bundle; exports.bundle = bundle;
exports.removeAllTSBoilerplate = removeAllTSBoilerplate; exports.removeAllTSBoilerplate = removeAllTSBoilerplate;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const vm = require("vm"); const vm_1 = __importDefault(require("vm"));
/** /**
* Bundle `entryPoints` given config `config`. * Bundle `entryPoints` given config `config`.
*/ */
@ -30,8 +33,8 @@ function bundle(entryPoints, config, callback) {
allMentionedModulesMap[excludedModule] = true; allMentionedModulesMap[excludedModule] = true;
}); });
}); });
const code = require('fs').readFileSync(path.join(__dirname, '../../src/vs/loader.js')); const code = require('fs').readFileSync(path_1.default.join(__dirname, '../../src/vs/loader.js'));
const r = vm.runInThisContext('(function(require, module, exports) { ' + code + '\n});'); const r = vm_1.default.runInThisContext('(function(require, module, exports) { ' + code + '\n});');
const loaderModule = { exports: {} }; const loaderModule = { exports: {} };
r.call({}, require, loaderModule, loaderModule.exports); r.call({}, require, loaderModule, loaderModule.exports);
const loader = loaderModule.exports; const loader = loaderModule.exports;
@ -149,7 +152,7 @@ function extractStrings(destFiles) {
_path = pieces[0]; _path = pieces[0];
} }
if (/^\.\//.test(_path) || /^\.\.\//.test(_path)) { if (/^\.\//.test(_path) || /^\.\.\//.test(_path)) {
const res = path.join(path.dirname(module), _path).replace(/\\/g, '/'); const res = path_1.default.join(path_1.default.dirname(module), _path).replace(/\\/g, '/');
return prefix + res; return prefix + res;
} }
return prefix + _path; return prefix + _path;
@ -359,7 +362,7 @@ function emitEntryPoint(modulesMap, deps, entryPoint, includedModules, prepend,
} }
function readFileAndRemoveBOM(path) { function readFileAndRemoveBOM(path) {
const BOM_CHAR_CODE = 65279; const BOM_CHAR_CODE = 65279;
let contents = fs.readFileSync(path, 'utf8'); let contents = fs_1.default.readFileSync(path, 'utf8');
// Remove BOM // Remove BOM
if (contents.charCodeAt(0) === BOM_CHAR_CODE) { if (contents.charCodeAt(0) === BOM_CHAR_CODE) {
contents = contents.substring(1); contents = contents.substring(1);

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as vm from 'vm'; import vm from 'vm';
interface IPosition { interface IPosition {
line: number; line: number;

View File

@ -3,24 +3,60 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.watchApiProposalNamesTask = exports.compileApiProposalNamesTask = void 0; exports.watchApiProposalNamesTask = exports.compileApiProposalNamesTask = void 0;
exports.transpileTask = transpileTask; exports.transpileTask = transpileTask;
exports.compileTask = compileTask; exports.compileTask = compileTask;
exports.watchTask = watchTask; exports.watchTask = watchTask;
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const gulp = require("gulp"); const gulp_1 = __importDefault(require("gulp"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const monacodts = require("./monaco-api"); const monacodts = __importStar(require("./monaco-api"));
const nls = require("./nls"); const nls = __importStar(require("./nls"));
const reporter_1 = require("./reporter"); const reporter_1 = require("./reporter");
const util = require("./util"); const util = __importStar(require("./util"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const os = require("os"); const os_1 = __importDefault(require("os"));
const File = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const task = require("./task"); const task = __importStar(require("./task"));
const index_1 = require("./mangle/index"); const index_1 = require("./mangle/index");
const postcss_1 = require("./postcss"); const postcss_1 = require("./postcss");
const ts = require("typescript"); const ts = require("typescript");
@ -28,7 +64,7 @@ const watch = require('./watch');
// --- gulp-tsb: compile and transpile -------------------------------- // --- gulp-tsb: compile and transpile --------------------------------
const reporter = (0, reporter_1.createReporter)(); const reporter = (0, reporter_1.createReporter)();
function getTypeScriptCompilerOptions(src) { function getTypeScriptCompilerOptions(src) {
const rootDir = path.join(__dirname, `../../${src}`); const rootDir = path_1.default.join(__dirname, `../../${src}`);
const options = {}; const options = {};
options.verbose = false; options.verbose = false;
options.sourceMap = true; options.sourceMap = true;
@ -38,13 +74,13 @@ function getTypeScriptCompilerOptions(src) {
options.rootDir = rootDir; options.rootDir = rootDir;
options.baseUrl = rootDir; options.baseUrl = rootDir;
options.sourceRoot = util.toFileUri(rootDir); options.sourceRoot = util.toFileUri(rootDir);
options.newLine = /\r\n/.test(fs.readFileSync(__filename, 'utf8')) ? 0 : 1; options.newLine = /\r\n/.test(fs_1.default.readFileSync(__filename, 'utf8')) ? 0 : 1;
return options; return options;
} }
function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }) { function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }) {
const tsb = require('./tsb'); const tsb = require('./tsb');
const sourcemaps = require('gulp-sourcemaps'); const sourcemaps = require('gulp-sourcemaps');
const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json'); const projectPath = path_1.default.join(__dirname, '../../', src, 'tsconfig.json');
const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) }; const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) };
if (!build) { if (!build) {
overrideOptions.inlineSourceMap = true; overrideOptions.inlineSourceMap = true;
@ -62,7 +98,7 @@ function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }
const isCSS = (f) => f.path.endsWith('.css') && !f.path.includes('fixtures'); const isCSS = (f) => f.path.endsWith('.css') && !f.path.includes('fixtures');
const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path))); const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path)));
const postcssNesting = require('postcss-nesting'); const postcssNesting = require('postcss-nesting');
const input = es.through(); const input = event_stream_1.default.through();
const output = input const output = input
.pipe(util.$if(isUtf8Test, bom())) // this is required to preserve BOM in test files that loose it otherwise .pipe(util.$if(isUtf8Test, bom())) // this is required to preserve BOM in test files that loose it otherwise
.pipe(util.$if(!build && isRuntimeJs, util.appendOwnPathSourceURL())) .pipe(util.$if(!build && isRuntimeJs, util.appendOwnPathSourceURL()))
@ -80,7 +116,7 @@ function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }
}))) })))
.pipe(tsFilter.restore) .pipe(tsFilter.restore)
.pipe(reporter.end(!!emitError)); .pipe(reporter.end(!!emitError));
return es.duplex(input, output); return event_stream_1.default.duplex(input, output);
} }
pipeline.tsProjectSrc = () => { pipeline.tsProjectSrc = () => {
return compilation.src({ base: src }); return compilation.src({ base: src });
@ -91,31 +127,31 @@ function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }
function transpileTask(src, out, esbuild) { function transpileTask(src, out, esbuild) {
const task = () => { const task = () => {
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { esbuild }, preserveEnglish: false }); const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { esbuild }, preserveEnglish: false });
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` }); const srcPipe = gulp_1.default.src(`${src}/**`, { base: `${src}` });
return srcPipe return srcPipe
.pipe(transpile()) .pipe(transpile())
.pipe(gulp.dest(out)); .pipe(gulp_1.default.dest(out));
}; };
task.taskName = `transpile-${path.basename(src)}`; task.taskName = `transpile-${path_1.default.basename(src)}`;
return task; return task;
} }
function compileTask(src, out, build, options = {}) { function compileTask(src, out, build, options = {}) {
const task = () => { const task = () => {
if (os.totalmem() < 4_000_000_000) { if (os_1.default.totalmem() < 4_000_000_000) {
throw new Error('compilation requires 4GB of RAM'); throw new Error('compilation requires 4GB of RAM');
} }
const compile = createCompile(src, { build, emitError: true, transpileOnly: false, preserveEnglish: !!options.preserveEnglish }); const compile = createCompile(src, { build, emitError: true, transpileOnly: false, preserveEnglish: !!options.preserveEnglish });
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` }); const srcPipe = gulp_1.default.src(`${src}/**`, { base: `${src}` });
const generator = new MonacoGenerator(false); const generator = new MonacoGenerator(false);
if (src === 'src') { if (src === 'src') {
generator.execute(); generator.execute();
} }
// mangle: TypeScript to TypeScript // mangle: TypeScript to TypeScript
let mangleStream = es.through(); let mangleStream = event_stream_1.default.through();
if (build && !options.disableMangle) { if (build && !options.disableMangle) {
let ts2tsMangler = new index_1.Mangler(compile.projectPath, (...data) => fancyLog(ansiColors.blue('[mangler]'), ...data), { mangleExports: true, manglePrivateFields: true }); let ts2tsMangler = new index_1.Mangler(compile.projectPath, (...data) => (0, fancy_log_1.default)(ansi_colors_1.default.blue('[mangler]'), ...data), { mangleExports: true, manglePrivateFields: true });
const newContentsByFileName = ts2tsMangler.computeNewFileContents(new Set(['saveState'])); const newContentsByFileName = ts2tsMangler.computeNewFileContents(new Set(['saveState']));
mangleStream = es.through(async function write(data) { mangleStream = event_stream_1.default.through(async function write(data) {
const tsNormalPath = ts.normalizePath(data.path); const tsNormalPath = ts.normalizePath(data.path);
const newContents = (await newContentsByFileName).get(tsNormalPath); const newContents = (await newContentsByFileName).get(tsNormalPath);
if (newContents !== undefined) { if (newContents !== undefined) {
@ -134,27 +170,27 @@ function compileTask(src, out, build, options = {}) {
.pipe(mangleStream) .pipe(mangleStream)
.pipe(generator.stream) .pipe(generator.stream)
.pipe(compile()) .pipe(compile())
.pipe(gulp.dest(out)); .pipe(gulp_1.default.dest(out));
}; };
task.taskName = `compile-${path.basename(src)}`; task.taskName = `compile-${path_1.default.basename(src)}`;
return task; return task;
} }
function watchTask(out, build, srcPath = 'src') { function watchTask(out, build, srcPath = 'src') {
const task = () => { const task = () => {
const compile = createCompile(srcPath, { build, emitError: false, transpileOnly: false, preserveEnglish: false }); const compile = createCompile(srcPath, { build, emitError: false, transpileOnly: false, preserveEnglish: false });
const src = gulp.src(`${srcPath}/**`, { base: srcPath }); const src = gulp_1.default.src(`${srcPath}/**`, { base: srcPath });
const watchSrc = watch(`${srcPath}/**`, { base: srcPath, readDelay: 200 }); const watchSrc = watch(`${srcPath}/**`, { base: srcPath, readDelay: 200 });
const generator = new MonacoGenerator(true); const generator = new MonacoGenerator(true);
generator.execute(); generator.execute();
return watchSrc return watchSrc
.pipe(generator.stream) .pipe(generator.stream)
.pipe(util.incremental(compile, src, true)) .pipe(util.incremental(compile, src, true))
.pipe(gulp.dest(out)); .pipe(gulp_1.default.dest(out));
}; };
task.taskName = `watch-${path.basename(out)}`; task.taskName = `watch-${path_1.default.basename(out)}`;
return task; return task;
} }
const REPO_SRC_FOLDER = path.join(__dirname, '../../src'); const REPO_SRC_FOLDER = path_1.default.join(__dirname, '../../src');
class MonacoGenerator { class MonacoGenerator {
_isWatch; _isWatch;
stream; stream;
@ -163,7 +199,7 @@ class MonacoGenerator {
_declarationResolver; _declarationResolver;
constructor(isWatch) { constructor(isWatch) {
this._isWatch = isWatch; this._isWatch = isWatch;
this.stream = es.through(); this.stream = event_stream_1.default.through();
this._watchedFiles = {}; this._watchedFiles = {};
const onWillReadFile = (moduleId, filePath) => { const onWillReadFile = (moduleId, filePath) => {
if (!this._isWatch) { if (!this._isWatch) {
@ -173,7 +209,7 @@ class MonacoGenerator {
return; return;
} }
this._watchedFiles[filePath] = true; this._watchedFiles[filePath] = true;
fs.watchFile(filePath, () => { fs_1.default.watchFile(filePath, () => {
this._declarationResolver.invalidateCache(moduleId); this._declarationResolver.invalidateCache(moduleId);
this._executeSoon(); this._executeSoon();
}); });
@ -186,7 +222,7 @@ class MonacoGenerator {
}; };
this._declarationResolver = new monacodts.DeclarationResolver(this._fsProvider); this._declarationResolver = new monacodts.DeclarationResolver(this._fsProvider);
if (this._isWatch) { if (this._isWatch) {
fs.watchFile(monacodts.RECIPE_PATH, () => { fs_1.default.watchFile(monacodts.RECIPE_PATH, () => {
this._executeSoon(); this._executeSoon();
}); });
} }
@ -211,7 +247,7 @@ class MonacoGenerator {
return r; return r;
} }
_log(message, ...rest) { _log(message, ...rest) {
fancyLog(ansiColors.cyan('[monaco.d.ts]'), message, ...rest); (0, fancy_log_1.default)(ansi_colors_1.default.cyan('[monaco.d.ts]'), message, ...rest);
} }
execute() { execute() {
const startTime = Date.now(); const startTime = Date.now();
@ -223,8 +259,8 @@ class MonacoGenerator {
if (result.isTheSame) { if (result.isTheSame) {
return; return;
} }
fs.writeFileSync(result.filePath, result.content); fs_1.default.writeFileSync(result.filePath, result.content);
fs.writeFileSync(path.join(REPO_SRC_FOLDER, 'vs/editor/common/standalone/standaloneEnums.ts'), result.enums); fs_1.default.writeFileSync(path_1.default.join(REPO_SRC_FOLDER, 'vs/editor/common/standalone/standaloneEnums.ts'), result.enums);
this._log(`monaco.d.ts is changed - total time took ${Date.now() - startTime} ms`); this._log(`monaco.d.ts is changed - total time took ${Date.now() - startTime} ms`);
if (!this._isWatch) { if (!this._isWatch) {
this.stream.emit('error', 'monaco.d.ts is no longer up to date. Please run gulp watch and commit the new file.'); this.stream.emit('error', 'monaco.d.ts is no longer up to date. Please run gulp watch and commit the new file.');
@ -234,21 +270,21 @@ class MonacoGenerator {
function generateApiProposalNames() { function generateApiProposalNames() {
let eol; let eol;
try { try {
const src = fs.readFileSync('src/vs/platform/extensions/common/extensionsApiProposals.ts', 'utf-8'); const src = fs_1.default.readFileSync('src/vs/platform/extensions/common/extensionsApiProposals.ts', 'utf-8');
const match = /\r?\n/m.exec(src); const match = /\r?\n/m.exec(src);
eol = match ? match[0] : os.EOL; eol = match ? match[0] : os_1.default.EOL;
} }
catch { catch {
eol = os.EOL; eol = os_1.default.EOL;
} }
const pattern = /vscode\.proposed\.([a-zA-Z\d]+)\.d\.ts$/; const pattern = /vscode\.proposed\.([a-zA-Z\d]+)\.d\.ts$/;
const versionPattern = /^\s*\/\/\s*version\s*:\s*(\d+)\s*$/mi; const versionPattern = /^\s*\/\/\s*version\s*:\s*(\d+)\s*$/mi;
const proposals = new Map(); const proposals = new Map();
const input = es.through(); const input = event_stream_1.default.through();
const output = input const output = input
.pipe(util.filter((f) => pattern.test(f.path))) .pipe(util.filter((f) => pattern.test(f.path)))
.pipe(es.through((f) => { .pipe(event_stream_1.default.through((f) => {
const name = path.basename(f.path); const name = path_1.default.basename(f.path);
const match = pattern.exec(name); const match = pattern.exec(name);
if (!match) { if (!match) {
return; return;
@ -281,27 +317,27 @@ function generateApiProposalNames() {
'export type ApiProposalName = keyof typeof _allApiProposals;', 'export type ApiProposalName = keyof typeof _allApiProposals;',
'', '',
].join(eol); ].join(eol);
this.emit('data', new File({ this.emit('data', new vinyl_1.default({
path: 'vs/platform/extensions/common/extensionsApiProposals.ts', path: 'vs/platform/extensions/common/extensionsApiProposals.ts',
contents: Buffer.from(contents) contents: Buffer.from(contents)
})); }));
this.emit('end'); this.emit('end');
})); }));
return es.duplex(input, output); return event_stream_1.default.duplex(input, output);
} }
const apiProposalNamesReporter = (0, reporter_1.createReporter)('api-proposal-names'); const apiProposalNamesReporter = (0, reporter_1.createReporter)('api-proposal-names');
exports.compileApiProposalNamesTask = task.define('compile-api-proposal-names', () => { exports.compileApiProposalNamesTask = task.define('compile-api-proposal-names', () => {
return gulp.src('src/vscode-dts/**') return gulp_1.default.src('src/vscode-dts/**')
.pipe(generateApiProposalNames()) .pipe(generateApiProposalNames())
.pipe(gulp.dest('src')) .pipe(gulp_1.default.dest('src'))
.pipe(apiProposalNamesReporter.end(true)); .pipe(apiProposalNamesReporter.end(true));
}); });
exports.watchApiProposalNamesTask = task.define('watch-api-proposal-names', () => { exports.watchApiProposalNamesTask = task.define('watch-api-proposal-names', () => {
const task = () => gulp.src('src/vscode-dts/**') const task = () => gulp_1.default.src('src/vscode-dts/**')
.pipe(generateApiProposalNames()) .pipe(generateApiProposalNames())
.pipe(apiProposalNamesReporter.end(true)); .pipe(apiProposalNamesReporter.end(true));
return watch('src/vscode-dts/**', { readDelay: 200 }) return watch('src/vscode-dts/**', { readDelay: 200 })
.pipe(util.debounce(task)) .pipe(util.debounce(task))
.pipe(gulp.dest('src')); .pipe(gulp_1.default.dest('src'));
}); });
//# sourceMappingURL=compilation.js.map //# sourceMappingURL=compilation.js.map

View File

@ -3,18 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import es from 'event-stream';
import * as fs from 'fs'; import fs from 'fs';
import * as gulp from 'gulp'; import gulp from 'gulp';
import * as path from 'path'; import path from 'path';
import * as monacodts from './monaco-api'; import * as monacodts from './monaco-api';
import * as nls from './nls'; import * as nls from './nls';
import { createReporter } from './reporter'; import { createReporter } from './reporter';
import * as util from './util'; import * as util from './util';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
import * as os from 'os'; import os from 'os';
import * as File from 'vinyl'; import File from 'vinyl';
import * as task from './task'; import * as task from './task';
import { Mangler } from './mangle/index'; import { Mangler } from './mangle/index';
import { RawSourceMap } from 'source-map'; import { RawSourceMap } from 'source-map';

View File

@ -3,12 +3,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.writeISODate = writeISODate; exports.writeISODate = writeISODate;
exports.readISODate = readISODate; exports.readISODate = readISODate;
const path = require("path"); const path_1 = __importDefault(require("path"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const root = path.join(__dirname, '..', '..'); const root = path_1.default.join(__dirname, '..', '..');
/** /**
* Writes a `outDir/date` file with the contents of the build * Writes a `outDir/date` file with the contents of the build
* so that other tasks during the build process can use it and * so that other tasks during the build process can use it and
@ -16,17 +19,17 @@ const root = path.join(__dirname, '..', '..');
*/ */
function writeISODate(outDir) { function writeISODate(outDir) {
const result = () => new Promise((resolve, _) => { const result = () => new Promise((resolve, _) => {
const outDirectory = path.join(root, outDir); const outDirectory = path_1.default.join(root, outDir);
fs.mkdirSync(outDirectory, { recursive: true }); fs_1.default.mkdirSync(outDirectory, { recursive: true });
const date = new Date().toISOString(); const date = new Date().toISOString();
fs.writeFileSync(path.join(outDirectory, 'date'), date, 'utf8'); fs_1.default.writeFileSync(path_1.default.join(outDirectory, 'date'), date, 'utf8');
resolve(); resolve();
}); });
result.taskName = 'build-date-file'; result.taskName = 'build-date-file';
return result; return result;
} }
function readISODate(outDir) { function readISODate(outDir) {
const outDirectory = path.join(root, outDir); const outDirectory = path_1.default.join(root, outDir);
return fs.readFileSync(path.join(outDirectory, 'date'), 'utf8'); return fs_1.default.readFileSync(path_1.default.join(outDirectory, 'date'), 'utf8');
} }
//# sourceMappingURL=date.js.map //# sourceMappingURL=date.js.map

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as fs from 'fs'; import fs from 'fs';
const root = path.join(__dirname, '..', '..'); const root = path.join(__dirname, '..', '..');

View File

@ -3,16 +3,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getProductionDependencies = getProductionDependencies; exports.getProductionDependencies = getProductionDependencies;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const cp = require("child_process"); const child_process_1 = __importDefault(require("child_process"));
const root = fs.realpathSync(path.dirname(path.dirname(__dirname))); const root = fs_1.default.realpathSync(path_1.default.dirname(path_1.default.dirname(__dirname)));
function getNpmProductionDependencies(folder) { function getNpmProductionDependencies(folder) {
let raw; let raw;
try { try {
raw = cp.execSync('npm ls --all --omit=dev --parseable', { cwd: folder, encoding: 'utf8', env: { ...process.env, NODE_ENV: 'production' }, stdio: [null, null, null] }); raw = child_process_1.default.execSync('npm ls --all --omit=dev --parseable', { cwd: folder, encoding: 'utf8', env: { ...process.env, NODE_ENV: 'production' }, stdio: [null, null, null] });
} }
catch (err) { catch (err) {
const regex = /^npm ERR! .*$/gm; const regex = /^npm ERR! .*$/gm;
@ -34,16 +37,16 @@ function getNpmProductionDependencies(folder) {
raw = err.stdout; raw = err.stdout;
} }
return raw.split(/\r?\n/).filter(line => { return raw.split(/\r?\n/).filter(line => {
return !!line.trim() && path.relative(root, line) !== path.relative(root, folder); return !!line.trim() && path_1.default.relative(root, line) !== path_1.default.relative(root, folder);
}); });
} }
function getProductionDependencies(folderPath) { function getProductionDependencies(folderPath) {
const result = getNpmProductionDependencies(folderPath); const result = getNpmProductionDependencies(folderPath);
// Account for distro npm dependencies // Account for distro npm dependencies
const realFolderPath = fs.realpathSync(folderPath); const realFolderPath = fs_1.default.realpathSync(folderPath);
const relativeFolderPath = path.relative(root, realFolderPath); const relativeFolderPath = path_1.default.relative(root, realFolderPath);
const distroFolderPath = `${root}/.build/distro/npm/${relativeFolderPath}`; const distroFolderPath = `${root}/.build/distro/npm/${relativeFolderPath}`;
if (fs.existsSync(distroFolderPath)) { if (fs_1.default.existsSync(distroFolderPath)) {
result.push(...getNpmProductionDependencies(distroFolderPath)); result.push(...getNpmProductionDependencies(distroFolderPath));
} }
return [...new Set(result)]; return [...new Set(result)];

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as cp from 'child_process'; import cp from 'child_process';
const root = fs.realpathSync(path.dirname(path.dirname(__dirname))); const root = fs.realpathSync(path.dirname(path.dirname(__dirname)));
function getNpmProductionDependencies(folder: string): string[] { function getNpmProductionDependencies(folder: string): string[] {

View File

@ -3,19 +3,55 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0; exports.config = void 0;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const vfs = require("vinyl-fs"); const vinyl_fs_1 = __importDefault(require("vinyl-fs"));
const filter = require("gulp-filter"); const gulp_filter_1 = __importDefault(require("gulp-filter"));
const util = require("./util"); const util = __importStar(require("./util"));
const getVersion_1 = require("./getVersion"); const getVersion_1 = require("./getVersion");
function isDocumentSuffix(str) { function isDocumentSuffix(str) {
return str === 'document' || str === 'script' || str === 'file' || str === 'source code'; return str === 'document' || str === 'script' || str === 'file' || str === 'source code';
} }
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8')); const product = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'product.json'), 'utf8'));
const commit = (0, getVersion_1.getVersion)(root); const commit = (0, getVersion_1.getVersion)(root);
function createTemplate(input) { function createTemplate(input) {
return (params) => { return (params) => {
@ -24,7 +60,7 @@ function createTemplate(input) {
}); });
}; };
} }
const darwinCreditsTemplate = product.darwinCredits && createTemplate(fs.readFileSync(path.join(root, product.darwinCredits), 'utf8')); const darwinCreditsTemplate = product.darwinCredits && createTemplate(fs_1.default.readFileSync(path_1.default.join(root, product.darwinCredits), 'utf8'));
/** /**
* Generate a `DarwinDocumentType` given a list of file extensions, an icon name, and an optional suffix or file type name. * Generate a `DarwinDocumentType` given a list of file extensions, an icon name, and an optional suffix or file type name.
* @param extensions A list of file extensions, such as `['bat', 'cmd']` * @param extensions A list of file extensions, such as `['bat', 'cmd']`
@ -183,7 +219,7 @@ exports.config = {
token: process.env['GITHUB_TOKEN'], token: process.env['GITHUB_TOKEN'],
repo: product.electronRepository || undefined, repo: product.electronRepository || undefined,
validateChecksum: true, validateChecksum: true,
checksumFile: path.join(root, 'build', 'checksums', 'electron.txt'), checksumFile: path_1.default.join(root, 'build', 'checksums', 'electron.txt'),
}; };
function getElectron(arch) { function getElectron(arch) {
return () => { return () => {
@ -196,18 +232,18 @@ function getElectron(arch) {
ffmpegChromium: false, ffmpegChromium: false,
keepDefaultApp: true keepDefaultApp: true
}; };
return vfs.src('package.json') return vinyl_fs_1.default.src('package.json')
.pipe(json({ name: product.nameShort })) .pipe(json({ name: product.nameShort }))
.pipe(electron(electronOpts)) .pipe(electron(electronOpts))
.pipe(filter(['**', '!**/app/package.json'])) .pipe((0, gulp_filter_1.default)(['**', '!**/app/package.json']))
.pipe(vfs.dest('.build/electron')); .pipe(vinyl_fs_1.default.dest('.build/electron'));
}; };
} }
async function main(arch = process.arch) { async function main(arch = process.arch) {
const version = electronVersion; const version = electronVersion;
const electronPath = path.join(root, '.build', 'electron'); const electronPath = path_1.default.join(root, '.build', 'electron');
const versionFile = path.join(electronPath, 'version'); const versionFile = path_1.default.join(electronPath, 'version');
const isUpToDate = fs.existsSync(versionFile) && fs.readFileSync(versionFile, 'utf8') === `${version}`; const isUpToDate = fs_1.default.existsSync(versionFile) && fs_1.default.readFileSync(versionFile, 'utf8') === `${version}`;
if (!isUpToDate) { if (!isUpToDate) {
await util.rimraf(electronPath)(); await util.rimraf(electronPath)();
await util.streamToPromise(getElectron(arch)()); await util.streamToPromise(getElectron(arch)());

View File

@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as vfs from 'vinyl-fs'; import vfs from 'vinyl-fs';
import * as filter from 'gulp-filter'; import filter from 'gulp-filter';
import * as util from './util'; import * as util from './util';
import { getVersion } from './getVersion'; import { getVersion } from './getVersion';

View File

@ -3,6 +3,42 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.fromMarketplace = fromMarketplace; exports.fromMarketplace = fromMarketplace;
exports.fromGithub = fromGithub; exports.fromGithub = fromGithub;
@ -14,35 +50,35 @@ exports.scanBuiltinExtensions = scanBuiltinExtensions;
exports.translatePackageJSON = translatePackageJSON; exports.translatePackageJSON = translatePackageJSON;
exports.webpackExtensions = webpackExtensions; exports.webpackExtensions = webpackExtensions;
exports.buildExtensionMedia = buildExtensionMedia; exports.buildExtensionMedia = buildExtensionMedia;
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const cp = require("child_process"); const child_process_1 = __importDefault(require("child_process"));
const glob = require("glob"); const glob_1 = __importDefault(require("glob"));
const gulp = require("gulp"); const gulp_1 = __importDefault(require("gulp"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const File = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const stats_1 = require("./stats"); const stats_1 = require("./stats");
const util2 = require("./util"); const util2 = __importStar(require("./util"));
const vzip = require('gulp-vinyl-zip'); const vzip = require('gulp-vinyl-zip');
const filter = require("gulp-filter"); const gulp_filter_1 = __importDefault(require("gulp-filter"));
const rename = require("gulp-rename"); const gulp_rename_1 = __importDefault(require("gulp-rename"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const buffer = require('gulp-buffer'); const gulp_buffer_1 = __importDefault(require("gulp-buffer"));
const jsoncParser = require("jsonc-parser"); const jsoncParser = __importStar(require("jsonc-parser"));
const dependencies_1 = require("./dependencies"); const dependencies_1 = require("./dependencies");
const builtInExtensions_1 = require("./builtInExtensions"); const builtInExtensions_1 = require("./builtInExtensions");
const getVersion_1 = require("./getVersion"); const getVersion_1 = require("./getVersion");
const fetch_1 = require("./fetch"); const fetch_1 = require("./fetch");
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
const commit = (0, getVersion_1.getVersion)(root); const commit = (0, getVersion_1.getVersion)(root);
const sourceMappingURLBase = `https://main.vscode-cdn.net/sourcemaps/${commit}`; const sourceMappingURLBase = `https://main.vscode-cdn.net/sourcemaps/${commit}`;
function minifyExtensionResources(input) { function minifyExtensionResources(input) {
const jsonFilter = filter(['**/*.json', '**/*.code-snippets'], { restore: true }); const jsonFilter = (0, gulp_filter_1.default)(['**/*.json', '**/*.code-snippets'], { restore: true });
return input return input
.pipe(jsonFilter) .pipe(jsonFilter)
.pipe(buffer()) .pipe((0, gulp_buffer_1.default)())
.pipe(es.mapSync((f) => { .pipe(event_stream_1.default.mapSync((f) => {
const errors = []; const errors = [];
const value = jsoncParser.parse(f.contents.toString('utf8'), errors, { allowTrailingComma: true }); const value = jsoncParser.parse(f.contents.toString('utf8'), errors, { allowTrailingComma: true });
if (errors.length === 0) { if (errors.length === 0) {
@ -54,11 +90,11 @@ function minifyExtensionResources(input) {
.pipe(jsonFilter.restore); .pipe(jsonFilter.restore);
} }
function updateExtensionPackageJSON(input, update) { function updateExtensionPackageJSON(input, update) {
const packageJsonFilter = filter('extensions/*/package.json', { restore: true }); const packageJsonFilter = (0, gulp_filter_1.default)('extensions/*/package.json', { restore: true });
return input return input
.pipe(packageJsonFilter) .pipe(packageJsonFilter)
.pipe(buffer()) .pipe((0, gulp_buffer_1.default)())
.pipe(es.mapSync((f) => { .pipe(event_stream_1.default.mapSync((f) => {
const data = JSON.parse(f.contents.toString('utf8')); const data = JSON.parse(f.contents.toString('utf8'));
f.contents = Buffer.from(JSON.stringify(update(data))); f.contents = Buffer.from(JSON.stringify(update(data)));
return f; return f;
@ -67,7 +103,7 @@ function updateExtensionPackageJSON(input, update) {
} }
function fromLocal(extensionPath, forWeb, disableMangle) { function fromLocal(extensionPath, forWeb, disableMangle) {
const webpackConfigFileName = forWeb ? 'extension-browser.webpack.config.js' : 'extension.webpack.config.js'; const webpackConfigFileName = forWeb ? 'extension-browser.webpack.config.js' : 'extension.webpack.config.js';
const isWebPacked = fs.existsSync(path.join(extensionPath, webpackConfigFileName)); const isWebPacked = fs_1.default.existsSync(path_1.default.join(extensionPath, webpackConfigFileName));
let input = isWebPacked let input = isWebPacked
? fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) ? fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle)
: fromLocalNormal(extensionPath); : fromLocalNormal(extensionPath);
@ -88,11 +124,11 @@ function fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) {
const vsce = require('@vscode/vsce'); const vsce = require('@vscode/vsce');
const webpack = require('webpack'); const webpack = require('webpack');
const webpackGulp = require('webpack-stream'); const webpackGulp = require('webpack-stream');
const result = es.through(); const result = event_stream_1.default.through();
const packagedDependencies = []; const packagedDependencies = [];
const packageJsonConfig = require(path.join(extensionPath, 'package.json')); const packageJsonConfig = require(path_1.default.join(extensionPath, 'package.json'));
if (packageJsonConfig.dependencies) { if (packageJsonConfig.dependencies) {
const webpackRootConfig = require(path.join(extensionPath, webpackConfigFileName)); const webpackRootConfig = require(path_1.default.join(extensionPath, webpackConfigFileName));
for (const key in webpackRootConfig.externals) { for (const key in webpackRootConfig.externals) {
if (key in packageJsonConfig.dependencies) { if (key in packageJsonConfig.dependencies) {
packagedDependencies.push(key); packagedDependencies.push(key);
@ -106,19 +142,19 @@ function fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) {
// as a temporary workaround. // as a temporary workaround.
vsce.listFiles({ cwd: extensionPath, packageManager: vsce.PackageManager.None, packagedDependencies }).then(fileNames => { vsce.listFiles({ cwd: extensionPath, packageManager: vsce.PackageManager.None, packagedDependencies }).then(fileNames => {
const files = fileNames const files = fileNames
.map(fileName => path.join(extensionPath, fileName)) .map(fileName => path_1.default.join(extensionPath, fileName))
.map(filePath => new File({ .map(filePath => new vinyl_1.default({
path: filePath, path: filePath,
stat: fs.statSync(filePath), stat: fs_1.default.statSync(filePath),
base: extensionPath, base: extensionPath,
contents: fs.createReadStream(filePath) contents: fs_1.default.createReadStream(filePath)
})); }));
// check for a webpack configuration files, then invoke webpack // check for a webpack configuration files, then invoke webpack
// and merge its output with the files stream. // and merge its output with the files stream.
const webpackConfigLocations = glob.sync(path.join(extensionPath, '**', webpackConfigFileName), { ignore: ['**/node_modules'] }); const webpackConfigLocations = glob_1.default.sync(path_1.default.join(extensionPath, '**', webpackConfigFileName), { ignore: ['**/node_modules'] });
const webpackStreams = webpackConfigLocations.flatMap(webpackConfigPath => { const webpackStreams = webpackConfigLocations.flatMap(webpackConfigPath => {
const webpackDone = (err, stats) => { const webpackDone = (err, stats) => {
fancyLog(`Bundled extension: ${ansiColors.yellow(path.join(path.basename(extensionPath), path.relative(extensionPath, webpackConfigPath)))}...`); (0, fancy_log_1.default)(`Bundled extension: ${ansi_colors_1.default.yellow(path_1.default.join(path_1.default.basename(extensionPath), path_1.default.relative(extensionPath, webpackConfigPath)))}...`);
if (err) { if (err) {
result.emit('error', err); result.emit('error', err);
} }
@ -149,28 +185,28 @@ function fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) {
} }
} }
} }
const relativeOutputPath = path.relative(extensionPath, webpackConfig.output.path); const relativeOutputPath = path_1.default.relative(extensionPath, webpackConfig.output.path);
return webpackGulp(webpackConfig, webpack, webpackDone) return webpackGulp(webpackConfig, webpack, webpackDone)
.pipe(es.through(function (data) { .pipe(event_stream_1.default.through(function (data) {
data.stat = data.stat || {}; data.stat = data.stat || {};
data.base = extensionPath; data.base = extensionPath;
this.emit('data', data); this.emit('data', data);
})) }))
.pipe(es.through(function (data) { .pipe(event_stream_1.default.through(function (data) {
// source map handling: // source map handling:
// * rewrite sourceMappingURL // * rewrite sourceMappingURL
// * save to disk so that upload-task picks this up // * save to disk so that upload-task picks this up
if (path.extname(data.basename) === '.js') { if (path_1.default.extname(data.basename) === '.js') {
const contents = data.contents.toString('utf8'); const contents = data.contents.toString('utf8');
data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) {
return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`; return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path_1.default.basename(extensionPath)}/${relativeOutputPath}/${g1}`;
}), 'utf8'); }), 'utf8');
} }
this.emit('data', data); this.emit('data', data);
})); }));
}); });
}); });
es.merge(...webpackStreams, es.readArray(files)) event_stream_1.default.merge(...webpackStreams, event_stream_1.default.readArray(files))
// .pipe(es.through(function (data) { // .pipe(es.through(function (data) {
// // debug // // debug
// console.log('out', data.path, data.contents.length); // console.log('out', data.path, data.contents.length);
@ -182,25 +218,25 @@ function fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) {
console.error(packagedDependencies); console.error(packagedDependencies);
result.emit('error', err); result.emit('error', err);
}); });
return result.pipe((0, stats_1.createStatsStream)(path.basename(extensionPath))); return result.pipe((0, stats_1.createStatsStream)(path_1.default.basename(extensionPath)));
} }
function fromLocalNormal(extensionPath) { function fromLocalNormal(extensionPath) {
const vsce = require('@vscode/vsce'); const vsce = require('@vscode/vsce');
const result = es.through(); const result = event_stream_1.default.through();
vsce.listFiles({ cwd: extensionPath, packageManager: vsce.PackageManager.Npm }) vsce.listFiles({ cwd: extensionPath, packageManager: vsce.PackageManager.Npm })
.then(fileNames => { .then(fileNames => {
const files = fileNames const files = fileNames
.map(fileName => path.join(extensionPath, fileName)) .map(fileName => path_1.default.join(extensionPath, fileName))
.map(filePath => new File({ .map(filePath => new vinyl_1.default({
path: filePath, path: filePath,
stat: fs.statSync(filePath), stat: fs_1.default.statSync(filePath),
base: extensionPath, base: extensionPath,
contents: fs.createReadStream(filePath) contents: fs_1.default.createReadStream(filePath)
})); }));
es.readArray(files).pipe(result); event_stream_1.default.readArray(files).pipe(result);
}) })
.catch(err => result.emit('error', err)); .catch(err => result.emit('error', err));
return result.pipe((0, stats_1.createStatsStream)(path.basename(extensionPath))); return result.pipe((0, stats_1.createStatsStream)(path_1.default.basename(extensionPath)));
} }
const userAgent = 'VSCode Build'; const userAgent = 'VSCode Build';
const baseHeaders = { const baseHeaders = {
@ -212,8 +248,8 @@ function fromMarketplace(serviceUrl, { name: extensionName, version, sha256, met
const json = require('gulp-json-editor'); const json = require('gulp-json-editor');
const [publisher, name] = extensionName.split('.'); const [publisher, name] = extensionName.split('.');
const url = `${serviceUrl}/publishers/${publisher}/vsextensions/${name}/${version}/vspackage`; const url = `${serviceUrl}/publishers/${publisher}/vsextensions/${name}/${version}/vspackage`;
fancyLog('Downloading extension:', ansiColors.yellow(`${extensionName}@${version}`), '...'); (0, fancy_log_1.default)('Downloading extension:', ansi_colors_1.default.yellow(`${extensionName}@${version}`), '...');
const packageJsonFilter = filter('package.json', { restore: true }); const packageJsonFilter = (0, gulp_filter_1.default)('package.json', { restore: true });
return (0, fetch_1.fetchUrls)('', { return (0, fetch_1.fetchUrls)('', {
base: url, base: url,
nodeFetchOptions: { nodeFetchOptions: {
@ -222,28 +258,28 @@ function fromMarketplace(serviceUrl, { name: extensionName, version, sha256, met
checksumSha256: sha256 checksumSha256: sha256
}) })
.pipe(vzip.src()) .pipe(vzip.src())
.pipe(filter('extension/**')) .pipe((0, gulp_filter_1.default)('extension/**'))
.pipe(rename(p => p.dirname = p.dirname.replace(/^extension\/?/, ''))) .pipe((0, gulp_rename_1.default)(p => p.dirname = p.dirname.replace(/^extension\/?/, '')))
.pipe(packageJsonFilter) .pipe(packageJsonFilter)
.pipe(buffer()) .pipe((0, gulp_buffer_1.default)())
.pipe(json({ __metadata: metadata })) .pipe(json({ __metadata: metadata }))
.pipe(packageJsonFilter.restore); .pipe(packageJsonFilter.restore);
} }
function fromGithub({ name, version, repo, sha256, metadata }) { function fromGithub({ name, version, repo, sha256, metadata }) {
const json = require('gulp-json-editor'); const json = require('gulp-json-editor');
fancyLog('Downloading extension from GH:', ansiColors.yellow(`${name}@${version}`), '...'); (0, fancy_log_1.default)('Downloading extension from GH:', ansi_colors_1.default.yellow(`${name}@${version}`), '...');
const packageJsonFilter = filter('package.json', { restore: true }); const packageJsonFilter = (0, gulp_filter_1.default)('package.json', { restore: true });
return (0, fetch_1.fetchGithub)(new URL(repo).pathname, { return (0, fetch_1.fetchGithub)(new URL(repo).pathname, {
version, version,
name: name => name.endsWith('.vsix'), name: name => name.endsWith('.vsix'),
checksumSha256: sha256 checksumSha256: sha256
}) })
.pipe(buffer()) .pipe((0, gulp_buffer_1.default)())
.pipe(vzip.src()) .pipe(vzip.src())
.pipe(filter('extension/**')) .pipe((0, gulp_filter_1.default)('extension/**'))
.pipe(rename(p => p.dirname = p.dirname.replace(/^extension\/?/, ''))) .pipe((0, gulp_rename_1.default)(p => p.dirname = p.dirname.replace(/^extension\/?/, '')))
.pipe(packageJsonFilter) .pipe(packageJsonFilter)
.pipe(buffer()) .pipe((0, gulp_buffer_1.default)())
.pipe(json({ __metadata: metadata })) .pipe(json({ __metadata: metadata }))
.pipe(packageJsonFilter.restore); .pipe(packageJsonFilter.restore);
} }
@ -269,7 +305,7 @@ const marketplaceWebExtensionsExclude = new Set([
'ms-vscode.js-debug', 'ms-vscode.js-debug',
'ms-vscode.vscode-js-profile-table' 'ms-vscode.vscode-js-profile-table'
]); ]);
const productJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')); const productJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../product.json'), 'utf8'));
const builtInExtensions = productJson.builtInExtensions || []; const builtInExtensions = productJson.builtInExtensions || [];
const webBuiltInExtensions = productJson.webBuiltInExtensions || []; const webBuiltInExtensions = productJson.webBuiltInExtensions || [];
/** /**
@ -326,7 +362,7 @@ function packageNativeLocalExtensionsStream(forWeb, disableMangle) {
* @returns a stream * @returns a stream
*/ */
function packageAllLocalExtensionsStream(forWeb, disableMangle) { function packageAllLocalExtensionsStream(forWeb, disableMangle) {
return es.merge([ return event_stream_1.default.merge([
packageNonNativeLocalExtensionsStream(forWeb, disableMangle), packageNonNativeLocalExtensionsStream(forWeb, disableMangle),
packageNativeLocalExtensionsStream(forWeb, disableMangle) packageNativeLocalExtensionsStream(forWeb, disableMangle)
]); ]);
@ -338,20 +374,20 @@ function packageAllLocalExtensionsStream(forWeb, disableMangle) {
*/ */
function doPackageLocalExtensionsStream(forWeb, disableMangle, native) { function doPackageLocalExtensionsStream(forWeb, disableMangle, native) {
const nativeExtensionsSet = new Set(nativeExtensions); const nativeExtensionsSet = new Set(nativeExtensions);
const localExtensionsDescriptions = (glob.sync('extensions/*/package.json') const localExtensionsDescriptions = (glob_1.default.sync('extensions/*/package.json')
.map(manifestPath => { .map(manifestPath => {
const absoluteManifestPath = path.join(root, manifestPath); const absoluteManifestPath = path_1.default.join(root, manifestPath);
const extensionPath = path.dirname(path.join(root, manifestPath)); const extensionPath = path_1.default.dirname(path_1.default.join(root, manifestPath));
const extensionName = path.basename(extensionPath); const extensionName = path_1.default.basename(extensionPath);
return { name: extensionName, path: extensionPath, manifestPath: absoluteManifestPath }; return { name: extensionName, path: extensionPath, manifestPath: absoluteManifestPath };
}) })
.filter(({ name }) => native ? nativeExtensionsSet.has(name) : !nativeExtensionsSet.has(name)) .filter(({ name }) => native ? nativeExtensionsSet.has(name) : !nativeExtensionsSet.has(name))
.filter(({ name }) => excludedExtensions.indexOf(name) === -1) .filter(({ name }) => excludedExtensions.indexOf(name) === -1)
.filter(({ name }) => builtInExtensions.every(b => b.name !== name)) .filter(({ name }) => builtInExtensions.every(b => b.name !== name))
.filter(({ manifestPath }) => (forWeb ? isWebExtension(require(manifestPath)) : true))); .filter(({ manifestPath }) => (forWeb ? isWebExtension(require(manifestPath)) : true)));
const localExtensionsStream = minifyExtensionResources(es.merge(...localExtensionsDescriptions.map(extension => { const localExtensionsStream = minifyExtensionResources(event_stream_1.default.merge(...localExtensionsDescriptions.map(extension => {
return fromLocal(extension.path, forWeb, disableMangle) return fromLocal(extension.path, forWeb, disableMangle)
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); .pipe((0, gulp_rename_1.default)(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
}))); })));
let result; let result;
if (forWeb) { if (forWeb) {
@ -360,10 +396,10 @@ function doPackageLocalExtensionsStream(forWeb, disableMangle, native) {
else { else {
// also include shared production node modules // also include shared production node modules
const productionDependencies = (0, dependencies_1.getProductionDependencies)('extensions/'); const productionDependencies = (0, dependencies_1.getProductionDependencies)('extensions/');
const dependenciesSrc = productionDependencies.map(d => path.relative(root, d)).map(d => [`${d}/**`, `!${d}/**/{test,tests}/**`]).flat(); const dependenciesSrc = productionDependencies.map(d => path_1.default.relative(root, d)).map(d => [`${d}/**`, `!${d}/**/{test,tests}/**`]).flat();
result = es.merge(localExtensionsStream, gulp.src(dependenciesSrc, { base: '.' }) result = event_stream_1.default.merge(localExtensionsStream, gulp_1.default.src(dependenciesSrc, { base: '.' })
.pipe(util2.cleanNodeModules(path.join(root, 'build', '.moduleignore'))) .pipe(util2.cleanNodeModules(path_1.default.join(root, 'build', '.moduleignore')))
.pipe(util2.cleanNodeModules(path.join(root, 'build', `.moduleignore.${process.platform}`)))); .pipe(util2.cleanNodeModules(path_1.default.join(root, 'build', `.moduleignore.${process.platform}`))));
} }
return (result return (result
.pipe(util2.setExecutableBit(['**/*.sh']))); .pipe(util2.setExecutableBit(['**/*.sh'])));
@ -373,9 +409,9 @@ function packageMarketplaceExtensionsStream(forWeb) {
...builtInExtensions.filter(({ name }) => (forWeb ? !marketplaceWebExtensionsExclude.has(name) : true)), ...builtInExtensions.filter(({ name }) => (forWeb ? !marketplaceWebExtensionsExclude.has(name) : true)),
...(forWeb ? webBuiltInExtensions : []) ...(forWeb ? webBuiltInExtensions : [])
]; ];
const marketplaceExtensionsStream = minifyExtensionResources(es.merge(...marketplaceExtensionsDescriptions const marketplaceExtensionsStream = minifyExtensionResources(event_stream_1.default.merge(...marketplaceExtensionsDescriptions
.map(extension => { .map(extension => {
const src = (0, builtInExtensions_1.getExtensionStream)(extension).pipe(rename(p => p.dirname = `extensions/${p.dirname}`)); const src = (0, builtInExtensions_1.getExtensionStream)(extension).pipe((0, gulp_rename_1.default)(p => p.dirname = `extensions/${p.dirname}`));
return updateExtensionPackageJSON(src, (data) => { return updateExtensionPackageJSON(src, (data) => {
delete data.scripts; delete data.scripts;
delete data.dependencies; delete data.dependencies;
@ -389,30 +425,30 @@ function packageMarketplaceExtensionsStream(forWeb) {
function scanBuiltinExtensions(extensionsRoot, exclude = []) { function scanBuiltinExtensions(extensionsRoot, exclude = []) {
const scannedExtensions = []; const scannedExtensions = [];
try { try {
const extensionsFolders = fs.readdirSync(extensionsRoot); const extensionsFolders = fs_1.default.readdirSync(extensionsRoot);
for (const extensionFolder of extensionsFolders) { for (const extensionFolder of extensionsFolders) {
if (exclude.indexOf(extensionFolder) >= 0) { if (exclude.indexOf(extensionFolder) >= 0) {
continue; continue;
} }
const packageJSONPath = path.join(extensionsRoot, extensionFolder, 'package.json'); const packageJSONPath = path_1.default.join(extensionsRoot, extensionFolder, 'package.json');
if (!fs.existsSync(packageJSONPath)) { if (!fs_1.default.existsSync(packageJSONPath)) {
continue; continue;
} }
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8')); const packageJSON = JSON.parse(fs_1.default.readFileSync(packageJSONPath).toString('utf8'));
if (!isWebExtension(packageJSON)) { if (!isWebExtension(packageJSON)) {
continue; continue;
} }
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder)); const children = fs_1.default.readdirSync(path_1.default.join(extensionsRoot, extensionFolder));
const packageNLSPath = children.filter(child => child === 'package.nls.json')[0]; const packageNLSPath = children.filter(child => child === 'package.nls.json')[0];
const packageNLS = packageNLSPath ? JSON.parse(fs.readFileSync(path.join(extensionsRoot, extensionFolder, packageNLSPath)).toString()) : undefined; const packageNLS = packageNLSPath ? JSON.parse(fs_1.default.readFileSync(path_1.default.join(extensionsRoot, extensionFolder, packageNLSPath)).toString()) : undefined;
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0]; const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0]; const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
scannedExtensions.push({ scannedExtensions.push({
extensionPath: extensionFolder, extensionPath: extensionFolder,
packageJSON, packageJSON,
packageNLS, packageNLS,
readmePath: readme ? path.join(extensionFolder, readme) : undefined, readmePath: readme ? path_1.default.join(extensionFolder, readme) : undefined,
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined, changelogPath: changelog ? path_1.default.join(extensionFolder, changelog) : undefined,
}); });
} }
return scannedExtensions; return scannedExtensions;
@ -423,7 +459,7 @@ function scanBuiltinExtensions(extensionsRoot, exclude = []) {
} }
function translatePackageJSON(packageJSON, packageNLSPath) { function translatePackageJSON(packageJSON, packageNLSPath) {
const CharCode_PC = '%'.charCodeAt(0); const CharCode_PC = '%'.charCodeAt(0);
const packageNls = JSON.parse(fs.readFileSync(packageNLSPath).toString()); const packageNls = JSON.parse(fs_1.default.readFileSync(packageNLSPath).toString());
const translate = (obj) => { const translate = (obj) => {
for (const key in obj) { for (const key in obj) {
const val = obj[key]; const val = obj[key];
@ -444,7 +480,7 @@ function translatePackageJSON(packageJSON, packageNLSPath) {
translate(packageJSON); translate(packageJSON);
return packageJSON; return packageJSON;
} }
const extensionsPath = path.join(root, 'extensions'); const extensionsPath = path_1.default.join(root, 'extensions');
// Additional projects to run esbuild on. These typically build code for webviews // Additional projects to run esbuild on. These typically build code for webviews
const esbuildMediaScripts = [ const esbuildMediaScripts = [
'markdown-language-features/esbuild-notebook.js', 'markdown-language-features/esbuild-notebook.js',
@ -463,7 +499,7 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) { for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn; const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;
if (outputRoot) { if (outputRoot) {
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path)); config.output.path = path_1.default.join(outputRoot, path_1.default.relative(path_1.default.dirname(configPath), config.output.path));
} }
webpackConfigs.push(config); webpackConfigs.push(config);
} }
@ -475,18 +511,18 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
for (const stats of fullStats.children) { for (const stats of fullStats.children) {
const outputPath = stats.outputPath; const outputPath = stats.outputPath;
if (outputPath) { if (outputPath) {
const relativePath = path.relative(extensionsPath, outputPath).replace(/\\/g, '/'); const relativePath = path_1.default.relative(extensionsPath, outputPath).replace(/\\/g, '/');
const match = relativePath.match(/[^\/]+(\/server|\/client)?/); const match = relativePath.match(/[^\/]+(\/server|\/client)?/);
fancyLog(`Finished ${ansiColors.green(taskName)} ${ansiColors.cyan(match[0])} with ${stats.errors.length} errors.`); (0, fancy_log_1.default)(`Finished ${ansi_colors_1.default.green(taskName)} ${ansi_colors_1.default.cyan(match[0])} with ${stats.errors.length} errors.`);
} }
if (Array.isArray(stats.errors)) { if (Array.isArray(stats.errors)) {
stats.errors.forEach((error) => { stats.errors.forEach((error) => {
fancyLog.error(error); fancy_log_1.default.error(error);
}); });
} }
if (Array.isArray(stats.warnings)) { if (Array.isArray(stats.warnings)) {
stats.warnings.forEach((warning) => { stats.warnings.forEach((warning) => {
fancyLog.warn(warning); fancy_log_1.default.warn(warning);
}); });
} }
} }
@ -506,7 +542,7 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
else { else {
webpack(webpackConfigs).run((err, stats) => { webpack(webpackConfigs).run((err, stats) => {
if (err) { if (err) {
fancyLog.error(err); fancy_log_1.default.error(err);
reject(); reject();
} }
else { else {
@ -520,9 +556,9 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
async function esbuildExtensions(taskName, isWatch, scripts) { async function esbuildExtensions(taskName, isWatch, scripts) {
function reporter(stdError, script) { function reporter(stdError, script) {
const matches = (stdError || '').match(/\> (.+): error: (.+)?/g); const matches = (stdError || '').match(/\> (.+): error: (.+)?/g);
fancyLog(`Finished ${ansiColors.green(taskName)} ${script} with ${matches ? matches.length : 0} errors.`); (0, fancy_log_1.default)(`Finished ${ansi_colors_1.default.green(taskName)} ${script} with ${matches ? matches.length : 0} errors.`);
for (const match of matches || []) { for (const match of matches || []) {
fancyLog.error(match); fancy_log_1.default.error(match);
} }
} }
const tasks = scripts.map(({ script, outputRoot }) => { const tasks = scripts.map(({ script, outputRoot }) => {
@ -534,7 +570,7 @@ async function esbuildExtensions(taskName, isWatch, scripts) {
if (outputRoot) { if (outputRoot) {
args.push('--outputRoot', outputRoot); args.push('--outputRoot', outputRoot);
} }
const proc = cp.execFile(process.argv[0], args, {}, (error, _stdout, stderr) => { const proc = child_process_1.default.execFile(process.argv[0], args, {}, (error, _stdout, stderr) => {
if (error) { if (error) {
return reject(error); return reject(error);
} }
@ -542,7 +578,7 @@ async function esbuildExtensions(taskName, isWatch, scripts) {
return resolve(); return resolve();
}); });
proc.stdout.on('data', (data) => { proc.stdout.on('data', (data) => {
fancyLog(`${ansiColors.green(taskName)}: ${data.toString('utf8')}`); (0, fancy_log_1.default)(`${ansi_colors_1.default.green(taskName)}: ${data.toString('utf8')}`);
}); });
}); });
}); });
@ -550,8 +586,8 @@ async function esbuildExtensions(taskName, isWatch, scripts) {
} }
async function buildExtensionMedia(isWatch, outputRoot) { async function buildExtensionMedia(isWatch, outputRoot) {
return esbuildExtensions('esbuilding extension media', isWatch, esbuildMediaScripts.map(p => ({ return esbuildExtensions('esbuilding extension media', isWatch, esbuildMediaScripts.map(p => ({
script: path.join(extensionsPath, p), script: path_1.default.join(extensionsPath, p),
outputRoot: outputRoot ? path.join(root, outputRoot, path.dirname(p)) : undefined outputRoot: outputRoot ? path_1.default.join(root, outputRoot, path_1.default.dirname(p)) : undefined
}))); })));
} }
//# sourceMappingURL=extensions.js.map //# sourceMappingURL=extensions.js.map

View File

@ -3,24 +3,24 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import es from 'event-stream';
import * as fs from 'fs'; import fs from 'fs';
import * as cp from 'child_process'; import cp from 'child_process';
import * as glob from 'glob'; import glob from 'glob';
import * as gulp from 'gulp'; import gulp from 'gulp';
import * as path from 'path'; import path from 'path';
import { Stream } from 'stream'; import { Stream } from 'stream';
import * as File from 'vinyl'; import File from 'vinyl';
import { createStatsStream } from './stats'; import { createStatsStream } from './stats';
import * as util2 from './util'; import * as util2 from './util';
const vzip = require('gulp-vinyl-zip'); const vzip = require('gulp-vinyl-zip');
import filter = require('gulp-filter'); import filter from 'gulp-filter';
import rename = require('gulp-rename'); import rename from 'gulp-rename';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
const buffer = require('gulp-buffer'); import buffer from 'gulp-buffer';
import * as jsoncParser from 'jsonc-parser'; import * as jsoncParser from 'jsonc-parser';
import webpack = require('webpack'); import webpack from 'webpack';
import { getProductionDependencies } from './dependencies'; import { getProductionDependencies } from './dependencies';
import { IExtensionDefinition, getExtensionStream } from './builtInExtensions'; import { IExtensionDefinition, getExtensionStream } from './builtInExtensions';
import { getVersion } from './getVersion'; import { getVersion } from './getVersion';

View File

@ -3,16 +3,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchUrls = fetchUrls; exports.fetchUrls = fetchUrls;
exports.fetchUrl = fetchUrl; exports.fetchUrl = fetchUrl;
exports.fetchGithub = fetchGithub; exports.fetchGithub = fetchGithub;
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const VinylFile = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const log = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const crypto = require("crypto"); const crypto_1 = __importDefault(require("crypto"));
const through2 = require("through2"); const through2_1 = __importDefault(require("through2"));
function fetchUrls(urls, options) { function fetchUrls(urls, options) {
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
@ -23,7 +26,7 @@ function fetchUrls(urls, options) {
if (!Array.isArray(urls)) { if (!Array.isArray(urls)) {
urls = [urls]; urls = [urls];
} }
return es.readArray(urls).pipe(es.map((data, cb) => { return event_stream_1.default.readArray(urls).pipe(event_stream_1.default.map((data, cb) => {
const url = [options.base, data].join(''); const url = [options.base, data].join('');
fetchUrl(url, options).then(file => { fetchUrl(url, options).then(file => {
cb(undefined, file); cb(undefined, file);
@ -37,7 +40,7 @@ async function fetchUrl(url, options, retries = 10, retryDelay = 1000) {
try { try {
let startTime = 0; let startTime = 0;
if (verbose) { if (verbose) {
log(`Start fetching ${ansiColors.magenta(url)}${retries !== 10 ? ` (${10 - retries} retry)` : ''}`); (0, fancy_log_1.default)(`Start fetching ${ansi_colors_1.default.magenta(url)}${retries !== 10 ? ` (${10 - retries} retry)` : ''}`);
startTime = new Date().getTime(); startTime = new Date().getTime();
} }
const controller = new AbortController(); const controller = new AbortController();
@ -48,33 +51,33 @@ async function fetchUrl(url, options, retries = 10, retryDelay = 1000) {
signal: controller.signal /* Typings issue with lib.dom.d.ts */ signal: controller.signal /* Typings issue with lib.dom.d.ts */
}); });
if (verbose) { if (verbose) {
log(`Fetch completed: Status ${response.status}. Took ${ansiColors.magenta(`${new Date().getTime() - startTime} ms`)}`); (0, fancy_log_1.default)(`Fetch completed: Status ${response.status}. Took ${ansi_colors_1.default.magenta(`${new Date().getTime() - startTime} ms`)}`);
} }
if (response.ok && (response.status >= 200 && response.status < 300)) { if (response.ok && (response.status >= 200 && response.status < 300)) {
const contents = Buffer.from(await response.arrayBuffer()); const contents = Buffer.from(await response.arrayBuffer());
if (options.checksumSha256) { if (options.checksumSha256) {
const actualSHA256Checksum = crypto.createHash('sha256').update(contents).digest('hex'); const actualSHA256Checksum = crypto_1.default.createHash('sha256').update(contents).digest('hex');
if (actualSHA256Checksum !== options.checksumSha256) { if (actualSHA256Checksum !== options.checksumSha256) {
throw new Error(`Checksum mismatch for ${ansiColors.cyan(url)} (expected ${options.checksumSha256}, actual ${actualSHA256Checksum}))`); throw new Error(`Checksum mismatch for ${ansi_colors_1.default.cyan(url)} (expected ${options.checksumSha256}, actual ${actualSHA256Checksum}))`);
} }
else if (verbose) { else if (verbose) {
log(`Verified SHA256 checksums match for ${ansiColors.cyan(url)}`); (0, fancy_log_1.default)(`Verified SHA256 checksums match for ${ansi_colors_1.default.cyan(url)}`);
} }
} }
else if (verbose) { else if (verbose) {
log(`Skipping checksum verification for ${ansiColors.cyan(url)} because no expected checksum was provided`); (0, fancy_log_1.default)(`Skipping checksum verification for ${ansi_colors_1.default.cyan(url)} because no expected checksum was provided`);
} }
if (verbose) { if (verbose) {
log(`Fetched response body buffer: ${ansiColors.magenta(`${contents.byteLength} bytes`)}`); (0, fancy_log_1.default)(`Fetched response body buffer: ${ansi_colors_1.default.magenta(`${contents.byteLength} bytes`)}`);
} }
return new VinylFile({ return new vinyl_1.default({
cwd: '/', cwd: '/',
base: options.base, base: options.base,
path: url, path: url,
contents contents
}); });
} }
let err = `Request ${ansiColors.magenta(url)} failed with status code: ${response.status}`; let err = `Request ${ansi_colors_1.default.magenta(url)} failed with status code: ${response.status}`;
if (response.status === 403) { if (response.status === 403) {
err += ' (you may be rate limited)'; err += ' (you may be rate limited)';
} }
@ -86,7 +89,7 @@ async function fetchUrl(url, options, retries = 10, retryDelay = 1000) {
} }
catch (e) { catch (e) {
if (verbose) { if (verbose) {
log(`Fetching ${ansiColors.cyan(url)} failed: ${e}`); (0, fancy_log_1.default)(`Fetching ${ansi_colors_1.default.cyan(url)} failed: ${e}`);
} }
if (retries > 0) { if (retries > 0) {
await new Promise(resolve => setTimeout(resolve, retryDelay)); await new Promise(resolve => setTimeout(resolve, retryDelay));
@ -117,7 +120,7 @@ function fetchGithub(repo, options) {
base: 'https://api.github.com', base: 'https://api.github.com',
verbose: options.verbose, verbose: options.verbose,
nodeFetchOptions: { headers: ghApiHeaders } nodeFetchOptions: { headers: ghApiHeaders }
}).pipe(through2.obj(async function (file, _enc, callback) { }).pipe(through2_1.default.obj(async function (file, _enc, callback) {
const assetFilter = typeof options.name === 'string' ? (name) => name === options.name : options.name; const assetFilter = typeof options.name === 'string' ? (name) => name === options.name : options.name;
const asset = JSON.parse(file.contents.toString()).assets.find((a) => assetFilter(a.name)); const asset = JSON.parse(file.contents.toString()).assets.find((a) => assetFilter(a.name));
if (!asset) { if (!asset) {

View File

@ -3,12 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import es from 'event-stream';
import * as VinylFile from 'vinyl'; import VinylFile from 'vinyl';
import * as log from 'fancy-log'; import log from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
import * as crypto from 'crypto'; import crypto from 'crypto';
import * as through2 from 'through2'; import through2 from 'through2';
import { Stream } from 'stream'; import { Stream } from 'stream';
export interface IFetchOptions { export interface IFetchOptions {

View File

@ -1,17 +1,20 @@
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.format = format; exports.format = format;
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const ts = require("typescript"); const typescript_1 = __importDefault(require("typescript"));
class LanguageServiceHost { class LanguageServiceHost {
files = {}; files = {};
addFile(fileName, text) { addFile(fileName, text) {
this.files[fileName] = ts.ScriptSnapshot.fromString(text); this.files[fileName] = typescript_1.default.ScriptSnapshot.fromString(text);
} }
fileExists(path) { fileExists(path) {
return !!this.files[path]; return !!this.files[path];
@ -20,18 +23,18 @@ class LanguageServiceHost {
return this.files[path]?.getText(0, this.files[path].getLength()); return this.files[path]?.getText(0, this.files[path].getLength());
} }
// for ts.LanguageServiceHost // for ts.LanguageServiceHost
getCompilationSettings = () => ts.getDefaultCompilerOptions(); getCompilationSettings = () => typescript_1.default.getDefaultCompilerOptions();
getScriptFileNames = () => Object.keys(this.files); getScriptFileNames = () => Object.keys(this.files);
getScriptVersion = (_fileName) => '0'; getScriptVersion = (_fileName) => '0';
getScriptSnapshot = (fileName) => this.files[fileName]; getScriptSnapshot = (fileName) => this.files[fileName];
getCurrentDirectory = () => process.cwd(); getCurrentDirectory = () => process.cwd();
getDefaultLibFileName = (options) => ts.getDefaultLibFilePath(options); getDefaultLibFileName = (options) => typescript_1.default.getDefaultLibFilePath(options);
} }
const defaults = { const defaults = {
baseIndentSize: 0, baseIndentSize: 0,
indentSize: 4, indentSize: 4,
tabSize: 4, tabSize: 4,
indentStyle: ts.IndentStyle.Smart, indentStyle: typescript_1.default.IndentStyle.Smart,
newLineCharacter: '\r\n', newLineCharacter: '\r\n',
convertTabsToSpaces: false, convertTabsToSpaces: false,
insertSpaceAfterCommaDelimiter: true, insertSpaceAfterCommaDelimiter: true,
@ -54,14 +57,14 @@ const defaults = {
const getOverrides = (() => { const getOverrides = (() => {
let value; let value;
return () => { return () => {
value ??= JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'tsfmt.json'), 'utf8')); value ??= JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '..', '..', 'tsfmt.json'), 'utf8'));
return value; return value;
}; };
})(); })();
function format(fileName, text) { function format(fileName, text) {
const host = new LanguageServiceHost(); const host = new LanguageServiceHost();
host.addFile(fileName, text); host.addFile(fileName, text);
const languageService = ts.createLanguageService(host); const languageService = typescript_1.default.createLanguageService(host);
const edits = languageService.getFormattingEditsForDocument(fileName, { ...defaults, ...getOverrides() }); const edits = languageService.getFormattingEditsForDocument(fileName, { ...defaults, ...getOverrides() });
edits edits
.sort((a, b) => a.span.start - b.span.start) .sort((a, b) => a.span.start - b.span.start)

View File

@ -2,9 +2,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as ts from 'typescript'; import ts from 'typescript';
class LanguageServiceHost implements ts.LanguageServiceHost { class LanguageServiceHost implements ts.LanguageServiceHost {

View File

@ -3,9 +3,42 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getVersion = getVersion; exports.getVersion = getVersion;
const git = require("./git"); const git = __importStar(require("./git"));
function getVersion(root) { function getVersion(root) {
let version = process.env['BUILD_SOURCEVERSION']; let version = process.env['BUILD_SOURCEVERSION'];
if (!version || !/^[0-9a-f]{40}$/i.test(version.trim())) { if (!version || !/^[0-9a-f]{40}$/i.test(version.trim())) {

View File

@ -1,21 +1,24 @@
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getVersion = getVersion; exports.getVersion = getVersion;
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
const path = require("path"); const path_1 = __importDefault(require("path"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
/** /**
* Returns the sha1 commit version of a repository or undefined in case of failure. * Returns the sha1 commit version of a repository or undefined in case of failure.
*/ */
function getVersion(repo) { function getVersion(repo) {
const git = path.join(repo, '.git'); const git = path_1.default.join(repo, '.git');
const headPath = path.join(git, 'HEAD'); const headPath = path_1.default.join(git, 'HEAD');
let head; let head;
try { try {
head = fs.readFileSync(headPath, 'utf8').trim(); head = fs_1.default.readFileSync(headPath, 'utf8').trim();
} }
catch (e) { catch (e) {
return undefined; return undefined;
@ -28,17 +31,17 @@ function getVersion(repo) {
return undefined; return undefined;
} }
const ref = refMatch[1]; const ref = refMatch[1];
const refPath = path.join(git, ref); const refPath = path_1.default.join(git, ref);
try { try {
return fs.readFileSync(refPath, 'utf8').trim(); return fs_1.default.readFileSync(refPath, 'utf8').trim();
} }
catch (e) { catch (e) {
// noop // noop
} }
const packedRefsPath = path.join(git, 'packed-refs'); const packedRefsPath = path_1.default.join(git, 'packed-refs');
let refsRaw; let refsRaw;
try { try {
refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim(); refsRaw = fs_1.default.readFileSync(packedRefsPath, 'utf8').trim();
} }
catch (e) { catch (e) {
return undefined; return undefined;

View File

@ -2,8 +2,8 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as fs from 'fs'; import fs from 'fs';
/** /**
* Returns the sha1 commit version of a repository or undefined in case of failure. * Returns the sha1 commit version of a repository or undefined in case of failure.

View File

@ -3,6 +3,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.EXTERNAL_EXTENSIONS = exports.XLF = exports.Line = exports.extraLanguages = exports.defaultLanguages = void 0; exports.EXTERNAL_EXTENSIONS = exports.XLF = exports.Line = exports.extraLanguages = exports.defaultLanguages = void 0;
exports.processNlsFiles = processNlsFiles; exports.processNlsFiles = processNlsFiles;
@ -12,20 +15,20 @@ exports.createXlfFilesForExtensions = createXlfFilesForExtensions;
exports.createXlfFilesForIsl = createXlfFilesForIsl; exports.createXlfFilesForIsl = createXlfFilesForIsl;
exports.prepareI18nPackFiles = prepareI18nPackFiles; exports.prepareI18nPackFiles = prepareI18nPackFiles;
exports.prepareIslFiles = prepareIslFiles; exports.prepareIslFiles = prepareIslFiles;
const path = require("path"); const path_1 = __importDefault(require("path"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const event_stream_1 = require("event-stream"); const event_stream_1 = require("event-stream");
const jsonMerge = require("gulp-merge-json"); const gulp_merge_json_1 = __importDefault(require("gulp-merge-json"));
const File = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const xml2js = require("xml2js"); const xml2js_1 = __importDefault(require("xml2js"));
const gulp = require("gulp"); const gulp_1 = __importDefault(require("gulp"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const iconv = require("@vscode/iconv-lite-umd"); const iconv_lite_umd_1 = __importDefault(require("@vscode/iconv-lite-umd"));
const l10n_dev_1 = require("@vscode/l10n-dev"); const l10n_dev_1 = require("@vscode/l10n-dev");
const REPO_ROOT_PATH = path.join(__dirname, '../..'); const REPO_ROOT_PATH = path_1.default.join(__dirname, '../..');
function log(message, ...rest) { function log(message, ...rest) {
fancyLog(ansiColors.green('[i18n]'), message, ...rest); (0, fancy_log_1.default)(ansi_colors_1.default.green('[i18n]'), message, ...rest);
} }
exports.defaultLanguages = [ exports.defaultLanguages = [
{ id: 'zh-tw', folderName: 'cht', translationId: 'zh-hant' }, { id: 'zh-tw', folderName: 'cht', translationId: 'zh-hant' },
@ -188,7 +191,7 @@ class XLF {
} }
static parse = function (xlfString) { static parse = function (xlfString) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const parser = new xml2js.Parser(); const parser = new xml2js_1.default.Parser();
const files = []; const files = [];
parser.parseString(xlfString, function (err, result) { parser.parseString(xlfString, function (err, result) {
if (err) { if (err) {
@ -278,8 +281,8 @@ function stripComments(content) {
return result; return result;
} }
function processCoreBundleFormat(base, fileHeader, languages, json, emitter) { function processCoreBundleFormat(base, fileHeader, languages, json, emitter) {
const languageDirectory = path.join(REPO_ROOT_PATH, '..', 'vscode-loc', 'i18n'); const languageDirectory = path_1.default.join(REPO_ROOT_PATH, '..', 'vscode-loc', 'i18n');
if (!fs.existsSync(languageDirectory)) { if (!fs_1.default.existsSync(languageDirectory)) {
log(`No VS Code localization repository found. Looking at ${languageDirectory}`); log(`No VS Code localization repository found. Looking at ${languageDirectory}`);
log(`To bundle translations please check out the vscode-loc repository as a sibling of the vscode repository.`); log(`To bundle translations please check out the vscode-loc repository as a sibling of the vscode repository.`);
} }
@ -289,10 +292,10 @@ function processCoreBundleFormat(base, fileHeader, languages, json, emitter) {
log(`Generating nls bundles for: ${language.id}`); log(`Generating nls bundles for: ${language.id}`);
} }
const languageFolderName = language.translationId || language.id; const languageFolderName = language.translationId || language.id;
const i18nFile = path.join(languageDirectory, `vscode-language-pack-${languageFolderName}`, 'translations', 'main.i18n.json'); const i18nFile = path_1.default.join(languageDirectory, `vscode-language-pack-${languageFolderName}`, 'translations', 'main.i18n.json');
let allMessages; let allMessages;
if (fs.existsSync(i18nFile)) { if (fs_1.default.existsSync(i18nFile)) {
const content = stripComments(fs.readFileSync(i18nFile, 'utf8')); const content = stripComments(fs_1.default.readFileSync(i18nFile, 'utf8'));
allMessages = JSON.parse(content); allMessages = JSON.parse(content);
} }
let nlsIndex = 0; let nlsIndex = 0;
@ -304,7 +307,7 @@ function processCoreBundleFormat(base, fileHeader, languages, json, emitter) {
nlsIndex++; nlsIndex++;
} }
} }
emitter.queue(new File({ emitter.queue(new vinyl_1.default({
contents: Buffer.from(`${fileHeader} contents: Buffer.from(`${fileHeader}
globalThis._VSCODE_NLS_MESSAGES=${JSON.stringify(nlsResult)}; globalThis._VSCODE_NLS_MESSAGES=${JSON.stringify(nlsResult)};
globalThis._VSCODE_NLS_LANGUAGE=${JSON.stringify(language.id)};`), globalThis._VSCODE_NLS_LANGUAGE=${JSON.stringify(language.id)};`),
@ -315,10 +318,10 @@ globalThis._VSCODE_NLS_LANGUAGE=${JSON.stringify(language.id)};`),
} }
function processNlsFiles(opts) { function processNlsFiles(opts) {
return (0, event_stream_1.through)(function (file) { return (0, event_stream_1.through)(function (file) {
const fileName = path.basename(file.path); const fileName = path_1.default.basename(file.path);
if (fileName === 'bundleInfo.json') { // pick a root level file to put the core bundles (TODO@esm this file is not created anymore, pick another) if (fileName === 'bundleInfo.json') { // pick a root level file to put the core bundles (TODO@esm this file is not created anymore, pick another)
try { try {
const json = JSON.parse(fs.readFileSync(path.join(REPO_ROOT_PATH, opts.out, 'nls.keys.json')).toString()); const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(REPO_ROOT_PATH, opts.out, 'nls.keys.json')).toString());
if (NLSKeysFormat.is(json)) { if (NLSKeysFormat.is(json)) {
processCoreBundleFormat(file.base, opts.fileHeader, opts.languages, json, this); processCoreBundleFormat(file.base, opts.fileHeader, opts.languages, json, this);
} }
@ -366,7 +369,7 @@ function getResource(sourceFile) {
} }
function createXlfFilesForCoreBundle() { function createXlfFilesForCoreBundle() {
return (0, event_stream_1.through)(function (file) { return (0, event_stream_1.through)(function (file) {
const basename = path.basename(file.path); const basename = path_1.default.basename(file.path);
if (basename === 'nls.metadata.json') { if (basename === 'nls.metadata.json') {
if (file.isBuffer()) { if (file.isBuffer()) {
const xlfs = Object.create(null); const xlfs = Object.create(null);
@ -393,7 +396,7 @@ function createXlfFilesForCoreBundle() {
for (const resource in xlfs) { for (const resource in xlfs) {
const xlf = xlfs[resource]; const xlf = xlfs[resource];
const filePath = `${xlf.project}/${resource.replace(/\//g, '_')}.xlf`; const filePath = `${xlf.project}/${resource.replace(/\//g, '_')}.xlf`;
const xlfFile = new File({ const xlfFile = new vinyl_1.default({
path: filePath, path: filePath,
contents: Buffer.from(xlf.toString(), 'utf8') contents: Buffer.from(xlf.toString(), 'utf8')
}); });
@ -413,7 +416,7 @@ function createXlfFilesForCoreBundle() {
} }
function createL10nBundleForExtension(extensionFolderName, prefixWithBuildFolder) { function createL10nBundleForExtension(extensionFolderName, prefixWithBuildFolder) {
const prefix = prefixWithBuildFolder ? '.build/' : ''; const prefix = prefixWithBuildFolder ? '.build/' : '';
return gulp return gulp_1.default
.src([ .src([
// For source code of extensions // For source code of extensions
`${prefix}extensions/${extensionFolderName}/{src,client,server}/**/*.{ts,tsx}`, `${prefix}extensions/${extensionFolderName}/{src,client,server}/**/*.{ts,tsx}`,
@ -429,12 +432,12 @@ function createL10nBundleForExtension(extensionFolderName, prefixWithBuildFolder
callback(); callback();
return; return;
} }
const extension = path.extname(file.relative); const extension = path_1.default.extname(file.relative);
if (extension !== '.json') { if (extension !== '.json') {
const contents = file.contents.toString('utf8'); const contents = file.contents.toString('utf8');
(0, l10n_dev_1.getL10nJson)([{ contents, extension }]) (0, l10n_dev_1.getL10nJson)([{ contents, extension }])
.then((json) => { .then((json) => {
callback(undefined, new File({ callback(undefined, new vinyl_1.default({
path: `extensions/${extensionFolderName}/bundle.l10n.json`, path: `extensions/${extensionFolderName}/bundle.l10n.json`,
contents: Buffer.from(JSON.stringify(json), 'utf8') contents: Buffer.from(JSON.stringify(json), 'utf8')
})); }));
@ -464,7 +467,7 @@ function createL10nBundleForExtension(extensionFolderName, prefixWithBuildFolder
} }
callback(undefined, file); callback(undefined, file);
})) }))
.pipe(jsonMerge({ .pipe((0, gulp_merge_json_1.default)({
fileName: `extensions/${extensionFolderName}/bundle.l10n.json`, fileName: `extensions/${extensionFolderName}/bundle.l10n.json`,
jsonSpace: '', jsonSpace: '',
concatArrays: true concatArrays: true
@ -481,16 +484,16 @@ function createXlfFilesForExtensions() {
let folderStreamEndEmitted = false; let folderStreamEndEmitted = false;
return (0, event_stream_1.through)(function (extensionFolder) { return (0, event_stream_1.through)(function (extensionFolder) {
const folderStream = this; const folderStream = this;
const stat = fs.statSync(extensionFolder.path); const stat = fs_1.default.statSync(extensionFolder.path);
if (!stat.isDirectory()) { if (!stat.isDirectory()) {
return; return;
} }
const extensionFolderName = path.basename(extensionFolder.path); const extensionFolderName = path_1.default.basename(extensionFolder.path);
if (extensionFolderName === 'node_modules') { if (extensionFolderName === 'node_modules') {
return; return;
} }
// Get extension id and use that as the id // Get extension id and use that as the id
const manifest = fs.readFileSync(path.join(extensionFolder.path, 'package.json'), 'utf-8'); const manifest = fs_1.default.readFileSync(path_1.default.join(extensionFolder.path, 'package.json'), 'utf-8');
const manifestJson = JSON.parse(manifest); const manifestJson = JSON.parse(manifest);
const extensionId = manifestJson.publisher + '.' + manifestJson.name; const extensionId = manifestJson.publisher + '.' + manifestJson.name;
counter++; counter++;
@ -501,17 +504,17 @@ function createXlfFilesForExtensions() {
} }
return _l10nMap; return _l10nMap;
} }
(0, event_stream_1.merge)(gulp.src([`.build/extensions/${extensionFolderName}/package.nls.json`, `.build/extensions/${extensionFolderName}/**/nls.metadata.json`], { allowEmpty: true }), createL10nBundleForExtension(extensionFolderName, exports.EXTERNAL_EXTENSIONS.includes(extensionId))).pipe((0, event_stream_1.through)(function (file) { (0, event_stream_1.merge)(gulp_1.default.src([`.build/extensions/${extensionFolderName}/package.nls.json`, `.build/extensions/${extensionFolderName}/**/nls.metadata.json`], { allowEmpty: true }), createL10nBundleForExtension(extensionFolderName, exports.EXTERNAL_EXTENSIONS.includes(extensionId))).pipe((0, event_stream_1.through)(function (file) {
if (file.isBuffer()) { if (file.isBuffer()) {
const buffer = file.contents; const buffer = file.contents;
const basename = path.basename(file.path); const basename = path_1.default.basename(file.path);
if (basename === 'package.nls.json') { if (basename === 'package.nls.json') {
const json = JSON.parse(buffer.toString('utf8')); const json = JSON.parse(buffer.toString('utf8'));
getL10nMap().set(`extensions/${extensionId}/package`, json); getL10nMap().set(`extensions/${extensionId}/package`, json);
} }
else if (basename === 'nls.metadata.json') { else if (basename === 'nls.metadata.json') {
const json = JSON.parse(buffer.toString('utf8')); const json = JSON.parse(buffer.toString('utf8'));
const relPath = path.relative(`.build/extensions/${extensionFolderName}`, path.dirname(file.path)); const relPath = path_1.default.relative(`.build/extensions/${extensionFolderName}`, path_1.default.dirname(file.path));
for (const file in json) { for (const file in json) {
const fileContent = json[file]; const fileContent = json[file];
const info = Object.create(null); const info = Object.create(null);
@ -536,8 +539,8 @@ function createXlfFilesForExtensions() {
} }
}, function () { }, function () {
if (_l10nMap?.size > 0) { if (_l10nMap?.size > 0) {
const xlfFile = new File({ const xlfFile = new vinyl_1.default({
path: path.join(extensionsProject, extensionId + '.xlf'), path: path_1.default.join(extensionsProject, extensionId + '.xlf'),
contents: Buffer.from((0, l10n_dev_1.getL10nXlf)(_l10nMap), 'utf8') contents: Buffer.from((0, l10n_dev_1.getL10nXlf)(_l10nMap), 'utf8')
}); });
folderStream.queue(xlfFile); folderStream.queue(xlfFile);
@ -560,7 +563,7 @@ function createXlfFilesForExtensions() {
function createXlfFilesForIsl() { function createXlfFilesForIsl() {
return (0, event_stream_1.through)(function (file) { return (0, event_stream_1.through)(function (file) {
let projectName, resourceFile; let projectName, resourceFile;
if (path.basename(file.path) === 'messages.en.isl') { if (path_1.default.basename(file.path) === 'messages.en.isl') {
projectName = setupProject; projectName = setupProject;
resourceFile = 'messages.xlf'; resourceFile = 'messages.xlf';
} }
@ -602,8 +605,8 @@ function createXlfFilesForIsl() {
const originalPath = file.path.substring(file.cwd.length + 1, file.path.split('.')[0].length).replace(/\\/g, '/'); const originalPath = file.path.substring(file.cwd.length + 1, file.path.split('.')[0].length).replace(/\\/g, '/');
xlf.addFile(originalPath, keys, messages); xlf.addFile(originalPath, keys, messages);
// Emit only upon all ISL files combined into single XLF instance // Emit only upon all ISL files combined into single XLF instance
const newFilePath = path.join(projectName, resourceFile); const newFilePath = path_1.default.join(projectName, resourceFile);
const xlfFile = new File({ path: newFilePath, contents: Buffer.from(xlf.toString(), 'utf-8') }); const xlfFile = new vinyl_1.default({ path: newFilePath, contents: Buffer.from(xlf.toString(), 'utf-8') });
this.queue(xlfFile); this.queue(xlfFile);
}); });
} }
@ -623,8 +626,8 @@ function createI18nFile(name, messages) {
if (process.platform === 'win32') { if (process.platform === 'win32') {
content = content.replace(/\n/g, '\r\n'); content = content.replace(/\n/g, '\r\n');
} }
return new File({ return new vinyl_1.default({
path: path.join(name + '.i18n.json'), path: path_1.default.join(name + '.i18n.json'),
contents: Buffer.from(content, 'utf8') contents: Buffer.from(content, 'utf8')
}); });
} }
@ -643,9 +646,9 @@ function prepareI18nPackFiles(resultingTranslationPaths) {
const extensionsPacks = {}; const extensionsPacks = {};
const errors = []; const errors = [];
return (0, event_stream_1.through)(function (xlf) { return (0, event_stream_1.through)(function (xlf) {
let project = path.basename(path.dirname(path.dirname(xlf.relative))); let project = path_1.default.basename(path_1.default.dirname(path_1.default.dirname(xlf.relative)));
// strip `-new` since vscode-extensions-loc uses the `-new` suffix to indicate that it's from the new loc pipeline // strip `-new` since vscode-extensions-loc uses the `-new` suffix to indicate that it's from the new loc pipeline
const resource = path.basename(path.basename(xlf.relative, '.xlf'), '-new'); const resource = path_1.default.basename(path_1.default.basename(xlf.relative, '.xlf'), '-new');
if (exports.EXTERNAL_EXTENSIONS.find(e => e === resource)) { if (exports.EXTERNAL_EXTENSIONS.find(e => e === resource)) {
project = extensionsProject; project = extensionsProject;
} }
@ -720,11 +723,11 @@ function prepareIslFiles(language, innoSetupConfig) {
function createIslFile(name, messages, language, innoSetup) { function createIslFile(name, messages, language, innoSetup) {
const content = []; const content = [];
let originalContent; let originalContent;
if (path.basename(name) === 'Default') { if (path_1.default.basename(name) === 'Default') {
originalContent = new TextModel(fs.readFileSync(name + '.isl', 'utf8')); originalContent = new TextModel(fs_1.default.readFileSync(name + '.isl', 'utf8'));
} }
else { else {
originalContent = new TextModel(fs.readFileSync(name + '.en.isl', 'utf8')); originalContent = new TextModel(fs_1.default.readFileSync(name + '.en.isl', 'utf8'));
} }
originalContent.lines.forEach(line => { originalContent.lines.forEach(line => {
if (line.length > 0) { if (line.length > 0) {
@ -746,10 +749,10 @@ function createIslFile(name, messages, language, innoSetup) {
} }
} }
}); });
const basename = path.basename(name); const basename = path_1.default.basename(name);
const filePath = `${basename}.${language.id}.isl`; const filePath = `${basename}.${language.id}.isl`;
const encoded = iconv.encode(Buffer.from(content.join('\r\n'), 'utf8').toString(), innoSetup.codePage); const encoded = iconv_lite_umd_1.default.encode(Buffer.from(content.join('\r\n'), 'utf8').toString(), innoSetup.codePage);
return new File({ return new vinyl_1.default({
path: filePath, path: filePath,
contents: Buffer.from(encoded), contents: Buffer.from(encoded),
}); });

View File

@ -3,17 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as fs from 'fs'; import fs from 'fs';
import { map, merge, through, ThroughStream } from 'event-stream'; import { map, merge, through, ThroughStream } from 'event-stream';
import * as jsonMerge from 'gulp-merge-json'; import jsonMerge from 'gulp-merge-json';
import * as File from 'vinyl'; import File from 'vinyl';
import * as xml2js from 'xml2js'; import xml2js from 'xml2js';
import * as gulp from 'gulp'; import gulp from 'gulp';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
import * as iconv from '@vscode/iconv-lite-umd'; import iconv from '@vscode/iconv-lite-umd';
import { l10nJsonFormat, getL10nXlf, l10nJsonDetails, getL10nFilesFromXlf, getL10nJson } from '@vscode/l10n-dev'; import { l10nJsonFormat, getL10nXlf, l10nJsonDetails, getL10nFilesFromXlf, getL10nJson } from '@vscode/l10n-dev';
const REPO_ROOT_PATH = path.join(__dirname, '../..'); const REPO_ROOT_PATH = path.join(__dirname, '../..');

View File

@ -3,9 +3,12 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.inlineMeta = inlineMeta; exports.inlineMeta = inlineMeta;
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const path_1 = require("path"); const path_1 = require("path");
const packageJsonMarkerId = 'BUILD_INSERT_PACKAGE_CONFIGURATION'; const packageJsonMarkerId = 'BUILD_INSERT_PACKAGE_CONFIGURATION';
// TODO in order to inline `product.json`, more work is // TODO in order to inline `product.json`, more work is
@ -16,7 +19,7 @@ const packageJsonMarkerId = 'BUILD_INSERT_PACKAGE_CONFIGURATION';
// - a `target` is added in `gulpfile.vscode.win32.js` // - a `target` is added in `gulpfile.vscode.win32.js`
// const productJsonMarkerId = 'BUILD_INSERT_PRODUCT_CONFIGURATION'; // const productJsonMarkerId = 'BUILD_INSERT_PRODUCT_CONFIGURATION';
function inlineMeta(result, ctx) { function inlineMeta(result, ctx) {
return result.pipe(es.through(function (file) { return result.pipe(event_stream_1.default.through(function (file) {
if (matchesFile(file, ctx)) { if (matchesFile(file, ctx)) {
let content = file.contents.toString(); let content = file.contents.toString();
let markerFound = false; let markerFound = false;

View File

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import es from 'event-stream';
import { basename } from 'path'; import { basename } from 'path';
import * as File from 'vinyl'; import File from 'vinyl';
export interface IInlineMetaContext { export interface IInlineMetaContext {
readonly targetPaths: string[]; readonly targetPaths: string[];

View File

@ -3,8 +3,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const ts = require("typescript"); const typescript_1 = __importDefault(require("typescript"));
const fs_1 = require("fs"); const fs_1 = require("fs");
const path_1 = require("path"); const path_1 = require("path");
const minimatch_1 = require("minimatch"); const minimatch_1 = require("minimatch");
@ -295,8 +298,8 @@ let hasErrors = false;
function checkFile(program, sourceFile, rule) { function checkFile(program, sourceFile, rule) {
checkNode(sourceFile); checkNode(sourceFile);
function checkNode(node) { function checkNode(node) {
if (node.kind !== ts.SyntaxKind.Identifier) { if (node.kind !== typescript_1.default.SyntaxKind.Identifier) {
return ts.forEachChild(node, checkNode); // recurse down return typescript_1.default.forEachChild(node, checkNode); // recurse down
} }
const checker = program.getTypeChecker(); const checker = program.getTypeChecker();
const symbol = checker.getSymbolAtLocation(node); const symbol = checker.getSymbolAtLocation(node);
@ -352,11 +355,11 @@ function checkFile(program, sourceFile, rule) {
} }
} }
function createProgram(tsconfigPath) { function createProgram(tsconfigPath) {
const tsConfig = ts.readConfigFile(tsconfigPath, ts.sys.readFile); const tsConfig = typescript_1.default.readConfigFile(tsconfigPath, typescript_1.default.sys.readFile);
const configHostParser = { fileExists: fs_1.existsSync, readDirectory: ts.sys.readDirectory, readFile: file => (0, fs_1.readFileSync)(file, 'utf8'), useCaseSensitiveFileNames: process.platform === 'linux' }; const configHostParser = { fileExists: fs_1.existsSync, readDirectory: typescript_1.default.sys.readDirectory, readFile: file => (0, fs_1.readFileSync)(file, 'utf8'), useCaseSensitiveFileNames: process.platform === 'linux' };
const tsConfigParsed = ts.parseJsonConfigFileContent(tsConfig.config, configHostParser, (0, path_1.resolve)((0, path_1.dirname)(tsconfigPath)), { noEmit: true }); const tsConfigParsed = typescript_1.default.parseJsonConfigFileContent(tsConfig.config, configHostParser, (0, path_1.resolve)((0, path_1.dirname)(tsconfigPath)), { noEmit: true });
const compilerHost = ts.createCompilerHost(tsConfigParsed.options, true); const compilerHost = typescript_1.default.createCompilerHost(tsConfigParsed.options, true);
return ts.createProgram(tsConfigParsed.fileNames, tsConfigParsed.options, compilerHost); return typescript_1.default.createProgram(tsConfigParsed.fileNames, tsConfigParsed.options, compilerHost);
} }
// //
// Create program and start checking // Create program and start checking

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as ts from 'typescript'; import ts from 'typescript';
import { readFileSync, existsSync } from 'fs'; import { readFileSync, existsSync } from 'fs';
import { resolve, dirname, join } from 'path'; import { resolve, dirname, join } from 'path';
import { match } from 'minimatch'; import { match } from 'minimatch';

View File

@ -3,16 +3,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.Mangler = void 0; exports.Mangler = void 0;
const v8 = require("node:v8"); const node_v8_1 = __importDefault(require("node:v8"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const process_1 = require("process"); const process_1 = require("process");
const source_map_1 = require("source-map"); const source_map_1 = require("source-map");
const ts = require("typescript"); const typescript_1 = __importDefault(require("typescript"));
const url_1 = require("url"); const url_1 = require("url");
const workerpool = require("workerpool"); const workerpool_1 = __importDefault(require("workerpool"));
const staticLanguageServiceHost_1 = require("./staticLanguageServiceHost"); const staticLanguageServiceHost_1 = require("./staticLanguageServiceHost");
const buildfile = require('../../buildfile'); const buildfile = require('../../buildfile');
class ShortIdent { class ShortIdent {
@ -66,29 +69,29 @@ class ClassData {
this.node = node; this.node = node;
const candidates = []; const candidates = [];
for (const member of node.members) { for (const member of node.members) {
if (ts.isMethodDeclaration(member)) { if (typescript_1.default.isMethodDeclaration(member)) {
// method `foo() {}` // method `foo() {}`
candidates.push(member); candidates.push(member);
} }
else if (ts.isPropertyDeclaration(member)) { else if (typescript_1.default.isPropertyDeclaration(member)) {
// property `foo = 234` // property `foo = 234`
candidates.push(member); candidates.push(member);
} }
else if (ts.isGetAccessor(member)) { else if (typescript_1.default.isGetAccessor(member)) {
// getter: `get foo() { ... }` // getter: `get foo() { ... }`
candidates.push(member); candidates.push(member);
} }
else if (ts.isSetAccessor(member)) { else if (typescript_1.default.isSetAccessor(member)) {
// setter: `set foo() { ... }` // setter: `set foo() { ... }`
candidates.push(member); candidates.push(member);
} }
else if (ts.isConstructorDeclaration(member)) { else if (typescript_1.default.isConstructorDeclaration(member)) {
// constructor-prop:`constructor(private foo) {}` // constructor-prop:`constructor(private foo) {}`
for (const param of member.parameters) { for (const param of member.parameters) {
if (hasModifier(param, ts.SyntaxKind.PrivateKeyword) if (hasModifier(param, typescript_1.default.SyntaxKind.PrivateKeyword)
|| hasModifier(param, ts.SyntaxKind.ProtectedKeyword) || hasModifier(param, typescript_1.default.SyntaxKind.ProtectedKeyword)
|| hasModifier(param, ts.SyntaxKind.PublicKeyword) || hasModifier(param, typescript_1.default.SyntaxKind.PublicKeyword)
|| hasModifier(param, ts.SyntaxKind.ReadonlyKeyword)) { || hasModifier(param, typescript_1.default.SyntaxKind.ReadonlyKeyword)) {
candidates.push(param); candidates.push(param);
} }
} }
@ -109,8 +112,8 @@ class ClassData {
} }
const { name } = node; const { name } = node;
let ident = name.getText(); let ident = name.getText();
if (name.kind === ts.SyntaxKind.ComputedPropertyName) { if (name.kind === typescript_1.default.SyntaxKind.ComputedPropertyName) {
if (name.expression.kind !== ts.SyntaxKind.StringLiteral) { if (name.expression.kind !== typescript_1.default.SyntaxKind.StringLiteral) {
// unsupported: [Symbol.foo] or [abc + 'field'] // unsupported: [Symbol.foo] or [abc + 'field']
return; return;
} }
@ -120,10 +123,10 @@ class ClassData {
return ident; return ident;
} }
static _getFieldType(node) { static _getFieldType(node) {
if (hasModifier(node, ts.SyntaxKind.PrivateKeyword)) { if (hasModifier(node, typescript_1.default.SyntaxKind.PrivateKeyword)) {
return 2 /* FieldType.Private */; return 2 /* FieldType.Private */;
} }
else if (hasModifier(node, ts.SyntaxKind.ProtectedKeyword)) { else if (hasModifier(node, typescript_1.default.SyntaxKind.ProtectedKeyword)) {
return 1 /* FieldType.Protected */; return 1 /* FieldType.Protected */;
} }
else { else {
@ -302,7 +305,7 @@ class DeclarationData {
this.replacementName = fileIdents.next(); this.replacementName = fileIdents.next();
} }
getLocations(service) { getLocations(service) {
if (ts.isVariableDeclaration(this.node)) { if (typescript_1.default.isVariableDeclaration(this.node)) {
// If the const aliases any types, we need to rename those too // If the const aliases any types, we need to rename those too
const definitionResult = service.getDefinitionAndBoundSpan(this.fileName, this.node.name.getStart()); const definitionResult = service.getDefinitionAndBoundSpan(this.fileName, this.node.name.getStart());
if (definitionResult?.definitions && definitionResult.definitions.length > 1) { if (definitionResult?.definitions && definitionResult.definitions.length > 1) {
@ -350,20 +353,20 @@ class Mangler {
this.projectPath = projectPath; this.projectPath = projectPath;
this.log = log; this.log = log;
this.config = config; this.config = config;
this.renameWorkerPool = workerpool.pool(path.join(__dirname, 'renameWorker.js'), { this.renameWorkerPool = workerpool_1.default.pool(path_1.default.join(__dirname, 'renameWorker.js'), {
maxWorkers: 1, maxWorkers: 1,
minWorkers: 'max' minWorkers: 'max'
}); });
} }
async computeNewFileContents(strictImplicitPublicHandling) { async computeNewFileContents(strictImplicitPublicHandling) {
const service = ts.createLanguageService(new staticLanguageServiceHost_1.StaticLanguageServiceHost(this.projectPath)); const service = typescript_1.default.createLanguageService(new staticLanguageServiceHost_1.StaticLanguageServiceHost(this.projectPath));
// STEP: // STEP:
// - Find all classes and their field info. // - Find all classes and their field info.
// - Find exported symbols. // - Find exported symbols.
const fileIdents = new ShortIdent('$'); const fileIdents = new ShortIdent('$');
const visit = (node) => { const visit = (node) => {
if (this.config.manglePrivateFields) { if (this.config.manglePrivateFields) {
if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) { if (typescript_1.default.isClassDeclaration(node) || typescript_1.default.isClassExpression(node)) {
const anchor = node.name ?? node; const anchor = node.name ?? node;
const key = `${node.getSourceFile().fileName}|${anchor.getStart()}`; const key = `${node.getSourceFile().fileName}|${anchor.getStart()}`;
if (this.allClassDataByKey.has(key)) { if (this.allClassDataByKey.has(key)) {
@ -376,19 +379,19 @@ class Mangler {
// Find exported classes, functions, and vars // Find exported classes, functions, and vars
if (( if ((
// Exported class // Exported class
ts.isClassDeclaration(node) typescript_1.default.isClassDeclaration(node)
&& hasModifier(node, ts.SyntaxKind.ExportKeyword) && hasModifier(node, typescript_1.default.SyntaxKind.ExportKeyword)
&& node.name) || ( && node.name) || (
// Exported function // Exported function
ts.isFunctionDeclaration(node) typescript_1.default.isFunctionDeclaration(node)
&& ts.isSourceFile(node.parent) && typescript_1.default.isSourceFile(node.parent)
&& hasModifier(node, ts.SyntaxKind.ExportKeyword) && hasModifier(node, typescript_1.default.SyntaxKind.ExportKeyword)
&& node.name && node.body // On named function and not on the overload && node.name && node.body // On named function and not on the overload
) || ( ) || (
// Exported variable // Exported variable
ts.isVariableDeclaration(node) typescript_1.default.isVariableDeclaration(node)
&& hasModifier(node.parent.parent, ts.SyntaxKind.ExportKeyword) // Variable statement is exported && hasModifier(node.parent.parent, typescript_1.default.SyntaxKind.ExportKeyword) // Variable statement is exported
&& ts.isSourceFile(node.parent.parent.parent)) && typescript_1.default.isSourceFile(node.parent.parent.parent))
// Disabled for now because we need to figure out how to handle // Disabled for now because we need to figure out how to handle
// enums that are used in monaco or extHost interfaces. // enums that are used in monaco or extHost interfaces.
/* || ( /* || (
@ -406,17 +409,17 @@ class Mangler {
this.allExportedSymbols.add(new DeclarationData(node.getSourceFile().fileName, node, fileIdents)); this.allExportedSymbols.add(new DeclarationData(node.getSourceFile().fileName, node, fileIdents));
} }
} }
ts.forEachChild(node, visit); typescript_1.default.forEachChild(node, visit);
}; };
for (const file of service.getProgram().getSourceFiles()) { for (const file of service.getProgram().getSourceFiles()) {
if (!file.isDeclarationFile) { if (!file.isDeclarationFile) {
ts.forEachChild(file, visit); typescript_1.default.forEachChild(file, visit);
} }
} }
this.log(`Done collecting. Classes: ${this.allClassDataByKey.size}. Exported symbols: ${this.allExportedSymbols.size}`); this.log(`Done collecting. Classes: ${this.allClassDataByKey.size}. Exported symbols: ${this.allExportedSymbols.size}`);
// STEP: connect sub and super-types // STEP: connect sub and super-types
const setupParents = (data) => { const setupParents = (data) => {
const extendsClause = data.node.heritageClauses?.find(h => h.token === ts.SyntaxKind.ExtendsKeyword); const extendsClause = data.node.heritageClauses?.find(h => h.token === typescript_1.default.SyntaxKind.ExtendsKeyword);
if (!extendsClause) { if (!extendsClause) {
// no EXTENDS-clause // no EXTENDS-clause
return; return;
@ -497,7 +500,7 @@ class Mangler {
.then((locations) => ({ newName, locations }))); .then((locations) => ({ newName, locations })));
}; };
for (const data of this.allClassDataByKey.values()) { for (const data of this.allClassDataByKey.values()) {
if (hasModifier(data.node, ts.SyntaxKind.DeclareKeyword)) { if (hasModifier(data.node, typescript_1.default.SyntaxKind.DeclareKeyword)) {
continue; continue;
} }
fields: for (const [name, info] of data.fields) { fields: for (const [name, info] of data.fields) {
@ -545,7 +548,7 @@ class Mangler {
let savedBytes = 0; let savedBytes = 0;
for (const item of service.getProgram().getSourceFiles()) { for (const item of service.getProgram().getSourceFiles()) {
const { mapRoot, sourceRoot } = service.getProgram().getCompilerOptions(); const { mapRoot, sourceRoot } = service.getProgram().getCompilerOptions();
const projectDir = path.dirname(this.projectPath); const projectDir = path_1.default.dirname(this.projectPath);
const sourceMapRoot = mapRoot ?? (0, url_1.pathToFileURL)(sourceRoot ?? projectDir).toString(); const sourceMapRoot = mapRoot ?? (0, url_1.pathToFileURL)(sourceRoot ?? projectDir).toString();
// source maps // source maps
let generator; let generator;
@ -557,7 +560,7 @@ class Mangler {
} }
else { else {
// source map generator // source map generator
const relativeFileName = normalize(path.relative(projectDir, item.fileName)); const relativeFileName = normalize(path_1.default.relative(projectDir, item.fileName));
const mappingsByLine = new Map(); const mappingsByLine = new Map();
// apply renames // apply renames
edits.sort((a, b) => b.offset - a.offset); edits.sort((a, b) => b.offset - a.offset);
@ -596,7 +599,7 @@ class Mangler {
}); });
} }
// source map generation, make sure to get mappings per line correct // source map generation, make sure to get mappings per line correct
generator = new source_map_1.SourceMapGenerator({ file: path.basename(item.fileName), sourceRoot: sourceMapRoot }); generator = new source_map_1.SourceMapGenerator({ file: path_1.default.basename(item.fileName), sourceRoot: sourceMapRoot });
generator.setSourceContent(relativeFileName, item.getFullText()); generator.setSourceContent(relativeFileName, item.getFullText());
for (const [, mappings] of mappingsByLine) { for (const [, mappings] of mappingsByLine) {
let lineDelta = 0; let lineDelta = 0;
@ -614,19 +617,19 @@ class Mangler {
} }
service.dispose(); service.dispose();
this.renameWorkerPool.terminate(); this.renameWorkerPool.terminate();
this.log(`Done: ${savedBytes / 1000}kb saved, memory-usage: ${JSON.stringify(v8.getHeapStatistics())}`); this.log(`Done: ${savedBytes / 1000}kb saved, memory-usage: ${JSON.stringify(node_v8_1.default.getHeapStatistics())}`);
return result; return result;
} }
} }
exports.Mangler = Mangler; exports.Mangler = Mangler;
// --- ast utils // --- ast utils
function hasModifier(node, kind) { function hasModifier(node, kind) {
const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined; const modifiers = typescript_1.default.canHaveModifiers(node) ? typescript_1.default.getModifiers(node) : undefined;
return Boolean(modifiers?.find(mode => mode.kind === kind)); return Boolean(modifiers?.find(mode => mode.kind === kind));
} }
function isInAmbientContext(node) { function isInAmbientContext(node) {
for (let p = node.parent; p; p = p.parent) { for (let p = node.parent; p; p = p.parent) {
if (ts.isModuleDeclaration(p)) { if (typescript_1.default.isModuleDeclaration(p)) {
return true; return true;
} }
} }
@ -636,21 +639,21 @@ function normalize(path) {
return path.replace(/\\/g, '/'); return path.replace(/\\/g, '/');
} }
async function _run() { async function _run() {
const root = path.join(__dirname, '..', '..', '..'); const root = path_1.default.join(__dirname, '..', '..', '..');
const projectBase = path.join(root, 'src'); const projectBase = path_1.default.join(root, 'src');
const projectPath = path.join(projectBase, 'tsconfig.json'); const projectPath = path_1.default.join(projectBase, 'tsconfig.json');
const newProjectBase = path.join(path.dirname(projectBase), path.basename(projectBase) + '2'); const newProjectBase = path_1.default.join(path_1.default.dirname(projectBase), path_1.default.basename(projectBase) + '2');
fs.cpSync(projectBase, newProjectBase, { recursive: true }); fs_1.default.cpSync(projectBase, newProjectBase, { recursive: true });
const mangler = new Mangler(projectPath, console.log, { const mangler = new Mangler(projectPath, console.log, {
mangleExports: true, mangleExports: true,
manglePrivateFields: true, manglePrivateFields: true,
}); });
for (const [fileName, contents] of await mangler.computeNewFileContents(new Set(['saveState']))) { for (const [fileName, contents] of await mangler.computeNewFileContents(new Set(['saveState']))) {
const newFilePath = path.join(newProjectBase, path.relative(projectBase, fileName)); const newFilePath = path_1.default.join(newProjectBase, path_1.default.relative(projectBase, fileName));
await fs.promises.mkdir(path.dirname(newFilePath), { recursive: true }); await fs_1.default.promises.mkdir(path_1.default.dirname(newFilePath), { recursive: true });
await fs.promises.writeFile(newFilePath, contents.out); await fs_1.default.promises.writeFile(newFilePath, contents.out);
if (contents.sourceMap) { if (contents.sourceMap) {
await fs.promises.writeFile(newFilePath + '.map', contents.sourceMap); await fs_1.default.promises.writeFile(newFilePath + '.map', contents.sourceMap);
} }
} }
} }

View File

@ -3,14 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as v8 from 'node:v8'; import v8 from 'node:v8';
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import { argv } from 'process'; import { argv } from 'process';
import { Mapping, SourceMapGenerator } from 'source-map'; import { Mapping, SourceMapGenerator } from 'source-map';
import * as ts from 'typescript'; import ts from 'typescript';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'url';
import * as workerpool from 'workerpool'; import workerpool from 'workerpool';
import { StaticLanguageServiceHost } from './staticLanguageServiceHost'; import { StaticLanguageServiceHost } from './staticLanguageServiceHost';
const buildfile = require('../../buildfile'); const buildfile = require('../../buildfile');

View File

@ -3,20 +3,23 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const ts = require("typescript"); const typescript_1 = __importDefault(require("typescript"));
const workerpool = require("workerpool"); const workerpool_1 = __importDefault(require("workerpool"));
const staticLanguageServiceHost_1 = require("./staticLanguageServiceHost"); const staticLanguageServiceHost_1 = require("./staticLanguageServiceHost");
let service; let service;
function findRenameLocations(projectPath, fileName, position) { function findRenameLocations(projectPath, fileName, position) {
if (!service) { if (!service) {
service = ts.createLanguageService(new staticLanguageServiceHost_1.StaticLanguageServiceHost(projectPath)); service = typescript_1.default.createLanguageService(new staticLanguageServiceHost_1.StaticLanguageServiceHost(projectPath));
} }
return service.findRenameLocations(fileName, position, false, false, { return service.findRenameLocations(fileName, position, false, false, {
providePrefixAndSuffixTextForRename: true, providePrefixAndSuffixTextForRename: true,
}) ?? []; }) ?? [];
} }
workerpool.worker({ workerpool_1.default.worker({
findRenameLocations findRenameLocations
}); });
//# sourceMappingURL=renameWorker.js.map //# sourceMappingURL=renameWorker.js.map

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as ts from 'typescript'; import ts from 'typescript';
import * as workerpool from 'workerpool'; import workerpool from 'workerpool';
import { StaticLanguageServiceHost } from './staticLanguageServiceHost'; import { StaticLanguageServiceHost } from './staticLanguageServiceHost';
let service: ts.LanguageService | undefined; let service: ts.LanguageService | undefined;

View File

@ -3,10 +3,13 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.StaticLanguageServiceHost = void 0; exports.StaticLanguageServiceHost = void 0;
const ts = require("typescript"); const typescript_1 = __importDefault(require("typescript"));
const path = require("path"); const path_1 = __importDefault(require("path"));
class StaticLanguageServiceHost { class StaticLanguageServiceHost {
projectPath; projectPath;
_cmdLine; _cmdLine;
@ -14,11 +17,11 @@ class StaticLanguageServiceHost {
constructor(projectPath) { constructor(projectPath) {
this.projectPath = projectPath; this.projectPath = projectPath;
const existingOptions = {}; const existingOptions = {};
const parsed = ts.readConfigFile(projectPath, ts.sys.readFile); const parsed = typescript_1.default.readConfigFile(projectPath, typescript_1.default.sys.readFile);
if (parsed.error) { if (parsed.error) {
throw parsed.error; throw parsed.error;
} }
this._cmdLine = ts.parseJsonConfigFileContent(parsed.config, ts.sys, path.dirname(projectPath), existingOptions); this._cmdLine = typescript_1.default.parseJsonConfigFileContent(parsed.config, typescript_1.default.sys, path_1.default.dirname(projectPath), existingOptions);
if (this._cmdLine.errors.length > 0) { if (this._cmdLine.errors.length > 0) {
throw parsed.error; throw parsed.error;
} }
@ -38,28 +41,28 @@ class StaticLanguageServiceHost {
getScriptSnapshot(fileName) { getScriptSnapshot(fileName) {
let result = this._scriptSnapshots.get(fileName); let result = this._scriptSnapshots.get(fileName);
if (result === undefined) { if (result === undefined) {
const content = ts.sys.readFile(fileName); const content = typescript_1.default.sys.readFile(fileName);
if (content === undefined) { if (content === undefined) {
return undefined; return undefined;
} }
result = ts.ScriptSnapshot.fromString(content); result = typescript_1.default.ScriptSnapshot.fromString(content);
this._scriptSnapshots.set(fileName, result); this._scriptSnapshots.set(fileName, result);
} }
return result; return result;
} }
getCurrentDirectory() { getCurrentDirectory() {
return path.dirname(this.projectPath); return path_1.default.dirname(this.projectPath);
} }
getDefaultLibFileName(options) { getDefaultLibFileName(options) {
return ts.getDefaultLibFilePath(options); return typescript_1.default.getDefaultLibFilePath(options);
} }
directoryExists = ts.sys.directoryExists; directoryExists = typescript_1.default.sys.directoryExists;
getDirectories = ts.sys.getDirectories; getDirectories = typescript_1.default.sys.getDirectories;
fileExists = ts.sys.fileExists; fileExists = typescript_1.default.sys.fileExists;
readFile = ts.sys.readFile; readFile = typescript_1.default.sys.readFile;
readDirectory = ts.sys.readDirectory; readDirectory = typescript_1.default.sys.readDirectory;
// this is necessary to make source references work. // this is necessary to make source references work.
realpath = ts.sys.realpath; realpath = typescript_1.default.sys.realpath;
} }
exports.StaticLanguageServiceHost = StaticLanguageServiceHost; exports.StaticLanguageServiceHost = StaticLanguageServiceHost;
//# sourceMappingURL=staticLanguageServiceHost.js.map //# sourceMappingURL=staticLanguageServiceHost.js.map

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as ts from 'typescript'; import ts from 'typescript';
import * as path from 'path'; import path from 'path';
export class StaticLanguageServiceHost implements ts.LanguageServiceHost { export class StaticLanguageServiceHost implements ts.LanguageServiceHost {

View File

@ -3,21 +3,24 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.DeclarationResolver = exports.FSProvider = exports.RECIPE_PATH = void 0; exports.DeclarationResolver = exports.FSProvider = exports.RECIPE_PATH = void 0;
exports.run3 = run3; exports.run3 = run3;
exports.execute = execute; exports.execute = execute;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const dtsv = '3'; const dtsv = '3';
const tsfmt = require('../../tsfmt.json'); const tsfmt = require('../../tsfmt.json');
const SRC = path.join(__dirname, '../../src'); const SRC = path_1.default.join(__dirname, '../../src');
exports.RECIPE_PATH = path.join(__dirname, '../monaco/monaco.d.ts.recipe'); exports.RECIPE_PATH = path_1.default.join(__dirname, '../monaco/monaco.d.ts.recipe');
const DECLARATION_PATH = path.join(__dirname, '../../src/vs/monaco.d.ts'); const DECLARATION_PATH = path_1.default.join(__dirname, '../../src/vs/monaco.d.ts');
function logErr(message, ...rest) { function logErr(message, ...rest) {
fancyLog(ansiColors.yellow(`[monaco.d.ts]`), message, ...rest); (0, fancy_log_1.default)(ansi_colors_1.default.yellow(`[monaco.d.ts]`), message, ...rest);
} }
function isDeclaration(ts, a) { function isDeclaration(ts, a) {
return (a.kind === ts.SyntaxKind.InterfaceDeclaration return (a.kind === ts.SyntaxKind.InterfaceDeclaration
@ -464,7 +467,7 @@ function generateDeclarationFile(ts, recipe, sourceFileGetter) {
}; };
} }
function _run(ts, sourceFileGetter) { function _run(ts, sourceFileGetter) {
const recipe = fs.readFileSync(exports.RECIPE_PATH).toString(); const recipe = fs_1.default.readFileSync(exports.RECIPE_PATH).toString();
const t = generateDeclarationFile(ts, recipe, sourceFileGetter); const t = generateDeclarationFile(ts, recipe, sourceFileGetter);
if (!t) { if (!t) {
return null; return null;
@ -472,7 +475,7 @@ function _run(ts, sourceFileGetter) {
const result = t.result; const result = t.result;
const usageContent = t.usageContent; const usageContent = t.usageContent;
const enums = t.enums; const enums = t.enums;
const currentContent = fs.readFileSync(DECLARATION_PATH).toString(); const currentContent = fs_1.default.readFileSync(DECLARATION_PATH).toString();
const one = currentContent.replace(/\r\n/gm, '\n'); const one = currentContent.replace(/\r\n/gm, '\n');
const other = result.replace(/\r\n/gm, '\n'); const other = result.replace(/\r\n/gm, '\n');
const isTheSame = (one === other); const isTheSame = (one === other);
@ -486,13 +489,13 @@ function _run(ts, sourceFileGetter) {
} }
class FSProvider { class FSProvider {
existsSync(filePath) { existsSync(filePath) {
return fs.existsSync(filePath); return fs_1.default.existsSync(filePath);
} }
statSync(filePath) { statSync(filePath) {
return fs.statSync(filePath); return fs_1.default.statSync(filePath);
} }
readFileSync(_moduleId, filePath) { readFileSync(_moduleId, filePath) {
return fs.readFileSync(filePath); return fs_1.default.readFileSync(filePath);
} }
} }
exports.FSProvider = FSProvider; exports.FSProvider = FSProvider;
@ -532,9 +535,9 @@ class DeclarationResolver {
} }
_getFileName(moduleId) { _getFileName(moduleId) {
if (/\.d\.ts$/.test(moduleId)) { if (/\.d\.ts$/.test(moduleId)) {
return path.join(SRC, moduleId); return path_1.default.join(SRC, moduleId);
} }
return path.join(SRC, `${moduleId}.ts`); return path_1.default.join(SRC, `${moduleId}.ts`);
} }
_getDeclarationSourceFile(moduleId) { _getDeclarationSourceFile(moduleId) {
const fileName = this._getFileName(moduleId); const fileName = this._getFileName(moduleId);

View File

@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import type * as ts from 'typescript'; import type * as ts from 'typescript';
import * as path from 'path'; import path from 'path';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
const dtsv = '3'; const dtsv = '3';

View File

@ -3,14 +3,50 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.nls = nls; exports.nls = nls;
const lazy = require("lazy.js"); const lazy_js_1 = __importDefault(require("lazy.js"));
const event_stream_1 = require("event-stream"); const event_stream_1 = require("event-stream");
const File = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const sm = require("source-map"); const sm = __importStar(require("source-map"));
const path = require("path"); const path = __importStar(require("path"));
const sort = require("gulp-sort"); const gulp_sort_1 = __importDefault(require("gulp-sort"));
var CollectStepResult; var CollectStepResult;
(function (CollectStepResult) { (function (CollectStepResult) {
CollectStepResult[CollectStepResult["Yes"] = 0] = "Yes"; CollectStepResult[CollectStepResult["Yes"] = 0] = "Yes";
@ -46,7 +82,7 @@ function nls(options) {
let base; let base;
const input = (0, event_stream_1.through)(); const input = (0, event_stream_1.through)();
const output = input const output = input
.pipe(sort()) // IMPORTANT: to ensure stable NLS metadata generation, we must sort the files because NLS messages are globally extracted and indexed across all files .pipe((0, gulp_sort_1.default)()) // IMPORTANT: to ensure stable NLS metadata generation, we must sort the files because NLS messages are globally extracted and indexed across all files
.pipe((0, event_stream_1.through)(function (f) { .pipe((0, event_stream_1.through)(function (f) {
if (!f.sourceMap) { if (!f.sourceMap) {
return this.emit('error', new Error(`File ${f.relative} does not have sourcemaps.`)); return this.emit('error', new Error(`File ${f.relative} does not have sourcemaps.`));
@ -67,7 +103,7 @@ function nls(options) {
this.emit('data', _nls.patchFile(f, typescript, options)); this.emit('data', _nls.patchFile(f, typescript, options));
}, function () { }, function () {
for (const file of [ for (const file of [
new File({ new vinyl_1.default({
contents: Buffer.from(JSON.stringify({ contents: Buffer.from(JSON.stringify({
keys: _nls.moduleToNLSKeys, keys: _nls.moduleToNLSKeys,
messages: _nls.moduleToNLSMessages, messages: _nls.moduleToNLSMessages,
@ -75,17 +111,17 @@ function nls(options) {
base, base,
path: `${base}/nls.metadata.json` path: `${base}/nls.metadata.json`
}), }),
new File({ new vinyl_1.default({
contents: Buffer.from(JSON.stringify(_nls.allNLSMessages)), contents: Buffer.from(JSON.stringify(_nls.allNLSMessages)),
base, base,
path: `${base}/nls.messages.json` path: `${base}/nls.messages.json`
}), }),
new File({ new vinyl_1.default({
contents: Buffer.from(JSON.stringify(_nls.allNLSModulesAndKeys)), contents: Buffer.from(JSON.stringify(_nls.allNLSModulesAndKeys)),
base, base,
path: `${base}/nls.keys.json` path: `${base}/nls.keys.json`
}), }),
new File({ new vinyl_1.default({
contents: Buffer.from(`/*--------------------------------------------------------- contents: Buffer.from(`/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved. * Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/ *--------------------------------------------------------*/
@ -111,7 +147,7 @@ var _nls;
_nls.allNLSModulesAndKeys = []; _nls.allNLSModulesAndKeys = [];
let allNLSMessagesIndex = 0; let allNLSMessagesIndex = 0;
function fileFrom(file, contents, path = file.path) { function fileFrom(file, contents, path = file.path) {
return new File({ return new vinyl_1.default({
contents: Buffer.from(contents), contents: Buffer.from(contents),
base: file.base, base: file.base,
cwd: file.cwd, cwd: file.cwd,
@ -163,7 +199,7 @@ var _nls;
const service = ts.createLanguageService(serviceHost); const service = ts.createLanguageService(serviceHost);
const sourceFile = ts.createSourceFile(filename, contents, ts.ScriptTarget.ES5, true); const sourceFile = ts.createSourceFile(filename, contents, ts.ScriptTarget.ES5, true);
// all imports // all imports
const imports = lazy(collect(ts, sourceFile, n => isImportNode(ts, n) ? CollectStepResult.YesAndRecurse : CollectStepResult.NoAndRecurse)); const imports = (0, lazy_js_1.default)(collect(ts, sourceFile, n => isImportNode(ts, n) ? CollectStepResult.YesAndRecurse : CollectStepResult.NoAndRecurse));
// import nls = require('vs/nls'); // import nls = require('vs/nls');
const importEqualsDeclarations = imports const importEqualsDeclarations = imports
.filter(n => n.kind === ts.SyntaxKind.ImportEqualsDeclaration) .filter(n => n.kind === ts.SyntaxKind.ImportEqualsDeclaration)
@ -188,7 +224,7 @@ var _nls;
.filter(r => !r.isWriteAccess) .filter(r => !r.isWriteAccess)
// find the deepest call expressions AST nodes that contain those references // find the deepest call expressions AST nodes that contain those references
.map(r => collect(ts, sourceFile, n => isCallExpressionWithinTextSpanCollectStep(ts, r.textSpan, n))) .map(r => collect(ts, sourceFile, n => isCallExpressionWithinTextSpanCollectStep(ts, r.textSpan, n)))
.map(a => lazy(a).last()) .map(a => (0, lazy_js_1.default)(a).last())
.filter(n => !!n) .filter(n => !!n)
.map(n => n) .map(n => n)
// only `localize` calls // only `localize` calls
@ -214,7 +250,7 @@ var _nls;
const localizeCallExpressions = localizeReferences const localizeCallExpressions = localizeReferences
.concat(namedLocalizeReferences) .concat(namedLocalizeReferences)
.map(r => collect(ts, sourceFile, n => isCallExpressionWithinTextSpanCollectStep(ts, r.textSpan, n))) .map(r => collect(ts, sourceFile, n => isCallExpressionWithinTextSpanCollectStep(ts, r.textSpan, n)))
.map(a => lazy(a).last()) .map(a => (0, lazy_js_1.default)(a).last())
.filter(n => !!n) .filter(n => !!n)
.map(n => n); .map(n => n);
// collect everything // collect everything
@ -281,14 +317,14 @@ var _nls;
} }
} }
toString() { toString() {
return lazy(this.lines).zip(this.lineEndings) return (0, lazy_js_1.default)(this.lines).zip(this.lineEndings)
.flatten().toArray().join(''); .flatten().toArray().join('');
} }
} }
function patchJavascript(patches, contents) { function patchJavascript(patches, contents) {
const model = new TextModel(contents); const model = new TextModel(contents);
// patch the localize calls // patch the localize calls
lazy(patches).reverse().each(p => model.apply(p)); (0, lazy_js_1.default)(patches).reverse().each(p => model.apply(p));
return model.toString(); return model.toString();
} }
function patchSourcemap(patches, rsm, smc) { function patchSourcemap(patches, rsm, smc) {
@ -349,7 +385,7 @@ var _nls;
const end = lcFrom(smc.generatedPositionFor(positionFrom(c.range.end))); const end = lcFrom(smc.generatedPositionFor(positionFrom(c.range.end)));
return { span: { start, end }, content: c.content }; return { span: { start, end }, content: c.content };
}; };
const localizePatches = lazy(localizeCalls) const localizePatches = (0, lazy_js_1.default)(localizeCalls)
.map(lc => (options.preserveEnglish ? [ .map(lc => (options.preserveEnglish ? [
{ range: lc.keySpan, content: `${allNLSMessagesIndex++}` } // localize('key', "message") => localize(<index>, "message") { range: lc.keySpan, content: `${allNLSMessagesIndex++}` } // localize('key', "message") => localize(<index>, "message")
] : [ ] : [
@ -358,7 +394,7 @@ var _nls;
])) ]))
.flatten() .flatten()
.map(toPatch); .map(toPatch);
const localize2Patches = lazy(localize2Calls) const localize2Patches = (0, lazy_js_1.default)(localize2Calls)
.map(lc => ({ range: lc.keySpan, content: `${allNLSMessagesIndex++}` } // localize2('key', "message") => localize(<index>, "message") .map(lc => ({ range: lc.keySpan, content: `${allNLSMessagesIndex++}` } // localize2('key', "message") => localize(<index>, "message")
)) ))
.map(toPatch); .map(toPatch);

View File

@ -4,12 +4,12 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import type * as ts from 'typescript'; import type * as ts from 'typescript';
import * as lazy from 'lazy.js'; import lazy from 'lazy.js';
import { duplex, through } from 'event-stream'; import { duplex, through } from 'event-stream';
import * as File from 'vinyl'; import File from 'vinyl';
import * as sm from 'source-map'; import * as sm from 'source-map';
import * as path from 'path'; import * as path from 'path';
import * as sort from 'gulp-sort'; import sort from 'gulp-sort';
declare class FileSourceMap extends File { declare class FileSourceMap extends File {
public sourceMap: sm.RawSourceMap; public sourceMap: sm.RawSourceMap;

View File

@ -3,16 +3,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path"); const path_1 = __importDefault(require("path"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const root = path.dirname(path.dirname(__dirname)); const root = path_1.default.dirname(path_1.default.dirname(__dirname));
const npmrcPath = path.join(root, 'remote', '.npmrc'); const npmrcPath = path_1.default.join(root, 'remote', '.npmrc');
const npmrc = fs.readFileSync(npmrcPath, 'utf8'); const npmrc = fs_1.default.readFileSync(npmrcPath, 'utf8');
const version = /^target="(.*)"$/m.exec(npmrc)[1]; const version = /^target="(.*)"$/m.exec(npmrc)[1];
const platform = process.platform; const platform = process.platform;
const arch = process.arch; const arch = process.arch;
const node = platform === 'win32' ? 'node.exe' : 'node'; const node = platform === 'win32' ? 'node.exe' : 'node';
const nodePath = path.join(root, '.build', 'node', `v${version}`, `${platform}-${arch}`, node); const nodePath = path_1.default.join(root, '.build', 'node', `v${version}`, `${platform}-${arch}`, node);
console.log(nodePath); console.log(nodePath);
//# sourceMappingURL=node.js.map //# sourceMappingURL=node.js.map

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as path from 'path'; import path from 'path';
import * as fs from 'fs'; import fs from 'fs';
const root = path.dirname(path.dirname(__dirname)); const root = path.dirname(path.dirname(__dirname));
const npmrcPath = path.join(root, 'remote', '.npmrc'); const npmrcPath = path.join(root, 'remote', '.npmrc');

View File

@ -3,22 +3,58 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.bundleTask = bundleTask; exports.bundleTask = bundleTask;
exports.minifyTask = minifyTask; exports.minifyTask = minifyTask;
const es = require("event-stream"); const es = __importStar(require("event-stream"));
const gulp = require("gulp"); const gulp = __importStar(require("gulp"));
const filter = require("gulp-filter"); const gulp_filter_1 = __importDefault(require("gulp-filter"));
const path = require("path"); const path = __importStar(require("path"));
const fs = require("fs"); const fs = __importStar(require("fs"));
const pump = require("pump"); const pump_1 = __importDefault(require("pump"));
const VinylFile = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const bundle = require("./bundle"); const bundle = __importStar(require("./bundle"));
const postcss_1 = require("./postcss"); const postcss_1 = require("./postcss");
const esbuild = require("esbuild"); const esbuild = __importStar(require("esbuild"));
const sourcemaps = require("gulp-sourcemaps"); const sourcemaps = __importStar(require("gulp-sourcemaps"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansiColors = __importStar(require("ansi-colors"));
const REPO_ROOT_PATH = path.join(__dirname, '../..'); const REPO_ROOT_PATH = path.join(__dirname, '../..');
const DEFAULT_FILE_HEADER = [ const DEFAULT_FILE_HEADER = [
'/*!--------------------------------------------------------', '/*!--------------------------------------------------------',
@ -44,7 +80,7 @@ function bundleESMTask(opts) {
const files = []; const files = [];
const tasks = []; const tasks = [];
for (const entryPoint of entryPoints) { for (const entryPoint of entryPoints) {
fancyLog(`Bundled entry point: ${ansiColors.yellow(entryPoint.name)}...`); (0, fancy_log_1.default)(`Bundled entry point: ${ansiColors.yellow(entryPoint.name)}...`);
// support for 'dest' via esbuild#in/out // support for 'dest' via esbuild#in/out
const dest = entryPoint.dest?.replace(/\.[^/.]+$/, '') ?? entryPoint.name; const dest = entryPoint.dest?.replace(/\.[^/.]+$/, '') ?? entryPoint.name;
// banner contents // banner contents
@ -128,7 +164,7 @@ function bundleESMTask(opts) {
path: file.path, path: file.path,
base: path.join(REPO_ROOT_PATH, opts.src) base: path.join(REPO_ROOT_PATH, opts.src)
}; };
files.push(new VinylFile(fileProps)); files.push(new vinyl_1.default(fileProps));
} }
}); });
tasks.push(task); tasks.push(task);
@ -160,10 +196,10 @@ function minifyTask(src, sourceMapBaseUrl) {
return cb => { return cb => {
const cssnano = require('cssnano'); const cssnano = require('cssnano');
const svgmin = require('gulp-svgmin'); const svgmin = require('gulp-svgmin');
const jsFilter = filter('**/*.js', { restore: true }); const jsFilter = (0, gulp_filter_1.default)('**/*.js', { restore: true });
const cssFilter = filter('**/*.css', { restore: true }); const cssFilter = (0, gulp_filter_1.default)('**/*.css', { restore: true });
const svgFilter = filter('**/*.svg', { restore: true }); const svgFilter = (0, gulp_filter_1.default)('**/*.svg', { restore: true });
pump(gulp.src([src + '/**', '!' + src + '/**/*.map']), jsFilter, sourcemaps.init({ loadMaps: true }), es.map((f, cb) => { (0, pump_1.default)(gulp.src([src + '/**', '!' + src + '/**/*.map']), jsFilter, sourcemaps.init({ loadMaps: true }), es.map((f, cb) => {
esbuild.build({ esbuild.build({
entryPoints: [f.path], entryPoints: [f.path],
minify: true, minify: true,

View File

@ -5,16 +5,16 @@
import * as es from 'event-stream'; import * as es from 'event-stream';
import * as gulp from 'gulp'; import * as gulp from 'gulp';
import * as filter from 'gulp-filter'; import filter from 'gulp-filter';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as pump from 'pump'; import pump from 'pump';
import * as VinylFile from 'vinyl'; import VinylFile from 'vinyl';
import * as bundle from './bundle'; import * as bundle from './bundle';
import { gulpPostcss } from './postcss'; import { gulpPostcss } from './postcss';
import * as esbuild from 'esbuild'; import * as esbuild from 'esbuild';
import * as sourcemaps from 'gulp-sourcemaps'; import * as sourcemaps from 'gulp-sourcemaps';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import * as ansiColors from 'ansi-colors';
const REPO_ROOT_PATH = path.join(__dirname, '../..'); const REPO_ROOT_PATH = path.join(__dirname, '../..');

View File

@ -3,13 +3,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process"); const child_process_1 = require("child_process");
const fs_1 = require("fs"); const fs_1 = require("fs");
const path = require("path"); const path_1 = __importDefault(require("path"));
const byline = require("byline"); const byline_1 = __importDefault(require("byline"));
const ripgrep_1 = require("@vscode/ripgrep"); const ripgrep_1 = require("@vscode/ripgrep");
const Parser = require("tree-sitter"); const tree_sitter_1 = __importDefault(require("tree-sitter"));
const { typescript } = require('tree-sitter-typescript'); const { typescript } = require('tree-sitter-typescript');
const product = require('../../product.json'); const product = require('../../product.json');
const packageJson = require('../../package.json'); const packageJson = require('../../package.json');
@ -258,7 +261,7 @@ const StringArrayQ = {
} }
}; };
function getProperty(qtype, node, key) { function getProperty(qtype, node, key) {
const query = new Parser.Query(typescript, `( const query = new tree_sitter_1.default.Query(typescript, `(
(pair (pair
key: [(property_identifier)(string)] @key key: [(property_identifier)(string)] @key
value: ${qtype.Q} value: ${qtype.Q}
@ -331,7 +334,7 @@ function getPolicy(moduleName, configurationNode, settingNode, policyNode, categ
return result; return result;
} }
function getPolicies(moduleName, node) { function getPolicies(moduleName, node) {
const query = new Parser.Query(typescript, ` const query = new tree_sitter_1.default.Query(typescript, `
( (
(call_expression (call_expression
function: (member_expression property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) function: (member_expression property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration)
@ -360,7 +363,7 @@ async function getFiles(root) {
return new Promise((c, e) => { return new Promise((c, e) => {
const result = []; const result = [];
const rg = (0, child_process_1.spawn)(ripgrep_1.rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); const rg = (0, child_process_1.spawn)(ripgrep_1.rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]);
const stream = byline(rg.stdout.setEncoding('utf8')); const stream = (0, byline_1.default)(rg.stdout.setEncoding('utf8'));
stream.on('data', path => result.push(path)); stream.on('data', path => result.push(path));
stream.on('error', err => e(err)); stream.on('error', err => e(err));
stream.on('end', () => c(result)); stream.on('end', () => c(result));
@ -494,13 +497,13 @@ async function getNLS(extensionGalleryServiceUrl, resourceUrlTemplate, languageI
return await getSpecificNLS(resourceUrlTemplate, languageId, latestCompatibleVersion); return await getSpecificNLS(resourceUrlTemplate, languageId, latestCompatibleVersion);
} }
async function parsePolicies() { async function parsePolicies() {
const parser = new Parser(); const parser = new tree_sitter_1.default();
parser.setLanguage(typescript); parser.setLanguage(typescript);
const files = await getFiles(process.cwd()); const files = await getFiles(process.cwd());
const base = path.join(process.cwd(), 'src'); const base = path_1.default.join(process.cwd(), 'src');
const policies = []; const policies = [];
for (const file of files) { for (const file of files) {
const moduleName = path.relative(base, file).replace(/\.ts$/i, '').replace(/\\/g, '/'); const moduleName = path_1.default.relative(base, file).replace(/\.ts$/i, '').replace(/\\/g, '/');
const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' });
const tree = parser.parse(contents); const tree = parser.parse(contents);
policies.push(...getPolicies(moduleName, tree.rootNode)); policies.push(...getPolicies(moduleName, tree.rootNode));
@ -529,11 +532,11 @@ async function main() {
const root = '.build/policies/win32'; const root = '.build/policies/win32';
await fs_1.promises.rm(root, { recursive: true, force: true }); await fs_1.promises.rm(root, { recursive: true, force: true });
await fs_1.promises.mkdir(root, { recursive: true }); await fs_1.promises.mkdir(root, { recursive: true });
await fs_1.promises.writeFile(path.join(root, `${product.win32RegValueName}.admx`), admx.replace(/\r?\n/g, '\n')); await fs_1.promises.writeFile(path_1.default.join(root, `${product.win32RegValueName}.admx`), admx.replace(/\r?\n/g, '\n'));
for (const { languageId, contents } of adml) { for (const { languageId, contents } of adml) {
const languagePath = path.join(root, languageId === 'en-us' ? 'en-us' : Languages[languageId]); const languagePath = path_1.default.join(root, languageId === 'en-us' ? 'en-us' : Languages[languageId]);
await fs_1.promises.mkdir(languagePath, { recursive: true }); await fs_1.promises.mkdir(languagePath, { recursive: true });
await fs_1.promises.writeFile(path.join(languagePath, `${product.win32RegValueName}.adml`), contents.replace(/\r?\n/g, '\n')); await fs_1.promises.writeFile(path_1.default.join(languagePath, `${product.win32RegValueName}.adml`), contents.replace(/\r?\n/g, '\n'));
} }
} }
if (require.main === module) { if (require.main === module) {

View File

@ -5,10 +5,10 @@
import { spawn } from 'child_process'; import { spawn } from 'child_process';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import * as path from 'path'; import path from 'path';
import * as byline from 'byline'; import byline from 'byline';
import { rgPath } from '@vscode/ripgrep'; import { rgPath } from '@vscode/ripgrep';
import * as Parser from 'tree-sitter'; import Parser from 'tree-sitter';
const { typescript } = require('tree-sitter-typescript'); const { typescript } = require('tree-sitter-typescript');
const product = require('../../product.json'); const product = require('../../product.json');
const packageJson = require('../../package.json'); const packageJson = require('../../package.json');

View File

@ -1,15 +1,18 @@
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.gulpPostcss = gulpPostcss; exports.gulpPostcss = gulpPostcss;
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
const postcss = require("postcss"); const postcss_1 = __importDefault(require("postcss"));
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
function gulpPostcss(plugins, handleError) { function gulpPostcss(plugins, handleError) {
const instance = postcss(plugins); const instance = (0, postcss_1.default)(plugins);
return es.map((file, callback) => { return event_stream_1.default.map((file, callback) => {
if (file.isNull()) { if (file.isNull()) {
return callback(null, file); return callback(null, file);
} }

View File

@ -2,9 +2,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as postcss from 'postcss'; import postcss from 'postcss';
import * as File from 'vinyl'; import File from 'vinyl';
import * as es from 'event-stream'; import es from 'event-stream';
export function gulpPostcss(plugins: postcss.AcceptedPlugin[], handleError?: (err: Error) => void) { export function gulpPostcss(plugins: postcss.AcceptedPlugin[], handleError?: (err: Error) => void) {
const instance = postcss(plugins); const instance = postcss(plugins);

View File

@ -3,13 +3,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
// @ts-check // @ts-check
const path = require("path"); const path_1 = __importDefault(require("path"));
const child_process_1 = require("child_process"); const child_process_1 = require("child_process");
const fs_1 = require("fs"); const fs_1 = require("fs");
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'; const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const rootDir = path.resolve(__dirname, '..', '..'); const rootDir = path_1.default.resolve(__dirname, '..', '..');
function runProcess(command, args = []) { function runProcess(command, args = []) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const child = (0, child_process_1.spawn)(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env, shell: process.platform === 'win32' }); const child = (0, child_process_1.spawn)(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env, shell: process.platform === 'win32' });
@ -19,7 +22,7 @@ function runProcess(command, args = []) {
} }
async function exists(subdir) { async function exists(subdir) {
try { try {
await fs_1.promises.stat(path.join(rootDir, subdir)); await fs_1.promises.stat(path_1.default.join(rootDir, subdir));
return true; return true;
} }
catch { catch {

View File

@ -5,7 +5,7 @@
// @ts-check // @ts-check
import * as path from 'path'; import path from 'path';
import { spawn } from 'child_process'; import { spawn } from 'child_process';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';

View File

@ -3,13 +3,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.createReporter = createReporter; exports.createReporter = createReporter;
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
class ErrorLog { class ErrorLog {
id; id;
constructor(id) { constructor(id) {
@ -23,7 +26,7 @@ class ErrorLog {
return; return;
} }
this.startTime = new Date().getTime(); this.startTime = new Date().getTime();
fancyLog(`Starting ${ansiColors.green('compilation')}${this.id ? ansiColors.blue(` ${this.id}`) : ''}...`); (0, fancy_log_1.default)(`Starting ${ansi_colors_1.default.green('compilation')}${this.id ? ansi_colors_1.default.blue(` ${this.id}`) : ''}...`);
} }
onEnd() { onEnd() {
if (--this.count > 0) { if (--this.count > 0) {
@ -37,10 +40,10 @@ class ErrorLog {
errors.map(err => { errors.map(err => {
if (!seen.has(err)) { if (!seen.has(err)) {
seen.add(err); seen.add(err);
fancyLog(`${ansiColors.red('Error')}: ${err}`); (0, fancy_log_1.default)(`${ansi_colors_1.default.red('Error')}: ${err}`);
} }
}); });
fancyLog(`Finished ${ansiColors.green('compilation')}${this.id ? ansiColors.blue(` ${this.id}`) : ''} with ${errors.length} errors after ${ansiColors.magenta((new Date().getTime() - this.startTime) + ' ms')}`); (0, fancy_log_1.default)(`Finished ${ansi_colors_1.default.green('compilation')}${this.id ? ansi_colors_1.default.blue(` ${this.id}`) : ''} with ${errors.length} errors after ${ansi_colors_1.default.magenta((new Date().getTime() - this.startTime) + ' ms')}`);
const regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/s; const regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/s;
const messages = errors const messages = errors
.map(err => regex.exec(err)) .map(err => regex.exec(err))
@ -49,7 +52,7 @@ class ErrorLog {
.map(([, path, line, column, message]) => ({ path, line: parseInt(line), column: parseInt(column), message })); .map(([, path, line, column, message]) => ({ path, line: parseInt(line), column: parseInt(column), message }));
try { try {
const logFileName = 'log' + (this.id ? `_${this.id}` : ''); const logFileName = 'log' + (this.id ? `_${this.id}` : '');
fs.writeFileSync(path.join(buildLogFolder, logFileName), JSON.stringify(messages)); fs_1.default.writeFileSync(path_1.default.join(buildLogFolder, logFileName), JSON.stringify(messages));
} }
catch (err) { catch (err) {
//noop //noop
@ -65,9 +68,9 @@ function getErrorLog(id = '') {
} }
return errorLog; return errorLog;
} }
const buildLogFolder = path.join(path.dirname(path.dirname(__dirname)), '.build'); const buildLogFolder = path_1.default.join(path_1.default.dirname(path_1.default.dirname(__dirname)), '.build');
try { try {
fs.mkdirSync(buildLogFolder); fs_1.default.mkdirSync(buildLogFolder);
} }
catch (err) { catch (err) {
// ignore // ignore
@ -81,7 +84,7 @@ function createReporter(id) {
result.end = (emitError) => { result.end = (emitError) => {
errors.length = 0; errors.length = 0;
errorLog.onStart(); errorLog.onStart();
return es.through(undefined, function () { return event_stream_1.default.through(undefined, function () {
errorLog.onEnd(); errorLog.onEnd();
if (emitError && errors.length > 0) { if (emitError && errors.length > 0) {
if (!errors.__logged__) { if (!errors.__logged__) {

View File

@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import es from 'event-stream';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
class ErrorLog { class ErrorLog {
constructor(public id: string) { constructor(public id: string) {

View File

@ -3,6 +3,8 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.snaps = void 0;
var snaps; var snaps;
(function (snaps) { (function (snaps) {
const fs = require('fs'); const fs = require('fs');
@ -52,5 +54,5 @@ var snaps;
fs.writeFileSync(wrappedInputFilepath, wrappedInputFile); fs.writeFileSync(wrappedInputFilepath, wrappedInputFile);
cp.execFileSync(mksnapshot, [wrappedInputFilepath, `--startup_blob`, startupBlobFilepath]); cp.execFileSync(mksnapshot, [wrappedInputFilepath, `--startup_blob`, startupBlobFilepath]);
} }
})(snaps || (snaps = {})); })(snaps || (exports.snaps = snaps = {}));
//# sourceMappingURL=snapshotLoader.js.map //# sourceMappingURL=snapshotLoader.js.map

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
namespace snaps { export namespace snaps {
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');

View File

@ -3,14 +3,50 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.extractEditor = extractEditor; exports.extractEditor = extractEditor;
exports.createESMSourcesAndResources2 = createESMSourcesAndResources2; exports.createESMSourcesAndResources2 = createESMSourcesAndResources2;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const tss = require("./treeshaking"); const tss = __importStar(require("./treeshaking"));
const REPO_ROOT = path.join(__dirname, '../../'); const REPO_ROOT = path_1.default.join(__dirname, '../../');
const SRC_DIR = path.join(REPO_ROOT, 'src'); const SRC_DIR = path_1.default.join(REPO_ROOT, 'src');
const dirCache = {}; const dirCache = {};
function writeFile(filePath, contents) { function writeFile(filePath, contents) {
function ensureDirs(dirPath) { function ensureDirs(dirPath) {
@ -18,21 +54,21 @@ function writeFile(filePath, contents) {
return; return;
} }
dirCache[dirPath] = true; dirCache[dirPath] = true;
ensureDirs(path.dirname(dirPath)); ensureDirs(path_1.default.dirname(dirPath));
if (fs.existsSync(dirPath)) { if (fs_1.default.existsSync(dirPath)) {
return; return;
} }
fs.mkdirSync(dirPath); fs_1.default.mkdirSync(dirPath);
} }
ensureDirs(path.dirname(filePath)); ensureDirs(path_1.default.dirname(filePath));
fs.writeFileSync(filePath, contents); fs_1.default.writeFileSync(filePath, contents);
} }
function extractEditor(options) { function extractEditor(options) {
const ts = require('typescript'); const ts = require('typescript');
const tsConfig = JSON.parse(fs.readFileSync(path.join(options.sourcesRoot, 'tsconfig.monaco.json')).toString()); const tsConfig = JSON.parse(fs_1.default.readFileSync(path_1.default.join(options.sourcesRoot, 'tsconfig.monaco.json')).toString());
let compilerOptions; let compilerOptions;
if (tsConfig.extends) { if (tsConfig.extends) {
compilerOptions = Object.assign({}, require(path.join(options.sourcesRoot, tsConfig.extends)).compilerOptions, tsConfig.compilerOptions); compilerOptions = Object.assign({}, require(path_1.default.join(options.sourcesRoot, tsConfig.extends)).compilerOptions, tsConfig.compilerOptions);
delete tsConfig.extends; delete tsConfig.extends;
} }
else { else {
@ -62,7 +98,7 @@ function extractEditor(options) {
const result = tss.shake(options); const result = tss.shake(options);
for (const fileName in result) { for (const fileName in result) {
if (result.hasOwnProperty(fileName)) { if (result.hasOwnProperty(fileName)) {
writeFile(path.join(options.destRoot, fileName), result[fileName]); writeFile(path_1.default.join(options.destRoot, fileName), result[fileName]);
} }
} }
const copied = {}; const copied = {};
@ -71,12 +107,12 @@ function extractEditor(options) {
return; return;
} }
copied[fileName] = true; copied[fileName] = true;
const srcPath = path.join(options.sourcesRoot, fileName); const srcPath = path_1.default.join(options.sourcesRoot, fileName);
const dstPath = path.join(options.destRoot, fileName); const dstPath = path_1.default.join(options.destRoot, fileName);
writeFile(dstPath, fs.readFileSync(srcPath)); writeFile(dstPath, fs_1.default.readFileSync(srcPath));
}; };
const writeOutputFile = (fileName, contents) => { const writeOutputFile = (fileName, contents) => {
writeFile(path.join(options.destRoot, fileName), contents); writeFile(path_1.default.join(options.destRoot, fileName), contents);
}; };
for (const fileName in result) { for (const fileName in result) {
if (result.hasOwnProperty(fileName)) { if (result.hasOwnProperty(fileName)) {
@ -86,14 +122,14 @@ function extractEditor(options) {
const importedFileName = info.importedFiles[i].fileName; const importedFileName = info.importedFiles[i].fileName;
let importedFilePath = importedFileName; let importedFilePath = importedFileName;
if (/(^\.\/)|(^\.\.\/)/.test(importedFilePath)) { if (/(^\.\/)|(^\.\.\/)/.test(importedFilePath)) {
importedFilePath = path.join(path.dirname(fileName), importedFilePath); importedFilePath = path_1.default.join(path_1.default.dirname(fileName), importedFilePath);
} }
if (/\.css$/.test(importedFilePath)) { if (/\.css$/.test(importedFilePath)) {
transportCSS(importedFilePath, copyFile, writeOutputFile); transportCSS(importedFilePath, copyFile, writeOutputFile);
} }
else { else {
const pathToCopy = path.join(options.sourcesRoot, importedFilePath); const pathToCopy = path_1.default.join(options.sourcesRoot, importedFilePath);
if (fs.existsSync(pathToCopy) && !fs.statSync(pathToCopy).isDirectory()) { if (fs_1.default.existsSync(pathToCopy) && !fs_1.default.statSync(pathToCopy).isDirectory()) {
copyFile(importedFilePath); copyFile(importedFilePath);
} }
} }
@ -107,18 +143,18 @@ function extractEditor(options) {
].forEach(copyFile); ].forEach(copyFile);
} }
function createESMSourcesAndResources2(options) { function createESMSourcesAndResources2(options) {
const SRC_FOLDER = path.join(REPO_ROOT, options.srcFolder); const SRC_FOLDER = path_1.default.join(REPO_ROOT, options.srcFolder);
const OUT_FOLDER = path.join(REPO_ROOT, options.outFolder); const OUT_FOLDER = path_1.default.join(REPO_ROOT, options.outFolder);
const OUT_RESOURCES_FOLDER = path.join(REPO_ROOT, options.outResourcesFolder); const OUT_RESOURCES_FOLDER = path_1.default.join(REPO_ROOT, options.outResourcesFolder);
const getDestAbsoluteFilePath = (file) => { const getDestAbsoluteFilePath = (file) => {
const dest = options.renames[file.replace(/\\/g, '/')] || file; const dest = options.renames[file.replace(/\\/g, '/')] || file;
if (dest === 'tsconfig.json') { if (dest === 'tsconfig.json') {
return path.join(OUT_FOLDER, `tsconfig.json`); return path_1.default.join(OUT_FOLDER, `tsconfig.json`);
} }
if (/\.ts$/.test(dest)) { if (/\.ts$/.test(dest)) {
return path.join(OUT_FOLDER, dest); return path_1.default.join(OUT_FOLDER, dest);
} }
return path.join(OUT_RESOURCES_FOLDER, dest); return path_1.default.join(OUT_RESOURCES_FOLDER, dest);
}; };
const allFiles = walkDirRecursive(SRC_FOLDER); const allFiles = walkDirRecursive(SRC_FOLDER);
for (const file of allFiles) { for (const file of allFiles) {
@ -126,15 +162,15 @@ function createESMSourcesAndResources2(options) {
continue; continue;
} }
if (file === 'tsconfig.json') { if (file === 'tsconfig.json') {
const tsConfig = JSON.parse(fs.readFileSync(path.join(SRC_FOLDER, file)).toString()); const tsConfig = JSON.parse(fs_1.default.readFileSync(path_1.default.join(SRC_FOLDER, file)).toString());
tsConfig.compilerOptions.module = 'es2022'; tsConfig.compilerOptions.module = 'es2022';
tsConfig.compilerOptions.outDir = path.join(path.relative(OUT_FOLDER, OUT_RESOURCES_FOLDER), 'vs').replace(/\\/g, '/'); tsConfig.compilerOptions.outDir = path_1.default.join(path_1.default.relative(OUT_FOLDER, OUT_RESOURCES_FOLDER), 'vs').replace(/\\/g, '/');
write(getDestAbsoluteFilePath(file), JSON.stringify(tsConfig, null, '\t')); write(getDestAbsoluteFilePath(file), JSON.stringify(tsConfig, null, '\t'));
continue; continue;
} }
if (/\.ts$/.test(file) || /\.d\.ts$/.test(file) || /\.css$/.test(file) || /\.js$/.test(file) || /\.ttf$/.test(file)) { if (/\.ts$/.test(file) || /\.d\.ts$/.test(file) || /\.css$/.test(file) || /\.js$/.test(file) || /\.ttf$/.test(file)) {
// Transport the files directly // Transport the files directly
write(getDestAbsoluteFilePath(file), fs.readFileSync(path.join(SRC_FOLDER, file))); write(getDestAbsoluteFilePath(file), fs_1.default.readFileSync(path_1.default.join(SRC_FOLDER, file)));
continue; continue;
} }
console.log(`UNKNOWN FILE: ${file}`); console.log(`UNKNOWN FILE: ${file}`);
@ -148,10 +184,10 @@ function createESMSourcesAndResources2(options) {
return result; return result;
} }
function _walkDirRecursive(dir, result, trimPos) { function _walkDirRecursive(dir, result, trimPos) {
const files = fs.readdirSync(dir); const files = fs_1.default.readdirSync(dir);
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const file = path.join(dir, files[i]); const file = path_1.default.join(dir, files[i]);
if (fs.statSync(file).isDirectory()) { if (fs_1.default.statSync(file).isDirectory()) {
_walkDirRecursive(file, result, trimPos); _walkDirRecursive(file, result, trimPos);
} }
else { else {
@ -206,8 +242,8 @@ function transportCSS(module, enqueue, write) {
if (!/\.css/.test(module)) { if (!/\.css/.test(module)) {
return false; return false;
} }
const filename = path.join(SRC_DIR, module); const filename = path_1.default.join(SRC_DIR, module);
const fileContents = fs.readFileSync(filename).toString(); const fileContents = fs_1.default.readFileSync(filename).toString();
const inlineResources = 'base64'; // see https://github.com/microsoft/monaco-editor/issues/148 const inlineResources = 'base64'; // see https://github.com/microsoft/monaco-editor/issues/148
const newContents = _rewriteOrInlineUrls(fileContents, inlineResources === 'base64'); const newContents = _rewriteOrInlineUrls(fileContents, inlineResources === 'base64');
write(module, newContents); write(module, newContents);
@ -217,12 +253,12 @@ function transportCSS(module, enqueue, write) {
const fontMatch = url.match(/^(.*).ttf\?(.*)$/); const fontMatch = url.match(/^(.*).ttf\?(.*)$/);
if (fontMatch) { if (fontMatch) {
const relativeFontPath = `${fontMatch[1]}.ttf`; // trim the query parameter const relativeFontPath = `${fontMatch[1]}.ttf`; // trim the query parameter
const fontPath = path.join(path.dirname(module), relativeFontPath); const fontPath = path_1.default.join(path_1.default.dirname(module), relativeFontPath);
enqueue(fontPath); enqueue(fontPath);
return relativeFontPath; return relativeFontPath;
} }
const imagePath = path.join(path.dirname(module), url); const imagePath = path_1.default.join(path_1.default.dirname(module), url);
const fileContents = fs.readFileSync(path.join(SRC_DIR, imagePath)); const fileContents = fs_1.default.readFileSync(path_1.default.join(SRC_DIR, imagePath));
const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png'; const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png';
let DATA = ';base64,' + fileContents.toString('base64'); let DATA = ';base64,' + fileContents.toString('base64');
if (!forceBase64 && /\.svg$/.test(url)) { if (!forceBase64 && /\.svg$/.test(url)) {

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import * as tss from './treeshaking'; import * as tss from './treeshaking';
const REPO_ROOT = path.join(__dirname, '../../'); const REPO_ROOT = path.join(__dirname, '../../');

View File

@ -3,11 +3,14 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.createStatsStream = createStatsStream; exports.createStatsStream = createStatsStream;
const es = require("event-stream"); const event_stream_1 = __importDefault(require("event-stream"));
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
class Entry { class Entry {
name; name;
totalCount; totalCount;
@ -28,13 +31,13 @@ class Entry {
} }
else { else {
if (this.totalCount === 1) { if (this.totalCount === 1) {
return `Stats for '${ansiColors.grey(this.name)}': ${Math.round(this.totalSize / 1204)}KB`; return `Stats for '${ansi_colors_1.default.grey(this.name)}': ${Math.round(this.totalSize / 1204)}KB`;
} }
else { else {
const count = this.totalCount < 100 const count = this.totalCount < 100
? ansiColors.green(this.totalCount.toString()) ? ansi_colors_1.default.green(this.totalCount.toString())
: ansiColors.red(this.totalCount.toString()); : ansi_colors_1.default.red(this.totalCount.toString());
return `Stats for '${ansiColors.grey(this.name)}': ${count} files, ${Math.round(this.totalSize / 1204)}KB`; return `Stats for '${ansi_colors_1.default.grey(this.name)}': ${count} files, ${Math.round(this.totalSize / 1204)}KB`;
} }
} }
} }
@ -43,7 +46,7 @@ const _entries = new Map();
function createStatsStream(group, log) { function createStatsStream(group, log) {
const entry = new Entry(group, 0, 0); const entry = new Entry(group, 0, 0);
_entries.set(entry.name, entry); _entries.set(entry.name, entry);
return es.through(function (data) { return event_stream_1.default.through(function (data) {
const file = data; const file = data;
if (typeof file.path === 'string') { if (typeof file.path === 'string') {
entry.totalCount += 1; entry.totalCount += 1;
@ -61,13 +64,13 @@ function createStatsStream(group, log) {
}, function () { }, function () {
if (log) { if (log) {
if (entry.totalCount === 1) { if (entry.totalCount === 1) {
fancyLog(`Stats for '${ansiColors.grey(entry.name)}': ${Math.round(entry.totalSize / 1204)}KB`); (0, fancy_log_1.default)(`Stats for '${ansi_colors_1.default.grey(entry.name)}': ${Math.round(entry.totalSize / 1204)}KB`);
} }
else { else {
const count = entry.totalCount < 100 const count = entry.totalCount < 100
? ansiColors.green(entry.totalCount.toString()) ? ansi_colors_1.default.green(entry.totalCount.toString())
: ansiColors.red(entry.totalCount.toString()); : ansi_colors_1.default.red(entry.totalCount.toString());
fancyLog(`Stats for '${ansiColors.grey(entry.name)}': ${count} files, ${Math.round(entry.totalSize / 1204)}KB`); (0, fancy_log_1.default)(`Stats for '${ansi_colors_1.default.grey(entry.name)}': ${count} files, ${Math.round(entry.totalSize / 1204)}KB`);
} }
} }
this.emit('end'); this.emit('end');

View File

@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as es from 'event-stream'; import es from 'event-stream';
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
import * as File from 'vinyl'; import File from 'vinyl';
class Entry { class Entry {
constructor(readonly name: string, public totalCount: number, public totalSize: number) { } constructor(readonly name: string, public totalCount: number, public totalSize: number) { }

View File

@ -3,15 +3,18 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getVariableNameValidator = getVariableNameValidator; exports.getVariableNameValidator = getVariableNameValidator;
const fs_1 = require("fs"); const fs_1 = require("fs");
const path = require("path"); const path_1 = __importDefault(require("path"));
const RE_VAR_PROP = /var\(\s*(--([\w\-\.]+))/g; const RE_VAR_PROP = /var\(\s*(--([\w\-\.]+))/g;
let knownVariables; let knownVariables;
function getKnownVariableNames() { function getKnownVariableNames() {
if (!knownVariables) { if (!knownVariables) {
const knownVariablesFileContent = (0, fs_1.readFileSync)(path.join(__dirname, './vscode-known-variables.json'), 'utf8').toString(); const knownVariablesFileContent = (0, fs_1.readFileSync)(path_1.default.join(__dirname, './vscode-known-variables.json'), 'utf8').toString();
const knownVariablesInfo = JSON.parse(knownVariablesFileContent); const knownVariablesInfo = JSON.parse(knownVariablesFileContent);
knownVariables = new Set([...knownVariablesInfo.colors, ...knownVariablesInfo.others]); knownVariables = new Set([...knownVariablesInfo.colors, ...knownVariablesInfo.others]);
} }

View File

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import path = require('path'); import path from 'path';
const RE_VAR_PROP = /var\(\s*(--([\w\-\.]+))/g; const RE_VAR_PROP = /var\(\s*(--([\w\-\.]+))/g;

View File

@ -3,12 +3,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.series = series; exports.series = series;
exports.parallel = parallel; exports.parallel = parallel;
exports.define = define; exports.define = define;
const fancyLog = require("fancy-log"); const fancy_log_1 = __importDefault(require("fancy-log"));
const ansiColors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
function _isPromise(p) { function _isPromise(p) {
if (typeof p.then === 'function') { if (typeof p.then === 'function') {
return true; return true;
@ -21,14 +24,14 @@ function _renderTime(time) {
async function _execute(task) { async function _execute(task) {
const name = task.taskName || task.displayName || `<anonymous>`; const name = task.taskName || task.displayName || `<anonymous>`;
if (!task._tasks) { if (!task._tasks) {
fancyLog('Starting', ansiColors.cyan(name), '...'); (0, fancy_log_1.default)('Starting', ansi_colors_1.default.cyan(name), '...');
} }
const startTime = process.hrtime(); const startTime = process.hrtime();
await _doExecute(task); await _doExecute(task);
const elapsedArr = process.hrtime(startTime); const elapsedArr = process.hrtime(startTime);
const elapsedNanoseconds = (elapsedArr[0] * 1e9 + elapsedArr[1]); const elapsedNanoseconds = (elapsedArr[0] * 1e9 + elapsedArr[1]);
if (!task._tasks) { if (!task._tasks) {
fancyLog(`Finished`, ansiColors.cyan(name), 'after', ansiColors.magenta(_renderTime(elapsedNanoseconds / 1e6))); (0, fancy_log_1.default)(`Finished`, ansi_colors_1.default.cyan(name), 'after', ansi_colors_1.default.magenta(_renderTime(elapsedNanoseconds / 1e6)));
} }
} }
async function _doExecute(task) { async function _doExecute(task) {

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fancyLog from 'fancy-log'; import fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import ansiColors from 'ansi-colors';
export interface BaseTask { export interface BaseTask {
displayName?: string; displayName?: string;

View File

@ -3,9 +3,45 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert"); const assert_1 = __importDefault(require("assert"));
const i18n = require("../i18n"); const i18n = __importStar(require("../i18n"));
suite('XLF Parser Tests', () => { suite('XLF Parser Tests', () => {
const sampleXlf = '<?xml version="1.0" encoding="utf-8"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"><file original="vs/base/common/keybinding" source-language="en" datatype="plaintext"><body><trans-unit id="key1"><source xml:lang="en">Key #1</source></trans-unit><trans-unit id="key2"><source xml:lang="en">Key #2 &amp;</source></trans-unit></body></file></xliff>'; const sampleXlf = '<?xml version="1.0" encoding="utf-8"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"><file original="vs/base/common/keybinding" source-language="en" datatype="plaintext"><body><trans-unit id="key1"><source xml:lang="en">Key #1</source></trans-unit><trans-unit id="key2"><source xml:lang="en">Key #2 &amp;</source></trans-unit></body></file></xliff>';
const sampleTranslatedXlf = '<?xml version="1.0" encoding="utf-8"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"><file original="vs/base/common/keybinding" source-language="en" target-language="ru" datatype="plaintext"><body><trans-unit id="key1"><source xml:lang="en">Key #1</source><target>Кнопка #1</target></trans-unit><trans-unit id="key2"><source xml:lang="en">Key #2 &amp;</source><target>Кнопка #2 &amp;</target></trans-unit></body></file></xliff>'; const sampleTranslatedXlf = '<?xml version="1.0" encoding="utf-8"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"><file original="vs/base/common/keybinding" source-language="en" target-language="ru" datatype="plaintext"><body><trans-unit id="key1"><source xml:lang="en">Key #1</source><target>Кнопка #1</target></trans-unit><trans-unit id="key2"><source xml:lang="en">Key #2 &amp;</source><target>Кнопка #2 &amp;</target></trans-unit></body></file></xliff>';
@ -17,25 +53,25 @@ suite('XLF Parser Tests', () => {
const xlf = new i18n.XLF('vscode-workbench'); const xlf = new i18n.XLF('vscode-workbench');
xlf.addFile(name, keys, messages); xlf.addFile(name, keys, messages);
const xlfString = xlf.toString(); const xlfString = xlf.toString();
assert.strictEqual(xlfString.replace(/\s{2,}/g, ''), sampleXlf); assert_1.default.strictEqual(xlfString.replace(/\s{2,}/g, ''), sampleXlf);
}); });
test('XLF to keys & messages conversion', () => { test('XLF to keys & messages conversion', () => {
i18n.XLF.parse(sampleTranslatedXlf).then(function (resolvedFiles) { i18n.XLF.parse(sampleTranslatedXlf).then(function (resolvedFiles) {
assert.deepStrictEqual(resolvedFiles[0].messages, translatedMessages); assert_1.default.deepStrictEqual(resolvedFiles[0].messages, translatedMessages);
assert.strictEqual(resolvedFiles[0].name, name); assert_1.default.strictEqual(resolvedFiles[0].name, name);
}); });
}); });
test('JSON file source path to Transifex resource match', () => { test('JSON file source path to Transifex resource match', () => {
const editorProject = 'vscode-editor', workbenchProject = 'vscode-workbench'; const editorProject = 'vscode-editor', workbenchProject = 'vscode-workbench';
const platform = { name: 'vs/platform', project: editorProject }, editorContrib = { name: 'vs/editor/contrib', project: editorProject }, editor = { name: 'vs/editor', project: editorProject }, base = { name: 'vs/base', project: editorProject }, code = { name: 'vs/code', project: workbenchProject }, workbenchParts = { name: 'vs/workbench/contrib/html', project: workbenchProject }, workbenchServices = { name: 'vs/workbench/services/textfile', project: workbenchProject }, workbench = { name: 'vs/workbench', project: workbenchProject }; const platform = { name: 'vs/platform', project: editorProject }, editorContrib = { name: 'vs/editor/contrib', project: editorProject }, editor = { name: 'vs/editor', project: editorProject }, base = { name: 'vs/base', project: editorProject }, code = { name: 'vs/code', project: workbenchProject }, workbenchParts = { name: 'vs/workbench/contrib/html', project: workbenchProject }, workbenchServices = { name: 'vs/workbench/services/textfile', project: workbenchProject }, workbench = { name: 'vs/workbench', project: workbenchProject };
assert.deepStrictEqual(i18n.getResource('vs/platform/actions/browser/menusExtensionPoint'), platform); assert_1.default.deepStrictEqual(i18n.getResource('vs/platform/actions/browser/menusExtensionPoint'), platform);
assert.deepStrictEqual(i18n.getResource('vs/editor/contrib/clipboard/browser/clipboard'), editorContrib); assert_1.default.deepStrictEqual(i18n.getResource('vs/editor/contrib/clipboard/browser/clipboard'), editorContrib);
assert.deepStrictEqual(i18n.getResource('vs/editor/common/modes/modesRegistry'), editor); assert_1.default.deepStrictEqual(i18n.getResource('vs/editor/common/modes/modesRegistry'), editor);
assert.deepStrictEqual(i18n.getResource('vs/base/common/errorMessage'), base); assert_1.default.deepStrictEqual(i18n.getResource('vs/base/common/errorMessage'), base);
assert.deepStrictEqual(i18n.getResource('vs/code/electron-main/window'), code); assert_1.default.deepStrictEqual(i18n.getResource('vs/code/electron-main/window'), code);
assert.deepStrictEqual(i18n.getResource('vs/workbench/contrib/html/browser/webview'), workbenchParts); assert_1.default.deepStrictEqual(i18n.getResource('vs/workbench/contrib/html/browser/webview'), workbenchParts);
assert.deepStrictEqual(i18n.getResource('vs/workbench/services/textfile/node/testFileService'), workbenchServices); assert_1.default.deepStrictEqual(i18n.getResource('vs/workbench/services/textfile/node/testFileService'), workbenchServices);
assert.deepStrictEqual(i18n.getResource('vs/workbench/browser/parts/panel/panelActions'), workbench); assert_1.default.deepStrictEqual(i18n.getResource('vs/workbench/browser/parts/panel/panelActions'), workbench);
}); });
}); });
//# sourceMappingURL=i18n.test.js.map //# sourceMappingURL=i18n.test.js.map

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import assert = require('assert'); import assert from 'assert';
import i18n = require('../i18n'); import * as i18n from '../i18n';
suite('XLF Parser Tests', () => { suite('XLF Parser Tests', () => {
const sampleXlf = '<?xml version="1.0" encoding="utf-8"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"><file original="vs/base/common/keybinding" source-language="en" datatype="plaintext"><body><trans-unit id="key1"><source xml:lang="en">Key #1</source></trans-unit><trans-unit id="key2"><source xml:lang="en">Key #2 &amp;</source></trans-unit></body></file></xliff>'; const sampleXlf = '<?xml version="1.0" encoding="utf-8"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"><file original="vs/base/common/keybinding" source-language="en" datatype="plaintext"><body><trans-unit id="key1"><source xml:lang="en">Key #1</source></trans-unit><trans-unit id="key2"><source xml:lang="en">Key #2 &amp;</source></trans-unit></body></file></xliff>';

View File

@ -3,13 +3,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.ShakeLevel = void 0; exports.ShakeLevel = void 0;
exports.toStringShakeLevel = toStringShakeLevel; exports.toStringShakeLevel = toStringShakeLevel;
exports.shake = shake; exports.shake = shake;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const TYPESCRIPT_LIB_FOLDER = path.dirname(require.resolve('typescript/lib/lib.d.ts')); const TYPESCRIPT_LIB_FOLDER = path_1.default.dirname(require.resolve('typescript/lib/lib.d.ts'));
var ShakeLevel; var ShakeLevel;
(function (ShakeLevel) { (function (ShakeLevel) {
ShakeLevel[ShakeLevel["Files"] = 0] = "Files"; ShakeLevel[ShakeLevel["Files"] = 0] = "Files";
@ -30,7 +33,7 @@ function printDiagnostics(options, diagnostics) {
for (const diag of diagnostics) { for (const diag of diagnostics) {
let result = ''; let result = '';
if (diag.file) { if (diag.file) {
result += `${path.join(options.sourcesRoot, diag.file.fileName)}`; result += `${path_1.default.join(options.sourcesRoot, diag.file.fileName)}`;
} }
if (diag.file && diag.start) { if (diag.file && diag.start) {
const location = diag.file.getLineAndCharacterOfPosition(diag.start); const location = diag.file.getLineAndCharacterOfPosition(diag.start);
@ -72,8 +75,8 @@ function createTypeScriptLanguageService(ts, options) {
}); });
// Add additional typings // Add additional typings
options.typings.forEach((typing) => { options.typings.forEach((typing) => {
const filePath = path.join(options.sourcesRoot, typing); const filePath = path_1.default.join(options.sourcesRoot, typing);
FILES[typing] = fs.readFileSync(filePath).toString(); FILES[typing] = fs_1.default.readFileSync(filePath).toString();
}); });
// Resolve libs // Resolve libs
const RESOLVED_LIBS = processLibFiles(ts, options); const RESOLVED_LIBS = processLibFiles(ts, options);
@ -104,19 +107,19 @@ function discoverAndReadFiles(ts, options) {
if (options.redirects[moduleId]) { if (options.redirects[moduleId]) {
redirectedModuleId = options.redirects[moduleId]; redirectedModuleId = options.redirects[moduleId];
} }
const dts_filename = path.join(options.sourcesRoot, redirectedModuleId + '.d.ts'); const dts_filename = path_1.default.join(options.sourcesRoot, redirectedModuleId + '.d.ts');
if (fs.existsSync(dts_filename)) { if (fs_1.default.existsSync(dts_filename)) {
const dts_filecontents = fs.readFileSync(dts_filename).toString(); const dts_filecontents = fs_1.default.readFileSync(dts_filename).toString();
FILES[`${moduleId}.d.ts`] = dts_filecontents; FILES[`${moduleId}.d.ts`] = dts_filecontents;
continue; continue;
} }
const js_filename = path.join(options.sourcesRoot, redirectedModuleId + '.js'); const js_filename = path_1.default.join(options.sourcesRoot, redirectedModuleId + '.js');
if (fs.existsSync(js_filename)) { if (fs_1.default.existsSync(js_filename)) {
// This is an import for a .js file, so ignore it... // This is an import for a .js file, so ignore it...
continue; continue;
} }
const ts_filename = path.join(options.sourcesRoot, redirectedModuleId + '.ts'); const ts_filename = path_1.default.join(options.sourcesRoot, redirectedModuleId + '.ts');
const ts_filecontents = fs.readFileSync(ts_filename).toString(); const ts_filecontents = fs_1.default.readFileSync(ts_filename).toString();
const info = ts.preProcessFile(ts_filecontents); const info = ts.preProcessFile(ts_filecontents);
for (let i = info.importedFiles.length - 1; i >= 0; i--) { for (let i = info.importedFiles.length - 1; i >= 0; i--) {
const importedFileName = info.importedFiles[i].fileName; const importedFileName = info.importedFiles[i].fileName;
@ -126,7 +129,7 @@ function discoverAndReadFiles(ts, options) {
} }
let importedModuleId = importedFileName; let importedModuleId = importedFileName;
if (/(^\.\/)|(^\.\.\/)/.test(importedModuleId)) { if (/(^\.\/)|(^\.\.\/)/.test(importedModuleId)) {
importedModuleId = path.join(path.dirname(moduleId), importedModuleId); importedModuleId = path_1.default.join(path_1.default.dirname(moduleId), importedModuleId);
if (importedModuleId.endsWith('.js')) { // ESM: code imports require to be relative and have a '.js' file extension if (importedModuleId.endsWith('.js')) { // ESM: code imports require to be relative and have a '.js' file extension
importedModuleId = importedModuleId.substr(0, importedModuleId.length - 3); importedModuleId = importedModuleId.substr(0, importedModuleId.length - 3);
} }
@ -148,8 +151,8 @@ function processLibFiles(ts, options) {
const key = `defaultLib:${filename}`; const key = `defaultLib:${filename}`;
if (!result[key]) { if (!result[key]) {
// add this file // add this file
const filepath = path.join(TYPESCRIPT_LIB_FOLDER, filename); const filepath = path_1.default.join(TYPESCRIPT_LIB_FOLDER, filename);
const sourceText = fs.readFileSync(filepath).toString(); const sourceText = fs_1.default.readFileSync(filepath).toString();
result[key] = sourceText; result[key] = sourceText;
// precess dependencies and "recurse" // precess dependencies and "recurse"
const info = ts.preProcessFile(sourceText); const info = ts.preProcessFile(sourceText);
@ -459,7 +462,7 @@ function markNodes(ts, languageService, options) {
if (importText.endsWith('.js')) { // ESM: code imports require to be relative and to have a '.js' file extension if (importText.endsWith('.js')) { // ESM: code imports require to be relative and to have a '.js' file extension
importText = importText.substr(0, importText.length - 3); importText = importText.substr(0, importText.length - 3);
} }
fullPath = path.join(path.dirname(nodeSourceFile.fileName), importText) + '.ts'; fullPath = path_1.default.join(path_1.default.dirname(nodeSourceFile.fileName), importText) + '.ts';
} }
else { else {
fullPath = importText + '.ts'; fullPath = importText + '.ts';

View File

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import type * as ts from 'typescript'; import type * as ts from 'typescript';
const TYPESCRIPT_LIB_FOLDER = path.dirname(require.resolve('typescript/lib/lib.d.ts')); const TYPESCRIPT_LIB_FOLDER = path.dirname(require.resolve('typescript/lib/lib.d.ts'));

View File

@ -3,16 +3,52 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.CancellationToken = void 0; exports.CancellationToken = void 0;
exports.createTypeScriptBuilder = createTypeScriptBuilder; exports.createTypeScriptBuilder = createTypeScriptBuilder;
const fs = require("fs"); const fs_1 = __importDefault(require("fs"));
const path = require("path"); const path_1 = __importDefault(require("path"));
const crypto = require("crypto"); const crypto_1 = __importDefault(require("crypto"));
const utils = require("./utils"); const utils = __importStar(require("./utils"));
const colors = require("ansi-colors"); const ansi_colors_1 = __importDefault(require("ansi-colors"));
const ts = require("typescript"); const typescript_1 = __importDefault(require("typescript"));
const Vinyl = require("vinyl"); const vinyl_1 = __importDefault(require("vinyl"));
const source_map_1 = require("source-map"); const source_map_1 = require("source-map");
var CancellationToken; var CancellationToken;
(function (CancellationToken) { (function (CancellationToken) {
@ -28,7 +64,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
const host = new LanguageServiceHost(cmd, projectFile, _log); const host = new LanguageServiceHost(cmd, projectFile, _log);
const outHost = new LanguageServiceHost({ ...cmd, options: { ...cmd.options, sourceRoot: cmd.options.outDir } }, cmd.options.outDir ?? '', _log); const outHost = new LanguageServiceHost({ ...cmd, options: { ...cmd.options, sourceRoot: cmd.options.outDir } }, cmd.options.outDir ?? '', _log);
let lastCycleCheckVersion; let lastCycleCheckVersion;
const service = ts.createLanguageService(host, ts.createDocumentRegistry()); const service = typescript_1.default.createLanguageService(host, typescript_1.default.createDocumentRegistry());
const lastBuildVersion = Object.create(null); const lastBuildVersion = Object.create(null);
const lastDtsHash = Object.create(null); const lastDtsHash = Object.create(null);
const userWantsDeclarations = cmd.options.declaration; const userWantsDeclarations = cmd.options.declaration;
@ -92,7 +128,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
if (/\.d\.ts$/.test(fileName)) { if (/\.d\.ts$/.test(fileName)) {
// if it's already a d.ts file just emit it signature // if it's already a d.ts file just emit it signature
const snapshot = host.getScriptSnapshot(fileName); const snapshot = host.getScriptSnapshot(fileName);
const signature = crypto.createHash('sha256') const signature = crypto_1.default.createHash('sha256')
.update(snapshot.getText(0, snapshot.getLength())) .update(snapshot.getText(0, snapshot.getLength()))
.digest('base64'); .digest('base64');
return resolve({ return resolve({
@ -109,7 +145,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
continue; continue;
} }
if (/\.d\.ts$/.test(file.name)) { if (/\.d\.ts$/.test(file.name)) {
signature = crypto.createHash('sha256') signature = crypto_1.default.createHash('sha256')
.update(file.text) .update(file.text)
.digest('base64'); .digest('base64');
if (!userWantsDeclarations) { if (!userWantsDeclarations) {
@ -117,7 +153,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
continue; continue;
} }
} }
const vinyl = new Vinyl({ const vinyl = new vinyl_1.default({
path: file.name, path: file.name,
contents: Buffer.from(file.text), contents: Buffer.from(file.text),
base: !config._emitWithoutBasePath && baseFor(host.getScriptSnapshot(fileName)) || undefined base: !config._emitWithoutBasePath && baseFor(host.getScriptSnapshot(fileName)) || undefined
@ -125,9 +161,9 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
if (!emitSourceMapsInStream && /\.js$/.test(file.name)) { if (!emitSourceMapsInStream && /\.js$/.test(file.name)) {
const sourcemapFile = output.outputFiles.filter(f => /\.js\.map$/.test(f.name))[0]; const sourcemapFile = output.outputFiles.filter(f => /\.js\.map$/.test(f.name))[0];
if (sourcemapFile) { if (sourcemapFile) {
const extname = path.extname(vinyl.relative); const extname = path_1.default.extname(vinyl.relative);
const basename = path.basename(vinyl.relative, extname); const basename = path_1.default.basename(vinyl.relative, extname);
const dirname = path.dirname(vinyl.relative); const dirname = path_1.default.dirname(vinyl.relative);
const tsname = (dirname === '.' ? '' : dirname + '/') + basename + '.ts'; const tsname = (dirname === '.' ? '' : dirname + '/') + basename + '.ts';
let sourceMap = JSON.parse(sourcemapFile.text); let sourceMap = JSON.parse(sourcemapFile.text);
sourceMap.sources[0] = tsname.replace(/\\/g, '/'); sourceMap.sources[0] = tsname.replace(/\\/g, '/');
@ -359,7 +395,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
delete oldErrors[projectFile]; delete oldErrors[projectFile];
if (oneCycle) { if (oneCycle) {
const cycleError = { const cycleError = {
category: ts.DiagnosticCategory.Error, category: typescript_1.default.DiagnosticCategory.Error,
code: 1, code: 1,
file: undefined, file: undefined,
start: undefined, start: undefined,
@ -383,7 +419,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
// print stats // print stats
const headNow = process.memoryUsage().heapUsed; const headNow = process.memoryUsage().heapUsed;
const MB = 1024 * 1024; const MB = 1024 * 1024;
_log('[tsb]', `time: ${colors.yellow((Date.now() - t1) + 'ms')} + \nmem: ${colors.cyan(Math.ceil(headNow / MB) + 'MB')} ${colors.bgcyan('delta: ' + Math.ceil((headNow - headUsed) / MB))}`); _log('[tsb]', `time: ${ansi_colors_1.default.yellow((Date.now() - t1) + 'ms')} + \nmem: ${ansi_colors_1.default.cyan(Math.ceil(headNow / MB) + 'MB')} ${ansi_colors_1.default.bgcyan('delta: ' + Math.ceil((headNow - headUsed) / MB))}`);
headUsed = headNow; headUsed = headNow;
}); });
} }
@ -480,11 +516,11 @@ class LanguageServiceHost {
let result = this._snapshots[filename]; let result = this._snapshots[filename];
if (!result && resolve) { if (!result && resolve) {
try { try {
result = new VinylScriptSnapshot(new Vinyl({ result = new VinylScriptSnapshot(new vinyl_1.default({
path: filename, path: filename,
contents: fs.readFileSync(filename), contents: fs_1.default.readFileSync(filename),
base: this.getCompilationSettings().outDir, base: this.getCompilationSettings().outDir,
stat: fs.statSync(filename) stat: fs_1.default.statSync(filename)
})); }));
this.addScriptSnapshot(filename, result); this.addScriptSnapshot(filename, result);
} }
@ -529,16 +565,16 @@ class LanguageServiceHost {
return delete this._snapshots[filename]; return delete this._snapshots[filename];
} }
getCurrentDirectory() { getCurrentDirectory() {
return path.dirname(this._projectPath); return path_1.default.dirname(this._projectPath);
} }
getDefaultLibFileName(options) { getDefaultLibFileName(options) {
return ts.getDefaultLibFilePath(options); return typescript_1.default.getDefaultLibFilePath(options);
} }
directoryExists = ts.sys.directoryExists; directoryExists = typescript_1.default.sys.directoryExists;
getDirectories = ts.sys.getDirectories; getDirectories = typescript_1.default.sys.getDirectories;
fileExists = ts.sys.fileExists; fileExists = typescript_1.default.sys.fileExists;
readFile = ts.sys.readFile; readFile = typescript_1.default.sys.readFile;
readDirectory = ts.sys.readDirectory; readDirectory = typescript_1.default.sys.readDirectory;
// ---- dependency management // ---- dependency management
collectDependents(filename, target) { collectDependents(filename, target) {
while (this._dependenciesRecomputeList.length) { while (this._dependenciesRecomputeList.length) {
@ -570,18 +606,18 @@ class LanguageServiceHost {
this._log('processFile', `Missing snapshot for: ${filename}`); this._log('processFile', `Missing snapshot for: ${filename}`);
return; return;
} }
const info = ts.preProcessFile(snapshot.getText(0, snapshot.getLength()), true); const info = typescript_1.default.preProcessFile(snapshot.getText(0, snapshot.getLength()), true);
// (0) clear out old dependencies // (0) clear out old dependencies
this._dependencies.resetNode(filename); this._dependencies.resetNode(filename);
// (1) ///-references // (1) ///-references
info.referencedFiles.forEach(ref => { info.referencedFiles.forEach(ref => {
const resolvedPath = path.resolve(path.dirname(filename), ref.fileName); const resolvedPath = path_1.default.resolve(path_1.default.dirname(filename), ref.fileName);
const normalizedPath = normalize(resolvedPath); const normalizedPath = normalize(resolvedPath);
this._dependencies.inertEdge(filename, normalizedPath); this._dependencies.inertEdge(filename, normalizedPath);
}); });
// (2) import-require statements // (2) import-require statements
info.importedFiles.forEach(ref => { info.importedFiles.forEach(ref => {
if (!ref.fileName.startsWith('.') || path.extname(ref.fileName) === '') { if (!ref.fileName.startsWith('.') || path_1.default.extname(ref.fileName) === '') {
// node module? // node module?
return; return;
} }
@ -589,8 +625,8 @@ class LanguageServiceHost {
let dirname = filename; let dirname = filename;
let found = false; let found = false;
while (!found && dirname.indexOf(stopDirname) === 0) { while (!found && dirname.indexOf(stopDirname) === 0) {
dirname = path.dirname(dirname); dirname = path_1.default.dirname(dirname);
let resolvedPath = path.resolve(dirname, ref.fileName); let resolvedPath = path_1.default.resolve(dirname, ref.fileName);
if (resolvedPath.endsWith('.js')) { if (resolvedPath.endsWith('.js')) {
resolvedPath = resolvedPath.slice(0, -3); resolvedPath = resolvedPath.slice(0, -3);
} }

Some files were not shown because too many files have changed in this diff Show More