Skip to content

Commit

Permalink
Improve editor-distro gulp task
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed May 31, 2016
1 parent 561cd05 commit 7ec0f25
Show file tree
Hide file tree
Showing 11 changed files with 507 additions and 334 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ out/
out-build/
out-editor/
out-editor-min/
out-editor-ossfree/
out-editor-ossfree-min/
out-monaco-editor-core/
out-vscode/
out-vscode-min/
build/node_modules
4 changes: 3 additions & 1 deletion build/gulpfile.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ exports.optimizeTask = function(opts) {
addComment: true,
includeContent: true
}))
.pipe(i18n.processNlsFiles())
.pipe(i18n.processNlsFiles({
fileHeader: bundledFileHeader
}))
.pipe(gulp.dest(out));
};
};
Expand Down
66 changes: 63 additions & 3 deletions build/gulpfile.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ var _ = require('underscore');
var buildfile = require('../src/buildfile');
var util = require('./lib/util');
var common = require('./gulpfile.common');
var es = require('event-stream');

var root = path.dirname(__dirname);
var headerVersion = process.env['BUILD_SOURCEVERSION'] || util.getVersion(root);
var sha1 = util.getVersion(root);
var semver = require('./monaco/package.json').version;
var headerVersion = semver + '(' + sha1 + ')';

// Build

Expand Down Expand Up @@ -63,7 +66,7 @@ function editorLoaderConfig(removeAllOSS) {
}

