Skip to content

Commit

Permalink
Added dart mappable
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Feb 29, 2024
1 parent b12deb2 commit 0ee3b2d
Show file tree
Hide file tree
Showing 17 changed files with 1,296 additions and 381 deletions.
2 changes: 1 addition & 1 deletion .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ runs:
shell: bash

- name: Build Version
run: dart run grinder build-version
run: dart run build_runner build --delete-conflicting-outputs
shell: bash
36 changes: 22 additions & 14 deletions lib/src/commands/config_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,56 @@ class ConfigCommand extends BaseCommand {
@override
Future<int> run() async {
// Flag if settings should be saved
var shouldSave = false;

var current = ConfigRepository.loadFile();
final currentConfig = ConfigRepository.loadAppConfig();
var updatedConfig = currentConfig;

// TODO: Consolidate redundant code

if (wasParsed(ConfigKeys.flutterUrl.paramKey)) {
final flutterRepo = stringArg(ConfigKeys.flutterUrl.paramKey);
logger.info('Setting flutter repo to: ${yellow.wrap(flutterRepo)}');
current.flutterUrl = flutterRepo;

shouldSave = true;
// current.flutterUrl = flutterRepo;
updatedConfig = currentConfig.copyWith(flutterUrl: flutterRepo);
}

if (wasParsed(ConfigKeys.gitCachePath.paramKey)) {
final gitCachePath = stringArg(ConfigKeys.gitCachePath.paramKey);
logger.info('Setting git cache path to: ${yellow.wrap(gitCachePath)}');
current.gitCachePath = gitCachePath;
shouldSave = true;
// currentConfig.gitCachePath = gitCachePath;
updatedConfig = currentConfig.copyWith(gitCachePath: gitCachePath);
}

if (wasParsed(ConfigKeys.useGitCache.paramKey)) {
final gitCache = boolArg(ConfigKeys.useGitCache.paramKey);
logger.info(
'Setting use git cache to: ${yellow.wrap(gitCache.toString())}',
);
current.useGitCache = gitCache;
shouldSave = true;
updatedConfig = currentConfig.copyWith(useGitCache: gitCache);
}

if (wasParsed(ConfigKeys.cachePath.paramKey)) {
final cachePath = stringArg(ConfigKeys.cachePath.paramKey);
logger.info('Setting fvm path to: ${yellow.wrap(cachePath)}');
current.cachePath = cachePath;
shouldSave = true;
updatedConfig = currentConfig.copyWith(cachePath: cachePath);
}

if (wasParsed(ConfigKeys.priviledgedAccess.paramKey)) {
final priviledgedAccess = boolArg(ConfigKeys.priviledgedAccess.paramKey);
logger.info(
'Setting priviledged access to: ${yellow.wrap(priviledgedAccess.toString())}',
);
updatedConfig =
currentConfig.copyWith(priviledgedAccess: priviledgedAccess);
}

// Save
if (shouldSave) {
if (updatedConfig != currentConfig) {
logger.info('');
final updateProgress = logger.progress('Saving settings');
// Update settings
try {
ConfigRepository.save(current);
ConfigRepository.save(currentConfig);
} catch (error) {
updateProgress.fail('Failed to save settings');
rethrow;
Expand All @@ -84,7 +92,7 @@ class ConfigCommand extends BaseCommand {
..info('Located at ${ctx.configPath}')
..info('');

final options = current.toMap();
final options = currentConfig.toMap();

if (options.keys.isEmpty) {
logger.info('No settings have been configured.');
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/update_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:pub_updater/pub_updater.dart';

import '../services/logger_service.dart';
import '../utils/constants.dart';
import '../version.g.dart';
import '../version.dart';

class UpdateCommand extends Command<int> {
static const String commandName = 'update';
Expand Down
Loading

0 comments on commit 0ee3b2d

Please sign in to comment.