Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v20 #305

Merged
merged 16 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ jobs:
strategy:
matrix:
node_version:
- 14
- 16
- 18
- 20
steps:
- uses: actions/checkout@v3
- name: Test with Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
cache: npm
node-version: 16
node-version: ${{ matrix.node_version }}
- run: npm ci
- run: npm run start-fixtures-server &
- run: sleep 3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: npm
- run: npm ci
- run: npm --prefix ./docs ci ./docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: npm
node-version: 16
node-version: 18
- run: npm ci
- run: npm run lint:fix
- uses: gr2m/[email protected]
Expand Down
11,818 changes: 1,018 additions & 10,800 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,30 @@
],
"repository": "github:octokit/rest.js",
"dependencies": {
"@octokit/core": "^4.2.1",
"@octokit/plugin-paginate-rest": "^6.1.2",
"@octokit/core": "^5.0.0",
"@octokit/plugin-paginate-rest": "^8.0.0",
"@octokit/plugin-request-log": "^1.0.4",
"@octokit/plugin-rest-endpoint-methods": "^7.1.2"
"@octokit/plugin-rest-endpoint-methods": "^9.0.0"
},
"devDependencies": {
"@octokit/auth-action": "^2.0.3",
"@octokit/auth-app": "^4.0.13",
"@octokit/auth-action": "^4.0.0",
"@octokit/auth-app": "^6.0.0",
"@octokit/fixtures-server": "^7.0.0",
"@octokit/request": "^6.2.5",
"@octokit/request": "^8.0.4",
"@octokit/tsconfig": "^2.0.0",
"@types/jest": "^29.0.0",
"@types/node": "^18.0.0",
"esbuild": "^0.18.0",
"fetch-mock": "^9.0.0",
"fetch-mock": "npm:@gr2m/[email protected]",
"glob": "^10.2.5",
"jest": "^29.0.0",
"nock": "^13.3.1",
"prettier": "3.0.0",
"semantic-release": "^21.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"undici": "^5.22.1"
},
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
Expand Down Expand Up @@ -120,6 +122,6 @@
]
},
"engines": {
"node": ">= 14"
"node": ">= 18"
}
}
44 changes: 32 additions & 12 deletions test/integration/agent-ca/agent-ca-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const https = require("https");
const { readFileSync } = require("fs");
const { resolve } = require("path");
const { fetch: undiciFetch, Agent } = require("undici");

const { Octokit } = require("../../..");
const ca = readFileSync(resolve(__dirname, "./ca.crt"));

require("../../mocha-node-setup");

