<commit_before>---

- set_fact:
    frontend_deployment_dir: "{{ frontend_project_dir }}/{{ 'current' if irma_deployment_code_version == 'local' else 'releases/' + irma_deployment_release_name }}"

- name: Ensure that releases directory has been created
  file:
    path: "{{ frontend_project_dir }}/releases"
    state: directory
    owner: "{{ frontend_user }}"
    group: "{{ frontend_group }}"

- name: Clone repository
  git:
    repo: "{{ frontend_deployment_repository }}"
    dest: "{{ frontend_deployment_dir }}"
    version: "{{ irma_deployment_code_version }}"
    accept_hostkey: yes
  when: irma_deployment_code_version != 'local'

- name: Install requirements in a Frontend virtualenv
  pip:
    requirements: "{{ frontend_deployment_dir }}/requirements.txt"
    virtualenv: "{{ frontend_deployment_dir }}/venv"

- name: Install NPM dependencies
  npm:
    path: "{{ frontend_deployment_dir }}/web"
    state: present
  register: npm_install

- name: Install Bower dependencies
  command: node_modules/.bin/bower install --config.interactive=false
  args:
    chdir: "{{ frontend_deployment_dir }}/web"

- name: Generate Web Frontend
  command: node_modules/.bin/gulp dist
  args:
    chdir: "{{ frontend_deployment_dir }}/web"

# Copy previous config file
#
# If error with copy, generate it
#- name: Configure {{ frontend_install_dir }}/config/frontend.ini file
  #ini_file:
    #dest="{{ frontend_install_dir }}/config/frontend.ini"
    #section={{ item.section }}
    #option={{ item.option }}
    #value={{ item.value }}
  #with_items: frontend_configs

- name: Create symlink release -> current
  file:
    src: "{{ frontend_deployment_dir }}"
    dest: "{{ frontend_install_dir }}"
    state: link
  when: irma_deployment_code_version != 'local'
<commit_msg>Copy npm and bower directories to speed up deployment<commit_after>---

- set_fact:
    frontend_deployment_dir: "{{ frontend_project_dir }}/{{ 'current' if irma_deployment_code_version == 'local' else 'releases/' + irma_deployment_release_name }}"

- name: Ensure that releases directory has been created
  file:
    path: "{{ frontend_project_dir }}/releases"
    state: directory
    owner: "{{ frontend_user }}"
    group: "{{ frontend_group }}"

- name: Clone repository
  git:
    repo: "{{ frontend_deployment_repository }}"
    dest: "{{ frontend_deployment_dir }}"
    version: "{{ irma_deployment_code_version }}"
    accept_hostkey: yes
  when: irma_deployment_code_version != 'local'

- name: Install requirements in a Frontend virtualenv
  pip:
    requirements: "{{ frontend_deployment_dir }}/requirements.txt"
    virtualenv: "{{ frontend_deployment_dir }}/venv"

- name: Copy previous Npm files
  shell: "cp -R {{frontend_install_dir}}/web/node_modules {{frontend_deployment_dir}}/web/node_modules"
  args:
    remotes: "{{frontend_install_dir}}/web/node_modules"
    creates: "{{frontend_deployment_dir}}/web/node_modules"
  # Errors when current does not exists (first deployment)
  ignore_errors: yes

- name: Install NPM dependencies
  npm:
    path: "{{ frontend_deployment_dir }}/web"
    state: present
  register: npm_install

- name: Copy previous Bower files
  shell: "cp -R {{frontend_install_dir}}/web/app/components {{frontend_deployment_dir}}/web/app/components"
  args:
    remotes: "{{frontend_install_dir}}/web/app/components"
    creates: "{{frontend_deployment_dir}}/web/app/components"
  # Errors when current does not exists (first deployment)
  ignore_errors: yes

- name: Install Bower dependencies
  command: node_modules/.bin/bower install --config.interactive=false
  args:
    chdir: "{{ frontend_deployment_dir }}/web"

- name: Generate Web Frontend
  command: node_modules/.bin/gulp dist
  args:
    chdir: "{{ frontend_deployment_dir }}/web"

# Copy previous config file
#
# If error with copy, generate it
#- name: Configure {{ frontend_install_dir }}/config/frontend.ini file
  #ini_file:
    #dest="{{ frontend_install_dir }}/config/frontend.ini"
    #section={{ item.section }}
    #option={{ item.option }}
    #value={{ item.value }}
  #with_items: frontend_configs

- name: Create symlink release -> current
  file:
    src: "{{ frontend_deployment_dir }}"
    dest: "{{ frontend_install_dir }}"
    state: link
  when: irma_deployment_code_version != 'local'

{'fraction_non_alphanumeric': 0.12628145386766076, 'fraction_numerical': 0.0, 'mean_word_length': 4.306551297898641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '133213', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1409, 'n_words': 328}