Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Mar 20, 2022
1 parent 390248d commit eca367f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-repository-distributor",
"version": "1.0.1",
"version": "1.1.0",
"description": "github-repository-distributor",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions scripts/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ main({
title: 'Hello world',
includeFork: 'true',
includeArchived: 'true'
// onlyPrivate: true
})
3 changes: 2 additions & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { RestEndpointMethodTypes } from '@octokit/rest'
export type { Root, Content, Paragraph, ListItem, Link } from 'mdast'
export type { Dictionary } from 'lodash'
export type Repository =
RestEndpointMethodTypes['repos']['listForUser']['response']['data'][number]
| RestEndpointMethodTypes['repos']['listForUser']['response']['data'][number]
| RestEndpointMethodTypes['repos']['listForAuthenticatedUser']['response']['data'][number]

export interface RawUserDefinedOptions {
token: string
Expand Down
25 changes: 18 additions & 7 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export { dayjs }
declare var __isAction__: boolean

export async function getAllRepos (options: UserDefinedOptions) {
const { token, username, includeFork, includeArchived } = options
const { token, username, includeFork, includeArchived, onlyPrivate } = options
let octokit
if (__isAction__) {
const { github } = await import('./action')
Expand All @@ -27,12 +27,23 @@ export async function getAllRepos (options: UserDefinedOptions) {
let allRepos: Repository[] = []

while (l === perPage) {
const res = await octokit.rest.repos.listForUser({
username,
per_page: perPage,
page,
sort: 'updated'
})
let res
if (!onlyPrivate) {
res = await octokit.rest.repos.listForUser({
username,
per_page: perPage,
page,
sort: 'updated'
})
} else {
res = await octokit.rest.repos.listForAuthenticatedUser({
// username,
per_page: perPage,
page,
sort: 'updated',
visibility: 'private'
})
}
page++
l = res.data.length
allRepos = allRepos.concat(res.data)
Expand Down

0 comments on commit eca367f

Please sign in to comment.