# frozen_string_literal: true

require_relative 'base'

module PluginConfig
  module Operations
    class List < Base
      def call
        data = read_json(settings_path)

        plugins = if data && data['enabledPlugins']
                    data['enabledPlugins'].keys.sort
                  else
                    []
                  end

        {
          status: 'ok',
          project: project,
          enabled_plugins: plugins,
          count: plugins.length
        }
      end
    end
  end
end
