155 lines
6.9 KiB
Diff
155 lines
6.9 KiB
Diff
diff --git a/dist/get-github-info.cjs.dev.js b/dist/get-github-info.cjs.dev.js
|
|
index 4f70e5c2113328562d998f7234d41fa5b40059e2..56a71544cfd76104a7d69b72bd268eed6f29e8f6 100644
|
|
--- a/dist/get-github-info.cjs.dev.js
|
|
+++ b/dist/get-github-info.cjs.dev.js
|
|
@@ -169,13 +169,19 @@ const GHDataLoader = new DataLoader__default['default'](async requests => {
|
|
|
|
repos[repo].push(data);
|
|
});
|
|
+ // I need to temporarily reduce the amount of commits we're fetching from GitHub to avoid errors from GitHub graphql API
|
|
+ const medusaCommits = repos["medusajs/medusa"];
|
|
+ const reducedCommits = medusaCommits.slice(0, 100) // 100 is an arbitrary number, we just need enough to have some commits with changesets
|
|
+ const reducedRepos = {
|
|
+ "medusajs/medusa": reducedCommits,
|
|
+ };
|
|
const data = await fetch__default['default']("https://api.github.com/graphql", {
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: `Token ${process.env.GITHUB_TOKEN}`
|
|
},
|
|
body: JSON.stringify({
|
|
- query: makeQuery(repos)
|
|
+ query: makeQuery(reducedRepos)
|
|
})
|
|
}).then(x => x.json());
|
|
|
|
@@ -232,11 +238,11 @@ async function getInfo(request) {
|
|
}, request));
|
|
let user = null;
|
|
|
|
- if (data.author && data.author.user) {
|
|
+ if (data && data.author && data.author.user) {
|
|
user = data.author.user;
|
|
}
|
|
|
|
- let associatedPullRequest = data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => {
|
|
+ let associatedPullRequest = data && data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => {
|
|
if (a.mergedAt === null && b.mergedAt === null) {
|
|
return 0;
|
|
}
|
|
@@ -262,7 +268,7 @@ async function getInfo(request) {
|
|
user: user ? user.login : null,
|
|
pull: associatedPullRequest ? associatedPullRequest.number : null,
|
|
links: {
|
|
- commit: `[\`${request.commit}\`](${data.commitUrl})`,
|
|
+ commit: `[\`${request.commit}\`](${data && data.commitUrl})`,
|
|
pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null,
|
|
user: user ? `[@${user.login}](${user.url})` : null
|
|
}
|
|
diff --git a/dist/get-github-info.cjs.prod.js b/dist/get-github-info.cjs.prod.js
|
|
index 879e55a7de71b291b021c6d0162e1577ab482a5d..8f89225d611a706a8336437cccb21861463e1583 100644
|
|
--- a/dist/get-github-info.cjs.prod.js
|
|
+++ b/dist/get-github-info.cjs.prod.js
|
|
@@ -76,13 +76,19 @@ const GHDataLoader = new DataLoader__default.default((async requests => {
|
|
let {repo: repo} = _ref, data = _objectWithoutProperties(_ref, _excluded);
|
|
void 0 === repos[repo] && (repos[repo] = []), repos[repo].push(data);
|
|
}));
|
|
+ // I need to temporarily reduce the amount of commits we're fetching from GitHub to avoid errors from GitHub graphql API
|
|
+ const medusaCommits = repos["medusajs/medusa"];
|
|
+ const reducedCommits = medusaCommits.slice(0, 100) // 100 is an arbitrary number, we just need enough to have some commits with changesets
|
|
+ const reducedRepos = {
|
|
+ "medusajs/medusa": reducedCommits,
|
|
+ };
|
|
const data = await fetch__default.default("https://api.github.com/graphql", {
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: "Token " + process.env.GITHUB_TOKEN
|
|
},
|
|
body: JSON.stringify({
|
|
- query: makeQuery(repos)
|
|
+ query: makeQuery(reducedRepos)
|
|
})
|
|
}).then((x => x.json()));
|
|
if (data.errors) throw new Error("An error occurred when fetching data from GitHub\n" + JSON.stringify(data.errors, null, 2));
|
|
diff --git a/dist/get-github-info.esm.js b/dist/get-github-info.esm.js
|
|
index 8978595dac32b007165ba8f87b749c8733ab123f..44a98818ffaced048f4fc75a771c7b52aa6eb9fe 100644
|
|
--- a/dist/get-github-info.esm.js
|
|
+++ b/dist/get-github-info.esm.js
|
|
@@ -160,13 +160,19 @@ const GHDataLoader = new DataLoader(async requests => {
|
|
|
|
repos[repo].push(data);
|
|
});
|
|
+ // I need to temporarily reduce the amount of commits we're fetching from GitHub to avoid errors from GitHub graphql API
|
|
+ const medusaCommits = repos["medusajs/medusa"];
|
|
+ const reducedCommits = medusaCommits.slice(0, 100) // 100 is an arbitrary number, we just need enough to have some commits with changesets
|
|
+ const reducedRepos = {
|
|
+ "medusajs/medusa": reducedCommits,
|
|
+ };
|
|
const data = await fetch("https://api.github.com/graphql", {
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: `Token ${process.env.GITHUB_TOKEN}`
|
|
},
|
|
body: JSON.stringify({
|
|
- query: makeQuery(repos)
|
|
+ query: makeQuery(reducedRepos)
|
|
})
|
|
}).then(x => x.json());
|
|
|
|
@@ -223,11 +229,11 @@ async function getInfo(request) {
|
|
}, request));
|
|
let user = null;
|
|
|
|
- if (data.author && data.author.user) {
|
|
+ if (data && data.author && data.author.user) {
|
|
user = data.author.user;
|
|
}
|
|
|
|
- let associatedPullRequest = data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => {
|
|
+ let associatedPullRequest = data && data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => {
|
|
if (a.mergedAt === null && b.mergedAt === null) {
|
|
return 0;
|
|
}
|
|
@@ -253,7 +259,7 @@ async function getInfo(request) {
|
|
user: user ? user.login : null,
|
|
pull: associatedPullRequest ? associatedPullRequest.number : null,
|
|
links: {
|
|
- commit: `[\`${request.commit}\`](${data.commitUrl})`,
|
|
+ commit: `[\`${request.commit}\`](${data && data.commitUrl})`,
|
|
pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null,
|
|
user: user ? `[@${user.login}](${user.url})` : null
|
|
}
|
|
diff --git a/src/index.ts b/src/index.ts
|
|
index 2378f369c4ca5f66b5c9f615e97d5ad143f37f46..ddd5788f4d5edfccef1cda582e12c10bad57b467 100644
|
|
--- a/src/index.ts
|
|
+++ b/src/index.ts
|
|
@@ -1,6 +1,6 @@
|
|
// @ts-ignore
|
|
-import fetch from "node-fetch";
|
|
import DataLoader from "dataloader";
|
|
+import fetch from "node-fetch";
|
|
|
|
const validRepoNameRegex = /^[\w.-]+\/[\w.-]+$/;
|
|
|
|
@@ -92,12 +92,19 @@ const GHDataLoader = new DataLoader(async (requests: RequestData[]) => {
|
|
repos[repo].push(data);
|
|
});
|
|
|
|
+ // I need to temporarily reduce the amount of commits we're fetching from GitHub to avoid errors from GitHub graphql API
|
|
+ const medusaCommits = repos["medusajs/medusa"];
|
|
+ const reducedCommits = medusaCommits.slice(0, 100) // 100 is an arbitrary number, we just need enough to have some commits with changesets
|
|
+ const reducedRepos = {
|
|
+ "medusajs/medusa": reducedCommits,
|
|
+ };
|
|
+
|
|
const data = await fetch("https://api.github.com/graphql", {
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: `Token ${process.env.GITHUB_TOKEN}`,
|
|
},
|
|
- body: JSON.stringify({ query: makeQuery(repos) }),
|
|
+ body: JSON.stringify({ query: makeQuery(reducedRepos) }),
|
|
}).then((x: any) => x.json());
|
|
|
|
if (data.errors) {
|