@@ -9,21 +9,20 @@ const fs = require('fs');
99const path = require ( 'path' ) ;
1010const del = require ( 'del' ) ;
1111const gulp = require ( 'gulp' ) ;
12- const gulpUtil = require ( 'gulp-util' ) ;
1312const mocha = require ( 'gulp-mocha' ) ;
1413const tslint = require ( 'gulp-tslint' ) ;
1514const vsce = require ( 'vsce' ) ;
1615const debugUtil = require ( './out/src/coreclr-debug/util' ) ;
1716const debugInstall = require ( './out/src/coreclr-debug/install' ) ;
1817const fs_extra = require ( 'fs-extra-promise' ) ;
19- const omnisharp = require ( './out/src/omnisharp/omnisharp' ) ;
20- const download = require ( './out/src/omnisharp/download' ) ;
21- const logger = require ( './out/src/omnisharp/logger' ) ;
18+ const packages = require ( './out/src/packages' ) ;
19+ const logger = require ( './out/src/logger' ) ;
2220const platform = require ( './out/src/platform' ) ;
21+ const util = require ( './out/src/common' ) ;
2322const child_process = require ( 'child_process' ) ;
2423
25- const Flavor = omnisharp . Flavor ;
26- const CoreClrFlavor = platform . CoreClrFlavor ;
24+ const Logger = logger . Logger ;
25+ const PackageManager = packages . PackageManager ;
2726const PlatformInformation = platform . PlatformInformation ;
2827
2928/// used in offline packaging run so does not clean .vsix
@@ -37,31 +36,29 @@ gulp.task('clean', ['omnisharp:clean', 'debugger:clean', 'package:clean'], () =>
3736} ) ;
3837
3938/// Omnisharp Tasks
40- function installOmnisharp ( omnisharps ) {
41- const promises = omnisharps . map ( ( omni , index ) => {
42- const log = new logger . Logger ( message => process . stdout . write ( message ) , index . toString ( ) ) ;
39+ function installOmnisharp ( platform , packageJSON ) {
40+ const packageManager = new PackageManager ( platform , packageJSON ) ;
41+ const logger = new Logger ( message => process . stdout . write ( message ) ) ;
4342
44- return download . go ( omni . flavor , omni . coreClrFlavor , log ) ;
45- } ) ;
46-
47- return Promise . all ( promises ) ;
43+ return packageManager . DownloadPackages ( logger )
44+ . then ( ( ) => {
45+ return packageManager . InstallPackages ( logger ) ;
46+ } ) ;
4847}
4948
5049function cleanOmnisharp ( ) {
51- return del ( '.omnisharp ' ) ;
50+ return del ( 'bin ' ) ;
5251}
5352
5453gulp . task ( 'omnisharp:clean' , ( ) => {
5554 return cleanOmnisharp ( ) ;
5655} ) ;
5756
5857gulp . task ( 'omnisharp:install' , [ 'omnisharp:clean' ] , ( ) => {
59- const flavor = gulpUtil . env . flavor || Flavor . CoreCLR ;
60-
61- return PlatformInformation . GetCurrent ( ) . then ( info => {
62- const coreClrFlavor = gulpUtil . env . coreClrFlavor || info . getCoreClrFlavor ( ) ;
63- return installOmnisharp ( [ { flavor, coreClrFlavor } ] ) ;
64- } ) ;
58+ return PlatformInformation . GetCurrent ( )
59+ . then ( platformInfo => {
60+ return installOmnisharp ( platformInfo , getPackageJSON ( ) ) ;
61+ } ) ;
6562} ) ;
6663
6764/// Debugger Tasks
@@ -83,11 +80,13 @@ function cleanDebugger() {
8380}
8481
8582gulp . task ( 'debugger:install' , [ 'debugger:clean' ] , ( ) => {
86- installDebugger ( gulp . env . runtimeId ) . then ( ( ) => {
87- console . log ( 'Installed Succesfully' ) ;
88- } ) . catch ( ( error ) => {
89- console . error ( error ) ;
90- } ) ;
83+ installDebugger ( gulp . env . runtimeId )
84+ . then ( ( ) => {
85+ console . log ( 'Installed Succesfully' ) ;
86+ } )
87+ . catch ( ( error ) => {
88+ console . error ( error ) ;
89+ } ) ;
9190} ) ;
9291
9392gulp . task ( 'debugger:clean' , ( ) => {
@@ -112,14 +111,21 @@ function doPackageSync(packageName) {
112111 }
113112}
114113
115- function doOfflinePackage ( runtimeId , omnisharps , packageName ) {
116- return clean ( ) . then ( ( ) => {
117- return installDebugger ( runtimeId ) ;
118- } ) . then ( ( ) => {
119- return installOmnisharp ( omnisharps ) ;
120- } ) . then ( ( ) => {
121- doPackageSync ( packageName + '-' + runtimeId + '.vsix' ) ;
122- } ) ;
114+ function doOfflinePackage ( runtimeId , platform , packageName , packageJSON ) {
115+ return clean ( )
116+ . then ( ( ) => {
117+ return installDebugger ( runtimeId ) ;
118+ } )
119+ . then ( ( ) => {
120+ return installOmnisharp ( platform , packageJSON ) ;
121+ } )
122+ . then ( ( ) => {
123+ doPackageSync ( packageName + '-' + runtimeId + '.vsix' ) ;
124+ } ) ;
125+ }
126+
127+ function getPackageJSON ( ) {
128+ return JSON . parse ( fs . readFileSync ( 'package.json' ) ) ;
123129}
124130
125131gulp . task ( 'package:clean' , ( ) => {
@@ -131,28 +137,31 @@ gulp.task('package:online', ['clean'], () => {
131137} ) ;
132138
133139gulp . task ( 'package:offline' , [ 'clean' ] , ( ) => {
134- var json = JSON . parse ( fs . readFileSync ( 'package.json' ) ) ;
135- var name = json . name ;
136- var version = json . version ;
140+ util . setExtensionPath ( __dirname ) ;
141+
142+ var packageJSON = getPackageJSON ( ) ;
143+ var name = packageJSON . name ;
144+ var version = packageJSON . version ;
137145 var packageName = name + '.' + version ;
138146
139147 var packages = [ ] ;
140- packages . push ( { rid : 'win7-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . Windows } , { flavor : Flavor . Desktop , coreClrFlavor : CoreClrFlavor . Windows } ] } ) ;
141- packages . push ( { rid : 'osx.10.11-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . OSX } ] } ) ;
142- packages . push ( { rid : 'centos.7-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . CentOS } ] } ) ;
143- packages . push ( { rid : 'debian.8-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . Debian } ] } ) ;
144- packages . push ( { rid : 'fedora.23-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . Fedora } ] } ) ;
145- packages . push ( { rid : 'opensuse.13.2-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . OpenSUSE } ] } ) ;
146- packages . push ( { rid : 'rhel.7.2-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . RHEL } ] } ) ;
147- packages . push ( { rid : 'ubuntu.14.04-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . Ubuntu14 } ] } ) ;
148- packages . push ( { rid : 'ubuntu.16.04-x64' , omnisharps : [ { flavor : Flavor . CoreCLR , coreClrFlavor : CoreClrFlavor . Ubuntu16 } ] } ) ;
148+ packages . push ( { rid : 'win7-x64' , platform : new PlatformInformation ( 'win32' ) } ) ;
149+ packages . push ( { rid : 'osx.10.11-x64' , platform : new PlatformInformation ( 'darwin' , 'x86_64' ) } ) ;
150+ packages . push ( { rid : 'centos.7-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
151+ packages . push ( { rid : 'debian.8-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
152+ packages . push ( { rid : 'fedora.23-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
153+ packages . push ( { rid : 'opensuse.13.2-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
154+ packages . push ( { rid : 'rhel.7.2-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
155+ packages . push ( { rid : 'ubuntu.14.04-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
156+ packages . push ( { rid : 'ubuntu.16.04-x64' , platform : new PlatformInformation ( 'linux' , 'x86_64' ) } ) ;
149157
150158 var promise = Promise . resolve ( ) ;
151159
152160 packages . forEach ( data => {
153- promise = promise . then ( ( ) => {
154- return doOfflinePackage ( data . rid , data . omnisharps , packageName ) ;
155- } )
161+ promise = promise
162+ . then ( ( ) => {
163+ return doOfflinePackage ( data . rid , data . platform , packageName , packageJSON ) ;
164+ } ) ;
156165 } ) ;
157166
158167 return promise ;
0 commit comments