Skip to content

Commit

Permalink
Pre-GSoC 2024 - Stable (#1934)
Browse files Browse the repository at this point in the history
* Added Base branch check to main

* Deleted all files in the main branch in anticipation of merging develop into main cleanly

* Merge develop to main

* Deleted all main files

* Merged develop into main
  • Loading branch information
palisadoes authored Apr 27, 2024
1 parent a320d35 commit 42633e2
Show file tree
Hide file tree
Showing 705 changed files with 63,291 additions and 23,988 deletions.
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# file to .env or set the variables in your local environment manually.


# Custom port number for the talawa-admin development server to run on. Default is 4321.

PORT=4321

# Run Talawa-api locally in your system, and put its url into the same.

REACT_APP_TALAWA_URL=
Expand All @@ -20,4 +24,8 @@ REACT_APP_USE_RECAPTCHA=
REACT_APP_RECAPTCHA_SITE_KEY=

# has to be inserted in the env file to use plugins and other websocket based features.
REACT_APP_BACKEND_WEBSOCKET_URL=ws://localhost:4000/graphql
REACT_APP_BACKEND_WEBSOCKET_URL=ws://localhost:4000/graphql

# If you want to logs Compiletime and Runtime error , warning and info write YES or if u want to
# keep the console clean leave it blank
ALLOW_LOGS=
51 changes: 31 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"eslint:recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"eslint-config-prettier",
"prettier"
],
"globals": {
"Atomics": "readonly",
Expand All @@ -27,11 +29,17 @@
},

// Specify the ESLint plugins tobe used
"plugins": ["react", "@typescript-eslint", "jest"],
"plugins": [
"react",
"@typescript-eslint",
"jest",
"import",
"eslint-plugin-tsdoc",
"prettier"
],
"rules": {
"react/destructuring-assignment": ["off"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/explicit-module-boundary-types": ["off"],
"react/destructuring-assignment": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"react/no-multi-comp": [
"error",
{
Expand All @@ -44,6 +52,14 @@
"extensions": [".tsx"]
}
],
"import/no-duplicates": "error",
"tsdoc/syntax": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/array-type": "error",
Expand All @@ -56,6 +72,7 @@
"allowTypedFunctionExpressions": true
}
],
"camelcase": "off",
"@typescript-eslint/naming-convention": [
"error",
// Interfaces must begin with Interface or TestInterface followed by a PascalCase name
Expand All @@ -76,7 +93,7 @@
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"format": ["camelCase", "UPPER_CASE", "PascalCase"],
"leadingUnderscore": "allow"
},
{
Expand All @@ -86,7 +103,7 @@
},
{
"selector": "function",
"format": ["camelCase"]
"format": ["camelCase", "PascalCase"]
},
{
"selector": "memberLike",
Expand All @@ -95,7 +112,11 @@
"leadingUnderscore": "require"
},

{ "selector": "variable", "modifiers": ["exported"], "format": null }
{
"selector": "variable",
"modifiers": ["exported"],
"format": null
}
],
// Ensures that components are always written in PascalCase
"react/jsx-pascal-case": [
Expand All @@ -110,23 +131,13 @@
// All tests must need not have an assertion
"jest/expect-expect": 0,

// Ensures that components are always indented by 2 spaces
"react/jsx-indent": ["warn", 2],
"react/jsx-tag-spacing": [
"warn",
{
"afterOpening": "never",
"beforeClosing": "never",
"beforeSelfClosing": "always"
}
],

// Enforce Strictly functional components
"react/no-unstable-nested-components": ["error", { "allowAsProps": true }],
"react/function-component-definition": [
0,
{ "namedComponents": "function-declaration" }
]
],
"prettier/prettier": "error"
},

