fix(core): update

This commit is contained in:
Philipp Kunz 2021-05-16 23:59:47 +00:00
parent 217724d836
commit c8dc59cdf2
4 changed files with 24 additions and 11 deletions

View File

@ -39,4 +39,4 @@
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ]
} }

View File

@ -34,7 +34,6 @@ For further information read the linked docs at the top of this README.
[![repo-footer](https://mojoio.gitlab.io/assets/repo-footer.svg)](https://mojo.io) [![repo-footer](https://mojoio.gitlab.io/assets/repo-footer.svg)](https://mojo.io)
## Contribution ## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -46,12 +46,16 @@ export class GitlabAccount {
for (const link of links) { for (const link of links) {
linkObjects.push({ linkObjects.push({
original: link, original: link,
link: findLinkName(link) link: findLinkName(link),
}); });
} }
const next = linkObjects.find(linkObject => linkObject.original.includes('rel="next"')); const next = linkObjects.find((linkObject) => linkObject.original.includes('rel="next"'));
if (next && response.body instanceof Array) { if (next && response.body instanceof Array) {
const nextResponse = await this.request(methodArg, next.link.replace('https://gitlab.com/api/v4', ''), {}); const nextResponse = await this.request(
methodArg,
next.link.replace('https://gitlab.com/api/v4', ''),
{}
);
response.body = response.body.concat(nextResponse); response.body = response.body.concat(nextResponse);
} }
} }

View File

@ -111,7 +111,7 @@ export class GitlabProject {
per_page: '100', per_page: '100',
} }
); );
const allProjects: GitlabProject[] = [] const allProjects: GitlabProject[] = [];
for (const projectData of response) { for (const projectData of response) {
allProjects.push(new GitlabProject(projectData, gitlabGroupArg)); allProjects.push(new GitlabProject(projectData, gitlabGroupArg));
} }
@ -127,11 +127,21 @@ export class GitlabProject {
this.gitlabGroupRef = gitlabGroupRefArg; this.gitlabGroupRef = gitlabGroupRefArg;
} }
public async getFileFromProject(filePathArg: string, refArg: string): Promise<plugins.smartfile.Smartfile> { public async getFileFromProject(
const response = await this.gitlabGroupRef.gitlabAccountRef.request('GET', `/projects/${this.data.id}/repository/files/${filePathArg}`, { filePathArg: string,
ref: refArg refArg: string
}); ): Promise<plugins.smartfile.Smartfile> {
return plugins.smartfile.Smartfile.fromBuffer(filePathArg, Buffer.from(response.content, response.encoding)); const response = await this.gitlabGroupRef.gitlabAccountRef.request(
'GET',
`/projects/${this.data.id}/repository/files/${filePathArg}`,
{
ref: refArg,
}
);
return plugins.smartfile.Smartfile.fromBuffer(
filePathArg,
Buffer.from(response.content, response.encoding)
);
} }
public async getReadmeAsMarkdown(refArg: string = 'master'): Promise<string> { public async getReadmeAsMarkdown(refArg: string = 'master'): Promise<string> {