3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,4 +7,5 @@ dist-ssr
|
|||||||
.env
|
.env
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
api/development/console.log
|
api/development/console.log
|
||||||
.pnpm-debug.log
|
.pnpm-debug.log
|
||||||
|
yarn.lock
|
@@ -18,7 +18,7 @@
|
|||||||
let repositories = [];
|
let repositories = [];
|
||||||
|
|
||||||
function dashify(str, options) {
|
function dashify(str, options) {
|
||||||
if (typeof str !== "string") return str
|
if (typeof str !== "string") return str;
|
||||||
return str
|
return str
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/\W/g, m => (/[À-ž]/.test(m) ? m : "-"))
|
.replace(/\W/g, m => (/[À-ž]/.test(m) ? m : "-"))
|
||||||
@@ -44,6 +44,14 @@
|
|||||||
loading.branches = false;
|
loading.branches = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getGithubRepos(id, page) {
|
||||||
|
const data = await $fetch(
|
||||||
|
`https://api.github.com/user/installations/${id}/repositories?per_page=100&page=${page}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadGithub() {
|
async function loadGithub() {
|
||||||
try {
|
try {
|
||||||
const { installations } = await $fetch(
|
const { installations } = await $fetch(
|
||||||
@@ -55,12 +63,29 @@
|
|||||||
$application.github.installation.id = installations[0].id;
|
$application.github.installation.id = installations[0].id;
|
||||||
$application.github.app.id = installations[0].app_id;
|
$application.github.app.id = installations[0].app_id;
|
||||||
|
|
||||||
const data = await $fetch(
|
let page = 1;
|
||||||
`https://api.github.com/user/installations/${$application.github.installation.id}/repositories?per_page=10000`,
|
let userRepos = 0;
|
||||||
|
const data = await getGithubRepos(
|
||||||
|
$application.github.installation.id,
|
||||||
|
page,
|
||||||
);
|
);
|
||||||
|
|
||||||
repositories = data.repositories;
|
repositories = repositories.concat(data.repositories);
|
||||||
const foundRepositoryOnGithub = data.repositories.find(
|
userRepos = data.total_count;
|
||||||
|
|
||||||
|
if (userRepos > repositories.length) {
|
||||||
|
while (userRepos > repositories.length) {
|
||||||
|
page = page + 1;
|
||||||
|
const repos = await getGithubRepos(
|
||||||
|
$application.github.installation.id,
|
||||||
|
page,
|
||||||
|
);
|
||||||
|
|
||||||
|
repositories = repositories.concat(repos.repositories);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const foundRepositoryOnGithub = repositories.find(
|
||||||
r =>
|
r =>
|
||||||
r.full_name ===
|
r.full_name ===
|
||||||
`${$application.repository.organization}/${$application.repository.name}`,
|
`${$application.repository.organization}/${$application.repository.name}`,
|
||||||
|
Reference in New Issue
Block a user