Skip to content

Commit

Permalink
chore: resolve upstream conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-omarov committed May 10, 2023
1 parent 085bff8 commit d7cc1fb
Show file tree
Hide file tree
Showing 8 changed files with 3,312 additions and 2,783 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# @changesets/action

## 1.4.4

### Patch Changes

- [#291](https://github.com/changesets/action/pull/291) [`db8a109`](https://github.com/changesets/action/commit/db8a1099bc0ba1dd6f46a5b9df4212e4f69e78c9) Thanks [@varl](https://github.com/varl)! - Wire up [`@octokit/plugin-throttling`](https://github.com/octokit/plugin-throttling.js) with all GitHub Octokit instances

## 1.4.3

### Patch Changes

- [#289](https://github.com/changesets/action/pull/289) [`8b28186`](https://github.com/changesets/action/commit/8b2818674de86a7fc69aebb9ed6b486ee32eb96e) Thanks [@varl](https://github.com/varl)! - Use logging provided by `@actions/core`

## 1.4.2

### Patch Changes

- [#286](https://github.com/changesets/action/pull/286) [`225a1e8`](https://github.com/changesets/action/commit/225a1e8cbcabb7b585174ba0ad806549db40d4cd) Thanks [@varl](https://github.com/varl)! - This patch implements the [`@octokit/plugin-throttling`](https://github.com/octokit/plugin-throttling.js) plugin and [wires
it up with the internal GitHub Octokit instance](https://github.com/actions/toolkit/tree/457303960f03375db6f033e214b9f90d79c3fe5c/packages/github#extending-the-octokit-instance).

This plugin is recommended by [the Octokit docs](://octokit.github.io/rest.js/v19#throttling) as it implements all the GitHub [best practices for integrators](https://docs.github.com/en/rest/guides/best-practices-for-integrators?apiVersion=2022-11-28).

This should help with `changesets/action` gitting spurious secondary rate limits and failing CI jobs, for which the only known workaround is to simply re-run the job.

## 1.4.1

### Patch Changes
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@changesets/action",
"version": "1.4.1",
"version": "1.4.4",
"main": "dist/index.js",
"license": "MIT",
"devDependencies": {
Expand All @@ -11,19 +11,20 @@
"@changesets/cli": "^2.20.0",
"@changesets/write": "^0.1.6",
"@types/fs-extra": "^8.0.0",
"@types/jest": "^24.0.18",
"@types/jest": "^29.5.1",
"@types/node": "^12.7.1",
"@types/semver": "^6.0.2",
"babel-jest": "^24.9.0",
"fixturez": "^1.1.0",
"babel-jest": "^29.5.0",
"husky": "^3.0.3",
"jest": "^24.9.0",
"jest": "^29.5.0",
"parcel": "^1.12.3",
"@vercel/ncc": "^0.36.1",
"fixturez": "^1.1.0",
"prettier": "^2.0.5",
"typescript": "^3.5.3"
"typescript": "^5.0.4"
},
"scripts": {
"build": "parcel build ./src/index.ts --no-source-maps --target=node --bundle-node-modules",
"build": "ncc build src/index.ts -o dist --transpile-only --minify",
"test": "jest",
"test:watch": "yarn test --watch",
"changeset": "changeset",
Expand All @@ -40,6 +41,7 @@
"@changesets/pre": "^1.0.9",
"@changesets/read": "^0.5.3",
"@manypkg/get-packages": "^1.1.3",
"@octokit/plugin-throttling": "5.1.1",
"fs-extra": "^8.1.0",
"mdast-util-to-string": "^1.0.6",
"remark-parse": "^9.0.0",
Expand All @@ -48,12 +50,13 @@
"semver": "^6.3.0",
"unified": "^8.3.2"
},
"resolutions": {
"glob-parent": "^5.1.2",
"node-fetch": "^2.6.7"
},
"husky": {
"hooks": {}
},
"prettier": {}
"prettier": {},
"resolutions": {
"glob-parent": "^5.1.2",
"node-fetch": "^2.6.7",
"**/@octokit/core": "4.2.0"
}
}
20 changes: 10 additions & 10 deletions src/__snapshots__/run.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`version creates simple PR 1`] = `
Array [
Object {
[
{
"base": "some-branch",
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
Expand Down Expand Up @@ -34,8 +34,8 @@ Array [
`;

exports[`version does not include any release information if a message with simplified release info exceeds size limit 1`] = `
Array [
Object {
[
{
"base": "some-branch",
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
Expand All @@ -52,8 +52,8 @@ Array [
`;

exports[`version does not include changelog entries if full message exceeds size limit 1`] = `
Array [
Object {
[
{
"base": "some-branch",
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
Expand All @@ -74,8 +74,8 @@ Array [
`;

exports[`version doesn't include ignored package that got a dependency update in the PR body 1`] = `
Array [
Object {
[
{
"base": "some-branch",
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
Expand All @@ -96,8 +96,8 @@ Array [
`;

exports[`version only includes bumped packages in the PR body 1`] = `
Array [
Object {
[
{
"base": "some-branch",
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
Expand Down
8 changes: 4 additions & 4 deletions src/__snapshots__/utils.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`it sorts the things right 1`] = `
Array [
Object {
[
{
"highestLevel": 3,
"name": "c",
"private": false,
},
Object {
{
"highestLevel": 1,
"name": "b",
"private": false,
},
Object {
{
"highestLevel": 3,
"name": "a",
"private": true,
Expand Down
22 changes: 11 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;

const inputCwd = core.getInput("cwd");
if (inputCwd) {
console.log("changing directory to the one given as the input");
core.info("changing directory to the one given as the input");
process.chdir(inputCwd);
}

let setupGitUser = core.getBooleanInput("setupGitUser");

if (setupGitUser) {
console.log("setting git user");
core.info("setting git user");
await gitUtils.setupUser();
}

console.log("setting GitHub credentials");
core.info("setting GitHub credentials");
await fs.writeFile(
`${process.env.HOME}/.netrc`,
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`
Expand All @@ -48,27 +48,27 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;

switch (true) {
case !hasChangesets && !hasPublishScript:
console.log("No changesets found");
core.info("No changesets found");
return;
case !hasChangesets && hasPublishScript: {
console.log(
core.info(
"No changesets found, attempting to publish any unpublished packages to npm"
);

let userNpmrcPath = `${process.env.HOME}/.npmrc`;
if (fs.existsSync(userNpmrcPath)) {
console.log("Found existing user .npmrc file");
core.info("Found existing user .npmrc file");
const userNpmrcContent = await fs.readFile(userNpmrcPath, "utf8");
const authLine = userNpmrcContent.split("\n").find((line) => {
// check based on https://github.com/npm/cli/blob/8f8f71e4dd5ee66b3b17888faad5a7bf6c657eed/test/lib/adduser.js#L103-L105
return /^\s*\/\/registry\.npmjs\.org\/:[_-]authToken=/i.test(line);
});
if (authLine) {
console.log(
core.info(
"Found existing auth token for the npm registry in the user .npmrc file"
);
} else {
console.log(
core.info(
"Didn't find existing auth token for the npm registry in the user .npmrc file, creating one"
);
fs.appendFileSync(
Expand All @@ -77,7 +77,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
);
}
} else {
console.log("No user .npmrc file found, creating one");
core.info("No user .npmrc file found, creating one");
fs.writeFileSync(
userNpmrcPath,
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n`
Expand All @@ -100,7 +100,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return;
}
case hasChangesets && !hasNonEmptyChangesets:
console.log("All changesets are empty; not creating PR");
core.info("All changesets are empty; not creating PR");
return;
case hasChangesets:
const { pullRequestNumber } = await runVersion({
Expand All @@ -116,6 +116,6 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return;
}
})().catch((err) => {
console.error(err);
core.error(err);
core.setFailed(err.message);
});
18 changes: 14 additions & 4 deletions src/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fixturez from "fixturez";
import * as github from "@actions/github";
import * as githubUtils from "@actions/github/lib/utils";
import fs from "fs-extra";
import path from "path";
import writeChangeset from "@changesets/write";
Expand All @@ -15,7 +16,19 @@ jest.mock("@actions/github", () => ({
ref: "refs/heads/some-branch",
sha: "xeac7",
},
getOctokit: jest.fn(),
}));
jest.mock("@actions/github/lib/utils", () => ({
GitHub: {
plugin: () => {
// function necessary to be used as constructor
return function() {
return {
rest: mockedGithubMethods,
}
}
},
},
getOctokitOptions: jest.fn(),
}));
jest.mock("./gitUtils");

Expand All @@ -30,9 +43,6 @@ let mockedGithubMethods = {
createRelease: jest.fn(),
},
};
(github.getOctokit as any).mockImplementation(() => ({
rest: mockedGithubMethods,
}));

let f = fixturez(__dirname);

Expand Down

0 comments on commit d7cc1fb

Please sign in to comment.