From 791b43dc1104a7e2a5189dc52b97ede3b7112f7f Mon Sep 17 00:00:00 2001 From: sato yoshiyuki Date: Tue, 11 May 2021 19:45:34 +0900 Subject: [PATCH 1/4] fix: github-graphsql.ts --- spec/dummy-data.ts | 53 ++++++++++++++++++++++++++++++++++++- spec/github-graphql.spec.ts | 3 +-- src/github-graphql.ts | 2 +- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/spec/dummy-data.ts b/spec/dummy-data.ts index 84dbed2..de565a0 100644 --- a/spec/dummy-data.ts +++ b/spec/dummy-data.ts @@ -2,9 +2,10 @@ import * as client from '../src/github-graphql'; export const dummyData: client.ResponseType = { "data": { - "viewer": { + "user": { "contributionsCollection": { "contributionCalendar": { + "isHalloween": false, "totalContributions": 366, "weeks": [ { @@ -2236,6 +2237,56 @@ export const dummyData: client.ResponseType = { "totalRepositoryContributions": 6 }, "repositories": { + "edges": [ + { + "cursor": "a", + }, + { + "cursor": "b", + }, + { + "cursor": "c", + }, + { + "cursor": "d", + }, + { + "cursor": "e", + }, + { + "cursor": "f", + }, + { + "cursor": "g", + }, + { + "cursor": "h", + }, + { + "cursor": "i", + }, + { + "cursor": "j", + }, + { + "cursor": "k", + }, + { + "cursor": "l", + }, + { + "cursor": "m", + }, + { + "cursor": "n", + }, + { + "cursor": "o", + }, + { + "cursor": "p", + } + ], "nodes": [ { "forkCount": 0, diff --git a/spec/github-graphql.spec.ts b/spec/github-graphql.spec.ts index d8f10a7..1d4a34f 100644 --- a/spec/github-graphql.spec.ts +++ b/spec/github-graphql.spec.ts @@ -12,8 +12,7 @@ afterEach(() => { describe('github-graphql', () => { it('fetchData', async () => { mock.onPost(client.URL).reply(200, dummyData); - const res = await client.fetchData("dummy"); - + const res = await client.fetchData("dummy", "username", 100); expect(res).toEqual(dummyData); }); }); diff --git a/src/github-graphql.ts b/src/github-graphql.ts index 539012a..ecbd95f 100644 --- a/src/github-graphql.ts +++ b/src/github-graphql.ts @@ -142,7 +142,7 @@ export const fetchData = async ( headers: headers, }); const result = response.data.data; - if (result) { + if (result && result.user.repositories.nodes.length === maxReposOneQuery) { const repos1 = result.user.repositories; let cursor = repos1.edges[repos1.edges.length - 1].cursor; while (repos1.nodes.length < maxRepos) { From dc55db45c0bcfb40fc119284481a4a45523b7251 Mon Sep 17 00:00:00 2001 From: sato yoshiyuki Date: Tue, 11 May 2021 19:46:31 +0900 Subject: [PATCH 2/4] lint --- src/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0b9489d..fb32d7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,9 +11,8 @@ export const main = async (): Promise => { core.setFailed('GITHUB_TOKEN is empty'); return; } - const userName = 3 <= process.argv.length - ? process.argv[2] - : process.env.USERNAME; + const userName = + 3 <= process.argv.length ? process.argv[2] : process.env.USERNAME; if (!userName) { core.setFailed('USERNAME is empty'); return; From 2f028c7ef95c06a36037eef727b725cfa275aa92 Mon Sep 17 00:00:00 2001 From: sato yoshiyuki Date: Tue, 11 May 2021 19:47:11 +0900 Subject: [PATCH 3/4] build 0.2.0 --- dist/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index f91df26..c6aad55 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1078,7 +1078,7 @@ const fetchData = async (token, userName, maxRepos) => { headers: headers, }); const result = response.data.data; - if (result) { + if (result && result.user.repositories.nodes.length === maxReposOneQuery) { const repos1 = result.user.repositories; let cursor = repos1.edges[repos1.edges.length - 1].cursor; while (repos1.nodes.length < maxRepos) { @@ -1164,9 +1164,7 @@ const main = async () => { core.setFailed('GITHUB_TOKEN is empty'); return; } - const userName = 3 <= process.argv.length - ? process.argv[2] - : process.env.USERNAME; + const userName = 3 <= process.argv.length ? process.argv[2] : process.env.USERNAME; if (!userName) { core.setFailed('USERNAME is empty'); return; From 27f1bd928a2f156973a45801954179d8a78fd6f7 Mon Sep 17 00:00:00 2001 From: sato yoshiyuki Date: Tue, 11 May 2021 19:47:18 +0900 Subject: [PATCH 4/4] release 0.2.0 --- CHANGE_LOG.md | 21 +++++++++++++++++++++ README.md | 2 +- docs/README.ja-jp.md | 4 ++-- package.json | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 CHANGE_LOG.md diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md new file mode 100644 index 0000000..68c9b8f --- /dev/null +++ b/CHANGE_LOG.md @@ -0,0 +1,21 @@ +# Change Log + +## 2021-05-11, 0.2.0 release + +* The repositories to be aggregated are only those owned by the user. +* Allow the number of repositories to be aggregated to be defined by environment variables. + * `MAX_REPOS` : (optional) max repositories, default 100 +* Make the colors of the four seasons mode every week and make a gradation. + * The image colors of each season are as follows. + * spring flowers + * summer leaves + * autumn leaves + * winter snow +* Label the radar chart scale with "1-, 10, 100, 1K, 10K+". +* Supports Halloween mode on github. +* The USERNAME can also be specified from the argument. + * Usage: `node dist/index.js ` without env `USERNAME` + +## 2021-05-09, 0.1.0 release + +First release. diff --git a/README.md b/README.md index 86b85c7..9d4ce4a 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ This will add the action to the repository. #### Environment variables * `GITHUB_TOKEN` : (required) access token -* `USERNAME` : (required) target user name +* `USERNAME` : (required) target user name (or specify with an argument). * `MAX_REPOS` : (optional) max repositories, default 100 - since ver. 0.2.0 ### step 3. Manually launch the action diff --git a/docs/README.ja-jp.md b/docs/README.ja-jp.md index ab934b7..6aee7b9 100644 --- a/docs/README.ja-jp.md +++ b/docs/README.ja-jp.md @@ -64,8 +64,8 @@ jobs: #### 環境変数 * `GITHUB_TOKEN` : (必須) アクセストークン -* `USERNAME` : (必須) 対象のユーザー名 -* `MAX_REPOS` : (任意) 最大のリポジトリ数。デフォルトは10 - バージョン 0.2.0 で追加 +* `USERNAME` : (必須) 対象のユーザー名. (あるいは引数で指定する) +* `MAX_REPOS` : (任意) 最大のリポジトリ数。デフォルトは100 - バージョン 0.2.0 で追加 ### 手順 3. アクションを手動起動する diff --git a/package.json b/package.json index 9770e9b..08e2971 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-profile-3d-contrib", - "version": "0.1.0", + "version": "0.2.0", "description": "Generate profile 3D Contributions", "main": "dist/index.js", "scripts": {