Don't use gulp anymore

This commit is contained in:
Alex Dima 2018-03-09 12:45:16 +01:00
parent 09e0f8b047
commit e5d3880ac4
9 changed files with 148 additions and 11543 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
/node_modules/
/out/
/release/

View file

@ -1,5 +1,4 @@
/.vscode/
/out/
/scripts/
/src/
/gulpfile.js

View file

@ -3,7 +3,6 @@
"files.trimTrailingWhitespace": true,
"search.exclude": {
"**/node_modules": true,
"**/release": true,
"**/out": true
"**/release": true
}
}

View file

@ -1,120 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var gulp = require('gulp');
var tsb = require('gulp-tsb');
var assign = require('object-assign');
var fs = require('fs');
var path = require('path');
var merge = require('merge-stream');
var rjs = require('gulp-requirejs');
var uglify = require('gulp-uglify');
var rimraf = require('rimraf');
var es = require('event-stream');
var TYPESCRIPT_LIB_SOURCE = path.join(__dirname, 'node_modules', 'typescript', 'lib');
var TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, 'src', 'lib');
gulp.task('clean-release', function(cb) { rimraf('release/min', { maxBusyTries: 1 }, cb); });
gulp.task('release', ['clean-release'], function() {
var sha1 = getGitVersion(__dirname);
var semver = require('./package.json').version;
var headerVersion = semver + '(' + sha1 + ')';
var BUNDLED_FILE_HEADER = [
'/*!-----------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * monaco-typescript version: ' + headerVersion,
' * Released under the MIT license',
' * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md',
' *-----------------------------------------------------------------------------*/',
''
].join('\n');
function bundleOne(moduleId, exclude) {
return rjs({
baseUrl: '/release/dev/',
name: 'vs/language/typescript/' + moduleId,
out: moduleId + '.js',
exclude: exclude,
paths: {
'vs/language/typescript': __dirname + '/release/dev/'
}
})
}
return merge(
merge(
bundleOne('monaco.contribution'),
bundleOne('lib/typescriptServices'),
bundleOne('mode', ['vs/language/typescript/lib/typescriptServices']),
bundleOne('worker', ['vs/language/typescript/lib/typescriptServices'])
)
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(es.through(function(data) {
data.contents = new Buffer(
BUNDLED_FILE_HEADER
+ data.contents.toString()
);
this.emit('data', data);
}))
.pipe(gulp.dest('./release/min/')),
gulp.src('src/monaco.d.ts').pipe(gulp.dest('./release/')),
);
});
function getGitVersion(repo) {
var git = path.join(repo, '.git');
var headPath = path.join(git, 'HEAD');
var head;
try {
head = fs.readFileSync(headPath, 'utf8').trim();
} catch (e) {
return void 0;
}
if (/^[0-9a-f]{40}$/i.test(head)) {
return head;
}
var refMatch = /^ref: (.*)$/.exec(head);
if (!refMatch) {
return void 0;
}
var ref = refMatch[1];
var refPath = path.join(git, ref);
try {
return fs.readFileSync(refPath, 'utf8').trim();
} catch (e) {
// noop
}
var packedRefsPath = path.join(git, 'packed-refs');
var refsRaw;
try {
refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
} catch (e) {
return void 0;
}
var refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
var refsMatch;
var refs = {};
while (refsMatch = refsRegex.exec(refsRaw)) {
refs[refsMatch[2]] = refsMatch[1];
}
return refs[ref];
}

