mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Upgrade @octokit/plugin-throttling and fix type errors (#294)
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@
|
|||||||
"@changesets/pre": "^1.0.9",
|
"@changesets/pre": "^1.0.9",
|
||||||
"@changesets/read": "^0.5.3",
|
"@changesets/read": "^0.5.3",
|
||||||
"@manypkg/get-packages": "^1.1.3",
|
"@manypkg/get-packages": "^1.1.3",
|
||||||
"@octokit/plugin-throttling": "5.1.1",
|
"@octokit/plugin-throttling": "^5.2.1",
|
||||||
"@types/fs-extra": "^8.0.0",
|
"@types/fs-extra": "^8.0.0",
|
||||||
"@types/jest": "^29.5.1",
|
"@types/jest": "^29.5.1",
|
||||||
"@types/node": "^12.7.1",
|
"@types/node": "^12.7.1",
|
||||||
|
|||||||
@@ -11,17 +11,19 @@ export default async function readChangesetState(
|
|||||||
cwd: string = process.cwd()
|
cwd: string = process.cwd()
|
||||||
): Promise<ChangesetState> {
|
): Promise<ChangesetState> {
|
||||||
let preState = await readPreState(cwd);
|
let preState = await readPreState(cwd);
|
||||||
let isInPreMode = preState !== undefined && preState.mode === "pre";
|
|
||||||
|
|
||||||
let changesets = await readChangesets(cwd);
|
let changesets = await readChangesets(cwd);
|
||||||
|
|
||||||
if (isInPreMode) {
|
if (preState !== undefined && preState.mode === "pre") {
|
||||||
let changesetsToFilter = new Set(preState.changesets);
|
let changesetsToFilter = new Set(preState.changesets);
|
||||||
changesets = changesets.filter((x) => !changesetsToFilter.has(x.id));
|
|
||||||
|
return {
|
||||||
|
preState,
|
||||||
|
changesets: changesets.filter((x) => !changesetsToFilter.has(x.id)),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
preState: isInPreMode ? preState : undefined,
|
preState: undefined,
|
||||||
changesets,
|
changesets,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-6
@@ -17,8 +17,6 @@ import * as gitUtils from "./gitUtils";
|
|||||||
import readChangesetState from "./readChangesetState";
|
import readChangesetState from "./readChangesetState";
|
||||||
import resolveFrom from "resolve-from";
|
import resolveFrom from "resolve-from";
|
||||||
import { throttling } from "@octokit/plugin-throttling";
|
import { throttling } from "@octokit/plugin-throttling";
|
||||||
// temporary workaround for https://github.com/octokit/plugin-throttling.js/pull/590
|
|
||||||
import type {} from "@octokit/plugin-throttling/dist-types/types.d";
|
|
||||||
|
|
||||||
// GitHub Issues/PRs messages have a max size limit on the
|
// GitHub Issues/PRs messages have a max size limit on the
|
||||||
// message body payload.
|
// message body payload.
|
||||||
@@ -26,7 +24,7 @@ import type {} from "@octokit/plugin-throttling/dist-types/types.d";
|
|||||||
// To avoid that, we ensure to cap the message to 60k chars.
|
// To avoid that, we ensure to cap the message to 60k chars.
|
||||||
const MAX_CHARACTERS_PER_MESSAGE = 60000;
|
const MAX_CHARACTERS_PER_MESSAGE = 60000;
|
||||||
|
|
||||||
const setupOctokit = (githubToken) => {
|
const setupOctokit = (githubToken: string) => {
|
||||||
return new (GitHub.plugin(throttling))(
|
return new (GitHub.plugin(throttling))(
|
||||||
getOctokitOptions(githubToken, {
|
getOctokitOptions(githubToken, {
|
||||||
throttle: {
|
throttle: {
|
||||||
@@ -61,7 +59,7 @@ const setupOctokit = (githubToken) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createRelease = async (
|
const createRelease = async (
|
||||||
octokit: ReturnType<typeof GitHub>,
|
octokit: ReturnType<typeof setupOctokit>,
|
||||||
{ pkg, tagName }: { pkg: Package; tagName: string }
|
{ pkg, tagName }: { pkg: Package; tagName: string }
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
@@ -87,7 +85,12 @@ const createRelease = async (
|
|||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// if we can't find a changelog, the user has probably disabled changelogs
|
// if we can't find a changelog, the user has probably disabled changelogs
|
||||||
if (err.code !== "ENOENT") {
|
if (
|
||||||
|
err &&
|
||||||
|
typeof err === "object" &&
|
||||||
|
"code" in err &&
|
||||||
|
err.code !== "ENOENT"
|
||||||
|
) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +208,12 @@ const requireChangesetsCliPkgJson = (cwd: string) => {
|
|||||||
try {
|
try {
|
||||||
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
|
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err && err.code === "MODULE_NOT_FOUND") {
|
if (
|
||||||
|
err &&
|
||||||
|
typeof err === "object" &&
|
||||||
|
"code" in err &&
|
||||||
|
err.code === "MODULE_NOT_FOUND"
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
|
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import remarkParse from "remark-parse";
|
|||||||
import remarkStringify from "remark-stringify";
|
import remarkStringify from "remark-stringify";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import mdastToString from "mdast-util-to-string";
|
import mdastToString from "mdast-util-to-string";
|
||||||
import { exec } from "@actions/exec";
|
|
||||||
import { getPackages, Package } from "@manypkg/get-packages";
|
import { getPackages, Package } from "@manypkg/get-packages";
|
||||||
|
|
||||||
export const BumpLevels = {
|
export const BumpLevels = {
|
||||||
|
|||||||
@@ -1751,10 +1751,10 @@
|
|||||||
"@octokit/types" "^6.39.0"
|
"@octokit/types" "^6.39.0"
|
||||||
deprecation "^2.3.1"
|
deprecation "^2.3.1"
|
||||||
|
|
||||||
"@octokit/plugin-throttling@5.1.1":
|
"@octokit/plugin-throttling@^5.2.1":
|
||||||
version "5.1.1"
|
version "5.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-throttling/-/plugin-throttling-5.1.1.tgz#7e7ff4646a8ad622d34d9e0c5be7a7e6ea35ba10"
|
resolved "https://registry.yarnpkg.com/@octokit/plugin-throttling/-/plugin-throttling-5.2.1.tgz#0600a0165bb439afaf40cf7cccae21cea7b3fd03"
|
||||||
integrity sha512-UlsdoW3ZOhhvjnK8S+OmQWOvB14kaKKdxseGFAxVHVggKZlgKO/ZtAb1AQoHXaQUCfO7uV/O5BR27o/wbKAzHg==
|
integrity sha512-UUTFP301/gYEgsPABIP35QZR4dEXPtyoXHCQhPXU8U4FphXKjXOahoMlHg/T4IQVWMmSy607zsqThuBkpV9Gjg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@octokit/types" "^9.0.0"
|
"@octokit/types" "^9.0.0"
|
||||||
bottleneck "^2.15.3"
|
bottleneck "^2.15.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user