From 19be9e89dfd032ab1c45de91f7844ce4f018eb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Badst=C3=BCbner?= Date: Fri, 2 Feb 2024 15:15:08 +0100 Subject: [PATCH] [patrol_cli] fix(analytics.dart): sanitize version check command #2087 in _getFlutterVersion() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Badstübner --- packages/patrol_cli/CHANGELOG.md | 4 ++++ packages/patrol_cli/lib/src/analytics/analytics.dart | 10 +++++++++- packages/patrol_cli/lib/src/base/constants.dart | 2 +- packages/patrol_cli/pubspec.yaml | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index 1d0c5915e..0cfbb1e12 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.3 + +- Fix invalid JSON output of version check command (#2087). + ## 2.6.2 - Print link to devtools regardless of open-devtools flag (#2076). diff --git a/packages/patrol_cli/lib/src/analytics/analytics.dart b/packages/patrol_cli/lib/src/analytics/analytics.dart index dc6308422..bb4f6830a 100644 --- a/packages/patrol_cli/lib/src/analytics/analytics.dart +++ b/packages/patrol_cli/lib/src/analytics/analytics.dart @@ -195,8 +195,16 @@ FlutterVersion _getFlutterVersion() { runInShell: true, ); - final versionData = jsonDecode(result.stdOut) as Map; + final versionData = + jsonDecode(cleanJsonResult(result)) as Map; final frameworkVersion = versionData['frameworkVersion'] as String; final channel = versionData['channel'] as String; return FlutterVersion(frameworkVersion, channel); } + +// Workaround for https://github.com/flutter/flutter/issues/122814 +String cleanJsonResult(io.ProcessResult result) { + final parts = result.stdOut.split('}')..removeLast(); + final cleanedString = parts.join('}'); + return '$cleanedString}'; +} diff --git a/packages/patrol_cli/lib/src/base/constants.dart b/packages/patrol_cli/lib/src/base/constants.dart index deb56214d..ad7dabc33 100644 --- a/packages/patrol_cli/lib/src/base/constants.dart +++ b/packages/patrol_cli/lib/src/base/constants.dart @@ -1,3 +1,3 @@ /// Version of Patrol CLI. Must be kept in sync with pubspec.yaml. /// If you update this, make sure that compatibility-table.mdx is updated (if needed) -const version = '2.6.2'; +const version = '2.6.3'; diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 21e6f31f3..fcd314a30 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: patrol_cli description: > Command-line tool for Patrol, a powerful Flutter-native UI testing framework. -version: 2.6.2 # Must be kept in sync with constants.dart +version: 2.6.3 # Must be kept in sync with constants.dart homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol_cli issue_tracker: https://github.com/leancodepl/patrol/issues?q=is%3Aopen+is%3Aissue+label%3A%22package%3A+patrol_cli%22