Build script cleanup

For #277526

Quick cleanup pass after converting these scripts
This commit is contained in:
Matt Bierner
2025-11-24 14:07:28 -08:00
parent 84f778cf5a
commit e779f86b17
17 changed files with 37 additions and 49 deletions

View File

@@ -71,7 +71,7 @@ const MimeTypesToCompress = new Set([
function wait(stream: es.ThroughStream): Promise<void> { function wait(stream: es.ThroughStream): Promise<void> {
return new Promise<void>((c, e) => { return new Promise<void>((c, e) => {
stream.on('end', () => c()); stream.on('end', () => c());
stream.on('error', (err: any) => e(err)); stream.on('error', (err) => e(err));
}); });
} }

View File

@@ -65,7 +65,7 @@ function main(): Promise<void> {
prefix: `sourcemaps/${commit}/` prefix: `sourcemaps/${commit}/`
})) }))
.on('end', () => c()) .on('end', () => c())
.on('error', (err: any) => e(err)); .on('error', (err) => e(err));
}); });
} }

View File

@@ -6,7 +6,7 @@
import gulp from 'gulp'; import gulp from 'gulp';
import path from 'path'; import path from 'path';
import * as util from './lib/util.ts'; import * as util from './lib/util.ts';
import * as getVersionModule from './lib/getVersion.ts'; import { getVersion } from './lib/getVersion.ts';
import * as task from './lib/task.ts'; import * as task from './lib/task.ts';
import es from 'event-stream'; import es from 'event-stream';
import File from 'vinyl'; import File from 'vinyl';
@@ -17,11 +17,9 @@ import * as compilation from './lib/compilation.ts';
import * as monacoapi from './lib/monaco-api.ts'; import * as monacoapi from './lib/monaco-api.ts';
import * as fs from 'fs'; import * as fs from 'fs';
import filter from 'gulp-filter'; import filter from 'gulp-filter';
import * as reporterModule from './lib/reporter.ts'; import { createReporter } from './lib/reporter.ts';
import monacoPackage from './monaco/package.json' with { type: 'json' }; import monacoPackage from './monaco/package.json' with { type: 'json' };
const { getVersion } = getVersionModule;
const { createReporter } = reporterModule;
const root = path.dirname(import.meta.dirname); const root = path.dirname(import.meta.dirname);
const sha1 = getVersion(root); const sha1 = getVersion(root);
const semver = monacoPackage.version; const semver = monacoPackage.version;

View File

@@ -13,18 +13,16 @@ import * as nodeUtil from 'util';
import es from 'event-stream'; import es from 'event-stream';
import filter from 'gulp-filter'; import filter from 'gulp-filter';
import * as util from './lib/util.ts'; import * as util from './lib/util.ts';
import * as getVersionModule from './lib/getVersion.ts'; import { getVersion } from './lib/getVersion.ts';
import * as task from './lib/task.ts'; import * as task from './lib/task.ts';
import watcher from './lib/watch/index.ts'; import watcher from './lib/watch/index.ts';
import * as reporterModule from './lib/reporter.ts'; import { createReporter } from './lib/reporter.ts';
import glob from 'glob'; import glob from 'glob';
import plumber from 'gulp-plumber'; import plumber from 'gulp-plumber';
import * as ext from './lib/extensions.ts'; import * as ext from './lib/extensions.ts';
import * as tsb from './lib/tsb/index.ts'; import * as tsb from './lib/tsb/index.ts';
import sourcemaps from 'gulp-sourcemaps'; import sourcemaps from 'gulp-sourcemaps';
const { getVersion } = getVersionModule;
const { createReporter } = reporterModule;
const root = path.dirname(import.meta.dirname); const root = path.dirname(import.meta.dirname);
const commit = getVersion(root); const commit = getVersion(root);

View File

