-
-
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.
- Loading branch information
1 parent
df8fbba
commit 68da649
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
tools/sz_repo_cli/lib/src/commands/src/build_website_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,70 @@ | ||
// 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:io'; | ||
|
||
import 'package:sz_repo_cli/src/common/common.dart'; | ||
|
||
/// The different flavors of the website. | ||
final _websiteFlavors = [ | ||
'prod', | ||
'dev', | ||
]; | ||
|
||
class BuildWebsiteCommand extends CommandBase { | ||
BuildWebsiteCommand(super.context) { | ||
argParser.addOption( | ||
flavorOptionName, | ||
allowed: _websiteFlavors, | ||
help: 'The flavor to build for.', | ||
defaultsTo: 'prod', | ||
); | ||
} | ||
|
||
static const flavorOptionName = 'flavor'; | ||
|
||
@override | ||
String get description => 'Build the Sharezone website in release mode.'; | ||
|
||
@override | ||
String get name => 'website'; | ||
|
||
@override | ||
Future<void> run() async { | ||
// Is used so that runProcess commands print the command that was run. Right | ||
// now this can't be done via an argument. | ||
// | ||
// This workaround should be addressed in the future. | ||
isVerbose = true; | ||
|
||
await _buildWebsite(); | ||
stdout.writeln('Build finished 🎉 '); | ||
} | ||
|
||
Future<void> _buildWebsite() async { | ||
try { | ||
final flavor = argResults![flavorOptionName] as String; | ||
await processRunner.runCommand( | ||
[ | ||
'fvm', | ||
'flutter', | ||
'build', | ||
'web', | ||
'--release', | ||
'--dart-define', | ||
'FLAVOR=$flavor', | ||
'--pwa-strategy', | ||
'none', | ||
], | ||
workingDirectory: repo.sharezoneWebsite.location, | ||
); | ||
} catch (e) { | ||
throw Exception('Failed to build website: $e'); | ||
} | ||
} | ||
} |
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