Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Bassiuz/fvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas de Vaan committed Feb 27, 2024
2 parents bc44def + 37937ed commit c121121
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 3.0.12

* Adds skipping version mismatch handling when using force or running with a custom fvm version.
* Adds skipping version mismatch handling when using force or running with a custom fvm version. [#653](https://github.com/leoafarias/fvm/issues/653)
* Fixes parsing error of vscode settings when there are commas [#656](https://github.com/leoafarias/fvm/issues/656)

## 3.0.11

Expand Down
4 changes: 2 additions & 2 deletions lib/src/commands/doctor_command.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:convert';
import 'dart:io';

import 'package:dart_console/dart_console.dart';
import 'package:io/io.dart';
import 'package:jsonc/jsonc.dart';
import 'package:path/path.dart';

import '../models/config_model.dart';
Expand Down Expand Up @@ -76,7 +76,7 @@ class DoctorCommand extends BaseCommand {
if (vscodeDir.existsSync()) {
if (settingsFile.existsSync()) {
try {
final settings = jsonDecode(settingsFile.readAsStringSync());
final settings = jsonc.decode(settingsFile.readAsStringSync());

final relativeSymlinkPath = relative(
project.localVersionSymlinkPath,
Expand Down
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 c121121

Please sign in to comment.