{"action":"created","comment":{"url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/comments/349558293","pull_request_review_id":321495194,"id":349558293,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM0OTU1ODI5Mw==","diff_hunk":"@@ -169,40 +174,59 @@ export default class Init extends Command {\n   private async modifyPackageJson(flags: Flags, initializationType: InitType) {\n     const packageJsonData = packageJsonParts(initializationType);\n \n-    const packageJson = this.packageJson(flags);\n+    const untouchedPackageJson = this.packageJson(flags);\n     const addFrontendScripts: boolean =\n-      flags.frontendScripts || (!flags.skipFrontendScripts && (await cli.confirm('Should frontend-related npm scripts for CI/CD be added?')));\n+      flags.frontendScripts ||\n+      (!flags.skipFrontendScripts && (await cli.confirm('Should frontend-related npm scriptsToBeAdded for CI/CD be added?')));\n     const backendScritps = { ...packageJsonData.backendBuildScripts, ...packageJsonData.backendTestScripts };\n-    const scripts = addFrontendScripts ? { ...backendScritps, ...packageJsonData.frontendScripts } : backendScritps;\n+    const scriptsToBeAdded = addFrontendScripts ? { ...backendScritps, ...packageJsonData.frontendScripts } : backendScritps;\n+    const scriptsAlreadyThere = untouchedPackageJson.scripts;\n \n-    const conflicts = packageJson.scripts ? Object.keys(scripts).filter(name => Object.keys(packageJson.scripts).includes(name)) : [];\n+    const conflicts = scriptsAlreadyThere ? Object.keys(scriptsToBeAdded).filter(name => Object.keys(scriptsAlreadyThere).includes(name)) : [];\n \n     if (\n       conflicts.length &&\n       !(await cli.confirm(`Script(s) with the name(s) \"${conflicts.join('\", \"')}\" already exist(s). Should they be overwritten?`))\n     ) {\n-      this.error('Script exits as npm scripts could not be written.', {\n+      this.error('Script exits as npm scriptsToBeAdded could not be written.', {\n         exit: 11\n       });\n     }\n-    packageJson.scripts = { ...packageJson.scripts, ...scripts };\n \n-    if (initializationType === InitType.freshExpress) {\n-      packageJson.devDependencies = { ...packageJson.devDependencies, ...packageJsonData.devDependencies };\n-    }\n+    const adjustedPackageJson = {\n+      ...this.packageJson(flags),\n+      scripts: { ...untouchedPackageJson.scripts, ...scriptsToBeAdded },\n+      dependencies: { ...untouchedPackageJson.dependencies, ...(await this.addDependencies(packageJsonData.dependencies)) },\n+      devDependencies: { ...untouchedPackageJson.devDependencies, ...(await this.addDependencies(packageJsonData.devDependencies)) }\n+    };\n+\n+    fs.writeFileSync(path.resolve(flags.projectDir, 'package.json'), JSON.stringify(adjustedPackageJson, null, 2));\n+  }\n \n-    fs.writeFileSync(path.resolve(flags.projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));\n+  private async addDependencies(dependencies: string[]): Promise<{ [key: string]: string }> {\n+    const result: { [key: string]: string } = {};\n+    const versionLookups = dependencies.map(dependency => this.getVersionOfDependency(dependency).then(version => (result[dependency] = version)));\n+    return Promise.all(versionLookups).then(() => result);\n+  }","path":"src/commands/init.ts","position":76,"original_position":76,"commit_id":"9160c36f3b01fea0c6830d8ff2c6481e134b8048","original_commit_id":"9160c36f3b01fea0c6830d8ff2c6481e134b8048","user":{"login":"FrankEssenberger","id":56544999,"node_id":"MDQ6VXNlcjU2NTQ0OTk5","avatar_url":"https://avatars3.githubusercontent.com/u/56544999?v=4","gravatar_id":"","url":"https://api.github.com/users/FrankEssenberger","html_url":"https://github.com/FrankEssenberger","followers_url":"https://api.github.com/users/FrankEssenberger/followers","following_url":"https://api.github.com/users/FrankEssenberger/following{/other_user}","gists_url":"https://api.github.com/users/FrankEssenberger/gists{/gist_id}","starred_url":"https://api.github.com/users/FrankEssenberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrankEssenberger/subscriptions","organizations_url":"https://api.github.com/users/FrankEssenberger/orgs","repos_url":"https://api.github.com/users/FrankEssenberger/repos","events_url":"https://api.github.com/users/FrankEssenberger/events{/privacy}","received_events_url":"https://api.github.com/users/FrankEssenberger/received_events","type":"User","site_admin":false},"body":"yes","created_at":"2019-11-22T11:47:34Z","updated_at":"2019-11-22T11:47:35Z","html_url":"https://github.com/SAP/cloud-sdk-cli/pull/16#discussion_r349558293","pull_request_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/comments/349558293"},"html":{"href":"https://github.com/SAP/cloud-sdk-cli/pull/16#discussion_r349558293"},"pull_request":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16"}},"in_reply_to_id":349481088},"pull_request":{"url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16","id":337443200,"node_id":"MDExOlB1bGxSZXF1ZXN0MzM3NDQzMjAw","html_url":"https://github.com/SAP/cloud-sdk-cli/pull/16","diff_url":"https://github.com/SAP/cloud-sdk-cli/pull/16.diff","patch_url":"https://github.com/SAP/cloud-sdk-cli/pull/16.patch","issue_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/16","number":16,"state":"open","locked":false,"title":"Add install to init","user":{"login":"FrankEssenberger","id":56544999,"node_id":"MDQ6VXNlcjU2NTQ0OTk5","avatar_url":"https://avatars3.githubusercontent.com/u/56544999?v=4","gravatar_id":"","url":"https://api.github.com/users/FrankEssenberger","html_url":"https://github.com/FrankEssenberger","followers_url":"https://api.github.com/users/FrankEssenberger/followers","following_url":"https://api.github.com/users/FrankEssenberger/following{/other_user}","gists_url":"https://api.github.com/users/FrankEssenberger/gists{/gist_id}","starred_url":"https://api.github.com/users/FrankEssenberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrankEssenberger/subscriptions","organizations_url":"https://api.github.com/users/FrankEssenberger/orgs","repos_url":"https://api.github.com/users/FrankEssenberger/repos","events_url":"https://api.github.com/users/FrankEssenberger/events{/privacy}","received_events_url":"https://api.github.com/users/FrankEssenberger/received_events","type":"User","site_admin":false},"body":"## Proposed Changes\r\n\r\nIn the init process some dependencies (sdk ones) were installed and other not. I changed it so that if it is a fresh init all dependencies are installed and the user can directly do test or start, without any install before. I also removed the jest files, if it is not a fresh init.\r\n\r\n## Type of Changes\r\n\r\n- [x] Bug Fix\r\n- [ ] New Feature\r\n- [ ] Documentation Update\r\n\r\n## Checklist\r\n\r\n- [x] I have added tests that prove my fix is effective or that my feature works\r\n~- [ ] I have added necessary documentation~\r\n\r\n","created_at":"2019-11-06T16:09:15Z","updated_at":"2019-11-22T11:47:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"645e1d15bfe442f32b44194f5432c0a326aec9df","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16/commits","review_comments_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16/comments","review_comment_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/16/comments","statuses_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/statuses/9160c36f3b01fea0c6830d8ff2c6481e134b8048","head":{"label":"SAP:addInstallToInit","ref":"addInstallToInit","sha":"9160c36f3b01fea0c6830d8ff2c6481e134b8048","user":{"login":"SAP","id":2531208,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzEyMDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2531208?v=4","gravatar_id":"","url":"https://api.github.com/users/SAP","html_url":"https://github.com/SAP","followers_url":"https://api.github.com/users/SAP/followers","following_url":"https://api.github.com/users/SAP/following{/other_user}","gists_url":"https://api.github.com/users/SAP/gists{/gist_id}","starred_url":"https://api.github.com/users/SAP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SAP/subscriptions","organizations_url":"https://api.github.com/users/SAP/orgs","repos_url":"https://api.github.com/users/SAP/repos","events_url":"https://api.github.com/users/SAP/events{/privacy}","received_events_url":"https://api.github.com/users/SAP/received_events","type":"Organization","site_admin":false},"repo":{"id":208224645,"node_id":"MDEwOlJlcG9zaXRvcnkyMDgyMjQ2NDU=","name":"cloud-sdk-cli","full_name":"SAP/cloud-sdk-cli","private":false,"owner":{"login":"SAP","id":2531208,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzEyMDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2531208?v=4","gravatar_id":"","url":"https://api.github.com/users/SAP","html_url":"https://github.com/SAP","followers_url":"https://api.github.com/users/SAP/followers","following_url":"https://api.github.com/users/SAP/following{/other_user}","gists_url":"https://api.github.com/users/SAP/gists{/gist_id}","starred_url":"https://api.github.com/users/SAP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SAP/subscriptions","organizations_url":"https://api.github.com/users/SAP/orgs","repos_url":"https://api.github.com/users/SAP/repos","events_url":"https://api.github.com/users/SAP/events{/privacy}","received_events_url":"https://api.github.com/users/SAP/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/SAP/cloud-sdk-cli","description":"The command line interface for the SAP Cloud SDK","fork":false,"url":"https://api.github.com/repos/SAP/cloud-sdk-cli","forks_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/forks","keys_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/teams","hooks_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/hooks","issue_events_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/events{/number}","events_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/events","assignees_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/assignees{/user}","branches_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/branches{/branch}","tags_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/tags","blobs_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/languages","stargazers_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/stargazers","contributors_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/contributors","subscribers_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/subscribers","subscription_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/subscription","commits_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/contents/{+path}","compare_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/merges","archive_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/downloads","issues_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues{/number}","pulls_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/labels{/name}","releases_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/releases{/id}","deployments_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/deployments","created_at":"2019-09-13T08:26:26Z","updated_at":"2019-11-12T09:10:53Z","pushed_at":"2019-11-22T08:14:20Z","git_url":"git://github.com/SAP/cloud-sdk-cli.git","ssh_url":"git@github.com:SAP/cloud-sdk-cli.git","clone_url":"https://github.com/SAP/cloud-sdk-cli.git","svn_url":"https://github.com/SAP/cloud-sdk-cli","homepage":null,"size":282,"stargazers_count":11,"watchers_count":11,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":2,"watchers":11,"default_branch":"master"}},"base":{"label":"SAP:master","ref":"master","sha":"9fd263ffa875cb30cc3c9e26f24e1a5154154290","user":{"login":"SAP","id":2531208,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzEyMDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2531208?v=4","gravatar_id":"","url":"https://api.github.com/users/SAP","html_url":"https://github.com/SAP","followers_url":"https://api.github.com/users/SAP/followers","following_url":"https://api.github.com/users/SAP/following{/other_user}","gists_url":"https://api.github.com/users/SAP/gists{/gist_id}","starred_url":"https://api.github.com/users/SAP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SAP/subscriptions","organizations_url":"https://api.github.com/users/SAP/orgs","repos_url":"https://api.github.com/users/SAP/repos","events_url":"https://api.github.com/users/SAP/events{/privacy}","received_events_url":"https://api.github.com/users/SAP/received_events","type":"Organization","site_admin":false},"repo":{"id":208224645,"node_id":"MDEwOlJlcG9zaXRvcnkyMDgyMjQ2NDU=","name":"cloud-sdk-cli","full_name":"SAP/cloud-sdk-cli","private":false,"owner":{"login":"SAP","id":2531208,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzEyMDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2531208?v=4","gravatar_id":"","url":"https://api.github.com/users/SAP","html_url":"https://github.com/SAP","followers_url":"https://api.github.com/users/SAP/followers","following_url":"https://api.github.com/users/SAP/following{/other_user}","gists_url":"https://api.github.com/users/SAP/gists{/gist_id}","starred_url":"https://api.github.com/users/SAP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SAP/subscriptions","organizations_url":"https://api.github.com/users/SAP/orgs","repos_url":"https://api.github.com/users/SAP/repos","events_url":"https://api.github.com/users/SAP/events{/privacy}","received_events_url":"https://api.github.com/users/SAP/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/SAP/cloud-sdk-cli","description":"The command line interface for the SAP Cloud SDK","fork":false,"url":"https://api.github.com/repos/SAP/cloud-sdk-cli","forks_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/forks","keys_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/teams","hooks_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/hooks","issue_events_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/events{/number}","events_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/events","assignees_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/assignees{/user}","branches_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/branches{/branch}","tags_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/tags","blobs_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/languages","stargazers_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/stargazers","contributors_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/contributors","subscribers_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/subscribers","subscription_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/subscription","commits_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/contents/{+path}","compare_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/merges","archive_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/downloads","issues_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues{/number}","pulls_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/labels{/name}","releases_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/releases{/id}","deployments_url":"https://api.github.com/repos/SAP/cloud-sdk-cli/deployments","created_at":"2019-09-13T08:26:26Z","updated_at":"2019-11-12T09:10:53Z","pushed_at":"2019-11-22T08:14:20Z","git_url":"git://github.com/SAP/cloud-sdk-cli.git","ssh_url":"git@github.com:SAP/cloud-sdk-cli.git","clone_url":"https://github.com/SAP/cloud-sdk-cli.git","svn_url":"https://github.com/SAP/cloud-sdk-cli","homepage":null,"size":282,"stargazers_count":11,"watchers_count":11,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":2,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16"},"html":{"href":"https://github.com/SAP/cloud-sdk-cli/pull/16"},"issue":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/16"},"comments":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/SAP/cloud-sdk-cli/statuses/9160c36f3b01fea0c6830d8ff2c6481e134b8048"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"FrankEssenberger"}}