Skip to content

Commit 96d609b

Browse files
Merge with Develop 20240924 (#2554)
* 20240929102658 Deleted all files in the main branch in anticipation of merging develop into main cleanly * 20240929103244 Merge develop into main --------- Co-authored-by: Peter Harrison <[email protected]>
1 parent 4215ea5 commit 96d609b

File tree

193 files changed

+5554
-2919
lines changed

Some content is hidden

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

193 files changed

+5554
-2919
lines changed

.coderabbit.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ reviews:
1313
drafts: false
1414
base_branches:
1515
- develop
16+
- main
1617
chat:
1718
auto_reply: true

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules
22
videos
33
images
4+
data
45
.env
56
.git
67
.gitignore

.env.sample

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ REDIS_HOST=
8484
REDIS_PORT=
8585
REDIS_PASSWORD=
8686

87+
# These environment variables are used to provide MinIo credentials
88+
89+
# The endpoint URL for MinIO server, specifying where the MinIO service is hosted
90+
MINIO_ENDPOINT=
91+
92+
# The username with root-level access for MinIO administration
93+
MINIO_ROOT_USER=
94+
95+
# The password corresponding to the MINIO_ROOT_USER for authentication
96+
MINIO_ROOT_PASSWORD=
97+
98+
# The default bucket name to use with MinIO for storing data
99+
MINIO_BUCKET=
100+
101+
# The local directory where MinIO stores its data files
102+
MINIO_DATA_DIR=
103+
104+
87105
# this environment variable is for setting the environment variable for Image Upload size
88106

89107
IMAGE_SIZE_LIMIT_KB=3000

.eslintrc.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@typescript-eslint/consistent-type-assertions": "error",
2525
"@typescript-eslint/consistent-type-imports": "error",
2626
"@typescript-eslint/explicit-function-return-type": "error",
27-
2827
// Interfaces must begin with Interface or TestInterface followed by a PascalCase name
2928
"@typescript-eslint/naming-convention": [
3029
"error",
@@ -80,7 +79,7 @@
8079
"plugins": ["@graphql-eslint"]
8180
},
8281
{
83-
"files": ["tests/**/*"],
82+
"files": ["tests/**/*", "setup.ts"],
8483
"rules": {
8584
"no-restricted-imports": "off"
8685
}
@@ -107,13 +106,13 @@
107106
],
108107
// restrict the use of same package in multiple import statements
109108
"import/no-duplicates": "error",
110-
111109
// warn/1, error/2, off/0
112110
"tsdoc/syntax": "error",
113-
114111
// Typescript Rules
115112
"@typescript-eslint/ban-ts-comment": "error",
116-
"@typescript-eslint/ban-types": "error",
113+
"@typescript-eslint/no-unsafe-function-type": "error",
114+
"@typescript-eslint/no-wrapper-object-types": "error",
115+
"@typescript-eslint/no-empty-object-type": "error",
117116
"@typescript-eslint/no-duplicate-enum-values": "error",
118117
"@typescript-eslint/no-explicit-any": "warn",
119118
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ If applicable, add screenshots to help explain your problem.
3131
Add any other context or screenshots about the feature request here.
3232

3333
**Potential internship candidates**
34-
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359
34+
35+
Please read this if you are planning to apply for a Palisadoes Foundation internship
36+
- https://github.com/PalisadoesFoundation/talawa/issues/359

.github/ISSUE_TEMPLATE/feature-request.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ A clear and concise description of approach to be followed.
2323
Add any other context or screenshots about the feature request here.
2424

2525
**Potential internship candidates**
26-
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359
26+
27+
Please read this if you are planning to apply for a Palisadoes Foundation internship
28+
- https://github.com/PalisadoesFoundation/talawa/issues/359

.github/workflows/check-tsdoc.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
// List of files to skip
5+
const filesToSkip = [
6+
"app.ts",
7+
"index.ts",
8+
"constants.ts",
9+
"db.ts",
10+
"env.ts",
11+
"logger.ts",
12+
"getSort.ts",
13+
// Add more files to skip as needed
14+
];
15+
16+
// List of directories to skip
17+
const dirsToSkip = [
18+
"typeDefs",
19+
"services",
20+
21+
// Add more directories to skip as needed
22+
];
23+
24+
// Recursively find all .tsx files, excluding files listed in filesToSkip and directories in dirsToSkip
25+
function findTsxFiles(dir) {
26+
let results = [];
27+
try {
28+
const list = fs.readdirSync(dir);
29+
list.forEach((file) => {
30+
const filePath = path.join(dir, file);
31+
const stat = fs.statSync(filePath);
32+
if (stat && stat.isDirectory()) {
33+
// Skip directories in dirsToSkip
34+
if (!dirsToSkip.includes(path.basename(filePath))) {
35+
results = results.concat(findTsxFiles(filePath));
36+
}
37+
} else if (
38+
filePath.endsWith('.ts') &&
39+
!filePath.endsWith('.spec.ts') &&
40+
!filesToSkip.includes(path.relative(dir, filePath))
41+
) {
42+
results.push(filePath);
43+
}
44+
});
45+
} catch (err) {
46+
console.error(`Error reading directory ${dir}: ${err.message}`);
47+
}
48+
return results;
49+
}
50+
51+
// Check if a file contains at least one TSDoc comment
52+
function containsTsDocComment(filePath) {
53+
try {
54+
const content = fs.readFileSync(filePath, 'utf8');
55+
return /\/\*\*[\s\S]*?\*\//.test(content);
56+
} catch (err) {
57+
console.error(`Error reading file ${filePath}: ${err.message}`);
58+
return false;
59+
}
60+
}
61+
62+
// Main function to run the validation
63+
function run() {
64+
const dir = process.argv[2] || './src'; // Allow directory path as a command-line argument
65+
const files = findTsxFiles(dir);
66+
let allValid = true;
67+
68+
files.forEach((file) => {
69+
if (!containsTsDocComment(file)) {
70+
console.error(`No TSDoc comment found in file: ${file}`);
71+
allValid = false;
72+
}
73+
});
74+
75+
if (!allValid) {
76+
process.exit(1);
77+
}
78+
}
79+
80+
run();
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
3+
"""ESLint Checker Script.
4+
5+
Methodology:
6+
7+
Recursively analyzes TypeScript files in the 'src' directory and its subdirectories
8+
as well as 'setup.ts' files to ensure they do not contain eslint-disable statements.
9+
10+
This script enforces code quality practices in the project.
11+
12+
NOTE:
13+
14+
This script complies with our python3 coding and documentation standards.
15+
It complies with:
16+
17+
1) Pylint
18+
2) Pydocstyle
19+
3) Pycodestyle
20+
4) Flake8
21+
22+
"""
23+
24+
import os
25+
import re
26+
import argparse
27+
import sys
28+
29+
def has_eslint_disable(file_path):
30+
"""
31+
Check if a TypeScript file contains eslint-disable statements.
32+
33+
Args:
34+
file_path (str): Path to the TypeScript file.
35+
36+
Returns:
37+
bool: True if eslint-disable statement is found, False otherwise.
38+
"""
39+
eslint_disable_pattern = re.compile(r'//\s*eslint-disable(?:-next-line|-line)?', re.IGNORECASE)
40+
41+
try:
42+
with open(file_path, 'r', encoding='utf-8') as file:
43+
content = file.read()
44+
return bool(eslint_disable_pattern.search(content))
45+
except Exception as e:
46+
print(f"Error reading file {file_path}: {e}")
47+
return False
48+
49+
def check_eslint(directory):
50+
"""
51+
Recursively check TypeScript files for eslint-disable statements in the 'src' directory.
52+
53+
Args:
54+
directory (str): Path to the directory.
55+
56+
Returns:
57+
list: List of files containing eslint-disable statements.
58+
"""
59+
eslint_issues = []
60+
61+
src_dir = os.path.join(directory, 'src')
62+
63+
if not os.path.exists(src_dir):
64+
print(f"Source directory '{src_dir}' does not exist.")
65+
return eslint_issues
66+
67+
for root, dirs, files in os.walk(src_dir):
68+
for file_name in files:
69+
if file_name.endswith('.tsx') and not file_name.endswith('.test.tsx'):
70+
file_path = os.path.join(root, file_name)
71+
if has_eslint_disable(file_path):
72+
eslint_issues.append(f'File {file_path} contains eslint-disable statement.')
73+
74+
setup_path = os.path.join(directory, 'setup.ts')
75+
if os.path.exists(setup_path) and has_eslint_disable(setup_path):
76+
eslint_issues.append(f'Setup file {setup_path} contains eslint-disable statement.')
77+
78+
return eslint_issues
79+
80+
def arg_parser_resolver():
81+
"""Resolve the CLI arguments provided by the user."""
82+
parser = argparse.ArgumentParser()
83+
parser.add_argument(
84+
"--directory",
85+
type=str,
86+
default=os.getcwd(),
87+
help="Path to the directory to check (default: current directory)"
88+
)
89+
return parser.parse_args()
90+
91+
def main():
92+
"""
93+
Execute the script's main functionality.
94+
95+
This function serves as the entry point for the script. It performs
96+
the following tasks:
97+
1. Validates and retrieves the directory to check from
98+
command line arguments.
99+
2. Recursively checks TypeScript files for eslint-disable statements.
100+
3. Provides informative messages based on the analysis.
101+
4. Exits with an error if eslint-disable statements are found.
102+
103+
Raises:
104+
SystemExit: If an error occurs during execution.
105+
"""
106+
args = arg_parser_resolver()
107+
if not os.path.exists(args.directory):
108+
print(f"Error: The specified directory '{args.directory}' does not exist.")
109+
sys.exit(1)
110+
111+
eslint_issues = check_eslint(args.directory)
112+
113+
if eslint_issues:
114+
for issue in eslint_issues:
115+
print(issue)
116+
print("ESLint-disable check failed. Exiting with error.")
117+
sys.exit(1)
118+
119+
print("ESLint-disable check completed successfully.")
120+
sys.exit(0)
121+
122+
if __name__ == "__main__":
123+
main()

.github/workflows/md_mdx_format_adjuster.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
3) Pycodestyle
1313
4) Flake8
1414
"""
15-
1615
import os
1716
import argparse
1817
import re

.github/workflows/pull-request.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ jobs:
3232
- name: Set up Node.js
3333
uses: actions/setup-node@v4
3434
with:
35-
node-version: '20.x'
35+
node-version: '22.x'
3636

3737
- name: Count number of lines
3838
run: |
3939
chmod +x ./.github/workflows/countline.py
4040
./.github/workflows/countline.py --lines 600 --exclude_files src/types/generatedGraphQLTypes.ts tests src/typeDefs/types.ts src/constants.ts
4141
42+
- name: Check for TSDoc comments
43+
run: npm run check-tsdoc # Run the TSDoc check script
44+
4245
- name: Restore node_modules from cache
4346
id: cache-npm
4447
uses: actions/cache@v4
@@ -71,7 +74,7 @@ jobs:
7174
if: steps.changed_files.outputs.any_changed == 'true'
7275
env:
7376
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
74-
run: npx eslint ${CHANGED_FILES}
77+
run: npx eslint ${CHANGED_FILES} --max-warnings=1500 && python .github/workflows/eslint_disable_check.py
7578

7679
- name: Check for formatting errors
7780
run: npm run format:check
@@ -171,7 +174,7 @@ jobs:
171174
needs: [Code-Quality-Checks]
172175
strategy:
173176
matrix:
174-
node-version: [20.x]
177+
node-version: [22.x]
175178
services:
176179
mongo:
177180
image: mongo:4.4
@@ -216,7 +219,7 @@ jobs:
216219
- name: Set up Node.js
217220
uses: actions/setup-node@v4
218221
with:
219-
node-version: '20.x'
222+
node-version: '22.x'
220223

221224
- name: Generate Access Token Secret
222225
run: echo "ACCESS_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV

0 commit comments

Comments
 (0)