diff --git a/gulpfile.js b/gulpfile.ts similarity index 72% rename from gulpfile.js rename to gulpfile.ts index 75d85fb43..fa6b04e1d 100644 --- a/gulpfile.js +++ b/gulpfile.ts @@ -5,30 +5,29 @@ 'use strict'; -const fs = require('fs'); -const path = require('path'); -const del = require('del'); -const gulp = require('gulp'); -const mocha = require('gulp-mocha'); -const tslint = require('gulp-tslint'); -const vsce = require('vsce'); -const debugUtil = require('./out/src/coreclr-debug/util'); -const packages = require('./out/src/packages'); -const logger = require('./out/src/logger'); -const platform = require('./out/src/platform'); -const util = require('./out/src/common'); -const child_process = require('child_process'); -const optionsSchemaGenerator = require('./out/src/tools/GenerateOptionsSchema'); -const packageDependencyUpdater = require('./out/src/tools/UpdatePackageDependencies'); -const eventStream = require('./out/src/EventStream'); -const csharpLoggerObserver = require('./out/src/observers/CsharpLoggerObserver'); - -const EventStream = eventStream.EventStream; +import * as child_process from 'child_process'; +import * as debugUtil from './src/coreclr-debug/util'; +import * as del from 'del'; +import * as fs from 'fs'; +import * as gulp from 'gulp'; +import * as logger from './src/logger'; +import * as mocha from 'gulp-mocha'; +import * as optionsSchemaGenerator from './src/tools/GenerateOptionsSchema'; +import * as packageDependencyUpdater from './src/tools/UpdatePackageDependencies'; +import * as packages from './src/packages'; +import * as path from 'path'; +import * as platform from './src/platform'; +import * as util from './src/common'; +import * as vsce from 'vsce'; + +import { CsharpLoggerObserver } from './src/observers/CsharpLoggerObserver'; +import { EventStream } from './src/EventStream'; +import tslint from 'gulp-tslint'; + const Logger = logger.Logger; const PackageManager = packages.PackageManager; const LinuxDistribution = platform.LinuxDistribution; const PlatformInformation = platform.PlatformInformation; -const CsharpLoggerObserver = csharpLoggerObserver.CsharpLoggerObserver; function cleanSync(deleteVsix) { del.sync('install.*'); @@ -58,15 +57,15 @@ function install(platformInfo, packageJSON) { let eventStream = new EventStream(); const logger = new Logger(message => process.stdout.write(message)); let stdoutObserver = new CsharpLoggerObserver(logger); - eventStream.subscribe(stdoutObserver.post); - const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'), logger); + eventStream.subscribe(stdoutObserver.post); + const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.')); - return packageManager.DownloadPackages(eventStream) + return packageManager.DownloadPackages(eventStream, undefined, undefined, undefined) .then(() => { - return packageManager.InstallPackages(eventStream); + return packageManager.InstallPackages(eventStream, undefined); }) .then(() => { - return util.touchInstallFile(util.InstallFileType.Lock) + return util.touchInstallFile(util.InstallFileType.Lock); }) .then(() => { return debugUtil.CoreClrDebugUtil.writeEmptyFile(debuggerUtil.installCompleteFilePath()); @@ -85,8 +84,8 @@ gulp.task('install', ['clean'], () => { /// Packaging (VSIX) Tasks function doPackageSync(packageName, outputFolder) { - var vsceArgs = []; - vsceArgs.push(path.join(__dirname, 'node_modules', 'vsce', 'out', 'vsce')) + let vsceArgs = []; + vsceArgs.push(path.join(__dirname, 'node_modules', 'vsce', 'out', 'vsce')); vsceArgs.push('package'); // package command if (packageName !== undefined) { @@ -100,7 +99,7 @@ function doPackageSync(packageName, outputFolder) { } } - var proc = child_process.spawnSync('node', vsceArgs); + let proc = child_process.spawnSync('node', vsceArgs); if (proc.error) { console.error(proc.error.toString()); } @@ -119,7 +118,7 @@ function doOfflinePackage(platformInfo, packageName, packageJSON, outputFolder) } function getPackageJSON() { - return JSON.parse(fs.readFileSync('package.json')); + return JSON.parse(fs.readFileSync('package.json').toString()); } gulp.task('package:clean', () => { @@ -127,13 +126,13 @@ gulp.task('package:clean', () => { }); gulp.task('package:online', ['clean'], () => { - doPackageSync(); + doPackageSync(undefined, undefined); }); gulp.task('package:offline', () => { util.setExtensionPath(__dirname); - var argv = require('minimist')(process.argv.slice(2), { boolean: ['retainVsix'] }); + let argv = require('minimist')(process.argv.slice(2), { boolean: ['retainVsix'] }); if (argv['retainVsix']) { //if user doesnot want to clean up the existing vsix packages cleanSync(false); @@ -142,22 +141,22 @@ gulp.task('package:offline', () => { cleanSync(true); } - var outputFolder; + let outputFolder; if (argv['o']) { outputFolder = argv['o']; } - var packageJSON = getPackageJSON(); - var name = packageJSON.name; - var version = packageJSON.version; - var packageName = name + '.' + version; + const packageJSON = getPackageJSON(); + const name = packageJSON.name; + const version = packageJSON.version; + const packageName = name + '.' + version; - var packages = []; + const packages = []; packages.push(new PlatformInformation('win32', 'x86_64')); packages.push(new PlatformInformation('darwin', 'x86_64')); packages.push(new PlatformInformation('linux', 'x86_64')); - var promise = Promise.resolve(); + let promise = Promise.resolve(); packages.forEach(platformInfo => { promise = promise @@ -178,9 +177,9 @@ const allTypeScript = [ const lintReporter = (output, file, options) => { //emits: src/helloWorld.c:5:3: warning: implicit declaration of function ‘prinft’ - var relativeBase = file.base.substring(file.cwd.length + 1).replace('\\', '/'); + let relativeBase = file.base.substring(file.cwd.length + 1).replace('\\', '/'); output.forEach(e => { - var message = relativeBase + e.name + ':' + (e.startPosition.line + 1) + ':' + (e.startPosition.character + 1) + ': ' + e.failure; + let message = relativeBase + e.name + ':' + (e.startPosition.line + 1) + ':' + (e.startPosition.character + 1) + ': ' + e.failure; console.log('[tslint] ' + message); }); }; @@ -191,8 +190,8 @@ gulp.task('tslint', () => { program: require('tslint').Linter.createProgram("./tsconfig.json"), configuration: "./tslint.json" })) - .pipe(tslint.report(lintReporter, { + .pipe(tslint.report({ summarizeFailureOutput: false, emitError: false - })) + })); });