{"action":"created","comment":{"url":"https://api.github.com/repos/embark-framework/embark/pulls/comments/233376007","pull_request_review_id":174772031,"id":233376007,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMzM3NjAwNw==","diff_hunk":"@@ -0,0 +1,226 @@\n+/*globals __*/\n+const env = require(\"../../core/env\");\n+const fs = require(\"../../core/fs\");\n+const utils = require(\"../../utils/utils\");\n+const EmbarkJS = require(\"embarkjs\");\n+const IpfsApi = require(\"ipfs-api\");\n+const stringify = require(\"json-stringify-safe\");\n+import Web3 from \"web3\";\n+import Suggestions from \"./suggestions\";\n+\n+declare const __: any;\n+\n+interface Events {\n+  on: any;\n+  request: any;\n+  emit: any;\n+  once: any;\n+  setCommandHandler: any;\n+}\n+\n+interface EmbarkApi {\n+  events: Events;\n+  registerAPICall: any;\n+  registerConsoleCommand: any;\n+}\n+\n+class Console {\n+  private embark: EmbarkApi;\n+  private events: Events;\n+  private plugins: any;\n+  private version: string;\n+  private logger: any;\n+  private ipc: any;\n+  private config: any;\n+  private history: string[];\n+  private cmdHistoryFile: string;\n+  private suggestions: Suggestions;\n+\n+  constructor(embark: any, options: any) {\n+    this.embark = embark;\n+    this.events = options.events;\n+    this.plugins = options.plugins;\n+    this.version = options.version;\n+    this.logger = options.logger;\n+    this.ipc = options.ipc;\n+    this.config = options.config;\n+    this.history = [];\n+    this.cmdHistoryFile = options.cmdHistoryFile || fs.dappPath(\".embark\", \"cmd_history\");\n+    this.loadHistory();\n+\n+    if (this.ipc.isServer()) {\n+      this.ipc.on(\"console:executeCmd\", this.executeCmd.bind(this));\n+    }\n+    this.events.setCommandHandler(\"console:executeCmd\", this.executeCmd.bind(this));\n+    this.events.setCommandHandler(\"console:history\", (cb: any) => this.getHistory(this.cmdHistorySize(), cb));\n+    this.registerEmbarkJs();\n+    this.registerConsoleCommands();\n+    this.registerApi();\n+\n+    this.suggestions = new Suggestions(embark, options);\n+  }\n+\n+  private cmdHistorySize() {\n+    return env.anchoredValue(env.CMD_HISTORY_SIZE);\n+  }\n+\n+  private registerApi() {\n+    const plugin = this.plugins.createPlugin(\"consoleApi\", {});\n+    plugin.registerAPICall(\"post\", \"/embark-api/command\", (req: any, res: any) => {\n+      this.executeCmd(req.body.command, (err: any, result: any) => {\n+        if (err) {\n+          return res.send({result: err.message || err});\n+        }\n+        if (typeof result === \"string\") {\n+          return res.send({result});\n+        }\n+        res.send({result: stringify(result, utils.jsonFunctionReplacer, 2)});\n+      });\n+    });\n+  }\n+\n+  private processEmbarkCmd(cmd: string) {\n+    if (cmd === \"help\" || cmd === __(\"help\") || cmd === \"01189998819991197253\") {\n+      const helpText = [\n+        __(\"Welcome to Embark\") + \" \" + this.version,\n+        \"\",\n+        __(\"possible commands are:\"),\n+        \"versions - \" + __(\"display versions in use for libraries and tools like web3 and solc\"),\n+        \"history - \" + __(\"display console commands history\"),\n+        // TODO: only if the blockchain is actually active!\n+        // will need to pass te current embark state here\n+        \"ipfs - \" + __(\"instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)\"),\n+        \"swarm - \" + __(\"instantiated swarm-api object configured to the current environment (available if swarm is enabled)\"),\n+        \"web3 - \" + __(\"instantiated web3.js object configured to the current environment\"),\n+        \"EmbarkJS - \" + __(\"EmbarkJS static functions for Storage, Messages, Names, etc.\"),\n+        \"quit - \" + __(\"to immediatly exit (alias: exit)\"),\n+        \"\",\n+        __(\"The web3 object and the interfaces for the deployed contracts and their methods are also available\"),\n+      ];\n+      return helpText.join(\"\\n\");\n+    } else if ([\"quit\", \"exit\", \"sair\", \"sortir\", __(\"quit\")].indexOf(cmd) >= 0) {\n+      utils.exit();\n+    }\n+    return false;\n+  }\n+\n+  private executeCmd(cmd: string, callback: any) {","path":"src/lib/modules/console/index.ts","position":107,"original_position":107,"commit_id":"0e85851fca358cd817bf1cfd6e6788e0108d5369","original_commit_id":"0e85851fca358cd817bf1cfd6e6788e0108d5369","user":{"login":"alaibe","id":491074,"node_id":"MDQ6VXNlcjQ5MTA3NA==","avatar_url":"https://avatars0.githubusercontent.com/u/491074?v=4","gravatar_id":"","url":"https://api.github.com/users/alaibe","html_url":"https://github.com/alaibe","followers_url":"https://api.github.com/users/alaibe/followers","following_url":"https://api.github.com/users/alaibe/following{/other_user}","gists_url":"https://api.github.com/users/alaibe/gists{/gist_id}","starred_url":"https://api.github.com/users/alaibe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alaibe/subscriptions","organizations_url":"https://api.github.com/users/alaibe/orgs","repos_url":"https://api.github.com/users/alaibe/repos","events_url":"https://api.github.com/users/alaibe/events{/privacy}","received_events_url":"https://api.github.com/users/alaibe/received_events","type":"User","site_admin":false},"body":"Instead of `any` I would suggest `void`, that is more precise and I think callback don't return anything?","created_at":"2018-11-14T09:46:40Z","updated_at":"2018-11-14T09:46:40Z","html_url":"https://github.com/embark-framework/embark/pull/1080#discussion_r233376007","pull_request_url":"https://api.github.com/repos/embark-framework/embark/pulls/1080","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/embark-framework/embark/pulls/comments/233376007"},"html":{"href":"https://github.com/embark-framework/embark/pull/1080#discussion_r233376007"},"pull_request":{"href":"https://api.github.com/repos/embark-framework/embark/pulls/1080"}},"in_reply_to_id":233197928},"pull_request":{"url":"https://api.github.com/repos/embark-framework/embark/pulls/1080","id":230511169,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwNTExMTY5","html_url":"https://github.com/embark-framework/embark/pull/1080","diff_url":"https://github.com/embark-framework/embark/pull/1080.diff","patch_url":"https://github.com/embark-framework/embark/pull/1080.patch","issue_url":"https://api.github.com/repos/embark-framework/embark/issues/1080","number":1080,"state":"open","locked":false,"title":"refactor(@embark/console): move console/index.js into typescript","user":{"login":"iurimatias","id":176720,"node_id":"MDQ6VXNlcjE3NjcyMA==","avatar_url":"https://avatars2.githubusercontent.com/u/176720?v=4","gravatar_id":"","url":"https://api.github.com/users/iurimatias","html_url":"https://github.com/iurimatias","followers_url":"https://api.github.com/users/iurimatias/followers","following_url":"https://api.github.com/users/iurimatias/following{/other_user}","gists_url":"https://api.github.com/users/iurimatias/gists{/gist_id}","starred_url":"https://api.github.com/users/iurimatias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iurimatias/subscriptions","organizations_url":"https://api.github.com/users/iurimatias/orgs","repos_url":"https://api.github.com/users/iurimatias/repos","events_url":"https://api.github.com/users/iurimatias/events{/privacy}","received_events_url":"https://api.github.com/users/iurimatias/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-13T15:13:51Z","updated_at":"2018-11-14T09:46:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c414582f3919843823ac65922201f0e31c1fe580","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/embark-framework/embark/pulls/1080/commits","review_comments_url":"https://api.github.com/repos/embark-framework/embark/pulls/1080/comments","review_comment_url":"https://api.github.com/repos/embark-framework/embark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/embark-framework/embark/issues/1080/comments","statuses_url":"https://api.github.com/repos/embark-framework/embark/statuses/0e85851fca358cd817bf1cfd6e6788e0108d5369","head":{"label":"embark-framework:refactor/console_ts","ref":"refactor/console_ts","sha":"0e85851fca358cd817bf1cfd6e6788e0108d5369","user":{"login":"embark-framework","id":12584440,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNTg0NDQw","avatar_url":"https://avatars1.githubusercontent.com/u/12584440?v=4","gravatar_id":"","url":"https://api.github.com/users/embark-framework","html_url":"https://github.com/embark-framework","followers_url":"https://api.github.com/users/embark-framework/followers","following_url":"https://api.github.com/users/embark-framework/following{/other_user}","gists_url":"https://api.github.com/users/embark-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/embark-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embark-framework/subscriptions","organizations_url":"https://api.github.com/users/embark-framework/orgs","repos_url":"https://api.github.com/users/embark-framework/repos","events_url":"https://api.github.com/users/embark-framework/events{/privacy}","received_events_url":"https://api.github.com/users/embark-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":36172821,"node_id":"MDEwOlJlcG9zaXRvcnkzNjE3MjgyMQ==","name":"embark","full_name":"embark-framework/embark","private":false,"owner":{"login":"embark-framework","id":12584440,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNTg0NDQw","avatar_url":"https://avatars1.githubusercontent.com/u/12584440?v=4","gravatar_id":"","url":"https://api.github.com/users/embark-framework","html_url":"https://github.com/embark-framework","followers_url":"https://api.github.com/users/embark-framework/followers","following_url":"https://api.github.com/users/embark-framework/following{/other_user}","gists_url":"https://api.github.com/users/embark-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/embark-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embark-framework/subscriptions","organizations_url":"https://api.github.com/users/embark-framework/orgs","repos_url":"https://api.github.com/users/embark-framework/repos","events_url":"https://api.github.com/users/embark-framework/events{/privacy}","received_events_url":"https://api.github.com/users/embark-framework/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/embark-framework/embark","description":"Framework for serverless Decentralized Applications using Ethereum, IPFS and other platforms","fork":false,"url":"https://api.github.com/repos/embark-framework/embark","forks_url":"https://api.github.com/repos/embark-framework/embark/forks","keys_url":"https://api.github.com/repos/embark-framework/embark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/embark-framework/embark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/embark-framework/embark/teams","hooks_url":"https://api.github.com/repos/embark-framework/embark/hooks","issue_events_url":"https://api.github.com/repos/embark-framework/embark/issues/events{/number}","events_url":"https://api.github.com/repos/embark-framework/embark/events","assignees_url":"https://api.github.com/repos/embark-framework/embark/assignees{/user}","branches_url":"https://api.github.com/repos/embark-framework/embark/branches{/branch}","tags_url":"https://api.github.com/repos/embark-framework/embark/tags","blobs_url":"https://api.github.com/repos/embark-framework/embark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/embark-framework/embark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/embark-framework/embark/git/refs{/sha}","trees_url":"https://api.github.com/repos/embark-framework/embark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/embark-framework/embark/statuses/{sha}","languages_url":"https://api.github.com/repos/embark-framework/embark/languages","stargazers_url":"https://api.github.com/repos/embark-framework/embark/stargazers","contributors_url":"https://api.github.com/repos/embark-framework/embark/contributors","subscribers_url":"https://api.github.com/repos/embark-framework/embark/subscribers","subscription_url":"https://api.github.com/repos/embark-framework/embark/subscription","commits_url":"https://api.github.com/repos/embark-framework/embark/commits{/sha}","git_commits_url":"https://api.github.com/repos/embark-framework/embark/git/commits{/sha}","comments_url":"https://api.github.com/repos/embark-framework/embark/comments{/number}","issue_comment_url":"https://api.github.com/repos/embark-framework/embark/issues/comments{/number}","contents_url":"https://api.github.com/repos/embark-framework/embark/contents/{+path}","compare_url":"https://api.github.com/repos/embark-framework/embark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/embark-framework/embark/merges","archive_url":"https://api.github.com/repos/embark-framework/embark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/embark-framework/embark/downloads","issues_url":"https://api.github.com/repos/embark-framework/embark/issues{/number}","pulls_url":"https://api.github.com/repos/embark-framework/embark/pulls{/number}","milestones_url":"https://api.github.com/repos/embark-framework/embark/milestones{/number}","notifications_url":"https://api.github.com/repos/embark-framework/embark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/embark-framework/embark/labels{/name}","releases_url":"https://api.github.com/repos/embark-framework/embark/releases{/id}","deployments_url":"https://api.github.com/repos/embark-framework/embark/deployments","created_at":"2015-05-24T13:10:10Z","updated_at":"2018-11-13T16:57:42Z","pushed_at":"2018-11-14T09:45:36Z","git_url":"git://github.com/embark-framework/embark.git","ssh_url":"git@github.com:embark-framework/embark.git","clone_url":"https://github.com/embark-framework/embark.git","svn_url":"https://github.com/embark-framework/embark","homepage":"https://embark.status.im/","size":20106,"stargazers_count":2511,"watchers_count":2511,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":366,"mirror_url":null,"archived":false,"open_issues_count":52,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":366,"open_issues":52,"watchers":2511,"default_branch":"master"}},"base":{"label":"embark-framework:master","ref":"master","sha":"192e6e112ab173a94ffc7f5893b851abffed6e1f","user":{"login":"embark-framework","id":12584440,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNTg0NDQw","avatar_url":"https://avatars1.githubusercontent.com/u/12584440?v=4","gravatar_id":"","url":"https://api.github.com/users/embark-framework","html_url":"https://github.com/embark-framework","followers_url":"https://api.github.com/users/embark-framework/followers","following_url":"https://api.github.com/users/embark-framework/following{/other_user}","gists_url":"https://api.github.com/users/embark-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/embark-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embark-framework/subscriptions","organizations_url":"https://api.github.com/users/embark-framework/orgs","repos_url":"https://api.github.com/users/embark-framework/repos","events_url":"https://api.github.com/users/embark-framework/events{/privacy}","received_events_url":"https://api.github.com/users/embark-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":36172821,"node_id":"MDEwOlJlcG9zaXRvcnkzNjE3MjgyMQ==","name":"embark","full_name":"embark-framework/embark","private":false,"owner":{"login":"embark-framework","id":12584440,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNTg0NDQw","avatar_url":"https://avatars1.githubusercontent.com/u/12584440?v=4","gravatar_id":"","url":"https://api.github.com/users/embark-framework","html_url":"https://github.com/embark-framework","followers_url":"https://api.github.com/users/embark-framework/followers","following_url":"https://api.github.com/users/embark-framework/following{/other_user}","gists_url":"https://api.github.com/users/embark-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/embark-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embark-framework/subscriptions","organizations_url":"https://api.github.com/users/embark-framework/orgs","repos_url":"https://api.github.com/users/embark-framework/repos","events_url":"https://api.github.com/users/embark-framework/events{/privacy}","received_events_url":"https://api.github.com/users/embark-framework/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/embark-framework/embark","description":"Framework for serverless Decentralized Applications using Ethereum, IPFS and other platforms","fork":false,"url":"https://api.github.com/repos/embark-framework/embark","forks_url":"https://api.github.com/repos/embark-framework/embark/forks","keys_url":"https://api.github.com/repos/embark-framework/embark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/embark-framework/embark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/embark-framework/embark/teams","hooks_url":"https://api.github.com/repos/embark-framework/embark/hooks","issue_events_url":"https://api.github.com/repos/embark-framework/embark/issues/events{/number}","events_url":"https://api.github.com/repos/embark-framework/embark/events","assignees_url":"https://api.github.com/repos/embark-framework/embark/assignees{/user}","branches_url":"https://api.github.com/repos/embark-framework/embark/branches{/branch}","tags_url":"https://api.github.com/repos/embark-framework/embark/tags","blobs_url":"https://api.github.com/repos/embark-framework/embark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/embark-framework/embark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/embark-framework/embark/git/refs{/sha}","trees_url":"https://api.github.com/repos/embark-framework/embark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/embark-framework/embark/statuses/{sha}","languages_url":"https://api.github.com/repos/embark-framework/embark/languages","stargazers_url":"https://api.github.com/repos/embark-framework/embark/stargazers","contributors_url":"https://api.github.com/repos/embark-framework/embark/contributors","subscribers_url":"https://api.github.com/repos/embark-framework/embark/subscribers","subscription_url":"https://api.github.com/repos/embark-framework/embark/subscription","commits_url":"https://api.github.com/repos/embark-framework/embark/commits{/sha}","git_commits_url":"https://api.github.com/repos/embark-framework/embark/git/commits{/sha}","comments_url":"https://api.github.com/repos/embark-framework/embark/comments{/number}","issue_comment_url":"https://api.github.com/repos/embark-framework/embark/issues/comments{/number}","contents_url":"https://api.github.com/repos/embark-framework/embark/contents/{+path}","compare_url":"https://api.github.com/repos/embark-framework/embark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/embark-framework/embark/merges","archive_url":"https://api.github.com/repos/embark-framework/embark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/embark-framework/embark/downloads","issues_url":"https://api.github.com/repos/embark-framework/embark/issues{/number}","pulls_url":"https://api.github.com/repos/embark-framework/embark/pulls{/number}","milestones_url":"https://api.github.com/repos/embark-framework/embark/milestones{/number}","notifications_url":"https://api.github.com/repos/embark-framework/embark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/embark-framework/embark/labels{/name}","releases_url":"https://api.github.com/repos/embark-framework/embark/releases{/id}","deployments_url":"https://api.github.com/repos/embark-framework/embark/deployments","created_at":"2015-05-24T13:10:10Z","updated_at":"2018-11-13T16:57:42Z","pushed_at":"2018-11-14T09:45:36Z","git_url":"git://github.com/embark-framework/embark.git","ssh_url":"git@github.com:embark-framework/embark.git","clone_url":"https://github.com/embark-framework/embark.git","svn_url":"https://github.com/embark-framework/embark","homepage":"https://embark.status.im/","size":20106,"stargazers_count":2511,"watchers_count":2511,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":366,"mirror_url":null,"archived":false,"open_issues_count":52,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":366,"open_issues":52,"watchers":2511,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/embark-framework/embark/pulls/1080"},"html":{"href":"https://github.com/embark-framework/embark/pull/1080"},"issue":{"href":"https://api.github.com/repos/embark-framework/embark/issues/1080"},"comments":{"href":"https://api.github.com/repos/embark-framework/embark/issues/1080/comments"},"review_comments":{"href":"https://api.github.com/repos/embark-framework/embark/pulls/1080/comments"},"review_comment":{"href":"https://api.github.com/repos/embark-framework/embark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/embark-framework/embark/pulls/1080/commits"},"statuses":{"href":"https://api.github.com/repos/embark-framework/embark/statuses/0e85851fca358cd817bf1cfd6e6788e0108d5369"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"alaibe"}}