@bigbinary/neeto-github-frontend 1.0.11 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -263
- package/app/javascript/src/translations/en.json +1 -0
- package/dist/index.cjs.js +145 -100
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +145 -102
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,296 +1,71 @@
|
|
|
1
1
|
# neeto-github-nano
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `neeto-github-nano` manages GitHub integration across neeto products.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Contents
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. [Development with Host Application](#development-with-host-application)
|
|
8
|
+
- [Engine](#engine)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Frontend package](#frontend-package)
|
|
12
|
+
- [Installation](#installation-1)
|
|
13
|
+
- [Components](#components)
|
|
14
|
+
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
gem "neeto-github-engine", git: "https://#{github_auth_string}@github.com/bigbinary/neeto-github-nano.git", branch: "stable"
|
|
11
|
-
|
|
12
|
-
gem "octokit"
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
And then execute:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
bundle
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Or use `gem install`:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
gem install neeto-github-engine octokit
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Migration
|
|
28
|
-
|
|
29
|
-
To Copy migration files, run:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
rails g neeto_github_engine:install
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
After adding the migration file, run:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
bundle exec rails db:migrate
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Integration
|
|
42
|
-
|
|
43
|
-
`neeto-github-engine` supports OAuth apps and GitHub apps. Depending upon the use case you can use either one or both together. Refer to the link below to understand the differences between a Github app and an OAuth app: <https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps>
|
|
44
|
-
|
|
45
|
-
1. [Integrate OAuth app](#integrate-oauth-app)
|
|
46
|
-
2. [Integrate GitHub app](#integrate-github-app)
|
|
47
|
-
|
|
48
|
-
## Integrate OAuth app
|
|
49
|
-
|
|
50
|
-
### Create an OAuth app on GitHub
|
|
51
|
-
|
|
52
|
-
Refer to this: <https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app>
|
|
16
|
+
## Development with Host Application
|
|
53
17
|
|
|
54
|
-
|
|
18
|
+
### Engine
|
|
19
|
+
The engine allows us to integrate OAuth apps and Github apps in the neeto applications.
|
|
55
20
|
|
|
56
|
-
|
|
57
|
-
https://connect.neeto<AppName>.com
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Here, the subdomain can be anything like `connect` or `app`.
|
|
61
|
-
The domain will be the application domain.
|
|
62
|
-
Create different OAuth apps for staging and production.
|
|
63
|
-
|
|
64
|
-
After getting the `client_id` and `client_secret`,
|
|
65
|
-
add this to the `secrets.yml` file in your application.
|
|
66
|
-
|
|
67
|
-
```yml
|
|
68
|
-
default:
|
|
69
|
-
github_oauth_app:
|
|
70
|
-
client_id: <%= ENV["GITHUB_CLIENT_ID"] %>
|
|
71
|
-
client_secret: <%= ENV["GITHUB_CLIENT_SECRET"] %>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
and add the secrets to ENV.
|
|
75
|
-
|
|
76
|
-
### Add JWT private and public keys
|
|
77
|
-
|
|
78
|
-
Run the following ruby command to generate an RSA key pair:
|
|
79
|
-
|
|
80
|
-
```ruby
|
|
81
|
-
rsa = OpenSSL::PKey::RSA.generate(2048)
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
The following command prints the private key:
|
|
85
|
-
|
|
86
|
-
```ruby
|
|
87
|
-
rsa.to_s
|
|
88
|
-
```
|
|
21
|
+
#### Installation
|
|
89
22
|
|
|
90
|
-
|
|
23
|
+
1. Add gems to your application's Gemfile:
|
|
91
24
|
|
|
92
25
|
```ruby
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Store the private and public keys as environment variables,
|
|
97
|
-
let's say, as `JWT_PRIVATE_KEY` and `JWT_PUBLIC_KEY`, respectively.
|
|
98
|
-
Then add the keys to the `secrets.yml` file in your application,
|
|
99
|
-
as shown below:
|
|
26
|
+
gem "octokit"
|
|
100
27
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
private_key: <%= ENV['JWT_PRIVATE_KEY'].inspect %>
|
|
105
|
-
public_key: <%= ENV['JWT_PUBLIC_KEY'].inspect %>
|
|
28
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
29
|
+
gem "neeto-github-engine"
|
|
30
|
+
end
|
|
106
31
|
```
|
|
107
32
|
|
|
108
|
-
|
|
33
|
+
2. And then execute:
|
|
109
34
|
|
|
110
35
|
```bash
|
|
111
|
-
|
|
36
|
+
bundle install
|
|
112
37
|
```
|
|
113
38
|
|
|
114
|
-
|
|
39
|
+
3. Copy migration files, run:
|
|
115
40
|
|
|
116
41
|
```bash
|
|
117
|
-
rails g neeto_github_engine:
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
This will add `NeetoGithubEngine::Integratable` concern to the `Organization` model.
|
|
121
|
-
|
|
122
|
-
### Controllers to store the access token
|
|
123
|
-
|
|
124
|
-
- `AuthorizeController` (`/neeto_github/authorize`)
|
|
125
|
-
This action accepts 4 params:
|
|
126
|
-
|
|
127
|
-
1. integrator_type
|
|
128
|
-
2. integrator_id
|
|
129
|
-
3. redirect_path
|
|
130
|
-
4. scope
|
|
131
|
-
|
|
132
|
-
For Example, if the `Organization` is the integrator of accounts then redirect the user to:
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
/neeto_github/authorize?${qs.stringify({
|
|
136
|
-
integrator_type: 'Organization',
|
|
137
|
-
integrator_id: organizationId,
|
|
138
|
-
scope: "repo",
|
|
139
|
-
redirect_path: `/settings/github-integration`,
|
|
140
|
-
})}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
where the `scope` is what scope level application needs to access GitHub and
|
|
144
|
-
`redirect_path` is where the user needs to be redirected after the authorization is completed.
|
|
145
|
-
|
|
146
|
-
### Controllers
|
|
147
|
-
|
|
148
|
-
```ruby
|
|
149
|
-
NeetoGithubEngine::AccountsController
|
|
42
|
+
rails g neeto_github_engine:install
|
|
150
43
|
```
|
|
151
44
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Mandatory params:
|
|
155
|
-
|
|
156
|
-
- `integrator_id`
|
|
157
|
-
- `integrator_type`
|
|
158
|
-
|
|
159
|
-
### Add Repository to Entity
|
|
45
|
+
4. After adding the migration file, run:
|
|
160
46
|
|
|
161
47
|
```bash
|
|
162
|
-
rails
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
The above command will:
|
|
166
|
-
|
|
167
|
-
1. Create a file in `app/models` with the name `<entity>Repository.rb`.
|
|
168
|
-
2. Add an association to the entity model.
|
|
169
|
-
|
|
170
|
-
### Link Pull Request With Entity
|
|
171
|
-
```
|
|
172
|
-
include NeetoGithubEngine::Linkable
|
|
173
|
-
```
|
|
174
|
-
The above concern will associate the entity with `NeetoGithubEngine::PullRequest` Model.
|
|
175
|
-
|
|
176
|
-
### Using controllers
|
|
177
|
-
|
|
178
|
-
- Controllers must inherit from
|
|
179
|
-
|
|
180
|
-
```ruby
|
|
181
|
-
NeetoGithubEngine::BaseController
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Mandatory params: account_id
|
|
185
|
-
|
|
186
|
-
## Integrate GitHub app
|
|
187
|
-
|
|
188
|
-
### Create a GitHub app in GitHub
|
|
189
|
-
|
|
190
|
-
Refer: https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app
|
|
191
|
-
|
|
192
|
-
**⚠️ When creating a GitHub app make sure to not to include spaces or special characters (except hyphen ``-``) in the GitHub App name field**
|
|
193
|
-
|
|
194
|
-
Set the post installation setup url in the GitHub app's general settings page as:
|
|
195
|
-
```
|
|
196
|
-
https://app.neeto<AppName>.com/neeto_github/app_installations/callbacks
|
|
197
|
-
```
|
|
198
|
-
Here, the subdomain can be anything like connect or app. The domain will be the application domain.
|
|
199
|
-
|
|
200
|
-
Enable the webhooks and set the webhook url as:
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
https://app.neeto<AppName>.com/neeto_github/webhooks
|
|
204
|
-
```
|
|
205
|
-
You can choose a random string of text with high entropy as `webhook_secret`.
|
|
206
|
-
|
|
207
|
-
After getting the `app_id`, `app_name`, `private_key` and `webhook_secret`, add them to the secrets.yml file in your application.
|
|
208
|
-
|
|
209
|
-
```yml
|
|
210
|
-
default: &default
|
|
211
|
-
github_app:
|
|
212
|
-
id: <%= ENV["GITHUB_APP_ID"] %>
|
|
213
|
-
name: <%= ENV["GITHUB_APP_NAME"] %>
|
|
214
|
-
private_key: <%= ENV["GITHUB_APP_PRIVATE_KEY"].inspect %>
|
|
215
|
-
webhook_secret: <%= ENV["GITHUB_APP_WEBHOOK_SECRET"] %>
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Follow the steps of OAuth app integration for adding [JWT private and public keys](#add-jwt-private-and-public-keys) and [association](#add-association).
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
### Install GitHub app
|
|
222
|
-
|
|
223
|
-
`AppInstallationsController#new` Used to install the github app in the user specified repositories. This action accepts 4 URL query parameters:
|
|
224
|
-
|
|
225
|
-
1. integrator_type
|
|
226
|
-
2. integrator_id
|
|
227
|
-
3. redirect_path
|
|
228
|
-
4. fallback_redirect_path
|
|
229
|
-
|
|
230
|
-
Here the `redirect_path` is where the user needs to be redirected after the installation is completed and `fallback_redirect_path` is where the user needs to redirected in case of any error.
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
GET /neeto_github/app_installations/new?integrator_type=<integrator_type>&integrator_id=<integrator_id>&redirect_path=/settings&fallback_redirect_path=/settings
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Fetch app installations
|
|
237
|
-
|
|
238
|
-
`AppInstallationsController#index` Used to list app installations that are associated with an integrator. This action accepts 4 URL query parameters:
|
|
239
|
-
|
|
240
|
-
1. integrator_type
|
|
241
|
-
2. integrator_id
|
|
242
|
-
3. page_size (optional)
|
|
243
|
-
4. page (optional)
|
|
244
|
-
|
|
245
|
-
```
|
|
246
|
-
GET /neeto_github/app_installations?integrator_type=<integrator_type>&integrator_id=<integrator_id>&page_size=10&page=1
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### Destroy app installation
|
|
250
|
-
|
|
251
|
-
`AppInstallationsController#destroy` Used to destroy a particular `AppInstallation`. This action accepts 3 URL parameters:
|
|
252
|
-
|
|
253
|
-
Query parameters:
|
|
254
|
-
1. integrator_type
|
|
255
|
-
2. integrator_id
|
|
256
|
-
|
|
257
|
-
Path parameters:
|
|
258
|
-
1. app_installation_id
|
|
259
|
-
|
|
260
|
-
```
|
|
261
|
-
DELETE /neeto_github/app_installations/<app_installation_id>?integrator_type=<integrator_type>&integrator_id=<integrator_id>
|
|
48
|
+
bundle exec rails db:migrate
|
|
262
49
|
```
|
|
263
50
|
|
|
264
|
-
|
|
51
|
+
#### Usage
|
|
52
|
+
- [Integration](./docs/engine/integration.md)
|
|
265
53
|
|
|
266
|
-
|
|
54
|
+
### Frontend package
|
|
55
|
+
The frontend package exports several components.
|
|
267
56
|
|
|
268
|
-
|
|
269
|
-
1. integrator_type
|
|
270
|
-
2. integrator_id
|
|
57
|
+
#### Installation
|
|
271
58
|
|
|
272
|
-
|
|
273
|
-
1. app_installation_id
|
|
59
|
+
Install the latest package using the below command -
|
|
274
60
|
|
|
61
|
+
```bash
|
|
62
|
+
yarn add @bigbinary/neeto-github-frontend
|
|
275
63
|
```
|
|
276
|
-
GET /neeto_github/app_installations/<app_installation_id>/repositories?integrator_id=<integrator_id>&integrator_type=<integrator_type>
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### Get an issue detail
|
|
280
|
-
|
|
281
|
-
`AppInstallations::Repositories::IssuesController#Issue` This action provides the details of an github issue. This action accepts 5 URL parameters:
|
|
282
64
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
65
|
+
#### Components
|
|
66
|
+
- [NeetoGithubNanoContainer](./docs/frontend/components/NeetoGithubNanoContainer/README.md)
|
|
67
|
+
- [NeetoGithubNanoPane](./docs/frontend/components/NeetoGithubNanoPane/README.md)
|
|
286
68
|
|
|
287
|
-
|
|
288
|
-
1. app_installation_id
|
|
289
|
-
4. repository_full_name
|
|
290
|
-
3. issue_number
|
|
69
|
+
## Instructions for Publishing
|
|
291
70
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
```
|
|
295
|
-
GET /neeto_github/app_installations/<app_installation_id>/repositories/<url_encoded_repository_full_name>/issues/<issue_number>?integrator_id=<integrator_id>&integrator_type=<integrator_type>
|
|
296
|
-
```
|
|
71
|
+
Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"neetoGithub": {
|
|
3
3
|
"connect": "Connect",
|
|
4
4
|
"github": "GitHub",
|
|
5
|
+
"fetchingRepos": "Please wait for a moment while we fetch your repositories",
|
|
5
6
|
"noRepos": "No repositories found",
|
|
6
7
|
"noReposDescription": "Connect a GitHub repository to begin using your existing repos for new services.",
|
|
7
8
|
"notConnectedDescription": "Connect your {{appName, anyCase}} account to GitHub to begin using your existing repos for new services.",
|