mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Grunt: add an update-external-app task
Builds the modules in bin/dist/modules and updates an app's node_modules/tns-core-modules dir. grunt update-external-app --path=/some/path/myapp1
This commit is contained in:
78
gruntfile.js
78
gruntfile.js
@ -5,8 +5,8 @@ module.exports = function(grunt) {
|
||||
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildTestsApp")>= 0) {
|
||||
var tsTester = require("./build/run-testsapp.grunt.js");
|
||||
tsTester.run(grunt);
|
||||
} else {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var fs=require("fs");
|
||||
var pathModule=require("path");
|
||||
@ -175,6 +175,16 @@ module.exports = function(grunt) {
|
||||
nodeTests: {
|
||||
src: localCfg.nodeTestsDir,
|
||||
},
|
||||
builtModules: {
|
||||
src: localCfg.outModulesDir
|
||||
},
|
||||
externalModules: {
|
||||
expand: true,
|
||||
src: '<%= grunt.option("path") %>/node_modules/tns-core-modules/**/*',
|
||||
options: {
|
||||
force: true
|
||||
},
|
||||
},
|
||||
readyAppFiles: {
|
||||
src: [localCfg.outModulesDir + "/apps/**"]
|
||||
}
|
||||
@ -285,6 +295,18 @@ module.exports = function(grunt) {
|
||||
dest: localCfg.outDir + "/",
|
||||
cwd: localCfg.outDir,
|
||||
flatten: true
|
||||
},
|
||||
builtModules: {
|
||||
expand: true,
|
||||
src: [
|
||||
'**/*',
|
||||
'!*.md',
|
||||
'!apps/**/*',
|
||||
'!node_modules/**/*',
|
||||
'!node-tests/**/*',
|
||||
],
|
||||
cwd: localCfg.outModulesDir,
|
||||
dest: "<%= grunt.option('path') %>/node_modules/tns-core-modules/",
|
||||
}
|
||||
},
|
||||
ts: {
|
||||
@ -478,6 +500,22 @@ module.exports = function(grunt) {
|
||||
"clean:typeScriptLeftovers",
|
||||
"copy:childPackageFiles"
|
||||
]);
|
||||
grunt.registerTask("check-external-app", function() {
|
||||
var appPath = grunt.option('path');
|
||||
if (!appPath) {
|
||||
grunt.fail.fatal("External app option required. Pass the --path option.");
|
||||
}
|
||||
if (!grunt.file.exists(appPath)) {
|
||||
grunt.fail.fatal("External application path does not exist: " + appPath);
|
||||
}
|
||||
});
|
||||
grunt.registerTask("update-external-app", [
|
||||
"check-external-app",
|
||||
"clean:builtModules",
|
||||
"compile-modules",
|
||||
"clean:externalModules",
|
||||
"copy:builtModules"
|
||||
]);
|
||||
grunt.registerTask("distribute-apps-files", [
|
||||
"copy:readyAppFiles",
|
||||
"clean:readyAppFiles"
|
||||
@ -498,12 +536,9 @@ module.exports = function(grunt) {
|
||||
var combinedDtsPath = pathModule.join(localCfg.outModulesDir, 'tns-core-modules.d.ts');
|
||||
grunt.file.write(combinedDtsPath, dtsLines.join('\n'));
|
||||
});
|
||||
//aliasing pack-modules for backwards compatibility
|
||||
grunt.registerTask("pack-modules", [
|
||||
"copy:modulesPackageDef",
|
||||
"copy:definitionFiles",
|
||||
"copy:jsLibs",
|
||||
"generate-tns-core-modules-dts",
|
||||
"ts:testCombinedDts",
|
||||
"compile-modules",
|
||||
"exec:packModules"
|
||||
]);
|
||||
grunt.registerTask("pack-apps", [
|
||||
@ -517,27 +552,35 @@ module.exports = function(grunt) {
|
||||
]);
|
||||
|
||||
grunt.registerTask("default", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
||||
"just-build",
|
||||
"build-all",
|
||||
|
||||
"pack-apps",
|
||||
"pack-ts-apps",
|
||||
"get-ready-packages"
|
||||
]));
|
||||
|
||||
grunt.registerTask("just-build", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
||||
grunt.registerTask("compile-modules", [
|
||||
"clean:build",
|
||||
"shell:getGitSHA",
|
||||
"compile-ts",
|
||||
"bom:allTargetFiles",
|
||||
"collect-modules-raw-files",
|
||||
"copy:modulesPackageDef",
|
||||
"copy:definitionFiles",
|
||||
"copy:jsLibs",
|
||||
"generate-tns-core-modules-dts",
|
||||
"ts:testCombinedDts",
|
||||
]);
|
||||
|
||||
//alias just-build for backwards compatibility
|
||||
grunt.registerTask("just-build", ["build-all"]);
|
||||
|
||||
grunt.registerTask("build-all", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
||||
"pack-modules",
|
||||
|
||||
"collect-apps-raw-files",
|
||||
"collect-modules-raw-files",
|
||||
|
||||
"compile-ts",
|
||||
"distribute-apps-files",
|
||||
"distribute-ts-apps-files",
|
||||
|
||||
"bom:allTargetFiles",
|
||||
|
||||
"pack-modules"
|
||||
]));
|
||||
|
||||
grunt.registerTask("node-tests", [
|
||||
@ -548,7 +591,4 @@ module.exports = function(grunt) {
|
||||
"env:nodeTests",
|
||||
"exec:mochaNode", //spawn a new process to use the new NODE_PATH
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -9,7 +9,9 @@
|
||||
"files": [
|
||||
"**/*.*",
|
||||
"**/*",
|
||||
"!node-tests/"
|
||||
"!.baseDir.*",
|
||||
"!node-tests/",
|
||||
"!apps/"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
|
Reference in New Issue
Block a user