Skip to content

Commit

Permalink
Update deps 2024-03 (#1248)
Browse files Browse the repository at this point in the history
* Update dependencies for repo root

* Update dependencies for system-tests

* Update dependencies for cms

* npm audit for cms

* Update dependencies for course-material

* npm audit for course-material

* Update dependencies for example-exercise

* npm audit for example-exercise

* Update dependencies for main-frontend

* npm audit for main-frontend

* Update dependencies for quizzes

* npm audit for quizzes

* Update dependencies for tmc

* npm audit for tmc

* Update dependencies for shared-module

* npm audit for shared-module

* Cargo upgrade

* Cargo update

* Update rust version, downgrade resvg and usvg

* Downgrade next for cms

* Generate gutenberg types

* System test fixes

* Eslint fixes

* Storybook fixes

* Cargo test fixes

* Retry multiple-choice dropdown test

* Retry more tests

* Add playwright-install

* Fix eslint-plugin-i18next

* Add missing translations

* fix

* Test stability fix

* Test stability fix
  • Loading branch information
nygrenh authored Mar 12, 2024
1 parent 0f09118 commit 94d0bd2
Show file tree
Hide file tree
Showing 133 changed files with 8,968 additions and 7,398 deletions.
169 changes: 120 additions & 49 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/* eslint-disable i18next/no-literal-string */

const DETECT_CSS_REGEX = /\S+:\s+[^\n]+;/
const DETECT_CSS_REGEX = /:.*;/
const DETECT_CSS_REGEX_2 = /!important/
const DETECT_CSS_REGEX_3 = /;.*:/s
const DETECT_PX_REGEX = /^\d+px$/
const DETECT_REM_REGEX = /^\d+rem$/
const DETECT_EM_REGEX = /^\d+em$/
const DETECT_COLOR_REGEX = /^#[0-9A-Fa-f]{6}$/

module.exports = {
env: {
browser: true,
Expand Down Expand Up @@ -120,61 +124,128 @@ module.exports = {
"i18next/no-literal-string": [
"error",
{
validateTemplate: true,
mode: "all",
message: "Untranslated string",
"should-validate-template": true,
// only add attributes here that are guranteed to never contain traslatable strings
ignoreAttribute: [
"variant",
"size",
"href",
"severity",
"navVariant",
"aria-labelledby",
"aria-describedby",
"url",
"labelId",
"defaultLanguage",
"color",
"labelPlacement",
"role",
"aria-hidden",
"maxWidth",
"transform",
"viewBox",
"testPlaceholder",
"sidebarPosition",
"buttonSize",
"labelStyle",
"data-testid",
],
ignore: [DETECT_CSS_REGEX, DETECT_PX_REGEX, DETECT_REM_REGEX, DETECT_EM_REGEX],
ignoreCallee: [
"div",
"useQuery",
"useQueryParameter",
"get",
"post",
"put",
"delete",
"create",
"styled",
"css",
"register",
"setValue",
"getValues",
"watch",
"useMediaQuery",
"console.log",
"console.error",
"Error",
],
ignoreProperty: ["type"],
"jsx-components": {
exclude: ["Trans"],
},
"jsx-attributes": {
exclude: [
"className",
"styleName",
"style",
"type",
"key",
"id",
"width",
"height",
"variant",
"size",
"href",
"severity",
"navVariant",
"aria-labelledby",
"aria-describedby",
"url",
"labelId",
"defaultLanguage",
"color",
"labelPlacement",
"role",
"aria-hidden",
"maxWidth",
"transform",
"viewBox",
"testPlaceholder",
"sidebarPosition",
"buttonSize",
"labelStyle",
"data-testid",
"weight",
"action",
"tagName",
],
},
words: {
exclude: [
DETECT_CSS_REGEX,
DETECT_CSS_REGEX_2,
DETECT_CSS_REGEX_3,
DETECT_PX_REGEX,
DETECT_REM_REGEX,
DETECT_EM_REGEX,
DETECT_COLOR_REGEX,
"[0-9!-/:-@[-`{-~]+",
"[A-Z_-]+",
/^\p{Emoji}+$/u,
],
},
callees: {
exclude: [
"i18n(ext)?",
"t",
"require",
"addEventListener",
"removeEventListener",
"postMessage",
"getElementById",
"dispatch",
"commit",
"includes",
"indexOf",
"endsWith",
"startsWith",
"div",
"useQuery",
"useQueryParameter",
"get",
"post",
"put",
"delete",
"create",
"styled",
"css",
"register",
"setValue",
"getValues",
"watch",
"useMediaQuery",
"log",
"error",
"warn",
"info",
"group",
"Error",
"querySelector",
"usePopper",
"i18n.on",
"i18n.off",
"createElement",
"localStorage.setItem",
"localStorage.getItem",
"differenceBy",
"accessor",
"useTranslation",
"sortBy",
"split",
"JSON.parse",
],
},
"object-properties": {
exclude: ["type", "[A-Z_-]+", "displayName"],
},
"class-properties": {
exclude: ["displayName"],
},
},
],
curly: "error",
},
overrides: [
{
files: ["system-tests/**/*"],
files: ["system-tests/**/*", "**.test.tsx", "**.test.ts"],
rules: {
"i18next/no-literal-string": "off",
},
Expand Down
11 changes: 11 additions & 0 deletions bin/playright-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/.common"

BASEDIR="$(dirname "${BASH_SOURCE[0]}")"
FOLDER_PATH="$BASEDIR/../system-tests"
RELATIVE_PATH=$(realpath --relative-to="$(pwd)" "$FOLDER_PATH")

run_command cd "$RELATIVE_PATH" || exit

run_command npx playwright install "$@"
2 changes: 1 addition & 1 deletion bin/sqlx-database-reset
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trap 'run_command kubectl delete pod $RANDOM_POD_NAME --force' EXIT

run_command kubectl run "$RANDOM_POD_NAME" --image=eu.gcr.io/moocfi-public/project-331-headless-lms-dev-base:latest --command -- sleep infinity

run_command kubectl wait --for=condition=ready pod/"$RANDOM_POD_NAME"
run_command kubectl wait --timeout 300s --for=condition=ready pod/"$RANDOM_POD_NAME"
# Copy migrations to pod
run_command kubectl cp "$RELATIVE_PATH" "$RANDOM_POD_NAME":migrations
# Create new database with a random name
Expand Down
58 changes: 33 additions & 25 deletions bin/translations-add-new-ones-to-non-en
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/.common"
#!/usr/bin/env python3

BASEDIR="$(dirname "${BASH_SOURCE[0]}")"
TRANSLATIONS_EN_PATH="$BASEDIR/../shared-module/src/locales/en"
TRANSLATIONS_EN_RELATIVE_PATH=$(realpath --relative-to="$(pwd)" "$TRANSLATIONS_EN_PATH")
FOLDERS_PATH="$BASEDIR/../shared-module/src/locales"
FOLDERS_RELATIVE_PATH=$(realpath --relative-to="$(pwd)" "$FOLDERS_PATH")
import os
import subprocess
import glob
import json

ensure_program_in_path jq
ensure_program_in_path find
ensure_program_in_path sponge
BASEDIR = os.path.dirname(os.path.realpath(__file__))
TRANSLATIONS_EN_PATH = os.path.join(BASEDIR, "../shared-module/src/locales/en")
TRANSLATIONS_EN_RELATIVE_PATH = os.path.relpath(TRANSLATIONS_EN_PATH)
FOLDERS_PATH = os.path.join(BASEDIR, "../shared-module/src/locales")
FOLDERS_RELATIVE_PATH = os.path.relpath(FOLDERS_PATH)

EN_PATHS=$(find "$TRANSLATIONS_EN_RELATIVE_PATH" -name '*.json')
# Find all localization folders that are not the source en folder
FOLDERS_PATH=$(find "$FOLDERS_RELATIVE_PATH" -maxdepth 1 -mindepth 1 -type d ! -name 'en')
def ensure_program_in_path(program):
if not any(os.access(os.path.join(path, program), os.X_OK) for path in os.environ["PATH"].split(os.pathsep)):
raise Exception(f"{program} not found in PATH")

for original_file in $EN_PATHS; do
for target_folder in $FOLDERS_PATH; do
target_folder_language=$(basename "$target_folder")
target_file="${original_file/\/en\//\/$target_folder_language\/}"
echo "Adding translations $original_file > $target_file"
echo "> jq -s 'add' \"$original_file\" \"$target_file\" | sponge \"$target_file\""
jq --sort-keys -s 'add' "$original_file" "$target_file" | sponge "$target_file"
done
done
ensure_program_in_path('jq')
ensure_program_in_path('sponge')

echo ""
echo "Important: remember to translate the new strings before adding them to version control"
EN_PATHS = glob.glob(f"{TRANSLATIONS_EN_RELATIVE_PATH}/*.json")
FOLDERS_PATH = [name for name in glob.glob(f"{FOLDERS_RELATIVE_PATH}/*") if os.path.isdir(name) and not name.endswith('/en')]

for original_file in EN_PATHS:
for target_folder in FOLDERS_PATH:
target_folder_language = os.path.basename(target_folder)
target_file = original_file.replace("/en/", f"/{target_folder_language}/")
print(f"Adding translations {original_file} > {target_file}")
with open(original_file) as f1, open(target_file) as f2:
data1 = json.load(f1)
data2 = json.load(f2)
missing_keys = [key for key in data1 if key not in data2]
for key in missing_keys:
data2[key] = data1[key]
with open(target_file, 'w') as f:
json.dump(data2, f, indent=2, ensure_ascii=False)

print("\nImportant: remember to translate the new strings before adding them to version control")
Loading

0 comments on commit 94d0bd2

Please sign in to comment.