gulp.task('clean-optimized-editor', util.rimraf('out-editor'));
gulp.task('optimize-editor', ['clean-optimized-editor', 'compile-build'], common.optimizeTask({
gulp.task('optimize-editor', ['clean-optimized-editor'/*, 'compile-build'*/], common.optimizeTask({
entryPoints: editorEntryPoints,
otherSources: editorOtherSources,
resources: editorResources,
Expand All @@ -74,4 +77,61 @@ gulp.task('optimize-editor', ['clean-optimized-editor', 'compile-build'], common

gulp.task('clean-minified-editor', util.rimraf('out-editor-min'));
gulp.task('minify-editor', ['clean-minified-editor', 'optimize-editor'], common.minifyTask('out-editor', true));
gulp.task('editor-distro', ['minify-editor', 'optimize-editor']);

gulp.task('clean-editor-distro', util.rimraf('out-monaco-editor-core'));
gulp.task('editor-distro', ['clean-editor-distro'/*, 'minify-editor', 'optimize-editor'*/], function() {
return es.merge(
// other assets
es.merge(
gulp.src('build/monaco/package.json'),
gulp.src('build/monaco/LICENSE'),
gulp.src('build/monaco/ThirdPartyNotices.txt'),
gulp.src('src/vs/monaco.d.ts')
).pipe(gulp.dest('out-monaco-editor-core')),

// dev folder
es.merge(
gulp.src('out-editor/**/*')
).pipe(gulp.dest('out-monaco-editor-core/dev')),

// min folder
es.merge(
gulp.src('out-editor-min/**/*')
).pipe(filterStream(function(path) {
// no map files
return !/\.js\.map$|nls\.metadata\.json/.test(path);
})).pipe(es.through(function(data) {
// tweak the sourceMappingURL
if (!/\.js$/.test(data.path)) {
this.emit('data', data);
return;
}

var relativePathToMap = path.relative(path.join(data.relative), path.join('min-maps', data.relative + '.map'));

var strContents = data.contents.toString();
var newStr = '//# sourceMappingURL=' + relativePathToMap.replace(/\\/g, '/');
strContents = strContents.replace(/\/\/\# sourceMappingURL=[^ ]+$/, newStr);

data.contents = new Buffer(strContents);
this.emit('data', data);
})).pipe(gulp.dest('out-monaco-editor-core/min')),

// min-maps folder
es.merge(
gulp.src('out-editor-min/**/*')
).pipe(filterStream(function(path) {
// no map files
return !/\.js\.map$/.test(path);
})).pipe(gulp.dest('out-monaco-editor-core/min-maps'))
);
});

function filterStream(testFunc) {
return es.through(function(data) {
if (!testFunc(data.relative)) {
return;
}
this.emit('data', data);
});
}
3 changes: 2 additions & 1 deletion build/gulpfile.hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var eolFilter = [
'!**/node_modules/**',
'!**/fixtures/**',
'!**/*.{svg,exe,png,scpt,bat,cmd,cur,ttf,woff,eot}',
'!build/{lib,monaco,tslintRules}/**/*.js'
'!build/{lib,tslintRules}/**/*.js',
'!build/monaco/**/*'
];

var indentationFilter = [
Expand Down
14 changes: 4 additions & 10 deletions build/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ function sortLanguages(directoryNames) {
return a.iso639_2 < b.iso639_2 ? -1 : (a.iso639_2 > b.iso639_2 ? 1 : 0);
});
}
var headerComment = [
'/*---------------------------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * Licensed under the MIT License. See License.txt in the project root for license information.',
' *---------------------------------------------------------------------------------------------*/'
].join('\n');
function stripComments(content) {
/**
* First capturing group matches double quoted string
Expand Down Expand Up @@ -164,7 +158,7 @@ function escapeCharacters(value) {
}
return result.join('');
}
function processCoreBundleFormat(json, emitter) {
function processCoreBundleFormat(fileHeader, json, emitter) {
var keysSection = json.keys;
var messageSection = json.messages;
var bundleSection = json.bundles;
Expand Down Expand Up @@ -236,7 +230,7 @@ function processCoreBundleFormat(json, emitter) {
Object.keys(bundleSection).forEach(function (bundle) {
var modules = bundleSection[bundle];
var contents = [
headerComment,
fileHeader,
("define(\"" + bundle + ".nls." + language.iso639_2 + "\", {")
];
modules.forEach(function (module, index) {
Expand Down Expand Up @@ -273,7 +267,7 @@ function processCoreBundleFormat(json, emitter) {
}
});
}
function processNlsFiles() {
function processNlsFiles(opts) {
return event_stream_1.through(function (file) {
var fileName = path.basename(file.path);
if (fileName === 'nls.metadata.json') {
Expand All @@ -285,7 +279,7 @@ function processNlsFiles() {
this.emit('error', "Failed to read component file: " + file.relative);
}
if (BundledFormat.is(json)) {
processCoreBundleFormat(json, this);
processCoreBundleFormat(opts.fileHeader, json, this);
}
}
this.emit('data', file);
Expand Down
17 changes: 4 additions & 13 deletions build/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ function sortLanguages(directoryNames: string[]): IDirectoryInfo[] {
});
}

const headerComment: string =
[
'/*---------------------------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * Licensed under the MIT License. See License.txt in the project root for license information.',
' *---------------------------------------------------------------------------------------------*/'
].join('\n');


function stripComments(content: string): string {
/**
* First capturing group matches double quoted string
Expand Down Expand Up @@ -189,7 +180,7 @@ function escapeCharacters(value:string):string {
return result.join('');
}

function processCoreBundleFormat(json: BundledFormat, emitter: any) {
function processCoreBundleFormat(fileHeader:string, json: BundledFormat, emitter: any) {
let keysSection = json.keys;
let messageSection = json.messages;
let bundleSection = json.bundles;
Expand Down Expand Up @@ -262,7 +253,7 @@ function processCoreBundleFormat(json: BundledFormat, emitter: any) {
Object.keys(bundleSection).forEach((bundle) => {
let modules = bundleSection[bundle];
let contents: string[] = [
headerComment,
fileHeader,
`define("${bundle}.nls.${language.iso639_2}", {`
];
modules.forEach((module, index) => {
Expand Down Expand Up @@ -299,7 +290,7 @@ function processCoreBundleFormat(json: BundledFormat, emitter: any) {
});
}

export function processNlsFiles(): ThroughStream {
export function processNlsFiles(opts:{fileHeader:string;}): ThroughStream {
return through(function(file: File) {
let fileName = path.basename(file.path);
if (fileName === 'nls.metadata.json') {
Expand All @@ -310,7 +301,7 @@ export function processNlsFiles(): ThroughStream {
this.emit('error', `Failed to read component file: ${file.relative}`)
}
if (BundledFormat.is(json)) {
processCoreBundleFormat(json, this);
processCoreBundleFormat(opts.fileHeader, json, this);
}
}
this.emit('data', file);
Expand Down
21 changes: 21 additions & 0 deletions build/monaco/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
103 changes: 103 additions & 0 deletions build/monaco/ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
Do Not Translate or Localize

This project incorporates components from the projects listed below. The original copyright notices and the licenses
under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted
herein, whether by implication, estoppel or otherwise.

1. HTML 5.1 W3C Working Draft version 08 October 2015 (http://www.w3.org/TR/2015/WD-html51-20151008/)
2. js-beautify version 1.5.10 (https://github.com/beautify-web/js-beautify)
3. string_scorer version 0.1.20 (https://github.com/joshaven/string_score)
4. vscode-swift version 0.0.1 (https://github.com/owensd/vscode-swift)


%% HTML 5.1 W3C Working Draft NOTICES AND INFORMATION BEGIN HERE
=========================================
Copyright © 2015 W3C® (MIT, ERCIM, Keio, Beihang). This software or document includes material copied
from or derived from HTML 5.1 W3C Working Draft (http://www.w3.org/TR/2015/WD-html51-20151008/.)

THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF
THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY
PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE
DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.

The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to this document or its contents
without specific, written prior permission. Title to copyright in this document will at all times remain with copyright holders.
=========================================
END OF HTML 5.1 W3C Working Draft NOTICES AND INFORMATION




%% js-beautify NOTICES AND INFORMATION BEGIN HERE
=========================================
The MIT License (MIT)

Copyright (c) 2007-2013 Einar Lielmanis and contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=========================================
END OF js-beautify NOTICES AND INFORMATION




%% string_scorer NOTICES AND INFORMATION BEGIN HERE
=========================================
This software is released under the MIT license:

Copyright (c) Joshaven Potter

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=========================================
END OF string_scorer NOTICES AND INFORMATION




%% vscode-swift NOTICES AND INFORMATION BEGIN HERE
=========================================
The MIT License (MIT)

Copyright (c) 2015 David Owens II

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=========================================
END OF vscode-swift NOTICES AND INFORMATION
Loading

0 comments on commit 7ec0f25

Please sign in to comment.