{"action":"created","issue":{"url":"https://api.github.com/repos/eduardoboucas/staticman/issues/219","repository_url":"https://api.github.com/repos/eduardoboucas/staticman","labels_url":"https://api.github.com/repos/eduardoboucas/staticman/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/eduardoboucas/staticman/issues/219/comments","events_url":"https://api.github.com/repos/eduardoboucas/staticman/issues/219/events","html_url":"https://github.com/eduardoboucas/staticman/pull/219","id":343450342,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDgzOTE4","number":219,"title":"Add GitLab support","user":{"login":"ntsim","id":9917868,"node_id":"MDQ6VXNlcjk5MTc4Njg=","avatar_url":"https://avatars1.githubusercontent.com/u/9917868?v=4","gravatar_id":"","url":"https://api.github.com/users/ntsim","html_url":"https://github.com/ntsim","followers_url":"https://api.github.com/users/ntsim/followers","following_url":"https://api.github.com/users/ntsim/following{/other_user}","gists_url":"https://api.github.com/users/ntsim/gists{/gist_id}","starred_url":"https://api.github.com/users/ntsim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ntsim/subscriptions","organizations_url":"https://api.github.com/users/ntsim/orgs","repos_url":"https://api.github.com/users/ntsim/repos","events_url":"https://api.github.com/users/ntsim/events{/privacy}","received_events_url":"https://api.github.com/users/ntsim/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":26,"created_at":"2018-07-22T23:50:08Z","updated_at":"2019-01-05T21:18:00Z","closed_at":"2018-08-29T18:12:45Z","author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/eduardoboucas/staticman/pulls/219","html_url":"https://github.com/eduardoboucas/staticman/pull/219","diff_url":"https://github.com/eduardoboucas/staticman/pull/219.diff","patch_url":"https://github.com/eduardoboucas/staticman/pull/219.patch"},"body":"Fixes #22 \r\n\r\nThis PR primarily adds support for GitLab across Staticman's API :rocket: :tada:. There is a quite a big surface area to this one @eduardoboucas, so there might be things that you might not be certain about. Let me know if there's anything that needs more work or I haven't quite covered!\r\n\r\nThis includes the following notable changes:\r\n\r\n### Staticman API config\r\n\r\n- `githubBaseUrl` added to allow URL of self-hosted GitHub API to be configured.\r\n- `githubAccessTokenUri` added to allow the OAuth access token endpoint of self-hosted GitHub instances to be configured.\r\n- `gitlabToken` added to allow configuration of Staticman's personal access token in the GitLab instance.\r\n- `gitlabBaseUrl  added to allow URL of self-hosted GitLab API to be configured. \r\n- `gitlabAccessTokenUri` added to allow the OAuth access token endpoint of self-hosted GitLab instances to be configured.\r\n- The new options all default to the publicly available instances of GitHub/GitLab.\r\n\r\n### Staticman site config (`staticman.yml`)\r\n\r\n- `gitlabAuth.clientId`, `gitlabAuth.clientSecret` and `gitlabAuth.redirectUri` added to provide OAuth configuration when a user wishes to authenticate via GitLab.\r\n- `githubAuth.redirectUri` added for parity with the new `gitlabAuth` options.\r\n- `auth.required` option added to determine if **any** authentication is required before the user can submit a comment through Staticman.\r\n\r\n### `/entry` endpoint \r\n\r\n- New URL pattern added: \r\n\t```\r\n\t/v3/entry/:service/:username/:repository/:branch/:property\r\n\t```\r\n- Accepts `gitlab` or `github` as a service parameter. This will be then used as the target for the consequent API calls.\r\n- Functionality mostly remains the same, but with Staticman now able to submit Merge Requests (PRs) to GitLab. MRs are set to automatically close the source branch, meaning that it is **not necessary** to have a webhook to close the branch with GitLab.\r\n- If `auth.required` site config option is true, then `options[auth-token]` and `options[auth-type]` must be passed through as well. \r\n- `options[auth-token]` replaces `option[github-token]` (as this was too specific to GitHub). \r\n- `options[auth-type]` has been added to allow the user to choose which authentication provider should be used i.e. `gitlab` or `github`. Any future integrations with other authentication providers would be expected to hook into this.\r\n- A new `User` model has been implemented which abstracts the user identity models from GitHub and GitLab. This only exposes common properties such as username, email, etc, hopefully simplifying future code.\r\n- The v2 API functionality is still implemented for backwards compatiblity. This includes the previous authentication behaviour where `options[github-token]` is used.\r\n\r\n### `/auth` endpoint\r\n\r\n- New URL pattern added: \r\n\t```\r\n\t/v3/auth/:service/:username/:repository/:branch/:property\r\n\t```\r\n- Accepts `gitlab` or `github` as a service parameter. This will be then used as the target for the consequent API calls.\r\n- The site owner will have to have set the correct options in their site config e.g. `gitlabAuth.clientId`, etc, to enable the user to authenticate with all authentication providers.\r\n- As part of GitLab's OAuth flow, a `redirectUri` **must** be provided (see [here](https://docs.gitlab.com/ee/api/oauth2.html#2-requesting-access-token)). Consequently, this has also been added for GitHub to be consistent.\r\n- The new `User` model is exposed here in the response's `user` property to confine the scope of this model for any future consumers.\r\n- The v2 API functionality is still implemented for backwards compatiblity (will return the GitHub API's user model in the response).\r\n\r\n### `/connect` endpoint\r\n\r\n- URL pattern changed to: \r\n\t```\r\n\t/v3/connect/:service/:username/:repository\r\n\t```\r\n- Remains largely unchanged, however with the addition of a service parameter. This has been added to be consistent and future proof against more Git service providers to connect through.\r\n- GitLab does not have collaborator invites, so this is currently not required for Staticman to collaborate on a project. The user can just add Staticman immediately.\r\n\r\n### Other changes\r\n\r\n- Minimum supported NodeJS version have been bumped up to `8.11.3` (the current LTS version).\r\n- New `class` syntax has been introduced in places such as the Git service classes.\r\n- Tests run 4x faster by improving how the test site config is setup before tests. Bugs have also been fixed due to config being modified between tests. Config is now mostly just copied to new objects between tests.\r\n- Various NPM dependencies have been changed/upgraded, such as:\r\n\t- `github` -> `@octokit/rest` as the previous package was deprecated.\r\n\t- `request-promise-native` -> `request-promise` as this interops with the GitLab package's `request-promise`.\r\n\t- `node-uuid` -> `uuid` as the previous package was deprecated."},"comment":{"url":"https://api.github.com/repos/eduardoboucas/staticman/issues/comments/451691067","html_url":"https://github.com/eduardoboucas/staticman/pull/219#issuecomment-451691067","issue_url":"https://api.github.com/repos/eduardoboucas/staticman/issues/219","id":451691067,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTY5MTA2Nw==","user":{"login":"VincentTam","id":5748535,"node_id":"MDQ6VXNlcjU3NDg1MzU=","avatar_url":"https://avatars0.githubusercontent.com/u/5748535?v=4","gravatar_id":"","url":"https://api.github.com/users/VincentTam","html_url":"https://github.com/VincentTam","followers_url":"https://api.github.com/users/VincentTam/followers","following_url":"https://api.github.com/users/VincentTam/following{/other_user}","gists_url":"https://api.github.com/users/VincentTam/gists{/gist_id}","starred_url":"https://api.github.com/users/VincentTam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VincentTam/subscriptions","organizations_url":"https://api.github.com/users/VincentTam/orgs","repos_url":"https://api.github.com/users/VincentTam/repos","events_url":"https://api.github.com/users/VincentTam/events{/privacy}","received_events_url":"https://api.github.com/users/VincentTam/received_events","type":"User","site_admin":false},"created_at":"2019-01-05T21:18:00Z","updated_at":"2019-01-05T21:18:00Z","author_association":"NONE","body":"@Kaligule It can _never_ be static since its endpoints respond dynamically to users' requests."}}
{"actor":{"display_login":"VincentTam"}}