{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/comments/83231240","pull_request_review_id":4086638,"id":83231240,"diff_hunk":"@@ -0,0 +1,138 @@\n+#!/usr/bin/env node\n+\"use strict\";\n+\n+const latestVersion = \"v\" + require('../../package.json').version;\n+const path = require('path');\n+const fs = require('fs');\n+const yuidoc = require('./yuidoc');\n+const NodeGit = require('nodegit');\n+const util = require('util');\n+const fsExtra = require('fs-extra');\n+\n+let repo;\n+let options = {\n+  apiDirRelPath: path.join('docs', 'api'),\n+  srcDirRelPath: path.join('docs', 'src'),\n+  checkoutStrategy: ( NodeGit.Checkout.STRATEGY.FORCE + NodeGit.Checkout.STRATEGY.DONT_WRITE_INDEX ),\n+}\n+\n+function checkoutSrcDirectories() {\n+  console.info('info:', 'Getting all references within the repo');\n+  return repo.getReferences(NodeGit.Reference.TYPE.OID).then(references => {\n+    console.info('info:', 'Picking objects for each requested references');\n+    const foundReferences = references.filter(reference => {\n+      if(options.requestedLatest && latestVersion == reference.shorthand()) {\n+        return true;\n+      }\n+\n+      if(options.requestedReferenceNames.indexOf(reference.shorthand()) != -1) {\n+        return true;\n+      }\n+\n+      return false;\n+    });\n+\n+    const foundNames = foundReferences.map(reference => reference.shorthand()).join(', ');\n+\n+    console.info('info:', 'Found', foundReferences.length, 'references', '(', foundNames, ')');\n+\n+    if(!foundReferences.length) {\n+      throw(new Error('No reference found or can be checked out'));\n+    }\n+\n+    const apiDocsMeta = [];\n+\n+    return foundReferences.reduce((promise, reference) => {\n+      let name = reference.shorthand();\n+\n+      return promise.then(() => {\n+        return reference.peel(NodeGit.Object.TYPE.COMMIT);\n+      }).then(object => {\n+        return repo.getCommit(object.id());\n+      }).then(commit => {\n+        console.info('\\ninfo:', 'Getting tree for', name);\n+\n+        return commit.getTree();\n+      }).then(tree => {\n+        let apiName = name;\n+\n+        if(options.requestedLatest && name == latestVersion) {\n+          apiName = '';\n+        }\n+\n+        const srcRelativePath = path.join(options.srcDirRelPath, name);\n+        const srcFullPath = path.join(repo.workdir(), srcRelativePath);\n+        const apiRelativePath = path.join(options.apiDirRelPath, apiName);\n+        const checkoutOptions = {\n+          checkoutStrategy: options.checkoutStrategy,\n+          paths: 'src',\n+          targetDirectory: srcFullPath\n+        };\n+\n+        if (fs.existsSync(srcFullPath)) {\n+          fsExtra.removeSync(srcFullPath);\n+        }\n+\n+        fsExtra.mkdirsSync(srcFullPath);\n+\n+        apiDocsMeta.push({\n+          version: name,\n+          srcFullPath: srcFullPath,\n+          srcRelativePath: srcRelativePath,\n+          apiPath: apiRelativePath\n+        });\n+\n+        console.info('info:', 'Checking out', name);\n+        return NodeGit.Checkout.tree(repo, tree, checkoutOptions);\n+      })\n+    }, Promise.resolve()).then(() => apiDocsMeta);\n+  });\n+}\n+\n+function copySrcDirectory() {\n+  const version = latestVersion;\n+  const srcFullPath = path.join(process.cwd(), options.srcDirRelPath);\n+\n+  fsExtra.copySync('./src', path.join(srcFullPath, 'src'));\n+\n+  return Promise.resolve([{\n+    version: version,\n+    srcFullPath: srcFullPath,\n+    srcRelativePath: options.srcDirRelPath,\n+    apiPath: options.apiDirRelPath\n+  }]);\n+}\n+\n+function generateYUIDoc(apiDocsMeta) {\n+  console.info('\\ninfo:', 'Generating API docs');\n+  return yuidoc.generate(apiDocsMeta).then(() => {\n+    return apiDocsMeta;\n+  });\n+}\n+\n+function deleteSrcDirectories() {\n+  console.info('\\ninfo:', 'Deleting SRC directories');\n+  return Promise.resolve().then(() => {\n+      fsExtra.removeSync(options.srcDirRelPath);","path":"scripts/util/doc-builder.js","position":116,"original_position":116,"commit_id":"928bbb33a550fe6e9a64cbe5cce68b2ebd57fff2","original_commit_id":"928bbb33a550fe6e9a64cbe5cce68b2ebd57fff2","user":{"login":"minasmart","id":568174,"avatar_url":"https://avatars.githubusercontent.com/u/568174?v=3","gravatar_id":"","url":"https://api.github.com/users/minasmart","html_url":"https://github.com/minasmart","followers_url":"https://api.github.com/users/minasmart/followers","following_url":"https://api.github.com/users/minasmart/following{/other_user}","gists_url":"https://api.github.com/users/minasmart/gists{/gist_id}","starred_url":"https://api.github.com/users/minasmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minasmart/subscriptions","organizations_url":"https://api.github.com/users/minasmart/orgs","repos_url":"https://api.github.com/users/minasmart/repos","events_url":"https://api.github.com/users/minasmart/events{/privacy}","received_events_url":"https://api.github.com/users/minasmart/received_events","type":"User","site_admin":false},"body":"weird indentation.","created_at":"2016-10-13T14:39:19Z","updated_at":"2016-10-13T14:40:06Z","html_url":"https://github.com/Shopify/js-buy-sdk/pull/205#discussion_r83231240","pull_request_url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205","_links":{"self":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/comments/83231240"},"html":{"href":"https://github.com/Shopify/js-buy-sdk/pull/205#discussion_r83231240"},"pull_request":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205","id":83160148,"html_url":"https://github.com/Shopify/js-buy-sdk/pull/205","diff_url":"https://github.com/Shopify/js-buy-sdk/pull/205.diff","patch_url":"https://github.com/Shopify/js-buy-sdk/pull/205.patch","issue_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/205","number":205,"state":"open","locked":false,"title":"Rewrite API docs generation script into javascript from shell script","user":{"login":"yomexzo","id":3056958,"avatar_url":"https://avatars.githubusercontent.com/u/3056958?v=3","gravatar_id":"","url":"https://api.github.com/users/yomexzo","html_url":"https://github.com/yomexzo","followers_url":"https://api.github.com/users/yomexzo/followers","following_url":"https://api.github.com/users/yomexzo/following{/other_user}","gists_url":"https://api.github.com/users/yomexzo/gists{/gist_id}","starred_url":"https://api.github.com/users/yomexzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yomexzo/subscriptions","organizations_url":"https://api.github.com/users/yomexzo/orgs","repos_url":"https://api.github.com/users/yomexzo/repos","events_url":"https://api.github.com/users/yomexzo/events{/privacy}","received_events_url":"https://api.github.com/users/yomexzo/received_events","type":"User","site_admin":false},"body":"This a continuation of the work at #199 but with a cleaner commit history.\r\n\r\nIt's also part of the docs road map at #202.\r\n\r\n### What it is\r\nThis PR removes the current shell script used to generate docs and replaces it with npm script that allows you to generate docs for any of the published JS-Buy-SDK versions on your machine.\r\n\r\n### Command\r\n`npm run build-doc -- [--references comma-seperated-list-of-tag-or-branch-names]`\r\n\r\n`--references` option defaults to `current` when not specified. API docs for the current version (gotten from `package.json`) is created into `/docs/api/current`.\r\n\r\n### Example usage\r\n`npm run build-doc -- --references master` generates API docs for the `master` branch.\r\n`npm run build-doc -- --references v0.2.2,v0.2.1` generates API docs for the `v0.2.2` and `v0.2.1` tags.\r\n\r\n👀 @minasmart, @mikkoh, @Shopify/javascript","created_at":"2016-08-29T20:16:17Z","updated_at":"2016-10-13T14:40:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d99cec947ce1ac3fb4ecd60eb88ac3fc56c5973","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205/commits","review_comments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205/comments","review_comment_url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/205/comments","statuses_url":"https://api.github.com/repos/Shopify/js-buy-sdk/statuses/928bbb33a550fe6e9a64cbe5cce68b2ebd57fff2","head":{"label":"Shopify:feature/docs","ref":"feature/docs","sha":"928bbb33a550fe6e9a64cbe5cce68b2ebd57fff2","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":49018115,"name":"js-buy-sdk","full_name":"Shopify/js-buy-sdk","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/js-buy-sdk","description":"The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.","fork":false,"url":"https://api.github.com/repos/Shopify/js-buy-sdk","forks_url":"https://api.github.com/repos/Shopify/js-buy-sdk/forks","keys_url":"https://api.github.com/repos/Shopify/js-buy-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/js-buy-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/js-buy-sdk/teams","hooks_url":"https://api.github.com/repos/Shopify/js-buy-sdk/hooks","issue_events_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/js-buy-sdk/events","assignees_url":"https://api.github.com/repos/Shopify/js-buy-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/js-buy-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/js-buy-sdk/tags","blobs_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/js-buy-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/js-buy-sdk/languages","stargazers_url":"https://api.github.com/repos/Shopify/js-buy-sdk/stargazers","contributors_url":"https://api.github.com/repos/Shopify/js-buy-sdk/contributors","subscribers_url":"https://api.github.com/repos/Shopify/js-buy-sdk/subscribers","subscription_url":"https://api.github.com/repos/Shopify/js-buy-sdk/subscription","commits_url":"https://api.github.com/repos/Shopify/js-buy-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/js-buy-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/js-buy-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/js-buy-sdk/merges","archive_url":"https://api.github.com/repos/Shopify/js-buy-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/js-buy-sdk/downloads","issues_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/js-buy-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/js-buy-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/js-buy-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/js-buy-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/deployments","created_at":"2016-01-04T19:26:34Z","updated_at":"2016-10-13T12:02:53Z","pushed_at":"2016-10-12T21:56:57Z","git_url":"git://github.com/Shopify/js-buy-sdk.git","ssh_url":"git@github.com:Shopify/js-buy-sdk.git","clone_url":"https://github.com/Shopify/js-buy-sdk.git","svn_url":"https://github.com/Shopify/js-buy-sdk","homepage":"https://shopify.github.io/js-buy-sdk","size":1829,"stargazers_count":142,"watchers_count":142,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":39,"mirror_url":null,"open_issues_count":37,"forks":39,"open_issues":37,"watchers":142,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"5e29fc1239462bed676da2cbb011ebc7025c3a3a","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":49018115,"name":"js-buy-sdk","full_name":"Shopify/js-buy-sdk","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/js-buy-sdk","description":"The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.","fork":false,"url":"https://api.github.com/repos/Shopify/js-buy-sdk","forks_url":"https://api.github.com/repos/Shopify/js-buy-sdk/forks","keys_url":"https://api.github.com/repos/Shopify/js-buy-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/js-buy-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/js-buy-sdk/teams","hooks_url":"https://api.github.com/repos/Shopify/js-buy-sdk/hooks","issue_events_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/js-buy-sdk/events","assignees_url":"https://api.github.com/repos/Shopify/js-buy-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/js-buy-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/js-buy-sdk/tags","blobs_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/js-buy-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/js-buy-sdk/languages","stargazers_url":"https://api.github.com/repos/Shopify/js-buy-sdk/stargazers","contributors_url":"https://api.github.com/repos/Shopify/js-buy-sdk/contributors","subscribers_url":"https://api.github.com/repos/Shopify/js-buy-sdk/subscribers","subscription_url":"https://api.github.com/repos/Shopify/js-buy-sdk/subscription","commits_url":"https://api.github.com/repos/Shopify/js-buy-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/js-buy-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/js-buy-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/js-buy-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/js-buy-sdk/merges","archive_url":"https://api.github.com/repos/Shopify/js-buy-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/js-buy-sdk/downloads","issues_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/js-buy-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/js-buy-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/js-buy-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/js-buy-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/deployments","created_at":"2016-01-04T19:26:34Z","updated_at":"2016-10-13T12:02:53Z","pushed_at":"2016-10-12T21:56:57Z","git_url":"git://github.com/Shopify/js-buy-sdk.git","ssh_url":"git@github.com:Shopify/js-buy-sdk.git","clone_url":"https://github.com/Shopify/js-buy-sdk.git","svn_url":"https://github.com/Shopify/js-buy-sdk","homepage":"https://shopify.github.io/js-buy-sdk","size":1829,"stargazers_count":142,"watchers_count":142,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":39,"mirror_url":null,"open_issues_count":37,"forks":39,"open_issues":37,"watchers":142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205"},"html":{"href":"https://github.com/Shopify/js-buy-sdk/pull/205"},"issue":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/205"},"comments":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/205/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/pulls/205/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/js-buy-sdk/statuses/928bbb33a550fe6e9a64cbe5cce68b2ebd57fff2"}}}}
{"actor":{"display_login":"minasmart"}}