From 9e1b35badbdf033b0bdfe85a7fc89008978c8ef8 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 19 Oct 2016 18:56:20 +0200 Subject: [PATCH] Add monaco-editor-setup script --- gulpfile.js | 27 ++++++++--------- package.json | 3 +- scripts/monaco-editor-setup.js | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 scripts/monaco-editor-setup.js diff --git a/gulpfile.js b/gulpfile.js index 7124c17e6c94e..0f0ed8b046c8b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,6 +9,14 @@ require('events').EventEmitter.defaultMaxListeners = 100; const gulp = require('gulp'); +// Record all defined tasks to determine later in this file (at the bottom) +// if further gulpfiles need to be included or not +var ALL_KNOWN_TASKS = [], originalGulpTask = gulp.task; +gulp.task = function() { + ALL_KNOWN_TASKS.push(arguments[0]); + return originalGulpTask.apply(gulp, Array.prototype.slice.call(arguments, 0)); +}; + const json = require('gulp-json-editor'); const buffer = require('gulp-buffer'); const tsb = require('gulp-tsb'); @@ -258,22 +266,13 @@ gulp.task('mixin', function () { .pipe(gulp.dest('.')); }); -var ALL_EDITOR_TASKS = [ - 'clean-optimized-editor', - 'optimize-editor', - 'clean-minified-editor', - 'minify-editor', - 'clean-editor-distro', - 'editor-distro', - 'analyze-editor-distro' -]; -var runningEditorTasks = process.argv.slice(2).every(function(arg) { - return (ALL_EDITOR_TASKS.indexOf(arg) !== -1); +require(`./build/gulpfile.editor`); + +var runningKnownTasks = process.argv.slice(2).every(function(arg) { + return (ALL_KNOWN_TASKS.indexOf(arg) !== -1); }); -if (runningEditorTasks) { - require(`./build/gulpfile.editor`); -} else { +if (!runningKnownTasks) { // Load all the gulpfiles only if running tasks other than the editor tasks const build = path.join(__dirname, 'build'); glob.sync('gulpfile.*.js', { cwd: build }) diff --git a/package.json b/package.json index 09dfe47d87597..734239cca71d6 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "test": "mocha", "preinstall": "node build/npm/preinstall.js", "postinstall": "node build/npm/postinstall.js", - "watch": "gulp watch" + "watch": "gulp watch", + "monaco-editor-setup": "node scripts/monaco-editor-setup.js" }, "dependencies": { "applicationinsights": "0.15.6", diff --git a/scripts/monaco-editor-setup.js b/scripts/monaco-editor-setup.js new file mode 100644 index 0000000000000..37b3585c7ec2a --- /dev/null +++ b/scripts/monaco-editor-setup.js @@ -0,0 +1,55 @@ + +var fs = require('fs'); +var cp = require('child_process'); +var path = require('path'); + +var keep = [ + 'azure-storage', + 'clone', + 'debounce', + 'event-stream', + 'glob', + 'gulp-azure-storage', + 'gulp-bom', + 'gulp-buffer', + 'gulp-concat', + 'gulp-cssnano', + 'gulp-filter', + 'gulp-flatmap', + 'gulp-json-editor', + 'gulp-mocha', + 'gulp-remote-src', + 'gulp-rename', + 'gulp-sourcemaps', + 'gulp-tsb', + 'gulp-uglify', + 'gulp-util', + 'gulp-vinyl-zip', + 'gulp-watch', + 'gulp', + 'lazy.js', + 'object-assign', + 'pump', + 'rimraf', + 'source-map', + 'typescript', + 'underscore', + 'vinyl', + 'vscode-nls-dev', +]; + +var packageJSON = require('../package.json'); +var modules = keep.map(function(module) { + var version = packageJSON.devDependencies[module]; + if (version) { + return module + '@' + version.replace(/^\^/, ''); + } else { + return module; + } +}); + +var cmd = `npm install ${modules.join(' ')}`; +console.log(cmd); +cp.execSync(cmd, { + cwd: path.join(__dirname, '..') +});