<commit_before>// Imports
const { readFileSync, readdirSync } = require('fs')
const { resolve } = require('path')
const { IS_DEBUG } = require('../../src/util/globals')

// pseudo code to mock api-gen
function generateAPI (comp, locale) {
  const api = {}

  // defaults if file doesn't exist
  let compMap = {
    props: [{ name: 'empty', type: '', default: '', source: '' }],
    mixins: ['empty'],
    slots: [{ name: 'empty', props: '' }],
    events: [{ name: 'empty', value: '' }],
    functions: [{ name: 'empty', signature: '' }],
    sass: [{ name: 'empty', default: '' }],
  }
  let compLocale = {
    props: { empty: '' },
    slots: { empty: '' },
    events: { empty: '' },
    functions: { empty: '' },
    sass: { empty: '' },
  }

  try {
    // make sure we're getting latest version of file
    delete require.cache[resolve(`build/api-gen/maps/${comp}.js`)]
    const mapFile = require(`./maps/${comp}`)[comp]
    compMap = mapFile
  } catch (e) {
    IS_DEBUG && console.log(`map: ${comp} not found`)
  }
  // fs is not useable when accessing via component
  // will need to find an alternative for the
  // merging of lang, possibly change to js
  const localePath = resolve(__dirname, `./locale/${locale}/${comp}.json`)
  try {
    const localeFile = JSON.parse(readFileSync(localePath, 'utf8'))
    compLocale = localeFile
  } catch (e) {
    IS_DEBUG && console.log(`locale: ${locale} not found`)
  }

  for (const [section, sValue] of Object.entries(compMap)) {
    const items = []

    if (section === 'mixins') {
      api.mixins = sValue

      continue
    }

    for (const item of sValue) {
      const description = compLocale[section][item.name] || ''

      items.push(Object.assign(item, { description }))
    }

    api[section] = items
  }

  return api
}

function generateCompList () {
  const mapPath = resolve(__dirname, './locale/en')
  const files = readdirSync(mapPath, 'utf8')
  const compList = []
  for (const item of files) {
    compList.push(item.split('.')[0])
  }
  return compList
}

function generateLocaleList () {
  return ['en', 'de-DE', 'fr-FR', 'ru-RU', 'zh-CN', 'ko-KR', 'ja-JP', 'eo-UY']
}

module.exports = {
  generateAPI,
  generateCompList,
  generateLocaleList,
}<commit_msg>docs(api): disable empty lang file generation<commit_after>// Imports
const { readFileSync, readdirSync } = require('fs')
const { resolve } = require('path')
const { IS_DEBUG } = require('../../src/util/globals')

// pseudo code to mock api-gen
function generateAPI (comp, locale) {
  const api = {}

  // defaults if file doesn't exist
  let compMap = {
    props: [{ name: 'empty', type: '', default: '', source: '' }],
    mixins: ['empty'],
    slots: [{ name: 'empty', props: '' }],
    events: [{ name: 'empty', value: '' }],
    functions: [{ name: 'empty', signature: '' }],
    sass: [{ name: 'empty', default: '' }],
  }
  let compLocale = {
    props: { empty: '' },
    slots: { empty: '' },
    events: { empty: '' },
    functions: { empty: '' },
    sass: { empty: '' },
  }

  try {
    // make sure we're getting latest version of file
    delete require.cache[resolve(`build/api-gen/maps/${comp}.js`)]
    const mapFile = require(`./maps/${comp}`)[comp]
    compMap = mapFile
  } catch (e) {
    IS_DEBUG && console.log(`map: ${comp} not found`)
  }
  // fs is not useable when accessing via component
  // will need to find an alternative for the
  // merging of lang, possibly change to js
  const localePath = resolve(__dirname, `./locale/${locale}/${comp}.json`)
  try {
    const localeFile = JSON.parse(readFileSync(localePath, 'utf8'))
    compLocale = localeFile
  } catch (e) {
    IS_DEBUG && console.log(`locale: ${locale} not found`)
  }

  for (const [section, sValue] of Object.entries(compMap)) {
    const items = []

    if (section === 'mixins') {
      api.mixins = sValue

      continue
    }

    for (const item of sValue) {
      const description = compLocale[section][item.name] || ''

      items.push(Object.assign(item, { description }))
    }

    api[section] = items
  }

  return api
}

function generateCompList () {
  const mapPath = resolve(__dirname, './locale/en')
  const files = readdirSync(mapPath, 'utf8')
  const compList = []
  for (const item of files) {
    compList.push(item.split('.')[0])
  }
  return compList
}

function generateLocaleList () {
  return ['en', /* 'de-DE', 'fr-FR', 'ru-RU', 'zh-CN', 'ko-KR', 'ja-JP', */ 'eo-UY']
}

module.exports = {
  generateAPI,
  generateCompList,
  generateLocaleList,
}
{'fraction_non_alphanumeric': 0.17809734513274336, 'fraction_numerical': 0.001327433628318584, 'mean_word_length': 3.0510752688172045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3004809', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1475, 'n_words': 391}