{"action":"created","comment":{"url":"https://api.github.com/repos/yeoman/yeoman.io/pulls/comments/26553689","id":26553689,"diff_hunk":"@@ -0,0 +1,81 @@\n+---\n+layout: documentation\n+title: Integrating Yeoman\n+category: authoring\n+sidebar: sidebars/authoring.html\n+excerpt: How can you integrate Yeoman system in your own tools\n+---\n+\n+Everytime you run a generator, you're actually using the `yeoman-environment`. This environment is a base system who's decoupled from any UI component and can be abstracted away by any tool. When you run `yo`, you're basically just running a terminal UI façade on top of the core yeoman environment.\n+\n+## The basics\n+\n+What you need to know first is that the environment system is contained in the `yeoman-environment` package. You can install it:\n+\n+```sh\n+npm install --save yeoman-environment\n+```\n+\n+This module provide methods to: retrieve installed generators, register generators, run generators and provide the common interfaces components. We provide a [full API documentation](http://yeoman.github.io/environment/) (which is the terse list of methods available.)\n+\n+## Using `yeoman-environment`\n+\n+### A simple usage example\n+\n+Let's start with a simple usage example of `yeoman-environment` before we move to deeper topics.\n+\n+In this example, let's assume `npm` wants to provide a `npm init` command to scaffold a `package.json`. Reading the other pages of the documentation, you already know how to create a generator - so let's assume we already have a `generator-npm`. We'll see how to invoke it.\n+\n+First step is to instantiate a new environment instance.\n+\n+```js\n+var yeoman = require('yeoman-environment');\n+var env = yeoman.createEnv();\n+```\n+\n+Then, we'll want to register our `generator-npm` so it can be used later. You have two options here:\n+\n+```js\n+// Here we register a generator based on it's path. Providing the namespace\n+// is optional.\n+env.register(require.resolve('generator-npm'), 'npm:app');\n+\n+// Or you can simple provide a generator constructor. Doing so, you need\n+// to provide a namespace manually\n+var GeneratorNPM = generators.Base.extend(/* put your methods in here */);\n+env.registerStub(GeneratorNPM, 'npm:app');\n+```\n+\n+Note that you can register as many generators as you want. Registered generators are just made available throughout the environment (to allow composability for example).\n+\n+At this point, your environment is ready to run `npm:app`.\n+\n+```js\n+// In it's simplest form\n+env.run('npm:app', done);\n+\n+// Or passing arguments and options\n+env.run('npm:app some-name', { 'skip-install': true }, done);\n+```\n+\n+There you go. You just need to put this code in a `bin` runnable file and you can run a yeoman generator without using `yo`.\n+\n+### Find installed generators\n+\n+But what if you wish to provide access to every yeoman generators installed on a user machine? Then you need to execute a lookup of the user disk.","path":"app/authoring/integrating-yeoman.md","position":65,"original_position":65,"commit_id":"d21cb698dfe38f0497e1e65bdb9ef1ed6316cfb3","original_commit_id":"d21cb698dfe38f0497e1e65bdb9ef1ed6316cfb3","user":{"login":"kevva","id":709159,"avatar_url":"https://avatars.githubusercontent.com/u/709159?v=3","gravatar_id":"","url":"https://api.github.com/users/kevva","html_url":"https://github.com/kevva","followers_url":"https://api.github.com/users/kevva/followers","following_url":"https://api.github.com/users/kevva/following{/other_user}","gists_url":"https://api.github.com/users/kevva/gists{/gist_id}","starred_url":"https://api.github.com/users/kevva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevva/subscriptions","organizations_url":"https://api.github.com/users/kevva/orgs","repos_url":"https://api.github.com/users/kevva/repos","events_url":"https://api.github.com/users/kevva/events{/privacy}","received_events_url":"https://api.github.com/users/kevva/received_events","type":"User","site_admin":false},"body":"`Yeoman generators`","created_at":"2015-03-17T07:29:40Z","updated_at":"2015-03-17T07:29:40Z","html_url":"https://github.com/yeoman/yeoman.io/pull/442#discussion_r26553689","pull_request_url":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442","_links":{"self":{"href":"https://api.github.com/repos/yeoman/yeoman.io/pulls/comments/26553689"},"html":{"href":"https://github.com/yeoman/yeoman.io/pull/442#discussion_r26553689"},"pull_request":{"href":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442"}}},"pull_request":{"url":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442","id":31301876,"html_url":"https://github.com/yeoman/yeoman.io/pull/442","diff_url":"https://github.com/yeoman/yeoman.io/pull/442.diff","patch_url":"https://github.com/yeoman/yeoman.io/pull/442.patch","issue_url":"https://api.github.com/repos/yeoman/yeoman.io/issues/442","number":442,"state":"open","locked":false,"title":"Add yeoman-environment documentation","user":{"login":"SBoudrias","id":923865,"avatar_url":"https://avatars.githubusercontent.com/u/923865?v=3","gravatar_id":"","url":"https://api.github.com/users/SBoudrias","html_url":"https://github.com/SBoudrias","followers_url":"https://api.github.com/users/SBoudrias/followers","following_url":"https://api.github.com/users/SBoudrias/following{/other_user}","gists_url":"https://api.github.com/users/SBoudrias/gists{/gist_id}","starred_url":"https://api.github.com/users/SBoudrias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SBoudrias/subscriptions","organizations_url":"https://api.github.com/users/SBoudrias/orgs","repos_url":"https://api.github.com/users/SBoudrias/repos","events_url":"https://api.github.com/users/SBoudrias/events{/privacy}","received_events_url":"https://api.github.com/users/SBoudrias/received_events","type":"User","site_admin":false},"body":"Started to work on the documentation to integrate Yeoman in third-party tools.\r\n\r\nComments / typo fixes are welcomed :)","created_at":"2015-03-17T02:09:46Z","updated_at":"2015-03-17T07:29:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"975ef88d452b6f40dc709ba0564399a3e5ce2ff4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442/commits","review_comments_url":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442/comments","review_comment_url":"https://api.github.com/repos/yeoman/yeoman.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yeoman/yeoman.io/issues/442/comments","statuses_url":"https://api.github.com/repos/yeoman/yeoman.io/statuses/d21cb698dfe38f0497e1e65bdb9ef1ed6316cfb3","head":{"label":"yeoman:yeoman-environment-doc","ref":"yeoman-environment-doc","sha":"d21cb698dfe38f0497e1e65bdb9ef1ed6316cfb3","user":{"login":"yeoman","id":1714870,"avatar_url":"https://avatars.githubusercontent.com/u/1714870?v=3","gravatar_id":"","url":"https://api.github.com/users/yeoman","html_url":"https://github.com/yeoman","followers_url":"https://api.github.com/users/yeoman/followers","following_url":"https://api.github.com/users/yeoman/following{/other_user}","gists_url":"https://api.github.com/users/yeoman/gists{/gist_id}","starred_url":"https://api.github.com/users/yeoman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeoman/subscriptions","organizations_url":"https://api.github.com/users/yeoman/orgs","repos_url":"https://api.github.com/users/yeoman/repos","events_url":"https://api.github.com/users/yeoman/events{/privacy}","received_events_url":"https://api.github.com/users/yeoman/received_events","type":"Organization","site_admin":false},"repo":{"id":4493652,"name":"yeoman.io","full_name":"yeoman/yeoman.io","owner":{"login":"yeoman","id":1714870,"avatar_url":"https://avatars.githubusercontent.com/u/1714870?v=3","gravatar_id":"","url":"https://api.github.com/users/yeoman","html_url":"https://github.com/yeoman","followers_url":"https://api.github.com/users/yeoman/followers","following_url":"https://api.github.com/users/yeoman/following{/other_user}","gists_url":"https://api.github.com/users/yeoman/gists{/gist_id}","starred_url":"https://api.github.com/users/yeoman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeoman/subscriptions","organizations_url":"https://api.github.com/users/yeoman/orgs","repos_url":"https://api.github.com/users/yeoman/repos","events_url":"https://api.github.com/users/yeoman/events{/privacy}","received_events_url":"https://api.github.com/users/yeoman/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yeoman/yeoman.io","description":"Yeoman website","fork":false,"url":"https://api.github.com/repos/yeoman/yeoman.io","forks_url":"https://api.github.com/repos/yeoman/yeoman.io/forks","keys_url":"https://api.github.com/repos/yeoman/yeoman.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yeoman/yeoman.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yeoman/yeoman.io/teams","hooks_url":"https://api.github.com/repos/yeoman/yeoman.io/hooks","issue_events_url":"https://api.github.com/repos/yeoman/yeoman.io/issues/events{/number}","events_url":"https://api.github.com/repos/yeoman/yeoman.io/events","assignees_url":"https://api.github.com/repos/yeoman/yeoman.io/assignees{/user}","branches_url":"https://api.github.com/repos/yeoman/yeoman.io/branches{/branch}","tags_url":"https://api.github.com/repos/yeoman/yeoman.io/tags","blobs_url":"https://api.github.com/repos/yeoman/yeoman.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yeoman/yeoman.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yeoman/yeoman.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/yeoman/yeoman.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yeoman/yeoman.io/statuses/{sha}","languages_url":"https://api.github.com/repos/yeoman/yeoman.io/languages","stargazers_url":"https://api.github.com/repos/yeoman/yeoman.io/stargazers","contributors_url":"https://api.github.com/repos/yeoman/yeoman.io/contributors","subscribers_url":"https://api.github.com/repos/yeoman/yeoman.io/subscribers","subscription_url":"https://api.github.com/repos/yeoman/yeoman.io/subscription","commits_url":"https://api.github.com/repos/yeoman/yeoman.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/yeoman/yeoman.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/yeoman/yeoman.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/yeoman/yeoman.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/yeoman/yeoman.io/contents/{+path}","compare_url":"https://api.github.com/repos/yeoman/yeoman.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yeoman/yeoman.io/merges","archive_url":"https://api.github.com/repos/yeoman/yeoman.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yeoman/yeoman.io/downloads","issues_url":"https://api.github.com/repos/yeoman/yeoman.io/issues{/number}","pulls_url":"https://api.github.com/repos/yeoman/yeoman.io/pulls{/number}","milestones_url":"https://api.github.com/repos/yeoman/yeoman.io/milestones{/number}","notifications_url":"https://api.github.com/repos/yeoman/yeoman.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yeoman/yeoman.io/labels{/name}","releases_url":"https://api.github.com/repos/yeoman/yeoman.io/releases{/id}","created_at":"2012-05-30T10:33:33Z","updated_at":"2015-03-17T06:07:35Z","pushed_at":"2015-03-17T01:13:55Z","git_url":"git://github.com/yeoman/yeoman.io.git","ssh_url":"git@github.com:yeoman/yeoman.io.git","clone_url":"https://github.com/yeoman/yeoman.io.git","svn_url":"https://github.com/yeoman/yeoman.io","homepage":"http://yeoman.io","size":39633,"stargazers_count":631,"watchers_count":631,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":234,"mirror_url":null,"open_issues_count":31,"forks":234,"open_issues":31,"watchers":631,"default_branch":"master"}},"base":{"label":"yeoman:master","ref":"master","sha":"0568f918c9771153a18c566b33c25484fc0f54b6","user":{"login":"yeoman","id":1714870,"avatar_url":"https://avatars.githubusercontent.com/u/1714870?v=3","gravatar_id":"","url":"https://api.github.com/users/yeoman","html_url":"https://github.com/yeoman","followers_url":"https://api.github.com/users/yeoman/followers","following_url":"https://api.github.com/users/yeoman/following{/other_user}","gists_url":"https://api.github.com/users/yeoman/gists{/gist_id}","starred_url":"https://api.github.com/users/yeoman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeoman/subscriptions","organizations_url":"https://api.github.com/users/yeoman/orgs","repos_url":"https://api.github.com/users/yeoman/repos","events_url":"https://api.github.com/users/yeoman/events{/privacy}","received_events_url":"https://api.github.com/users/yeoman/received_events","type":"Organization","site_admin":false},"repo":{"id":4493652,"name":"yeoman.io","full_name":"yeoman/yeoman.io","owner":{"login":"yeoman","id":1714870,"avatar_url":"https://avatars.githubusercontent.com/u/1714870?v=3","gravatar_id":"","url":"https://api.github.com/users/yeoman","html_url":"https://github.com/yeoman","followers_url":"https://api.github.com/users/yeoman/followers","following_url":"https://api.github.com/users/yeoman/following{/other_user}","gists_url":"https://api.github.com/users/yeoman/gists{/gist_id}","starred_url":"https://api.github.com/users/yeoman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeoman/subscriptions","organizations_url":"https://api.github.com/users/yeoman/orgs","repos_url":"https://api.github.com/users/yeoman/repos","events_url":"https://api.github.com/users/yeoman/events{/privacy}","received_events_url":"https://api.github.com/users/yeoman/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yeoman/yeoman.io","description":"Yeoman website","fork":false,"url":"https://api.github.com/repos/yeoman/yeoman.io","forks_url":"https://api.github.com/repos/yeoman/yeoman.io/forks","keys_url":"https://api.github.com/repos/yeoman/yeoman.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yeoman/yeoman.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yeoman/yeoman.io/teams","hooks_url":"https://api.github.com/repos/yeoman/yeoman.io/hooks","issue_events_url":"https://api.github.com/repos/yeoman/yeoman.io/issues/events{/number}","events_url":"https://api.github.com/repos/yeoman/yeoman.io/events","assignees_url":"https://api.github.com/repos/yeoman/yeoman.io/assignees{/user}","branches_url":"https://api.github.com/repos/yeoman/yeoman.io/branches{/branch}","tags_url":"https://api.github.com/repos/yeoman/yeoman.io/tags","blobs_url":"https://api.github.com/repos/yeoman/yeoman.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yeoman/yeoman.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yeoman/yeoman.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/yeoman/yeoman.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yeoman/yeoman.io/statuses/{sha}","languages_url":"https://api.github.com/repos/yeoman/yeoman.io/languages","stargazers_url":"https://api.github.com/repos/yeoman/yeoman.io/stargazers","contributors_url":"https://api.github.com/repos/yeoman/yeoman.io/contributors","subscribers_url":"https://api.github.com/repos/yeoman/yeoman.io/subscribers","subscription_url":"https://api.github.com/repos/yeoman/yeoman.io/subscription","commits_url":"https://api.github.com/repos/yeoman/yeoman.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/yeoman/yeoman.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/yeoman/yeoman.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/yeoman/yeoman.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/yeoman/yeoman.io/contents/{+path}","compare_url":"https://api.github.com/repos/yeoman/yeoman.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yeoman/yeoman.io/merges","archive_url":"https://api.github.com/repos/yeoman/yeoman.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yeoman/yeoman.io/downloads","issues_url":"https://api.github.com/repos/yeoman/yeoman.io/issues{/number}","pulls_url":"https://api.github.com/repos/yeoman/yeoman.io/pulls{/number}","milestones_url":"https://api.github.com/repos/yeoman/yeoman.io/milestones{/number}","notifications_url":"https://api.github.com/repos/yeoman/yeoman.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yeoman/yeoman.io/labels{/name}","releases_url":"https://api.github.com/repos/yeoman/yeoman.io/releases{/id}","created_at":"2012-05-30T10:33:33Z","updated_at":"2015-03-17T06:07:35Z","pushed_at":"2015-03-17T01:13:55Z","git_url":"git://github.com/yeoman/yeoman.io.git","ssh_url":"git@github.com:yeoman/yeoman.io.git","clone_url":"https://github.com/yeoman/yeoman.io.git","svn_url":"https://github.com/yeoman/yeoman.io","homepage":"http://yeoman.io","size":39633,"stargazers_count":631,"watchers_count":631,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":234,"mirror_url":null,"open_issues_count":31,"forks":234,"open_issues":31,"watchers":631,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442"},"html":{"href":"https://github.com/yeoman/yeoman.io/pull/442"},"issue":{"href":"https://api.github.com/repos/yeoman/yeoman.io/issues/442"},"comments":{"href":"https://api.github.com/repos/yeoman/yeoman.io/issues/442/comments"},"review_comments":{"href":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442/comments"},"review_comment":{"href":"https://api.github.com/repos/yeoman/yeoman.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yeoman/yeoman.io/pulls/442/commits"},"statuses":{"href":"https://api.github.com/repos/yeoman/yeoman.io/statuses/d21cb698dfe38f0497e1e65bdb9ef1ed6316cfb3"}}}}