text: 'use strict';
  
  const firebase = require('firebase-tools');
  const fs = require('fs-extra');
  
  class Firebase {
    static async save(config, revision) {
      return firebase.deploy({
        'only': 'hosting',
        public: config.get('project.localDir'),
        project: config.get('firebase.project'),
        site: config.get('firebase.site'),
        message: revision.toString()
      });
    }
  
    static async createManifestFile() {
      const manifestFilePath = 'firebase.json';
  
      if (await fs.pathExists(manifestFilePath)) {
        return { created: false };
      }
  
      try {
        const manifestFileContent = { hosting: {} };
        await fs.outputJSON(manifestFilePath, manifestFileContent);
      } catch (error) {
        throw new Error('Could not write manifest file');
      }
  
      return { created: true };
    }
  
    static async createCredentialsFile(config) {
      try {
        JSON.parse(config.get('firebase.credentials.content'));
      } catch (error) {
        throw new Error('Credentials JSON input is not valid');
      }
  
      try {
        await fs.writeFile(config.get('firebase.credentials.path'), config.get('firebase.credentials.content'));
      } catch (error) {
        throw new Error('Could not write credentials file');
      }
  
      return { created: true };
    }
  }
  
  module.exports = Firebase;
  