Created
August 8, 2012 20:56
-
-
Save moduscreate/3298710 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/silkjs | |
| /* | |
| This is a prototype of a SilkJS Sencha Touch -> PhoneGap automated deployment script. | |
| More to come at moduscreate.com/blog :) | |
| */ | |
| console = require('console'); | |
| fs = require('fs'); | |
| process = require('builtin/process'); | |
| (function() { | |
| var sleepTime = 2, // time to sleep | |
| target = 'testing', | |
| webAppDir = 'html5', | |
| buildDir = 'build/$target', | |
| iosDir = 'ios/www', | |
| devNullRd = ' >/dev/null 2>&1', | |
| commands = { | |
| senchaBuild : 'cd ' + webAppDir + '; sencha app build ' + target, | |
| sayDeploying : 'say Deploying' + devNullRd, | |
| sayDone : 'say done building' + devNullRd, | |
| // todo migrate to notification | |
| reportError : ('').concat( | |
| 'osascript -e \'tell application "Finder"\'', | |
| ' -e "activate"', | |
| ' -e \'display alert \"Erorr with Sencha Touch 2 build\"\'', | |
| ' -e "end tell"' | |
| ), | |
| copyIosResources : [ | |
| 'rm -rf ' + iosDir + '/*', | |
| 'cp -Rf ' + buildDir + '/* ' + iosDir + '/', | |
| 'cp ' + webAppDir + '/lib/cordova-1.9.0.ios.js ' + iosDir +'/cordova-1.9.0.js', | |
| 'cp ' + webAppDir + '/lib/ChildBrowser.ios.js ' + iosDir + '/ChildBrowser.js' | |
| ] | |
| }; | |
| var exec = function(cmd) { | |
| console.log('Executing : ' + cmd); | |
| return process.exec(cmd); | |
| }; | |
| var deploy = function() { | |
| exec(commands.sayDeploying); | |
| var out = exec(commands.senchaBuild); | |
| if (out.match('ERROR')) { | |
| exec(commands.reportError); | |
| console.log('<<<<<<<< OUTPUT >>>>>>>'); | |
| console.log(out); | |
| } | |
| else { | |
| commands.copyIosResources.each(function(cmd) { | |
| exec(cmd); | |
| }); | |
| } | |
| }; | |
| var projectName = 'discovermusic', | |
| fileName = '/tmp/' + projectName + '_watcher.md5', | |
| md5 = fs.readFile(fileName), | |
| getChangesStr = 'ls -lR html5/ | md5', | |
| newMd5; | |
| while (1) { | |
| newMd5 = exec(getChangesStr); | |
| if (md5 == null || md5 != newMd5 ) { | |
| deploy(); | |
| md5 = newMd5; | |
| fs.writeFile(fileName, newMd5); | |
| } | |
| process.sleep(sleepTime); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment