From 8c364d6b1ce1267cbd8bfeefbb3124d1b5d1ae7b Mon Sep 17 00:00:00 2001 From: Wei Date: Sat, 14 Dec 2024 08:43:25 -0500 Subject: [PATCH] chore: adding `trailingComma` prettier --- .prettierrc.yaml | 1 + babel.config.ts | 4 ++-- bin/action.min.js | 1 - jest.config.ts | 2 +- src/createCheck.ts | 4 ++-- src/deploy.ts | 14 +++++++------- src/index.ts | 24 ++++++++++++------------ src/postOrUpdateComment.ts | 6 +++--- test/deploy.test.ts | 10 +++++----- test/hash.test.ts | 6 +++--- test/postOrUpdateComment.test.ts | 10 +++++----- test/samples/cliOutputs.ts | 28 ++++++++++++++-------------- 12 files changed, 55 insertions(+), 55 deletions(-) diff --git a/.prettierrc.yaml b/.prettierrc.yaml index 76c9b034..b9dfb5e9 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -13,3 +13,4 @@ # limitations under the License. singleQuote: false +trailingComma: none diff --git a/babel.config.ts b/babel.config.ts index 7aa62c47..cb3d560e 100644 --- a/babel.config.ts +++ b/babel.config.ts @@ -3,6 +3,6 @@ module.exports = { presets: [ ["@babel/preset-env", { targets: { node: "current" } }], - "@babel/preset-typescript", - ], + "@babel/preset-typescript" + ] }; diff --git a/bin/action.min.js b/bin/action.min.js index 8324beb8..9c931a29 100644 --- a/bin/action.min.js +++ b/bin/action.min.js @@ -92976,7 +92976,6 @@ async function execWithCredentials(args, projectId, gacFilename, opts) { } return deployOutputBuf.length ? deployOutputBuf[deployOutputBuf.length - 1].toString("utf-8") : ""; // output from the CLI } - async function deployPreview(gacFilename, deployConfig) { const { projectId, diff --git a/jest.config.ts b/jest.config.ts index eff25332..fe0e72b0 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -11,5 +11,5 @@ export default { preset: "ts-jest", // The test environment that will be used for testing - testEnvironment: "node", + testEnvironment: "node" }; diff --git a/src/createCheck.ts b/src/createCheck.ts index f445e2fc..f0d00da1 100644 --- a/src/createCheck.ts +++ b/src/createCheck.ts @@ -25,7 +25,7 @@ export async function createCheck( ...context.repo, name: "Deploy Preview", head_sha: context.payload.pull_request?.head.sha, - status: "in_progress", + status: "in_progress" }); return async (details: Object) => { @@ -34,7 +34,7 @@ export async function createCheck( check_run_id: check.data.id, completed_at: new Date().toISOString(), status: "completed", - ...details, + ...details }); }; } diff --git a/src/deploy.ts b/src/deploy.ts index 76c61858..fb0df11b 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -66,7 +66,7 @@ export function interpretChannelDeployResult( return { expireTime, expire_time_formatted, - urls, + urls }; } @@ -88,19 +88,19 @@ async function execWithCredentials( ...(projectId ? ["--project", projectId] : []), debug ? "--debug" // gives a more thorough error message - : "--json", // allows us to easily parse the output + : "--json" // allows us to easily parse the output ], { listeners: { stdout(data: Buffer) { deployOutputBuf.push(data); - }, + } }, env: { ...process.env, FIREBASE_DEPLOY_AGENT: "action-hosting-deploy", - GOOGLE_APPLICATION_CREDENTIALS: gacFilename, // the CLI will automatically authenticate with this env variable set - }, + GOOGLE_APPLICATION_CREDENTIALS: gacFilename // the CLI will automatically authenticate with this env variable set + } } ); } catch (e) { @@ -113,7 +113,7 @@ async function execWithCredentials( ); await execWithCredentials(args, projectId, gacFilename, { debug: true, - firebaseToolsVersion, + firebaseToolsVersion }); } else { throw e; @@ -137,7 +137,7 @@ export async function deployPreview( "hosting:channel:deploy", channelId, ...(target ? ["--only", target] : []), - ...(expires ? ["--expires", expires] : []), + ...(expires ? ["--expires", expires] : []) ], projectId, gacFilename, diff --git a/src/index.ts b/src/index.ts index fe34502b..cc0f30d2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,7 @@ import { getInput, setFailed, setOutput, - startGroup, + startGroup } from "@actions/core"; import { context, getOctokit } from "@actions/github"; import { existsSync } from "fs"; @@ -29,19 +29,19 @@ import { deployPreview, deployProductionSite, ErrorResult, - interpretChannelDeployResult, + interpretChannelDeployResult } from "./deploy"; import { getChannelId } from "./getChannelId"; import { getURLsMarkdownFromChannelDeployResult, - postChannelSuccessComment, + postChannelSuccessComment } from "./postOrUpdateComment"; // Inputs defined in action.yml const expires = getInput("expires"); const projectId = getInput("projectId"); const googleApplicationCredentials = getInput("firebaseServiceAccount", { - required: true, + required: true }); const configuredChannelId = getInput("channelId"); const isProductionDeploy = configuredChannelId === "live"; @@ -93,7 +93,7 @@ async function run() { const deployment = await deployProductionSite(gacFilename, { projectId, target, - firebaseToolsVersion, + firebaseToolsVersion }); if (deployment.status === "error") { throw Error((deployment as ErrorResult).error); @@ -107,8 +107,8 @@ async function run() { conclusion: "success", output: { title: `Production deploy succeeded`, - summary: `[${hostname}](${url})`, - }, + summary: `[${hostname}](${url})` + } }); return; } @@ -121,7 +121,7 @@ async function run() { expires, channelId, target, - firebaseToolsVersion, + firebaseToolsVersion }); if (deployment.status === "error") { @@ -152,8 +152,8 @@ async function run() { conclusion: "success", output: { title: `Deploy preview succeeded`, - summary: getURLsMarkdownFromChannelDeployResult(deployment), - }, + summary: getURLsMarkdownFromChannelDeployResult(deployment) + } }); } catch (e) { setFailed(e.message); @@ -162,8 +162,8 @@ async function run() { conclusion: "failure", output: { title: "Deploy preview failed", - summary: `Error: ${e.message}`, - }, + summary: `Error: ${e.message}` + } }); } } diff --git a/src/postOrUpdateComment.ts b/src/postOrUpdateComment.ts index adf66f1e..e8c4f32e 100644 --- a/src/postOrUpdateComment.ts +++ b/src/postOrUpdateComment.ts @@ -67,14 +67,14 @@ export async function postChannelSuccessComment( ) { const commentInfo = { ...context.repo, - issue_number: context.issue.number, + issue_number: context.issue.number }; const commentMarkdown = getChannelDeploySuccessComment(result, commit); const comment = { ...commentInfo, - body: commentMarkdown, + body: commentMarkdown }; startGroup(`Commenting on PR`); @@ -100,7 +100,7 @@ export async function postChannelSuccessComment( await github.rest.issues.updateComment({ ...context.repo, comment_id: commentId, - body: comment.body, + body: comment.body }); } catch (e) { commentId = null; diff --git a/test/deploy.test.ts b/test/deploy.test.ts index c72dd153..0cbae282 100644 --- a/test/deploy.test.ts +++ b/test/deploy.test.ts @@ -4,7 +4,7 @@ import { deployPreview, deployProductionSite, ProductionDeployConfig, - ProductionSuccessResult, + ProductionSuccessResult } from "../src/deploy"; import * as exec from "@actions/exec"; import { @@ -12,17 +12,17 @@ import { channelMultiSiteSuccess, channelSingleSiteSuccess, liveDeployMultiSiteSuccess, - liveDeploySingleSiteSuccess, + liveDeploySingleSiteSuccess } from "./samples/cliOutputs"; const baseChannelDeployConfig: ChannelDeployConfig = { projectId: "my-project", channelId: "my-channel", - expires: undefined, + expires: undefined }; const baseLiveDeployConfig: ProductionDeployConfig = { - projectId: "my-project", + projectId: "my-project" }; async function fakeExecFail( @@ -114,7 +114,7 @@ describe("deploy", () => { const config: ChannelDeployConfig = { ...baseChannelDeployConfig, - target: "my-second-site", + target: "my-second-site" }; await deployPreview("my-file", config); diff --git a/test/hash.test.ts b/test/hash.test.ts index 5e66884c..1f0af964 100644 --- a/test/hash.test.ts +++ b/test/hash.test.ts @@ -1,6 +1,6 @@ import { channelSingleSiteSuccess, - channelMultiSiteSuccess, + channelMultiSiteSuccess } from "./samples/cliOutputs"; import { createDeploySignature } from "../src/hash"; @@ -18,8 +18,8 @@ describe("hash", () => { ...channelMultiSiteSuccess, result: { targetX: channelMultiSiteSuccess.result.target2, - targetY: channelMultiSiteSuccess.result.target1, - }, + targetY: channelMultiSiteSuccess.result.target1 + } }); expect(signMulti2).toEqual("980f04126fb629deaadace7d6ee8a0628942e3d3"); }); diff --git a/test/postOrUpdateComment.test.ts b/test/postOrUpdateComment.test.ts index 7abe581d..2c9cfbb7 100644 --- a/test/postOrUpdateComment.test.ts +++ b/test/postOrUpdateComment.test.ts @@ -1,15 +1,15 @@ import { singleSiteComment, multiSiteComment, - notABotComment, + notABotComment } from "./samples/comments"; import { getChannelDeploySuccessComment, - createBotCommentIdentifier, + createBotCommentIdentifier } from "../src/postOrUpdateComment"; import { channelSingleSiteSuccess, - channelMultiSiteSuccess, + channelMultiSiteSuccess } from "./samples/cliOutputs"; import { createDeploySignature } from "../src/hash"; @@ -37,7 +37,7 @@ describe("postOrUpdateComment", () => { const isCommentByBot = createBotCommentIdentifier(signature); const testComment = { user: { type: "Bot" }, - body: singleSiteComment, + body: singleSiteComment }; expect(isCommentByBot(testComment)).toEqual(true); }); @@ -47,7 +47,7 @@ describe("postOrUpdateComment", () => { const isCommentByBot = createBotCommentIdentifier(signature); const testComment = { user: { type: "Bot" }, - body: notABotComment, + body: notABotComment }; expect(isCommentByBot(testComment)).toEqual(false); }); diff --git a/test/samples/cliOutputs.ts b/test/samples/cliOutputs.ts index 1fda8f7d..e395f9df 100644 --- a/test/samples/cliOutputs.ts +++ b/test/samples/cliOutputs.ts @@ -1,7 +1,7 @@ import { ChannelSuccessResult, ErrorResult, - ProductionSuccessResult, + ProductionSuccessResult } from "../../src/deploy"; export const commitId = "fe211ff"; @@ -13,15 +13,15 @@ export const channelMultiSiteSuccess: ChannelSuccessResult = { site: "my-main-hosting-site", target: "target1", url: "https://action-hosting-deploy-demo--multisite-test-goqvngto.web.app", - expireTime: "2020-10-27T21:32:57.233344586Z", + expireTime: "2020-10-27T21:32:57.233344586Z" }, target2: { site: "my-second-hosting-site", target: "target2", url: "https://action-hosting-deploy-demo-2--multisite-test-ksadajci.web.app", - expireTime: "2020-10-27T21:32:57.233344586Z", - }, - }, + expireTime: "2020-10-27T21:32:57.233344586Z" + } + } }; export const channelSingleSiteSuccess: ChannelSuccessResult = { @@ -30,22 +30,22 @@ export const channelSingleSiteSuccess: ChannelSuccessResult = { "action-hosting-deploy-demo": { site: "action-hosting-deploy-demo", url: "https://action-hosting-deploy-demo--singlesite-test-jl98rmie.web.app", - expireTime: "2020-10-27T21:32:57.233344586Z", - }, - }, + expireTime: "2020-10-27T21:32:57.233344586Z" + } + } }; export const channelError: ErrorResult = { status: "error", error: - "HTTP Error: 400, Channel IDs can only include letters, numbers, underscores, hyphens, and periods.", + "HTTP Error: 400, Channel IDs can only include letters, numbers, underscores, hyphens, and periods." }; export const liveDeploySingleSiteSuccess: ProductionSuccessResult = { status: "success", result: { - hosting: "sites/jeff-test-699d3/versions/7aebddc461b66922", - }, + hosting: "sites/jeff-test-699d3/versions/7aebddc461b66922" + } }; export const liveDeployMultiSiteSuccess: ProductionSuccessResult = { @@ -53,7 +53,7 @@ export const liveDeployMultiSiteSuccess: ProductionSuccessResult = { result: { hosting: [ "sites/action-hosting-deploy-demo/versions/cd71a5c43ba0921b", - "sites/action-hosting-deploy-demo-2/versions/e843c071a09cecbf", - ], - }, + "sites/action-hosting-deploy-demo-2/versions/e843c071a09cecbf" + ] + } };