Skip to content

Commit

Permalink
feat: Added a flavor & suffix for the versionbump command
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Feb 4, 2024
1 parent 0eb0b2c commit 6e170cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.10.14

# Feat:
- Add the option to add a `flavor` to the versionbump command
- Add the option to add a `suffix`to the versionbump command

# 0.10.13

# Feat:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class FlutterBuildPlugin extends ImpaktfullCliPlugin {

/// Bumps the version of the app in release_config.yaml
/// Commits the change & returns the build_nr of the new version
Future<int> versionBump() async {
Future<int> versionBump({
String? flavor,
String? suffix,
}) async {
final isGitProject = ImpaktfullCliEnvironment.isInstalled(CliTool.git);
if (isGitProject) {
final isGitClean = await GitUtil.isGitClean(processRunner);
Expand All @@ -32,15 +35,22 @@ class FlutterBuildPlugin extends ImpaktfullCliPlugin {
final file = File('release_config.json');
var newConfigData = <String, dynamic>{};
var buildNr = 0;
var buildNrKey = 'build_nr';
if (flavor != null) {
buildNrKey += '_$flavor';
}
if (suffix != null) {
buildNrKey += '_$suffix';
}
if (file.existsSync()) {
final content = file.readAsStringSync();
final orignalConfigData = jsonDecode(content) as Map<String, dynamic>;
newConfigData = orignalConfigData;
buildNr = orignalConfigData['build_nr'] as int;
buildNr = orignalConfigData[buildNrKey] as int;
}
buildNr++;
ImpaktfullCliLogger.debug('New build_nr: $buildNr');
newConfigData['build_nr'] = buildNr;
ImpaktfullCliLogger.debug('New build_nr: $buildNr (for key: $buildNrKey)');
newConfigData[buildNrKey] = buildNr;
if (!file.existsSync()) {
file.createSync(recursive: true);
}
Expand All @@ -55,7 +65,7 @@ class FlutterBuildPlugin extends ImpaktfullCliPlugin {
'git',
'commit',
'-m',
'Bump build_nr to $buildNr',
'Bump build_nr to $buildNr (for key: $buildNrKey)',
]);
}
return buildNr;
Expand Down

0 comments on commit 6e170cb

Please sign in to comment.