diff --git a/.yarn/patches/changesets-github-info.patch b/.yarn/patches/changesets-github-info.patch new file mode 100644 index 0000000000..0eeaced27f --- /dev/null +++ b/.yarn/patches/changesets-github-info.patch @@ -0,0 +1,154 @@ +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) { diff --git a/package.json b/package.json index 2bdfa917e9..91c8d1e4e9 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "@redocly/cli/react": "^17.0.1", "@redocly/cli/react-dom": "^17.0.1", "pg": "8.16.3", - "@changesets/assemble-release-plan@^6.0.0": "patch:@changesets/assemble-release-plan@npm:^6.0.0#.yarn/patches/changesets.patch" + "@changesets/assemble-release-plan@^6.0.0": "patch:@changesets/assemble-release-plan@npm:^6.0.0#.yarn/patches/changesets.patch", + "@changesets/get-github-info@^0.5.2": "patch:@changesets/get-github-info@npm:^0.5.2#.yarn/patches/changesets-github-info.patch" } } diff --git a/yarn.lock b/yarn.lock index 67ace983aa..e7579ae4dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3603,6 +3603,16 @@ __metadata: languageName: node linkType: hard +"@changesets/get-github-info@patch:@changesets/get-github-info@npm:^0.5.2#.yarn/patches/changesets-github-info.patch::locator=root%40workspace%3A.": + version: 0.5.2 + resolution: "@changesets/get-github-info@patch:@changesets/get-github-info@npm%3A0.5.2#.yarn/patches/changesets-github-info.patch::version=0.5.2&hash=9a2bd4&locator=root%40workspace%3A." + dependencies: + dataloader: ^1.4.0 + node-fetch: ^2.5.0 + checksum: 6b9adb6c6e879dcdf4a2140d1b1d17a19965d2db1e10676baefb1e99e183dce7d52abf6a333235cb77f52ecf860597a4caa87ad58cd4be946a0319fbc31b7730 + languageName: node + linkType: hard + "@changesets/get-release-plan@npm:^4.0.0": version: 4.0.0 resolution: "@changesets/get-release-plan@npm:4.0.0"