@@ -8,13 +8,11 @@ import * as path from 'path';
import * as task from './lib/task.ts'; import * as task from './lib/task.ts';
import * as util from './lib/util.ts'; import * as util from './lib/util.ts';
import electron from '@vscode/gulp-electron'; import electron from '@vscode/gulp-electron';
import * as electronConfigModule from './lib/electron.ts'; import { config } from './lib/electron.ts';
import filter from 'gulp-filter'; import filter from 'gulp-filter';
import * as deps from './lib/dependencies.ts'; import * as deps from './lib/dependencies.ts';
import { existsSync, readdirSync } from 'fs'; import { existsSync, readdirSync } from 'fs';
const { config } = electronConfigModule;
const root = path.dirname(import.meta.dirname); const root = path.dirname(import.meta.dirname);
const BUILD_TARGETS = [ const BUILD_TARGETS = [

View File

@@ -86,7 +86,7 @@ const vscodeWebEntryPoints = [
].flat(); ].flat();
/** /**
* @param extensionsRoot {string} The location where extension will be read from * @param extensionsRoot The location where extension will be read from
* @param product The parsed product.json file contents * @param product The parsed product.json file contents
*/ */
export const createVSCodeWebFileContentMapper = (extensionsRoot: string, product: typeof import('../product.json')) => { export const createVSCodeWebFileContentMapper = (extensionsRoot: string, product: typeof import('../product.json')) => {

View File

@@ -2,22 +2,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.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import gulp from 'gulp';
import * as path from 'path';
import * as fs from 'fs';
import assert from 'assert'; import assert from 'assert';
import * as cp from 'child_process'; import * as cp from 'child_process';
import * as util from './lib/util.ts'; import * as fs from 'fs';
import * as getVersionModule from './lib/getVersion.ts'; import gulp from 'gulp';
import * as task from './lib/task.ts'; import * as path from 'path';
import rcedit from 'rcedit';
import vfs from 'vinyl-fs';
import pkg from '../package.json' with { type: 'json' }; import pkg from '../package.json' with { type: 'json' };
import product from '../product.json' with { type: 'json' }; import product from '../product.json' with { type: 'json' };
import vfs from 'vinyl-fs'; import { getVersion } from './lib/getVersion.ts';
import rcedit from 'rcedit'; import * as task from './lib/task.ts';
import { createRequire } from 'module'; import * as util from './lib/util.ts';
const { getVersion } = getVersionModule; import { createRequire } from 'module';
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
const repoPath = path.dirname(import.meta.dirname); const repoPath = path.dirname(import.meta.dirname);
const commit = getVersion(repoPath); const commit = getVersion(repoPath);
const buildPath = (arch: string) => path.join(path.dirname(repoPath), `VSCode-win32-${arch}`); const buildPath = (arch: string) => path.join(path.dirname(repoPath), `VSCode-win32-${arch}`);
@@ -58,12 +58,12 @@ function packageInnoSetup(iss: string, options: { definitions?: Record<string, u
}); });
} }
function buildWin32Setup(arch: string, target: string) { function buildWin32Setup(arch: string, target: string): task.CallbackTask {
if (target !== 'system' && target !== 'user') { if (target !== 'system' && target !== 'user') {
throw new Error('Invalid setup target'); throw new Error('Invalid setup target');
} }
return (cb?: (err?: any) => void) => { return (cb) => {
const x64AppId = target === 'system' ? product.win32x64AppId : product.win32x64UserAppId; const x64AppId = target === 'system' ? product.win32x64AppId : product.win32x64UserAppId;
const arm64AppId = target === 'system' ? product.win32arm64AppId : product.win32arm64UserAppId; const arm64AppId = target === 'system' ? product.win32arm64AppId : product.win32arm64UserAppId;

View File

@@ -247,7 +247,7 @@ class MonacoGenerator {
return r; return r;
} }
private _log(message: any, ...rest: unknown[]): void { private _log(message: string, ...rest: unknown[]): void {
fancyLog(ansiColors.cyan('[monaco.d.ts]'), message, ...rest); fancyLog(ansiColors.cyan('[monaco.d.ts]'), message, ...rest);
} }

View File

@@ -131,7 +131,7 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string,
) as string[]); ) as string[]);
const webpackStreams = webpackConfigLocations.flatMap(webpackConfigPath => { const webpackStreams = webpackConfigLocations.flatMap(webpackConfigPath => {
const webpackDone = (err: any, stats: any) => { const webpackDone = (err: Error | undefined, stats: any) => {
fancyLog(`Bundled extension: ${ansiColors.yellow(path.join(path.basename(extensionPath), path.relative(extensionPath, webpackConfigPath)))}...`); fancyLog(`Bundled extension: ${ansiColors.yellow(path.join(path.basename(extensionPath), path.relative(extensionPath, webpackConfigPath)))}...`);
if (err) { if (err) {
result.emit('error', err); result.emit('error', err);

View File

@@ -80,7 +80,7 @@ interface BundledFormat {
type NLSKeysFormat = [string /* module ID */, string[] /* keys */]; type NLSKeysFormat = [string /* module ID */, string[] /* keys */];
function isNLSKeysFormat(value: any): value is NLSKeysFormat { function isNLSKeysFormat(value: unknown): value is NLSKeysFormat {
if (value === undefined) { if (value === undefined) {
return false; return false;
} }
@@ -239,7 +239,7 @@ export class XLF {
const files: { messages: Record<string, string>; name: string; language: string }[] = []; const files: { messages: Record<string, string>; name: string; language: string }[] = [];
parser.parseString(xlfString, function (err: any, result: any) { parser.parseString(xlfString, function (err: Error | undefined, result: any) {
if (err) { if (err) {
reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`)); reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`));
} }

View File

@@ -268,7 +268,7 @@ const _nls = (() => {
// `localize` named imports // `localize` named imports
const allLocalizeImportDeclarations = importDeclarations const allLocalizeImportDeclarations = importDeclarations
.filter(d => !!(d.importClause && d.importClause.namedBindings && d.importClause.namedBindings.kind === ts.SyntaxKind.NamedImports)) .filter(d => !!(d.importClause && d.importClause.namedBindings && d.importClause.namedBindings.kind === ts.SyntaxKind.NamedImports))
.map(d => ([] as any[]).concat((d.importClause!.namedBindings! as ts.NamedImports).elements)) .map(d => (d.importClause!.namedBindings! as ts.NamedImports).elements)
.flatten(); .flatten();
// `localize` read-only references // `localize` read-only references
@@ -280,7 +280,7 @@ const _nls = (() => {
// custom named `localize` read-only references // custom named `localize` read-only references
const namedLocalizeReferences = allLocalizeImportDeclarations const namedLocalizeReferences = allLocalizeImportDeclarations
.filter(d => d.propertyName && d.propertyName.getText() === functionName) .filter(d => !!d.propertyName && d.propertyName.getText() === functionName)
.map(n => service.getReferencesAtPosition(filename, n.name.pos + 1) ?? []) .map(n => service.getReferencesAtPosition(filename, n.name.pos + 1) ?? [])
.flatten() .flatten()
.filter(r => !r.isWriteAccess); .filter(r => !r.isWriteAccess);

View File

@@ -18,7 +18,7 @@ export interface StreamTask extends BaseTask {
(): NodeJS.ReadWriteStream; (): NodeJS.ReadWriteStream;
} }
export interface CallbackTask extends BaseTask { export interface CallbackTask extends BaseTask {
(cb?: (err?: any) => void): void; (cb?: (err?: Error) => void): void;
} }
export type Task = PromiseTask | StreamTask | CallbackTask; export type Task = PromiseTask | StreamTask | CallbackTask;

View File

@@ -5,7 +5,9 @@
import { existsSync } from 'fs'; import { existsSync } from 'fs';
// Complete list of directories where npm should be executed to install node modules /**
* Complete list of directories where npm should be executed to install node modules
*/
export const dirs = [ export const dirs = [
'', '',
'build', 'build',

View File

@@ -5,9 +5,8 @@
import { execSync } from 'child_process'; import { execSync } from 'child_process';
import { join, resolve } from 'path'; import { join, resolve } from 'path';
import { existsSync, rmSync } from 'fs'; import { existsSync, rmSync } from 'fs';
import { fileURLToPath } from 'url';
const rootPath = resolve(fileURLToPath(import.meta.url), '..', '..', '..'); const rootPath = resolve(import.meta.dirname, '..', '..');
const telemetryDocsPath = join(rootPath, 'vscode-telemetry-docs'); const telemetryDocsPath = join(rootPath, 'vscode-telemetry-docs');
const repoUrl = 'https://github.com/microsoft/vscode-telemetry-docs'; const repoUrl = 'https://github.com/microsoft/vscode-telemetry-docs';

View File

@@ -6,7 +6,6 @@
import { spawn as _spawn } from 'child_process'; import { spawn as _spawn } from 'child_process';
import { readdirSync, readFileSync } from 'fs'; import { readdirSync, readFileSync } from 'fs';
import { join } from 'path'; import { join } from 'path';
import url from 'url';
async function spawn(cmd: string, args: string[], opts?: Parameters<typeof _spawn>[2]) { async function spawn(cmd: string, args: string[], opts?: Parameters<typeof _spawn>[2]) {
return new Promise<void>((c, e) => { return new Promise<void>((c, e) => {
@@ -40,9 +39,11 @@ async function main() {
} }
} }
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) { if (import.meta.main) {
main().catch(err => { try {
await main();
} catch (err) {
console.error(err); console.error(err);
process.exit(1); process.exit(1);
}); }
} }

View File

@@ -5,9 +5,8 @@
import { execSync } from 'child_process'; import { execSync } from 'child_process';
import { join, resolve } from 'path'; import { join, resolve } from 'path';
import { readFileSync, writeFileSync } from 'fs'; import { readFileSync, writeFileSync } from 'fs';
import { fileURLToPath } from 'url';
const rootPath = resolve(fileURLToPath(import.meta.url), '..', '..', '..', '..'); const rootPath = resolve(import.meta.dirname, '..', '..', '..');
const vscodePath = join(rootPath, 'vscode'); const vscodePath = join(rootPath, 'vscode');
const distroPath = join(rootPath, 'vscode-distro'); const distroPath = join(rootPath, 'vscode-distro');
const commit = execSync('git rev-parse HEAD', { cwd: distroPath, encoding: 'utf8' }).trim(); const commit = execSync('git rev-parse HEAD', { cwd: distroPath, encoding: 'utf8' }).trim();

View File

@@ -9,14 +9,7 @@
"erasableSyntaxOnly": true, "erasableSyntaxOnly": true,
"verbatimModuleSyntax": true, "verbatimModuleSyntax": true,
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"preserveConstEnums": true,
"sourceMap": true,
"resolveJsonModule": true, "resolveJsonModule": true,
// enable JavaScript type checking for the language service
// use the tsconfig.build.json for compiling which disable JavaScript
// type checking so that JavaScript file are not transpiled
"allowJs": true,
"checkJs": false,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"exactOptionalPropertyTypes": false, "exactOptionalPropertyTypes": false,