addInitialAssetEntries method
Registers the default client's env file as a Flutter asset so the app
can load it when no CLIENT_ENV is passed.
Implementation
Future<void> addInitialAssetEntries() async {
final file = File(p.join(projectDir, 'pubspec.yaml'));
if (!file.existsSync()) return;
try {
final content = await file.readAsString();
final editor = YamlEditor(content);
final yaml = loadYaml(content);
final flutter = yaml['flutter'] as YamlMap?;
final currentAssets = (flutter?['assets'] as YamlList?)?.toList() ?? [];
if (!currentAssets.contains(defaultClientEnvAsset)) {
currentAssets.add(defaultClientEnvAsset);
editor.update(['flutter', 'assets'], currentAssets);
await file.writeAsString(editor.toString());
Logger.success('Added $defaultClientEnvAsset to pubspec assets.');
}
} catch (e) {
Logger.warning('Failed to add initial asset entries to pubspec.yaml: $e');
}
}