PublishToolsConfig.fromYamlFile constructor
PublishToolsConfig.fromYamlFile( - String filePath
)
Implementation
factory PublishToolsConfig.fromYamlFile(String filePath) {
final pubSpec = Pubspec.parse(joinFile(
Directory.current,
['pubspec.yaml'],
).readAsStringSync());
final YamlMap config = loadYaml(File(filePath).readAsStringSync());
final checkKeys = <String>[
'commit',
];
if (!config.mapContainsKeys(checkKeys)) {
throw Exception('The config file is missing a top level key.');
}
return PublishToolsConfig(
pubSpec: pubSpec,
github: config.containsKey('github')
? GithubConfig.fromYamlMap(config['github'], pubSpec)
: GithubConfig.fromGitFolder(),
homebrew: HomebrewConfig.fromYamlMap(config['homebrew'] ?? YamlMap()),
optionalMetaFilePath: config['meta'],
templates: config.containsKey('templates')
? (config['templates'] as List)
.map((template) => MarkdownTemplate.fromYamlMap(template))
.toList()
: [
YamlMap.wrap({'name': 'README.md', 'type': 'overwrite'}),
YamlMap.wrap({'name': 'CHANGELOG.md', 'type': 'prepend'}),
]
.map((template) => MarkdownTemplate.fromYamlMap(template))
.toList(),
commit: config['commit'],
optionalChangeList: config['changes'],
);
}