Skip to content

Commit

Permalink
maint: modernize devDependencies (#287)
Browse files Browse the repository at this point in the history
* maint: modernize devDependencies

* Switch to vitest
* Switch to fetch-mock@11 from custom fork
* Remove semantic-release from devDeps

* maint: remove vitest ui

* style: prettier

* test: update inline snapshots

* Revert "test: update inline snapshots"

This reverts commit b819a31.

* fix merge
  • Loading branch information
wolfy1339 authored Jan 1, 2025
1 parent 9b4f7bb commit 7752bbe
Show file tree
Hide file tree
Showing 23 changed files with 1,827 additions and 9,891 deletions.
11,583 changes: 1,770 additions & 9,813 deletions package-lock.json

Large diffs are not rendered by default.

46 changes: 5 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "prettier --check '{src,test,scripts}/**/*' README.md package.json",
"lint:fix": "prettier --write '{src,test,scripts}/**/*' README.md package.json",
"pretest": "npm run -s lint",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage"
"test": "vitest run --coverage"
},
"repository": "https://github.com/octokit/oauth-methods.js",
"keywords": [
Expand All @@ -28,53 +28,17 @@
},
"devDependencies": {
"@octokit/tsconfig": "^3.0.0",
"@types/jest": "^29.0.0",
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^2.0.0",
"esbuild": "^0.24.0",
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
"fetch-mock": "^11.0.0",
"glob": "^11.0.0",
"jest": "^29.0.0",
"prettier": "3.4.2",
"semantic-release": "^24.0.0",
"semantic-release-plugin-update-version-in-files": "^1.1.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts"
],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.test.json",
"useESM": true
}
]
},
"coverageThreshold": {
"global": {
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
},
"moduleNameMapper": {
"^(.+)\\.jsx?$": "$1"
}
"typescript": "^5.0.0",
"vitest": "^2.0.0"
},
"release": {
"branches": [
"+([0-9]).x",
"main",
"next",
{
"name": "beta",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down
7 changes: 3 additions & 4 deletions src/check-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export async function checkToken(
export async function checkToken(
options: CheckTokenOAuthAppOptions | CheckTokenGitHubAppOptions,
): Promise<any> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const response = await request("POST /applications/{client_id}/token", {
headers: {
Expand Down
7 changes: 3 additions & 4 deletions src/create-device-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ export type CreateDeviceCodeDeviceTokenResponse = OctokitResponse<{
export async function createDeviceCode(
options: CreateDeviceCodeOAuthAppOptions | CreateDeviceCodeGitHubAppOptions,
): Promise<CreateDeviceCodeDeviceTokenResponse> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const parameters: Record<string, unknown> = {
client_id: options.clientId,
Expand Down
7 changes: 3 additions & 4 deletions src/delete-authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ export async function deleteAuthorization(
| DeleteAuthorizationOAuthAppOptions
| DeleteAuthorizationGitHubAppOptions,
): Promise<any> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const auth = btoa(`${options.clientId}:${options.clientSecret}`);
return request(
Expand Down
7 changes: 3 additions & 4 deletions src/delete-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ export async function deleteToken(
export async function deleteToken(
options: DeleteTokenOAuthAppOptions | DeleteTokenGitHubAppOptions,
): Promise<any> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const auth = btoa(`${options.clientId}:${options.clientSecret}`);
return request(
Expand Down
7 changes: 3 additions & 4 deletions src/exchange-device-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ export async function exchangeDeviceCode(
| ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret
| ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret,
): Promise<any> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const response = await oauthRequest(
request,
Expand Down
7 changes: 3 additions & 4 deletions src/exchange-web-flow-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ export async function exchangeWebFlowCode(
| ExchangeWebFlowCodeOAuthAppOptions
| ExchangeWebFlowCodeGitHubAppOptions,
): Promise<any> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const response = await oauthRequest(
request,
Expand Down
7 changes: 3 additions & 4 deletions src/refresh-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ export type RefreshTokenResponse =
export async function refreshToken(
options: RefreshTokenOptions,
): Promise<RefreshTokenResponse> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const response = await oauthRequest(
request,
Expand Down
7 changes: 3 additions & 4 deletions src/reset-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export async function resetToken(
export async function resetToken(
options: ResetTokenOAuthAppOptions | ResetTokenGitHubAppOptions,
): Promise<any> {
const request =
options.request ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const auth = btoa(`${options.clientId}:${options.clientSecret}`);
const response = await request(
Expand Down
7 changes: 3 additions & 4 deletions src/scope-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ export async function scopeToken(
...requestOptions
} = options;

const request =
optionsRequest ||
/* istanbul ignore next: we always pass a custom request in tests */
defaultRequest;
/* v8 ignore start: we always pass a custom request in tests */
const request = options.request || defaultRequest;
/* v8 ignore stop */

const response = await request(
"POST /applications/{client_id}/token/scoped",
Expand Down
1 change: 1 addition & 0 deletions test/check-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { checkToken } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/create-device-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { createDeviceCode } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/delete-authorization.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { deleteAuthorization } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/delete-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { deleteToken } from "../src/index.js";
Expand Down
3 changes: 2 additions & 1 deletion test/exchange-device-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { exchangeDeviceCode } from "../src/index.js";
Expand Down Expand Up @@ -135,7 +136,7 @@ describe("exchangeDeviceCode()", () => {
},
);

expect(
await expect(
async () =>
await exchangeDeviceCode({
clientType: "oauth-app",
Expand Down
1 change: 1 addition & 0 deletions test/exchange-web-flow-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { exchangeWebFlowCode } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/get-web-flow-authorization-url.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import { request } from "@octokit/request";
import { getWebFlowAuthorizationUrl } from "../src/index.js";

Expand Down
1 change: 1 addition & 0 deletions test/refresh-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { refreshToken } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/reset-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { resetToken } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/scope-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { scopeToken } from "../src/index.js";
Expand Down
1 change: 1 addition & 0 deletions test/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from "vitest";
import {
getWebFlowAuthorizationUrl,
exchangeWebFlowCode,
Expand Down
13 changes: 13 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from "vite";

export default defineConfig({
test: {
coverage: {
include: ["src/**/*.ts"],
reporter: ["html"],
thresholds: {
100: true,
},
},
},
});

0 comments on commit 7752bbe

Please sign in to comment.