Skip to content

Commit

Permalink
Removed flavor command
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Sep 26, 2023
1 parent 143a369 commit b28716f
Show file tree
Hide file tree
Showing 22 changed files with 163 additions and 247 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

- Implemented .gitignore notice to setup `fvm`
- Configure vscode automatically
- Check .gitignore for cached version
- Cache clean up, and corrective action in case of corrupted cache or upgraded SDK
- Flutter repo git reference for much faster clone of new versions.
- Project version constraint check on pubspec.yaml, before using version.
- Removed --skip-setup on `use` command. If you need to install without setting up, you should use `install`. You can force SDK setup on install by using -s or --setup
- Better `fvm doctor` command. Now provides much better output and information about the project and environment.
- Per project config global overrides. You can now override FVM settings on a per project basis
- Removed "flavor" command in favor for `fvm use {flavor}`
- Removed "destroy" command in favor of `fvm remove --all`

### Breaking changes

- FVM Config - FVM config now will be saved as fvm.yml at the root of the project. This will allow for better project configuration and versioning, `.fvm/fvm_config.json` will still be generated to be used by FVM, but it can be added to `.gitignore`. It will be generated when runing a `fvm install` or `fvm use` command.

## 2.4.1 - 2022-07-06
- Filter out Mac releases based on architecture.

Expand Down
38 changes: 0 additions & 38 deletions lib/src/commands/destroy_command.dart

This file was deleted.

91 changes: 0 additions & 91 deletions lib/src/commands/flavor_command.dart

This file was deleted.

4 changes: 1 addition & 3 deletions lib/src/commands/install_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ class InstallCommand extends BaseCommand {
);

if (setup) {
await setupFlutterWorkflow(
version: cacheVersion,
);
await setupFlutterWorkflow(cacheVersion);
}

return ExitCode.success.code;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/list_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ListCommand extends BaseCommand {
..info('Cache directory: ${cyan.wrap(ctx.versionsCachePath)}')
..spacer;

final releases = await FlutterReleasesClient.get();
final releases = await FlutterReleases.get();
final globalVersion = GlobalVersionService.fromContext.getGlobal();
final table = Table()
..insertColumn(header: 'SDK', alignment: TextAlignment.left)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/releases_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ReleasesCommand extends BaseCommand {

logger.detail('Filtering by channel: $channelName');

final releases = await FlutterReleasesClient.get();
final releases = await FlutterReleases.get();

final versions = releases.releases.reversed;

Expand Down
33 changes: 32 additions & 1 deletion lib/src/commands/remove_command.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'dart:io';

import 'package:fvm/constants.dart';
import 'package:fvm/src/utils/context.dart';
import 'package:io/io.dart';

import '../models/flutter_version_model.dart';
Expand All @@ -8,7 +12,14 @@ import 'base_command.dart';

/// Removes Flutter SDK
class RemoveCommand extends BaseCommand {
RemoveCommand();
RemoveCommand() {
argParser.addFlag(
'all',
help: 'Removes all versions',
abbr: 'a',
negatable: false,
);
}

@override
final name = 'remove';
Expand All @@ -23,6 +34,26 @@ class RemoveCommand extends BaseCommand {
@override
Future<int> run() async {
final all = boolArg('all');

if (all) {
final confirmRemoval = logger.confirm(
'Are you sure you want to remove all versions in your $kPackageName cache ?',
defaultValue: false,
);
if (confirmRemoval) {
final versionsCache = Directory(ctx.versionsCachePath);
if (versionsCache.existsSync()) {
versionsCache.deleteSync(recursive: true);

logger.success(
'$kPackageName Directory ${versionsCache.path} has been deleted',
);
}
}
return ExitCode.success.code;
}

String? version;

if (argResults!.rest.isEmpty) {
Expand Down
47 changes: 28 additions & 19 deletions lib/src/commands/use_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:fvm/fvm.dart';
import 'package:fvm/src/services/releases_service/releases_client.dart';
import 'package:fvm/src/utils/helpers.dart';
import 'package:fvm/src/workflows/ensure_cache.workflow.dart';
import 'package:fvm/src/workflows/setup_flutter_workflow.dart';
import 'package:io/io.dart';

import '../services/logger_service.dart';
Expand Down Expand Up @@ -48,6 +47,12 @@ class UseCommand extends BaseCommand {
'skip-setup',
help: 'Skips Flutter setup after install',
negatable: false,
)
..addFlag(
'unprivileged',
abbr: 'u',
help: 'Runs use workflow without the need for elevated privileges',
negatable: false,
);
}
@override
Expand All @@ -56,6 +61,7 @@ class UseCommand extends BaseCommand {
final pinOption = boolArg('pin');
final flavorOption = stringArg('flavor');
final skipSetup = boolArg('skip-setup');
final unprivileged = boolArg('unprivileged');

String? version;

Expand All @@ -73,28 +79,18 @@ class UseCommand extends BaseCommand {
version ??= argResults!.rest[0];

// Get valid flutter version. Force version if is to be pinned.

if (pinOption) {
if (!isFlutterChannel(version)) {
throw UsageException(
'Cannot pin a version that is not a channel.',
usage,
);
}

/// Cannot pin master channel
if (version == 'master') {
if (!isFlutterChannel(version) || version == 'master') {
throw UsageException(
'Cannot pin a version from "master" channel.',
'Cannot pin a version that is not in dev, beta or stable channels.',
usage,
);
}

/// Pin release to channel
final channel = FlutterChannel.fromName(version);

final release = await FlutterReleasesClient.getLatestReleaseOfChannel(
FlutterChannel.fromName(version),
);
final release = await FlutterReleases.getLatestReleaseOfChannel(channel);

logger.info(
'Pinning version ${release.version} from "$version" release channel...',
Expand All @@ -103,20 +99,33 @@ class UseCommand extends BaseCommand {
version = release.version;
}

final cacheVersion = await ensureCacheWorkflow(version);
// Gets flavor version
final flavorVersion = project.flavors[version];

if (!skipSetup && cacheVersion.notSetup) {
await setupFlutterWorkflow(
version: cacheVersion,
if (flavorVersion != null) {
if (flavorOption != null) {
throw UsageException(
'Cannot use the --flavor when using fvm use {flavor}',
usage,
);
}

logger.info(
'Using Flutter SDK from "$flavorOption" which is "$flavorVersion"',
);
version = flavorVersion;
}

final cacheVersion = await ensureCacheWorkflow(version);

/// Run use workflow
await useVersionWorkflow(
version: cacheVersion,
project: project,
force: forceOption,
flavor: flavorOption,
skipSetup: skipSetup,
unprivileged: unprivileged,
);

return ExitCode.success.code;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/project_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Project {
}

/// Retrieves the flavors defined in the project's `fvm.yaml` file.
Map<String, dynamic> get flavors => config?.flavors ?? {};
Map<String, String> get flavors => config?.flavors ?? {};

/// Retrieves the dart tool package config.
///
Expand Down
Loading

0 comments on commit b28716f

Please sign in to comment.