loadAssetConfiguration method
Loads the complete asset configuration from morpheme.yaml and command arguments.
Parameters:
morphemeYamlPath: Path to the morpheme.yaml fileflavor: Optional flavor name for environment-specific configuration
Returns an AssetConfig instance with all configuration settings.
Throws ConfigurationException if required configuration is missing or invalid.
Implementation
AssetConfig loadAssetConfiguration({
String? morphemeYamlPath,
String? flavor,
}) {
// Validate and load morpheme.yaml
final morphemeYaml = _loadMorphemeYaml(morphemeYamlPath);
// Extract project name
final projectName = morphemeYaml.projectName;
if (projectName.isEmpty) {
throw ConfigurationException(
'Project name not found in morpheme.yaml',
suggestions: [
'Add "project_name: your_project_name" to morpheme.yaml',
'Ensure morpheme.yaml is properly formatted',
],
);
}
// Extract assets configuration
final assetsConfig = morphemeYaml['assets'];
if (assetsConfig == null) {
throw ConfigurationException(
'Assets configuration not found in morpheme.yaml',
suggestions: [
'Add an "assets:" section to morpheme.yaml',
'Run "morpheme init" to generate a basic configuration',
],
);
}
// Create asset configuration
return AssetConfig.fromMorphemeConfig(
projectName: projectName,
assetsConfig: assetsConfig,
flavor: flavor,
);
}