mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +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) {
|
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildTestsApp")>= 0) {
|
||||||
var tsTester = require("./build/run-testsapp.grunt.js");
|
var tsTester = require("./build/run-testsapp.grunt.js");
|
||||||
tsTester.run(grunt);
|
tsTester.run(grunt);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var fs=require("fs");
|
var fs=require("fs");
|
||||||
var pathModule=require("path");
|
var pathModule=require("path");
|
||||||
@ -175,6 +175,16 @@ module.exports = function(grunt) {
|
|||||||
nodeTests: {
|
nodeTests: {
|
||||||
src: localCfg.nodeTestsDir,
|
src: localCfg.nodeTestsDir,
|
||||||
},
|
},
|
||||||
|
builtModules: {
|
||||||
|
src: localCfg.outModulesDir
|
||||||
|
},
|
||||||
|
externalModules: {
|
||||||
|
expand: true,
|
||||||
|
src: '<%= grunt.option("path") %>/node_modules/tns-core-modules/**/*',
|
||||||
|
options: {
|
||||||
|
force: true
|
||||||
|
},
|
||||||
|
},
|
||||||
readyAppFiles: {
|
readyAppFiles: {
|
||||||
src: [localCfg.outModulesDir + "/apps/**"]
|
src: [localCfg.outModulesDir + "/apps/**"]
|
||||||
}
|
}
|
||||||
@ -285,6 +295,18 @@ module.exports = function(grunt) {
|
|||||||
dest: localCfg.outDir + "/",
|
dest: localCfg.outDir + "/",
|
||||||
cwd: localCfg.outDir,
|
cwd: localCfg.outDir,
|
||||||
flatten: true
|
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: {
|
ts: {
|
||||||
@ -478,6 +500,22 @@ module.exports = function(grunt) {
|
|||||||
"clean:typeScriptLeftovers",
|
"clean:typeScriptLeftovers",
|
||||||
"copy:childPackageFiles"
|
"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", [
|
grunt.registerTask("distribute-apps-files", [
|
||||||
"copy:readyAppFiles",
|
"copy:readyAppFiles",
|
||||||
"clean:readyAppFiles"
|
"clean:readyAppFiles"
|
||||||
@ -498,12 +536,9 @@ module.exports = function(grunt) {
|
|||||||
var combinedDtsPath = pathModule.join(localCfg.outModulesDir, 'tns-core-modules.d.ts');
|
var combinedDtsPath = pathModule.join(localCfg.outModulesDir, 'tns-core-modules.d.ts');
|
||||||
grunt.file.write(combinedDtsPath, dtsLines.join('\n'));
|
grunt.file.write(combinedDtsPath, dtsLines.join('\n'));
|
||||||
});
|
});
|
||||||
|
//aliasing pack-modules for backwards compatibility
|
||||||
grunt.registerTask("pack-modules", [
|
grunt.registerTask("pack-modules", [
|
||||||
"copy:modulesPackageDef",
|
"compile-modules",
|
||||||
"copy:definitionFiles",
|
|
||||||
"copy:jsLibs",
|
|
||||||
"generate-tns-core-modules-dts",
|
|
||||||
"ts:testCombinedDts",
|
|
||||||
"exec:packModules"
|
"exec:packModules"
|
||||||
]);
|
]);
|
||||||
grunt.registerTask("pack-apps", [
|
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([
|
grunt.registerTask("default", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
||||||
"just-build",
|
"build-all",
|
||||||
|
|
||||||
"pack-apps",
|
"pack-apps",
|
||||||
"pack-ts-apps",
|
"pack-ts-apps",
|
||||||
"get-ready-packages"
|
"get-ready-packages"
|
||||||
]));
|
]));
|
||||||
|
|
||||||
grunt.registerTask("just-build", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
grunt.registerTask("compile-modules", [
|
||||||
"clean:build",
|
"clean:build",
|
||||||
"shell:getGitSHA",
|
"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-apps-raw-files",
|
||||||
"collect-modules-raw-files",
|
|
||||||
|
|
||||||
"compile-ts",
|
|
||||||
"distribute-apps-files",
|
"distribute-apps-files",
|
||||||
"distribute-ts-apps-files",
|
"distribute-ts-apps-files",
|
||||||
|
|
||||||
"bom:allTargetFiles",
|
|
||||||
|
|
||||||
"pack-modules"
|
|
||||||
]));
|
]));
|
||||||
|
|
||||||
grunt.registerTask("node-tests", [
|
grunt.registerTask("node-tests", [
|
||||||
@ -548,7 +591,4 @@ module.exports = function(grunt) {
|
|||||||
"env:nodeTests",
|
"env:nodeTests",
|
||||||
"exec:mochaNode", //spawn a new process to use the new NODE_PATH
|
"exec:mochaNode", //spawn a new process to use the new NODE_PATH
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"**/*.*",
|
"**/*.*",
|
||||||
"**/*",
|
"**/*",
|
||||||
"!node-tests/"
|
"!.baseDir.*",
|
||||||
|
"!node-tests/",
|
||||||
|
"!apps/"
|
||||||
],
|
],
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Reference in New Issue
Block a user