{"action":"created","issue":{"url":"https://api.github.com/repos/rstacruz/pnpm/issues/125","repository_url":"https://api.github.com/repos/rstacruz/pnpm","labels_url":"https://api.github.com/repos/rstacruz/pnpm/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/rstacruz/pnpm/issues/125/comments","events_url":"https://api.github.com/repos/rstacruz/pnpm/issues/125/events","html_url":"https://github.com/rstacruz/pnpm/issues/125","id":135012700,"number":125,"title":"Add a public API for installation and linking","user":{"login":"patrickheeney","id":1407228,"avatar_url":"https://avatars.githubusercontent.com/u/1407228?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickheeney","html_url":"https://github.com/patrickheeney","followers_url":"https://api.github.com/users/patrickheeney/followers","following_url":"https://api.github.com/users/patrickheeney/following{/other_user}","gists_url":"https://api.github.com/users/patrickheeney/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickheeney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickheeney/subscriptions","organizations_url":"https://api.github.com/users/patrickheeney/orgs","repos_url":"https://api.github.com/users/patrickheeney/repos","events_url":"https://api.github.com/users/patrickheeney/events{/privacy}","received_events_url":"https://api.github.com/users/patrickheeney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-20T00:47:49Z","updated_at":"2016-03-25T17:30:40Z","closed_at":null,"body":"I am using pnpm as part of a mono repo and I need to install a subset of the package.json files. Something like `pnpm install -f package.local.json`. Since files are not supported, I looked at integration within my own CLI tool. These are the problems I ran into:\r\n\r\n```javascript\r\nconst install = require('pnpm/lib/cmd/install');\r\nconst installError = require('pnpm/lib/err');\r\n\r\nreturn install(dependencies, { quiet: false }).catch(installError);\r\n```\r\n\r\nOn the surface, this looks pretty good, but it unfortunately uses the `package.json` from the current directory of my CLI tool as root, so it installs them in the wrong location.\r\n\r\n```javascript\r\nconst install = require('pnpm/lib/install_multiple');\r\nconst installConfig = require('pnpm/lib/config');\r\nconst installLog = require('pnpm/lib/logger');\r\nconst installError = require('pnpm/lib/err');\r\nconst installPeers = require('pnpm/lib/install/link_peers');\r\n\r\nconst ctx = {\r\n  root: rootPath,\r\n  store: path.resolve(rootPath, installConfig.store_path),\r\n  log: installLog()\r\n};\r\n    \r\nreturn install(ctx, dependencies, path.join(ctx.root, 'node_modules'), { quiet: false })\r\n  .then(_ => installPeers(null, ctx.store, ctx.installs))\r\n  .catch(installError);\r\n```\r\n\r\nThis did the trick, but as you can see its pretty verbose and reaches quite a bit into the `pnpm` internals. It would be nice to have a public API that could do something like this:\r\n\r\n```javascript\r\nimport pnpmApi from 'pnpm/api';\r\n\r\nreturn pnpmApi.install(dependencies, rootPath, { quiet: false });\r\n```\r\n\r\nThe implementation would look like my last snippet above. Let me know if you would accept a pull request for this?\r\n\r\nEDIT: Also wanted to point out that `installPeers` accepts `pkg` as a first argument, but it does not use it in the function. "},"comment":{"url":"https://api.github.com/repos/rstacruz/pnpm/issues/comments/201378605","html_url":"https://github.com/rstacruz/pnpm/issues/125#issuecomment-201378605","issue_url":"https://api.github.com/repos/rstacruz/pnpm/issues/125","id":201378605,"user":{"login":"davej","id":26971,"avatar_url":"https://avatars.githubusercontent.com/u/26971?v=3","gravatar_id":"","url":"https://api.github.com/users/davej","html_url":"https://github.com/davej","followers_url":"https://api.github.com/users/davej/followers","following_url":"https://api.github.com/users/davej/following{/other_user}","gists_url":"https://api.github.com/users/davej/gists{/gist_id}","starred_url":"https://api.github.com/users/davej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davej/subscriptions","organizations_url":"https://api.github.com/users/davej/orgs","repos_url":"https://api.github.com/users/davej/repos","events_url":"https://api.github.com/users/davej/events{/privacy}","received_events_url":"https://api.github.com/users/davej/received_events","type":"User","site_admin":false},"created_at":"2016-03-25T17:30:40Z","updated_at":"2016-03-25T17:30:40Z","body":"@patrickheeney looks good, only thing I would add is that it would be nice if it exposed an EventEmitter to track progress rather than logging to console. Perhaps even better might be a generator but that could be more difficult to implement."}}