const path = require('path');

let index = 0;

// 需要混淆的文件列表
const obfuscatorFiles = [
  'src/api/upms/api-menu.js',
  'src/api/app-management/api-home.js',
  'src/api/api-login.js',
  'src/api/upms/api-user.js'
].map((item) => {
  index++;
  let obfuscatorIndex = 'obfuscator' + index;
  let oldFilePath = item;
  let newFilePath = item.replace(/src/, 'obfuscator/src');
  let resourceRegExp = item.replace(/\//g, '\\\\');
  let newResource = './';
  let num = item.split('/').length - 1;
  for (let i = 0; i < num; i++) {
    newResource += '../';
  }
  newResource += 'obfuscator/' + item;
  return {
    // 混淆编号
    obfuscatorIndex: obfuscatorIndex,
    // 源文件
    oldFilePath: path.resolve(__dirname, oldFilePath),
    // 新文件
    newFilePath: path.resolve(__dirname, newFilePath),
    // 匹配源文件的正则表达式
    resourceRegExp: resourceRegExp,
    // 替换源文件的新文件相对路径
    newResource: newResource
  };
});

module.exports = function () {
  return obfuscatorFiles;
};
