Skip to content

Commit faf599b

Browse files
zackkridaobulatsarayourfriend
authored
Migrate to Nuxt 3 (#4257)
Co-authored-by: Olga Bulat <[email protected]> Co-authored-by: sarayourfriend <[email protected]>
1 parent dff3a85 commit faf599b

File tree

419 files changed

+15520
-27806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

419 files changed

+15520
-27806
lines changed

.codespell/ignore_words.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;; Please include explanations for each ignored word.
22
;; See https://docs.openverse.org/meta/codespell.html for docs.
33

4-
;; Jest's `afterAll` hook incorrectly matched
4+
;; JS test library's `afterAll` hook incorrectly matched
55
afterall
66

77
;; `nd` references licence part

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
coverage
22

3+
# Vendored module. See explanation in file
4+
frontend/test/unit/test-utils/render-suspended.ts
5+
36
frontend/test/tapes
47
frontend/nuxt-template-overrides
58
frontend/storybook-static

.github/actions/build-docs/action.yml

-8
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ runs:
1717
# Pass -W to fail CI if warnings exist
1818
just documentation/build -W
1919
20-
- name: Build Storybook
21-
shell: bash
22-
run: |
23-
just frontend/run storybook:build-for-docs
24-
mv frontend/storybook-static/favicon_storybook.ico frontend/storybook-static/favicon.ico
25-
26-
# Storybook will be available at `/storybook`
2720
- name: Merge all docs
2821
shell: bash
2922
run: |
3023
mv documentation/_build /tmp/docs
31-
mv frontend/storybook-static /tmp/docs/storybook

.github/workflows/ci_cd.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ jobs:
294294
- name: Setup CI env
295295
uses: ./.github/actions/setup-env
296296
with:
297-
# Python is not needed to run the tests.
298-
setup_python: false
299-
# Node.js is needed by lint actions.
300-
install_recipe: "node-install"
297+
setup_python: true
298+
# Node.js is not needed to run the tests.
299+
setup_nodejs: false
300+
install_recipe: ""
301301

302302
- name: Load Docker images
303303
uses: ./.github/actions/load-img
@@ -796,14 +796,11 @@ jobs:
796796
name:
797797
- playwright_vr
798798
- playwright_e2e
799-
- storybook
800799
include:
801800
- name: playwright_vr
802801
script: "test:playwright visual-regression -u"
803802
- name: playwright_e2e
804803
script: "test:playwright e2e"
805-
- name: storybook
806-
script: "test:storybook -u"
807804

808805
steps:
809806
- name: Checkout repository
@@ -866,7 +863,6 @@ jobs:
866863
name:
867864
- playwright_vr
868865
- playwright_e2e
869-
- storybook
870866

871867
steps:
872868
- name: Pass

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ repos:
6161
# Must include any plugins defined in prettier.config.js, along with TypeScript and Prettier themselves
6262
# Versions must be manually kept in sync with those in the pnpm-lock.yaml file to prevent drift.
6363
additional_dependencies:
64-
- prettier@3.2.5
65-
- prettier-plugin-tailwindcss@0.5.14
64+
- prettier@3.3.2
65+
- prettier-plugin-tailwindcss@0.6.5
6666
6767

6868
- repo: https://github.com/koalaman/shellcheck-precommit
@@ -119,7 +119,7 @@ repos:
119119
- id: types
120120
name: types
121121
files: ^(frontend|packages/js)/.*$
122-
entry: bash -c 'pnpm run -r types'
122+
entry: bash -c 'pnpm run prepare:nuxt && pnpm run -r types'
123123
language: system
124124
pass_filenames: false
125125

automations/data/labels.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ groups:
189189
- name: pytest
190190
description: Involves pytest
191191
emoji: "🐍"
192-
- name: jest
193-
description: Involves Jest
192+
- name: vitest
193+
description: Involves vitest
194194
emoji: "🟨"
195195
- name: playwright
196196
description: Involves Playwright

documentation/meta/documentation/guidelines.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ maintainers which occurred after reading
1212
These are some aspects to consider when starting the document.
1313

1414
**Type**: _(README, "Getting Started", Conceptual, Procedural
15-
[tutorial/how-to/guide], Reference [API reference, Glossary, Troubleshooting,
16-
Changelog])_\
15+
[tutorial/how-to/guide], Reference [API reference, Glossary,
16+
Troubleshooting, Changelog])_\
1717
**Audience**:\
1818
**Purpose**:\
1919
**Title**:\

