Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
leoafarias committed Feb 29, 2024
1 parent 1a6cfea commit 0cba4aa
Showing 4 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/src/services/base_service.dart
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import '../utils/context.dart';

abstract class ContextService {
final FVMContext? _context;

const ContextService(FVMContext? context) : _context = context;

/// Gets context, if no context is passed will get from scope
1 change: 0 additions & 1 deletion lib/src/services/releases_service/releases_client.dart
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@ String getReleasesUrl(String platform) {

class FlutterReleases {
static Releases? _cacheReleasesRes;

const FlutterReleases._();

/// Gets Flutter SDK Releases
23 changes: 14 additions & 9 deletions lib/src/utils/context.dart
Original file line number Diff line number Diff line change
@@ -38,12 +38,12 @@ class FVMContext {
/// Flag to determine if context is running in a test
final bool isTest;

/// App config
final AppConfig config;

/// Generators for dependencies
final Map<Type, dynamic>? generators;

/// App config
final AppConfig _config;

/// Generated values
final Map<Type, dynamic> _dependencies = {};

@@ -58,12 +58,9 @@ class FVMContext {

// Load config from file in config path

final projectConfig = ProjectConfig.loadFromPath(workingDirectory);
final envConfig = ConfigRepository.loadEnv();

final appConfig = ConfigRepository.loadFile()
.mergeConfig(envConfig)
.mergeConfig(projectConfig);
final appConfig = ConfigRepository.loadFile().mergeConfig(envConfig);

// Merge config from file with env config
final config = appConfig.merge(configOverrides);
@@ -94,10 +91,18 @@ class FVMContext {
FVMContext._({
required this.id,
required this.workingDirectory,
required this.config,
required AppConfig config,
this.generators = const {},
this.isTest = false,
});
}) : _config = config;

AppConfig get config {
// TODO: Need to optimize this
// For now optimizing for correctness
final projectConfig = ProjectService(this).findAncestor().config;

return _config.mergeConfig(projectConfig);
}

/// Environment variables
Map<String, String> get environment => Platform.environment;
5 changes: 2 additions & 3 deletions lib/src/workflows/resolve_dependencies.workflow.dart
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import 'package:mason_logger/mason_logger.dart';
import '../models/cache_flutter_version_model.dart';
import '../models/project_model.dart';
import '../services/logger_service.dart';
import '../utils/context.dart';
import '../utils/exceptions.dart';

Future<void> resolveDependenciesWorkflow(
@@ -18,9 +19,7 @@ Future<void> resolveDependenciesWorkflow(
return;
}

final runPubGetOnSdkChanges = project.config?.runPubGetOnSdkChanges ?? true;

if (!runPubGetOnSdkChanges) {
if (!ctx.runPubGetOnSdkChanges) {
logger
..info('Skipping "pub get" because of config setting.')
..spacer;

0 comments on commit 0cba4aa

Please sign in to comment.