Skip to content

Commit

Permalink
Update dependencies (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibdex authored Apr 9, 2022
1 parent cd81e4c commit c95b1c4
Show file tree
Hide file tree
Showing 7 changed files with 463 additions and 711 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2021 Thibault Derousseaux <tibdex@gmail.com>
Copyright (c) 2022 Thibault Derousseaux <tibdex@gmail.com>

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:

Expand Down
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
{
"name": "github-app-token",
"version": "1.5.1",
"version": "1.5.2",
"license": "MIT",
"type": "module",
"files": [
"action.yml",
"dist"
],
"scripts": {
"prebuild": "tsc --build",
"build": "ncc build src/index.ts --minify --target es2021 --v8-cache",
"prettier": "prettier --ignore-path .gitignore \"./**/*.{cjs,js,json,md,ts,yml}\"",
"xo": "xo"
},
"devDependencies": {
"dependencies": {
"@actions/core": "^1.6.0",
"@actions/github": "^5.0.0",
"@actions/github": "^5.0.1",
"@octokit/auth-app": "^3.6.1",
"@octokit/request": "^5.6.2",
"@octokit/request": "^5.6.3",
"ensure-error": "^4.0.0",
"is-base64": "^1.1.0"
},
"devDependencies": {
"@types/error-cause": "^1.0.1",
"@types/is-base64": "^1.1.1",
"@types/node": "^16.11.11",
"@vercel/ncc": "^0.33.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"@types/node": "^16.11.26",
"@vercel/ncc": "^0.33.3",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"is-base64": "^1.1.0",
"prettier": "^2.5.1",
"prettier-plugin-packagejson": "^2.2.15",
"typescript": "^4.5.2",
"xo": "^0.47.0",
"yarn-deduplicate": "^3.1.0"
"prettier": "^2.6.2",
"prettier-plugin-packagejson": "^2.2.17",
"typescript": "^4.7.0-beta",
"xo": "^0.48.0",
"yarn-deduplicate": "^4.0.0"
}
}
14 changes: 11 additions & 3 deletions src/fetch-installation-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { env } from "node:process";
import { getOctokit } from "@actions/github";
import { createAppAuth } from "@octokit/auth-app";
import { request } from "@octokit/request";
import ensureError from "ensure-error";

export const fetchInstallationToken = async ({
appId,
Expand Down Expand Up @@ -29,9 +30,16 @@ export const fetchInstallationToken = async ({
if (installationId === undefined) {
const authApp = await app({ type: "app" });
const octokit = getOctokit(authApp.token);
({
data: { id: installationId },
} = await octokit.rest.apps.getRepoInstallation({ owner, repo }));
try {
({
data: { id: installationId },
} = await octokit.rest.apps.getRepoInstallation({ owner, repo }));
} catch (error: unknown) {
throw new Error(
"Could not get repo installation. Is the app installed on this repo?",
{ cause: ensureError(error) },
);
}
}

const installation = await app({ installationId, type: "installation" });
Expand Down
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Buffer } from "node:buffer";
import { getInput, info, setFailed, setOutput, setSecret } from "@actions/core";
import { context } from "@actions/github";
import ensureError from "ensure-error";
import isBase64 from "is-base64";
import { fetchInstallationToken } from "./fetch-installation-token.js";

Expand Down Expand Up @@ -29,12 +30,9 @@ const run = async () => {
setSecret(installationToken);
setOutput("token", installationToken);
info("Token generated successfully!");
} catch (error: unknown) {
if (typeof error === "string" || error instanceof Error) {
setFailed(error);
} else {
setFailed(`Caught error of unexpected type: ${typeof error}`);
}
} catch (_error: unknown) {
const error = ensureError(_error);
setFailed(error);
}
};

Expand Down
9 changes: 4 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true,
"strict": true,
"target": "es2021",
"types": ["node"]
"types": ["node", "error-cause/auto"]
},
"include": ["src"]
}
10 changes: 10 additions & 0 deletions xo.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ module.exports = {
],
plugins: ["sort-destructure-keys", "typescript-sort-keys"],
rules: {
// GitHub uses snake_case in its returned payloads.
"@typescript-eslint/naming-convention": "off",
// Forbid function declarations.
"func-style": ["error", "expression", { allowArrowFunctions: true }],
// Already taken care of by TypeScript.
"import/namespace": "off",
// Named export are better for static analysis.
// See https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/
"import/no-default-export": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: false,
optionalDependencies: false,
peerDependencies: false,
},
],
"import/no-namespace": "error",
"import/order": [
"error",
Expand Down
Loading

0 comments on commit c95b1c4

Please sign in to comment.