-
-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathconfig.dart
60 lines (48 loc) · 1.22 KB
/
config.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'dart:io';
import 'package:path/path.dart';
import 'package:yaml/yaml.dart';
import '../utils/map.dart';
import 'pubspec.dart';
class Config {
Config._({required this.pubspec});
final Pubspec pubspec;
}
Future<Config> loadPubspecConfig(File pubspecFile) async {
// ignore: avoid_print
print('FlutterGen Loading ... '
'${normalize(join(
basename(pubspecFile.parent.path),
basename(pubspecFile.path),
))}');
final content = await pubspecFile.readAsString().catchError((dynamic error) {
throw FileSystemException(
'Cannot open pubspec.yaml: ${pubspecFile.absolute}');
});
final userMap = loadYaml(content) as Map?;
final defaultMap = loadYaml(_defaultConfig) as Map?;
final mergedMap = mergeMap([defaultMap, userMap]);
final pubspec = Pubspec.fromJson(mergedMap);
return Config._(pubspec: pubspec);
}
const _defaultConfig = '''
name: $invalidStringValue
flutter_gen:
output: lib/gen/
line_length: 80
integrations:
flutter_svg: false
flare_flutter: false
rive: false
assets:
enabled: true
package_parameter_enabled: false
style: dot-delimiter
fonts:
enabled: true
colors:
enabled: true
inputs: []
flutter:
assets: []
fonts: []
''';