<commit_before>/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
/* eslint no-console: "off" */
/* eslint global-require: "off" */
/* eslint no-param-reassign: ["error", { "props": false }] */
const phenome = require('../../phenome/lib/compiler-io/index');
const fs = require('fs');
const { transformSync } = require('@babel/core');

function transformRestSpread(buildPath) {
  const reactFiles = fs.readdirSync(`${buildPath}/react/components`).filter(f => f[0] !== '.' && f.indexOf('.d.ts') < 0);
  const vueFiles = fs.readdirSync(`${buildPath}/vue/components`).filter(f => f[0] !== '.' && f.indexOf('.d.ts') < 0);

  function transformFile(filePath) {
    const fileContent = fs.readFileSync(filePath, 'utf8');
    const { code } = transformSync(fileContent, {
      plugins: [
        ['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
      ],
    });
    fs.writeFileSync(filePath, code);
  }
  reactFiles.forEach((fileName) => {
    transformFile(`${buildPath}/react/components/${fileName}`);
  });
  vueFiles.forEach((fileName) => {
    transformFile(`${buildPath}/vue/components/${fileName}`);
  });
}

// Phenome
function build(cb) {
  const env = process.env.NODE_ENV || 'development';
  const buildPath = env === 'development' ? './build' : './packages';

  phenome({
    paths: ['./src/phenome/**/*.js', './src/phenome/**/*.jsx'],
    react: {
      out: `${buildPath}/react/`,
      typeScriptDefinitions: true,
      helpers: {
        el: 'auto',
        slots: 'auto',
        props: 'auto',
        children: 'auto',
        parent: 'auto',
        dispatchEvent: 'auto',
        watch: 'auto',
        forceUpdate: 'auto',
      },
    },
    vue: {
      out: `${buildPath}/vue/`,
      helpers: {
        el: 'auto',
        slots: 'auto',
        props: 'auto',
        children: 'auto',
        parent: 'auto',
        refs: 'auto',
        dispatchEvent: 'auto',
        state: 'auto',
        setState: 'auto',
        forceUpdate: 'auto',
      },
    },
  }).then(() => {
    transformRestSpread(buildPath);
    if (cb) cb();
  }).catch((err) => {
    console.log(err);
    if (cb) cb();
  });
}

module.exports = build;
<commit_msg>Fix Phenome lib path<commit_after>/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
/* eslint no-console: "off" */
/* eslint global-require: "off" */
/* eslint no-param-reassign: ["error", { "props": false }] */
const phenome = require('phenome');
const fs = require('fs');
const { transformSync } = require('@babel/core');

function transformRestSpread(buildPath) {
  const reactFiles = fs.readdirSync(`${buildPath}/react/components`).filter(f => f[0] !== '.' && f.indexOf('.d.ts') < 0);
  const vueFiles = fs.readdirSync(`${buildPath}/vue/components`).filter(f => f[0] !== '.' && f.indexOf('.d.ts') < 0);

  function transformFile(filePath) {
    const fileContent = fs.readFileSync(filePath, 'utf8');
    const { code } = transformSync(fileContent, {
      plugins: [
        ['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
      ],
    });
    fs.writeFileSync(filePath, code);
  }
  reactFiles.forEach((fileName) => {
    transformFile(`${buildPath}/react/components/${fileName}`);
  });
  vueFiles.forEach((fileName) => {
    transformFile(`${buildPath}/vue/components/${fileName}`);
  });
}

// Phenome
function build(cb) {
  const env = process.env.NODE_ENV || 'development';
  const buildPath = env === 'development' ? './build' : './packages';

  phenome({
    paths: ['./src/phenome/**/*.js', './src/phenome/**/*.jsx'],
    react: {
      out: `${buildPath}/react/`,
      typeScriptDefinitions: true,
      helpers: {
        el: 'auto',
        slots: 'auto',
        props: 'auto',
        children: 'auto',
        parent: 'auto',
        dispatchEvent: 'auto',
        watch: 'auto',
        forceUpdate: 'auto',
      },
    },
    vue: {
      out: `${buildPath}/vue/`,
      helpers: {
        el: 'auto',
        slots: 'auto',
        props: 'auto',
        children: 'auto',
        parent: 'auto',
        refs: 'auto',
        dispatchEvent: 'auto',
        state: 'auto',
        setState: 'auto',
        forceUpdate: 'auto',
      },
    },
  }).then(() => {
    transformRestSpread(buildPath);
    if (cb) cb();
  }).catch((err) => {
    console.log(err);
    if (cb) cb();
  });
}

module.exports = build;

{'fraction_non_alphanumeric': 0.2071767095463778, 'fraction_numerical': 0.0022568269013766643, 'mean_word_length': 2.781569965870307, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 15, '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': '2610019', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1455, 'n_words': 275}