-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
sz build_runner build
command (#997)
Needed for #963 Usage: ``` $ sz build_runner Missing subcommand for "pub global run sz_repo_cli build_runner". Usage: pub global run sz_repo_cli build_runner <subcommand> [arguments] -h, --help Print this usage information. Available subcommands: build Performs a single build on the specified targets and then exits. Run "pub global run sz_repo_cli help" to see global options. ``` ``` $ sz build_runner build holidays ⚙ Running abgabe_http_api ⚙ Running sharezone ⚙ Running abgabe_http_api ✅ holidays ✅ sharezone ✅ Task was successfully executed for all packages! ```
- Loading branch information
1 parent
a2f2631
commit 9c6a3c4
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
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,59 @@ | ||
// 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); | ||
|
||
@override | ||
final String name = 'build'; | ||
|
||
@override | ||
final String description = | ||
'Performs a single build on the specified targets and then exits. Uses the "--delete-conflicting-outputs" flag'; | ||
|
||
@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', | ||
// We use the "--delete-conflicting-outputs" flag, because we want to | ||
// delete the conflicting outputs. | ||
// | ||
// Normally, the Dart CLI shows three options when there is a conflict: | ||
// delete (1), cancel build (2) or list conflicts (3). But since we | ||
// don't show the output of the `dart run build_runner` command, the | ||
// user has no way to choose between these options. | ||
// | ||
// Therefore, we hard code it to delete the conflicting outputs. | ||
'--delete-conflicting-outputs', | ||
], | ||
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