<commit_before>import * as fs from 'fs';
import * as ghpages from 'gh-pages';
import _ from 'lodash';
import logWith from 'log-with';
import mkdirp from 'mkdirp';
import * as path from 'path';

const logger = logWith(module);

class Representation {
  constructor(folder, fileName = 'me.json') {
    this.sources = [];
    this.fileName = fileName;
    this.folder = folder;
  }

  write(data) {
    const filePath = path.join(process.cwd(), this.folder, this.fileName);
    logger.debug('File created at', filePath);
    mkdirp.sync(path.dirname(filePath));
    fs.writeFileSync(filePath, JSON.stringify(data, null, 4));
    return this;
  }

  addSource(source) {
    this.sources.push(source);
    return this;
  }

  async build() {
    const sources = _.map(this.sources, async (source) => {
      try {
        return source.load();
      } catch (e) {
        return null;
      }
    });
    this.payload = _.compact(await Promise.all(sources));
    return this;
  }

  async generate() {
    await this.build();
    this.write(this.payload || {});
    return this;
  }

  async publish() {
    const promise = new Promise(
      (resolve, reject) => ghpages.publish(this.folder, (err) => {
        if (err) {
          reject(err);
          return;
        }
        resolve();
      }));
    await promise;
    return this;
  }
}

export default Representation;<commit_msg>pass credential for git push<commit_after>import * as fs from 'fs';
import * as ghpages from 'gh-pages';
import _ from 'lodash';
import logWith from 'log-with';
import mkdirp from 'mkdirp';
import * as path from 'path';

const logger = logWith(module);

class Representation {
  constructor(folder, config, fileName = 'me.json') {
    this.sources = [];
    this.fileName = fileName;
    this.folder = folder;
    this.config = config;
  }

  write(data) {
    const filePath = path.join(process.cwd(), this.folder, this.fileName);
    logger.debug('File created at', filePath);
    mkdirp.sync(path.dirname(filePath));
    fs.writeFileSync(filePath, JSON.stringify(data, null, 4));
    return this;
  }

  addSource(source) {
    this.sources.push(source);
    return this;
  }

  async build() {
    const sources = _.map(this.sources, async (source) => {
      try {
        return source.load();
      } catch (e) {
        return null;
      }
    });
    this.payload = _.compact(await Promise.all(sources));
    return this;
  }

  async generate() {
    await this.build();
    this.write(this.payload || {});
    return this;
  }

  async publish() {
    const promise = new Promise(
      (resolve, reject) => ghpages.publish(this.folder,
        this.config.publish,
        (err) => {
          if (err) {
            reject(err);
            return;
          }
          resolve();
        }));
    await promise;
    return this;
  }
}

export default Representation;
{'fraction_non_alphanumeric': 0.13991625959525472, 'fraction_numerical': 0.0006978367062107466, 'mean_word_length': 2.5614906832298137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4473628', 'n_tokens_mistral': 908, 'n_tokens_neox': 898, 'n_words': 223}