build: switch from yarn to npm to manage js dependencies and move js contents to root

yarn v1 is being deprecated and starts to have some issues

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-11-14 17:24:42 +01:00
parent 32055122c3
commit 2e72f6faf4
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
595 changed files with 12078 additions and 7843 deletions

View File

@ -22,7 +22,7 @@
# In the latter case `**/*.{ex,exs}` will be used. # In the latter case `**/*.{ex,exs}` will be used.
# #
included: ["lib/", "src/", "test/"], included: ["lib/", "src/", "test/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/js/"] excluded: [~r"/_build/", ~r"/deps/", ~r"/src/"]
}, },
# #
# If you create your own checks, you must specify the source files for # If you create your own checks, you must specify the source files for

View File

@ -15,5 +15,5 @@ Makefile
README.md README.md
SECURITY.md SECURITY.md
ssh_match_hostname ssh_match_hostname
.js/package-lock.json package-lock.json
js/node_modules node_modules

7
.gitignore vendored
View File

@ -46,7 +46,12 @@ release/
.weblate .weblate
docker/production/.env docker/production/.env
test-junit-report.xml test-junit-report.xml
js/junit.xml junit.xml
.env .env
demo/ demo/
codeclimate.json codeclimate.json
node_modules
stats.html
/coverage
/playwright-report/

View File

@ -13,7 +13,6 @@ stages:
variables: variables:
MIX_ENV: "test" MIX_ENV: "test"
YARN_CACHE_FOLDER: "js/.yarn"
# DB Variables for Postgres / Postgis # DB Variables for Postgres / Postgis
POSTGRES_DB: mobilizon_test POSTGRES_DB: mobilizon_test
POSTGRES_USER: postgres POSTGRES_USER: postgres
@ -38,8 +37,8 @@ cache:
paths: paths:
- deps/ - deps/
- _build/ - _build/
- js/node_modules - node_modules
- js/.yarn - .npm
# Installed dependencies are cached across the pipeline # Installed dependencies are cached across the pipeline
# So there is no need to reinstall them all the time # So there is no need to reinstall them all the time
@ -47,7 +46,7 @@ cache:
install: install:
stage: install stage: install
script: script:
- yarn --cwd "js" install --frozen-lockfile - npm ci
- mix deps.get - mix deps.get
- mix compile - mix compile
@ -74,10 +73,10 @@ lint-front:
stage: check stage: check
before_script: before_script:
- export EXITVALUE=0 - export EXITVALUE=0
- yarn --cwd "js" install --frozen-lockfile - npm ci
script: script:
- yarn --cwd "js" run lint || export EXITVALUE=1 - npm run lint || export EXITVALUE=1
- yarn --cwd "js" run prettier -c . || export EXITVALUE=1 - npm run prettier -c . || export EXITVALUE=1
- exit $EXITVALUE - exit $EXITVALUE
build-frontend: build-frontend:
@ -87,8 +86,8 @@ build-frontend:
- apt update - apt update
- apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant - apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant
script: script:
- yarn --cwd "js" install --frozen-lockfile - npm install --frozen-lockfile
- yarn --cwd "js" run build - npm run build
artifacts: artifacts:
expire_in: 5 days expire_in: 5 days
paths: paths:
@ -118,7 +117,7 @@ deps:
script: script:
- export EXITVALUE=0 - export EXITVALUE=0
- mix hex.outdated || export EXITVALUE=1 - mix hex.outdated || export EXITVALUE=1
- yarn --cwd "js" outdated || export EXITVALUE=1 - npm outdated || export EXITVALUE=1
- exit $EXITVALUE - exit $EXITVALUE
allow_failure: true allow_failure: true
needs: needs:
@ -151,16 +150,16 @@ vitest:
needs: needs:
- lint-front - lint-front
before_script: before_script:
- yarn --cwd "js" install --frozen-lockfile - npm install --frozen-lockfile
script: script:
- yarn --cwd "js" run coverage --reporter=default --reporter=junit --outputFile.junit=./junit.xml - npm run coverage --reporter=default --reporter=junit --outputFile.junit=./junit.xml
artifacts: artifacts:
when: always when: always
paths: paths:
- js/coverage - coverage
reports: reports:
junit: junit:
- js/junit.xml - junit.xml
expire_in: 30 days expire_in: 30 days
e2e: e2e:
@ -175,11 +174,10 @@ e2e:
- mix ecto.create - mix ecto.create
- mix ecto.migrate - mix ecto.migrate
- mix run priv/repo/e2e.seed.exs - mix run priv/repo/e2e.seed.exs
- cd js && yarn install && yarn run build && npx playwright install && cd ../ - npm install && npm run build && npx playwright install
- mix phx.digest - mix phx.digest
script: script:
- mix phx.server & - mix phx.server &
- cd js
- npx wait-on http://localhost:4000 - npx wait-on http://localhost:4000
- npx playwright test --project $BROWSER - npx playwright test --project $BROWSER
parallel: parallel:
@ -188,8 +186,8 @@ e2e:
artifacts: artifacts:
expire_in: 2 days expire_in: 2 days
paths: paths:
- js/playwright-report/ - playwright-report/
- js/test-results/ - test-results/
pages: pages:
stage: deploy stage: deploy
@ -198,8 +196,8 @@ pages:
- mix deps.get - mix deps.get
- mix docs - mix docs
- mv doc public/backend - mv doc public/backend
# #- yarn run --cwd "js" styleguide:build # #- npm run styleguide:build
# #- mv js/styleguide public/frontend # #- mv styleguide public/frontend
rules: rules:
- if: '$CI_COMMIT_BRANCH == "main"' - if: '$CI_COMMIT_BRANCH == "main"'
artifacts: artifacts:

