Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and improvements #676

Merged
merged 23 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Unreleased

* Added: `fvm use [version] --force` now skips install confirmation prompt by @mrgnhnt96
* Added: Added flag to skip pub get on `install` and `use`, `--skip-pub-get` by @mrgnhnt96
* Improvement: CI Flag now skips check update by @leoafarias
* Fix: Improve App Config and Project Config overrides by @leoafarias
* Fix: Incorrect check version update logic by @leoafarias
* Improvemnet: Better exception handling during mirror creation by @leoafarias

## 3.0.12

* Adds skipping version mismatch handling when using force or running with a custom fvm version. [#653](https://github.com/leoafarias/fvm/issues/653)
Expand Down
2 changes: 1 addition & 1 deletion bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:fvm/src/utils/context.dart';
import 'package:scope/scope.dart';

Future<void> main(List<String> args) async {
final scope = Scope()..value(contextKey, FVMContext.create());
final scope = Scope()..value(contextKey, FVMContext.main);

await _flushThenExit(
await scope.run(() => FvmCommandRunner().run((args))),
Expand Down
5 changes: 5 additions & 0 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ module.exports = withNextra({
destination: "/documentation/getting-started/faq",
permanent: true,
},
{
source: "/docs/guides/global_version",
destination: "/documentation/guides/global-configuration",
permanent: true,
},
];
},
});
49 changes: 16 additions & 33 deletions lib/src/commands/config_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,62 +29,45 @@ 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;

if (wasParsed(ConfigKeys.flutterUrl.paramKey)) {
final flutterRepo = stringArg(ConfigKeys.flutterUrl.paramKey);
logger.info('Setting flutter repo to: ${yellow.wrap(flutterRepo)}');
current.flutterUrl = flutterRepo;
void updateConfigKey<T>(ConfigKeys key, T value) {
if (wasParsed(key.paramKey)) {
final updatedMap = AppConfig.fromMap({key.name: value});
logger.info(
'Setting ${key.paramKey} to: ${yellow.wrap(value.toString())}',
);

shouldSave = true;
}

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;
}

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;
logger.info(updatedMap.toString());
updatedConfig = updatedConfig.merge(updatedMap);
}
}

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;
for (var key in ConfigKeys.values) {
updateConfigKey(key, argResults![key.paramKey]);
}

// Save
if (shouldSave) {
if (updatedConfig != currentConfig) {
logger.info('');
final updateProgress = logger.progress('Saving settings');
// Update settings
try {
ConfigRepository.save(current);
ConfigRepository.save(updatedConfig);
} catch (error) {
updateProgress.fail('Failed to save settings');
rethrow;
}
updateProgress.complete('Settings saved.');
} else {
// How do I scape a file.path?

logger
..info('FVM Configuration:')
..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
4 changes: 2 additions & 2 deletions lib/src/commands/install_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class InstallCommand extends BaseCommand {
..addFlag(
'skip-pub-get',
help: 'Skip resolving dependencies after switching Flutter SDK',
negatable: false,
defaultsTo: false,
negatable: false,
);
}

Expand Down Expand Up @@ -65,7 +65,7 @@ class InstallCommand extends BaseCommand {
project: project,
force: true,
skipSetup: !setup,
resolveDependencies: !skipPubGet,
runPubGetOnSdkChange: !skipPubGet,
);

return ExitCode.success.code;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/commands/list_command.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:dart_console/dart_console.dart';
import '../services/global_version_service.dart';
import '../services/releases_service/models/release.model.dart';
import '../services/releases_service/releases_client.dart';
import '../utils/helpers.dart';
import 'package:mason_logger/mason_logger.dart';

import '../services/cache_service.dart';
import '../services/global_version_service.dart';
import '../services/logger_service.dart';
import '../services/releases_service/models/release.model.dart';
import '../services/releases_service/releases_client.dart';
import '../utils/context.dart';
import '../utils/helpers.dart';
import 'base_command.dart';

/// List installed SDK Versions
Expand Down Expand Up @@ -71,7 +71,7 @@ class ListCommand extends BaseCommand {
String flutterSdkVersion = version.flutterSdkVersion ?? '';

String getVersionOutput() {
if (version.notSetup) {
if (version.isNotSetup) {
return flutterSdkVersion = '${yellow.wrap('Need setup')}';
}
if (latestRelease != null && version.isChannel) {
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
4 changes: 2 additions & 2 deletions lib/src/commands/use_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class UseCommand extends BaseCommand {
..addFlag(
'skip-pub-get',
help: 'Skip resolving dependencies after switching Flutter SDK',
negatable: false,
defaultsTo: false,
negatable: false,
)
..addFlag(
'skip-setup',
Expand Down Expand Up @@ -135,8 +135,8 @@ class UseCommand extends BaseCommand {
project: project,
force: forceOption,
skipSetup: skipSetup,
runPubGetOnSdkChange: !skipPubGet,
flavor: flavorOption,
resolveDependencies: !skipPubGet,
);

return ExitCode.success.code;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/models/cache_flutter_version_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class CacheFlutterVersion extends FlutterVersion {
}

/// Verifies that cacheVersion has been setup
bool get notSetup => flutterSdkVersion == null;
bool get isNotSetup => flutterSdkVersion == null;

/// Returns bool if version is setup
bool get isSetup => flutterSdkVersion != null;

Future<ProcessResult> run(
String command, {
Expand Down
Loading
Loading