{"action":"created","comment":{"url":"https://api.github.com/repos/pebble/rockyjs/pulls/comments/50287349","id":50287349,"diff_hunk":"@@ -0,0 +1,106 @@\n+module.exports = function(grunt) {\n+\n+    // location of our temporary working copy we use to build tags\n+    var tempCheckout = 'temp/checkout';\n+\n+    // register a few promise related convenience functions\n+    var exec = require('./utils')(grunt).exec;\n+\n+    var Q = require(\"q\");\n+    var fs = require('fs');\n+    var simpleGit = require(\"simple-git\");\n+\n+    // rocky.js filename for a given version\n+    function rockyNameForTag(version) {\n+        return 'build/dist/rocky-' + version + '.js';\n+    }\n+\n+    // true, if a versioned rocky file exists in the destination folder\n+    function versionedRockyExists(tag) {\n+        try {\n+            return fs.statSync(rockyNameForTag(tag)).isFile();\n+        } catch (err) {\n+            return false;\n+        }\n+    }\n+\n+    // creates a promise that expresses all steps for a given tag\n+    function checkoutNpmBuildCopy(tag) {\n+        return simpleGit(tempCheckout).promising('checkout', tag)\n+        .then(function() {\n+            return exec('npm install', {cwd: tempCheckout});\n+        })\n+        .then(function() {\n+            return exec('grunt build', {cwd:tempCheckout});\n+        })\n+        .then(function() {\n+            var taggedPkg = grunt.file.readJSON(tempCheckout + '/package.json');\n+            var destName = rockyNameForTag(taggedPkg.version);\n+            if (versionedRockyExists(taggedPkg.version)) {\n+                grunt.log.warn(\"skipping file\", destName, \"Tag\", tag, \"seems to be named incorrectly.\");\n+                return false;\n+            }\n+            return exec('cp ' + tempCheckout + '/' + destName + ' ' + destName);\n+        });\n+    }\n+\n+    // actual grunt task\n+    var desc = 'Checks out and builds tags from remote repository and copies versioned output to ./build/dist';\n+    grunt.registerTask('build-missing-dists', desc, function() {\n+        var done = this.async();\n+\n+        // delete temp folder\n+        exec( 'rm -rf ' + tempCheckout)\n+        // checkout Rocky.js repo into temp folder\n+        .then(function() {\n+            var url = grunt.file.readJSON('package.json').repository.url;\n+            grunt.verbose.writeln('cloning', url, 'into', tempCheckout);\n+            return simpleGit('.').promising(\"clone\", url, tempCheckout);\n+        })\n+        // checkout gh-pages and copy all missing rocky-x.y.z.js from its dist folder to build/dist\n+        // we do this so that we will have gh-pages' dist folder + this working copy's rocky.js\n+        .then(function() {\n+            return simpleGit(tempCheckout).promising('checkout', 'gh-pages');\n+        })\n+        .then(function() {\n+            // copy all rocky.js files from gh-pages' dist into this working copy's build folder, but\n+            // preserve existing files in build/dist (presumably only the one we built from this working copy before)\n+            return exec('cp -n ' + tempCheckout + '/dist/*.js build/dist')\n+                   .catch(function(){return \"this is fine since cp -n returns 1 if there was a file already.\"});","path":"tasks/dist.js","position":82,"original_position":69,"commit_id":"e34eeaf0660e9036950dfcf9b824655ecb6ced1b","original_commit_id":"4199d75c4f8760411f99e1fe977b6c79e5f915c3","user":{"login":"HBehrens","id":486904,"avatar_url":"https://avatars.githubusercontent.com/u/486904?v=3","gravatar_id":"","url":"https://api.github.com/users/HBehrens","html_url":"https://github.com/HBehrens","followers_url":"https://api.github.com/users/HBehrens/followers","following_url":"https://api.github.com/users/HBehrens/following{/other_user}","gists_url":"https://api.github.com/users/HBehrens/gists{/gist_id}","starred_url":"https://api.github.com/users/HBehrens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HBehrens/subscriptions","organizations_url":"https://api.github.com/users/HBehrens/orgs","repos_url":"https://api.github.com/users/HBehrens/repos","events_url":"https://api.github.com/users/HBehrens/events{/privacy}","received_events_url":"https://api.github.com/users/HBehrens/received_events","type":"User","site_admin":false},"body":"This looks terrible! What about this: I keep it as it is and you create a PR that bumps the node version and replaces this cumbersome snippets with `yield` + promises?","created_at":"2016-01-20T17:24:17Z","updated_at":"2016-01-20T17:24:17Z","html_url":"https://github.com/pebble/rockyjs/pull/30#discussion_r50287349","pull_request_url":"https://api.github.com/repos/pebble/rockyjs/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/pebble/rockyjs/pulls/comments/50287349"},"html":{"href":"https://github.com/pebble/rockyjs/pull/30#discussion_r50287349"},"pull_request":{"href":"https://api.github.com/repos/pebble/rockyjs/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/pebble/rockyjs/pulls/30","id":56567035,"html_url":"https://github.com/pebble/rockyjs/pull/30","diff_url":"https://github.com/pebble/rockyjs/pull/30.diff","patch_url":"https://github.com/pebble/rockyjs/pull/30.patch","issue_url":"https://api.github.com/repos/pebble/rockyjs/issues/30","number":30,"state":"open","locked":false,"title":"PBL-32068 Remove dist folder and let travis manage it on gh-pages","user":{"login":"HBehrens","id":486904,"avatar_url":"https://avatars.githubusercontent.com/u/486904?v=3","gravatar_id":"","url":"https://api.github.com/users/HBehrens","html_url":"https://github.com/HBehrens","followers_url":"https://api.github.com/users/HBehrens/followers","following_url":"https://api.github.com/users/HBehrens/following{/other_user}","gists_url":"https://api.github.com/users/HBehrens/gists{/gist_id}","starred_url":"https://api.github.com/users/HBehrens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HBehrens/subscriptions","organizations_url":"https://api.github.com/users/HBehrens/orgs","repos_url":"https://api.github.com/users/HBehrens/repos","events_url":"https://api.github.com/users/HBehrens/events{/privacy}","received_events_url":"https://api.github.com/users/HBehrens/received_events","type":"User","site_admin":false},"body":"- creates new grunt task `build-missing-diets` to update `build/dist` based on remote tags\r\n- configures travis to call this each time (as part of a new `pre-publish` task) it rebuilds the static page\r\n- remove dist folder and change grunt tasks to directly build into `build/dist`\r\n\r\nI also introduced a new `tasks` folder that contains this new task + a few convenience functions to deal with promises. The idea is to continue to use this for future tasks and also to clean up today's `Grunfile.js` whenever we find the time.","created_at":"2016-01-20T05:53:36Z","updated_at":"2016-01-20T17:24:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"863848a4a4511425b973641a9dd368aaf6e7c2e6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pebble/rockyjs/pulls/30/commits","review_comments_url":"https://api.github.com/repos/pebble/rockyjs/pulls/30/comments","review_comment_url":"https://api.github.com/repos/pebble/rockyjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pebble/rockyjs/issues/30/comments","statuses_url":"https://api.github.com/repos/pebble/rockyjs/statuses/e34eeaf0660e9036950dfcf9b824655ecb6ced1b","head":{"label":"pebble:PBL-32068-dist_folder","ref":"PBL-32068-dist_folder","sha":"e34eeaf0660e9036950dfcf9b824655ecb6ced1b","user":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"repo":{"id":48650252,"name":"rockyjs","full_name":"pebble/rockyjs","owner":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pebble/rockyjs","description":"JS Powered Pebbles in Your Browser","fork":false,"url":"https://api.github.com/repos/pebble/rockyjs","forks_url":"https://api.github.com/repos/pebble/rockyjs/forks","keys_url":"https://api.github.com/repos/pebble/rockyjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pebble/rockyjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pebble/rockyjs/teams","hooks_url":"https://api.github.com/repos/pebble/rockyjs/hooks","issue_events_url":"https://api.github.com/repos/pebble/rockyjs/issues/events{/number}","events_url":"https://api.github.com/repos/pebble/rockyjs/events","assignees_url":"https://api.github.com/repos/pebble/rockyjs/assignees{/user}","branches_url":"https://api.github.com/repos/pebble/rockyjs/branches{/branch}","tags_url":"https://api.github.com/repos/pebble/rockyjs/tags","blobs_url":"https://api.github.com/repos/pebble/rockyjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pebble/rockyjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pebble/rockyjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/pebble/rockyjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pebble/rockyjs/statuses/{sha}","languages_url":"https://api.github.com/repos/pebble/rockyjs/languages","stargazers_url":"https://api.github.com/repos/pebble/rockyjs/stargazers","contributors_url":"https://api.github.com/repos/pebble/rockyjs/contributors","subscribers_url":"https://api.github.com/repos/pebble/rockyjs/subscribers","subscription_url":"https://api.github.com/repos/pebble/rockyjs/subscription","commits_url":"https://api.github.com/repos/pebble/rockyjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/pebble/rockyjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/pebble/rockyjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/pebble/rockyjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/pebble/rockyjs/contents/{+path}","compare_url":"https://api.github.com/repos/pebble/rockyjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pebble/rockyjs/merges","archive_url":"https://api.github.com/repos/pebble/rockyjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pebble/rockyjs/downloads","issues_url":"https://api.github.com/repos/pebble/rockyjs/issues{/number}","pulls_url":"https://api.github.com/repos/pebble/rockyjs/pulls{/number}","milestones_url":"https://api.github.com/repos/pebble/rockyjs/milestones{/number}","notifications_url":"https://api.github.com/repos/pebble/rockyjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pebble/rockyjs/labels{/name}","releases_url":"https://api.github.com/repos/pebble/rockyjs/releases{/id}","created_at":"2015-12-27T15:39:14Z","updated_at":"2016-01-19T19:47:10Z","pushed_at":"2016-01-20T15:58:23Z","git_url":"git://github.com/pebble/rockyjs.git","ssh_url":"git@github.com:pebble/rockyjs.git","clone_url":"https://github.com/pebble/rockyjs.git","svn_url":"https://github.com/pebble/rockyjs","homepage":"http://pebble.github.io/rockyjs","size":1213,"stargazers_count":125,"watchers_count":125,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"open_issues_count":10,"forks":4,"open_issues":10,"watchers":125,"default_branch":"master"}},"base":{"label":"pebble:master","ref":"master","sha":"6e4d24be58d8adf53ce3514c22de11d772c3e604","user":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"repo":{"id":48650252,"name":"rockyjs","full_name":"pebble/rockyjs","owner":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pebble/rockyjs","description":"JS Powered Pebbles in Your Browser","fork":false,"url":"https://api.github.com/repos/pebble/rockyjs","forks_url":"https://api.github.com/repos/pebble/rockyjs/forks","keys_url":"https://api.github.com/repos/pebble/rockyjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pebble/rockyjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pebble/rockyjs/teams","hooks_url":"https://api.github.com/repos/pebble/rockyjs/hooks","issue_events_url":"https://api.github.com/repos/pebble/rockyjs/issues/events{/number}","events_url":"https://api.github.com/repos/pebble/rockyjs/events","assignees_url":"https://api.github.com/repos/pebble/rockyjs/assignees{/user}","branches_url":"https://api.github.com/repos/pebble/rockyjs/branches{/branch}","tags_url":"https://api.github.com/repos/pebble/rockyjs/tags","blobs_url":"https://api.github.com/repos/pebble/rockyjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pebble/rockyjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pebble/rockyjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/pebble/rockyjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pebble/rockyjs/statuses/{sha}","languages_url":"https://api.github.com/repos/pebble/rockyjs/languages","stargazers_url":"https://api.github.com/repos/pebble/rockyjs/stargazers","contributors_url":"https://api.github.com/repos/pebble/rockyjs/contributors","subscribers_url":"https://api.github.com/repos/pebble/rockyjs/subscribers","subscription_url":"https://api.github.com/repos/pebble/rockyjs/subscription","commits_url":"https://api.github.com/repos/pebble/rockyjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/pebble/rockyjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/pebble/rockyjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/pebble/rockyjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/pebble/rockyjs/contents/{+path}","compare_url":"https://api.github.com/repos/pebble/rockyjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pebble/rockyjs/merges","archive_url":"https://api.github.com/repos/pebble/rockyjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pebble/rockyjs/downloads","issues_url":"https://api.github.com/repos/pebble/rockyjs/issues{/number}","pulls_url":"https://api.github.com/repos/pebble/rockyjs/pulls{/number}","milestones_url":"https://api.github.com/repos/pebble/rockyjs/milestones{/number}","notifications_url":"https://api.github.com/repos/pebble/rockyjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pebble/rockyjs/labels{/name}","releases_url":"https://api.github.com/repos/pebble/rockyjs/releases{/id}","created_at":"2015-12-27T15:39:14Z","updated_at":"2016-01-19T19:47:10Z","pushed_at":"2016-01-20T15:58:23Z","git_url":"git://github.com/pebble/rockyjs.git","ssh_url":"git@github.com:pebble/rockyjs.git","clone_url":"https://github.com/pebble/rockyjs.git","svn_url":"https://github.com/pebble/rockyjs","homepage":"http://pebble.github.io/rockyjs","size":1213,"stargazers_count":125,"watchers_count":125,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"open_issues_count":10,"forks":4,"open_issues":10,"watchers":125,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pebble/rockyjs/pulls/30"},"html":{"href":"https://github.com/pebble/rockyjs/pull/30"},"issue":{"href":"https://api.github.com/repos/pebble/rockyjs/issues/30"},"comments":{"href":"https://api.github.com/repos/pebble/rockyjs/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/pebble/rockyjs/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/pebble/rockyjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pebble/rockyjs/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/pebble/rockyjs/statuses/e34eeaf0660e9036950dfcf9b824655ecb6ced1b"}}}}