{"action":"created","comment":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/comments/153925171","pull_request_review_id":80006290,"id":153925171,"diff_hunk":"@@ -344,3 +370,457 @@ function buildEnumInfo(field, angularAppName, packageName) {\n function copyObjectProps(toObj, fromObj) {\n     Object.assign(toObj, fromObj);\n }\n+\n+\n+/**\n+ * get a property by path in a array\n+ *\n+ * @param {array} array - array in which we want to search\n+ * @param {string} name - property name to search \"format myProperty.level2.level3\"\n+ * @param {string} generator - The generator\n+ * @return {string} the value of property or undefined\n+ */\n+function getPropertyInArray(array, name, generator) {\n+    return _.get(array, name);\n+}\n+\n+/**\n+ * Update or create a property by path in a array\n+ *\n+ * @param {array} array - array in which we want to update\n+ * @param {string} name - property name to search \"format myProperty.level2.level3\"\n+ * @param {string} generator - The generator\n+ * @param {string} value - (optional) value of the property\n+ */\n+function updatePropertyInArray(array, name, generator, value) {\n+    _.set(array, name, value);\n+}\n+\n+/**\n+ * Delete a property by path in a array\n+ *\n+ * @param {array} array - array in which we want to delete\n+ * @param {string} name - property name to search \"format myProperty.level2.level3\"\n+ * @param {string} generator - The generator\n+ */\n+function deletePropertyInArray(array, name, generator) {\n+    _.unset(array, name);\n+}\n+\n+/**\n+ * Get a yaml property by path in a file\n+ *\n+ * @param {string} file - yaml file to search\n+ * @param {string} name - property name to search \"format myProperty.level2.level3\"\n+ * @param {string} generator - The generator\n+ * @return {string} the value of property or undefined\n+ */\n+function getYamlProperty(file, name, generator) {\n+    const treeData = jsyaml.safeLoad(generator.fs.read(file));\n+    return getPropertyInArray(treeData, name.toString().split('.'), generator);\n+}\n+\n+/**\n+ * Add yaml properties at beginin\n+ *\n+ * @param {string} file - yaml file to update\n+ * @param {array} properties - array of property to add\n+ * @param {string} generator - The generator\n+ */\n+function addYamlPropertiesAtBeginin(file, properties, generator) {\n+    const bodyLines = generator.fs.read(file).split('\\n');\n+    const newLines = jsyaml.safeDump(properties, { indent: 4 }).split('\\n');\n+    bodyLines.splice(bodyLines.count, 0, newLines.join('\\n'));\n+    generator.fs.write(file, bodyLines.join('\\n'));\n+}\n+\n+/**\n+ * Add yaml properties at end\n+ *\n+ * @param {string} file - yaml file to update\n+ * @param {array} properties - array of property to add\n+ * @param {string} generator - The generator\n+ */\n+function addYamlPropertiesAtEnd(file, properties, generator) {\n+    const bodyLines = generator.fs.read(file).split('\\n');\n+    const newLines = jsyaml.safeDump(properties, { indent: 4 }).split('\\n');\n+    generator.fs.write(file, bodyLines.concat(newLines).join('\\n'));\n+}\n+\n+/**\n+ * Add yaml properties before another property\n+ *\n+ * @param {string} file - yaml file to update\n+ * @param {array} properties - array of property to add\n+ * @param {string} generator - The generator\n+ * @param {string} propertyBefore - The property before which we wish to insert new properties\n+ * @param {string} addBeforeComment - (Optional) if this variable is defined, means that we will return the index before the previuous comment of the property.\n+ */\n+function addYamlPropertiesBeforeAnotherProperty(file, properties, generator, propertyBefore, addBeforeComment) {\n+    const body = generator.fs.read(file);\n+    const newLines = jsyaml.safeDump(properties, { indent: 4 }).split('\\n');\n+    const applicationPropertyIndex = getIndexBeforeLineOfProperty(body, propertyBefore, generator, addBeforeComment);\n+    if (applicationPropertyIndex === -1) {\n+        throw new Error(`Property ${propertyBefore} not found`); // inside callback\n+    }\n+    const bodyLines = body.split('\\n');\n+    bodyLines.splice(applicationPropertyIndex, 0, newLines.join('\\n'));\n+    generator.fs.write(file, bodyLines.join('\\n'));\n+}\n+\n+/**\n+ * Add yaml properties after another property\n+ *\n+ * @param {string} file - yaml file to update\n+ * @param {array} properties - array of property to add\n+ * @param {string} generator - The generator\n+ * @param {string} propertyAfter - The property after which we wish to insert new properties\n+ */\n+function addYamlPropertiesAfterAnotherProperty(file, properties, generator, propertyAfter) {\n+    const body = generator.fs.read(file);\n+    const newLines = jsyaml.safeDump(properties, { indent: 4 }).split('\\n');\n+    const applicationPropertyIndex = getIndexAfterLineOfProperty(file, propertyAfter, generator);\n+    if (applicationPropertyIndex === -1) {\n+        throw new Error(`Property ${propertyAfter} not found`); // inside callback\n+    }\n+    const bodyLines = body.split('\\n');\n+    bodyLines.splice(applicationPropertyIndex, 0, newLines.join('\\n'));\n+    generator.fs.write(file, bodyLines.join('\\n'));","path":"generators/utils.js","position":161,"original_position":161,"commit_id":"e98ae7322bccd1ed0adb2fd923a8c965d6083b22","original_commit_id":"e98ae7322bccd1ed0adb2fd923a8c965d6083b22","user":{"login":"deepu105","id":1107223,"avatar_url":"https://avatars2.githubusercontent.com/u/1107223?v=4","gravatar_id":"","url":"https://api.github.com/users/deepu105","html_url":"https://github.com/deepu105","followers_url":"https://api.github.com/users/deepu105/followers","following_url":"https://api.github.com/users/deepu105/following{/other_user}","gists_url":"https://api.github.com/users/deepu105/gists{/gist_id}","starred_url":"https://api.github.com/users/deepu105/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepu105/subscriptions","organizations_url":"https://api.github.com/users/deepu105/orgs","repos_url":"https://api.github.com/users/deepu105/repos","events_url":"https://api.github.com/users/deepu105/events{/privacy}","received_events_url":"https://api.github.com/users/deepu105/received_events","type":"User","site_admin":false},"body":"return result dont write","created_at":"2017-11-29T21:49:15Z","updated_at":"2017-11-29T21:59:52Z","html_url":"https://github.com/jhipster/generator-jhipster/pull/6769#discussion_r153925171","pull_request_url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/comments/153925171"},"html":{"href":"https://github.com/jhipster/generator-jhipster/pull/6769#discussion_r153925171"},"pull_request":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769"}}},"pull_request":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769","id":155415159,"html_url":"https://github.com/jhipster/generator-jhipster/pull/6769","diff_url":"https://github.com/jhipster/generator-jhipster/pull/6769.diff","patch_url":"https://github.com/jhipster/generator-jhipster/pull/6769.patch","issue_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/6769","number":6769,"state":"open","locked":false,"title":"Add methods for work with yaml file","user":{"login":"antarus","id":928683,"avatar_url":"https://avatars1.githubusercontent.com/u/928683?v=4","gravatar_id":"","url":"https://api.github.com/users/antarus","html_url":"https://github.com/antarus","followers_url":"https://api.github.com/users/antarus/followers","following_url":"https://api.github.com/users/antarus/following{/other_user}","gists_url":"https://api.github.com/users/antarus/gists{/gist_id}","starred_url":"https://api.github.com/users/antarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antarus/subscriptions","organizations_url":"https://api.github.com/users/antarus/orgs","repos_url":"https://api.github.com/users/antarus/repos","events_url":"https://api.github.com/users/antarus/events{/privacy}","received_events_url":"https://api.github.com/users/antarus/received_events","type":"User","site_admin":false},"body":"This code allows you to add one or more properties to a yaml file.\r\ncode update from hipster-labs/generator-jhipster-spring-cloud-stream\r\n\r\n- Please make sure the below checklist is followed for Pull Requests.\r\n\r\n- [ ] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green\r\n- [ ] Tests are added where necessary\r\n- [ ] Documentation is added/updated where necessary\r\n- [ ] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed\r\n","created_at":"2017-11-29T18:16:09Z","updated_at":"2017-11-29T21:59:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"337e601d4c6a463f133184e0fb1cadf76d82cfd7","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769/commits","review_comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769/comments","review_comment_url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/6769/comments","statuses_url":"https://api.github.com/repos/jhipster/generator-jhipster/statuses/e98ae7322bccd1ed0adb2fd923a8c965d6083b22","head":{"label":"antarus:add-methods-for-work-with-yaml-file","ref":"add-methods-for-work-with-yaml-file","sha":"e98ae7322bccd1ed0adb2fd923a8c965d6083b22","user":{"login":"antarus","id":928683,"avatar_url":"https://avatars1.githubusercontent.com/u/928683?v=4","gravatar_id":"","url":"https://api.github.com/users/antarus","html_url":"https://github.com/antarus","followers_url":"https://api.github.com/users/antarus/followers","following_url":"https://api.github.com/users/antarus/following{/other_user}","gists_url":"https://api.github.com/users/antarus/gists{/gist_id}","starred_url":"https://api.github.com/users/antarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antarus/subscriptions","organizations_url":"https://api.github.com/users/antarus/orgs","repos_url":"https://api.github.com/users/antarus/repos","events_url":"https://api.github.com/users/antarus/events{/privacy}","received_events_url":"https://api.github.com/users/antarus/received_events","type":"User","site_admin":false},"repo":{"id":110010384,"name":"generator-jhipster","full_name":"antarus/generator-jhipster","owner":{"login":"antarus","id":928683,"avatar_url":"https://avatars1.githubusercontent.com/u/928683?v=4","gravatar_id":"","url":"https://api.github.com/users/antarus","html_url":"https://github.com/antarus","followers_url":"https://api.github.com/users/antarus/followers","following_url":"https://api.github.com/users/antarus/following{/other_user}","gists_url":"https://api.github.com/users/antarus/gists{/gist_id}","starred_url":"https://api.github.com/users/antarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antarus/subscriptions","organizations_url":"https://api.github.com/users/antarus/orgs","repos_url":"https://api.github.com/users/antarus/repos","events_url":"https://api.github.com/users/antarus/events{/privacy}","received_events_url":"https://api.github.com/users/antarus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/antarus/generator-jhipster","description":"Open Source application generator for creating Spring Boot + Angular projects in seconds!","fork":true,"url":"https://api.github.com/repos/antarus/generator-jhipster","forks_url":"https://api.github.com/repos/antarus/generator-jhipster/forks","keys_url":"https://api.github.com/repos/antarus/generator-jhipster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antarus/generator-jhipster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antarus/generator-jhipster/teams","hooks_url":"https://api.github.com/repos/antarus/generator-jhipster/hooks","issue_events_url":"https://api.github.com/repos/antarus/generator-jhipster/issues/events{/number}","events_url":"https://api.github.com/repos/antarus/generator-jhipster/events","assignees_url":"https://api.github.com/repos/antarus/generator-jhipster/assignees{/user}","branches_url":"https://api.github.com/repos/antarus/generator-jhipster/branches{/branch}","tags_url":"https://api.github.com/repos/antarus/generator-jhipster/tags","blobs_url":"https://api.github.com/repos/antarus/generator-jhipster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antarus/generator-jhipster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antarus/generator-jhipster/git/refs{/sha}","trees_url":"https://api.github.com/repos/antarus/generator-jhipster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antarus/generator-jhipster/statuses/{sha}","languages_url":"https://api.github.com/repos/antarus/generator-jhipster/languages","stargazers_url":"https://api.github.com/repos/antarus/generator-jhipster/stargazers","contributors_url":"https://api.github.com/repos/antarus/generator-jhipster/contributors","subscribers_url":"https://api.github.com/repos/antarus/generator-jhipster/subscribers","subscription_url":"https://api.github.com/repos/antarus/generator-jhipster/subscription","commits_url":"https://api.github.com/repos/antarus/generator-jhipster/commits{/sha}","git_commits_url":"https://api.github.com/repos/antarus/generator-jhipster/git/commits{/sha}","comments_url":"https://api.github.com/repos/antarus/generator-jhipster/comments{/number}","issue_comment_url":"https://api.github.com/repos/antarus/generator-jhipster/issues/comments{/number}","contents_url":"https://api.github.com/repos/antarus/generator-jhipster/contents/{+path}","compare_url":"https://api.github.com/repos/antarus/generator-jhipster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antarus/generator-jhipster/merges","archive_url":"https://api.github.com/repos/antarus/generator-jhipster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antarus/generator-jhipster/downloads","issues_url":"https://api.github.com/repos/antarus/generator-jhipster/issues{/number}","pulls_url":"https://api.github.com/repos/antarus/generator-jhipster/pulls{/number}","milestones_url":"https://api.github.com/repos/antarus/generator-jhipster/milestones{/number}","notifications_url":"https://api.github.com/repos/antarus/generator-jhipster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antarus/generator-jhipster/labels{/name}","releases_url":"https://api.github.com/repos/antarus/generator-jhipster/releases{/id}","deployments_url":"https://api.github.com/repos/antarus/generator-jhipster/deployments","created_at":"2017-11-08T17:51:04Z","updated_at":"2017-11-08T17:51:10Z","pushed_at":"2017-11-29T18:18:58Z","git_url":"git://github.com/antarus/generator-jhipster.git","ssh_url":"git@github.com:antarus/generator-jhipster.git","clone_url":"https://github.com/antarus/generator-jhipster.git","svn_url":"https://github.com/antarus/generator-jhipster","homepage":"http://www.jhipster.tech","size":25118,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jhipster:master","ref":"master","sha":"4ace4773c8d2b9a4b16ff4d812e4579d791f6c98","user":{"login":"jhipster","id":6059488,"avatar_url":"https://avatars3.githubusercontent.com/u/6059488?v=4","gravatar_id":"","url":"https://api.github.com/users/jhipster","html_url":"https://github.com/jhipster","followers_url":"https://api.github.com/users/jhipster/followers","following_url":"https://api.github.com/users/jhipster/following{/other_user}","gists_url":"https://api.github.com/users/jhipster/gists{/gist_id}","starred_url":"https://api.github.com/users/jhipster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhipster/subscriptions","organizations_url":"https://api.github.com/users/jhipster/orgs","repos_url":"https://api.github.com/users/jhipster/repos","events_url":"https://api.github.com/users/jhipster/events{/privacy}","received_events_url":"https://api.github.com/users/jhipster/received_events","type":"Organization","site_admin":false},"repo":{"id":13753636,"name":"generator-jhipster","full_name":"jhipster/generator-jhipster","owner":{"login":"jhipster","id":6059488,"avatar_url":"https://avatars3.githubusercontent.com/u/6059488?v=4","gravatar_id":"","url":"https://api.github.com/users/jhipster","html_url":"https://github.com/jhipster","followers_url":"https://api.github.com/users/jhipster/followers","following_url":"https://api.github.com/users/jhipster/following{/other_user}","gists_url":"https://api.github.com/users/jhipster/gists{/gist_id}","starred_url":"https://api.github.com/users/jhipster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhipster/subscriptions","organizations_url":"https://api.github.com/users/jhipster/orgs","repos_url":"https://api.github.com/users/jhipster/repos","events_url":"https://api.github.com/users/jhipster/events{/privacy}","received_events_url":"https://api.github.com/users/jhipster/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jhipster/generator-jhipster","description":"Open Source application generator for creating Spring Boot + Angular projects in seconds!","fork":false,"url":"https://api.github.com/repos/jhipster/generator-jhipster","forks_url":"https://api.github.com/repos/jhipster/generator-jhipster/forks","keys_url":"https://api.github.com/repos/jhipster/generator-jhipster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jhipster/generator-jhipster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jhipster/generator-jhipster/teams","hooks_url":"https://api.github.com/repos/jhipster/generator-jhipster/hooks","issue_events_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/events{/number}","events_url":"https://api.github.com/repos/jhipster/generator-jhipster/events","assignees_url":"https://api.github.com/repos/jhipster/generator-jhipster/assignees{/user}","branches_url":"https://api.github.com/repos/jhipster/generator-jhipster/branches{/branch}","tags_url":"https://api.github.com/repos/jhipster/generator-jhipster/tags","blobs_url":"https://api.github.com/repos/jhipster/generator-jhipster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jhipster/generator-jhipster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jhipster/generator-jhipster/git/refs{/sha}","trees_url":"https://api.github.com/repos/jhipster/generator-jhipster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jhipster/generator-jhipster/statuses/{sha}","languages_url":"https://api.github.com/repos/jhipster/generator-jhipster/languages","stargazers_url":"https://api.github.com/repos/jhipster/generator-jhipster/stargazers","contributors_url":"https://api.github.com/repos/jhipster/generator-jhipster/contributors","subscribers_url":"https://api.github.com/repos/jhipster/generator-jhipster/subscribers","subscription_url":"https://api.github.com/repos/jhipster/generator-jhipster/subscription","commits_url":"https://api.github.com/repos/jhipster/generator-jhipster/commits{/sha}","git_commits_url":"https://api.github.com/repos/jhipster/generator-jhipster/git/commits{/sha}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/comments{/number}","issue_comment_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/comments{/number}","contents_url":"https://api.github.com/repos/jhipster/generator-jhipster/contents/{+path}","compare_url":"https://api.github.com/repos/jhipster/generator-jhipster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jhipster/generator-jhipster/merges","archive_url":"https://api.github.com/repos/jhipster/generator-jhipster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jhipster/generator-jhipster/downloads","issues_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues{/number}","pulls_url":"https://api.github.com/repos/jhipster/generator-jhipster/pulls{/number}","milestones_url":"https://api.github.com/repos/jhipster/generator-jhipster/milestones{/number}","notifications_url":"https://api.github.com/repos/jhipster/generator-jhipster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jhipster/generator-jhipster/labels{/name}","releases_url":"https://api.github.com/repos/jhipster/generator-jhipster/releases{/id}","deployments_url":"https://api.github.com/repos/jhipster/generator-jhipster/deployments","created_at":"2013-10-21T20:07:22Z","updated_at":"2017-11-29T19:03:42Z","pushed_at":"2017-11-29T21:30:18Z","git_url":"git://github.com/jhipster/generator-jhipster.git","ssh_url":"git@github.com:jhipster/generator-jhipster.git","clone_url":"https://github.com/jhipster/generator-jhipster.git","svn_url":"https://github.com/jhipster/generator-jhipster","homepage":"http://www.jhipster.tech","size":25112,"stargazers_count":8743,"watchers_count":8743,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1969,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1969,"open_issues":57,"watchers":8743,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769"},"html":{"href":"https://github.com/jhipster/generator-jhipster/pull/6769"},"issue":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/issues/6769"},"comments":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/issues/6769/comments"},"review_comments":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769/comments"},"review_comment":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/pulls/6769/commits"},"statuses":{"href":"https://api.github.com/repos/jhipster/generator-jhipster/statuses/e98ae7322bccd1ed0adb2fd923a8c965d6083b22"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"deepu105"}}