[example][m] - changed styling and added octokit

This commit is contained in:
Luccas Mateus de Medeiros Gomes
2023-04-18 12:41:30 -03:00
parent 078e261e56
commit 868e9816a0
9 changed files with 1583 additions and 332 deletions

View File

@@ -1,5 +1,6 @@
import * as crypto from "crypto";
import axios from "axios";
import { Octokit } from "octokit"
export default class Project {
id: string;
@@ -8,6 +9,7 @@ export default class Project {
github_repo: string;
readme: string;
metadata: any;
repo_metadata: any;
constructor(owner: string, name: string) {
this.name = name;
@@ -22,6 +24,7 @@ export default class Project {
}
initFromGitHub = async () => {
const octokit = new Octokit()
// TODO: what if the repo doesn't exist?
await this.getFileContent("README.md")
.then((content) => (this.readme = content))
@@ -30,6 +33,9 @@ export default class Project {
await this.getFileContent("datapackage.json")
.then((content) => (this.metadata = content))
.catch((e) => (this.metadata = {}));
const github_metadata = await octokit.rest.repos.get({ owner: this.owner, repo: this.name })
this.repo_metadata = github_metadata.data ? github_metadata.data : null
};
getFileContent = (path, branch = "main") => {