-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add sz build_runner build
command
#997
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
tools/sz_repo_cli/lib/src/commands/src/build_runner_build_command.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) | ||
// Licensed under the EUPL-1.2-or-later. | ||
// | ||
// You may obtain a copy of the Licence at: | ||
// https://joinup.ec.europa.eu/software/page/eupl | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:sz_repo_cli/src/common/common.dart'; | ||
|
||
class BuildRunnerBuild extends ConcurrentCommand { | ||
BuildRunnerBuild(SharezoneRepo repo) : super(repo) { | ||
argParser.addFlag( | ||
'delete-conflicting-outputs', | ||
help: | ||
'By default, the user will be prompted to delete any files which already exist but were not known to be generated by this specific build script.', | ||
aliases: ['d'], | ||
defaultsTo: false, | ||
negatable: false, | ||
); | ||
} | ||
|
||
@override | ||
final String name = 'build'; | ||
|
||
@override | ||
final String description = | ||
'Performs a single build on the specified targets and then exits.'; | ||
|
||
@override | ||
int get defaultMaxConcurrency => 5; | ||
|
||
@override | ||
Duration get defaultPackageTimeout => const Duration(minutes: 10); | ||
|
||
@override | ||
Stream<Package> get packagesToProcess { | ||
return repo | ||
.streamPackages() | ||
.where((package) => package.hasBuildRunnerDependency); | ||
} | ||
|
||
@override | ||
Future<void> runTaskForPackage(Package package) async { | ||
await runProcessSucessfullyOrThrow( | ||
'fvm', | ||
[ | ||
'dart', | ||
'run', | ||
'build_runner', | ||
'build', | ||
'--delete-conflicting-outputs', | ||
'${argResults!['delete-conflicting-outputs'] as bool}', | ||
], | ||
workingDirectory: package.path, | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tools/sz_repo_cli/lib/src/commands/src/build_runner_command.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) | ||
// Licensed under the EUPL-1.2-or-later. | ||
// | ||
// You may obtain a copy of the Licence at: | ||
// https://joinup.ec.europa.eu/software/page/eupl | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import 'package:args/command_runner.dart'; | ||
|
||
class BuildRunnerCommand extends Command { | ||
@override | ||
String get description => | ||
'Runs "dart run build_runner" for every package that contains build_runner as a dependency.'; | ||
|
||
@override | ||
String get name => 'build_runner'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if promoting the options works with our CLI. Maybe we should always use the
--delete-conflicting-outputs
flag because I think this is the option to always use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what do you mean exactly. Does that mean that you are unsure if we as developers would notice having that flag for the command?
I'm okay with defaulting it with true, since like you said that's the option we're always using anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, when there is a conflict, the CLI prompts three options. You can then press key 1, 2 or 3.
However, because we don't show the prints from the Dart CLI, you will not see this message and you can't press any of these options.
Therefore, I would also hard-code
--delete-conflicting-outputs
totrue
because as a Sharezone Repo CLI user can't do anything else and wouldn't make sense to set--delete-conflicting-outputs
tofalse
.