From edef963c577372b84e0dbc387e4fbcd7dd2a603b Mon Sep 17 00:00:00 2001 From: Aidan Cunniffe Date: Tue, 7 Jan 2025 12:14:04 +0100 Subject: [PATCH] allow overriding ci comment (#2871) --- package.json | 2 +- projects/fastify-capture/package.json | 2 +- projects/json-pointer-helpers/package.json | 2 +- projects/openapi-io/package.json | 2 +- projects/openapi-utilities/package.json | 2 +- projects/optic/package.json | 2 +- projects/optic/src/commands/ci/comment/comment.ts | 3 +++ projects/optic/src/commands/ci/comment/common.ts | 6 +++--- projects/rulesets-base/package.json | 2 +- projects/standard-rulesets/package.json | 2 +- 10 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 09a5d5c609..72f9f3cd76 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "openapi-workspaces", "license": "MIT", "private": true, - "version": "1.0.4", + "version": "1.0.5", "workspaces": [ "projects/json-pointer-helpers", "projects/openapi-io", diff --git a/projects/fastify-capture/package.json b/projects/fastify-capture/package.json index e9868acb48..1027b15b6e 100644 --- a/projects/fastify-capture/package.json +++ b/projects/fastify-capture/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/fastify-capture", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/json-pointer-helpers/package.json b/projects/json-pointer-helpers/package.json index 93394c01c4..a24c15cc13 100644 --- a/projects/json-pointer-helpers/package.json +++ b/projects/json-pointer-helpers/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/json-pointer-helpers", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/openapi-io/package.json b/projects/openapi-io/package.json index 6b5e5f6d8e..cfe3b9e742 100644 --- a/projects/openapi-io/package.json +++ b/projects/openapi-io/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/openapi-io", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/openapi-utilities/package.json b/projects/openapi-utilities/package.json index 15c4bcdb39..b16799f179 100644 --- a/projects/openapi-utilities/package.json +++ b/projects/openapi-utilities/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/openapi-utilities", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/optic/package.json b/projects/optic/package.json index fc99650ea5..87f1ff17f2 100644 --- a/projects/optic/package.json +++ b/projects/optic/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/optic", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/optic/src/commands/ci/comment/comment.ts b/projects/optic/src/commands/ci/comment/comment.ts index 51a622c9e6..4e09af88ac 100644 --- a/projects/optic/src/commands/ci/comment/comment.ts +++ b/projects/optic/src/commands/ci/comment/comment.ts @@ -51,6 +51,7 @@ export const registerCiComment = (cli: Command, config: OpticCliConfig) => { '--enterprise-base-url ', '(only for enterprise versions of github or gitlab) - the base url to your enterprise github / gitlab instance' ) + .option('--comment-url ', 'override the url of the comment') .option('--verbose', 'show all operations changed in each API', false) .description('comment on a pull request / merge request') .action( @@ -60,6 +61,7 @@ export const registerCiComment = (cli: Command, config: OpticCliConfig) => { type CommonOptions = { verbose: boolean; + commentUrl: string; }; type UnvalidatedOptions = CommonOptions & { @@ -153,6 +155,7 @@ const getCiCommentAction = await commenter.getComment(COMPARE_SUMMARY_IDENTIFIER); const body = generateCompareSummaryMarkdown({ sha: options.sha }, data, { verbose: options.verbose, + overrideUrl: options.commentUrl, }); if (maybeComment) { diff --git a/projects/optic/src/commands/ci/comment/common.ts b/projects/optic/src/commands/ci/comment/common.ts index 0225250561..a3494a13f9 100644 --- a/projects/optic/src/commands/ci/comment/common.ts +++ b/projects/optic/src/commands/ci/comment/common.ts @@ -82,7 +82,7 @@ const getCaptureIssuesLabel = ({ export const generateCompareSummaryMarkdown = ( commit: { sha: string }, results: CiRunDetails, - options: { verbose: boolean } + options: { verbose: boolean; overrideUrl?: string } ) => { const anyCompletedHasWarning = results.completed.some( (s) => s.warnings.length > 0 @@ -122,7 +122,7 @@ ${s.apiName} ${getOperationsText(s.comparison.groupedDiffs, { - webUrl: s.opticWebUrl, + webUrl: options.overrideUrl || s.opticWebUrl, verbose: options.verbose, labelJoiner: ',\n', })} @@ -163,7 +163,7 @@ ${ -${s.opticWebUrl ? `[View report](${s.opticWebUrl})` : ''} +${options.overrideUrl || s.opticWebUrl ? `[View report](${options.overrideUrl || s.opticWebUrl})` : ''} ` diff --git a/projects/rulesets-base/package.json b/projects/rulesets-base/package.json index 67c8284e6c..63c3582048 100644 --- a/projects/rulesets-base/package.json +++ b/projects/rulesets-base/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/rulesets-base", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/standard-rulesets/package.json b/projects/standard-rulesets/package.json index 88d718924a..2e423e9e68 100644 --- a/projects/standard-rulesets/package.json +++ b/projects/standard-rulesets/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/standard-rulesets", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.4", + "version": "1.0.5", "main": "build/index.js", "types": "build/index.d.ts", "files": [