{"action":"created","issue":{"url":"https://api.github.com/repos/meteorhacks/npm/issues/72","labels_url":"https://api.github.com/repos/meteorhacks/npm/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/meteorhacks/npm/issues/72/comments","events_url":"https://api.github.com/repos/meteorhacks/npm/issues/72/events","html_url":"https://github.com/meteorhacks/npm/issues/72","id":57880629,"number":72,"title":"Install, uninstall CLI","user":{"login":"steve8708","id":844291,"avatar_url":"https://avatars.githubusercontent.com/u/844291?v=3","gravatar_id":"","url":"https://api.github.com/users/steve8708","html_url":"https://github.com/steve8708","followers_url":"https://api.github.com/users/steve8708/followers","following_url":"https://api.github.com/users/steve8708/following{/other_user}","gists_url":"https://api.github.com/users/steve8708/gists{/gist_id}","starred_url":"https://api.github.com/users/steve8708/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve8708/subscriptions","organizations_url":"https://api.github.com/users/steve8708/orgs","repos_url":"https://api.github.com/users/steve8708/repos","events_url":"https://api.github.com/users/steve8708/events{/privacy}","received_events_url":"https://api.github.com/users/steve8708/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-17T03:54:03Z","updated_at":"2015-02-17T03:55:35Z","closed_at":null,"body":"With meteor I dearly miss the simplicity of `npm install {pkg}` and `npm uninstall {pkg}`\r\n\r\nMy OCD brain was hating having to look up the latest version of packages and manually add them to my packages.json file, so I made a little CLI so I can `./cli install {pkg}` and `./cli uninstall {pkg}` but this is not the most elegant of solutions\r\n\r\nAny thoughts on a possible better solution that can be worked into this package? My quick and dirty CLI tool below\r\n\r\n```coffee\r\n#!/usr/bin/env coffee\r\n\r\n# USAGE:\r\n#   ./cli install chalk\r\n#   ./cli uninstall chalk\r\n\r\nexec = require('child_process').exec\r\nfs = require 'fs'\r\n\r\nargv = process.argv\r\n\r\nhandleError = (error) ->\r\n  throw error if error\r\n\r\ncommand = argv[2]\r\n\r\nswitch command\r\n  when 'install'\r\n    pkg = argv[3]\r\n\r\n    exec \"npm show #{pkg} version\", (error, output) ->\r\n      handleError error\r\n      latestVersion = output.trim()\r\n\r\n      fs.readFile 'packages.json', 'utf8', (error, contents) ->\r\n        handleError error\r\n\r\n        json = JSON.parse contents\r\n        json[pkg] = latestVersion\r\n        newString = JSON.stringify json, null, 2\r\n        newString += '\\n'\r\n\r\n        fs.writeFile 'packages.json', newString, (error) ->\r\n          handleError error\r\n\r\n          console.info \"Latest #{pkg} added to ./packages.json\"\r\n\r\n  when 'uninstall'\r\n    pkg = argv[3]\r\n\r\n    fs.readFile 'packages.json', 'utf8', (error, contents) ->\r\n      handleError error\r\n\r\n      json = JSON.parse contents\r\n      if json[pkg]\r\n        delete json[pkg]\r\n      else\r\n        console.warn \"Huh? #{pkg} is not in your packages.json\"\r\n        return\r\n\r\n      newString = JSON.stringify json, null, 2\r\n      newString += '\\n'\r\n\r\n      fs.writeFile 'packages.json', newString, (error) ->\r\n        handleError error\r\n\r\n        console.info \"#{pkg} removed from packages.json\"\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/meteorhacks/npm/issues/comments/74613752","html_url":"https://github.com/meteorhacks/npm/issues/72#issuecomment-74613752","issue_url":"https://api.github.com/repos/meteorhacks/npm/issues/72","id":74613752,"user":{"login":"steve8708","id":844291,"avatar_url":"https://avatars.githubusercontent.com/u/844291?v=3","gravatar_id":"","url":"https://api.github.com/users/steve8708","html_url":"https://github.com/steve8708","followers_url":"https://api.github.com/users/steve8708/followers","following_url":"https://api.github.com/users/steve8708/following{/other_user}","gists_url":"https://api.github.com/users/steve8708/gists{/gist_id}","starred_url":"https://api.github.com/users/steve8708/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve8708/subscriptions","organizations_url":"https://api.github.com/users/steve8708/orgs","repos_url":"https://api.github.com/users/steve8708/repos","events_url":"https://api.github.com/users/steve8708/events{/privacy}","received_events_url":"https://api.github.com/users/steve8708/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T03:55:35Z","updated_at":"2015-02-17T03:55:35Z","body":"This is probably not possible without this - https://github.com/MeteorCommunity/discussions/issues/9\r\n\r\nBut who knows if there is a workaround anyone can think of in the interim?"}}