From 3d4cfca980fee5b0e4a916c0ffc2a6758bd181ba Mon Sep 17 00:00:00 2001 From: Viren Khatri <44755140+werainkhatri@users.noreply.github.com> Date: Tue, 11 Oct 2022 04:31:54 +0530 Subject: [PATCH] initial commit --- .../lib/src/command_runner.dart | 2 + .../lib/src/commands/bug_report.dart | 105 ++++++++++++++++++ packages/flutterfire_cli/pubspec.yaml | 1 + 3 files changed, 108 insertions(+) create mode 100644 packages/flutterfire_cli/lib/src/commands/bug_report.dart diff --git a/packages/flutterfire_cli/lib/src/command_runner.dart b/packages/flutterfire_cli/lib/src/command_runner.dart index 030cd77a..5bacbfdb 100644 --- a/packages/flutterfire_cli/lib/src/command_runner.dart +++ b/packages/flutterfire_cli/lib/src/command_runner.dart @@ -17,6 +17,7 @@ import 'package:args/command_runner.dart'; +import 'commands/bug_report.dart'; import 'commands/config.dart'; import 'common/utils.dart'; import 'flutter_app.dart'; @@ -50,5 +51,6 @@ class FlutterFireCommandRunner extends CommandRunner { ); addCommand(ConfigCommand(flutterApp)); + addCommand(BugReportCommand(flutterApp)); } } diff --git a/packages/flutterfire_cli/lib/src/commands/bug_report.dart b/packages/flutterfire_cli/lib/src/commands/bug_report.dart new file mode 100644 index 00000000..a0f3d152 --- /dev/null +++ b/packages/flutterfire_cli/lib/src/commands/bug_report.dart @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016-present Invertase Limited & Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this library except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import 'package:issue/issue.dart'; + +import '../flutter_app.dart'; +import 'base.dart'; + +class BugReportCommand extends FlutterFireCommand { + BugReportCommand(FlutterApp? flutterApp) : super(flutterApp); + + @override + final String description = 'Generate a bug report for your project.'; + + @override + final String name = 'bug-report'; + + @override + Future run() async { + commandRequiresFlutterApp(); + + final config = IssueConfig( + template: FlutterFireIssueTemplate(), + tracker: GitHubIssueTracker( + organization: 'firebase', + repository: 'flutterfire', + template: '---bug-report.md', + ), + ); + + try { + await buildIssueAndOpen(config); + } on UserInterruptException { + logger.stdout('Aborting $name.'); + } + } +} + +class FlutterFireIssueTemplate extends IssueTemplate { + FlutterFireIssueTemplate() + : super( + titleTemplate: '🐛 [PLUGIN_NAME_HERE] Your issue title here', + labels: ['Needs Attention', 'type: bug'], + heading: '## Bug report', + sections: [ + const DescriptionIssueSection(), + CombinedIssueSection( + prompt: 'Issue Details', + sections: const [ + StepsToReproduceIssueSection(), + ExpectedBehaviorIssueSection(), + SampleProjectIssueSection(), + ], + ), + const DividerIssueSection(), + const AdditionalContextIssueSection(), + const DividerIssueSection(), + FlutterDoctorIssueSection(), + const DividerIssueSection(), + FlutterDependenciesIssueSection(), + ], + ); +} + +class SampleProjectIssueSection extends IssueSection { + const SampleProjectIssueSection() + : super.userDriven( + heading: '### Sample project', + content: + 'Providing a minimal example project which demonstrates the bug ' + 'in isolation from your main App _greatly_ enhances the chance ' + 'of a timely fix.\n' + 'Please link to the public repository URL.', + ); +} + +class FlutterDependenciesIssueSection extends DetailsIssueSection { + FlutterDependenciesIssueSection() + : super.commandDriven( + command: ['flutter', 'pub', 'deps', '--', '--style=compact'], + heading: '### Flutter dependencies', + details: ''' +```bash +$kPlaceholder +```''', + placeholder: kPlaceholder, + summary: 'Click To Expand', + ); + + static const kPlaceholder = 'PASTE FLUTTER DEPENDENCIES OUTPUT HERE'; +} diff --git a/packages/flutterfire_cli/pubspec.yaml b/packages/flutterfire_cli/pubspec.yaml index 69ecdb61..f3fe69e9 100644 --- a/packages/flutterfire_cli/pubspec.yaml +++ b/packages/flutterfire_cli/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: deep_pick: ^0.10.0 file: ^6.1.2 interact: ^2.1.1 + issue: ^0.0.3 meta: ^1.7.0 path: ^1.8.0 platform: ^3.0.2