@venturialstd/gitlab 0.0.1 → 0.0.2
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 +26 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @venturialstd/gitlab
|
|
1
|
+
# @venturialstd/gitlab
|
|
2
2
|
|
|
3
3
|
A lightweight **NestJS SDK for GitLab**, developed by **Venturial**, that allows you to interact with GitLab projects, merge requests, and repository files. Designed to be used by directly instantiating a client with custom configuration, without depending on a global module. Ideal for projects under the **Venturial organization**.
|
|
4
4
|
|
|
@@ -17,9 +17,9 @@ A lightweight **NestJS SDK for GitLab**, developed by **Venturial**, that allows
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @venturialstd/gitlab
|
|
20
|
+
npm install @venturialstd/gitlab
|
|
21
21
|
# or
|
|
22
|
-
yarn add @venturialstd/gitlab
|
|
22
|
+
yarn add @venturialstd/gitlab
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
---
|
|
@@ -32,21 +32,28 @@ You can create a client anywhere in your project and pass the host and token:
|
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
34
|
import { Injectable } from "@nestjs/common";
|
|
35
|
-
import { GitlabClient } from "@venturialstd/gitlab
|
|
35
|
+
import { GitlabClient, GitlabProjectService } from "@venturialstd/gitlab";
|
|
36
36
|
import { HttpService } from "@nestjs/axios";
|
|
37
37
|
|
|
38
38
|
@Injectable()
|
|
39
39
|
export class GitlabClientProvider {
|
|
40
40
|
private client: GitlabClient;
|
|
41
|
+
private projectService: GitlabProjectService;
|
|
41
42
|
|
|
42
43
|
constructor(private readonly httpService: HttpService) {}
|
|
43
44
|
|
|
44
|
-
async getClient(host: string, token: string)
|
|
45
|
+
private async getClient(host: string, token: string) {
|
|
45
46
|
if (!this.client) {
|
|
46
47
|
this.client = new GitlabClient(this.httpService, { host, token });
|
|
47
48
|
}
|
|
48
49
|
return this.client;
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
async getProjectService() {
|
|
53
|
+
if (!this.projectService)
|
|
54
|
+
this.projectService = new GitlabProjectService(await this.getClient());
|
|
55
|
+
return this.projectService;
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
```
|
|
52
59
|
|
|
@@ -63,25 +70,14 @@ import { GitlabClient } from "@venturialstd/gitlab-sdk";
|
|
|
63
70
|
export class HarveyGitlabService {
|
|
64
71
|
constructor(private readonly gitlabClientProvider: GitlabClientProvider) {}
|
|
65
72
|
|
|
66
|
-
async reviewMergeRequest(projectName: string
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return "No open merge requests";
|
|
75
|
-
|
|
76
|
-
const mrId = mergeRequests[0].iid;
|
|
77
|
-
const diff = await client.getMergeRequestDiff(projectName, mrId);
|
|
78
|
-
const fileContent = await client.getFile(projectName, "README.md");
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
mergeRequest: mergeRequests[0],
|
|
82
|
-
diff,
|
|
83
|
-
fileContent,
|
|
84
|
-
};
|
|
73
|
+
async reviewMergeRequest(projectName: string) {
|
|
74
|
+
const gitlabProjectService =
|
|
75
|
+
await this.gitlabClientProvider.getProjectService();
|
|
76
|
+
|
|
77
|
+
const mergeRequests =
|
|
78
|
+
await gitlabProjectService.getMergeRequests(projectId);
|
|
79
|
+
|
|
80
|
+
return mergeRequests;
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
83
|
```
|
|
@@ -90,13 +86,13 @@ export class HarveyGitlabService {
|
|
|
90
86
|
|
|
91
87
|
## API
|
|
92
88
|
|
|
93
|
-
### GitlabClient
|
|
89
|
+
### GitlabClient | GitlabProjectService
|
|
94
90
|
|
|
95
|
-
| Method | Parameters
|
|
96
|
-
| ------------------------------------------------------------ |
|
|
97
|
-
| `getMergeRequests(projectId: string)` |
|
|
98
|
-
| `getMergeRequestDiff(projectId: string, mrId: string)` |
|
|
99
|
-
| `getFile(projectId: string, filePath: string, ref?: string)` |
|
|
91
|
+
| Method | Parameters | Description |
|
|
92
|
+
| ------------------------------------------------------------ | ---------------------------------------------------- | -------------------------------------------- |
|
|
93
|
+
| `getMergeRequests(projectId: string)` | projectId | Returns a list of open merge requests |
|
|
94
|
+
| `getMergeRequestDiff(projectId: string, mrId: string)` | projectId, mrId | Returns the raw diff of a merge request |
|
|
95
|
+
| `getFile(projectId: string, filePath: string, ref?: string)` | projectId, filePath, optional ref (default `"main"`) | Returns the raw content of a repository file |
|
|
100
96
|
|
|
101
97
|
---
|
|
102
98
|
|