Skip to content

Commit 3e4d477

Browse files
authored
feat: v7 (#580)
BREAKING CHANGE: package is now ESM BREAKING CHANGE: remove type "oauth" that was previously deprecated
1 parent d147168 commit 3e4d477

12 files changed

+240
-495
lines changed

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,19 @@ Node
6969
Install with <code>npm install @octokit/auth-app</code>
7070

7171
```js
72-
const { createAppAuth } = require("@octokit/auth-app");
73-
// or: import { createAppAuth } from "@octokit/auth-app";
72+
import { createAppAuth } from "@octokit/auth-app";
7473
```
7574

7675
</td></tr>
7776
</tbody>
7877
</table>
7978

79+
> [!IMPORTANT]
80+
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
81+
>
82+
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
83+
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
84+
8085
### Authenticate as GitHub App (JSON Web Token)
8186

8287
```js
@@ -225,8 +230,8 @@ Node
225230
Install with `npm install @octokit/core @octokit/auth-app`. Optionally replace `@octokit/core` with a compatible module
226231

227232
```js
228-
const { Octokit } = require("@octokit/core");
229-
const { createAppAuth, createOAuthUserAuth } = require("@octokit/auth-app");
233+
import { Octokit } from "@octokit/core";
234+
import { createAppAuth, createOAuthUserAuth } from "@octokit/auth-app";
230235
```
231236

232237
</td></tr>
@@ -332,7 +337,7 @@ await installationOctokit.request("POST /repos/{owner}/{repo}/issues", {
332337
<code>string</code>
333338
</th>
334339
<td>
335-
<strong>Required</strong>. Content of the <code>*.pem</code> file you downloaded from the app’s about page. You can generate a new private key if needed.
340+
<strong>Required</strong>. Content of the <code>*.pem</code> file you downloaded from the app’s about page. You can generate a new private key if needed. If your private key contains escaped newlines (`\\n`), they will be automatically replaced with actual newlines.
336341
</td>
337342
</tr>
338343
<tr>
@@ -382,7 +387,7 @@ Automatically set to `octokit.request` when using with an `Octokit` constructor.
382387
For standalone usage, you can pass in your own [`@octokit/request`](https://github.com/octokit/request.js) instance. For usage with enterprise, set `baseUrl` to the hostname + `/api/v3`. Example:
383388

384389
```js
385-
const { request } = require("@octokit/request");
390+
import { request } from "@octokit/request";
386391
createAppAuth({
387392
appId: 1,
388393
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
@@ -431,10 +436,11 @@ createAppAuth({
431436
You can pass in your preferred logging tool by passing <code>option.log</code> to the constructor. If you would like to make the log level configurable using an environment variable or external option, we recommend the console-log-level package. For example:
432437

433438
```js
439+
import consoleLogLevel from "console-log-level";
434440
createAppAuth({
435441
appId: 1,
436442
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
437-
log: require("console-log-level")({ level: "info" }),
443+
log: consoleLogLevel({ level: "info" }),
438444
});
439445
```
440446

@@ -674,10 +680,7 @@ The `auth({type: "oauth-user", factory })` call with resolve with whatever the f
674680
For example, you can create a new `auth` instance for an installation which shares the internal state (especially the access token cache) with the calling `auth` instance:
675681

676682
```js
677-
const {
678-
createAppAuth,
679-
createOAuthUserAuth,
680-
} = require("@octokit/auth-oauth-app");
683+
import { createAppAuth, createOAuthUserAuth } from "@octokit/auth-oauth-app";
681684

682685
const appAuth = createAppAuth({
683686
appId: 1,
@@ -807,10 +810,7 @@ The `auth({type: "oauth-user", factory })` call with resolve with whatever the f
807810
For example, you can create a new `auth` instance for an installation which shares the internal state (especially the access token cache) with the calling `auth` instance:
808811

809812
```js
810-
const {
811-
createAppAuth,
812-
createOAuthUserAuth,
813-
} = require("@octokit/auth-oauth-app");
813+
import { createAppAuth, createOAuthUserAuth } from "@octokit/auth-oauth-app";
814814

815815
const appAuth = createAppAuth({
816816
appId: 1,

0 commit comments

Comments
 (0)