View File

@ -1,4 +1,3 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
cd js npm run pre-commit
yarn run lint-staged

View File

@ -1,6 +1,6 @@
FROM elixir:alpine FROM elixir:alpine
RUN apk add --no-cache inotify-tools postgresql-client yarn file make gcc libc-dev argon2 imagemagick cmake build-base libwebp-tools bash ncurses git python3 RUN apk add --no-cache inotify-tools postgresql-client file make gcc libc-dev argon2 imagemagick cmake build-base libwebp-tools bash ncurses git python3
RUN mix local.hex --force && mix local.rebar --force RUN mix local.hex --force && mix local.rebar --force

View File

@ -4,7 +4,7 @@ init:
setup: stop setup: stop
@bash docker/message.sh "Compiling everything" @bash docker/message.sh "Compiling everything"
docker-compose run --rm api bash -c 'mix deps.get; yarn --cwd "js"; yarn --cwd "js" build:pictures; mix ecto.create; mix ecto.migrate' docker-compose run --rm api bash -c 'mix deps.get; npm ci; npm run build:pictures; mix ecto.create; mix ecto.migrate'
migrate: migrate:
docker-compose run --rm api mix ecto.migrate docker-compose run --rm api mix ecto.migrate
logs: logs:

View File

@ -7,6 +7,6 @@ module.exports = {
localSchemaFile: "./schema.graphql", localSchemaFile: "./schema.graphql",
}, },
// Files processed by the extension // Files processed by the extension
includes: ["js/src/**/*.vue", "js/src/**/*.js"], includes: ["src/**/*.vue", "src/**/*.js"],
}, },
}; };

View File

@ -16,7 +16,6 @@ config :mobilizon, Mobilizon.Web.Endpoint,
watchers: [ watchers: [
node: [ node: [
"node_modules/.bin/vite", "node_modules/.bin/vite",
cd: Path.expand("../js", __DIR__)
] ]
] ]

View File

@ -16,7 +16,7 @@ config :mobilizon, Mobilizon.Web.Endpoint,
check_origin: false, check_origin: false,
# Somehow this can't be merged properly with the dev config so we got this… # Somehow this can't be merged properly with the dev config so we got this…
watchers: [ watchers: [
yarn: [cd: Path.expand("../js", __DIR__)] npm: []
] ]
config :vite_phx, config :vite_phx,

View File

@ -18,9 +18,8 @@ ENV NODE_VERSION 18
RUN apt-get update -yq && apt-get install -yq build-essential cmake postgresql-client git curl gnupg unzip exiftool webp imagemagick gifsicle RUN apt-get update -yq && apt-get install -yq build-essential cmake postgresql-client git curl gnupg unzip exiftool webp imagemagick gifsicle
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# # Install Node & yarn # # Install Node
# RUN curl -sL https://deb.nodesource.com/setup_16.x | bash && apt-get install nodejs -yq # RUN curl -sL https://deb.nodesource.com/setup_16.x | bash && apt-get install nodejs -yq
# RUN npm install -g yarn
# Install build tools # Install build tools
RUN source /root/.bashrc && \ RUN source /root/.bashrc && \
@ -32,8 +31,8 @@ COPY ./ /mobilizon
WORKDIR /mobilizon WORKDIR /mobilizon
# # Build front-end # # Build front-end
# RUN yarn --cwd "js" install --frozen-lockfile # RUN npm install
# RUN yarn --cwd "js" run build # RUN npm run build
# Elixir release # Elixir release
RUN source /root/.bashrc && \ RUN source /root/.bashrc && \

View File

