Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bug-report command #116

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/flutterfire_cli/lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -50,5 +51,6 @@ class FlutterFireCommandRunner extends CommandRunner<void> {
);

addCommand(ConfigCommand(flutterApp));
addCommand(BugReportCommand(flutterApp));
}
}
105 changes: 105 additions & 0 deletions packages/flutterfire_cli/lib/src/commands/bug_report.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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';
}
1 change: 1 addition & 0 deletions packages/flutterfire_cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down