Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Mar 17, 2022
1 parent e25a8eb commit bd7e692
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 34 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ main({
username: 'sonofmagic',
filepath: 'test/fixtures/README.md',
motto: false,
title: 'Hello world!'
title: 'Hello world!',
includeFork: 'true'
})
```

### Options

| Name | Type | Description | Default Value |
| -------- | ----------------- | ------------------------------------------ | ------------- |
| token | string | the repo PAT or GITHUB_TOKEN | |
| username | string | github username to generate markdown files | |
| filepath | string | main markdown file path | README.md |
| motto | string \| boolean | whether add powered by footer | 'true' | --- |
| title | string | main markdown h1 title | repo.name |
| Name | Type | Description | Default Value |
| ----------- | ----------------- | ------------------------------------------ | ------------- |
| token | string | the repo PAT or GITHUB_TOKEN | |
| username | string | github username to generate markdown files | |
| filepath | string | main markdown file path | README.md |
| motto | string \| boolean | whether add powered by footer | 'false' | --- |
| title | string | main markdown h1 title | repo.name |
| includeFork | string \| boolean | include forked repos | 'false' |
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ inputs:
description: 'github username to generate markdown files'
required: true
motto:
description: 'whether add powered by footer'
description: 'whether add powered by footer (boolean)'
default: 'true'
includeFork:
description: 'include forked repos (boolean)'
default: 'true'
filepath:
description: 'main markdown file path'
default: 'README.md'
Expand Down
2 changes: 1 addition & 1 deletion lib/action-140b734f.js → lib/action-af27701a.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index-7cc46d03.js → lib/index-09a51084.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-7cc46d03.js");require("fs/promises"),require("path"),exports.getRepos=e.getRepos,exports.main=e.main;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-09a51084.js");require("fs/promises"),require("path"),exports.getRepos=e.getRepos,exports.main=e.main;
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.0",
"version": "1.0.1",
"description": "github-repository-distributor",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions scripts/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ main({
token: process.env.GITHUB_TOKEN,
username: 'sonofmagic',
filepath: 'test/fixtures/README.md',
motto: false,
title: 'Hello world'
motto: 'true',
title: 'Hello world',
includeFork: 'true'
})
31 changes: 16 additions & 15 deletions src/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,22 @@ export async function makeTree (

const keys = Object.keys(dic)
const orderedKeys = orderBy(keys, (key) => dic[key].length, 'desc')

children.push({
type: 'heading',
depth: 2,
children: [
{
type: 'text',
value: 'Legend'
}
]
})
children.push({
type: 'text',
value: `${nameToEmoji.twisted_rightwards_arrows}:forked `
})
if (options.includeFork) {
children.push({
type: 'heading',
depth: 2,
children: [
{
type: 'text',
value: 'Legend'
}
]
})
children.push({
type: 'text',
value: `${nameToEmoji.twisted_rightwards_arrows}:forked `
})
}

for (let i = 0; i < orderedKeys.length; i++) {
const lang = orderedKeys[i]
Expand Down
6 changes: 4 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function getDefaults (): UserDefinedOptions {
username: 'sonofmagic',
filepath: 'README.md',
motto: true,
title: pkg.name
title: pkg.name,
includeFork: true
}
}

Expand All @@ -35,7 +36,8 @@ export function transfer (options?: RawUserDefinedOptions) {
if (options) {
opt = {
...options,
motto: parseBoolean(options.motto)
motto: parseBoolean(options.motto),
includeFork: parseBoolean(options.includeFork)
}
} else {
opt = {}
Expand Down
2 changes: 2 additions & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ export interface RawUserDefinedOptions {
title?: string
motto?: string | boolean
filepath?: string
includeFork?: string | boolean
}
export interface UserDefinedOptions {
token: string
username: string
title: string
motto: boolean
filepath: string
includeFork: boolean
}
8 changes: 6 additions & 2 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 } = options
const { token, username, includeFork } = options
let octokit
if (__isAction__) {
const { github } = await import('./action')
Expand Down Expand Up @@ -37,7 +37,11 @@ export async function getAllRepos (options: UserDefinedOptions) {
l = res.data.length
allRepos = allRepos.concat(res.data)
}
return uniqBy(allRepos, (repo) => repo.id)
const result = uniqBy(allRepos, (repo) => repo.id)
if (!includeFork) {
return result.filter((x) => !x.fork)
}
return result
}

export function groupByLang (repos: Repository[]) {
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,7 @@
1. [quickly-start-for-web-function](https://github.com/sonofmagic/quickly-start-for-web-function) (2021-08-06 12:25:11)

quickly-start-for-web-function

***

Generate by [`sonofmagic/github-repository-distributor`](https://github.com/sonofmagic/github-repository-distributor) at 2022-03-17 19:00:53

0 comments on commit bd7e692

Please sign in to comment.