Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit c95b1c4

Browse files
authored
Update dependencies (#36)
1 parent cd81e4c commit c95b1c4

File tree

7 files changed

+463
-711
lines changed

7 files changed

+463
-711
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The MIT License (MIT)
2-
Copyright (c) 2021 Thibault Derousseaux <[email protected]>
2+
Copyright (c) 2022 Thibault Derousseaux <[email protected]>
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55

package.json

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
{
22
"name": "github-app-token",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"license": "MIT",
55
"type": "module",
66
"files": [
77
"action.yml",
88
"dist"
99
],
1010
"scripts": {
11+
"prebuild": "tsc --build",
1112
"build": "ncc build src/index.ts --minify --target es2021 --v8-cache",
1213
"prettier": "prettier --ignore-path .gitignore \"./**/*.{cjs,js,json,md,ts,yml}\"",
1314
"xo": "xo"
1415
},
15-
"devDependencies": {
16+
"dependencies": {
1617
"@actions/core": "^1.6.0",
17-
"@actions/github": "^5.0.0",
18+
"@actions/github": "^5.0.1",
1819
"@octokit/auth-app": "^3.6.1",
19-
"@octokit/request": "^5.6.2",
20+
"@octokit/request": "^5.6.3",
21+
"ensure-error": "^4.0.0",
22+
"is-base64": "^1.1.0"
23+
},
24+
"devDependencies": {
25+
"@types/error-cause": "^1.0.1",
2026
"@types/is-base64": "^1.1.1",
21-
"@types/node": "^16.11.11",
22-
"@vercel/ncc": "^0.33.0",
23-
"eslint-config-prettier": "^8.3.0",
24-
"eslint-plugin-import": "^2.25.3",
27+
"@types/node": "^16.11.26",
28+
"@vercel/ncc": "^0.33.3",
29+
"eslint-config-prettier": "^8.5.0",
30+
"eslint-plugin-import": "^2.26.0",
2531
"eslint-plugin-sort-destructure-keys": "^1.4.0",
2632
"eslint-plugin-typescript-sort-keys": "^2.1.0",
27-
"is-base64": "^1.1.0",
28-
"prettier": "^2.5.1",
29-
"prettier-plugin-packagejson": "^2.2.15",
30-
"typescript": "^4.5.2",
31-
"xo": "^0.47.0",
32-
"yarn-deduplicate": "^3.1.0"
33+
"prettier": "^2.6.2",
34+
"prettier-plugin-packagejson": "^2.2.17",
35+
"typescript": "^4.7.0-beta",
36+
"xo": "^0.48.0",
37+
"yarn-deduplicate": "^4.0.0"
3338
}
3439
}

src/fetch-installation-token.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { env } from "node:process";
22
import { getOctokit } from "@actions/github";
33
import { createAppAuth } from "@octokit/auth-app";
44
import { request } from "@octokit/request";
5+
import ensureError from "ensure-error";
56

67
export const fetchInstallationToken = async ({
78
appId,
@@ -29,9 +30,16 @@ export const fetchInstallationToken = async ({
2930
if (installationId === undefined) {
3031
const authApp = await app({ type: "app" });
3132
const octokit = getOctokit(authApp.token);
32-
({
33-
data: { id: installationId },
34-
} = await octokit.rest.apps.getRepoInstallation({ owner, repo }));
33+
try {
34+
({
35+
data: { id: installationId },
36+
} = await octokit.rest.apps.getRepoInstallation({ owner, repo }));
37+
} catch (error: unknown) {
38+
throw new Error(
39+
"Could not get repo installation. Is the app installed on this repo?",
40+
{ cause: ensureError(error) },
41+
);
42+
}
3543
}
3644

3745
const installation = await app({ installationId, type: "installation" });

src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Buffer } from "node:buffer";
22
import { getInput, info, setFailed, setOutput, setSecret } from "@actions/core";
33
import { context } from "@actions/github";
4+
import ensureError from "ensure-error";
45
import isBase64 from "is-base64";
56
import { fetchInstallationToken } from "./fetch-installation-token.js";
67

@@ -29,12 +30,9 @@ const run = async () => {
2930
setSecret(installationToken);
3031
setOutput("token", installationToken);
3132
info("Token generated successfully!");
32-
} catch (error: unknown) {
33-
if (typeof error === "string" || error instanceof Error) {
34-
setFailed(error);
35-
} else {
36-
setFailed(`Caught error of unexpected type: ${typeof error}`);
37-
}
33+
} catch (_error: unknown) {
34+
const error = ensureError(_error);
35+
setFailed(error);
3836
}
3937
};
4038

tsconfig.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"compilerOptions": {
3-
"allowSyntheticDefaultImports": true,
43
"forceConsistentCasingInFileNames": true,
5-
"module": "esnext",
6-
"moduleResolution": "node",
7-
"noEmitOnError": true,
4+
"module": "nodenext",
5+
"moduleResolution": "nodenext",
6+
"noEmit": true,
87
"strict": true,
98
"target": "es2021",
10-
"types": ["node"]
9+
"types": ["node", "error-cause/auto"]
1110
},
1211
"include": ["src"]
1312
}

xo.config.cjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@ module.exports = {
1313
],
1414
plugins: ["sort-destructure-keys", "typescript-sort-keys"],
1515
rules: {
16+
// GitHub uses snake_case in its returned payloads.
17+
"@typescript-eslint/naming-convention": "off",
1618
// Forbid function declarations.
1719
"func-style": ["error", "expression", { allowArrowFunctions: true }],
1820
// Already taken care of by TypeScript.
1921
"import/namespace": "off",
2022
// Named export are better for static analysis.
2123
// See https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/
2224
"import/no-default-export": "error",
25+
"import/no-extraneous-dependencies": [
26+
"error",
27+
{
28+
devDependencies: false,
29+
optionalDependencies: false,
30+
peerDependencies: false,
31+
},
32+
],
2333
"import/no-namespace": "error",
2434
"import/order": [
2535
"error",

0 commit comments

Comments
 (0)