From ee77b720d5d085a2b852d319b9fedc63565ee7c9 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Mon, 2 Nov 2015 15:57:19 +0200 Subject: [PATCH 1/2] Remove files sections in JS libs package.json. Those exclude unlisted files (d.ts files mostly) that we want bundled in. No point in listing d.ts files since we already keep those folders clean. --- css/package.json | 4 ---- js-libs/easysax/package.json | 5 ----- js-libs/esprima/package.json | 11 +---------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/css/package.json b/css/package.json index 93bb89103..3fb0fd8a0 100644 --- a/css/package.json +++ b/css/package.json @@ -3,10 +3,6 @@ "version": "2.2.1", "description": "CSS parser / stringifier", "main": "index", - "files": [ - "index.js", - "lib" - ], "dependencies": { "source-map": "^0.1.38", "source-map-resolve": "^0.3.0", diff --git a/js-libs/easysax/package.json b/js-libs/easysax/package.json index 33bf3ac4d..a71044b75 100644 --- a/js-libs/easysax/package.json +++ b/js-libs/easysax/package.json @@ -17,11 +17,6 @@ "email": "flash.vkv@gmail.com", "url": "http://vflash.ru" }, - "files": [ - "easysax.js", - "LICENSE", - "README.md" - ], "repository": { "type": "git", "url": "https://github.com/vflash/easysax" diff --git a/js-libs/esprima/package.json b/js-libs/esprima/package.json index f7219193c..9364d6431 100644 --- a/js-libs/esprima/package.json +++ b/js-libs/esprima/package.json @@ -8,15 +8,6 @@ "esvalidate": "./bin/esvalidate.js" }, "version": "2.0.0-dev", - "files": [ - "bin", - "test/run.js", - "test/runner.js", - "test/test.js", - "test/compat.js", - "test/reflect.js", - "esprima.js" - ], "engines": { "node": ">=0.4.0" }, @@ -80,4 +71,4 @@ "benchmark": "node test/benchmarks.js", "benchmark-quick": "node test/benchmarks.js quick" } -} \ No newline at end of file +} From 65d81aeb90a7284f9732c8f2f8784aa3a34ed30f Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Tue, 3 Nov 2015 11:12:44 +0200 Subject: [PATCH 2/2] Include d.ts files in tns-core-modules package. - Generate a combined tns-core-modules.d.ts file for user projects. (Will be included in tsconfig.json files by the `tns` tool automagically.) - Test the integrity of the generated combined file by compiling it. - Remove all traces of the obsoleted tns-definitions package. --- gruntfile.js | 107 ++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 62 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 24e885c37..b584ab7b9 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -80,18 +80,6 @@ module.exports = function(grunt) { packageObject.keywords = packageObject.keywords.concat(newKeywords); }; - var updateDefinitionsPackageDef = function(content, srcPath) { - return updatePackageDef(content, function(contentAsObject) { - contentAsObject.version = localCfg.packageVersion; - contentAsObject.name = "tns-definitions"; - contentAsObject.description = "NativeScript Module definitions"; - contentAsObject.license = "Apache-2.0"; - if (localCfg.commitSHA) { - contentAsObject.repository.url += "/commit/" + localCfg.commitSHA; - } - }); - }; - var getCommitSha = function() { if (process.env.GIT_COMMIT) { return process.env.GIT_COMMIT; @@ -142,11 +130,6 @@ module.exports = function(grunt) { outModulesDir: "./bin/dist/modules", outAppsDir: "./bin/dist/apps", outTsAppsDir: "./bin/dist/ts-apps", - outDefinitionsDir: "./bin/dist/definitions", - - excludedModules: [ - "!./ui/slide-out/**/*.*" - ] }; var nodeTestEnv = JSON.parse(JSON.stringify(process.env)); @@ -162,15 +145,15 @@ module.exports = function(grunt) { "!" + localCfg.outDir + "/**/*.*", "!./node_modules/**/*.*", "!./bin/**/*.*", - "!./build/**/*.*", - "!./Deploy/**/*.*", - "!./obj/**/*.*", - "!./out/**/*.*", - "!./.*/**/*.*" + "!./build/**/*.*", + "!./Deploy/**/*.*", + "!./obj/**/*.*", + "!./out/**/*.*", + "!./.*/**/*.*" ]; localCfg.typeScriptSrc = [ "./**/*.ts" - ].concat(localCfg.defaultExcludes).concat(localCfg.excludedModules); + ].concat(localCfg.defaultExcludes); localCfg.typeScriptSrcForTsLint = localCfg.typeScriptSrc.concat([ "!./ios.d.ts", "!./android17.d.ts", @@ -217,12 +200,12 @@ module.exports = function(grunt) { jsLibs: { expand: true, src: [ - "./js-libs/**/*.js", - "./fetch/**/*.js", - "./css/**/*.js", - "./css-value/**/*.js", + "js-libs/**/*.js", + "fetch/**/*.js", + "css/**/*.js", + "css-value/**/*.js", ], - dest: "<%= localCfg.outModulesDir %>/", + dest: localCfg.outModulesDir, cwd: localCfg.srcDir }, license: { @@ -242,11 +225,16 @@ module.exports = function(grunt) { definitionFiles: { src: [ localCfg.srcDir + "/**/*.d.ts", - pathModule.join(localCfg.srcDir, "LICENSE"), //Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there! - "!" + localCfg.srcDir + "/apps/**" - ].concat(localCfg.defaultExcludes).concat(localCfg.excludedModules), - dest: localCfg.outDefinitionsDir + "/", + "!" + localCfg.srcDir + "/apps/**", + "!" + localCfg.srcDir + "/node-tests/**", + "!" + localCfg.srcDir + "/org.nativescript.widgets.d.ts", + "!" + localCfg.srcDir + "/android17.d.ts", + "!" + localCfg.srcDir + "/**/*.android.d.ts", + "!" + localCfg.srcDir + "/ios.d.ts", + "!" + localCfg.srcDir + "/**/*.ios.d.ts", + ].concat(localCfg.defaultExcludes), + dest: localCfg.outModulesDir + "/", expand: true, options: { process: filterTypeScriptFiles @@ -260,13 +248,6 @@ module.exports = function(grunt) { process: updateModulesPackageDef } }, - definitionsPackageDef: { - src: localCfg.packageJsonFilePath, - dest: localCfg.outDefinitionsDir + "/", - options: { - process: updateDefinitionsPackageDef - } - }, appPackageDef: { expand: true, flatten: true, @@ -282,10 +263,10 @@ module.exports = function(grunt) { localCfg.srcDir + "/**/package.json", "!./package.json", "!./Deploy/**/*.*", - "!./bin/**/*.*", - "!./Tests/**/*.*", - "!" + localCfg.outDir + "/**/*.*" - ].concat(localCfg.excludedModules), + "!./bin/**/*.*", + "!./Tests/**/*.*", + "!" + localCfg.outDir + "/**/*.*" + ], dest: localCfg.outModulesDir + "/" }, rawAppsFiles: { @@ -352,6 +333,13 @@ module.exports = function(grunt) { ], outDir: localCfg.outModulesDir, options: tsOptions + }, + testCombinedDts: { + src: [ + pathModule.join(localCfg.outModulesDir, 'tns-core-modules.d.ts'), + ], + outDir: localCfg.outModulesDir, + options: tsOptions } }, tslint: { @@ -369,10 +357,6 @@ module.exports = function(grunt) { cmd: "npm pack", cwd: localCfg.outModulesDir + "/" }, - packDefinitions: { - cmd: "npm pack", - cwd: localCfg.outDefinitionsDir + "/" - }, packApp: { cmd: "npm pack", cwd: "__dummy__" @@ -487,11 +471,6 @@ module.exports = function(grunt) { "multidest:copyLicenseFiles" ]); - // Does nothing to avoid copying the same files twice. Instead, - // the distribute-definition-files tasks copies the d.ts files - // from the source root directly to the output folder. - grunt.registerTask("collect-definitions-raw-files", []); - grunt.registerTask("collect-modules-raw-files", [ "copy:jsLibs", "copy:license" @@ -512,11 +491,22 @@ module.exports = function(grunt) { grunt.registerTask("distribute-ts-apps-files", [ "copy:readyTsAppFiles" ]); - grunt.registerTask("distribute-definition-files", [ - "copy:definitionFiles" - ]); + grunt.registerTask("generate-tns-core-modules-dts", function() { + var dtsFiles = grunt.file.expand({cwd: localCfg.outModulesDir}, ['**/*.d.ts']); + dtsFiles.sort() + + var dtsLines = dtsFiles.map(function(dtsFile) { + return '/// '; + }); + var combinedDtsPath = pathModule.join(localCfg.outModulesDir, 'tns-core-modules.d.ts'); + grunt.file.write(combinedDtsPath, dtsLines.join('\n')); + }); grunt.registerTask("pack-modules", [ "copy:modulesPackageDef", + "copy:definitionFiles", + "copy:jsLibs", + "generate-tns-core-modules-dts", + "ts:testCombinedDts", "exec:packModules" ]); grunt.registerTask("pack-apps", [ @@ -525,10 +515,6 @@ module.exports = function(grunt) { grunt.registerTask("pack-ts-apps", [ "processEachApp:" + localCfg.outTsAppsDir + ":-ts" ]); - grunt.registerTask("pack-definitions", [ - "copy:definitionsPackageDef", - "exec:packDefinitions" - ]); grunt.registerTask("get-ready-packages", [ "copy:readyPackages" ]); @@ -538,7 +524,6 @@ module.exports = function(grunt) { "pack-apps", "pack-ts-apps", - "pack-definitions", "get-ready-packages" ])); @@ -547,13 +532,11 @@ module.exports = function(grunt) { "shell:getGitSHA", "collect-apps-raw-files", - "collect-definitions-raw-files", "collect-modules-raw-files", "compile-ts", "distribute-apps-files", "distribute-ts-apps-files", - "distribute-definition-files", "pack-modules" ]));