move sample code and apps out of main repo

and add a grunt task that brings them in for use in dev
This commit is contained in:
Jonathan Lipps
2014-08-12 17:58:42 -07:00
parent d8ec80710b
commit 0483952a0e
10 changed files with 77 additions and 2 deletions
+1
View File
@@ -5,6 +5,7 @@ npm*.log
node_modules
*.trace
xcuserdata
sample-code/examples
sample-code/apps/TestApp/build
sample-code/apps/WebViewApp/build
sample-code/apps/WebViewApp/WebViewApp.xcodeproj/project.xcworkspace/xcshareddata
+3
View File
@@ -52,3 +52,6 @@
[submodule "submodules/io.appium.settings"]
path = submodules/io.appium.settings
url = https://github.com/appium/io.appium.settings.git
[submodule "submodules/sample-code"]
path = submodules/sample-code
url = https://github.com/appium/sample-code
+7
View File
@@ -19,6 +19,7 @@ var path = require('path')
, generateAppiumIo = gruntHelpers.generateAppiumIo
, setDeviceConfigVer = gruntHelpers.setDeviceConfigVer
, setBuildTime = gruntHelpers.setBuildTime
, getSampleCode = gruntHelpers.getSampleCode
, setGitRev = gruntHelpers.setGitRev
, getGitRev = require('./lib/helpers').getGitRev;
@@ -155,6 +156,12 @@ module.exports = function (grunt) {
grunt.registerTask('setBuildTime', function () {
setBuildTime(grunt, this.async());
});
grunt.registerTask('getSampleCode', function (hardcore) {
if (typeof hardcore !== "undefined" && hardcore === "hardcore") {
hardcore = true;
}
getSampleCode(grunt, hardcore, this.async());
});
grunt.registerTask('setGitRev', function (rev) {
var done = this.async();
if (typeof rev === "undefined") {
+1
View File
@@ -8,6 +8,7 @@ kinds of appium dev tasks. Here's what you can do:
|grunt lint|Run JSLint|
|grunt test|Run the unit tests|
|grunt unit|Run the unit tests|
|grunt getSampleCode|Download sample code and apps. Accepts `:hardcore` parameter|
|grunt buildApp:&lt;AppName&gt;:&lt;SDK&gt;|Build an iOS app for the iPhone Simulator. Expects there to be a .app at `sample-code/apps/<AppName>/build/Release-iphonesimulator/<AppName>.app`. Default SDK is 'iphonesimulator7.1'|
|grunt signApp:&lt;certName&gt;|Signs the test app with an absolute path to an iOS dev certificate|
|grunt authorize|Authorize your simulator to run without prompting|
@@ -23,7 +23,7 @@ want to zip it up, you can.
The best way to see what to do currently is to look at the example tests:
[Node.js](/sample-code/examples/node) | [Python](/sample-code/examples/python) | [PHP](/sample-code/examples/php) | [Ruby](/sample-code/examples/ruby) | [Java](/sample-code/examples/java)
[Node.js](https://github.com/appium/sample-code/sample-code/examples/node) | [Python](https://github.com/appium/sample-code/sample-code/examples/python) | [PHP](https://github.com/appium/sample-code/sample-code/examples/php) | [Ruby](https://github.com/appium/sample-code/sample-code/examples/ruby) | [Java](https://github.com/appium/sample-code/sample-code/examples/java)
Basically, first make sure Appium is running:
+46
View File
@@ -55,6 +55,52 @@ module.exports.startAppium = function (appName, verbose, readyCb, doneCb) {
);
};
var execWithOutput = function (cmd, cb) {
exec(cmd, function (err, stdout, stderr) {
if (err) {
console.error("Command failed");
console.error("stdout:");
console.error(stdout);
console.error("stderr:");
console.error(stderr);
}
cb(err, stdout, stderr);
});
};
module.exports.getSampleCode = function (grunt, hardcore, cb) {
var submodulesDir = path.resolve(__dirname, "submodules");
var sampleCodeGit = path.resolve(submodulesDir, "sample-code");
var sampleCodeDir = path.resolve(__dirname, "sample-code");
var sampleCodeExists = fs.existsSync(sampleCodeDir);
var updateCmd = "git submodule update --init " + sampleCodeGit;
console.log("Cloning/updating Appium sample-code submodule");
execWithOutput(updateCmd, function (err, stdout, stderr) {
if (err) return cb(err);
var updated = false;
if (stdout + stderr !== "") {
// there were submodule updates
console.log("There were updates to the submodule");
updated = true;
}
if (hardcore || updated) {
console.log("Removing old sample-code");
console.log("Please remember to rebuild test apps");
rimraf.sync(sampleCodeDir);
}
if (hardcore || updated || !sampleCodeExists) {
console.log("Copying sample-code out for use");
ncp(path.resolve(sampleCodeGit, "sample-code"), sampleCodeDir, function (err) {
if (err) return cb(err);
console.log("Test apps are ready for building");
cb();
});
} else {
console.log("Sample code was not updated, doing nothing");
}
});
};
module.exports.runTestsWithServer = function (grunt, appName, testType, deviceType, verbose, cb) {
if (typeof verbose === "undefined") {
verbose = false;
+5
View File
@@ -53,6 +53,11 @@ if %doDev% == 1 (
ECHO.
)
:: Install Sample Code
if %doDev% == 1 (
CALL :runCmd "node_modules\.bin\grunt getSampleCode"
)
:: Reset Android
if %doAndroid% == 1 (
ECHO.
+12
View File
@@ -138,6 +138,15 @@ reset_general() {
fi
}
reset_sample_code() {
echo "* Initializing sample code and test apps"
if $hardcore ; then
run_cmd "$grunt" getSampleCode:hardcore
else
run_cmd "$grunt" getSampleCode
fi
}
reset_ios() {
echo "RESETTING IOS"
set +e
@@ -563,6 +572,9 @@ main() {
fi
reset_npm
reset_general
if $include_dev ; then
reset_sample_code
fi
if $should_reset_ios ; then
reset_ios
fi
-1
View File
@@ -1 +0,0 @@
The sample code has moved to [appium/sample-code](https://github.com/appium/sample-code)