{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/shipit-engine/pulls/comments/175632375","pull_request_review_id":105192776,"id":175632375,"diff_hunk":"@@ -79,7 +93,73 @@ def package_version\n         JSON.parse(package_json.read)['version']\n       end\n \n+      def publish_config\n+        JSON.parse(package_json.read)['publishConfig']\n+      end\n+\n+      def publish_config_access\n+        publish_config['access']\n+      end\n+\n+      def publish_config_registry\n+        publish_config['registry'] || publish_config['@shopify:registry']\n+      end\n+\n+      def package_name\n+        JSON.parse(package_json.read)['name']\n+      end\n+\n+      def scoped_package?\n+        package_name.start_with?('@shopify')\n+      end\n+\n+      def publish?\n+        return false if publish_config.blank?\n+        return false unless valid_publish_config_access?\n+        return false unless valid_publish_config_registry?\n+      end\n+\n+      def valid_publish_config_access?\n+        return false if publish_config_access.blank?\n+        return false unless VALID_ACCESS.include?(publish_config_access)\n+        true\n+      end\n+\n+      def valid_publish_config_registry?\n+        return false if publish_config_registry.blank?\n+        return false unless VALID_REGISTRY.include?(publish_config_registry)","path":"app/models/shipit/deploy_spec/npm_discovery.rb","position":null,"original_position":80,"commit_id":"5df8c37aae078dcbb1ee2560a0a839be3e179b8a","original_commit_id":"069b8519de708e6570fb98faaf1470cf39756b37","user":{"login":"ismail-syed","id":6130700,"avatar_url":"https://avatars1.githubusercontent.com/u/6130700?v=4","gravatar_id":"","url":"https://api.github.com/users/ismail-syed","html_url":"https://github.com/ismail-syed","followers_url":"https://api.github.com/users/ismail-syed/followers","following_url":"https://api.github.com/users/ismail-syed/following{/other_user}","gists_url":"https://api.github.com/users/ismail-syed/gists{/gist_id}","starred_url":"https://api.github.com/users/ismail-syed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ismail-syed/subscriptions","organizations_url":"https://api.github.com/users/ismail-syed/orgs","repos_url":"https://api.github.com/users/ismail-syed/repos","events_url":"https://api.github.com/users/ismail-syed/events{/privacy}","received_events_url":"https://api.github.com/users/ismail-syed/received_events","type":"User","site_admin":false},"body":"PR has been updated to reflect what we've discussed above.","created_at":"2018-03-20T01:18:13Z","updated_at":"2018-03-20T01:18:13Z","html_url":"https://github.com/Shopify/shipit-engine/pull/767#discussion_r175632375","pull_request_url":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Shopify/shipit-engine/pulls/comments/175632375"},"html":{"href":"https://github.com/Shopify/shipit-engine/pull/767#discussion_r175632375"},"pull_request":{"href":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767"}},"in_reply_to_id":175527103},"pull_request":{"url":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767","id":175936715,"html_url":"https://github.com/Shopify/shipit-engine/pull/767","diff_url":"https://github.com/Shopify/shipit-engine/pull/767.diff","patch_url":"https://github.com/Shopify/shipit-engine/pull/767.patch","issue_url":"https://api.github.com/repos/Shopify/shipit-engine/issues/767","number":767,"state":"open","locked":false,"title":"Enforce publishConfig settings for npm package","user":{"login":"ismail-syed","id":6130700,"avatar_url":"https://avatars1.githubusercontent.com/u/6130700?v=4","gravatar_id":"","url":"https://api.github.com/users/ismail-syed","html_url":"https://github.com/ismail-syed","followers_url":"https://api.github.com/users/ismail-syed/followers","following_url":"https://api.github.com/users/ismail-syed/following{/other_user}","gists_url":"https://api.github.com/users/ismail-syed/gists{/gist_id}","starred_url":"https://api.github.com/users/ismail-syed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ismail-syed/subscriptions","organizations_url":"https://api.github.com/users/ismail-syed/orgs","repos_url":"https://api.github.com/users/ismail-syed/repos","events_url":"https://api.github.com/users/ismail-syed/events{/privacy}","received_events_url":"https://api.github.com/users/ismail-syed/received_events","type":"User","site_admin":false},"body":"### What is this?\r\nWith the recent feature of private npm package support via [PackageCloud](https://packagecloud.io/l/npm-registry) (PC) we're updating all our isolated system to support this (token-rotator, pipa, shopify-build, dev etc.)\r\n\r\n### How?\r\nThis PR enforces a [`publishConfig`](https://docs.npmjs.com/files/package.json#publishconfig) option to be present and properly configured in a `package.json` before publishing. The `publishConfig` option must be present for a few reason: \r\n\r\n1. To configure shipit to auth with PC for our private packages, we'll need to update the global `~/.npmrc` file with a valid config & token \r\n```\r\nalways-auth=true\r\n@shopify:registry=https://packages.shopify.io/shopify/node/npm/\r\n//packages.shopify.io/shopify/node/npm/:_authToken=<PC_TOKEN>\r\n```\r\n* All dependencies with the `@shopify/<package_name>` scope will be fetched from PC. For public `@shopify` name-spaced packages on the npm registry, PC will proxy the install through the public npm registry if they do not exist on PC.\r\n* Since our global config for `@shopify` is set to point to PC, `publishConfig` settings in the `package.json` allows maintainer to override the registry being published to (private/public).This allows internal package maintainers to freely choose between deploying node.js packages publicly on the public npm registry and privately on our PC server.\r\n\r\n\r\nBelow is a summary of valid `publishConfig` options. This will also be documented and added to the engineering blog somewhere [here](https://development.shopify.io/guides/gems/)\r\n\r\n### Public packages\r\n#### @shopify/package-name\r\n```\r\n  \"publishConfig\": {\r\n      \"access\": \"public\",\r\n      \"@shopify:registry\": \"https://registry.npmjs.org/\"\r\n  }\r\n```\r\n\r\n### Private packages\r\n#### @shopify/package-name\r\n```\r\n  \"publishConfig\": {\r\n    \"access\": \"restricted\",\r\n    \"@shopify:registry\": \"https://packages.shopify.io/shopify/node/npm/\"\r\n  }\r\n```\r\n\r\n*NOTE:* If your package name does not use a scoped `@shopify` namespace, set the registry as\r\n```\r\n\"publishConfig\": {\r\n  \"access\": \"<public|restricted>\",\r\n  \"registry\": \"<npm-registry|package-cloud-registry>\"\r\n}\r\n\r\n```\r\n\r\n### Next steps\r\n* Add documentation to the engineering blog on how to deploy public/private packages\r\n* Update the global `~/.npmrc` file on shipit.\r\n","created_at":"2018-03-19T15:31:23Z","updated_at":"2018-03-20T01:18:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd4aa99bc560a508b16040a4aedb0bcea4200c46","assignee":null,"assignees":[],"requested_reviewers":[{"login":"byroot","id":44640,"avatar_url":"https://avatars0.githubusercontent.com/u/44640?v=4","gravatar_id":"","url":"https://api.github.com/users/byroot","html_url":"https://github.com/byroot","followers_url":"https://api.github.com/users/byroot/followers","following_url":"https://api.github.com/users/byroot/following{/other_user}","gists_url":"https://api.github.com/users/byroot/gists{/gist_id}","starred_url":"https://api.github.com/users/byroot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/byroot/subscriptions","organizations_url":"https://api.github.com/users/byroot/orgs","repos_url":"https://api.github.com/users/byroot/repos","events_url":"https://api.github.com/users/byroot/events{/privacy}","received_events_url":"https://api.github.com/users/byroot/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767/commits","review_comments_url":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767/comments","review_comment_url":"https://api.github.com/repos/Shopify/shipit-engine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/shipit-engine/issues/767/comments","statuses_url":"https://api.github.com/repos/Shopify/shipit-engine/statuses/5df8c37aae078dcbb1ee2560a0a839be3e179b8a","head":{"label":"Shopify:package-cloud-npm-support","ref":"package-cloud-npm-support","sha":"5df8c37aae078dcbb1ee2560a0a839be3e179b8a","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars1.githubusercontent.com/u/8085?v=4","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":17228890,"name":"shipit-engine","full_name":"Shopify/shipit-engine","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars1.githubusercontent.com/u/8085?v=4","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/shipit-engine","description":"Deployment coordination","fork":false,"url":"https://api.github.com/repos/Shopify/shipit-engine","forks_url":"https://api.github.com/repos/Shopify/shipit-engine/forks","keys_url":"https://api.github.com/repos/Shopify/shipit-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/shipit-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/shipit-engine/teams","hooks_url":"https://api.github.com/repos/Shopify/shipit-engine/hooks","issue_events_url":"https://api.github.com/repos/Shopify/shipit-engine/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/shipit-engine/events","assignees_url":"https://api.github.com/repos/Shopify/shipit-engine/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/shipit-engine/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/shipit-engine/tags","blobs_url":"https://api.github.com/repos/Shopify/shipit-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/shipit-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/shipit-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/shipit-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/shipit-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/shipit-engine/languages","stargazers_url":"https://api.github.com/repos/Shopify/shipit-engine/stargazers","contributors_url":"https://api.github.com/repos/Shopify/shipit-engine/contributors","subscribers_url":"https://api.github.com/repos/Shopify/shipit-engine/subscribers","subscription_url":"https://api.github.com/repos/Shopify/shipit-engine/subscription","commits_url":"https://api.github.com/repos/Shopify/shipit-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/shipit-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/shipit-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/shipit-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/shipit-engine/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/shipit-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/shipit-engine/merges","archive_url":"https://api.github.com/repos/Shopify/shipit-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/shipit-engine/downloads","issues_url":"https://api.github.com/repos/Shopify/shipit-engine/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/shipit-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/shipit-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/shipit-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/shipit-engine/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/shipit-engine/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/shipit-engine/deployments","created_at":"2014-02-26T22:59:57Z","updated_at":"2018-03-19T14:28:48Z","pushed_at":"2018-03-20T01:12:03Z","git_url":"git://github.com/Shopify/shipit-engine.git","ssh_url":"git@github.com:Shopify/shipit-engine.git","clone_url":"https://github.com/Shopify/shipit-engine.git","svn_url":"https://github.com/Shopify/shipit-engine","homepage":"https://shopifyengineering.myshopify.com/blogs/engineering/introducing-shipit","size":2574,"stargazers_count":642,"watchers_count":642,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":54,"open_issues":40,"watchers":642,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"b52cdca6ebf56486c6368f86d014ea07c9295442","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars1.githubusercontent.com/u/8085?v=4","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":17228890,"name":"shipit-engine","full_name":"Shopify/shipit-engine","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars1.githubusercontent.com/u/8085?v=4","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/shipit-engine","description":"Deployment coordination","fork":false,"url":"https://api.github.com/repos/Shopify/shipit-engine","forks_url":"https://api.github.com/repos/Shopify/shipit-engine/forks","keys_url":"https://api.github.com/repos/Shopify/shipit-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/shipit-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/shipit-engine/teams","hooks_url":"https://api.github.com/repos/Shopify/shipit-engine/hooks","issue_events_url":"https://api.github.com/repos/Shopify/shipit-engine/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/shipit-engine/events","assignees_url":"https://api.github.com/repos/Shopify/shipit-engine/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/shipit-engine/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/shipit-engine/tags","blobs_url":"https://api.github.com/repos/Shopify/shipit-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/shipit-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/shipit-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/shipit-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/shipit-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/shipit-engine/languages","stargazers_url":"https://api.github.com/repos/Shopify/shipit-engine/stargazers","contributors_url":"https://api.github.com/repos/Shopify/shipit-engine/contributors","subscribers_url":"https://api.github.com/repos/Shopify/shipit-engine/subscribers","subscription_url":"https://api.github.com/repos/Shopify/shipit-engine/subscription","commits_url":"https://api.github.com/repos/Shopify/shipit-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/shipit-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/shipit-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/shipit-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/shipit-engine/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/shipit-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/shipit-engine/merges","archive_url":"https://api.github.com/repos/Shopify/shipit-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/shipit-engine/downloads","issues_url":"https://api.github.com/repos/Shopify/shipit-engine/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/shipit-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/shipit-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/shipit-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/shipit-engine/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/shipit-engine/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/shipit-engine/deployments","created_at":"2014-02-26T22:59:57Z","updated_at":"2018-03-19T14:28:48Z","pushed_at":"2018-03-20T01:12:03Z","git_url":"git://github.com/Shopify/shipit-engine.git","ssh_url":"git@github.com:Shopify/shipit-engine.git","clone_url":"https://github.com/Shopify/shipit-engine.git","svn_url":"https://github.com/Shopify/shipit-engine","homepage":"https://shopifyengineering.myshopify.com/blogs/engineering/introducing-shipit","size":2574,"stargazers_count":642,"watchers_count":642,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":54,"open_issues":40,"watchers":642,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767"},"html":{"href":"https://github.com/Shopify/shipit-engine/pull/767"},"issue":{"href":"https://api.github.com/repos/Shopify/shipit-engine/issues/767"},"comments":{"href":"https://api.github.com/repos/Shopify/shipit-engine/issues/767/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/shipit-engine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/shipit-engine/pulls/767/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/shipit-engine/statuses/5df8c37aae078dcbb1ee2560a0a839be3e179b8a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ismail-syed"}}