Skip to content

Commit

Permalink
Adding type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Feb 28, 2022
1 parent 062b82c commit f71bd27
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 6 deletions.
8 changes: 8 additions & 0 deletions build/gulpfile.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ const appendJSToESMImportsTask = task.define('append-js-to-esm-imports', () => {
}
});

/**
* @param {string} contents
*/
function toExternalDTS(contents) {
let lines = contents.split(/\r\n|\r|\n/);
let killNextCloseCurlyBrace = false;
Expand Down Expand Up @@ -278,6 +281,9 @@ function toExternalDTS(contents) {
return lines.join('\n').replace(/\n\n\n+/g, '\n\n');
}

/**
* @param {{ (path: string): boolean }} testFunc
*/
function filterStream(testFunc) {
return es.through(function (data) {
if (!testFunc(data.relative)) {
Expand Down Expand Up @@ -479,6 +485,8 @@ function createTscCompileTask(watch) {
});
let errors = [];
let reporter = createReporter('monaco');

/** @type {NodeJS.ReadWriteStream | undefined} */
let report;
// eslint-disable-next-line no-control-regex
let magic = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; // https://stackoverflow.com/questions/25245716/remove-all-ansi-colors-styles-from-strings
Expand Down
3 changes: 3 additions & 0 deletions build/gulpfile.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ const watchWebExtensionsTask = task.define('watch-web', () => buildWebExtensions
gulp.task(watchWebExtensionsTask);
exports.watchWebExtensionsTask = watchWebExtensionsTask;

/**
* @param {boolean} isWatch
*/
async function buildWebExtensions(isWatch) {
const webpackConfigLocations = await nodeUtil.promisify(glob)(
path.join(extensionsPath, '**', 'extension-browser.webpack.config.js'),
Expand Down
3 changes: 3 additions & 0 deletions build/gulpfile.hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const path = require('path');
const task = require('./lib/task');
const { hygiene } = require('./hygiene');

/**
* @param {string} actualPath
*/
function checkPackageJSON(actualPath) {
const actual = require(path.join(__dirname, '..', actualPath));
const rootPackageJSON = require('../package.json');
Expand Down
2 changes: 1 addition & 1 deletion build/gulpfile.scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BUILD_TARGETS = [
];

BUILD_TARGETS.forEach(buildTarget => {
const dashed = (str) => (str ? `-${str}` : ``);
const dashed = (/** @type {string | null} */ str) => (str ? `-${str}` : ``);
const platform = buildTarget.platform;
const arch = buildTarget.arch;

Expand Down
24 changes: 24 additions & 0 deletions build/gulpfile.vscode.linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ function prepareDebPackage(arch) {
};
}

/**
* @param {string} arch
*/
function buildDebPackage(arch) {
const debArch = getDebPackageArch(arch);
return shell.task([
Expand All @@ -112,14 +115,23 @@ function buildDebPackage(arch) {
], { cwd: '.build/linux/deb/' + debArch });
}

/**
* @param {string} rpmArch
*/
function getRpmBuildPath(rpmArch) {
return '.build/linux/rpm/' + rpmArch + '/rpmbuild';
}

/**
* @param {string} arch
*/
function getRpmPackageArch(arch) {
return { x64: 'x86_64', armhf: 'armv7hl', arm64: 'aarch64' }[arch];
}

/**
* @param {string} arch
*/
function prepareRpmPackage(arch) {
const binaryDir = '../VSCode-linux-' + arch;
const rpmArch = getRpmPackageArch(arch);
Expand Down Expand Up @@ -186,6 +198,9 @@ function prepareRpmPackage(arch) {
};
}

/**
* @param {string} arch
*/
function buildRpmPackage(arch) {
const rpmArch = getRpmPackageArch(arch);
const rpmBuildPath = getRpmBuildPath(rpmArch);
Expand All @@ -199,10 +214,16 @@ function buildRpmPackage(arch) {
]);
}

/**
* @param {string} arch
*/
function getSnapBuildPath(arch) {
return `.build/linux/snap/${arch}/${product.applicationName}-${arch}`;
}

/**
* @param {string} arch
*/
function prepareSnapPackage(arch) {
const binaryDir = '../VSCode-linux-' + arch;
const destination = getSnapBuildPath(arch);
Expand Down Expand Up @@ -247,6 +268,9 @@ function prepareSnapPackage(arch) {
};
}

/**
* @param {string} arch
*/
function buildSnapPackage(arch) {
const snapBuildPath = getSnapBuildPath(arch);
// Default target for snapcraft runs: pull, build, stage and prime, and finally assembles the snap.
Expand Down
2 changes: 1 addition & 1 deletion build/gulpfile.vscode.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const compileWebExtensionsBuildTask = task.define('compile-web-extensions-build'
));
gulp.task(compileWebExtensionsBuildTask);

const dashed = (str) => (str ? `-${str}` : ``);
const dashed = (/** @type {string} */ str) => (str ? `-${str}` : ``);

['', 'min'].forEach(minified => {
const sourceFolderName = `out-vscode-web${dashed(minified)}`;
Expand Down
25 changes: 21 additions & 4 deletions build/gulpfile.vscode.win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const rcedit = require('rcedit');
const mkdirp = require('mkdirp');

const repoPath = path.dirname(__dirname);
const buildPath = arch => path.join(path.dirname(repoPath), `VSCode-win32-${arch}`);
const zipDir = arch => path.join(repoPath, '.build', `win32-${arch}`, 'archive');
const zipPath = arch => path.join(zipDir(arch), `VSCode-win32-${arch}.zip`);
const setupDir = (arch, target) => path.join(repoPath, '.build', `win32-${arch}`, `${target}-setup`);
const buildPath = (/** @type {string} */ arch) => path.join(path.dirname(repoPath), `VSCode-win32-${arch}`);
const zipDir = (/** @type {string} */ arch) => path.join(repoPath, '.build', `win32-${arch}`, 'archive');
const zipPath = (/** @type {string} */ arch) => path.join(zipDir(arch), `VSCode-win32-${arch}.zip`);
const setupDir = (/** @type {string} */ arch, /** @type {string} */ target) => path.join(repoPath, '.build', `win32-${arch}`, `${target}-setup`);
const issPath = path.join(__dirname, 'win32', 'code.iss');
const innoSetupPath = path.join(path.dirname(path.dirname(require.resolve('innosetup'))), 'bin', 'ISCC.exe');
const signWin32Path = path.join(repoPath, 'build', 'azure-pipelines', 'common', 'sign-win32');
Expand Down Expand Up @@ -63,6 +63,10 @@ function packageInnoSetup(iss, options, cb) {
});
}

/**
* @param {string} arch
* @param {string} target
*/
function buildWin32Setup(arch, target) {
if (target !== 'system' && target !== 'user') {
throw new Error('Invalid setup target');
Expand Down Expand Up @@ -112,6 +116,10 @@ function buildWin32Setup(arch, target) {
};
}

/**
* @param {string} arch
* @param {string} target
*/
function defineWin32SetupTasks(arch, target) {
const cleanTask = util.rimraf(setupDir(arch, target));
gulp.task(task.define(`vscode-win32-${arch}-${target}-setup`, task.series(cleanTask, buildWin32Setup(arch, target))));
Expand All @@ -124,6 +132,9 @@ defineWin32SetupTasks('ia32', 'user');
defineWin32SetupTasks('x64', 'user');
defineWin32SetupTasks('arm64', 'user');

/**
* @param {string} arch
*/
function archiveWin32Setup(arch) {
return cb => {
const args = ['a', '-tzip', zipPath(arch), '-x!CodeSignSummary*.md', '.', '-r'];
Expand All @@ -138,13 +149,19 @@ gulp.task(task.define('vscode-win32-ia32-archive', task.series(util.rimraf(zipDi
gulp.task(task.define('vscode-win32-x64-archive', task.series(util.rimraf(zipDir('x64')), archiveWin32Setup('x64'))));
gulp.task(task.define('vscode-win32-arm64-archive', task.series(util.rimraf(zipDir('arm64')), archiveWin32Setup('arm64'))));

/**
* @param {string} arch
*/
function copyInnoUpdater(arch) {
return () => {
return gulp.src('build/win32/{inno_updater.exe,vcruntime140.dll}', { base: 'build/win32' })
.pipe(vfs.dest(path.join(buildPath(arch), 'tools')));
};
}

/**
* @param {string} executablePath
*/
function updateIcon(executablePath) {
return cb => {
const icon = path.join(repoPath, 'resources', 'win32', 'code.ico');
Expand Down

0 comments on commit f71bd27

Please sign in to comment.