frontend/.env.template

+58-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
1-
#API_URL=http://127.17.0.1:8000/
2-
#API_CLIENT_ID=""
3-
#API_CLIENT_SECRET=""
1+
PORT=8443
2+
3+
# ---------------------------- #
4+
# REQUIRED LOCAL ENV VARIABLES #
5+
# ---------------------------- #
6+
# DEPLOYMENT_ENV=local
7+
# SITE_DOMAIN=localhost
8+
# SITE_URL=http://localhost:8443
9+
#/**
10+
#* We rely on the Nginx container running as `frontend_nginx`
11+
#* in the local compose stack to proxy requests. Therefore, the
12+
#* URL here is not for the Plausible container in the local stack,
13+
#* but the Nginx service, which then itself forwards the requests
14+
#* to the local Plausible instance.
15+
#*
16+
#* In production, the Nginx container is handling all requests
17+
#* made to the root URL (openverse.org), and is configured to
18+
#* forward Plausible requests to upstream Plausible.
19+
#*/
20+
# PLAUSIBLE_SITE_URL = http://localhost:50290
21+
22+
# ---------------------------- #
23+
# OPTIONAL LOCAL ENV VARIABLES
24+
# ---------------------------- #
25+
### API settings
26+
27+
# NUXT_PUBLIC_API_URL=http://127.17.0.1:8000/ # local dev API
28+
# NUXT_PUBLIC_API_URL=http://localhost:49153/ # talkback proxy
29+
# NUXT_PUBLIC_API_URL=https://api.openverse.org/# prod API
30+
31+
# NUXT_API_CLIENT_ID=""
32+
# NUXT_API_CLIENT_SECRET=""
33+
34+
# -------------------- #
35+
# PRODUCTION VARIABLES #
36+
# -------------------- #
37+
# DEPLOYMENT_ENV=production
38+
# NUXT_API_CLIENT_ID=""
39+
# NUXT_API_CLIENT_SECRET=""
40+
# NUXT_PUBLIC_API_URL=https://api.openverse.org/
41+
# NUXT_PUBLIC_SENTRY_DSN=""
42+
# NUXT_PUBLIC_SENTRY_RELEASE=""
43+
# SITE_URL=https://openverse.org
44+
# SITE_DOMAIN=openverse.org
45+
# PLAUSIBLE_SITE_URL=https://openverse.org
46+
47+
# ----------------- #
48+
# STAGING VARIABLES #
49+
# ----------------- #
50+
# DEPLOYMENT_ENV=staging
51+
# NUXT_API_CLIENT_ID=""
52+
# NUXT_API_CLIENT_SECRET=""
53+
# NUXT_PUBLIC_API_URL=https://api-staging.openverse.org/
54+
# NUXT_PUBLIC_SENTRY_DSN=""
55+
# NUXT_PUBLIC_SENTRY_RELEASE=""
56+
# SITE_URL=https://staging.openverse.org
57+
# SITE_DOMAIN=staging.openverse.org
58+
# PLAUSIBLE_SITE_URL=https://staging.openverse.org

frontend/.storybook/decorators/with-rtl.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import Vue from "vue"
1+
import { useI18n } from "#imports"
2+
3+
import { ref, watch, onMounted, reactive } from "vue"
24

3-
import { ref, watch, useContext, onMounted } from "@nuxtjs/composition-api"
45
import { useEffect } from "@storybook/client-api"
56

6-
const languageDirection = Vue.observable({ value: "ltr" })
7+
const languageDirection = reactive({ value: "ltr" })
78

