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 13 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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ script:
- npm run cov:instrument
- npm test --silent
- npm run cov:report
- npm run test:release
- npm run test:artifacts
- if [ $TRAVIS_PULL_REQUEST_BRANCH == "" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other thing: can you also check that travis tag != master? That way we'll only run this when someone starts a release (the release process on GitHub creates a new branch).

npm run test:release
fi

after_failure:
- ./.travis/printLogs.sh
Expand Down
45 changes: 36 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ 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;
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 All @@ -51,12 +55,15 @@ 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));
let stdoutObserver = new CsharpLoggerObserver(logger);
eventStream.subscribe(stdoutObserver.post);
const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'), logger);

return packageManager.DownloadPackages(logger)
return packageManager.DownloadPackages(eventStream)
.then(() => {
return packageManager.InstallPackages(logger);
return packageManager.InstallPackages(eventStream);
})
.then(() => {
return util.touchInstallFile(util.InstallFileType.Lock)
Expand All @@ -76,15 +83,21 @@ 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'))
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);
Expand All @@ -93,15 +106,15 @@ function doPackageSync(packageName) {
}
}

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);
});
}

Expand All @@ -117,14 +130,28 @@ gulp.task('package:online', ['clean'], () => {
doPackageSync();
});

gulp.task('package:offline', ['clean'], () => {
gulp.task('package:offline', () => {
util.setExtensionPath(__dirname);

var 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);
}

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

var packageJSON = getPackageJSON();
var name = packageJSON.name;
var version = packageJSON.version;
var packageName = name + '.' + version;

var packages = [];
packages.push(new PlatformInformation('win32', 'x86_64'));
packages.push(new PlatformInformation('darwin', 'x86_64'));
Expand All @@ -135,7 +162,7 @@ gulp.task('package:offline', ['clean'], () => {
packages.forEach(platformInfo => {
promise = promise
.then(() => {
return doOfflinePackage(platformInfo, packageName, packageJSON);
return doOfflinePackage(platformInfo, packageName, packageJSON, outputFolder);
});
});

Expand Down
Loading