From 53a1e02665173c02410d7c8edcebf16e6afd6010 Mon Sep 17 00:00:00 2001 From: Sanghun Lee Date: Fri, 3 Jan 2025 23:01:40 +0900 Subject: [PATCH] fix(BA-449): Allow new version notation in GQL schema --- gql-inspector-checker.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gql-inspector-checker.js b/gql-inspector-checker.js index 1d59f04094..63bf6ff3f2 100644 --- a/gql-inspector-checker.js +++ b/gql-inspector-checker.js @@ -1,8 +1,9 @@ module.exports = (props) => { const { changes, newSchema, oldSchema } = props; return changes.map((change) => { - const deprecateNotationRegex = /Deprecated since (\d{2}\.\d{2}.\d{1})/; - const addNotationRegex = /Added in (\d{2}\.\d{2}.\d{1})/; + // Allowed version notations: 'XX.XX.X', 'XX.X.X' + const deprecateNotationRegex = /Deprecated since (\d{2}\.\d{1,2}\.\d{1})/; + const addNotationRegex = /Added in (\d{2}\.\d{1,2}\.\d{1})/; if ( [ "FIELD_DEPRECATION_REASON_ADDED", @@ -15,9 +16,9 @@ module.exports = (props) => { if (newReason && !newReason.match(deprecateNotationRegex)) { change.criticality.level = "BREAKING"; change.criticality.reason = - 'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X."'; + 'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X." or "Deprecated since XX.X.X."'; change.message = - 'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X.", ' + + 'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X." or "Deprecated since XX.X.X.", ' + change.message; } } else if ( @@ -31,9 +32,9 @@ module.exports = (props) => { if (!description || (description && !description.match(addNotationRegex))) { change.criticality.level = "BREAKING"; change.criticality.reason = - 'New fields must include a description with a version number in the format "Added in XX.XX.X."'; + 'New fields must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X."'; change.message = - 'New fields must include a description with a version number in the format "Added in XX.XX.X.", ' + + 'New fields must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X.", ' + change.message; } } else if ( @@ -46,9 +47,9 @@ module.exports = (props) => { if (!description || (description && !description.match(addNotationRegex))) { change.criticality.level = "BREAKING"; change.criticality.reason = - 'New types must include a description with a version number in the format "Added in XX.XX.X."'; + 'New types must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X."'; change.message = - 'New types must include a description with a version number in the format "Added in XX.XX.X.", ' + + 'New types must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X.", ' + change.message; } } else if ( @@ -65,9 +66,9 @@ module.exports = (props) => { if (!description || (description && !description.match(addNotationRegex))) { change.criticality.level = "BREAKING"; change.criticality.reason = - 'New arguments must include a description with a version number in the format "Added in XX.XX.X."'; + 'New arguments must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X."'; change.message = - 'New arguments must include a description with a version number in the format "Added in XX.XX.X.", ' + + 'New arguments must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X.", ' + change.message; } else { change.criticality.level = "DANGEROUS";