{"action":"created","comment":{"url":"https://api.github.com/repos/radicaled/dart-tools/pulls/comments/31399400","id":31399400,"diff_hunk":"@@ -0,0 +1,86 @@\n+spawn = require('child_process').spawn\n+SdkService = require '../sdk/sdk_service'\n+Picker = require '../ui/picker'\n+path = require 'path'\n+\n+# Stagehand support\n+class Stagehand\n+  @activate: =>\n+    return new Promise (resolve, reject) =>\n+      cmd  = SdkService.getCommandPath 'pub'\n+      args = ['global', 'activate', 'stagehand']\n+      errors = ''\n+\n+      process = spawn cmd, args\n+      process.stderr.on 'data', (data) =>\n+        errors = errors + data.toString()\n+      process.on 'exit', (code) =>\n+        if code is 0\n+          resolve()\n+        else\n+          reject(errors)\n+\n+  @getProjectTemplates: =>\n+    return new Promise (resolve, reject) =>\n+      cmd  = SdkService.getCommandPath 'pub'\n+      args = ['global', 'run', 'stagehand', '--machine']\n+      errors = ''\n+      json = ''\n+\n+      process = spawn cmd, args\n+      process.stdout.on 'data', (data) =>\n+        json = json + data.toString()\n+      process.stderr.on 'data', (data) =>\n+        errors = errors + data.toString()\n+      process.on 'exit', (code) =>\n+        if code is 0\n+          resolve(JSON.parse(json))\n+        else\n+          reject(errors)\n+\n+  @showProjectTemplates: =>\n+    picker = new Picker\n+    @getProjectTemplates().then (projectTemplates) =>\n+      items = projectTemplates.map (pt) =>\n+        {item: pt, displayName: pt.label, description: pt.description}\n+\n+      return picker.selectFrom(items)\n+\n+  @generate: (projectTemplate) =>\n+    picker = new Picker\n+    projectPaths  = atom.project.getPaths()\n+    generateProject = (projectPath) =>\n+      atom.notifications.addInfo \"[dart-tools] Generating #{projectTemplate.label}.\"\n+\n+      cmd  = SdkService.getCommandPath 'pub'\n+      args = ['global', 'run', 'stagehand', projectTemplate.name]\n+      errors = ''\n+      output = ''\n+\n+      process = spawn cmd, args,\n+        cwd: projectPath\n+      process.stdout.on 'data', (data) =>\n+        output = output + data.toString()\n+      process.stderr.on 'data', (data) =>\n+        errors = errors + data.toString()\n+      process.on 'exit', (code) =>\n+        if code is 0\n+          atom.notifications.addInfo \"[dart-tools] Generated #{projectTemplate.label}!\"\n+        else\n+          atom.notifications.addError \"[dart-tools] Failed to generate #{projectTemplate.label}!\",\n+            detail: errors or output\n+\n+    if projectPaths.length is 0\n+      atom.notifications.addError \"[dart-tools] Cannot run Stagehand without a project directory open.\"","path":"lib/stagehand/stagehand.coffee","position":74,"original_position":74,"commit_id":"adc71191416f8a77b8d44a4149193989ef31a094","original_commit_id":"adc71191416f8a77b8d44a4149193989ef31a094","user":{"login":"radicaled","id":40635,"avatar_url":"https://avatars.githubusercontent.com/u/40635?v=3","gravatar_id":"","url":"https://api.github.com/users/radicaled","html_url":"https://github.com/radicaled","followers_url":"https://api.github.com/users/radicaled/followers","following_url":"https://api.github.com/users/radicaled/following{/other_user}","gists_url":"https://api.github.com/users/radicaled/gists{/gist_id}","starred_url":"https://api.github.com/users/radicaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radicaled/subscriptions","organizations_url":"https://api.github.com/users/radicaled/orgs","repos_url":"https://api.github.com/users/radicaled/repos","events_url":"https://api.github.com/users/radicaled/events{/privacy}","received_events_url":"https://api.github.com/users/radicaled/received_events","type":"User","site_admin":false},"body":">  Are we requiring there to be a project open to run stagehand?\r\n\r\nIn Atom a project is just a set of directories that is open inside of Atom, so we're requiring the user have at least one directory open in the project before continuing. By default if you open Atom, it's rooted in the home directory, so if you asked a user to type a relative path to the location to run Stagehand it's very possible they might fatfinger \"Projects/dart/cool-new-webapp\" into \"Proects/dart/cool-new-webapp\", so I thought it would be safer to leave the directory creation to something with tab-complete like Advanced New File, or just doing it through the Atom GUI.","created_at":"2015-06-01T03:37:18Z","updated_at":"2015-06-01T03:37:18Z","html_url":"https://github.com/radicaled/dart-tools/pull/78#discussion_r31399400","pull_request_url":"https://api.github.com/repos/radicaled/dart-tools/pulls/78","_links":{"self":{"href":"https://api.github.com/repos/radicaled/dart-tools/pulls/comments/31399400"},"html":{"href":"https://github.com/radicaled/dart-tools/pull/78#discussion_r31399400"},"pull_request":{"href":"https://api.github.com/repos/radicaled/dart-tools/pulls/78"}}},"pull_request":{"url":"https://api.github.com/repos/radicaled/dart-tools/pulls/78","id":36576760,"html_url":"https://github.com/radicaled/dart-tools/pull/78","diff_url":"https://github.com/radicaled/dart-tools/pull/78.diff","patch_url":"https://github.com/radicaled/dart-tools/pull/78.patch","issue_url":"https://api.github.com/repos/radicaled/dart-tools/issues/78","number":78,"state":"open","locked":false,"title":"Stagehand","user":{"login":"radicaled","id":40635,"avatar_url":"https://avatars.githubusercontent.com/u/40635?v=3","gravatar_id":"","url":"https://api.github.com/users/radicaled","html_url":"https://github.com/radicaled","followers_url":"https://api.github.com/users/radicaled/followers","following_url":"https://api.github.com/users/radicaled/following{/other_user}","gists_url":"https://api.github.com/users/radicaled/gists{/gist_id}","starred_url":"https://api.github.com/users/radicaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radicaled/subscriptions","organizations_url":"https://api.github.com/users/radicaled/orgs","repos_url":"https://api.github.com/users/radicaled/repos","events_url":"https://api.github.com/users/radicaled/events{/privacy}","received_events_url":"https://api.github.com/users/radicaled/received_events","type":"User","site_admin":false},"body":"Stagehand support.\r\n\r\nKinda slow -- it runs \"pub global activate stagehand\" every time, since I don't know how to detect if Stagehand is available without just trying to run it before hand.","created_at":"2015-05-31T04:30:43Z","updated_at":"2015-06-01T03:37:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"768950b0ac80b80b29278b734dc5521eced8cbe4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/radicaled/dart-tools/pulls/78/commits","review_comments_url":"https://api.github.com/repos/radicaled/dart-tools/pulls/78/comments","review_comment_url":"https://api.github.com/repos/radicaled/dart-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/radicaled/dart-tools/issues/78/comments","statuses_url":"https://api.github.com/repos/radicaled/dart-tools/statuses/adc71191416f8a77b8d44a4149193989ef31a094","head":{"label":"radicaled:stagehand","ref":"stagehand","sha":"adc71191416f8a77b8d44a4149193989ef31a094","user":{"login":"radicaled","id":40635,"avatar_url":"https://avatars.githubusercontent.com/u/40635?v=3","gravatar_id":"","url":"https://api.github.com/users/radicaled","html_url":"https://github.com/radicaled","followers_url":"https://api.github.com/users/radicaled/followers","following_url":"https://api.github.com/users/radicaled/following{/other_user}","gists_url":"https://api.github.com/users/radicaled/gists{/gist_id}","starred_url":"https://api.github.com/users/radicaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radicaled/subscriptions","organizations_url":"https://api.github.com/users/radicaled/orgs","repos_url":"https://api.github.com/users/radicaled/repos","events_url":"https://api.github.com/users/radicaled/events{/privacy}","received_events_url":"https://api.github.com/users/radicaled/received_events","type":"User","site_admin":false},"repo":{"id":21885799,"name":"dart-tools","full_name":"radicaled/dart-tools","owner":{"login":"radicaled","id":40635,"avatar_url":"https://avatars.githubusercontent.com/u/40635?v=3","gravatar_id":"","url":"https://api.github.com/users/radicaled","html_url":"https://github.com/radicaled","followers_url":"https://api.github.com/users/radicaled/followers","following_url":"https://api.github.com/users/radicaled/following{/other_user}","gists_url":"https://api.github.com/users/radicaled/gists{/gist_id}","starred_url":"https://api.github.com/users/radicaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radicaled/subscriptions","organizations_url":"https://api.github.com/users/radicaled/orgs","repos_url":"https://api.github.com/users/radicaled/repos","events_url":"https://api.github.com/users/radicaled/events{/privacy}","received_events_url":"https://api.github.com/users/radicaled/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/radicaled/dart-tools","description":"Various tools for Dart in Atom","fork":false,"url":"https://api.github.com/repos/radicaled/dart-tools","forks_url":"https://api.github.com/repos/radicaled/dart-tools/forks","keys_url":"https://api.github.com/repos/radicaled/dart-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radicaled/dart-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radicaled/dart-tools/teams","hooks_url":"https://api.github.com/repos/radicaled/dart-tools/hooks","issue_events_url":"https://api.github.com/repos/radicaled/dart-tools/issues/events{/number}","events_url":"https://api.github.com/repos/radicaled/dart-tools/events","assignees_url":"https://api.github.com/repos/radicaled/dart-tools/assignees{/user}","branches_url":"https://api.github.com/repos/radicaled/dart-tools/branches{/branch}","tags_url":"https://api.github.com/repos/radicaled/dart-tools/tags","blobs_url":"https://api.github.com/repos/radicaled/dart-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radicaled/dart-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radicaled/dart-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/radicaled/dart-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radicaled/dart-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/radicaled/dart-tools/languages","stargazers_url":"https://api.github.com/repos/radicaled/dart-tools/stargazers","contributors_url":"https://api.github.com/repos/radicaled/dart-tools/contributors","subscribers_url":"https://api.github.com/repos/radicaled/dart-tools/subscribers","subscription_url":"https://api.github.com/repos/radicaled/dart-tools/subscription","commits_url":"https://api.github.com/repos/radicaled/dart-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/radicaled/dart-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/radicaled/dart-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/radicaled/dart-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/radicaled/dart-tools/contents/{+path}","compare_url":"https://api.github.com/repos/radicaled/dart-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radicaled/dart-tools/merges","archive_url":"https://api.github.com/repos/radicaled/dart-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radicaled/dart-tools/downloads","issues_url":"https://api.github.com/repos/radicaled/dart-tools/issues{/number}","pulls_url":"https://api.github.com/repos/radicaled/dart-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/radicaled/dart-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/radicaled/dart-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radicaled/dart-tools/labels{/name}","releases_url":"https://api.github.com/repos/radicaled/dart-tools/releases{/id}","created_at":"2014-07-16T03:52:54Z","updated_at":"2015-05-29T03:43:01Z","pushed_at":"2015-05-31T04:32:06Z","git_url":"git://github.com/radicaled/dart-tools.git","ssh_url":"git@github.com:radicaled/dart-tools.git","clone_url":"https://github.com/radicaled/dart-tools.git","svn_url":"https://github.com/radicaled/dart-tools","homepage":null,"size":1934,"stargazers_count":20,"watchers_count":20,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":16,"forks":4,"open_issues":16,"watchers":20,"default_branch":"master"}},"base":{"label":"radicaled:master","ref":"master","sha":"a40eb962efc99aebb8e48ca88ba00b29ea43197a","user":{"login":"radicaled","id":40635,"avatar_url":"https://avatars.githubusercontent.com/u/40635?v=3","gravatar_id":"","url":"https://api.github.com/users/radicaled","html_url":"https://github.com/radicaled","followers_url":"https://api.github.com/users/radicaled/followers","following_url":"https://api.github.com/users/radicaled/following{/other_user}","gists_url":"https://api.github.com/users/radicaled/gists{/gist_id}","starred_url":"https://api.github.com/users/radicaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radicaled/subscriptions","organizations_url":"https://api.github.com/users/radicaled/orgs","repos_url":"https://api.github.com/users/radicaled/repos","events_url":"https://api.github.com/users/radicaled/events{/privacy}","received_events_url":"https://api.github.com/users/radicaled/received_events","type":"User","site_admin":false},"repo":{"id":21885799,"name":"dart-tools","full_name":"radicaled/dart-tools","owner":{"login":"radicaled","id":40635,"avatar_url":"https://avatars.githubusercontent.com/u/40635?v=3","gravatar_id":"","url":"https://api.github.com/users/radicaled","html_url":"https://github.com/radicaled","followers_url":"https://api.github.com/users/radicaled/followers","following_url":"https://api.github.com/users/radicaled/following{/other_user}","gists_url":"https://api.github.com/users/radicaled/gists{/gist_id}","starred_url":"https://api.github.com/users/radicaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radicaled/subscriptions","organizations_url":"https://api.github.com/users/radicaled/orgs","repos_url":"https://api.github.com/users/radicaled/repos","events_url":"https://api.github.com/users/radicaled/events{/privacy}","received_events_url":"https://api.github.com/users/radicaled/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/radicaled/dart-tools","description":"Various tools for Dart in Atom","fork":false,"url":"https://api.github.com/repos/radicaled/dart-tools","forks_url":"https://api.github.com/repos/radicaled/dart-tools/forks","keys_url":"https://api.github.com/repos/radicaled/dart-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radicaled/dart-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radicaled/dart-tools/teams","hooks_url":"https://api.github.com/repos/radicaled/dart-tools/hooks","issue_events_url":"https://api.github.com/repos/radicaled/dart-tools/issues/events{/number}","events_url":"https://api.github.com/repos/radicaled/dart-tools/events","assignees_url":"https://api.github.com/repos/radicaled/dart-tools/assignees{/user}","branches_url":"https://api.github.com/repos/radicaled/dart-tools/branches{/branch}","tags_url":"https://api.github.com/repos/radicaled/dart-tools/tags","blobs_url":"https://api.github.com/repos/radicaled/dart-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radicaled/dart-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radicaled/dart-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/radicaled/dart-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radicaled/dart-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/radicaled/dart-tools/languages","stargazers_url":"https://api.github.com/repos/radicaled/dart-tools/stargazers","contributors_url":"https://api.github.com/repos/radicaled/dart-tools/contributors","subscribers_url":"https://api.github.com/repos/radicaled/dart-tools/subscribers","subscription_url":"https://api.github.com/repos/radicaled/dart-tools/subscription","commits_url":"https://api.github.com/repos/radicaled/dart-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/radicaled/dart-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/radicaled/dart-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/radicaled/dart-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/radicaled/dart-tools/contents/{+path}","compare_url":"https://api.github.com/repos/radicaled/dart-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radicaled/dart-tools/merges","archive_url":"https://api.github.com/repos/radicaled/dart-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radicaled/dart-tools/downloads","issues_url":"https://api.github.com/repos/radicaled/dart-tools/issues{/number}","pulls_url":"https://api.github.com/repos/radicaled/dart-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/radicaled/dart-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/radicaled/dart-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radicaled/dart-tools/labels{/name}","releases_url":"https://api.github.com/repos/radicaled/dart-tools/releases{/id}","created_at":"2014-07-16T03:52:54Z","updated_at":"2015-05-29T03:43:01Z","pushed_at":"2015-05-31T04:32:06Z","git_url":"git://github.com/radicaled/dart-tools.git","ssh_url":"git@github.com:radicaled/dart-tools.git","clone_url":"https://github.com/radicaled/dart-tools.git","svn_url":"https://github.com/radicaled/dart-tools","homepage":null,"size":1934,"stargazers_count":20,"watchers_count":20,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":16,"forks":4,"open_issues":16,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/radicaled/dart-tools/pulls/78"},"html":{"href":"https://github.com/radicaled/dart-tools/pull/78"},"issue":{"href":"https://api.github.com/repos/radicaled/dart-tools/issues/78"},"comments":{"href":"https://api.github.com/repos/radicaled/dart-tools/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/radicaled/dart-tools/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/radicaled/dart-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/radicaled/dart-tools/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/radicaled/dart-tools/statuses/adc71191416f8a77b8d44a4149193989ef31a094"}}}}