// Let ESLint use the react version in the package.json
Expand Down
18 changes: 18 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Configuration for automated dependency updates using Dependabot
version: 2
updates:
# Define the target package ecosystem
- package-ecosystem: "npm"
# Specify the root directory
directory: "/"
# Schedule automated updates to run weekly
schedule:
interval: "weekly"
# Labels to apply to Dependabot PRs
labels:
- "dependencies"
# Specify the target branch for PRs
target-branch: "develop"
# Customize commit message prefix
commit-message:
prefix: "chore(deps):"
34 changes: 0 additions & 34 deletions .github/workflows/authorized-changes-detection.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codeql-codescan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
language: [ 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
170 changes: 170 additions & 0 deletions .github/workflows/compare_translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
"""Script to encourage more efficient coding practices.
Methodology:
Utility for comparing translations between default and other languages.
This module defines a function to compare two translations
and print any missing keys in the other language's translation.
Attributes:
FileTranslation : Named tuple to represent a combination
of file and missing translations.
Fields:
- file (str): The file name.
- missing_translations (list): List of missing translations.
Functions:
compare_translations(default_translation, other_translation):
Compare two translations and print missing keys.
load_translation(filepath):
Load translation from a file.
check_translations():
Load the default translation and compare it with other translations.
main():
The main function to run the script.
Parses command-line arguments, checks for the
existence of the specified directory, and then
calls check_translations with the provided or default directory.
Usage:
This script can be executed to check and print missing
translations in other languages based on the default English translation.
Example:
python compare_translations.py
NOTE:
This script complies with our python3 coding and documentation standards
and should be used as a reference guide. It complies with:
1) Pylint
2) Pydocstyle
3) Pycodestyle
4) Flake8
"""
# standard imports
import argparse
import json
import os
import sys
from collections import namedtuple

# Named tuple for file and missing
# translations combination
FileTranslation = namedtuple("FileTranslation",
["file", "missing_translations"])


def compare_translations(default_translation,
other_translation, default_file, other_file):
"""Compare two translations and return detailed info about missing/mismatched keys.
Args:
default_translation (dict): The default translation (en.json).
other_translation (dict): The other language translation.
default_file (str): The name of the default translation file.
other_file (str): The name of the other
translation file.
Returns:
list: A list of detailed error messages for each missing/mismatched key.
"""
errors = []

# Check for missing keys in other_translation
for key in default_translation:
if key not in other_translation:
error_msg = f"Missing Key: '{key}' - This key from '{default_file}' is missing in '{other_file}'."
errors.append(error_msg)
# Check for keys in other_translation that don't match any in default_translation
for key in other_translation:
if key not in default_translation:
error_msg = f"Error Key: '{key}' - This key in '{other_file}' does not match any key in '{default_file}'."
errors.append(error_msg)
return errors


def load_translation(filepath):
"""Load translation from a file.
Args:
filepath: Path to the translation file
Returns:
translation: Loaded translation
"""
with open(filepath, "r", encoding="utf-8") as file:
translation = json.load(file)
return translation


def check_translations(directory):
"""Load default translation and compare with other translations.
Args:
directory (str): The directory containing translation files.
Returns:
None
"""
default_file = "en.json"
default_translation = load_translation(os.path.join(directory, default_file))
translations = os.listdir(directory)
translations.remove(default_file) # Exclude default translation

error_found = False

for translation_file in translations:
other_file = os.path.join(directory, translation_file)
other_translation = load_translation(other_file)

# Compare translations and get detailed error messages
errors = compare_translations(
default_translation, other_translation, default_file, translation_file
)
if errors:
error_found = True
print(f"File {translation_file} has missing translations for:")
for error in errors:
print(f" - {error}")

if error_found:
sys.exit(1) # Exit with an error status code
else:
print("All translations are present")
sys.exit(0)


def main():
"""
Parse command-line arguments, check for the existence of the specified directory
and call check_translations with the provided or default directory.
"""
parser = argparse.ArgumentParser(
description="Check and print missing translations for all non-default languages."
)
parser.add_argument(
"--directory",
type=str,
nargs="?",
default=os.path.join(os.getcwd(), "public/locales"),
help="Directory containing translation files(relative to the root directory).",
)
args = parser.parse_args()

if not os.path.exists(args.directory):
print(f"Error: The specified directory '{args.directory}' does not exist.")
sys.exit(1)

check_translations(args.directory)


if __name__ == "__main__":
main()
Loading

0 comments on commit 42633e2

Please sign in to comment.