<commit_before>'use strict';

const $ = require('cheerio');
const fs = require('fs');
const path = require('path');
const sendfile = require('koa-sendfile');
const _ = require('lodash');
/**
 * A set of functions called "actions" for `Admin`
 */

module.exports = {

  index: function *() {

    // Read the default `index.html` file from the admin panel build
    const html = fs.readFileSync(path.resolve(__dirname, '..', 'public', 'build', 'index.html'));

    // Convert the stream to a string
    const htmlString = html.toString();

    // Use `cheerio` to parse the HTML string
    const parsedHTML = $.load(htmlString);

    // // Some plugins are ignored
    // const ignoredPlugins = ['admin', 'user'];
    //
    // // Inject `js` files from plugins builds in the main admin panel
    // _.forEach(strapi.api, (value, pluginName) => {
    //   if (!_.includes(ignoredPlugins, pluginName)) {
    //     // Main plugin `js` file
    //     const pluginMainScript = $('<script>').attr('src', '/plugins/' + pluginName + '/main.js');
    //     parsedHTML('body').append(pluginMainScript);
    //
    //     // Vendors plugin `js` file
    //     const pluginVendorScript = $('<script>').attr('src', '/plugins/' + pluginName + '/vendor.js');
    //     parsedHTML('body').append(pluginVendorScript);
    //   }
    // });

    // Finally, send the HTML file with injected scripts
    this.body = parsedHTML.html();
  },

  file: function *() {
    yield sendfile(this, path.resolve(__dirname, '..', 'public', 'build', this.params.file));
    if (!this.status) this.throw(404);
  }
};<commit_msg>Fix plugins routes in admin file generator<commit_after>'use strict';

const $ = require('cheerio');
const fs = require('fs');
const path = require('path');
const sendfile = require('koa-sendfile');
const _ = require('lodash');
/**
 * A set of functions called "actions" for `Admin`
 */

module.exports = {

  index: function *() {

    // Read the default `index.html` file from the admin panel build
    const html = fs.readFileSync(path.resolve(__dirname, '..', 'public', 'build', 'index.html'));

    // Convert the stream to a string
    const htmlString = html.toString();

    // Use `cheerio` to parse the HTML string
    const parsedHTML = $.load(htmlString);

    // Some plugins are ignored
    const ignoredPlugins = ['admin', 'user'];

    console.log('strapi.plugins', strapi.plugins)

    // Inject `js` files from plugins builds in the main admin panel
    _.forEach(strapi.plugins, (value, pluginName) => {
      if (!_.includes(ignoredPlugins, pluginName)) {
        // Main plugin `js` file
        const pluginMainScript = $('<script>').attr('src', '/' + pluginName + '/main.js');
        parsedHTML('body').append(pluginMainScript);

        // Vendors plugin `js` file
        const pluginVendorScript = $('<script>').attr('src', '/' + pluginName + '/vendor.js');
        parsedHTML('body').append(pluginVendorScript);
      }
    });

    // Finally, send the HTML file with injected scripts
    this.body = parsedHTML.html();
  },

  file: function *() {
    yield sendfile(this, path.resolve(__dirname, '..', 'public', 'build', this.params.file));
    if (!this.status) this.throw(404);
  }
};
{'fraction_non_alphanumeric': 0.17272444858651756, 'fraction_numerical': 0.001863932898415657, 'mean_word_length': 3.0350877192982457, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5354516', 'n_tokens_mistral': 971, 'n_tokens_neox': 949, 'n_words': 264}