Skip to content

Commit

Permalink
Merge pull request #658 from leoafarias/fix/650
Browse files Browse the repository at this point in the history
Update dependencies and fix deprecation warnings
  • Loading branch information
leoafarias authored Feb 26, 2024
2 parents 36e40b6 + 62e59d5 commit bc02bba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/src/models/config_model.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Use just for reference, should not change

import 'dart:convert';
import 'dart:io';

import 'package:args/args.dart';
import 'package:jsonc/jsonc.dart';

import '../utils/change_case.dart';
import '../utils/constants.dart';
Expand Down Expand Up @@ -204,7 +204,7 @@ class AppConfig extends Config {
}

factory AppConfig.fromJson(String source) {
return AppConfig.fromMap(json.decode(source) as Map<String, dynamic>);
return AppConfig.fromMap(jsonc.decode(source) as Map<String, dynamic>);
}

static AppConfig? loadFromPath(String path) {
Expand Down Expand Up @@ -321,7 +321,7 @@ class ProjectConfig extends Config {

/// Returns ConfigDto from a json string
factory ProjectConfig.fromJson(String source) =>
ProjectConfig.fromMap(json.decode(source) as Map<String, dynamic>);
ProjectConfig.fromMap(jsonc.decode(source) as Map<String, dynamic>);

static ProjectConfig? loadFromPath(String path) {
final configFile = File(path);
Expand Down
13 changes: 7 additions & 6 deletions lib/src/utils/deprecation_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,32 @@ import 'context.dart';
void deprecationWorkflow() {
_warnDeprecatedEnvVars();
final fvmDir = ctx.fvmDir;
final settingsFile = File(join(fvmDir, '.settings'));
final legacySettingsFile = File(join(fvmDir, '.settings'));

if (!settingsFile.existsSync()) {
if (!legacySettingsFile.existsSync()) {
return;
}

final payload = settingsFile.readAsStringSync();
final payload = legacySettingsFile.readAsStringSync();
try {
final settings = jsonDecode(payload);
final settingsCachePath = settings['cachePath'] as String?;
if (settingsCachePath != null && settingsCachePath != fvmDir) {
var appConfig = ConfigRepository.loadFile();
appConfig = appConfig.copyWith(cachePath: fvmDir);
ConfigRepository.save(appConfig);
settingsFile.deleteSync(recursive: true);
legacySettingsFile.deleteSync(recursive: true);
logger.success(
'We have moved the settings file ${settingsFile.path}'
'We have moved the settings file ${legacySettingsFile.path}'
'Your settings have been migrated to $kAppConfigFile'
'Your cachePath is now $settingsCachePath. FVM will exit now. Please run the command again.',
);
// Exit to prevent execution with wrong cache path
exit(ExitCode.success.code);
}
} catch (_) {
logger.warn('Could not parse legact settings file');
logger.warn('Could not parse legacy settings file');
legacySettingsFile.deleteSync(recursive: true);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tool/homebrew.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:convert';
import 'dart:io';

import 'package:crypto/crypto.dart';
import 'package:fvm/src/utils/http.dart';
import 'package:grinder/grinder.dart';
import 'package:http/http.dart' as http;
import 'package:jsonc/jsonc.dart';
import 'package:path/path.dart' as path;

import 'grind.dart';
Expand Down Expand Up @@ -33,7 +33,7 @@ Future<void> _homebrewFormula() async {

final response = await fetch(url.toString(), headers: headers);

final Map<String, dynamic> release = json.decode(response);
final Map<String, dynamic> release = jsonc.decode(response);
final List assets = release['assets'];
final Map<String, dynamic> assetData = {};

Expand Down

0 comments on commit bc02bba

Please sign in to comment.