@ -3,11 +3,10 @@ FROM node:18-alpine as assets
RUN apk add --no-cache python3 build-base libwebp-tools bash imagemagick ncurses RUN apk add --no-cache python3 build-base libwebp-tools bash imagemagick ncurses
WORKDIR /build WORKDIR /build
COPY js . COPY . .
# Network timeout because it's slow when cross-compiling # Network timeout because it's slow when cross-compiling
RUN yarn install --network-timeout 100000 \ RUN npm install && npm run build
&& yarn run build
# Then, build the application binary # Then, build the application binary
FROM elixir:1.15-alpine AS builder FROM elixir:1.15-alpine AS builder

View File

@ -4,7 +4,7 @@ LABEL maintainer="Thomas Citharel <tcit@tcit.fr>"
ENV REFRESHED_AT=2023-08-17 ENV REFRESHED_AT=2023-08-17
RUN apt-get update -yq && apt-get install -yq build-essential inotify-tools postgresql-client git curl gnupg xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 cmake exiftool python3-pip python3-setuptools RUN apt-get update -yq && apt-get install -yq build-essential inotify-tools postgresql-client git curl gnupg xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 cmake exiftool python3-pip python3-setuptools
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash && apt-get install nodejs -yq RUN curl -sL https://deb.nodesource.com/setup_20.x | bash && apt-get install nodejs -yq
RUN npm install -g yarn wait-on RUN npm install -g wait-on
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN mix local.hex --force && mix local.rebar --force RUN mix local.hex --force && mix local.rebar --force
RUN pip3 install -Iv weasyprint pyexcel_ods3 RUN pip3 install -Iv weasyprint pyexcel_ods3

View File

@ -19,7 +19,7 @@ Mobilizon is an app that uses:
* `config` backend compile-time and runtime configuration * `config` backend compile-time and runtime configuration
* `docker` 🐳 * `docker` 🐳
* `js/src` Front-end * `src` Front-end
* `lib/federation` Handling all the federation stuff (sending and receving activities, converting activities, signatures, helpers…) * `lib/federation` Handling all the federation stuff (sending and receving activities, converting activities, signatures, helpers…)
* `lib/graphql/schema` The schema declarations for the GraphQL API * `lib/graphql/schema` The schema declarations for the GraphQL API
* `lib/graphql/resolvers` The logic behind the GraphQL API * `lib/graphql/resolvers` The logic behind the GraphQL API

View File

27
js/.gitignore vendored
View File

@ -1,27 +0,0 @@
.DS_Store
node_modules
/dist
/coverage
stats.html
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/test-results/
/playwright-report/
/playwright/.cache/

View File

@ -1,40 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"baseUrl": ".",
"types": ["webpack-env", "jest", "vite/client", "vite-plugin-pwa/vue"],
"typeRoots": ["./@types", "./node_modules/@types"],
"paths": {
"@/*": ["src/*"]
},
"lib": [
"esnext",
"dom",
"es2017.intl",
"dom.iterable",
"scripthost",
"webworker"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
"env.d.ts"
],
"exclude": ["node_modules"]
}

File diff suppressed because it is too large Load Diff

View File

@ -268,7 +268,7 @@ defmodule Mobilizon.Mixfile do
"deps.get", "deps.get",
"ecto.create --quiet", "ecto.create --quiet",
"ecto.migrate", "ecto.migrate",
"cmd cd js && yarn install && cd ../", "cmd npm ci",
"phx.server" "phx.server"
] ]
] ]

11986
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"preview": "vite preview", "preview": "vite preview",
"build": "yarn run build:assets && yarn run build:pictures", "build": "npm run build:assets && npm run build:pictures",
"lint": "eslint --ext .ts,.vue --ignore-path .gitignore --fix src", "lint": "eslint --ext .ts,.vue --ignore-path .gitignore --fix src",
"format": "prettier . --write", "format": "prettier . --write",
"build:assets": "vite build", "build:assets": "vite build",
@ -15,7 +15,8 @@
"story:preview": "histoire preview", "story:preview": "histoire preview",
"test": "vitest", "test": "vitest",
"coverage": "vitest run --coverage", "coverage": "vitest run --coverage",
"prepare": "cd ../ && husky install" "prepare": "husky install",
"pre-commit": "lint-staged"
}, },
"lint-staged": { "lint-staged": {
"**/*.{js,ts,vue}": [ "**/*.{js,ts,vue}": [

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 776 B

After

Width:  |  Height:  |  Size: 776 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 791 B

After

Width:  |  Height:  |  Size: 791 B

View File

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 1015 B

View File

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 857 B

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 857 B

View File

Before

Width:  |  Height:  |  Size: 920 B

After

Width:  |  Height:  |  Size: 920 B

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 378 B

View File

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 174 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Some files were not shown because too many files have changed in this diff Show More