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

Fix offline packaging using event stream #2138

Merged
merged 25 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ script:
- npm run cov:instrument
- npm test --silent
- npm run cov:report
- npm run test:release
- npm run test:artifacts
- 'if [[ "$TRAVIS_TAG" != "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]; then npm run test:release; fi'

after_failure:
- ./.travis/printLogs.sh
Expand Down
106 changes: 66 additions & 40 deletions gulpfile.js → gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@

'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');
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;
Expand Down Expand Up @@ -51,15 +54,18 @@ gulp.task('updatePackageDependencies', () => {
// Install Tasks
function install(platformInfo, packageJSON) {
const packageManager = new PackageManager(platformInfo, packageJSON);
let eventStream = new EventStream();
const logger = new Logger(message => process.stdout.write(message));
const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'), logger);
let stdoutObserver = new CsharpLoggerObserver(logger);
eventStream.subscribe(stdoutObserver.post);
const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'));

return packageManager.DownloadPackages(logger)
return packageManager.DownloadPackages(eventStream, undefined, undefined, undefined)
.then(() => {
return packageManager.InstallPackages(logger);
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 @@ -76,66 +82,86 @@ gulp.task('install', ['clean'], () => {
});

/// Packaging (VSIX) Tasks
function doPackageSync(packageName) {
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) {
vsceArgs.push('-o');
vsceArgs.push(packageName);
if (outputFolder) {
//if we have specified an output folder then put the files in that output folder
vsceArgs.push(path.join(outputFolder, packageName));
}
else {
vsceArgs.push(packageName);
}
}

var proc = child_process.spawnSync('node', vsceArgs);
let proc = child_process.spawnSync('node', vsceArgs);
if (proc.error) {
console.error(proc.error.toString());
}
}

function doOfflinePackage(platformInfo, packageName, packageJSON) {
function doOfflinePackage(platformInfo, packageName, packageJSON, outputFolder) {
if (process.platform === 'win32') {
throw new Error('Do not build offline packages on windows. Runtime executables will not be marked executable in *nix packages.');
}

cleanSync(false);
return install(platformInfo, packageJSON)
.then(() => {
doPackageSync(packageName + '-' + platformInfo.platform + '-' + platformInfo.architecture + '.vsix');
doPackageSync(packageName + '-' + platformInfo.platform + '-' + platformInfo.architecture + '.vsix', 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', ['clean'], () => {
gulp.task('package:offline', () => {
util.setExtensionPath(__dirname);

var packageJSON = getPackageJSON();
var name = packageJSON.name;
var version = packageJSON.version;
var packageName = name + '.' + version;
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);
}
else {
cleanSync(true);
}

let outputFolder;
if (argv['o']) {
outputFolder = argv['o'];
}

var packages = [];
const packageJSON = getPackageJSON();
const name = packageJSON.name;
const version = packageJSON.version;
const packageName = name + '.' + version;

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
.then(() => {
return doOfflinePackage(platformInfo, packageName, packageJSON);
return doOfflinePackage(platformInfo, packageName, packageJSON, outputFolder);
});
});

Expand All @@ -151,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 @@ -164,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
}))
}));
});
Loading