diff --git a/packages/codemagic_app_preview/README.md b/packages/codemagic_app_preview/README.md index fb2dd68..ca379f7 100644 --- a/packages/codemagic_app_preview/README.md +++ b/packages/codemagic_app_preview/README.md @@ -81,6 +81,7 @@ If you are interested in supporting self-hosted GitLab, Bitbucket or a different |  `--message` | Optional | Custom message to include in the comment. | "Only team members are able to install the iOS app.", see [this example](https://github.com/SharezoneApp/sharezone-app/pull/1095#issuecomment-1733715519). | |  `--expires_in` | Optional | Defines the duration for which the URLs to the artifacts are valid. The maximum duration depends on your account type, see [Codemagic documentation](https://docs.codemagic.io/billing/pricing/#build-history-and-artifact-storage). The default value is 30 days. | `2w 6d 23h 59m 59s` or `365d` | | `--app_name` | Optional | The name of the app. This is helpful if you have multiple apps in the same repository. Using different names for different apps allows you to post multiple comments in the same pull request. | `sharezone` | +| `--qr-code-size` | Optional |  The size of the QR code in pixels as an integer. The default value is 200. | `500` or `400` | ## Quick Start Guide diff --git a/packages/codemagic_app_preview/lib/src/commands/post_command.dart b/packages/codemagic_app_preview/lib/src/commands/post_command.dart index 3a1deaf..7a9fcd3 100644 --- a/packages/codemagic_app_preview/lib/src/commands/post_command.dart +++ b/packages/codemagic_app_preview/lib/src/commands/post_command.dart @@ -57,6 +57,12 @@ class PostCommand extends Command { 'app-name', help: 'The name of the app. This is helpful if you have multiple apps in the same repository. If not provided, the name "default" is used. Using different names for different apps allows you to post multiple comments in the same pull request.', + ) + ..addOption( + 'qr-code-size', + help: + 'The size of the QR code in pixels as an integer. The default value is 200. Example values: "100" or "500"', + defaultsTo: '200', ); } @@ -89,6 +95,7 @@ class PostCommand extends Command { final comment = CommentBuilder(environmentVariableAccessor).build( builds, message: argResults?['message'], + qrCodeSize: int.parse(argResults?['qr-code-size']!), ); final gitHostRepository = await _getGitHostRepository(gitRepo); diff --git a/packages/codemagic_app_preview/lib/src/comment/comment_builder.dart b/packages/codemagic_app_preview/lib/src/comment/comment_builder.dart index d8e1a12..3e61bc8 100644 --- a/packages/codemagic_app_preview/lib/src/comment/comment_builder.dart +++ b/packages/codemagic_app_preview/lib/src/comment/comment_builder.dart @@ -16,13 +16,17 @@ class CommentBuilder { /// Builds a message that can be used a comment on a pull request. String build( List builds, { + required int qrCodeSize, String? appName, String? message, }) { final comment = StringBuffer(); final commit = _environmentVariableAccessor.get('FCI_COMMIT'); - final table = _buildTable(builds); + final table = _buildTable( + builds, + qrCodeSize: qrCodeSize, + ); comment.write( '⬇️ Builds generated by [Codemagic](https://codemagic.io) for commit $commit ⬇️'); @@ -50,7 +54,10 @@ class CommentBuilder { /// |:-:|:-:| /// | ![image](https://app-preview-qr.nils.re/?size=150x150&data=$LINK)
[Download link]($LINK) | ![image](https://app-preview-qr.nils.re/?size=150x150&data=$ENCODED_IPA_LINK)
[Download link]($LINK) /// ``` - String _buildTable(List builds) { + String _buildTable( + List builds, { + required int qrCodeSize, + }) { final table = StringBuffer(); int columnsCounter = 0; @@ -80,6 +87,7 @@ class CommentBuilder { url: build.publicUrl, groupId: groupId, platform: build.platform, + qrCodeSize: qrCodeSize, ); if (build.platform == BuildPlatform.macos) { @@ -175,9 +183,10 @@ class CommentBuilder { required String url, required String groupId, required BuildPlatform platform, + required int qrCodeSize, }) { // The url needs to be encoded to make it safe to use as a url component. final encodedUrl = Uri.encodeComponent(url); - return 'https://app-preview-qr.nils.re/?size=150x150&data=$encodedUrl&platform=${platform.platformIdentifier}&groupId=$groupId'; + return 'https://app-preview-qr.nils.re/?size=${qrCodeSize}x$qrCodeSize&data=$encodedUrl&platform=${platform.platformIdentifier}&groupId=$groupId'; } } diff --git a/packages/codemagic_app_preview/test/comment_builder_test.dart b/packages/codemagic_app_preview/test/comment_builder_test.dart index f51f4b2..7721cf4 100644 --- a/packages/codemagic_app_preview/test/comment_builder_test.dart +++ b/packages/codemagic_app_preview/test/comment_builder_test.dart @@ -54,12 +54,12 @@ void main() { // The group id that is generated when using 42 as seed. const groupId = "33aec45d"; - expect(builder.build(builds), + expect(builder.build(builds, qrCodeSize: 351), """⬇️ Builds generated by [Codemagic](https://codemagic.io) for commit $commit ⬇️ | ${builds[0].platform.platformName} | | ${builds[1].platform.platformName} | | ${builds[2].platform.platformName} | |:-:|:-:|:-:|:-:|:-:| -| ![Android QR code](https://app-preview-qr.nils.re/?size=150x150&data=${Uri.encodeComponent(builds[0].publicUrl)}&platform=android&groupId=$groupId)
[Download link](${builds[0].publicUrl}) | | ![iOS QR code](https://app-preview-qr.nils.re/?size=150x150&data=${Uri.encodeComponent(builds[1].publicUrl)}&platform=ios&groupId=$groupId)
[Download link](${builds[1].publicUrl}) | | Download Icon
[Download link](${builds[2].publicUrl}) | +| ![Android QR code](https://app-preview-qr.nils.re/?size=351x351&data=${Uri.encodeComponent(builds[0].publicUrl)}&platform=android&groupId=$groupId)
[Download link](${builds[0].publicUrl}) | | ![iOS QR code](https://app-preview-qr.nils.re/?size=351x351&data=${Uri.encodeComponent(builds[1].publicUrl)}&platform=ios&groupId=$groupId)
[Download link](${builds[1].publicUrl}) | | Download Icon
[Download link](${builds[2].publicUrl}) | (expires Tue, 24 Jan 2023 11:10:09 GMT)
Codemagic build: [$buildId](https://codemagic.io/app/$projectId/build/$buildId); comment generated with [Codemagic App Preview](https://github.com/nilsreichardt/codemagic-app-preview)
@@ -80,7 +80,8 @@ void main() { ]; final message = 'this is a custom message'; - expect(builder.build(builds, message: message), contains(message)); + expect(builder.build(builds, message: message, qrCodeSize: 150), + contains(message)); }); }); }