Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert gulpfile to ts #7

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 41 additions & 42 deletions gulpfile.js → gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.*');
Expand Down Expand Up @@ -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());
Expand All @@ -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) {
Expand All @@ -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());
}
Expand All @@ -119,21 +118,21 @@ 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', () => {
del.sync('*.vsix');
});

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);
Expand All @@ -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
Expand All @@ -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);
});
};
Expand All @@ -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
}))
}));
});