89
export const WithRTL = (story, context) => {
910
useEffect(() => {
@@ -15,7 +16,7 @@ export const WithRTL = (story, context) => {
1516
components: { story },
1617
setup() {
1718
const element = ref()
18-
const { i18n } = useContext()
19+
const { i18n } = useI18n({ useScope: "global" })
1920
onMounted(() => {
2021
watch(
2122
languageDirection,

frontend/.storybook/decorators/with-ui-store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, onMounted } from "@nuxtjs/composition-api"
1+
import { ref, onMounted } from "vue"
22

33
import { useLayout } from "~/composables/use-layout"
44

frontend/.storybook/main.js

-23
This file was deleted.

frontend/.storybook/middleware.js

-1
This file was deleted.

frontend/.storybook/preview.js

-30
This file was deleted.

frontend/Dockerfile

+12-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ WORKDIR /home/node/
2020
# Copy monorepo mocking files into `/home/node`, which pretends to be the monorepo root.
2121
# Note: these files must be manually un-ignored in the root .dockerignore
2222
# hadolint ignore=DL3022
23-
COPY --from=repo_root --chown=node:node .npmrc .pnpmfile.cjs pnpm-lock.yaml tsconfig.base.json ./
24-
23+
COPY --from=repo_root --chown=node:node .npmrc .pnpmfile.cjs pnpm-lock.yaml ./
2524
RUN echo '{"packages":["frontend/"]}' > pnpm-workspace.yaml
2625

2726
# Copy the `frontend/` directory into `/home/node/frontend`, as a package in the monorepo.
@@ -40,9 +39,12 @@ RUN pnpm install && pnpm i18n
4039
# disable telemetry when building the app
4140
ENV NUXT_TELEMETRY_DISABLED=1
4241
ENV NODE_ENV=production
43-
ENV SENTRY_DSN=https://[email protected]/5799642
42+
ENV NUXT_PUBLIC_SENTRY_DSN=https://[email protected]/5799642
4443

45-
ARG API_URL
44+
ARG API_URL=https://api.openverse.org/
45+
ENV NUXT_PUBLIC_API_URL=$API_URL
46+
# Increase memory limit for the build process (necessary for i18n routes)
47+
ENV NODE_OPTIONS="--max_old_space_size=4096"
4648

4749
RUN pnpm build
4850

@@ -67,7 +69,12 @@ COPY --from=builder --chown=node:node /home/node/frontend ./frontend/
6769
WORKDIR /home/node/frontend/
6870

6971
ARG SEMANTIC_VERSION
70-
ENV SENTRY_RELEASE=$SEMANTIC_VERSION
72+
ARG DEPLOYMENT_ENV=production
73+
ARG API_URL=https://api.openverse.org/
74+
75+
ENV NUXT_PUBLIC_API_URL=$API_URL
76+
ENV NUXT_PUBLIC_SENTRY_RELEASE=$SEMANTIC_VERSION
77+
ENV NUXT_PUBLIC_SENTRY_ENVIRONMENT=$DEPLOYMENT_ENV
7178

7279
# set app serving to permissive / assigned
7380
ENV NUXT_HOST=0.0.0.0

frontend/Dockerfile.playwright

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ ARG PLAYWRIGHT_VERSION
44

55
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-jammy
66

7-
COPY package.json /
7+
WORKDIR /frontend
8+
9+
COPY package.json .
810

911
# Ensure the Playwright container's pnpm cache folder exists and is writable
1012
RUN mkdir -p /.cache/node/corepack/ && chmod -R 777 /.cache/node/corepack/
1113

1214
# Requires `packageManager` field to be present in `frontend/package.json`.
1315
RUN corepack enable pnpm
16+
17+
# DO NOT actually run `pnpm install` here. Doing so requires us to copy the the source into the container.
18+
# However, that's a waste of time because we mount the source in the compose file anyway.
19+
# Instead, we run `pnpm install` in the entrypoint script defined in the compose file.
20+
# ENTRYPOINT ["pnpm", "install", "&&"]

frontend/docker-compose.playwright.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ services:
66
args:
77
- PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}
88
volumes:
9-
- ../node_modules:/node_modules
10-
- .:/frontend
11-
- ${PWD}/../tsconfig.base.json:/tsconfig.base.json
9+
- ../node_modules:/node_modules:rw,Z
10+
- .:/frontend:rw,Z
1211
user: ${USER_ID}
1312
working_dir: /frontend
14-
command: pnpm ${TEST_COMMAND} ${PLAYWRIGHT_ARGS:-}
13+
entrypoint: >
14+
/bin/sh -c '
15+
pnpm install;
16+
pnpm ${TEST_COMMAND} ${PLAYWRIGHT_ARGS:-};
17+
'
1518
environment:
1619
# This makes the webserver that Playwright runs show the build
1720
- DEBUG=pw:webserver

frontend/jest.config.ts

-38
This file was deleted.

frontend/justfile

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export FRONTEND_PNPM_VERSION := `grep 'packageManager' ../package.json | awk -F'
3535
# Build the frontend Docker image
3636
build-img tag="openverse-frontend:local" target="app":
3737
docker build \
38+
--load \
3839
--target {{ target }} \
3940
--build-context 'repo_root=..' \
4041
--build-arg FRONTEND_NODE_VERSION=$(just node-version) \

0 commit comments

Comments
 (0)