diff options
author | Bryan Berry <bryan@olenepal.org> | 2009-12-30 09:23:45 (GMT) |
---|---|---|
committer | Bryan Berry <bryan@olenepal.org> | 2009-12-30 09:23:45 (GMT) |
commit | 5a8caf604742c06037f6790aa045c42ab1739861 (patch) | |
tree | 2925f442e25f52b4f0402bd7463486a76c465bc0 | |
parent | 9a525cb17b27f9f4d19200c79b12e11f78a23a23 (diff) |
kbuild.js can parse basic arguments
-rw-r--r-- | bin/kbuild.js | 86 | ||||
-rwxr-xr-x | examples/Conozco-Uruguay/js/lesson.js | 15 |
2 files changed, 61 insertions, 40 deletions
diff --git a/bin/kbuild.js b/bin/kbuild.js index a3c2b41..13754ac 100644 --- a/bin/kbuild.js +++ b/bin/kbuild.js @@ -4,37 +4,21 @@ var file = require('file'); var os = require('os'); var args = require('args'); -//list of repos -var REPOS = [ ["folder_name", "git_url"], - ["folder_name", "git_url"] - ]; - -var XO_BUNDLE_REPO = "~/tmp/bundle"; - - -var GIT_DIR = "~/tmp/gitDir"; -var BUILD_DIR = "~/tmp/build"; -var STABLE_TARGET = "~/tmp/stableTarget"; -var UNSTABLE_TARGET = "~/tmp/unstableTarget"; +//list of repos for lessons +var REPOS = [ "git_url", "git_url"]; +var bundleRepo = "~/karma/karma_bundle"; +var gitDir = "~/tmp/gitDir"; +var bundleDir = "~/tmp/bundle"; var tag = "master"; + //folders used by each lesson as it is processed var lessonGitDir = ""; var lessonBuildDir = ""; -var addExitCodeCheck = function (cmd) { - return cmd.concat('; echo $?'); -}; - -var isSuccessful = function(str){ - var newArray = str.split('\n'); - return newArray[newArray.length -2] === "0" ? - true : false; -}; //parse args var parser = new args.Parser(); - parser.help( 'Builds and distributes Karma bundle to different type of targets' ); @@ -43,18 +27,60 @@ parser.option('-t', '--tag', 'tag') .help("which tag to checkout for all lessons") .set(); +parser.option('--bundle-repo', 'bundleRepo') + .help("repository where template for an XO bundle resides") + .set(); + +parser.option('--git-dir', 'gitDir') + .help("directory where this script will checkout the target versions") + .set(); + parser.helpful(); -print(tag); +var options = parser.parse(system.args); +tag = options.tag || tag; +bundleRepo = options.bundleRepo || bundleRepo; +gitDir = options.gitDir || gitDir; +//check that bundleRepo exists +//otherwise throw error +if (!file.exists(bundleRepo)){ + throw new Error ("The bundle repository you supplied:\"" + + bundleRepo + "\" does not exist"); +} + //check that the gitdir exists //if not create it - -//check that build dir exists, if not create it -//pull latest copy of XO_BUNDLE - +var cmd = ''; +var proc = ''; +var exitCode; + +if(!file.exists(gitDir)){ + file.mkdir(gitDir); +} + +if (!file.exists(gitDir + '/.git')){ + cmd = "git clone " + bundleRepo + " " + gitDir; + proc = os.popen(cmd); + exitCode = proc.wait(); + if (exitCode !== 0){ + throw new Error("Could not clone the bundle repository: " + + bundleRepo + "\nResults of shell commands \n" + + proc.stderr.read()); + } +} else { + //pull newest version + cmd = "cd " + gitDir + ";git pull origin master "; + proc = os.popen(cmd); + exitCode = proc.wait(); + if (exitCode !== 0){ + throw new Error("Could not update the bundle repository: " + + bundleRepo + "\nResults of shell commands \n" + + proc.stderr.read()); + } +} //loop through repos //check that it exists, if not create it and clone it @@ -64,11 +90,15 @@ print(tag); //if tag doesn't exist, delete all files except .git + + +//check that build dir exists, if not create it + //after loop, copy all files except the .git ones to build directory //delete empty directories starting w/ "karma-" //delete unneeded directories like tests, docs - +//for each entry in the lessons directory, create hyperlink in index.html //delete all tmp files from editors diff --git a/examples/Conozco-Uruguay/js/lesson.js b/examples/Conozco-Uruguay/js/lesson.js index 5e8e890..b1ea740 100755 --- a/examples/Conozco-Uruguay/js/lesson.js +++ b/examples/Conozco-Uruguay/js/lesson.js @@ -2,19 +2,10 @@ $(document).ready( function(){ var k = Karma({ svg :[ - {name:'capitals', domId: 'capitals'}, - {name:'alien', domId: 'alien'}, - {name:'spaceship', domId: 'spaceship'}, - {name: 'help', domId: 'helpScreen'}, - {name:'playAgain', domId:'playAgain'}, - {name:'helpIcon', domId:'helpIcon'}, - {name:'quitIcon', domId:'quitIcon'} - ], - audio:[ - {name:'correct', file:'correct.ogg'}, - {name:'incorrect', file:'incorrect.ogg'} + {name:'crossword', domId: 'crossword'}, ] - }); + + }); k.ready(function() { //Program constants |