11438
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@
"compile-esm": "node ./scripts/copy ./src/lib/typescriptServices.js ./release/esm/lib/typescriptServices.js && tsc -p ./src/tsconfig.esm.json",
"compile": "node ./scripts/rmdir ./release && npm run compile-amd && npm run compile-esm",
"watch": "tsc -p ./src --watch",
"prepublish": "npm run compile && gulp release",
"prepublish": "npm run compile && node ./scripts/bundle && node ./scripts/copy ./src/monaco.d.ts ./release/monaco.d.ts",
"import-typescript": "node ./scripts/importTypescript"
},
"author": "Microsoft Corporation",
@ -21,21 +21,10 @@
"url": "https://github.com/Microsoft/monaco-typescript/issues"
},
"devDependencies": {
"event-stream": "^3.3.2",
"gulp": "^3.9.1",
"gulp-requirejs": "^0.4.0",
"gulp-tsb": "^2.0.0",
"gulp-uglify": "^1.5.3",
"merge-stream": "^1.0.0",
"mocha": "^2.5.3",
"monaco-editor-core": "^0.10.0",
"object-assign": "^4.1.0",
"rimraf": "^2.5.2",
"monaco-editor-core": "0.11.1",
"requirejs": "^2.3.5",
"typescript": "2.7.2",
"webpack": "^4.1.1",
"webpack-cli": "^2.0.10"
},
"dependencies": {
"webpack-bundle-analyzer": "^2.11.1"
"uglify-js": "^3.3.13"
}
}

51
scripts/bundle.js Normal file
View file

@ -0,0 +1,51 @@
const requirejs = require('requirejs');
const path = require('path');
const fs = require('fs');
const UglifyJS = require("uglify-js");
const git = require('./git');
const REPO_ROOT = path.resolve(__dirname, '..');
const sha1 = git.getGitVersion(REPO_ROOT);
const semver = require('../package.json').version;
const headerVersion = semver + '(' + sha1 + ')';
const BUNDLED_FILE_HEADER = [
'/*!-----------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * monaco-typescript version: ' + headerVersion,
' * Released under the MIT license',
' * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md',
' *-----------------------------------------------------------------------------*/',
''
].join('\n');
bundleOne('monaco.contribution');
bundleOne('lib/typescriptServices');
bundleOne('mode', ['vs/language/typescript/lib/typescriptServices']);
bundleOne('worker', ['vs/language/typescript/lib/typescriptServices']);
function bundleOne(moduleId, exclude) {
requirejs.optimize({
baseUrl: 'release/dev/',
name: 'vs/language/typescript/' + moduleId,
out: 'release/min/' + moduleId + '.js',
exclude: exclude,
paths: {
'vs/language/typescript': REPO_ROOT + '/release/dev'
},
optimize: 'none'
}, function(buildResponse) {
const filePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
const fileContents = fs.readFileSync(filePath).toString();
console.log();
console.log(`Minifying ${filePath}...`);
const result = UglifyJS.minify(fileContents, {
output: {
comments: 'some'
}
});
console.log(`Done.`);
fs.writeFileSync(filePath, BUNDLED_FILE_HEADER + result.code);
})
}

52
scripts/git.js Normal file
View file

@ -0,0 +1,52 @@
const path = require('path');
const fs = require('fs');
exports.getGitVersion = function(repo) {
var git = path.join(repo, '.git');
var headPath = path.join(git, 'HEAD');
var head;
try {
head = fs.readFileSync(headPath, 'utf8').trim();
} catch (e) {
return void 0;
}
if (/^[0-9a-f]{40}$/i.test(head)) {
return head;
}
var refMatch = /^ref: (.*)$/.exec(head);
if (!refMatch) {
return void 0;
}
var ref = refMatch[1];
var refPath = path.join(git, ref);
try {
return fs.readFileSync(refPath, 'utf8').trim();
} catch (e) {
// noop
}
var packedRefsPath = path.join(git, 'packed-refs');
var refsRaw;
try {
refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
} catch (e) {
return void 0;
}
var refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
var refsMatch;
var refs = {};
while (refsMatch = refsRegex.exec(refsRaw)) {
refs[refsMatch[2]] = refsMatch[1];
}
return refs[ref];
};

View file

@ -329,7 +329,11 @@ export class QuickInfoAdapter extends Adapter implements monaco.languages.HoverP
let contents = ts.displayPartsToString(info.displayParts);
return {
range: this._textSpanToRange(resource, info.textSpan),
contents: [ contents, documentation + (tags ? '\n\n' + tags : '') ]
contents: [{
value: contents
}, {
value: documentation + (tags ? '\n\n' + tags : '')
}]
};
}));
}