Add a compile-dts step to verify that we don't expose platform types.

Alas Grunt or grunt-ts doesn't fail the build if that fails.
This commit is contained in:
Hristo Deshev
2015-10-30 17:02:04 +02:00
parent 70041bd999
commit 10e802d107

View File

@@ -25,7 +25,7 @@ module.exports = function(grunt) {
var contentAsObject = JSON.parse(content); var contentAsObject = JSON.parse(content);
update(contentAsObject); update(contentAsObject);
return JSON.stringify(contentAsObject, null, "\t"); return JSON.stringify(contentAsObject, null, "\t");
} };
var updateModulesPackageDef = function(content, srcPath) { var updateModulesPackageDef = function(content, srcPath) {
return updatePackageDef(content, function(contentAsObject) { return updatePackageDef(content, function(contentAsObject) {
@@ -42,7 +42,7 @@ module.exports = function(grunt) {
contentAsObject.version = localCfg.packageVersion; contentAsObject.version = localCfg.packageVersion;
contentAsObject.author = "Telerik <support@telerik.com>"; contentAsObject.author = "Telerik <support@telerik.com>";
var specificKeywords = ["telerik", "mobile", "nativescript", "{N}", "tns", "appbuilder"]; var specificKeywords = ["telerik", "mobile", "nativescript", "{N}", "tns", "appbuilder"];
if (currentAppName.indexOf("template-") == 0) { if (currentAppName.indexOf("template-") === 0) {
var templateName = currentAppName.substring("template-".length); var templateName = currentAppName.substring("template-".length);
contentAsObject.name = "tns-" + currentAppName; contentAsObject.name = "tns-" + currentAppName;
contentAsObject.description = "Nativescript " + templateName + " project template"; contentAsObject.description = "Nativescript " + templateName + " project template";
@@ -132,7 +132,7 @@ module.exports = function(grunt) {
} }
} }
return allDirs; return allDirs;
} };
var localCfg = { var localCfg = {
srcDir: ".", srcDir: ".",
@@ -150,7 +150,7 @@ module.exports = function(grunt) {
}; };
var nodeTestEnv = JSON.parse(JSON.stringify(process.env)); var nodeTestEnv = JSON.parse(JSON.stringify(process.env));
nodeTestEnv['NODE_PATH'] = localCfg.outModulesDir; nodeTestEnv.NODE_PATH = localCfg.outModulesDir;
localCfg.nodeTestsDir = pathModule.join(localCfg.outModulesDir, 'node-tests'); localCfg.nodeTestsDir = pathModule.join(localCfg.outModulesDir, 'node-tests');
@@ -177,6 +177,19 @@ module.exports = function(grunt) {
"!./libjs.d.ts" "!./libjs.d.ts"
]); ]);
var tsOptions = {
fast: 'never',
module: "commonjs",
target: "es5",
sourceMap: false,
declaration: false,
removeComments: !grunt.option('leavecomments') || '',
compiler: "node_modules/typescript/bin/tsc",
noEmitOnError: true,
experimentalDecorators: true,
noEmitHelpers: true
};
grunt.initConfig({ grunt.initConfig({
localCfg : localCfg, localCfg : localCfg,
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
@@ -314,36 +327,31 @@ module.exports = function(grunt) {
build: { build: {
src: localCfg.typeScriptSrc, src: localCfg.typeScriptSrc,
outDir: localCfg.outModulesDir, outDir: localCfg.outModulesDir,
options: { options: tsOptions
fast: 'never',
module: "commonjs",
target: "es5",
sourceMap: false,
declaration: false,
removeComments: "<%= !grunt.option('leavecomments') || '' %>",
compiler: "node_modules/typescript/bin/tsc",
noEmitOnError: true,
experimentalDecorators: true,
noEmitHelpers: true
}
}, },
buildNodeTests: { buildNodeTests: {
src: [ src: [
'js-libs/easysax/**/*.ts', 'js-libs/easysax/**/*.ts',
'xml/**/*.ts', 'xml/**/*.ts',
'node-tests/**/*.ts', 'node-tests/**/*.ts',
'es-collections.d.ts',
], ],
outDir: localCfg.outModulesDir, outDir: localCfg.outModulesDir,
options: { options: tsOptions
fast: 'never', },
module: "commonjs", buildDts: {
target: "es5", src: [
sourceMap: false, '**/*.d.ts',
declaration: false, '!org.nativescript.widgets.d.ts',
removeComments: "<%= !grunt.option('leavecomments') || '' %>", '!**/*.android.d.ts',
compiler: "node_modules/typescript/bin/tsc", '!node_modules/**/*',
noEmitOnError: true '!bin/**/*',
} '!apps/**/*',
'!android17.d.ts',
'!ios.d.ts',
],
outDir: localCfg.outModulesDir,
options: tsOptions
} }
}, },
tslint: { tslint: {
@@ -431,7 +439,7 @@ module.exports = function(grunt) {
clonedTasks.push({name: taskName, cfg: taskCfg}); clonedTasks.push({name: taskName, cfg: taskCfg});
} }
return clonedTasks; return clonedTasks;
} };
var enqueueTasks = function(tasks) { var enqueueTasks = function(tasks) {
for (var i=0; i<tasks.length; i++) { for (var i=0; i<tasks.length; i++) {
@@ -439,7 +447,7 @@ module.exports = function(grunt) {
grunt.config(task.name, task.cfg); grunt.config(task.name, task.cfg);
grunt.task.run(task.name.join(":")); grunt.task.run(task.name.join(":"));
} }
} };
grunt.registerTask("processEachApp", function(outAppsDir, pkgAppNameSuffix){ grunt.registerTask("processEachApp", function(outAppsDir, pkgAppNameSuffix){
var allapps = getSubDirs(localCfg.srcAppsDir); var allapps = getSubDirs(localCfg.srcAppsDir);
@@ -489,7 +497,10 @@ module.exports = function(grunt) {
"copy:license" "copy:license"
]); ]);
grunt.registerTask("compile-dts", ["ts:buildDts"]);
grunt.registerTask("compile-ts", [ grunt.registerTask("compile-ts", [
"compile-dts",
"ts:build", "ts:build",
"clean:typeScriptLeftovers", "clean:typeScriptLeftovers",
"copy:childPackageFiles" "copy:childPackageFiles"