Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Update templates and synced files
Dhruv Bhanushalia9532c314e85
diff --git a/.github/sync.yml b/.github/sync.ymlindex a5d7b35c1..05c858f38 100644--- a/.github/sync.yml+++ b/.github/sync.yml@@ -6,8 +6,6 @@ group:# Openverse- repos: |WordPress/openverse-catalog- WordPress/openverse-api- WordPress/openverse-frontendWordPress/openverse-infrastructurefiles:# Synced workflows@@ -37,15 +35,22 @@ group:dest: .github/release_drafter.yml- source: .github/ISSUE_TEMPLATE/dest: .github/ISSUE_TEMPLATE/- # Unified lint rules++ # prettier.config.js- repos: |WordPress/openverse+ files:+ - source: templates/prettier.config.local.js.jinja+ dest: prettier.config.js+ template: true+ - repos: |WordPress/openverse-catalog- WordPress/openverse-apifiles:- source: templates/prettier.config.js.jinjadest: prettier.config.jstemplate: true++ # .pre-commit-config.yaml- repos: |WordPress/openversefiles:@@ -54,27 +59,15 @@ group:template: true- repos: |WordPress/openverse-catalog- WordPress/openverse-apifiles:- source: templates/.pre-commit-config.yaml.jinjadest: .pre-commit-config.yamltemplate:contains_js_code: false- - repos: |- WordPress/openverse-frontend- files:- - source: templates/.pre-commit-config.frontend.yaml.jinja- dest: .pre-commit-config.yaml- template:- contains_python_code: false- - source: templates/prettier.config.frontend.js.jinja- dest: prettier.config.js- template: true- # Pull request configuration++ # pull_request_template.md- repos: |WordPress/openverse- WordPress/openverse-frontend- WordPress/openverse-apifiles:- source: templates/pull_request_template.md.jinjadest: .github/PULL_REQUEST_TEMPLATE/pull_request_template.mddiff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 3281ff6ca..bf7bbb5fa 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -1,11 +1,22 @@# This file is being synced from WordPress/openverse. Any changes made to it# here will be overwritten. Please make any necessary edits to these files:-# - https://github.com/WordPress/openverse/blob/main/.pre-commit-config.yaml.jinja+# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.yaml.jinja# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.local.yaml.jinjaexclude: Pipfile\.lock|migrations|\.idea|node_modules|archive|retiredrepos:+ - repo: local # More local hooks are defined at the bottom.+ hooks:+ - id: i18n+ name: i18n+ files: ^frontend/.*$+ # Check if the i18n files have been downloaded by checking if the Arabic translation exists+ # Download the i18n files if they do not exist+ entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/src/locales/ar.json ]; then just frontend/run i18n; fi'+ language: system+ pass_filenames: false+- repo: https://github.com/pre-commit/pre-commit-hooksrev: v4.0.1hooks:@@ -83,7 +94,8 @@ repos:rev: v8.15.0hooks:- id: eslint- files: ^js/.*$+ files: \.(js|ts|vue)$+ exclude: ^load_testing/.*|frontend/(nuxt-template-overrides/.*|.remake/.*)$ # ESLint raises warnings for ignored files."types": [file] # ESLint only accepts [javascript] by default.args:- --ignore-path=.gitignore@@ -92,6 +104,20 @@ repos:additional_dependencies:+ - "@babel/[email protected]"+ - "@intlify/[email protected]"+ - "@nuxtjs/[email protected]"+ - "@typescript-eslint/[email protected]"+ - "@typescript-eslint/[email protected]"# Use the `.prettierignore` and `.prettier.config.js` files to configure project-specific requirements.- repo: https://github.com/pre-commit/mirrors-prettier@@ -100,26 +126,45 @@ repos:- id: prettieradditional_dependencies:- repo: https://github.com/koalaman/shellcheck-precommitrev: v0.8.0hooks:- id: shellcheck- - repo: local+ - repo: local # More local hooks are defined at the top.hooks:+ - id: types+ name: types+ files: ^frontend/.*$+ entry: bash -c 'just frontend/run types'+ language: system+ pass_filenames: false+ - id: test:unit+ name: test:unit+ files: ^frontend/.*$+ entry: bash -c 'just frontend/run test:unit'+ language: system+ pass_filenames: false+ stages:+ - push- id: render-precommitname: render-precommit+ files: ^templates/.*$entry: bash -c 'just automations/js/render-precommit'language: systempass_filenames: false- id: render-prettiername: render-prettier+ files: ^templates/.*$entry: bash -c 'just automations/js/render-prettier'language: systempass_filenames: false- id: render-githubname: render-github+ files: ^templates/.*$entry: bash -c 'just automations/js/render-github'language: systempass_filenames: falsediff --git a/automations/js/justfile b/automations/js/justfileindex 1716de32f..da493ff67 100644--- a/automations/js/justfile+++ b/automations/js/justfile@@ -26,7 +26,7 @@ render-precommit:# Render `prettier.config.js`render-prettier:- just render templates/prettier.config.js.jinja prettier.config.js+ just render templates/prettier.config.local.js.jinja prettier.config.js# Render GitHub issue & PR templatesrender-github:diff --git a/prettier.config.js b/prettier.config.jsindex 0a79e738b..8e8b2e5d5 100644--- a/prettier.config.js+++ b/prettier.config.js@@ -1,6 +1,7 @@// This file is being synced from WordPress/openverse. Any changes made to it// here will be overwritten. Please make any necessary edits to these files:-// - https://github.com/WordPress/openverse/blob/main/prettier.config.js.jinja+// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.js.jinja+// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.local.js.jinjamodule.exports = {trailingComma: "es5",@@ -15,5 +16,13 @@ module.exports = {proseWrap: "preserve",},},+ {+ files: ["frontend/**/*"],+ options: {+ plugins: [require("prettier-plugin-tailwindcss")],+ tailwindConfig: "frontend/tailwind.config.js",+ vueIndentScriptAndStyle: false,+ },+ },],}diff --git a/templates/.pre-commit-config.frontend.yaml.jinja b/templates/.pre-commit-config.frontend.yaml.jinjadeleted file mode 100644index 2f38c6632..000000000--- a/templates/.pre-commit-config.frontend.yaml.jinja+++ /dev/null@@ -1,73 +0,0 @@-{% set eslint_files = '\\.(js|ts|vue)$' %}-{% set eslint_exclude = '^nuxt-template-overrides/.*|.remake/.*$' %}--{% extends 'templates/.pre-commit-config.yaml.jinja' %}--{% block note %}-{{ super() }}-# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.frontend.yaml.jinja-{%- endblock %}--{#=======================================-Repo blocks must be indented by 2 spaces.-=======================================#}--{% block repos_top %}- - repo: local # More local hooks are defined at the bottom.- hooks:- - id: i18n- name: i18n- # Check if the i18n files have been downloaded by checking if the Arabic translation exists- # Download the i18n files if they do not exist- entry: bash -c 'if [ ! -f "$(dirname "$dir")"/src/locales/ar.json ]; then pnpm i18n; fi'- language: system- pass_filenames: false-{# This comment adds a blank line. #}-{% endblock %}--{% block repos_bottom %}-{# This comment adds a blank line. #}- - repo: local # More local hooks are defined at the top.- hooks:- - id: types- name: types- entry: bash -c 'pnpm types'- language: system- pass_filenames: false-- - id: test:unit- name: test:unit- entry: bash -c 'pnpm test:unit'- language: system- pass_filenames: false- stages:- - push-{% endblock %}--{#=========================================-Dependencies must be indented by 10 spaces.-=========================================#}--{% block eslint_dependencies %}-{{ super() }}- - "@babel/[email protected]"- - "@intlify/[email protected]"- - "@nuxtjs/[email protected]"- - "@typescript-eslint/[email protected]"- - "@typescript-eslint/[email protected]"-{%- endblock %}--{% block prettier_dependencies %}-{{ super() }}-{%- endblock %}diff --git a/templates/.pre-commit-config.local.yaml.jinja b/templates/.pre-commit-config.local.yaml.jinjaindex 460ab656e..6e012aaa8 100644--- a/templates/.pre-commit-config.local.yaml.jinja+++ b/templates/.pre-commit-config.local.yaml.jinja@@ -1,3 +1,6 @@+{% set eslint_files = '\\.(js|ts|vue)$' %}+{% set eslint_exclude = '^load_testing/.*|frontend/(nuxt-template-overrides/.*|.remake/.*)$' %}+{% extends 'templates/.pre-commit-config.yaml.jinja' %}{% block note %}@@ -5,16 +8,77 @@# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.local.yaml.jinja{%- endblock %}+{#=======================================+Repo blocks must be indented by 2 spaces.+=======================================#}++{% block repos_top %}+ - repo: local # More local hooks are defined at the bottom.+ hooks:+ - id: i18n+ name: i18n+ files: ^frontend/.*$+ # Check if the i18n files have been downloaded by checking if the Arabic translation exists+ # Download the i18n files if they do not exist+ entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/src/locales/ar.json ]; then just frontend/run i18n; fi'+ language: system+ pass_filenames: false+{# This comment adds a blank line. #}+{% endblock %}+{% block repos_bottom %}{# This comment adds a blank line. #}- - repo: local+ - repo: local # More local hooks are defined at the top.hooks:+ - id: types+ name: types+ files: ^frontend/.*$+ entry: bash -c 'just frontend/run types'+ language: system+ pass_filenames: false+ - id: test:unit+ name: test:unit+ files: ^frontend/.*$+ entry: bash -c 'just frontend/run test:unit'+ language: system+ pass_filenames: false+ stages:+ - push{% set renders = ["precommit", "prettier", "github"] %}{% for render in renders %}- id: render-{{ render }}name: render-{{ render }}+ files: ^templates/.*$entry: bash -c 'just automations/js/render-{{ render }}'language: systempass_filenames: false{% endfor %}{% endblock %}++{#=========================================+Dependencies must be indented by 10 spaces.+=========================================#}++{% block eslint_dependencies %}+{{ super() }}+ - "@babel/[email protected]"+ - "@intlify/[email protected]"+ - "@nuxtjs/[email protected]"+ - "@typescript-eslint/[email protected]"+ - "@typescript-eslint/[email protected]"+{%- endblock %}++{% block prettier_dependencies %}+{{ super() }}+{%- endblock %}diff --git a/templates/.pre-commit-config.yaml.jinja b/templates/.pre-commit-config.yaml.jinjaindex 2de1949e2..d4ed9f043 100644--- a/templates/.pre-commit-config.yaml.jinja+++ b/templates/.pre-commit-config.yaml.jinja@@ -1,7 +1,7 @@{% block note %}# This file is being synced from WordPress/openverse. Any changes made to it# here will be overwritten. Please make any necessary edits to these files:-# - https://github.com/WordPress/openverse/blob/main/.pre-commit-config.yaml.jinja+# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.yaml.jinja{%- endblock %}{# This comment adds a blank line. #}diff --git a/templates/prettier.config.frontend.js.jinja b/templates/prettier.config.frontend.js.jinjadeleted file mode 100644index 0aa4638f4..000000000--- a/templates/prettier.config.frontend.js.jinja+++ /dev/null@@ -1,12 +0,0 @@-{% extends 'templates/prettier.config.js.jinja' %}--{% block note %}-{{ super() }}-// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.frontend.js.jinja-{%- endblock %}--{% block additional_config %}- vueIndentScriptAndStyle: false,- plugins: [require("prettier-plugin-tailwindcss")],- tailwindConfig: "tailwind.config.js",-{% endblock %}diff --git a/templates/prettier.config.js.jinja b/templates/prettier.config.js.jinjaindex df187fc93..9161d6c71 100644--- a/templates/prettier.config.js.jinja+++ b/templates/prettier.config.js.jinja@@ -1,7 +1,7 @@{% block note %}// This file is being synced from WordPress/openverse. Any changes made to it// here will be overwritten. Please make any necessary edits to these files:-// - https://github.com/WordPress/openverse/blob/main/prettier.config.js.jinja+// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.js.jinja{%- endblock %}{# This comment adds a blank line. #}@@ -18,6 +18,8 @@ module.exports = {proseWrap: "preserve",},},+ {% block additional_overrides %}+ {% endblock %}],{% block additional_config %}{% endblock %}diff --git a/templates/prettier.config.local.js.jinja b/templates/prettier.config.local.js.jinjanew file mode 100644index 000000000..a36935791--- /dev/null+++ b/templates/prettier.config.local.js.jinja@@ -0,0 +1,17 @@+{% extends 'templates/prettier.config.js.jinja' %}++{% block note %}+{{ super() }}+// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.local.js.jinja+{%- endblock %}++{% block additional_overrides %}+ {+ files: ["frontend/**/*"],+ options: {+ plugins: [require("prettier-plugin-tailwindcss")],+ tailwindConfig: "frontend/tailwind.config.js",+ vueIndentScriptAndStyle: false,+ },+ },+{% endblock %}