Merge branch 'ext-compile'

This commit is contained in:
Joao Moreno
2016-03-04 15:54:01 +01:00
25 changed files with 123 additions and 2258 deletions
+84 -130
View File
@@ -18,151 +18,105 @@ var util = require('./lib/util');
var watcher = require('./lib/watch');
var createReporter = require('./lib/reporter');
var glob = require('glob');
var fs = require('fs');
var JSONC = require('json-comments');
var sourcemaps = require('gulp-sourcemaps');
var nlsDev = require('vscode-nls-dev');
var quiet = !!process.env['VSCODE_BUILD_QUIET'];
var extensionsPath = path.join(path.dirname(__dirname), 'extensions');
function getTSConfig(plugin) {
var script = (plugin.desc && plugin.desc.scripts && plugin.desc.scripts['vscode:prepublish']) || '';
var match = /^node \.\.\/\.\.\/node\_modules\/gulp\/bin\/gulp\.js \-\-gulpfile \.\.\/\.\.\/build\/gulpfile\.extensions\.js compile-extension:([^ ]+) ?(.*tsconfig\.json)/.exec(script);
var compilations = glob.sync('**/tsconfig.json', {
cwd: extensionsPath,
ignore: '**/out/**'
});
if (!match) {
return;
}
var pluginRoot = path.join(extensionsPath, plugin.desc.name);
var options = require(path.join(pluginRoot, match[2])).compilerOptions;
var tasks = compilations.map(function(tsconfigFile) {
var absolutePath = path.join(extensionsPath, tsconfigFile);
var options = require(absolutePath).compilerOptions;
options.verbose = !quiet;
return options;
}
function readAllPlugins() {
var PLUGINS_FOLDER = path.join(extensionsPath);
var globRelativeDirname = path.dirname(tsconfigFile);
var name = globRelativeDirname.replace(/\//g, '-');
var clean = 'clean-extension:' + name;
var compile = 'compile-extension:' + name;
var compileBuild = 'compile-build-extension:' + name;
var watch = 'watch-extension:' + name;
var extensions = glob.sync('*/package.json', {
cwd: PLUGINS_FOLDER
});
var pipeline = (function () {
var reporter = quiet ? null : createReporter();
var compilation = tsb.create(options, null, null, quiet ? null : function (err) { reporter(err.toString()); });
var result = [];
extensions.forEach(function (relativeJSONPath) {
var relativePath = path.dirname(relativeJSONPath);
var fullJSONPath = path.join(PLUGINS_FOLDER, relativeJSONPath);
var contents = fs.readFileSync(fullJSONPath).toString();
var desc = JSONC.parse(contents);
result.push({
relativePath: relativePath,
desc: desc
});
});
return result;
}
var tasks = readAllPlugins()
.map(function (plugin) {
var options = getTSConfig(plugin);
if (!options) {
return null;
}
var name = plugin.desc.name;
var pluginRoot = path.join(extensionsPath, name);
var clean = 'clean-extension:' + name;
var compile = 'compile-extension:' + name;
var compileBuild = 'compile-build-extension:' + name;
var watch = 'watch-extension:' + name;
var sources = 'extensions/' + name + '/src/**';
var deps = [
'src/vs/vscode.d.ts',
'src/typings/mocha.d.ts',
'extensions/declares.d.ts',
'extensions/node.d.ts',
'extensions/lib.core.d.ts'
];
var pipeline = (function () {
var reporter = quiet ? null : createReporter();
var compilation = tsb.create(options, null, null, quiet ? null : function (err) { reporter(err.toString()); });
return function (build) {
var input = es.through();
var tsFilter = filter(['**/*.ts', '!**/lib/lib*.d.ts'], { restore: true });
var output;
if (build) {
output = input
.pipe(tsFilter)
.pipe(sourcemaps.init())
.pipe(compilation())
.pipe(nlsDev.rewriteLocalizeCalls())
.pipe(sourcemaps.write('.', {
addComment: false,
includeContent: false
}))
.pipe(tsFilter.restore)
.pipe(quiet ? es.through() : reporter.end());
} else {
output = input
.pipe(tsFilter)
return function (build) {
var input = es.through();
var tsFilter = filter(['**/*.ts', '!**/lib/lib*.d.ts', '!**/node_modules/**'], { restore: true });
var output;
if (build) {
output = input
.pipe(tsFilter)
.pipe(sourcemaps.init())
.pipe(compilation())
.pipe(tsFilter.restore)
.pipe(quiet ? es.through() : reporter.end());
}
.pipe(nlsDev.rewriteLocalizeCalls())
.pipe(sourcemaps.write('.', {
addComment: false,
includeContent: false
}))
.pipe(tsFilter.restore)
.pipe(quiet ? es.through() : reporter.end());
return es.duplex(input, output);
};
})();
} else {
output = input
.pipe(tsFilter)
.pipe(compilation())
.pipe(tsFilter.restore)
.pipe(quiet ? es.through() : reporter.end());
}
var sourcesRoot = path.join(pluginRoot, 'src');
var sourcesOpts = { cwd: path.dirname(__dirname), base: sourcesRoot };
var depsOpts = { cwd: path.dirname(__dirname) };
gulp.task(clean, function (cb) {
rimraf(path.join(pluginRoot, 'out'), cb);
});
gulp.task(compile, [clean], function () {
var src = es.merge(gulp.src(sources, sourcesOpts), gulp.src(deps, depsOpts));
return src
.pipe(pipeline(false))
.pipe(gulp.dest('extensions/' + name + '/out'));
});
gulp.task(compileBuild, [clean], function () {
var src = es.merge(gulp.src(sources, sourcesOpts), gulp.src(deps, depsOpts));
return src
.pipe(pipeline(true))
.pipe(gulp.dest('extensions/' + name + '/out'));
});
gulp.task(watch, [clean], function () {
var src = es.merge(gulp.src(sources, sourcesOpts), gulp.src(deps, depsOpts));
var watchSrc = es.merge(watcher(sources, sourcesOpts), watcher(deps, depsOpts));
return watchSrc
.pipe(util.incremental(pipeline, src))
.pipe(gulp.dest('extensions/' + name + '/out'));
});
return {
clean: clean,
compile: compile,
compileBuild: compileBuild,
watch: watch
return es.duplex(input, output);
};
})
.filter(function(task) { return !!task; });
})();
var root = path.join('extensions', globRelativeDirname);
var srcBase = path.join(root, 'src');
var src = path.join(srcBase, '**');
var out = path.join(root, 'out');
var srcOpts = { cwd: path.dirname(__dirname), base: srcBase };
gulp.task(clean, function (cb) {
rimraf(out, cb);
});
gulp.task(compile, [clean], function () {
var input = gulp.src(src, srcOpts);
return input
.pipe(pipeline(false))
.pipe(gulp.dest(out));
});
gulp.task(compileBuild, [clean], function () {
var input = gulp.src(src, srcOpts);
return input
.pipe(pipeline(true))
.pipe(gulp.dest(out));
});
gulp.task(watch, [clean], function () {
var input = gulp.src(src, srcOpts);
var watchInput = watcher(src, srcOpts);
return watchInput
.pipe(util.incremental(pipeline, input))
.pipe(gulp.dest(out));
});
return {
clean: clean,
compile: compile,
compileBuild: compileBuild,
watch: watch
};
});
gulp.task('clean-extensions', tasks.map(function (t) { return t.clean; }));
gulp.task('compile-extensions', tasks.map(function (t) { return t.compile; }));
@@ -3,8 +3,5 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../extensions/node.d.ts'/>
/// <reference path='../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../node_modules/vscode-languageclient/lib/main.d.ts'/>
/// <reference path='../../../../extensions/declares.d.ts'/>
@@ -4,7 +4,7 @@
"target": "es5",
"module": "commonjs",
"sourceMap": false,
"outDir": "../out"
"outDir": "out"
},
"exclude": [
"node_modules"
+2 -2
View File
@@ -10,8 +10,8 @@
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false,
"sourceMaps": false,
"outDir": "${workspaceRoot}/out",
"sourceMaps": true,
"outDir": "${workspaceRoot}/client/out",
"preLaunchTask": "npm"
}
]
+1 -1
View File
@@ -20,7 +20,7 @@
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "vscode:prepublish"],
"args": ["run", "compile"],
// The tsc compiler is started in watching mode
"isWatching": true,
+11
View File
@@ -0,0 +1,11 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../../extensions/node.d.ts'/>
/// <reference path='../../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../../../../extensions/declares.d.ts'/>
/// <reference path='../../../node_modules/vscode-languageclient/lib/main.d.ts'/>
@@ -3,8 +3,9 @@
"noLib": true,
"target": "es5",
"module": "commonjs",
"sourceMap": false,
"outDir": "../out"
"sourceMap": true,
"sourceRoot": "../src",
"outDir": "./out"
},
"exclude": [
"node_modules"
+2 -3
View File
@@ -8,10 +8,9 @@
"activationEvents": [
"onLanguage:json"
],
"main": "./out/jsonMain",
"main": "./client/out/jsonMain",
"scripts": {
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:json ./src/tsconfig.json",
"postinstall": "cd server && npm install && npm run compile && cd .."
"compile": "gulp compile-extension:json-client && gulp compile-extension:json-server"
},
"contributes": {
"languages": [
+2 -3
View File
@@ -18,8 +18,7 @@
"typescript": "^1.6.2"
},
"scripts": {
"compile": "tsc -p .",
"watch": "tsc --watch -p .",
"postinstall": "tsc -p ."
"compile": "gulp compile-extension:json-server",
"watch": "gulp watch-extension:json-server"
}
}
+8
View File
@@ -0,0 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../../extensions/node.d.ts'/>
/// <reference path='../../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../../../../extensions/declares.d.ts'/>
+2 -1
View File
@@ -1,9 +1,10 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"sourceRoot": "../src",
"outDir": "./out"
},
"exclude": [
-13
View File
@@ -1,13 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare function run(): void;
declare function suite(name: string, fn: (err?)=>void);
declare function test(name: string, fn: (done?: (err?)=>void)=>void);
declare function suiteSetup(fn: (done?: (err?)=>void)=>void);
declare function suiteTeardown(fn: (done?: (err?)=>void)=>void);
declare function setup(fn: (done?: (err?)=>void)=>void);
declare function teardown(fn: (done?: (err?)=>void)=>void);
File diff suppressed because it is too large Load Diff
-16
View File
@@ -1,16 +0,0 @@
{
"compilerOptions": {
"module": "amd",
"noImplicitAny": true,
"removeComments": false,
"preserveConstEnums": true,
"target": "ES5",
"sourceMap": false
},
"exclude": [
"typescript/src/lib",
"typescript/out/lib",
"jshint",
"vscode-api-tests/node_modules"
]
}
+1
View File
@@ -5,5 +5,6 @@
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../extensions/declares.d.ts'/>
/// <reference path='../../../../extensions/node.d.ts'/>
/// <reference path='../../../../extensions/lib.core.d.ts'/>
+1 -1
View File
@@ -12,7 +12,7 @@ export interface ITask<T> {
export class Delayer<T> {
public defaultDelay: number;
private timeout: NodeJS.Timer;
private timeout: any; // Timer
private completionPromise: Promise<T>;
private onSuccess: (value?: T | Thenable<T>) => void;
private task: ITask<T>;
@@ -170,7 +170,10 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
// ' ' + stream.listeners('error').length
// );
}, 1000);
timer.unref();
if ((<any>timer).unref) {
(<any>timer).unref();
}
});
-1
View File
@@ -70,7 +70,6 @@
"innosetup-compiler": "^5.5.60",
"istanbul": "^0.3.17",
"jsdom-no-contextify": "^3.1.0",
"json-comments": "^0.2.1",
"lazy.js": "^0.4.2",
"mime": "1.2.11",
"minimatch": "^2.0.10",