From b4add9fcaacbcb1f91c75e0f1864bc5dab3dd9a5 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 5 Jul 2019 16:11:50 +0200 Subject: [PATCH] remove gulp sequence --- build/gulpfile.extensions.js | 9 +++--- build/lib/extensions.js | 52 ++++++++++-------------------- build/lib/extensions.ts | 62 +++++++++++------------------------- 3 files changed, 40 insertions(+), 83 deletions(-) diff --git a/build/gulpfile.extensions.js b/build/gulpfile.extensions.js index 14e0a99af65..e4f7b58d50a 100644 --- a/build/gulpfile.extensions.js +++ b/build/gulpfile.extensions.js @@ -153,10 +153,11 @@ gulp.task(compileExtensionsBuildLegacyTask); // Azure Pipelines const cleanExtensionsBuildTask = task.define('clean-extensions-build', util.rimraf('.build/extensions')); -const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series(cleanExtensionsBuildTask, () => { - return ext.packageExtensionsStream() - .pipe(gulp.dest('.build')); -})); +const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series( + cleanExtensionsBuildTask, + task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream().pipe(gulp.dest('.build'))), + task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream().pipe(gulp.dest('.build'))), +)); gulp.task(compileExtensionsBuildTask); exports.compileExtensionsBuildTask = compileExtensionsBuildTask; \ No newline at end of file diff --git a/build/lib/extensions.js b/build/lib/extensions.js index 3d062c0d273..e12f8f14568 100644 --- a/build/lib/extensions.js +++ b/build/lib/extensions.js @@ -81,7 +81,7 @@ function fromLocalWebpack(extensionPath) { return data; })) .pipe(packageJsonFilter.restore); - const webpackStreams = webpackConfigLocations.map(webpackConfigPath => () => { + const webpackStreams = webpackConfigLocations.map(webpackConfigPath => { const webpackDone = (err, stats) => { fancyLog(`Bundled extension: ${ansiColors.yellow(path.join(path.basename(extensionPath), path.relative(extensionPath, webpackConfigPath)))}...`); if (err) { @@ -120,7 +120,7 @@ function fromLocalWebpack(extensionPath) { this.emit('data', data); })); }); - es.merge(sequence(webpackStreams), patchFilesStream) + es.merge(...webpackStreams, patchFilesStream) // .pipe(es.through(function (data) { // // debug // console.log('out', data.path, data.contents.length); @@ -186,29 +186,7 @@ const excludedExtensions = [ 'ms-vscode.node-debug2', ]; const builtInExtensions = require('../builtInExtensions.json'); -/** - * We're doing way too much stuff at once, with webpack et al. So much stuff - * that while downloading extensions from the marketplace, node js doesn't get enough - * stack frames to complete the download in under 2 minutes, at which point the - * marketplace server cuts off the http request. So, we sequentialize the extensino tasks. - */ -function sequence(streamProviders) { - const result = es.through(); - function pop() { - if (streamProviders.length === 0) { - result.emit('end'); - } - else { - const fn = streamProviders.shift(); - fn() - .on('end', function () { setTimeout(pop, 0); }) - .pipe(result, { end: false }); - } - } - pop(); - return result; -} -function packageExtensionsStream() { +function packageLocalExtensionsStream() { const localExtensionDescriptions = glob.sync('extensions/*/package.json') .map(manifestPath => { const extensionPath = path.dirname(path.join(root, manifestPath)); @@ -217,18 +195,20 @@ function packageExtensionsStream() { }) .filter(({ name }) => excludedExtensions.indexOf(name) === -1) .filter(({ name }) => builtInExtensions.every(b => b.name !== name)); - const localExtensions = () => sequence([...localExtensionDescriptions.map(extension => () => { - return fromLocal(extension.path) - .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); - })]); - const localExtensionDependencies = () => gulp.src('extensions/node_modules/**', { base: '.' }); - const marketplaceExtensions = () => es.merge(...builtInExtensions - .map(extension => { - return fromMarketplace(extension.name, extension.version, extension.metadata) + return es.merge(gulp.src('extensions/node_modules/**', { base: '.' }), ...localExtensionDescriptions.map(extension => { + return fromLocal(extension.path) .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); - })); - return sequence([localExtensions, localExtensionDependencies, marketplaceExtensions]) + })) .pipe(util2.setExecutableBit(['**/*.sh'])) .pipe(filter(['**', '!**/*.js.map'])); } -exports.packageExtensionsStream = packageExtensionsStream; +exports.packageLocalExtensionsStream = packageLocalExtensionsStream; +function packageMarketplaceExtensionsStream() { + return es.merge(builtInExtensions.map(extension => { + return fromMarketplace(extension.name, extension.version, extension.metadata) + .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); + })) + .pipe(util2.setExecutableBit(['**/*.sh'])) + .pipe(filter(['**', '!**/*.js.map'])); +} +exports.packageMarketplaceExtensionsStream = packageMarketplaceExtensionsStream; diff --git a/build/lib/extensions.ts b/build/lib/extensions.ts index 014946523df..381d56e2abb 100644 --- a/build/lib/extensions.ts +++ b/build/lib/extensions.ts @@ -93,7 +93,7 @@ function fromLocalWebpack(extensionPath: string): Stream { .pipe(packageJsonFilter.restore); - const webpackStreams = webpackConfigLocations.map(webpackConfigPath => () => { + const webpackStreams = webpackConfigLocations.map(webpackConfigPath => { const webpackDone = (err: any, stats: any) => { fancyLog(`Bundled extension: ${ansiColors.yellow(path.join(path.basename(extensionPath), path.relative(extensionPath, webpackConfigPath)))}...`); @@ -140,7 +140,7 @@ function fromLocalWebpack(extensionPath: string): Stream { })); }); - es.merge(sequence(webpackStreams), patchFilesStream) + es.merge(...webpackStreams, patchFilesStream) // .pipe(es.through(function (data) { // // debug // console.log('out', data.path, data.contents.length); @@ -227,31 +227,7 @@ interface IBuiltInExtension { const builtInExtensions: IBuiltInExtension[] = require('../builtInExtensions.json'); -/** - * We're doing way too much stuff at once, with webpack et al. So much stuff - * that while downloading extensions from the marketplace, node js doesn't get enough - * stack frames to complete the download in under 2 minutes, at which point the - * marketplace server cuts off the http request. So, we sequentialize the extensino tasks. - */ -function sequence(streamProviders: { (): Stream }[]): Stream { - const result = es.through(); - - function pop() { - if (streamProviders.length === 0) { - result.emit('end'); - } else { - const fn = streamProviders.shift()!; - fn() - .on('end', function () { setTimeout(pop, 0); }) - .pipe(result, { end: false }); - } - } - - pop(); - return result; -} - -export function packageExtensionsStream(): NodeJS.ReadWriteStream { +export function packageLocalExtensionsStream(): NodeJS.ReadWriteStream { const localExtensionDescriptions = (glob.sync('extensions/*/package.json')) .map(manifestPath => { const extensionPath = path.dirname(path.join(root, manifestPath)); @@ -261,22 +237,22 @@ export function packageExtensionsStream(): NodeJS.ReadWriteStream { .filter(({ name }) => excludedExtensions.indexOf(name) === -1) .filter(({ name }) => builtInExtensions.every(b => b.name !== name)); - const localExtensions = () => sequence([...localExtensionDescriptions.map(extension => () => { - return fromLocal(extension.path) - .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); - })]); - - const localExtensionDependencies = () => gulp.src('extensions/node_modules/**', { base: '.' }); - - const marketplaceExtensions = () => es.merge( - ...builtInExtensions - .map(extension => { - return fromMarketplace(extension.name, extension.version, extension.metadata) - .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); - }) - ); - - return sequence([localExtensions, localExtensionDependencies, marketplaceExtensions]) + return es.merge( + gulp.src('extensions/node_modules/**', { base: '.' }), + ...localExtensionDescriptions.map(extension => { + return fromLocal(extension.path) + .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); + }) + ) + .pipe(util2.setExecutableBit(['**/*.sh'])) + .pipe(filter(['**', '!**/*.js.map'])); +} + +export function packageMarketplaceExtensionsStream(): NodeJS.ReadWriteStream { + return es.merge(builtInExtensions.map(extension => { + return fromMarketplace(extension.name, extension.version, extension.metadata) + .pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`)); + })) .pipe(util2.setExecutableBit(['**/*.sh'])) .pipe(filter(['**', '!**/*.js.map'])); }