mirror of
https://github.com/bendtherules/github-delete-unused-repos.git
synced 2026-08-18 22:02:57 +00:00
Export main 2 functions from gh + Use in index
Also reformatted gh
This commit is contained in:
@@ -73,7 +73,7 @@ interface ResponseWithMetaLink {
|
|||||||
|
|
||||||
interface ResponseWithDataArrayAndMeta<T>
|
interface ResponseWithDataArrayAndMeta<T>
|
||||||
extends ResponseWithDataArray<T>,
|
extends ResponseWithDataArray<T>,
|
||||||
ResponseWithMetaLink {}
|
ResponseWithMetaLink { }
|
||||||
|
|
||||||
interface ResponseFromGetUserRepo extends ResponseWithMetaLink {
|
interface ResponseFromGetUserRepo extends ResponseWithMetaLink {
|
||||||
data: RepoFromGetUserRepo[];
|
data: RepoFromGetUserRepo[];
|
||||||
@@ -163,7 +163,7 @@ interface RepoNameWithParentRepo {
|
|||||||
|
|
||||||
interface RepoNameWithBranchesAndParent
|
interface RepoNameWithBranchesAndParent
|
||||||
extends RepoNameWithBranches,
|
extends RepoNameWithBranches,
|
||||||
RepoNameWithParentRepo {}
|
RepoNameWithParentRepo { }
|
||||||
|
|
||||||
const username = 'rousan';
|
const username = 'rousan';
|
||||||
|
|
||||||
@@ -204,13 +204,13 @@ async function fetchRepoNameWithBranches(
|
|||||||
|
|
||||||
const branchesResponse: ResponseWithDataArray<
|
const branchesResponse: ResponseWithDataArray<
|
||||||
BranchFromGetBranches
|
BranchFromGetBranches
|
||||||
> = await paginate((tmpFirstParam: Octokit.ReposGetBranchesParams): Promise<
|
> = await paginate((tmpFirstParam: Octokit.ReposGetBranchesParams): Promise<
|
||||||
ResponseFromGetBranches
|
|
||||||
> => {
|
|
||||||
return (octokit.repos.getBranches(tmpFirstParam) as any) as Promise<
|
|
||||||
ResponseFromGetBranches
|
ResponseFromGetBranches
|
||||||
>;
|
> => {
|
||||||
}, params);
|
return (octokit.repos.getBranches(tmpFirstParam) as any) as Promise<
|
||||||
|
ResponseFromGetBranches
|
||||||
|
>;
|
||||||
|
}, params);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
repoName,
|
repoName,
|
||||||
@@ -319,31 +319,31 @@ async function fetchUserIsNotContributor(
|
|||||||
|
|
||||||
const responseFromGetContributors: ResponseWithDataArray<
|
const responseFromGetContributors: ResponseWithDataArray<
|
||||||
OwnerFromGetContributors
|
OwnerFromGetContributors
|
||||||
> = await paginate(
|
> = await paginate(
|
||||||
async (
|
async (
|
||||||
tmpFirstParam: Octokit.ReposGetContributorsParams
|
tmpFirstParam: Octokit.ReposGetContributorsParams
|
||||||
): Promise<ResponseWithDataArrayAndMeta<OwnerFromGetContributors>> => {
|
): Promise<ResponseWithDataArrayAndMeta<OwnerFromGetContributors>> => {
|
||||||
// Modify getContributors to return empty contributor data array instead of undefined for empty repos
|
// Modify getContributors to return empty contributor data array instead of undefined for empty repos
|
||||||
const response = await ((octokit.repos.getContributors(
|
const response = await ((octokit.repos.getContributors(
|
||||||
tmpFirstParam
|
tmpFirstParam
|
||||||
) as any) as Promise<ResponseFromGetContributors>);
|
) as any) as Promise<ResponseFromGetContributors>);
|
||||||
|
|
||||||
let dataNormalized = response.data;
|
let dataNormalized = response.data;
|
||||||
if (dataNormalized === undefined) {
|
if (dataNormalized === undefined) {
|
||||||
dataNormalized = [];
|
dataNormalized = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseNormalized: ResponseWithDataArrayAndMeta<
|
const responseNormalized: ResponseWithDataArrayAndMeta<
|
||||||
OwnerFromGetContributors
|
OwnerFromGetContributors
|
||||||
> = {
|
> = {
|
||||||
data: dataNormalized,
|
data: dataNormalized,
|
||||||
meta: response.meta,
|
meta: response.meta,
|
||||||
};
|
};
|
||||||
|
|
||||||
return responseNormalized;
|
return responseNormalized;
|
||||||
},
|
},
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
||||||
const contributors = responseFromGetContributors.data;
|
const contributors = responseFromGetContributors.data;
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ async function fetchUserIsNotContributor(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUnusedForkedRepos() {
|
export async function fetchUnusedForkedRepos() {
|
||||||
const params: Octokit.ReposGetForUserParams = {
|
const params: Octokit.ReposGetForUserParams = {
|
||||||
username,
|
username,
|
||||||
};
|
};
|
||||||
@@ -369,7 +369,7 @@ async function fetchUnusedForkedRepos() {
|
|||||||
): Promise<ResponseFromGetUserRepo> => {
|
): Promise<ResponseFromGetUserRepo> => {
|
||||||
return (octokit.repos.getForUser(tmpFirstParam) as any) as Promise<
|
return (octokit.repos.getForUser(tmpFirstParam) as any) as Promise<
|
||||||
ResponseFromGetUserRepo
|
ResponseFromGetUserRepo
|
||||||
>;
|
>;
|
||||||
},
|
},
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
@@ -514,10 +514,13 @@ async function fetchUnusedForkedRepos() {
|
|||||||
return unusedRepoNames;
|
return unusedRepoNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchUnusedForkedRepos().then(unusedRepoNames => {
|
|
||||||
// tslint:disable-next-line:no-console
|
export function runMain() {
|
||||||
console.log(unusedRepoNames);
|
fetchUnusedForkedRepos().then(unusedRepoNames => {
|
||||||
});
|
// tslint:disable-next-line:no-console
|
||||||
|
console.log(unusedRepoNames);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Next steps
|
// Next steps
|
||||||
//
|
//
|
||||||
|
|||||||
+4
-1
@@ -1,8 +1,10 @@
|
|||||||
import { Greeter } from './greeter';
|
import { Greeter } from './greeter';
|
||||||
|
// tslint:disable-next-line:ordered-imports
|
||||||
|
import { fetchUnusedForkedRepos, runMain } from './gh';
|
||||||
export * from './greeter';
|
export * from './greeter';
|
||||||
|
|
||||||
// tslint:disable-next-line:only-arrow-functions
|
// tslint:disable-next-line:only-arrow-functions
|
||||||
(function(currentWindow: Window) {
|
(function (currentWindow: Window) {
|
||||||
// execute when load index.js
|
// execute when load index.js
|
||||||
|
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
@@ -11,6 +13,7 @@ export * from './greeter';
|
|||||||
// assign Greeter to global
|
// assign Greeter to global
|
||||||
const myWindow = currentWindow as any;
|
const myWindow = currentWindow as any;
|
||||||
myWindow.Greeter = Greeter;
|
myWindow.Greeter = Greeter;
|
||||||
|
myWindow.runMain = runMain;
|
||||||
// we can use Greeter , execute following in console
|
// we can use Greeter , execute following in console
|
||||||
// var greet = new Greeter('myName');
|
// var greet = new Greeter('myName');
|
||||||
// greet.greet();
|
// greet.greet();
|
||||||
|
|||||||
Reference in New Issue
Block a user