<commit_before># This code fetch the components from the addons but only in the root of the
# addon/**/client folder.

TARGET_ROOT = "#{Dir.pwd}/app/javascript/src/componentLoader/components".freeze

begin
# clear previous build
FileUtils.rm_f Dir.glob("#{TARGET_ROOT}/*")

Dir.foreach('addons/') do |path|
  addons_client_root = "addons/#{path}/client"
  next unless Dir.exist? addons_client_root
  File.symlink("#{Dir.pwd}/#{addons_client_root}", "#{TARGET_ROOT}/#{path}")
end
# handles error on the platforms that does not support symlink
# http://ruby-doc.org/core-2.2.0/File.html#symlink-method
rescue
  puts '[sciNote] Unable to load React components from addons!'
  puts '[sciNote] Your system does not support symlink!'
end
<commit_msg>adds(addon_loader) a generator that creates a js file with available addons<commit_after>TARGET_ROOT = "#{Dir.pwd}/app/javascript/src/componentLoader/components".freeze

begin
# clear previous build
FileUtils.rm_f Dir.glob("#{TARGET_ROOT}/*")

available_addons = []
Dir.foreach('addons/') do |path|
  addons_client_root = "addons/#{path}/client"
  next unless Dir.exist? addons_client_root
  available_addons << path
  File.symlink("#{Dir.pwd}/#{addons_client_root}", "#{TARGET_ROOT}/#{path}")
end

# generate a file with available addons
if available_addons.any?
  file_name = "#{Dir.pwd}/app/javascript/src/componentLoader/availableAddons.js"
  # remove if already exists
  FileUtils.rm_f Dir.glob(file_name)
  File.new(file_name, 'w+')
  File.open(file_name, 'w') do |file|
    file.write("export default #{available_addons};")
  end
end

# handles error on the platforms that does not support symlink
# http://ruby-doc.org/core-2.2.0/File.html#symlink-method
rescue
  puts '[sciNote] Unable to load React components from addons!'
  puts '[sciNote] Your system does not support symlink!'
end

{'fraction_non_alphanumeric': 0.1343121261555193, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 5.1952861952861955, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3380058', 'n_tokens_mistral': 616, 'n_tokens_neox': 621, 'n_words': 158}