describe("custom client certificate", () => {
let server;
before((done) => {
Expand All @@ -28,13 +26,23 @@ describe("custom client certificate", () => {
server.listen(0, done);
});

it("https.Agent({ca})", () => {
const agent = new https.Agent({
ca,
it("undici.Agent({ca})", () => {
const agent = new Agent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
connect: { ca: ca },
});
const myFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: agent,
});
};
const octokit = new Octokit({
baseUrl: "https://localhost:" + server.address().port,
request: { agent },
request: {
fetch: myFetch,
},
});

return octokit.rest.repos.get({
Expand All @@ -43,14 +51,26 @@ describe("custom client certificate", () => {
});
});

it("https.Agent({ca, rejectUnauthorized})", () => {
const agent = new https.Agent({
ca: "invalid",
rejectUnauthorized: false,
it("undici.Agent({ca, rejectUnauthorized})", () => {
const agent = new Agent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
connect: {
ca: "invalid",
rejectUnauthorized: true,
},
});
const myFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: agent,
});
};
const octokit = new Octokit({
baseUrl: "https://localhost:" + server.address().port,
request: { agent },
request: {
fetch: myFetch,
},
});

return octokit.rest.repos.get({
Expand Down
2 changes: 0 additions & 2 deletions test/integration/apps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const { Octokit } = require("../../");
const BEARER_TOKEN =
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTM4MTkzMTIsImV4cCI6MTU1MzgxOTM3MiwiaXNzIjoxfQ.etiSZ4LFQZ8tiMGJVqKDoGn8hxMCgwL4iLvU5xBUqbAPr4pbk_jJZmMQjuxTlOnRxq4e7NouTizGCdfohRMb3R1mpLzGPzOH9_jqSA_BWYxolsRP_WDSjuNcw6nSxrPRueMVRBKFHrqcTOZJej0djRB5pI61hDZJ_-DGtiOIFexlK3iuVKaqBkvJS5-TbTekGuipJ652g06gXuz-l8i0nHiFJldcuIruwn28hTUrjgtPbjHdSBVn_QQLKc2Fhij8OrhcGqp_D_fvb_KovVmf1X6yWiwXV5VXqWARS-JGD9JTAr2495ZlLV_E4WPxdDpz1jl6XS9HUhMuwBpaCOuipw";

require("../mocha-node-setup");

describe("apps", () => {
let octokit;

Expand Down
2 changes: 0 additions & 2 deletions test/integration/authentication-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ const { createActionAuth } = require("@octokit/auth-action");

const { Octokit } = require("../..");

require("../mocha-node-setup");

describe("authentication", () => {
it("unauthenticated", () => {
nock("https://authentication-test-host.com").get("/").reply(200, {});
Expand Down
2 changes: 0 additions & 2 deletions test/integration/conditional-request-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const nock = require("nock");

const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("request 304s", () => {
let octokit;

Expand Down
2 changes: 0 additions & 2 deletions test/integration/deprecations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const nock = require("nock");
const DeprecatedOctokit = require("../../");
const { Octokit } = DeprecatedOctokit;

require("../mocha-node-setup");

const Mocktokit = Octokit.plugin((octokit) => {
octokit.hook.wrap("request", () => null);
});
Expand Down
2 changes: 0 additions & 2 deletions test/integration/pagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const nock = require("nock");

const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("pagination", () => {
it(".paginate()", () => {
nock("https://pagination-test.com")
Expand Down
2 changes: 0 additions & 2 deletions test/integration/params-validations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const nock = require("nock");

const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("params validations", () => {
it("octokit.rest.orgs.get({})", () => {
const octokit = new Octokit();
Expand Down
2 changes: 0 additions & 2 deletions test/integration/plugins-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("plugins", () => {
it("gets called in constructor", () => {
const MyOctokit = Octokit.plugin((octokit) => {
Expand Down
2 changes: 0 additions & 2 deletions test/integration/register-endpoints-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const nock = require("nock");

const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("registerEndpoints", () => {
it("optins are not altered in registered endpoint methods", () => {
nock("https://api.github.com")
Expand Down
2 changes: 0 additions & 2 deletions test/integration/request-errors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const nock = require("nock");

const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("request errors", () => {
it("timeout", () => {
nock("https://request-errors-test.com").get("/").delay(2000).reply(200, {});
Expand Down
2 changes: 0 additions & 2 deletions test/issues/1134-missing-endpoint-scopes-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/1134", () => {
it("octokit.rest.pulls", () => {
const octokit = new Octokit();
Expand Down
2 changes: 0 additions & 2 deletions test/issues/1279-store-otp-send-header-all-requests-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/1279", () => {
it("2fa code gets stored and passed as header to listAuthorizations", () => {
nock("https://authentication-test-host.com", {
Expand Down
2 changes: 0 additions & 2 deletions test/issues/1323-parameter-deprecation-bug-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../..");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/1323", () => {
it("should accept new parameter", () => {
nock("https://api.github.com")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/1497", () => {
it("octokit.rest.repos.updateBranchProtection()", () => {
nock("https://request-errors-test.com", {
Expand Down
2 changes: 0 additions & 2 deletions test/issues/1553-deprecated-teams-methods-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/1553", () => {
it.skip("octokit.rest.teams.removeMember()", () => {
const octokit = new Octokit();
Expand Down
2 changes: 0 additions & 2 deletions test/issues/765-remove-milestone-from-issue-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/765", () => {
it("octokit.rest.issues.update({..., milestone: null})", () => {
nock("https://api.github.com")
Expand Down
2 changes: 0 additions & 2 deletions test/issues/818-get-installations-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/818", () => {
it("octokit.rest.apps.listInstallations()", () => {
nock("https://api.github.com").get("/app/installations").reply(200, []);
Expand Down
2 changes: 0 additions & 2 deletions test/issues/826-fail-on-304-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/826", () => {
it("throws error on 304 responses", () => {
nock("https://request-errors-test.com")
Expand Down
2 changes: 0 additions & 2 deletions test/issues/841-head-request-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/841", () => {
it("supports sending GET requests with method: HEAD", () => {
nock("https://head-request-test.com")
Expand Down
2 changes: 0 additions & 2 deletions test/issues/861-custom-accept-header-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/861", () => {
it("custom accept header", () => {
nock("https://issues-861-test.com", {
Expand Down
2 changes: 0 additions & 2 deletions test/issues/922-create-check-with-empty-actions-array-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const nock = require("nock");
const { Octokit } = require("../../");

require("../mocha-node-setup");

describe("https://github.com/octokit/rest.js/issues/922", () => {
it("octokit.rest.issues.update({..., milestone: null})", () => {
nock("https://api.github.com")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("api.github.com", () => {
.then((response) => {
expect(response.data.length).toEqual(1);

return githubUserB.repos.acceptInvitation({
return githubUserB.repos.acceptInvitationForAuthenticatedUser({
invitation_id: response.data[0].id,
});
})
Expand Down
17 changes: 10 additions & 7 deletions test/scenarios/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ describe("api.github.com", () => {
expect(error.message).toEqual(
`Validation Failed: {"resource":"Label","code":"invalid","field":"color"}`,
);
expect(error.response.data.errors).toStrictEqual([
{
resource: "Label",
code: "invalid",
field: "color",
},
]);
// To-Do: Figure out why the objects are not strictly equal
expect(JSON.stringify(error.response.data.errors)).toStrictEqual(
JSON.stringify([
{
resource: "Label",
code: "invalid",
field: "color",
},
]),
);
Comment on lines +27 to +36
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same situation as in octokit/core.js#563

octokit/core.js#563 (comment)

This will need to be handled in a follow-up issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 FAIL  test/scenarios/errors.test.ts
  ● api.github.com › (#684) errors-test

    expect(received).toStrictEqual(expected) // deep equality

    Expected: [{"code": "invalid", "field": "color", "resource": "Label"}]
    Received: serializes to the same string

      25 |           `Validation Failed: {"resource":"Label","code":"invalid","field":"color"}`,
      26 |         );
    > 27 |         expect(error.response.data.errors).toStrictEqual([
         |                                            ^
      28 |           {
      29 |             resource: "Label",
      30 |             code: "invalid",

      at test/scenarios/errors.test.ts:27:44

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in octokit/core.js#588

expect(error.response.data.documentation_url).toMatch(
new RegExp("rest/reference/issues#create-a-label"),
);
Expand Down