diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index 734512e69..c3966ed61 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -14,9 +14,9 @@ describe("util", () => { it("strips template", () => { assert.equal( uploadUrl( - "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}" + "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", ), - "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets" + "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets", ); }); }); @@ -30,7 +30,7 @@ describe("util", () => { it("parses newline and comma-delimited (and then some)", () => { assert.deepStrictEqual( parseInputFiles("foo,bar\nbaz,boom,\n\ndoom,loom "), - ["foo", "bar", "baz", "boom", "doom", "loom"] + ["foo", "bar", "baz", "boom", "doom", "loom"], ); }); }); @@ -53,7 +53,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - }) + }), ); }); it("uses input body path", () => { @@ -74,7 +74,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - }) + }), ); }); it("defaults to body path when both body and body path are provided", () => { @@ -95,7 +95,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - }) + }), ); }); }); @@ -129,7 +129,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); @@ -155,7 +155,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); it("supports discussion category names", () => { @@ -180,7 +180,7 @@ describe("util", () => { input_discussion_category_name: "releases", input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); @@ -206,7 +206,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: true, input_make_latest: undefined, - } + }, ); }); @@ -235,7 +235,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); it("uses input token as the source of GITHUB_TOKEN by default", () => { @@ -262,7 +262,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); it("parses basic config with draft and prerelease", () => { @@ -288,7 +288,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); it("parses basic config where make_latest is passed", () => { @@ -313,7 +313,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: "false", - } + }, ); }); it("parses basic config with append_body", () => { @@ -338,7 +338,7 @@ describe("util", () => { input_discussion_category_name: undefined, input_generate_release_notes: false, input_make_latest: undefined, - } + }, ); }); }); @@ -355,7 +355,7 @@ describe("util", () => { it("resolves files given a set of paths", async () => { assert.deepStrictEqual( paths(["tests/data/**/*", "tests/data/does/not/exist/*"]), - ["tests/data/foo/bar.txt"] + ["tests/data/foo/bar.txt"], ); }); }); @@ -364,7 +364,7 @@ describe("util", () => { it("returns the patterns that don't match any files", async () => { assert.deepStrictEqual( unmatchedPatterns(["tests/data/**/*", "tests/data/does/not/exist/*"]), - ["tests/data/does/not/exist/*"] + ["tests/data/does/not/exist/*"], ); }); }); diff --git a/src/github.ts b/src/github.ts index 8c7cb4275..eaf3a7073 100644 --- a/src/github.ts +++ b/src/github.ts @@ -121,7 +121,7 @@ export class GitHubReleaser implements Releaser { }): AsyncIterableIterator<{ data: Release[] }> { const updatedParams = { per_page: 100, ...params }; return this.github.paginate.iterator( - this.github.rest.repos.listReleases.endpoint.merge(updatedParams) + this.github.rest.repos.listReleases.endpoint.merge(updatedParams), ); } } @@ -144,7 +144,7 @@ export const upload = async ( github: GitHub, url: string, path: string, - currentAssets: Array<{ id: number; name: string }> + currentAssets: Array<{ id: number; name: string }>, ): Promise => { const [owner, repo] = config.github_repository.split("/"); const { name, size, mime, data: body } = asset(path); @@ -152,7 +152,7 @@ export const upload = async ( // note: GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets" endpoint lists the renamed filenames. // due to this renaming we need to be mindful when we compare the file name we're uploading with a name github may already have rewritten for logical comparison // see https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset - ({ name: currentName }) => currentName == name.replace(" ", ".") + ({ name: currentName }) => currentName == name.replace(" ", "."), ); if (currentAsset) { console.log(`♻️ Deleting previously uploaded asset ${name}...`); @@ -180,7 +180,7 @@ export const upload = async ( throw new Error( `Failed to upload release asset ${name}. received status code ${ resp.status - }\n${json.message}\n${JSON.stringify(json.errors)}` + }\n${json.message}\n${JSON.stringify(json.errors)}`, ); } return json; @@ -189,7 +189,7 @@ export const upload = async ( export const release = async ( config: Config, releaser: Releaser, - maxRetries: number = 3 + maxRetries: number = 3, ): Promise => { if (maxRetries <= 0) { console.log(`❌ Too many retries. Aborting...`); @@ -234,13 +234,13 @@ export const release = async ( repo, discussion_category_name, generate_release_notes, - maxRetries + maxRetries, ); } let existingRelease: Release = _release!; console.log( - `Found release ${existingRelease.name} (with id=${existingRelease.id})` + `Found release ${existingRelease.name} (with id=${existingRelease.id})`, ); const release_id = existingRelease.id; @@ -250,7 +250,7 @@ export const release = async ( config.input_target_commitish !== existingRelease.target_commitish ) { console.log( - `Updating commit from "${existingRelease.target_commitish}" to "${config.input_target_commitish}"` + `Updating commit from "${existingRelease.target_commitish}" to "${config.input_target_commitish}"`, ); target_commitish = config.input_target_commitish; } else { @@ -301,7 +301,7 @@ export const release = async ( } catch (error) { if (error.status !== 404) { console.log( - `⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}` + `⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`, ); throw error; } @@ -314,7 +314,7 @@ export const release = async ( repo, discussion_category_name, generate_release_notes, - maxRetries + maxRetries, ); } }; @@ -327,7 +327,7 @@ async function createRelease( repo: string, discussion_category_name: string | undefined, generate_release_notes: boolean | undefined, - maxRetries: number + maxRetries: number, ) { const tag_name = tag; const name = config.input_name || tag; @@ -341,7 +341,7 @@ async function createRelease( commitMessage = ` using commit "${target_commitish}"`; } console.log( - `👩‍🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...` + `👩‍🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...`, ); try { let release = await releaser.createRelease({ @@ -366,7 +366,7 @@ async function createRelease( switch (error.status) { case 403: console.log( - "Skip retry — your GitHub token/PAT does not have the required permission to create a release" + "Skip retry — your GitHub token/PAT does not have the required permission to create a release", ); throw error; diff --git a/src/main.ts b/src/main.ts index 27400b3fa..34b2d696a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -46,7 +46,7 @@ async function run() { throttle: { onRateLimit: (retryAfter, options) => { console.warn( - `Request quota exhausted for request ${options.method} ${options.url}` + `Request quota exhausted for request ${options.method} ${options.url}`, ); if (options.request.retryCount === 0) { // only retries once @@ -57,7 +57,7 @@ async function run() { onAbuseLimit: (retryAfter, options) => { // does not retry, only logs a warning console.warn( - `Abuse detected for request ${options.method} ${options.url}` + `Abuse detected for request ${options.method} ${options.url}`, ); }, }, @@ -81,11 +81,11 @@ async function run() { gh, uploadUrl(rel.upload_url), path, - currentAssets + currentAssets, ); delete json.uploader; return json; - }) + }), ).catch((error) => { throw error; }); diff --git a/src/util.ts b/src/util.ts index 29904fdb7..5dce79f64 100644 --- a/src/util.ts +++ b/src/util.ts @@ -47,7 +47,7 @@ export const parseInputFiles = (files: string): string[] => { .concat(line.split(",")) .filter((pat) => pat) .map((pat) => pat.trim()), - [] + [], ); }; @@ -80,7 +80,7 @@ export const parseConfig = (env: Env): Config => { export const paths = (patterns: string[]): string[] => { return patterns.reduce((acc: string[], pattern: string): string[] => { return acc.concat( - glob.sync(pattern).filter((path) => statSync(path).isFile()) + glob.sync(pattern).filter((path) => statSync(path).isFile()), ); }, []); }; @@ -90,7 +90,7 @@ export const unmatchedPatterns = (patterns: string[]): string[] => { return acc.concat( glob.sync(pattern).filter((path) => statSync(path).isFile()).length == 0 ? [pattern] - : [] + : [], ); }, []); };