listPlugins method

Future<List<AutomationPluginInfo>> listPlugins()

Returns plugins installed in this workspace.

Implementation

Future<List<AutomationPluginInfo>> listPlugins() async {
  final result = await runPulumiCommand(<String>['plugin', 'ls', '--json']);
  final decoded = jsonDecode(result.stdout);
  if (decoded is! List) {
    throw FormatException(
      'Expected array JSON from `pulumi plugin ls --json`',
    );
  }

  return decoded
      .whereType<Map>()
      .map((entry) {
        final mapped = entry.map((key, value) => MapEntry('$key', value));
        return AutomationPluginInfo.fromJson(mapped);
      })
      .toList(growable: false);
}