Reconfigure android-specific tasks and arguments to be cross-platform. Update documentation

This commit is contained in:
Erjan Gavalji
2015-10-26 18:01:28 +02:00
parent cfb6c41542
commit 8355634274
2 changed files with 47 additions and 17 deletions

View File

@ -13,7 +13,7 @@ module.exports = {
emulatorProcessIdentifier: grunt.option("emuPId"),
emuAvdName: grunt.option("avd"),
outFile: grunt.option("logFilePath"),
androidRuntimePath: grunt.option("androidRuntimePath"),
runtimePath: grunt.option("runtimePath"),
showEmu: grunt.option("showEmu")
};
@ -38,7 +38,7 @@ module.exports = {
modulesPath: args.modulesPath || "./bin/dist/tns-core-modules-" + modulesPackageConfig.version + ".tgz",
emuAvdName: args.emuAvdName,
outfile: args.outFile || "./TestRunResult.txt",
androidFrameworkArgument: args.androidRuntimePath ? " --frameworkPath=" + args.androidRuntimePath : "",
frameworkArgument: args.runtimePath ? " --frameworkPath=" + args.runtimePath : "",
showEmu: args.showEmu || false,
workingDir:".testsapprun",
@ -112,6 +112,27 @@ module.exports = {
return newContent;
}
}
},
addiOSPermissions: {
src: localCfg.testsAppName + "-Info.plist",
dest: pathModule.join(localCfg.applicationDir,"/platforms/ios/", localCfg.testsAppName) + "/",
cwd: pathModule.join(localCfg.applicationDir,"/platforms/ios/", localCfg.testsAppName),
expand: true,
options: {
process: function(content, srcPath) {
var newContent = content;
var lastDictLocator = /(<\/dict>\s*<\/plist>)$/gm;
if (!/NSAppTransportSecurity/.test(content)) {
newContent = newContent.replace(lastDictLocator, "<key>NSAppTransportSecurity</key>\n$1");
}
if (!/NSAllowsArbitraryLoads/.test(content)) {
newContent = newContent.replace(lastDictLocator, "<dict>\n<key>NSAllowsArbitraryLoads</key>\n<true/>\n</dict>\n$1");
}
return newContent;
}
}
}
},
exec: {
@ -127,12 +148,8 @@ module.exports = {
cmd: localCfg.tnsPath + " create " + localCfg.testsAppName,
cwd: localCfg.workingDir
},
addAndroidPlatform: {
cmd: "tns platform add android " + localCfg.androidFrameworkArgument,
cwd: localCfg.applicationDir
},
buildAndroidApp: {
cmd: "tns build android",
addPlatform: {
cmd: "tns platform add " + localCfg.platform.toLowerCase() + " " + localCfg.frameworkArgument,
cwd: localCfg.applicationDir
},
restartAdb: {
@ -163,7 +180,16 @@ module.exports = {
maxBuffer: Infinity
}
}
}
},
buildApp: {
command: "tns build " + localCfg.platform.toLowerCase(),
options: {
execOptions: {
maxBuffer: Infinity,
cwd: localCfg.applicationDir
}
}
},
}
});
@ -178,15 +204,17 @@ module.exports = {
return templatedTaskName.replace(/\{platform\}/, localCfg.platform);
}
grunt.registerTask("doPostPlatformAdd", [
grunt.registerTask("doPostPlatformAddAndroid", [
"exec:restartAdb"
]);
grunt.registerTask("doPostPlatformAddiOS", [
]);
grunt.registerTask("testsapp", [
"clean:workingDir",
"mkdir:workingDir",
getPlatformSpecificTask("exec:kill{platform}Emulator"),
getPlatformSpecificTask("exec:start{platform}Emulator"),
// getPlatformSpecificTask("exec:kill{platform}Emulator"),
// getPlatformSpecificTask("exec:start{platform}Emulator"),
"exec:createApp",
"clean:originalAppDir",
@ -196,10 +224,10 @@ module.exports = {
"copy:modulesToDir",
"clean:tempExtractedModules",
getPlatformSpecificTask("exec:add{platform}Platform"),
"exec:addPlatform",
getPlatformSpecificTask("copy:add{platform}Permissions"),
getPlatformSpecificTask("exec:build{platform}App"),
"doPostPlatformAdd",
"shell:buildApp",
getPlatformSpecificTask("doPostPlatformAdd{platform}"),
getPlatformSpecificTask("exec:uninstallExisting{platform}App"),
getPlatformSpecificTask("exec:installNew{platform}App"),

View File

@ -46,9 +46,11 @@ emulator process, as the emulator sometimes hangs.
tests.
- `logFilePath`: [Optional] The path to the file, which the test app run
log will get saved to. Defaults to "./TestRunResult.txt".
- `androidRuntimePath`: [Optional] The path to a custom Android Runtime
- `runtimePath`: [Optional] The path to a custom iOS or Android Runtime
package to have the tests run onto. If not specified, the newest available
build on [npmjs.com](http://npmjs.com).
build on [npmjs.com](http://npmjs.com) -
[tns-ios](https://www.npmjs.com/package/tns-ios) or
[tns-android](https://www.npmjs.com/package/tns-android).
# Sample run:
```